roam-commit Mailing List for Roam, a Windows Mobile library (Page 3)
Status: Alpha
Brought to you by:
jonfroehlich
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
(9) |
Apr
(10) |
May
|
Jun
|
Jul
(10) |
Aug
(1) |
Sep
(7) |
Oct
(4) |
Nov
(6) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(1) |
Feb
(9) |
Mar
(11) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <jon...@us...> - 2007-07-30 00:09:13
|
Revision: 88
http://roam.svn.sourceforge.net/roam/?rev=88&view=rev
Author: jonfroehlich
Date: 2007-07-29 17:09:11 -0700 (Sun, 29 Jul 2007)
Log Message:
-----------
1. added some comments to FillRoundedRectangle (it's been so long since i used the class, i even forgot what all the constructor params meant)
2. updated some utils classes with a few new functions (IsLetterOrNumber in KeyUtils and DestroyWindow in WindowUtils)
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/KeyUtils.cs
Trunk/Source/Roam.Common/Utils/WindowUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Common/Utils/KeyUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/KeyUtils.cs 2007-07-25 06:31:17 UTC (rev 87)
+++ Trunk/Source/Roam.Common/Utils/KeyUtils.cs 2007-07-30 00:09:11 UTC (rev 88)
@@ -56,6 +56,17 @@
}
}
+ public static bool IsLetter(Keys keycode)
+ {
+ if ((keycode >= Keys.A && keycode <= Keys.Z)) { return true; }
+ else { return false; }
+ }
+
+ public static bool IsLetterOrNumber(Keys keycode)
+ {
+ return IsLetter(keycode) && IsNumber(keycode);
+ }
+
/// <summary>
/// Returns the number that maps to the keycode or -1
/// if the keycode is not a number
Modified: Trunk/Source/Roam.Common/Utils/WindowUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-25 06:31:17 UTC (rev 87)
+++ Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-30 00:09:11 UTC (rev 88)
@@ -172,6 +172,22 @@
}
/// <summary>
+ /// This function destroys the specified window. The function sends a WM_DESTROY message to the window to
+ /// deactivate it and removes the keyboard focus from it. The function also destroys the window's menu,
+ /// destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window
+ /// is at the top of the viewer chain).
+ ///
+ /// If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated
+ /// child or owned windows when it destroys the parent or owner window. The function first destroys child or
+ /// owned windows, and then it destroys the parent or owner window.
+ ///
+ /// DestroyWindow also destroys modeless dialog boxes created by the CreateDialog function.
+ /// </summary>
+ /// <param name="hWnd">[in] Handle to the window to be destroyed. </param>
+ /// <returns>true if the window is destroyed, false otherwise</returns>
+ public static extern bool DestroyWindow(IntPtr hWnd);
+
+ /// <summary>
/// This function returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is
/// the area on top of which all icons and other windows are painted.
/// </summary>
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-07-25 06:31:17 UTC (rev 87)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-07-30 00:09:11 UTC (rev 88)
@@ -533,7 +533,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs 2007-07-25 06:31:17 UTC (rev 87)
+++ Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs 2007-07-30 00:09:11 UTC (rev 88)
@@ -39,16 +39,63 @@
#endregion Fields
#region Constructors
+
+ /// <summary>
+ /// Creates a FillRoundedRectangle object with the given back color. The forecolor defaults
+ /// to black and the pen width to 1
+ /// </summary>
+ /// <param name="backColor">the rounded rectangle backcolor</param>
public FillRoundedRectangle(Color backColor) : this(backColor, Color.Black, 1) { }
+
+ /// <summary>
+ /// Creates a FillRoundedRectangle object with the given back and fore colors. The
+ /// pen width defaults to 1.
+ /// </summary>
+ /// <param name="backColor">the rounded rectangle backcolor</param>
+ /// <param name="foreColor">the rounded rectangle outline color</param>
public FillRoundedRectangle(Color backColor, Color foreColor) : this(backColor, foreColor, 1) { }
+
+ /// <summary>
+ /// Creates a FillRoundedRectangle object with the given back and fore colors.
+ /// </summary>
+ /// <param name="backColor">the rounded rectangle backcolor</param>
+ /// <param name="foreColor">the rounded rectangle outline color</param>
+ /// <param name="alphaBlend">the amount of opacity given to the fill color</param>
public FillRoundedRectangle(Color backColor, Color foreColor, float alphaBlend)
: this(backColor, foreColor, 5, 5, alphaBlend) { }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="backColor"></param>
+ /// <param name="foreColor"></param>
+ /// <param name="roundedCornerWidth"></param>
+ /// <param name="roundedCornerHeight"></param>
public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight)
: this(backColor, foreColor, roundedCornerWidth, roundedCornerHeight, 1) { }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="backColor"></param>
+ /// <param name="foreColor"></param>
+ /// <param name="roundedCornerWidth"></param>
+ /// <param name="roundedCornerHeight"></param>
+ /// <param name="penWidth"></param>
public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight, float penWidth)
: this(backColor, foreColor, roundedCornerWidth, roundedCornerHeight, 1, 0)
{
}
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="backColor"></param>
+ /// <param name="foreColor"></param>
+ /// <param name="roundedCornerWidth"></param>
+ /// <param name="roundedCornerHeight"></param>
+ /// <param name="penWidth"></param>
+ /// <param name="alphaBlend"></param>
public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight, float penWidth, float alphaBlend)
: base(alphaBlend, backColor)
{
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-25 06:31:18
|
Revision: 87
http://roam.svn.sourceforge.net/roam/?rev=87&view=rev
Author: jonfroehlich
Date: 2007-07-24 23:31:17 -0700 (Tue, 24 Jul 2007)
Log Message:
-----------
attempted to squash bug #1706500 found by sakowiczm, which is: I forgot to finish my implementation of SqlCeWrapper. I left both the Open/Close methods unfinished. I completed this and added a reference count property which counts the number of open connections. I have not yet tested these changes.
Modified Paths:
--------------
Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs
===================================================================
--- Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs 2007-07-24 07:40:33 UTC (rev 86)
+++ Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs 2007-07-25 06:31:17 UTC (rev 87)
@@ -33,13 +33,30 @@
{
private static SqlCeConnection _sqlCeConnection;
private static object _objLock = new object();
+ private static int _referenceCount = 0;
+ public static int ReferenceCount
+ {
+ get { return _referenceCount; }
+ }
+
+ public static bool IsOpened
+ {
+ get { return _sqlCeConnection != null; }
+ }
+
public static void Open(string connectionString)
{
lock (_objLock)
{
- if (_sqlCeConnection != null) throw new InvalidOperationException("Connection already open.");
- _sqlCeConnection = new SqlCeConnection(connectionString);
+ if (_sqlCeConnection != null )
+ {
+ _sqlCeConnection = new SqlCeConnection(connectionString);
+ _referenceCount = 0;
+ }
+
+ _sqlCeConnection.Open();
+ _referenceCount++;
}
}
@@ -47,10 +64,14 @@
{
lock (_objLock)
{
- if (_sqlCeConnection != null)
+ _referenceCount--;
+
+ if (_sqlCeConnection != null && _referenceCount <= 0)
{
+ _sqlCeConnection.Close();
_sqlCeConnection.Dispose();
_sqlCeConnection = null;
+ _referenceCount = 0;
}
}
}
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-24 07:40:36
|
Revision: 86
http://roam.svn.sourceforge.net/roam/?rev=86&view=rev
Author: jonfroehlich
Date: 2007-07-24 00:40:33 -0700 (Tue, 24 Jul 2007)
Log Message:
-----------
1. updated Buffer AddRange (untested)
2. added StandardDeviation to MathUtils
Modified Paths:
--------------
Trunk/Source/Roam.Common/Collections/Buffer.cs
Trunk/Source/Roam.Common/Utils/MathUtils.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Common/Collections/Buffer.cs
===================================================================
--- Trunk/Source/Roam.Common/Collections/Buffer.cs 2007-07-23 07:25:14 UTC (rev 85)
+++ Trunk/Source/Roam.Common/Collections/Buffer.cs 2007-07-24 07:40:33 UTC (rev 86)
@@ -20,7 +20,8 @@
namespace Roam.Common.Collections
{
/// <summary>
- ///
+ /// A finite sized memory structure. When the MaxItems count is reached, the next object added
+ /// to the buffer causes the first item to be removed (in a FIFO fashion).
/// </summary>
/// <remarks>
///
@@ -134,10 +135,23 @@
public virtual void AddRange(T[] items)
{
- while (_listItems.Count + items.Length >= _maxItems)
+ //jeffixme test this method
+ if (items.Length >= _maxItems)
{
- _listItems.RemoveFirst();
+ _listItems.Clear();
+ int startIndex = items.Length - _maxItems;
+ for (int i = 0; i < _maxItems; i++)
+ {
+ _listItems.AddLast(items[startIndex + i]);
+ }
}
+ else
+ {
+ while (_listItems.Count + items.Length >= _maxItems)
+ {
+ _listItems.RemoveFirst();
+ }
+ }
foreach (T t in items)
{
Modified: Trunk/Source/Roam.Common/Utils/MathUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-07-23 07:25:14 UTC (rev 85)
+++ Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-07-24 07:40:33 UTC (rev 86)
@@ -86,6 +86,22 @@
return S / (n - 1);
}
+ /// <summary>
+ /// To understand standard deviation, keep in mind that variance is the average of the squared
+ /// differences between data points and the mean. Variance is tabulated in units squared.
+ /// Standard deviation, being the square root of that quantity, therefore measures the spread
+ /// of data about the mean, measured in the same units as the data.
+ /// </summary>
+ /// <param name="values"></param>
+ /// <returns></returns>
+ public static double StandardDeviation(ICollection<double> values)
+ {
+ double variance = Variance(values);
+ //the standard deviation is the square root of the variance
+ //http://en.wikipedia.org/wiki/Standard_deviation
+ return Math.Sqrt(variance);
+ }
+
public static Pair<double, double> MinMax(ICollection<double> values)
{
double max = double.MinValue;
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-23 07:25:16
|
Revision: 85
http://roam.svn.sourceforge.net/roam/?rev=85&view=rev
Author: jonfroehlich
Date: 2007-07-23 00:25:14 -0700 (Mon, 23 Jul 2007)
Log Message:
-----------
1. changed some float types to double in MathUtils
2. added WindowsMobile.Location dll to Library
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/MathUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Library/Release/Microsoft.WindowsMobile.Location.dll
Trunk/Library/Release/Microsoft.WindowsMobile.Location.pdb
Property Changed:
----------------
Trunk/Samples/WallpaperChanger/
Added: Trunk/Library/Release/Microsoft.WindowsMobile.Location.dll
===================================================================
(Binary files differ)
Property changes on: Trunk/Library/Release/Microsoft.WindowsMobile.Location.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Trunk/Library/Release/Microsoft.WindowsMobile.Location.pdb
===================================================================
(Binary files differ)
Property changes on: Trunk/Library/Release/Microsoft.WindowsMobile.Location.pdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Property changes on: Trunk/Samples/WallpaperChanger
___________________________________________________________________
Name: svn:ignore
+ bin
obj
Modified: Trunk/Source/Roam.Common/Utils/MathUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-07-21 06:19:34 UTC (rev 84)
+++ Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-07-23 07:25:14 UTC (rev 85)
@@ -28,8 +28,7 @@
/// <author>Jon Froehlich</author>
public static class MathUtils
{
-
- public static double GetDistance(Point ptStart, Point ptEnd)
+ public static double GetEuclideanDistance(Point ptStart, Point ptEnd)
{
int xDiff = ptEnd.X - ptStart.X;
int yDiff = ptEnd.Y - ptStart.Y;
@@ -42,27 +41,27 @@
/// <param name="ptStart"></param>
/// <param name="ptEnd"></param>
/// <returns></returns>
- public static float GetAngle(Point ptStart, Point ptEnd)
+ public static double GetAngle(Point ptStart, Point ptEnd)
{
Vector2 v = new Vector2(1,0);
Vector2 w = new Vector2(ptEnd.X - ptStart.X, ptEnd.Y - ptStart.Y);
- float angleRad = v.GetAngle(w);
+ double angleRad = v.GetAngle(w);
if(w.X < 0 && w.Y > 0 || w.X >=0 && w.Y >= 0){
- angleRad = (float)((System.Math.PI * 2) - angleRad);
+ angleRad = (System.Math.PI * 2) - angleRad;
}
return angleRad;
}
- public static float DegreesToRadians(float degrees)
+ public static double DegreesToRadians(double degrees)
{
- return (float)(degrees * System.Math.PI / 180f);
+ return degrees * System.Math.PI / 180.0;
}
- public static float RadiansToDegrees(float radians)
+ public static double RadiansToDegrees(double radians)
{
- return (float)(radians * 180 / System.Math.PI);
+ return radians * 180.0 / System.Math.PI;
}
public static double Variance(ICollection<double> values)
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-21 06:19:48
|
Revision: 84
http://roam.svn.sourceforge.net/roam/?rev=84&view=rev
Author: jonfroehlich
Date: 2007-07-20 23:19:34 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
1. added PowerNotificationUIThread.cs which simply calls the EventHandler delegate in the UI thread
2. added some overloaded constructors to NumericTextBox and TextBox
3. added WallpaperChanger sample, see http://csharponphone.blogspot.com/2007/07/wallpaper-screenshots-and-application.html
Modified Paths:
--------------
Trunk/Source/Roam/Utils/PerformanceUtils.cs
Trunk/Source/Roam/Utils/PowerNotification.cs
Trunk/Source/Roam.UI/Controls/NumericTextBox.cs
Trunk/Source/Roam.UI/Controls/TextBox.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Samples/
Trunk/Samples/Samples.sln
Trunk/Samples/Samples.suo
Trunk/Samples/WallpaperChanger/
Trunk/Samples/WallpaperChanger/CapturedScreenForm.cs
Trunk/Samples/WallpaperChanger/CapturedScreenForm.designer.cs
Trunk/Samples/WallpaperChanger/CapturedScreenForm.resx
Trunk/Samples/WallpaperChanger/Form1.cs
Trunk/Samples/WallpaperChanger/Form1.designer.cs
Trunk/Samples/WallpaperChanger/Form1.resx
Trunk/Samples/WallpaperChanger/Program.cs
Trunk/Samples/WallpaperChanger/Properties/
Trunk/Samples/WallpaperChanger/Properties/AssemblyInfo.cs
Trunk/Samples/WallpaperChanger/Properties/Resources.Designer.cs
Trunk/Samples/WallpaperChanger/Properties/Resources.resx
Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj
Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj.user
Trunk/Source/Roam.UI/Utils/PowerNotificationUIThread.cs
Added: Trunk/Samples/Samples.sln
===================================================================
--- Trunk/Samples/Samples.sln (rev 0)
+++ Trunk/Samples/Samples.sln 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WallpaperChanger", "WallpaperChanger\WallpaperChanger.csproj", "{4958E328-69B8-4E0C-A669-73E0DB11C071}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4958E328-69B8-4E0C-A669-73E0DB11C071}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4958E328-69B8-4E0C-A669-73E0DB11C071}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4958E328-69B8-4E0C-A669-73E0DB11C071}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {4958E328-69B8-4E0C-A669-73E0DB11C071}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4958E328-69B8-4E0C-A669-73E0DB11C071}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4958E328-69B8-4E0C-A669-73E0DB11C071}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: Trunk/Samples/Samples.suo
===================================================================
(Binary files differ)
Property changes on: Trunk/Samples/Samples.suo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Trunk/Samples/WallpaperChanger/CapturedScreenForm.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/CapturedScreenForm.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/CapturedScreenForm.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,50 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace WallpaperChanger
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public partial class CapturedScreenForm : Form
+ {
+ public CapturedScreenForm(Bitmap bm)
+ : this()
+ {
+ _pictureBox.Image = bm;
+ }
+
+ public CapturedScreenForm()
+ {
+ InitializeComponent();
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/CapturedScreenForm.designer.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/CapturedScreenForm.designer.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/CapturedScreenForm.designer.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,73 @@
+namespace WallpaperChanger
+{
+ partial class CapturedScreenForm
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this._pictureBox = new System.Windows.Forms.PictureBox();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // _pictureBox
+ //
+ this._pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._pictureBox.Location = new System.Drawing.Point(0, 0);
+ this._pictureBox.Name = "_pictureBox";
+ this._pictureBox.Size = new System.Drawing.Size(240, 266);
+ this._pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ //
+ // CapturedScreenForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._pictureBox);
+ this.Menu = this.mainMenu1;
+ this.Name = "CapturedScreenForm";
+ this.Text = "CapturedScreenForm";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.PictureBox _pictureBox;
+ }
+}
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/CapturedScreenForm.resx
===================================================================
--- Trunk/Samples/WallpaperChanger/CapturedScreenForm.resx (rev 0)
+++ Trunk/Samples/WallpaperChanger/CapturedScreenForm.resx 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/Form1.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/Form1.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/Form1.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,241 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.UI.Utils;
+using Roam.Utils;
+using Roam.Common.Utils;
+using System.Threading;
+using System.Diagnostics;
+using Roam.UI.Forms;
+using Roam.UI.Controls;
+
+namespace WallpaperChanger
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public partial class Form1 : Form
+ {
+ private PowerNotificationUIThread _powerNotification;
+ private WindowUtils.EnumWindowsProc _enumWindowsProc;
+ private Bitmap _capturedScreen;
+
+ public Form1()
+ {
+ InitializeComponent();
+ _textBoxFilteredList.ShowAddButton = false;
+ //_textBoxFilteredList.Items.Add("Internet Explorer");
+ //_textBoxFilteredList.Items.Add("Opera");
+ //_textBoxFilteredList.Items.Add("Contacts");
+ //_textBoxFilteredList.Items.Add("Call History");
+ //_textBoxFilteredList.Items.Add("Text Messages");
+ _powerNotification = new PowerNotificationUIThread(this);
+ _powerNotification.PowerNotificationEvent += new EventHandler<PowerNotificationEventArgs>(OnPowerNotificationEvent);
+ _enumWindowsProc = new WindowUtils.EnumWindowsProc(OnEnumWindows);
+ WindowUtils.EnumWindows(_enumWindowsProc);
+ }
+
+ private void OnPowerNotificationEvent(object sender, PowerNotificationEventArgs e)
+ {
+ string powerMessage = e.PowerBroadcast.GetSystemPowerStateAsString();
+ bool isDeviceIdleMessage = IsDeviceIdleMessage(powerMessage);
+ Debug.WriteLine("Power message: " + powerMessage);
+
+ if (_menuItemStartAfterDeviceIdle.Checked && isDeviceIdleMessage)
+ {
+ _menuItemStartAfterDeviceIdle.Checked = false;
+ SwitchWallpaper();
+ int success = PowerUtils.SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Idle, PowerUtils.POWER_FORCE);
+ //we could also try the Idle2 flag :)
+ //PowerUtils.SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Idle2, PowerUtils.POWER_FORCE);
+ }
+ }
+
+ private bool IsDeviceIdleMessage(string powerMessage)
+ {
+ //device idle messages I have seen:
+ //backlightoff
+ //screenoff
+ //useridle
+ return powerMessage.IndexOf("idle") != -1 || powerMessage.IndexOf("off") != -1;
+ }
+
+ private void SwitchWallpaper()
+ {
+ string windowTitleToMatch = _textBoxFilteredList.SelectedText;
+ Debug.WriteLine("Looking for hwnd to " + windowTitleToMatch);
+ IntPtr matchingHwnd = WindowUtils.FindWindow(windowTitleToMatch);
+
+ if (matchingHwnd != IntPtr.Zero)
+ {
+ Debug.WriteLine(string.Format("FindWindow returned hwnd={0} title={1} when looking for {2}",
+ matchingHwnd, WindowUtils.GetWindowText(matchingHwnd), windowTitleToMatch));
+
+ IntPtr currentForegroundWindow = WindowUtils.GetForegroundWindow();
+ Debug.WriteLine(string.Format("The current foreground window hwnd={0} title={1}",
+ currentForegroundWindow, WindowUtils.GetWindowText(currentForegroundWindow)));
+
+ SetForegroundWindow(matchingHwnd);
+ Application.DoEvents();
+ Thread.Sleep(100);
+ if (_capturedScreen != null) { _capturedScreen.Dispose(); }
+ _capturedScreen = ScreenUtils.CaptureScreen();
+
+ //crop bitmap
+ Bitmap bmCropped = new Bitmap(_cropRect.Width, _cropRect.Height);
+ Graphics g = Graphics.FromImage(bmCropped);
+ g.DrawImage(_capturedScreen,
+ new Rectangle(0, 0, bmCropped.Width, bmCropped.Height),
+ _cropRect, GraphicsUnit.Pixel);
+ _capturedScreen.Dispose();
+ g.Dispose();
+ _capturedScreen = bmCropped;
+
+ DesktopUtils.SetWallpaper(_capturedScreen, @"\Storage Card\bgimagefile.jpg");
+ IntPtr hWndDesktop = WindowUtils.GetDesktopWindow();
+
+ //wait for this to occur as well
+ SetForegroundWindow(hWndDesktop);
+ Thread.Sleep(1000);
+ SetForegroundWindow(currentForegroundWindow);
+ }
+ else
+ {
+ Debug.WriteLine(string.Format("FindWindow returned hwnd={0} when looking for {1}",
+ matchingHwnd, windowTitleToMatch));
+ }
+ }
+
+ private void SetForegroundWindow(IntPtr hwnd)
+ {
+ //wait until window switch is complete or time threshold exceeded
+ string title = WindowUtils.GetWindowText(hwnd);
+ Debug.WriteLine(string.Format("Attempting to set hwnd={0} title={1} to foreground",
+ hwnd, title));
+ bool successfullySwitchedForeground = WindowUtils.SetForegroundWindow(hwnd);
+
+ TimeSpan timeThreshold = TimeSpan.FromSeconds(10);
+ DateTime start = DateTime.Now;
+ while (WindowUtils.GetForegroundWindow() != hwnd &&
+ (TimeSpan)(DateTime.Now - start) < timeThreshold)
+ {
+ Debug.WriteLine(string.Format("Failed to switch to hwnd={0} title={1}. SetForegroundWindow returned {2}",
+ hwnd, title, successfullySwitchedForeground));
+
+ Thread.Sleep(1000);
+ successfullySwitchedForeground = WindowUtils.SetForegroundWindow(hwnd);
+ }
+ //Debug.WriteLine("Time: " + (TimeSpan)(DateTime.Now - start));
+ Debug.WriteLine(string.Format("CurrentForegroundWindow={0}, WaitingForWindow={1}, Foreground=Desired? {2}",
+ WindowUtils.GetForegroundWindow(), hwnd, hwnd == WindowUtils.GetForegroundWindow()));
+ }
+
+
+ private int OnEnumWindows(IntPtr hWnd, IntPtr lParam)
+ {
+ string windowText = WindowUtils.GetWindowText(hWnd);
+ if (!string.IsNullOrEmpty(windowText))
+ {
+ int index = _textBoxFilteredList.Items.Add(windowText);
+ _textBoxFilteredList.Items[index].Font = _textBoxFilteredList.Font;
+ }
+ return 1;
+ }
+
+ private void OnMenuItemExit(object sender, EventArgs e)
+ {
+ this.Close();
+ Application.Exit();
+ }
+
+ private void OnMenuItemStartNow(object sender, EventArgs e)
+ {
+ //_windowTitleToMatch = _textBoxFilteredList.
+ //WindowUtils.EnumWindows(_enumWindowsProc);
+ Cursor.Current = Cursors.WaitCursor;
+ SwitchWallpaper();
+ Cursor.Current = Cursors.Default;
+ }
+
+ private void OnMenuItemStartAfterDeviceIdle(object sender, EventArgs e)
+ {
+ //after idle
+ _menuItemStartAfterDeviceIdle.Checked = !_menuItemStartAfterDeviceIdle.Checked;
+ }
+
+ private void OnMenuItemUpdateWindowTitleList(object sender, EventArgs e)
+ {
+ _textBoxFilteredList.RemoveFilteredItems();
+ _textBoxFilteredList.Items.Clear();
+ WindowUtils.EnumWindows(_enumWindowsProc);
+ }
+
+ private void OnMenuItemClearWindowTitleList(object sender, EventArgs e)
+ {
+ _textBoxFilteredList.RemoveFilteredItems();
+ _textBoxFilteredList.Items.Clear();
+ }
+
+ private void OnMenuItemViewCapturedScreen(object sender, EventArgs e)
+ {
+ CapturedScreenForm csf = new CapturedScreenForm(_capturedScreen);
+ csf.ShowDialog();
+ }
+
+ private void OnMenuItemForceDeviceIdle(object sender, EventArgs e)
+ {
+ PowerUtils.SetSystemPowerState(IntPtr.Zero, PowerStateFlags.Idle2, PowerUtils.POWER_FORCE);
+ }
+
+ private void OnMenuItemMoveSelectedWindowToForeground(object sender, EventArgs e)
+ {
+ IntPtr hWnd = WindowUtils.FindWindow(_textBoxFilteredList.SelectedText);
+ if (hWnd != IntPtr.Zero)
+ {
+ WindowUtils.SetForegroundWindow(hWnd);
+ }
+ }
+
+ private Rectangle _cropRect = new Rectangle(0, 0, 240, 320);
+ private void OnCaptureCropDimensions(object sender, EventArgs e)
+ {
+ LabelControlPair lcpX = new LabelControlPair("X: ", new NumericTextBox(false, true, _cropRect.X));
+ LabelControlPair lcpY = new LabelControlPair("Y: ", new NumericTextBox(false, true, _cropRect.Y));
+ LabelControlPair lcpWidth = new LabelControlPair("Width: ", new NumericTextBox(false, true, _cropRect.Width));
+ LabelControlPair lcpHeight = new LabelControlPair("Height: ", new NumericTextBox(false, true, _cropRect.Height));
+
+ Form form = FormFactory.Create(new LabelControlPair[] { lcpX, lcpY, lcpWidth, lcpHeight });
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ _cropRect = new Rectangle(
+ ((NumericTextBox)(lcpX.Element2)).TextAsInt,
+ ((NumericTextBox)(lcpY.Element2)).TextAsInt,
+ ((NumericTextBox)(lcpWidth.Element2)).TextAsInt,
+ ((NumericTextBox)(lcpHeight.Element2)).TextAsInt);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/Form1.designer.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/Form1.designer.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/Form1.designer.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,181 @@
+using Roam.UI.Controls;
+namespace WallpaperChanger
+{
+ partial class Form1
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this._menuItemStartNow = new System.Windows.Forms.MenuItem();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this._menuItemClearWindowTitleList = new System.Windows.Forms.MenuItem();
+ this._updateWindowTitleList = new System.Windows.Forms.MenuItem();
+ this._menuItemMoveSelectedWindowToForeground = new System.Windows.Forms.MenuItem();
+ this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this._menuItemForceDeviceIdle = new System.Windows.Forms.MenuItem();
+ this._menuItemStartAfterDeviceIdle = new System.Windows.Forms.MenuItem();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this._menuItemViewCapturedScreen = new System.Windows.Forms.MenuItem();
+ this.menuItem6 = new System.Windows.Forms.MenuItem();
+ this._textBoxFilteredList = new Roam.UI.Controls.TextBoxFilteredList();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Segoe Condensed", 8F, System.Drawing.FontStyle.Regular);
+ this.label1.Location = new System.Drawing.Point(4, 4);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(207, 19);
+ this.label1.Text = "Window Title to Search For:";
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.OnMenuItemExit);
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this._menuItemStartNow);
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.MenuItems.Add(this.menuItem4);
+ this.menuItem2.MenuItems.Add(this.menuItem5);
+ this.menuItem2.Text = "Menu";
+ //
+ // _menuItemStartNow
+ //
+ this._menuItemStartNow.Text = "Start Now";
+ this._menuItemStartNow.Click += new System.EventHandler(this.OnMenuItemStartNow);
+ //
+ // menuItem3
+ //
+ this.menuItem3.MenuItems.Add(this._menuItemClearWindowTitleList);
+ this.menuItem3.MenuItems.Add(this._updateWindowTitleList);
+ this.menuItem3.MenuItems.Add(this._menuItemMoveSelectedWindowToForeground);
+ this.menuItem3.Text = "Window List";
+ //
+ // _menuItemClearWindowTitleList
+ //
+ this._menuItemClearWindowTitleList.Text = "Clear list";
+ this._menuItemClearWindowTitleList.Click += new System.EventHandler(this.OnMenuItemClearWindowTitleList);
+ //
+ // _updateWindowTitleList
+ //
+ this._updateWindowTitleList.Text = "Update Window Title List";
+ this._updateWindowTitleList.Click += new System.EventHandler(this.OnMenuItemUpdateWindowTitleList);
+ //
+ // _menuItemMoveSelectedWindowToForeground
+ //
+ this._menuItemMoveSelectedWindowToForeground.Text = "Selected Window To Foreground";
+ this._menuItemMoveSelectedWindowToForeground.Click += new System.EventHandler(this.OnMenuItemMoveSelectedWindowToForeground);
+ //
+ // menuItem4
+ //
+ this.menuItem4.MenuItems.Add(this._menuItemForceDeviceIdle);
+ this.menuItem4.MenuItems.Add(this._menuItemStartAfterDeviceIdle);
+ this.menuItem4.Text = "Device Idle";
+ //
+ // _menuItemForceDeviceIdle
+ //
+ this._menuItemForceDeviceIdle.Text = "Force Device Idle";
+ this._menuItemForceDeviceIdle.Click += new System.EventHandler(this.OnMenuItemForceDeviceIdle);
+ //
+ // _menuItemStartAfterDeviceIdle
+ //
+ this._menuItemStartAfterDeviceIdle.Checked = true;
+ this._menuItemStartAfterDeviceIdle.Text = "Start After Device Idle";
+ this._menuItemStartAfterDeviceIdle.Click += new System.EventHandler(this.OnMenuItemStartAfterDeviceIdle);
+ //
+ // menuItem5
+ //
+ this.menuItem5.MenuItems.Add(this._menuItemViewCapturedScreen);
+ this.menuItem5.MenuItems.Add(this.menuItem6);
+ this.menuItem5.Text = "Captured Screen";
+ //
+ // _menuItemViewCapturedScreen
+ //
+ this._menuItemViewCapturedScreen.Text = "View Captured Screen";
+ this._menuItemViewCapturedScreen.Click += new System.EventHandler(this.OnMenuItemViewCapturedScreen);
+ //
+ // menuItem6
+ //
+ this.menuItem6.Text = "Capture Crop Dimensions";
+ this.menuItem6.Click += new System.EventHandler(this.OnCaptureCropDimensions);
+ //
+ // _textBoxFilteredList
+ //
+ this._textBoxFilteredList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this._textBoxFilteredList.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._textBoxFilteredList.Location = new System.Drawing.Point(4, 22);
+ this._textBoxFilteredList.Name = "_textBoxFilteredList";
+ this._textBoxFilteredList.Size = new System.Drawing.Size(233, 241);
+ this._textBoxFilteredList.TabIndex = 0;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._textBoxFilteredList);
+ this.Controls.Add(this.label1);
+ this.Menu = this.mainMenu1;
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private Roam.UI.Controls.TextBoxFilteredList _textBoxFilteredList;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem _menuItemStartNow;
+ private System.Windows.Forms.MenuItem _menuItemStartAfterDeviceIdle;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.MenuItem _updateWindowTitleList;
+ private System.Windows.Forms.MenuItem _menuItemClearWindowTitleList;
+ private System.Windows.Forms.MenuItem _menuItemViewCapturedScreen;
+ private System.Windows.Forms.MenuItem _menuItemForceDeviceIdle;
+ private System.Windows.Forms.MenuItem _menuItemMoveSelectedWindowToForeground;
+ private System.Windows.Forms.MenuItem menuItem3;
+ private System.Windows.Forms.MenuItem menuItem4;
+ private System.Windows.Forms.MenuItem menuItem5;
+ private System.Windows.Forms.MenuItem menuItem6;
+ }
+}
+
Added: Trunk/Samples/WallpaperChanger/Form1.resx
===================================================================
--- Trunk/Samples/WallpaperChanger/Form1.resx (rev 0)
+++ Trunk/Samples/WallpaperChanger/Form1.resx 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/Program.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/Program.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/Program.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,39 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+namespace WallpaperChanger
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [MTAThread]
+ static void Main()
+ {
+ Application.Run(new Form1());
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/Properties/AssemblyInfo.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/Properties/AssemblyInfo.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/Properties/AssemblyInfo.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("WallpaperChanger")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WallpaperChanger")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e38eba99-4619-4de5-9f2e-0c85c79a30ff")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+
Added: Trunk/Samples/WallpaperChanger/Properties/Resources.Designer.cs
===================================================================
--- Trunk/Samples/WallpaperChanger/Properties/Resources.Designer.cs (rev 0)
+++ Trunk/Samples/WallpaperChanger/Properties/Resources.Designer.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,68 @@
+//------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.832
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+//------------------------------------------------------------------------------
+
+namespace WallpaperChanger.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the Strongly Typed Resource Builder
+ // class via a tool like ResGen or Visual Studio.NET.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ class Resources
+ {
+
+ private static System.Resources.ResourceManager _resMgr;
+
+ private static System.Globalization.CultureInfo _resCulture;
+
+ /*FamANDAssem*/
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((_resMgr == null))
+ {
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("WallpaperChanger.Properties.Resources", typeof(Resources).Assembly);
+ _resMgr = temp;
+ }
+ return _resMgr;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return _resCulture;
+ }
+ set
+ {
+ _resCulture = value;
+ }
+ }
+ }
+}
Added: Trunk/Samples/WallpaperChanger/Properties/Resources.resx
===================================================================
--- Trunk/Samples/WallpaperChanger/Properties/Resources.resx (rev 0)
+++ Trunk/Samples/WallpaperChanger/Properties/Resources.resx 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj
===================================================================
--- Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj (rev 0)
+++ Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,119 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4958E328-69B8-4E0C-A669-73E0DB11C071}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>WallpaperChanger</RootNamespace>
+ <AssemblyName>WallpaperChanger</AssemblyName>
+ <ProjectTypeGuids>{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <PlatformFamilyName>Smartphone</PlatformFamilyName>
+ <PlatformID>BD0CC567-F6FD-4ca3-99D2-063EFDFC0A39</PlatformID>
+ <OSVersion>5.01</OSVersion>
+ <DeployDirSuffix>WallpaperChanger</DeployDirSuffix>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FormFactorID>
+ </FormFactorID>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;$(PlatformFamilyName)</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <FileAlignment>512</FileAlignment>
+ <WarningLevel>4</WarningLevel>
+ <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE;$(PlatformFamilyName)</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <FileAlignment>512</FileAlignment>
+ <WarningLevel>4</WarningLevel>
+ <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="mscorlib" />
+ <Reference Include="OpenNETCF.WindowsCE, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\Research\Roam\Trunk\Source\Roam.UI\bin\Release\OpenNETCF.WindowsCE.dll</HintPath>
+ </Reference>
+ <Reference Include="Roam, Version=1.0.2755.40810, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\Source\Roam.UI\bin\Release\Roam.dll</HintPath>
+ </Reference>
+ <Reference Include="Roam.Common, Version=1.0.2754.14429, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\Source\Roam.UI\bin\Release\Roam.Common.dll</HintPath>
+ </Reference>
+ <Reference Include="Roam.UI, Version=1.0.2756.13386, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\Source\Roam.UI\bin\Release\Roam.UI.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CapturedScreenForm.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="CapturedScreenForm.designer.cs">
+ <DependentUpon>CapturedScreenForm.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Form1.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Form1.designer.cs">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="CapturedScreenForm.resx">
+ <DependentUpon>CapturedScreenForm.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Form1.resx">
+ <DependentUpon>Form1.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <Import Condition="'$(TargetFrameworkVersion)' == 'v1.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.v1.targets" />
+ <Import Condition="'$(TargetFrameworkVersion)' == 'v2.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
+ <HostingProcess disable="1" />
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj.user
===================================================================
--- Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj.user (rev 0)
+++ Trunk/Samples/WallpaperChanger/WallpaperChanger.csproj.user 2007-07-21 06:19:34 UTC (rev 84)
@@ -0,0 +1,5 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <DeployDeviceID>BD0CC567-F6FD-4ca3-99D2-063EFDFC0A39d6518ffb-710f-11d3-99f2-00105a0df099</DeployDeviceID>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
Modified: Trunk/Source/Roam/Utils/PerformanceUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/PerformanceUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
+++ Trunk/Source/Roam/Utils/PerformanceUtils.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -1,3 +1,17 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
using System;
using System.Collections.Generic;
using System.Text;
@@ -5,6 +19,13 @@
namespace Roam.Utils
{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
public static class PerformanceUtils
{
[DllImport("coredll.dll", EntryPoint = "QueryPerformanceCounter")]
Modified: Trunk/Source/Roam/Utils/PowerNotification.cs
===================================================================
--- Trunk/Source/Roam/Utils/PowerNotification.cs 2007-07-18 08:42:09 UTC (rev 83)
+++ Trunk/Source/Roam/Utils/PowerNotification.cs 2007-07-21 06:19:34 UTC (rev 84)
@@ -95,10 +95,7 @@
_log.DebugFormat("{0}: Message: {1}} Flags: {2} IsAlert: {3} Length: {4} MessageString: {5}",
pb.Message, pb.Flags, pb.IsAlert, pb....
[truncated message content] |
|
From: <jon...@us...> - 2007-07-18 08:42:11
|
Revision: 83
http://roam.svn.sourceforge.net/roam/?rev=83&view=rev
Author: jonfroehlich
Date: 2007-07-18 01:42:09 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
1. fixed bug in FilteredListBox when items were filtered and Items.Clear() was called the filtered items were not removed. Added method RemoveFilteredItems()
2. Fixed a bug in DesktopUtils with regards to SetWallpaper--I accidentally opened a file stream than tried to save to that file via Image.Save(path). That's just not gonna work
3. Updated WindowUtils with some more useful windows related utility functions
Modified Paths:
--------------
Trunk/Source/Roam/Utils/ProcessUtils.cs
Trunk/Source/Roam.Common/Utils/WindowUtils.cs
Trunk/Source/Roam.UI/Controls/FilteredListBox.cs
Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs
Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam/Utils/ProcessUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/ProcessUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam/Utils/ProcessUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -71,13 +71,6 @@
/// <param name="pvEnvironment">[in] Not supported; set to NULL. </param>
/// <param name="pszCurDir">[in] Not supported; set to NULL. </param>
/// <param name="psiStartInfo">[in] Not supported; set to NULL. </param>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
/// <param name="pProcInfo">[out] Pointer to a PROCESS_INFORMATION structure that receives identification information about the new process. </param>
/// <returns>true indicates success</returns>
[DllImport("CoreDll.DLL", SetLastError = true)]
Modified: Trunk/Source/Roam.Common/Utils/WindowUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -80,67 +80,105 @@
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
+ /// <summary>
+ /// Returns true if the given control contains the handle
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="control"></param>
+ /// <returns></returns>
public static bool ContainsHandle(IntPtr handle, Control control)
{
- if (control.Handle == handle)
- {
- return true;
- }
- else
- {
- return ContainsHandle(handle, control.Controls);
- }
+ if (control.Handle == handle) { return true; }
+ else { return ContainsHandle(handle, control.Controls); }
}
+ /// <summary>
+ /// Returns true if the control collection contains the given handle
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="controls"></param>
+ /// <returns></returns>
public static bool ContainsHandle(IntPtr handle, Control.ControlCollection controls)
{
foreach (Control control in controls)
{
- if (control.Handle == handle)
- {
- return true;
- }
-
- if (ContainsHandle(handle, control.Controls))
- {
- return true;
- }
+ if (control.Handle == handle) { return true; }
+ if (ContainsHandle(handle, control.Controls)) { return true; }
}
return false;
}
+ /// <summary>
+ /// Returns the Control whose hWnd matches the provided handle and is
+ /// within the provided container
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="container"></param>
+ /// <returns></returns>
public static Control FindWindow(IntPtr handle, Control container)
{
- if (handle == container.Handle)
- {
- return container;
- }
- else
- {
- return FindWindow(handle, container.Controls);
- }
+ if (handle == container.Handle) { return container; }
+ else { return FindWindow(handle, container.Controls); }
}
+ /// <summary>
+ /// Returns the Control corresponding to the handle in the provided
+ /// control collection
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="controls"></param>
+ /// <returns></returns>
public static Control FindWindow(IntPtr handle, Control.ControlCollection controls)
{
foreach (Control control in controls)
{
- if (control.Handle == handle)
- {
- return control;
- }
+ if (control.Handle == handle) { return control; }
Control c = FindWindow(handle, control.Controls);
- if (c != null)
- {
- return c;
- }
+ if (c != null) { return c; }
}
return null;
}
+ /// <summary>
+ /// This function retrieves the handle to the top-level window whose class name and window name match the specified strings.
+ /// This function does not search child windows.
+ /// </summary>
+ /// <param name="lpClassName">Long pointer to a null-terminated string that specifies the class name or is an atom that
+ /// identifies the class-name string. If this parameter is an atom, it must be a global atom
+ /// created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be
+ /// placed in the low-order word of lpClassName; the high-order word must be zero. </param>
+ /// <param name="lpWindowName">Long pointer to a null-terminated string that specifies the window name (the window's title).
+ /// If this parameter is NULL, all window names match. </param>
+ /// <returns>A handle to the window that has the specified class name and window name indicates success. NULL indicates failure.
+ /// To get extended error information, call GetLastError. </returns>
+ /// <remarks>
+ /// If lpClassName is an atom, it must be an atom returned from RegisterClass.
+ /// </remarks>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+
+ /// <summary>
+ /// This function retrieves the handle to the top-level window whose window name match the specified strings.
+ /// This function does not search child windows.
+ /// </summary>
+ /// <param name="windowTitle"></param>
+ /// <returns></returns>
+ public static IntPtr FindWindow(string windowTitle)
+ {
+ return FindWindow(null, windowTitle);
+ }
+
+ /// <summary>
+ /// This function returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is
+ /// the area on top of which all icons and other windows are painted.
+ /// </summary>
+ /// <returns>The return value is a handle to the desktop window.</returns>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr GetDesktopWindow();
+
public static void PrintWindowHandles(Control control)
{
Debug.WriteLine(String.Format("Name: {0} Type: {1} Handle: {2}", control.Name, control.GetType().FullName, control.Handle));
Modified: Trunk/Source/Roam.UI/Controls/FilteredListBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/FilteredListBox.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.UI/Controls/FilteredListBox.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -65,6 +65,11 @@
}
}
+ public virtual void RemoveFilteredItems()
+ {
+ if (_filteredItems != null) { _filteredItems.Clear(); }
+ }
+
public virtual void SetFilter(IFilter<ListItem> filter)
{
_log.DebugFormat("SetFilter : entered with filter={0}", filter.ToString());
Modified: Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -184,6 +184,15 @@
{
get { return _addButton; }
}
+
+ public string SelectedText
+ {
+ get
+ {
+ if (_filteredListBox.SelectedIndex != -1) { return _filteredListBox.SelectedItem.ToString(); }
+ else return _textBox.Text;
+ }
+ }
#endregion Properties
#region Public Methods
@@ -222,6 +231,11 @@
_filteredListBox.Size = new Size(this.Width, this.Height - _textBorder.Bottom);
this.Invalidate();
}
+
+ public void RemoveFilteredItems()
+ {
+ _filteredListBox.RemoveFilteredItems();
+ }
#endregion Public Methods
#region Protected Methods
Modified: Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DesktopUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.UI/Utils/DesktopUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -23,6 +23,7 @@
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
+using System.Threading;
namespace Roam.UI.Utils
{
@@ -72,7 +73,6 @@
File.Delete(tempFilePath);
}
- FileStream fs = File.Create(tempFilePath);
image.Save(tempFilePath, ImageFormat.Jpeg);
SetWallpaper(tempFilePath);
}
@@ -117,5 +117,13 @@
Win32Window.SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
}
+
+ /// <summary>
+ /// This function returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is
+ /// the area on top of which all icons and other windows are painted.
+ /// </summary>
+ /// <returns>The return value is a handle to the desktop window.</returns>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr GetDesktopWindow();
}
}
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-16 07:03:19
|
Revision: 82
http://roam.svn.sourceforge.net/roam/?rev=82&view=rev
Author: jonfroehlich
Date: 2007-07-16 00:03:17 -0700 (Mon, 16 Jul 2007)
Log Message:
-----------
tested out ability to switch to any open application with a valid hwnd (see EnumWindowsTest which can automatically switch to Internet Explorer, if Internet Explorer is open)
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/WindowUtils.cs
Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Common/Utils/WindowUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-16 06:41:26 UTC (rev 81)
+++ Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
@@ -30,6 +30,8 @@
/// <author>Jon Froehlich</author>
public static class WindowUtils
{
+ public delegate int EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
+
/// <summary>
/// The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window,
/// in turn, to an application-defined callback function. EnumWindows continues until the last top-level window
@@ -49,8 +51,35 @@
/// referencing a handle to a window that has been destroyed.
/// </remarks>
[DllImport("coredll.dll", SetLastError = true)]
- public static extern int EnumWindows(IntPtr lpEnumFunc, uint lParam);
+ private static extern int EnumWindows(IntPtr lpEnumFunc, uint lParam);
+ public static int EnumWindows(EnumWindowsProc enumWindowsProc, uint lParam)
+ {
+ IntPtr callbackDelegatePointer = Marshal.GetFunctionPointerForDelegate(enumWindowsProc);
+ return EnumWindows(callbackDelegatePointer, lParam);
+ }
+
+ public static int EnumWindows(EnumWindowsProc enumWindowsProc)
+ {
+ return EnumWindows(enumWindowsProc, 0);
+ }
+
+ /// <summary>
+ /// The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates
+ /// the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system
+ /// assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.
+ /// </summary>
+ /// <param name="hWnd">[in] Handle to the window that should be activated and brought to the foreground. </param>
+ /// <returns>If the window was brought to the foreground, the return value is nonzero. If the window was not brought to the foreground,
+ /// the return value is zero.
+ /// </returns>
+ /// <remarks>
+ /// The foreground window is the window at the top of the Z-Order. It is the window that the user is working with. In a preemptive
+ /// multitasking environment, you should generally let the user control which window is the foreground window.
+ /// </remarks>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern bool SetForegroundWindow(IntPtr hWnd);
+
public static bool ContainsHandle(IntPtr handle, Control control)
{
if (control.Handle == handle)
Modified: Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs 2007-07-16 06:41:26 UTC (rev 81)
+++ Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs 2007-07-16 07:03:17 UTC (rev 82)
@@ -33,9 +33,10 @@
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this._scrollableLabel = new Roam.UI.Controls.ScrollableLabel();
- this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this.menuItem6 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// mainMenu1
@@ -52,6 +53,7 @@
//
this.menuItem2.MenuItems.Add(this.menuItem3);
this.menuItem2.MenuItems.Add(this.menuItem5);
+ this.menuItem2.MenuItems.Add(this.menuItem6);
this.menuItem2.MenuItems.Add(this.menuItem4);
this.menuItem2.Text = "Menu";
//
@@ -60,6 +62,11 @@
this.menuItem3.Text = "Enum Windows";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
+ // menuItem5
+ //
+ this.menuItem5.Text = "Foreground";
+ this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
+ //
// menuItem4
//
this.menuItem4.Text = "Clear";
@@ -74,10 +81,11 @@
this._scrollableLabel.Size = new System.Drawing.Size(240, 266);
this._scrollableLabel.TabIndex = 1;
//
- // menuItem5
+ // menuItem6
//
- this.menuItem5.Text = "Foreground";
- this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
+ this.menuItem6.Enabled = false;
+ this.menuItem6.Text = "Switch to Internet Explorer";
+ this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// EnumWindowsTest
//
@@ -101,5 +109,6 @@
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
+ private System.Windows.Forms.MenuItem menuItem6;
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs 2007-07-16 06:41:26 UTC (rev 81)
+++ Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs 2007-07-16 07:03:17 UTC (rev 82)
@@ -12,28 +12,30 @@
{
public partial class EnumWindowsTest : Form
{
- EnumWindowsProc callbackDelegate;
- IntPtr callbackDelegatePointer;
+ private WindowUtils.EnumWindowsProc _callbackDelegate;
- [DllImport("coredll.dll", SetLastError = true)]
- public static extern bool EnumWindows(IntPtr lpEnumFunc, uint lParam);
- public delegate int EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
+ //just to test out the app switch
+ private IntPtr _hwndInternetExplorer = IntPtr.Zero;
public EnumWindowsTest()
{
InitializeComponent();
_scrollableLabel.MaxLines = 200;
- callbackDelegate = new EnumWindowsProc(EnumWindowsCallbackProc);
- callbackDelegatePointer = Marshal.GetFunctionPointerForDelegate(callbackDelegate);
+ _callbackDelegate = new WindowUtils.EnumWindowsProc(EnumWindowsCallbackProc);
}
public int EnumWindowsCallbackProc(IntPtr hwnd, IntPtr lParam)
{
//System.Diagnostics.Debug.WriteLine("Window: " + hwnd.ToString());
- //System.Diagnostics.Debug.WriteLine("Window: " + hwnd.ToString());
- _scrollableLabel.AddLine("hWnd: {0} title: {1}", hwnd, WindowUtils.GetWindowText(hwnd));
- //StringBuilder sb = new StringBuilder();
- //_scrollableLabel.AddLine(string.Format("{0} {1}", hwnd.ToString(), WindowUtils.GetWindowText(hwnd, sb, int.MaxValue)));
+ string windowText = WindowUtils.GetWindowText(hwnd);
+ _scrollableLabel.AddLine("hWnd: {0} title: {1}", hwnd, windowText);
+
+ if (windowText.IndexOf("Internet") != -1)
+ {
+ _hwndInternetExplorer = hwnd;
+ menuItem6.Enabled = true;
+ }
+
return 1;
}
@@ -44,7 +46,7 @@
private void menuItem3_Click(object sender, EventArgs e)
{
- EnumWindows(callbackDelegatePointer, 0);
+ WindowUtils.EnumWindows(_callbackDelegate);
}
private void menuItem4_Click(object sender, EventArgs e)
@@ -63,61 +65,13 @@
_scrollableLabel.AddLine("Foreground Child: {0} title: {1}", childOfForeground, WindowUtils.GetWindowText(childOfForeground));
}
}
- }
- //public partial class EnumWindowsTest : Form
- //{
- // /// <summary>
- // /// The EnumWindowsProc function is an application-defined callback function used with the EnumWindows
- // /// or EnumDesktopWindows function. It receives top-level window handles. The WNDENUMPROC type defines
- // /// a pointer to this callback function. EnumWindowsProc is a placeholder for the application-defined
- // /// function name.
- // /// </summary>
- // /// <param name="hwnd">[in] Handle to a top-level window. </param>
- // /// <param name="lParam">[in] Specifies the application-defined value given in EnumWindows or EnumDesktopWindows. </param>
- // /// <returns>To continue enumeration, the callback function must return TRUE; to stop enumeration, it must return FALSE. </returns>
- // public delegate int EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
-
- // private EnumWindowsProc _callbackDelegate;
- // private IntPtr _callbackDelegatePointer;
-
- // [DllImport("coredll.dll", SetLastError = true)]
- // public static extern int EnumWindows(IntPtr lpEnumFunc, uint lParam);
-
- // public EnumWindowsTest()
- // {
- // InitializeComponent();
- // _callbackDelegate = new EnumWindowsProc(EnumWindowsCallbackProc);
- // _callbackDelegatePointer = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
- // }
-
- // private void menuItem1_Click(object sender, EventArgs e)
- // {
- // this.Close();
- // }
-
- // /// <summary>
- // ///
- // /// </summary>
- // /// <param name="hwnd"></param>
- // /// <param name="lParam"></param>
- // /// <returns>To continue enumeration, the callback function must return TRUE; to stop enumeration, it must return FALSE. </returns>
- // public int EnumWindowsCallbackProc(IntPtr hwnd, IntPtr lParam)
- // {
- // System.Diagnostics.Debug.WriteLine("Window: " + hwnd.ToString());
- // StringBuilder sb = new StringBuilder();
- // _scrollableLabel.AddLine(string.Format("{0} {1}", hwnd.ToString(), WindowUtils.GetWindowText(hwnd, sb, int.MaxValue)));
- // return 1;
- // }
-
- // private void menuItem3_Click(object sender, EventArgs e)
- // {
- // EnumWindows(_callbackDelegatePointer, 0);
- // }
-
- // private void menuItem4_Click(object sender, EventArgs e)
- // {
- // _scrollableLabel.Clear();
- // }
- //}
+ private void menuItem6_Click(object sender, EventArgs e)
+ {
+ if (_hwndInternetExplorer != IntPtr.Zero)
+ {
+ WindowUtils.SetForegroundWindow(_hwndInternetExplorer);
+ }
+ }
+ }
}
\ No newline at end of file
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-16 06:41:28
|
Revision: 81
http://roam.svn.sourceforge.net/roam/?rev=81&view=rev
Author: jonfroehlich
Date: 2007-07-15 23:41:26 -0700 (Sun, 15 Jul 2007)
Log Message:
-----------
added EnumWindows test
Modified Paths:
--------------
Trunk/Source/Roam/Utils/ProcessUtils.cs
Trunk/Source/Roam.Common/Utils/TypeUtils.cs
Trunk/Source/Roam.Common/Utils/WindowUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test/Utils/KeySnifferTest.Designer.cs
Trunk/Source/Roam.Test/Utils/KeySnifferTest.cs
Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
Trunk/Source/Roam.UI/Utils/KeySniffer.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs
Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.resx
Trunk/Source/Roam.Test/Sandbox/PingTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/PingTest.cs
Trunk/Source/Roam.Test/Sandbox/PingTest.resx
Modified: Trunk/Source/Roam/Utils/ProcessUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/ProcessUtils.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam/Utils/ProcessUtils.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -24,13 +24,6 @@
/// </summary>
/// <author>Jon Froehlich</author>
/// <author>Mike Y. Chen</author>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
public static class ProcessUtils
{
#region P/Invoke Code
@@ -41,21 +34,6 @@
///
/// </remarks>
/// <author>Jon Froehlich</author>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- //class for PROCESSINFO struct pinvoke
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
public class ProcessInfo
{
public IntPtr hProcess;
Modified: Trunk/Source/Roam.Common/Utils/TypeUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/TypeUtils.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.Common/Utils/TypeUtils.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -42,34 +42,12 @@
/// <summary>
/// Returns true if type1 is the same type as type2 OR if type1 is a
- /// <summary>
- ///
/// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- /// subclass of type2
- /// </summary>
/// <param name="type1"></param>
/// <param name="type2"></param>
/// <returns></returns>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
public static bool EqualsOrSubclassOf(Type type1, Type type2)
{
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
return type1 == type2 || type1.IsSubclassOf(type2);
}
@@ -83,24 +61,10 @@
return ParseNamespace(type.FullName);
}
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
public static string CombineNamespace(String strNamespace, String className)
{
String strReturn = strNamespace;
if (strNamespace[strNamespace.Length - 1] != '.') { strReturn += "."; }
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
return strReturn + className;
}
Modified: Trunk/Source/Roam.Common/Utils/WindowUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -30,6 +30,26 @@
/// <author>Jon Froehlich</author>
public static class WindowUtils
{
+ /// <summary>
+ /// The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window,
+ /// in turn, to an application-defined callback function. EnumWindows continues until the last top-level window
+ /// is enumerated or the callback function returns FALSE.
+ /// </summary>
+ /// <param name="enumWindowsProc">[in] Pointer to an application-defined callback function. For more information, see EnumWindowsProc. </param>
+ /// <param name="lParam">[in] Specifies an application-defined value to be passed to the callback function. </param>
+ /// <returns>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
+ /// To get extended error information, call GetLastError. If EnumWindowsProc returns zero, the return value is also zero.
+ /// In this case, the callback function should call SetLastError to obtain a meaningful error code to be returned to the
+ /// caller of EnumWindows.
+ /// </returns>
+ /// <remarks>
+ /// The EnumWindows function does not enumerate child windows, with the exception of a few top-level windows owned
+ /// by the system that have the WS_CHILD style. This function is more reliable than calling the GetWindow function
+ /// in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or
+ /// referencing a handle to a window that has been destroyed.
+ /// </remarks>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern int EnumWindows(IntPtr lpEnumFunc, uint lParam);
public static bool ContainsHandle(IntPtr handle, Control control)
{
@@ -112,63 +132,88 @@
Control controlFocused = FindFocusedControl(control);
if (controlFocused == null)
{
- Debug.WriteLine(String.Format("Could not find any focused controls in Name: {0} Type: {1} Handle: {2} or any of its children", control.Name, control.GetType().FullName, control.Handle));
+ Debug.WriteLine(
+ String.Format("Could not find any focused controls in Name: {0} Type: {1} Handle: {2} or any of its children",
+ control.Name, control.GetType().FullName, control.Handle));
}
else
{
- Debug.WriteLine(String.Format("Focused control: Name: {0} Type: {1} Handle: {2}", controlFocused.Name, controlFocused.GetType().FullName, controlFocused.Handle));
+ Debug.WriteLine(
+ String.Format("Focused control: Name: {0} Type: {1} Handle: {2}",
+ controlFocused.Name, controlFocused.GetType().FullName, controlFocused.Handle));
}
}
public static Control FindFocusedControl(Control control)
{
- if (control.Focused)
- {
- return control;
- }
- else
- {
- return FindFocusedControl(control.Controls);
- }
+ if (control.Focused) { return control; }
+ else { return FindFocusedControl(control.Controls); }
}
public static Control FindFocusedControl(Control.ControlCollection controls)
{
foreach (Control control in controls)
{
- if (control.Focused)
- {
- return control;
- }
+ if (control.Focused) { return control; }
Control c = FindFocusedControl(control.Controls);
- if (c != null)
- {
- return c;
- }
+ if (c != null) { return c; }
}
return null;
}
- //HWND GetForegroundWindow(void);
+ /// <summary>
+ /// The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working).
+ /// The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
+ /// </summary>
+ /// <returns>The return value is a handle to the foreground window. The foreground window can be NULL in certain circumstances,
+ /// such as when a window is losing activation. </returns>
[DllImport("coredll.dll", SetLastError = true)]
public static extern IntPtr GetForegroundWindow();
- //int GetWindowText(
- // HWND hWnd,
- // LPTSTR lpString,
- // int nMaxCount
- //);
+ /// <summary>
+ /// The GetWindowText function copies the text of the specified window's title bar (if it has one) into a buffer.
+ /// If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve
+ /// the text of a control in another application.
+ /// </summary>
+ /// <param name="hWnd">[in] Handle to the window or control containing the text.</param>
+ /// <param name="lpString">[out] Pointer to the buffer that will receive the text. If the string is as long or longer than the buffer,
+ /// the string is truncated and terminated with a NULL character. </param>
+ /// <param name="nMaxCount">[in] Specifies the maximum number of characters to copy to the buffer, including the NULL character.
+ /// If the text exceeds this limit, it is truncated. </param>
+ /// <returns>If the function succeeds, the return value is the length, in characters, of the copied string, not including
+ /// the terminating NULL character. If the window has no title bar or text, if the title bar is empty, or if the window
+ /// or control handle is invalid, the return value is zero. To get extended error information, call GetLastError.
+ /// This function cannot retrieve the text of an edit control in another application.
+ /// </returns>
[DllImport("coredll.dll", SetLastError = true)]
- public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
+ private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
+ public static string GetWindowText(IntPtr hWnd)
+ {
+ return GetWindowText(hWnd, 1000);
+ }
- //HWND GetWindow(
- // HWND hWnd,
- // UINT uCmd
- //);
+ public static string GetWindowText(IntPtr hWnd, int nMaxCount)
+ {
+ StringBuilder sb = new StringBuilder(nMaxCount);
+ GetWindowText(hWnd, sb, sb.Capacity);
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// The GetWindow function retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window.
+ /// </summary>
+ /// <param name="hWnd">[in] Handle to a window. The window handle retrieved is relative to this window, based on the value of the uCmd parameter. </param>
+ /// <param name="uCmd"></param>
+ /// <returns></returns>
[DllImport("coredll.dll")]
public static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
+
+ public static IntPtr GetChildWindow(IntPtr hWnd)
+ {
+ return GetWindow(hWnd, GetWindowConstants.GW_CHILD);
+ }
}
/// <summary>
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-07-16 06:41:26 UTC (rev 81)
@@ -57,6 +57,7 @@
<Reference Include="mscorlib" />
<Reference Include="OpenNETCF, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL" />
<Reference Include="OpenNETCF.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL" />
+ <Reference Include="OpenNETCF.Net, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL" />
<Reference Include="OpenNETCF.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL" />
<Reference Include="OpenNETCF.WindowsCE, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL" />
<Reference Include="System" />
@@ -73,6 +74,12 @@
<Compile Include="Media\SoundLoopPlayerTest.Designer.cs">
<DependentUpon>SoundLoopPlayerTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\EnumWindowsTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Sandbox\EnumWindowsTest.Designer.cs">
+ <DependentUpon>EnumWindowsTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\PhoneButtonManager.cs" />
<Compile Include="Sandbox\Camera.cs">
<SubType>Component</SubType>
@@ -129,6 +136,10 @@
<SubType>Designer</SubType>
<DependentUpon>AssemblyTest.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Sandbox\EnumWindowsTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>EnumWindowsTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Sandbox\PhoneButtonManagerTest.resx">
<SubType>Designer</SubType>
<DependentUpon>PhoneButtonManagerTest.cs</DependentUpon>
@@ -157,6 +168,10 @@
<SubType>Designer</SubType>
<DependentUpon>PhoneStateTest.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Sandbox\PingTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>PingTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Sandbox\SignalStrengthTest.resx">
<SubType>Designer</SubType>
<DependentUpon>SignalStrengthTest.cs</DependentUpon>
@@ -400,6 +415,12 @@
<Compile Include="Sandbox\PhoneStateTest.Designer.cs">
<DependentUpon>PhoneStateTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\PingTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Sandbox\PingTest.Designer.cs">
+ <DependentUpon>PingTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\SignalStrengthTest.cs">
<SubType>Form</SubType>
</Compile>
@@ -650,7 +671,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
Added: Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.Designer.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -0,0 +1,105 @@
+namespace Roam.Test.Sandbox
+{
+ partial class EnumWindowsTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this._scrollableLabel = new Roam.UI.Controls.ScrollableLabel();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.MenuItems.Add(this.menuItem5);
+ this.menuItem2.MenuItems.Add(this.menuItem4);
+ this.menuItem2.Text = "Menu";
+ //
+ // menuItem3
+ //
+ this.menuItem3.Text = "Enum Windows";
+ this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
+ //
+ // menuItem4
+ //
+ this.menuItem4.Text = "Clear";
+ this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
+ //
+ // _scrollableLabel
+ //
+ this._scrollableLabel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._scrollableLabel.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._scrollableLabel.Location = new System.Drawing.Point(0, 0);
+ this._scrollableLabel.Name = "_scrollableLabel";
+ this._scrollableLabel.Size = new System.Drawing.Size(240, 266);
+ this._scrollableLabel.TabIndex = 1;
+ //
+ // menuItem5
+ //
+ this.menuItem5.Text = "Foreground";
+ this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
+ //
+ // EnumWindowsTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._scrollableLabel);
+ this.Menu = this.mainMenu1;
+ this.Name = "EnumWindowsTest";
+ this.Text = "EnumWindowsTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private Roam.UI.Controls.ScrollableLabel _scrollableLabel;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem menuItem3;
+ private System.Windows.Forms.MenuItem menuItem4;
+ private System.Windows.Forms.MenuItem menuItem5;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using Roam.Common.Utils;
+
+namespace Roam.Test.Sandbox
+{
+ public partial class EnumWindowsTest : Form
+ {
+ EnumWindowsProc callbackDelegate;
+ IntPtr callbackDelegatePointer;
+
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern bool EnumWindows(IntPtr lpEnumFunc, uint lParam);
+ public delegate int EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
+
+ public EnumWindowsTest()
+ {
+ InitializeComponent();
+ _scrollableLabel.MaxLines = 200;
+ callbackDelegate = new EnumWindowsProc(EnumWindowsCallbackProc);
+ callbackDelegatePointer = Marshal.GetFunctionPointerForDelegate(callbackDelegate);
+ }
+
+ public int EnumWindowsCallbackProc(IntPtr hwnd, IntPtr lParam)
+ {
+ //System.Diagnostics.Debug.WriteLine("Window: " + hwnd.ToString());
+ //System.Diagnostics.Debug.WriteLine("Window: " + hwnd.ToString());
+ _scrollableLabel.AddLine("hWnd: {0} title: {1}", hwnd, WindowUtils.GetWindowText(hwnd));
+ //StringBuilder sb = new StringBuilder();
+ //_scrollableLabel.AddLine(string.Format("{0} {1}", hwnd.ToString(), WindowUtils.GetWindowText(hwnd, sb, int.MaxValue)));
+ return 1;
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void menuItem3_Click(object sender, EventArgs e)
+ {
+ EnumWindows(callbackDelegatePointer, 0);
+ }
+
+ private void menuItem4_Click(object sender, EventArgs e)
+ {
+ _scrollableLabel.Clear();
+ }
+
+ private void menuItem5_Click(object sender, EventArgs e)
+ {
+ IntPtr foregroundHwnd = WindowUtils.GetForegroundWindow();
+ _scrollableLabel.AddLine("Foreground: {0} title: {1}", foregroundHwnd, WindowUtils.GetWindowText(foregroundHwnd));
+
+ IntPtr childOfForeground = WindowUtils.GetChildWindow(foregroundHwnd);
+ if (childOfForeground != IntPtr.Zero)
+ {
+ _scrollableLabel.AddLine("Foreground Child: {0} title: {1}", childOfForeground, WindowUtils.GetWindowText(childOfForeground));
+ }
+ }
+ }
+
+ //public partial class EnumWindowsTest : Form
+ //{
+ // /// <summary>
+ // /// The EnumWindowsProc function is an application-defined callback function used with the EnumWindows
+ // /// or EnumDesktopWindows function. It receives top-level window handles. The WNDENUMPROC type defines
+ // /// a pointer to this callback function. EnumWindowsProc is a placeholder for the application-defined
+ // /// function name.
+ // /// </summary>
+ // /// <param name="hwnd">[in] Handle to a top-level window. </param>
+ // /// <param name="lParam">[in] Specifies the application-defined value given in EnumWindows or EnumDesktopWindows. </param>
+ // /// <returns>To continue enumeration, the callback function must return TRUE; to stop enumeration, it must return FALSE. </returns>
+ // public delegate int EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
+
+ // private EnumWindowsProc _callbackDelegate;
+ // private IntPtr _callbackDelegatePointer;
+
+ // [DllImport("coredll.dll", SetLastError = true)]
+ // public static extern int EnumWindows(IntPtr lpEnumFunc, uint lParam);
+
+ // public EnumWindowsTest()
+ // {
+ // InitializeComponent();
+ // _callbackDelegate = new EnumWindowsProc(EnumWindowsCallbackProc);
+ // _callbackDelegatePointer = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
+ // }
+
+ // private void menuItem1_Click(object sender, EventArgs e)
+ // {
+ // this.Close();
+ // }
+
+ // /// <summary>
+ // ///
+ // /// </summary>
+ // /// <param name="hwnd"></param>
+ // /// <param name="lParam"></param>
+ // /// <returns>To continue enumeration, the callback function must return TRUE; to stop enumeration, it must return FALSE. </returns>
+ // public int EnumWindowsCallbackProc(IntPtr hwnd, IntPtr lParam)
+ // {
+ // System.Diagnostics.Debug.WriteLine("Window: " + hwnd.ToString());
+ // StringBuilder sb = new StringBuilder();
+ // _scrollableLabel.AddLine(string.Format("{0} {1}", hwnd.ToString(), WindowUtils.GetWindowText(hwnd, sb, int.MaxValue)));
+ // return 1;
+ // }
+
+ // private void menuItem3_Click(object sender, EventArgs e)
+ // {
+ // EnumWindows(_callbackDelegatePointer, 0);
+ // }
+
+ // private void menuItem4_Click(object sender, EventArgs e)
+ // {
+ // _scrollableLabel.Clear();
+ // }
+ //}
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/EnumWindowsTest.resx 2007-07-16 06:41:26 UTC (rev 81)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/PingTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PingTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PingTest.Designer.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -0,0 +1,100 @@
+namespace Roam.Test.Sandbox
+{
+ partial class PingTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this._scrollableLabel = new Roam.UI.Controls.ScrollableLabel();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this._textBoxAddress = new Roam.UI.Controls.TextBox();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // _scrollableLabel
+ //
+ this._scrollableLabel.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._scrollableLabel.Location = new System.Drawing.Point(0, 0);
+ this._scrollableLabel.Name = "_scrollableLabel";
+ this._scrollableLabel.Size = new System.Drawing.Size(240, 231);
+ this._scrollableLabel.TabIndex = 0;
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.Text = "Menu";
+ //
+ // _textBoxAddress
+ //
+ this._textBoxAddress.Location = new System.Drawing.Point(1, 233);
+ this._textBoxAddress.Name = "_textBoxAddress";
+ this._textBoxAddress.SelectTextOnFocus = true;
+ this._textBoxAddress.Size = new System.Drawing.Size(237, 30);
+ this._textBoxAddress.TabIndex = 1;
+ this._textBoxAddress.Text = "www.yahoo.com";
+ //
+ // menuItem3
+ //
+ this.menuItem3.Text = "Ping";
+ this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
+ //
+ // PingTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._textBoxAddress);
+ this.Controls.Add(this._scrollableLabel);
+ this.Menu = this.mainMenu1;
+ this.Name = "PingTest";
+ this.Text = "PingTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Roam.UI.Controls.ScrollableLabel _scrollableLabel;
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem menuItem3;
+ private Roam.UI.Controls.TextBox _textBoxAddress;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/PingTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PingTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PingTest.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using OpenNETCF.Net.NetworkInformation;
+
+namespace Roam.Test.Sandbox
+{
+ public partial class PingTest : Form
+ {
+ public PingTest()
+ {
+ InitializeComponent();
+ }
+
+ private void menuItem3_Click(object sender, EventArgs e)
+ {
+ Ping ping = new Ping();
+ //PingOptions pingOptions = new PingOptions()
+
+ _scrollableLabel.AddLine("Pinging " + _textBoxAddress.Text + " ...");
+ Application.DoEvents();
+ Cursor.Current = Cursors.WaitCursor;
+ PingReply pingReply = ping.Send(_textBoxAddress.Text, 40000);
+ Cursor.Current = Cursors.Default;
+ _scrollableLabel.AddLine(string.Format("Reply from {0}: bytes={1} time={2}ms TTL={3}",
+ pingReply.Address, pingReply.Buffer.Length, pingReply.RoundTripTime, pingReply.Options.Ttl));
+ ping.Dispose();
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/PingTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PingTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PingTest.resx 2007-07-16 06:41:26 UTC (rev 81)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/Utils/KeySnifferTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Utils/KeySnifferTest.Designer.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.Test/Utils/KeySnifferTest.Designer.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -34,6 +34,7 @@
this.menuItem2 = new System.Windows.Forms.MenuItem();
this._menuItemStartStop = new System.Windows.Forms.MenuItem();
this._scrollableLabel = new Roam.UI.Controls.ScrollableLabel();
+ this._menuItemTrap = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// mainMenu1
@@ -49,6 +50,7 @@
// menuItem2
//
this.menuItem2.MenuItems.Add(this._menuItemStartStop);
+ this.menuItem2.MenuItems.Add(this._menuItemTrap);
this.menuItem2.Text = "Menu";
//
// _menuItemStartStop
@@ -65,6 +67,10 @@
this._scrollableLabel.Size = new System.Drawing.Size(240, 266);
this._scrollableLabel.TabIndex = 3;
//
+ // _menuItemTrap
+ //
+ this._menuItemTrap.Text = "Trap";
+ //
// KeySnifferTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
@@ -85,5 +91,6 @@
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem _menuItemStartStop;
private Roam.UI.Controls.ScrollableLabel _scrollableLabel;
+ private System.Windows.Forms.MenuItem _menuItemTrap;
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/Utils/KeySnifferTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Utils/KeySnifferTest.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.Test/Utils/KeySnifferTest.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -37,12 +37,20 @@
private void _keySniffer_KeyUp(object sender, KeyEventArgs e)
{
- PrintKey("KEYUP", e);
+ PrintKey("KEYUP", e);
+ if (_menuItemTrap.Checked)
+ {
+ e.Handled = true;
+ }
}
private void _keySniffer_KeyDown(object sender, KeyEventArgs e)
{
- PrintKey("KEYDOWN", e);
+ PrintKey("KEYDOWN", e);
+ if (_menuItemTrap.Checked)
+ {
+ e.Handled = true;
+ }
}
private void PrintKey(string p, KeyEventArgs e)
@@ -69,5 +77,10 @@
_keySniffer.Start();
}
}
+
+ private void _menuItemTrap_Click(object sender, EventArgs e)
+ {
+ _menuItemTrap.Checked = !_menuItemTrap.Checked;
+ }
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -58,12 +58,21 @@
private Fill _backFill = new FillSimpleLinearGradient(new SimpleLinearGradient(Color.FromArgb(206, 223, 239), Color.White, SimpleLinearGradient.FillDirection.TopToBottom));
private Insets _textInsets = new Insets(1, 1, 1, 1);
#endregion Private Fields
-
public ScrollableLabel()
: this(String.Empty)
{
}
+ /// <summary>
+ /// Default is 30 lines
+ /// </summary>
+ /// <param name="maxLines"></param>
+ public ScrollableLabel(int maxLines)
+ : this(string.Empty)
+ {
+ _buffer.MaxItems = maxLines;
+ }
+
public ScrollableLabel(string text)
{
_vScrollBar = new VScrollBar();
Modified: Trunk/Source/Roam.UI/Utils/KeySniffer.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/KeySniffer.cs 2007-07-01 22:43:14 UTC (rev 80)
+++ Trunk/Source/Roam.UI/Utils/KeySniffer.cs 2007-07-16 06:41:26 UTC (rev 81)
@@ -19,6 +19,7 @@
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Roam.Utils;
+using System.Reflection;
namespace Roam.UI.Utils
{
@@ -49,6 +50,7 @@
protected delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
+ #region Constructors
public KeySniffer()
{
}
@@ -57,10 +59,14 @@
{
if (startImmediately) { Start(); }
}
+ #endregion Constructors
+ #region Properties
public bool IsSniffing { get { return _hookHandle != 0; } }
+ #endregion Properties
- public virtual bool Start()
+ #region Methods
+ public bool Start()
{
if (IsSniffing)
{
@@ -80,7 +86,7 @@
return _hookHandle != 0;
}
- public virtual bool Stop()
+ public bool Stop()
{
if (_hookHandle != 0)
{
@@ -115,9 +121,9 @@
{
KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));
Keys key = (Keys)hookStruct.VkCode;
- Debug.WriteLine(string.Format("wParam: {5} lParam: {6} key: {0} flags: {1} scancode: {2} time: {3} extrainfo: {4}",
- key, hookStruct.Flags, hookStruct.ScanCode, hookStruct.Time, hookStruct.ExtraInfo,
- wParam, lParam));
+ //Debug.WriteLine(string.Format("wParam: {5} lParam: {6} key: {0} flags: {1} scancode: {2} time: {3} extrainfo: {4}",
+ // key, hookStruct.Flags, hookStruct.ScanCode, hookStruct.Time, hookStruct.ExtraInfo,
+ // wParam, lParam));
//if any of the underlying events set the e.Handled flag
bool handled = false;
@@ -148,8 +154,9 @@
if (handled)
{ return 1;}
else
- { return CallNextHookEx(_hookDelegate,code, wParam, lParam);}
+ { return CallNextHookEx(_hookDelegate,code, wParam, lParam);}
}
+ #endregion Methods
#region P/Invoke Declarations
/// <summary>
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-07-01 22:43:16
|
Revision: 80
http://roam.svn.sourceforge.net/roam/?rev=80&view=rev
Author: jonfroehlich
Date: 2007-07-01 15:43:14 -0700 (Sun, 01 Jul 2007)
Log Message:
-----------
added KeySniffer
Modified Paths:
--------------
Trunk/Source/Roam/Media/SoundLoopPlayer.cs
Trunk/Source/Roam/Roam.csproj
Trunk/Source/Roam/Utils/DeviceUtils.cs
Trunk/Source/Roam/Utils/PowerUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test.Desktop/MeasureStringTest.cs
Trunk/Source/Roam.Test.Desktop/Roam.Test.Desktop.csproj
Trunk/Source/Roam.Test.Desktop/ShapeItemTest.cs
Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.Designer.cs
Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs
Trunk/Source/Roam.UI/Drawing/PolygonItem.cs
Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.UI/Utils/HotKeyManager.cs
Trunk/Source/Roam.UI/Utils/WindowsMessagingUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam/Utils/PerformanceUtils.cs
Trunk/Source/Roam/Utils/WindowsConstants.cs
Trunk/Source/Roam/Utils/WindowsHooks.cs
Trunk/Source/Roam.Test/Sandbox/PhoneButtonManager.cs
Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.cs
Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.resx
Trunk/Source/Roam.Test/Sandbox/TimeTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/TimeTest.cs
Trunk/Source/Roam.Test/Sandbox/TimeTest.resx
Trunk/Source/Roam.Test/Utils/KeySnifferTest.Designer.cs
Trunk/Source/Roam.Test/Utils/KeySnifferTest.cs
Trunk/Source/Roam.Test/Utils/KeySnifferTest.resx
Trunk/Source/Roam.Test/Utils/KeySniffersTest.Designer.cs
Trunk/Source/Roam.Test/Utils/KeySniffersTest.cs
Trunk/Source/Roam.Test/Utils/KeySniffersTest.resx
Trunk/Source/Roam.Test.Desktop/ActuationItemForm.Designer.cs
Trunk/Source/Roam.Test.Desktop/ActuationItemForm.cs
Trunk/Source/Roam.UI/Utils/KeySniffer.cs
Modified: Trunk/Source/Roam/Media/SoundLoopPlayer.cs
===================================================================
--- Trunk/Source/Roam/Media/SoundLoopPlayer.cs 2007-04-25 06:42:49 UTC (rev 79)
+++ Trunk/Source/Roam/Media/SoundLoopPlayer.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -21,14 +21,6 @@
namespace Roam.Media
{
- /// <summary>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
/// This class is used for looping sounds over and over.
///
/// It would derive from CyclePlayer and use that functionality but in order to do so
Modified: Trunk/Source/Roam/Roam.csproj
===================================================================
--- Trunk/Source/Roam/Roam.csproj 2007-04-25 06:42:49 UTC (rev 79)
+++ Trunk/Source/Roam/Roam.csproj 2007-07-01 22:43:14 UTC (rev 80)
@@ -69,12 +69,15 @@
<Compile Include="PocketOutlook\Sms.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\DeviceUtils.cs" />
+ <Compile Include="Utils\PerformanceUtils.cs" />
<Compile Include="Utils\PowerNotification.cs" />
<Compile Include="Utils\PowerUtils.cs" />
<Compile Include="Utils\ProcessUtils.cs" />
<Compile Include="Utils\StorageCardUtils.cs" />
<Compile Include="Utils\SystemUtils.cs" />
<Compile Include="Utils\ThreadUtils.cs" />
+ <Compile Include="Utils\WindowsHooks.cs" />
+ <Compile Include="Utils\WindowsConstants.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Roam.Common\Roam.Common.csproj">
Modified: Trunk/Source/Roam/Utils/DeviceUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/DeviceUtils.cs 2007-04-25 06:42:49 UTC (rev 79)
+++ Trunk/Source/Roam/Utils/DeviceUtils.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -20,21 +20,8 @@
namespace Roam.Utils
{
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
+
//jeffixme I believe the deviceid functionality is in OpenNetCF in the DeviceManagement class
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
//If that's the case, some of this class is redundant.
/// <summary>
@@ -47,25 +34,6 @@
public static class DeviceUtils
{
/// <summary>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- /// I would suggest using the Stopwatch class for performance timing
- /// which can be found in OpenNETCF's SDF.
- /// </summary>
- /// <param name="perfCounter"></param>
- /// <returns></returns>
- [DllImport("coredll.dll")]
- internal static extern int QueryPerformanceCounter(out Int64 perfCounter);
-
- [DllImport("coredll.dll")]
- internal static extern int QueryPerformanceFrequency(out Int64 frequency);
-
- /// <summary>
/// This function returns the amount of time, in milliseconds, that the
/// system has been idle.
/// </summary>
Added: Trunk/Source/Roam/Utils/PerformanceUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/PerformanceUtils.cs (rev 0)
+++ Trunk/Source/Roam/Utils/PerformanceUtils.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Roam.Utils
+{
+ public static class PerformanceUtils
+ {
+ [DllImport("coredll.dll", EntryPoint = "QueryPerformanceCounter")]
+ private static extern bool QueryPerformanceCounter(out long count);
+
+ [DllImport("coredll.dll", EntryPoint = "QueryPerformanceFrequency")]
+ private static extern bool QueryPerformanceFrequency(out long countsPerSecond);
+
+ //these two variables are initialized in the PerformanceUtils static constructor
+ public static readonly long Frequency;
+ public static readonly long FrequencyInMs;
+
+ static PerformanceUtils()
+ {
+ if (QueryPerformanceFrequency(out Frequency) == false)
+ {
+ throw new Exception("The high resolution timer is not available on this device.");
+ }
+
+ FrequencyInMs = Frequency / 1000;
+ }
+
+ public static long GetTimestampMs()
+ {
+ long count;
+ QueryPerformanceCounter(out count);
+ return (long)Math.Round(count / (double)FrequencyInMs);
+ }
+
+ public static long GetPerformanceCount()
+ {
+ long count;
+ QueryPerformanceCounter(out count);
+ return count;
+ }
+ }
+}
Modified: Trunk/Source/Roam/Utils/PowerUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/PowerUtils.cs 2007-04-25 06:42:49 UTC (rev 79)
+++ Trunk/Source/Roam/Utils/PowerUtils.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -234,41 +234,13 @@
/// These flags are defined in pm.h
///
/// A note on flags: Bit fields are generally used for lists of elements that might
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
/// occur in combination, whereas enumeration constants are generally used for
/// lists of mutually exclusive elements. Therefore, bit fields are designed to
/// be combined with a bitwise OR operation to generate unnamed values, whereas
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
/// enumerated constants are not. Languages vary in their use of bit fields
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
/// compared to enumeration constants.
/// </summary>
[Flags]
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
public enum PowerStateFlags : uint
{
On = (0x00010000), // on state
Added: Trunk/Source/Roam/Utils/WindowsConstants.cs
===================================================================
--- Trunk/Source/Roam/Utils/WindowsConstants.cs (rev 0)
+++ Trunk/Source/Roam/Utils/WindowsConstants.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,96 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Roam.Utils
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public static class WindowsConstants
+ {
+ //these values are found in winuser.h or through experimentation
+
+ #region Keys
+ /// <summary>
+ /// The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key
+ /// is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.
+ /// </summary>
+ public static int WM_KEYDOWN = 0x100;
+
+ /// <summary>
+ /// The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem key is released.
+ /// A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that
+ /// is pressed when a window has the keyboard focus.
+ /// </summary>
+ public static int WM_KEYUP = 0x0101;
+
+ /// <summary>
+ /// The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user
+ /// presses the F10 key (which activates the menu bar) or holds down the ALT key and then
+ /// presses another key. It also occurs when no window currently has the keyboard focus;
+ /// in this case, the WM_SYSKEYDOWN message is sent to the active window. The window that
+ /// receives the message can distinguish between these two contexts by checking the context
+ /// code in the lParam parameter.
+ /// </summary>
+ public static int WM_SYSKEYDOWN = 0x104;
+
+ /// <summary>
+ /// The WM_SYSKEYUP message is posted to the window with the keyboard focus when the user
+ /// releases a key that was pressed while the ALT key was held down. It also occurs when no
+ /// window currently has the keyboard focus; in this case, the WM_SYSKEYUP message is sent
+ /// to the active window. The window that receives the message can distinguish between
+ /// these two contexts by checking the context code in the lParam parameter.
+ /// </summary>
+ public static int WM_SYSKEYUP = 0x105;
+
+ public static int WM_KEYPRESS = 0x010F;
+ public static int WM_HOTKEY = 0x0312;
+ #endregion Keys
+
+ #region Mouse
+ public static int WM_MOUSEMOVE = 0x0200;
+ public static int WM_LBUTTONDOWN = 0x0201;
+ public static int WM_LBUTTONUP = 0x0202;
+ public static int WM_LBUTTONDBLCLK = 0x0203;
+ public static int WM_RBUTTONDOWN = 0x0204;
+ public static int WM_RBUTTONUP = 0x0205;
+ public static int WM_RBUTTONDBLCLK = 0x0206;
+ public static int WM_MBUTTONDOWN = 0x0207;
+ public static int WM_MBUTTONUP = 0x0208;
+ public static int WM_MBUTTONDBLCLK = 0x0209;
+ public static int WM_MOUSELAST = 0x0209;
+ #endregion Mouse
+
+ public static byte VK_BACK = 0x08;
+ public static byte VK_ESCAPE = 0x1B;
+ public static byte VK_SHIFT = 0x10;
+ public static byte VK_CAPITAL = 0x14;
+ public static byte VK_NUMLOCK = 0x90;
+
+ public static int MOD_ALT = 0x0001;
+ public static int MOD_CONTROL = 0x0002;
+ public static int MOD_SHIFT = 0x0004;
+ public static int MOD_WIN = 0x0008;
+ public static int MOD_KEYUP = 0x1000;
+ }
+}
Added: Trunk/Source/Roam/Utils/WindowsHooks.cs
===================================================================
--- Trunk/Source/Roam/Utils/WindowsHooks.cs (rev 0)
+++ Trunk/Source/Roam/Utils/WindowsHooks.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,229 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Roam.Utils
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ [Flags]
+ public enum LowLevelKeyHookFlags : uint
+ {
+ /// <summary>
+ /// Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad.
+ /// The value is 1 if the key is an extended key; otherwise, it is 0.
+ /// </summary>
+ LLKHF_EXTENDED = 0x00,
+
+ /// <summary>
+ /// Reserved.
+ /// </summary>
+ LLKHF_RESERVED1 = 0x01,
+
+ /// <summary>
+ /// Reserved.
+ /// </summary>
+ LLKHF_RESERVED2 = 0x02,
+
+ /// <summary>
+ /// Reserved.
+ /// </summary>
+ LLKHF_RESERVED3 = 0x03,
+
+ /// <summary>
+ /// Specifies whether the event was injected. The value is 1 if the event
+ /// was injected; otherwise, it is 0.
+ /// </summary>
+ LLKHF_INJECTED = 0x04,
+
+ /// <summary>
+ /// Specifies the context code. The value is 1 if the ALT key is pressed;
+ /// otherwise, it is 0.
+ /// </summary>
+ LLKHF_ALTDOWN = 0x05,
+
+ /// <summary>
+ /// Reserved.
+ /// </summary>
+ LLKHF_RESERVED4 = 0x06,
+
+ /// <summary>
+ /// Specifies the transition state. The value is 0 if the key is
+ /// pressed and 1 if it is being released.
+ /// </summary>
+ LLKHF_UP = 0x07
+ }
+
+ /// <summary>
+ /// As found in WinUser.h. Also, see SetWindowsHookEx documentation
+ ///
+ /// UPDATE: I found that the windows hook values listed in WinUser.h do _not_ actually
+ /// work in Windows Mobile. I empirically found that the WH_KEYBOARD_LL value is 20
+ /// by looping through codes from 1 onward. No other hook appears to work. I checked
+ /// all values up to around 800,000.
+ /// </summary>
+ /// <author>Jon Froehlich</author>
+ public enum WindowsHooks : int
+ {
+ //WH_MSGFILTER = -1,
+
+ /// <summary>
+ /// Installs a hook procedure that records input messages posted to the system message queue. This hook is useful for recording macros.
+ /// For more information, see the JournalRecordProc hook procedure.
+ /// </summary>
+ //WH_JOURNALRECORD = 0,
+
+ /// <summary>
+ /// Installs a hook procedure that posts messages previously recorded by a WH_JOURNALRECORD hook procedure.
+ /// For more information, see the JournalPlaybackProc hook procedure.
+ /// </summary>
+ //WH_JOURNALPLAYBACK = 1,
+
+ /// <summary>
+ /// Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.
+ /// </summary>
+ //WH_KEYBOARD = 2,
+
+ /// <summary>
+ /// Installs a hook procedure that monitors messages posted to a message queue. For more information, see the GetMsgProc hook procedure.
+ /// </summary>
+ //WH_GETMESSAGE = 3,
+
+ /// <summary>
+ /// Installs a hook procedure that monitors messages before the system sends them to
+ /// the destination window procedure. For more information, see the CallWndProc hook procedure.
+ /// </summary>
+ //WH_CALLWNDPROC = 4,
+
+ /// <summary>
+ /// Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application.
+ /// For more information, see the CBTProc hook procedure.
+ /// </summary>
+ //WH_CBT = 5,
+
+ /// <summary>
+ /// Installs a hook procedure that monitors messages generated as a result of an input event
+ /// in a dialog box, message box, menu, or scroll bar. The hook procedure monitors these
+ /// messages for all applications in the same desktop as the calling thread.
+ /// For more information, see the SysMsgProc hook procedure.
+ /// </summary>
+ //WH_SYSMSGFILTER = 6,
+
+ /// <summary>
+ /// Installs a hook procedure that monitors mouse messages.
+ /// For more information, see the MouseProc hook procedure.
+ /// </summary>
+ //WH_MOUSE = 7,
+ //WH_HARDWARE = 8,
+
+ /// <summary>
+ /// Installs a hook procedure useful for debugging other hook procedures. For more
+ /// information, see the DebugProc hook procedure.
+ /// </summary>
+ //WH_DEBUG = 9,
+
+ /// <summary>
+ /// Installs a hook procedure that receives notifications useful to shell applications.
+ /// For more information, see the ShellProc hook procedure.
+ /// </summary>
+ //WH_SHELL = 10,
+
+ /// <summary>
+ /// Installs a hook procedure that will be called when the application's foreground thread is about to become idle.
+ /// This hook is useful for performing low priority tasks during idle time.
+ /// For more information, see the ForegroundIdleProc hook procedure.
+ /// </summary>
+ //WH_FOREGROUNDIDLE = 11,
+
+ /// <summary>
+ /// Installs a hook procedure that monitors messages after they have been processed by the destination window procedure.
+ /// For more information, see the CallWndRetProc hook procedure.
+ /// </summary>
+ //WH_CALLWNDPROCRET = 12,
+
+ /// <summary>
+ /// Windows NT/2000/XP: Installs a hook procedure that monitors low-level keyboard input events.
+ /// For more information, see the LowLevelKeyboardProc hook procedure.
+ /// </summary>
+ WH_KEYBOARD_LL = 20,
+
+ /// <summary>
+ /// Windows NT/2000/XP: Installs a hook procedure that monitors low-level mouse input events.
+ /// For more information, see the LowLevelMouseProc hook procedure.
+ /// </summary>
+ //WH_MOUSE_LL = 14
+ }
+
+ /// <summary>
+ /// The KBDLLHOOKSTRUCT structure contains information about a low-level keyboard input event.
+ /// </summary>
+ /// <remarks>
+ /// Declared in Winuser.h
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ [StructLayout(LayoutKind.Sequential)]
+ public struct KBDLLHOOKSTRUCT
+ {
+ #region Fields
+ private int _vkCode;
+ private int _scanCode;
+ private LowLevelKeyHookFlags _flags;
+ private int _time;
+ private IntPtr _dwExtraInfo;
+ #endregion Fields
+
+ #region Properties
+ /// <summary>
+ /// Specifies a virtual-key code. The code must be a value in the range 1 to 254.
+ /// </summary>
+ public int VkCode { get { return _vkCode; } }
+
+ /// <summary>
+ /// Specifies a hardware scan code for the key.
+ /// </summary>
+ public int ScanCode { get { return _scanCode; } }
+
+ /// <summary>
+ /// Specifies the extended-key flag, event-injected flag, context code, and
+ /// transition-state flag.
+ /// </summary>
+ /// <remarks>
+ /// This member is specified as follows. An application can use
+ /// the following values to test the keystroke flags.
+ /// </remarks>
+ public LowLevelKeyHookFlags Flags { get { return _flags; } }
+
+ /// <summary>
+ /// Specifies the time stamp for this message, equivalent to what GetMessageTime
+ /// would return for this message. Note: I believe GetMessageTime is equivalent
+ /// to Environment.TickCount
+ /// </summary>
+ public int Time { get { return _time; } }
+
+ /// <summary>
+ /// Specifies extra information associated with the message.
+ /// </summary>
+ public IntPtr ExtraInfo { get { return _dwExtraInfo; } }
+ #endregion Properties
+ }
+}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-25 06:42:49 UTC (rev 79)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-07-01 22:43:14 UTC (rev 80)
@@ -73,6 +73,7 @@
<Compile Include="Media\SoundLoopPlayerTest.Designer.cs">
<DependentUpon>SoundLoopPlayerTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\PhoneButtonManager.cs" />
<Compile Include="Sandbox\Camera.cs">
<SubType>Component</SubType>
</Compile>
@@ -128,6 +129,10 @@
<SubType>Designer</SubType>
<DependentUpon>AssemblyTest.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Sandbox\PhoneButtonManagerTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>PhoneButtonManagerTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Sandbox\ColorsTest.resx">
<SubType>Designer</SubType>
<DependentUpon>ColorsTest.cs</DependentUpon>
@@ -168,6 +173,10 @@
<SubType>Designer</SubType>
<DependentUpon>StarItemTest.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Sandbox\TimeTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>TimeTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Sandbox\TopMostFormTest.resx">
<SubType>Designer</SubType>
<DependentUpon>TopMostFormTest.cs</DependentUpon>
@@ -324,6 +333,14 @@
<SubType>Designer</SubType>
<DependentUpon>InsetsForm.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Utils\KeySniffersTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>KeySniffersTest.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Utils\KeySnifferTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>KeySnifferTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Utils\MeasureStringTest.resx">
<SubType>Designer</SubType>
<DependentUpon>MeasureStringTest.cs</DependentUpon>
@@ -371,6 +388,12 @@
<Compile Include="Sandbox\MonthCalendarTest.Designer.cs">
<DependentUpon>MonthCalendarTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\PhoneButtonManagerTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Sandbox\PhoneButtonManagerTest.Designer.cs">
+ <DependentUpon>PhoneButtonManagerTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\PhoneStateTest.cs">
<SubType>Form</SubType>
</Compile>
@@ -404,6 +427,12 @@
<Compile Include="Sandbox\TextBoxBackgroundTest.cs">
<SubType>Component</SubType>
</Compile>
+ <Compile Include="Sandbox\TimeTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Sandbox\TimeTest.Designer.cs">
+ <DependentUpon>TimeTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\TopMostFormTest.cs">
<SubType>Form</SubType>
</Compile>
@@ -483,7 +512,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
@@ -621,7 +650,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
@@ -674,6 +703,18 @@
<Compile Include="Utils\InsetsForm.Designer.cs">
<DependentUpon>InsetsForm.cs</DependentUpon>
</Compile>
+ <Compile Include="Utils\KeySniffersTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Utils\KeySniffersTest.Designer.cs">
+ <DependentUpon>KeySniffersTest.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Utils\KeySnifferTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Utils\KeySnifferTest.Designer.cs">
+ <DependentUpon>KeySnifferTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Utils\MeasureStringTest.cs">
<SubType>Form</SubType>
</Compile>
Added: Trunk/Source/Roam.Test/Sandbox/PhoneButtonManager.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PhoneButtonManager.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PhoneButtonManager.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,333 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace Roam.Test.Sandbox
+{
+ public class PhoneButtonManager
+ {
+ #region EventsDelegates
+
+ public delegate void PhoneButtonDelegate(PhoneButtonEventArgs args);
+ public static event PhoneButtonDelegate AnyButtonEvent;
+ public static event PhoneButtonDelegate EscapeButtonEvent;
+ public static event PhoneButtonDelegate LeftMenuButtonEvent;
+ public static event PhoneButtonDelegate RightMenuButtonEvent;
+
+ #endregion
+
+ #region Imports
+ private delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam);
+
+ //This is the Import for the SetWindowsHookEx function.
+ //Use this function to install a thread-specific hook.
+ [DllImport("coredll.dll", CharSet = CharSet.Auto,
+ CallingConvention = CallingConvention.Winapi)]
+ private static extern int SetWindowsHookEx(int idHook, HookProc lpfn,
+ IntPtr hInstance, int threadId);
+
+ //This is the Import for the UnhookWindowsHookEx function.
+ //Call this function to uninstall the hook.
+ [DllImport("coredll.dll", CharSet = CharSet.Auto,
+ CallingConvention = CallingConvention.Winapi)]
+ private static extern bool UnhookWindowsHookEx(int idHook);
+
+ //This is the Import for the CallNextHookEx function.
+ //Use this function to pass the hook information to the next hook procedure in chain.
+ [DllImport("coredll.dll", CharSet = CharSet.Auto,
+ CallingConvention = CallingConvention.Winapi)]
+ private static extern int CallNextHookEx(int idHook, int nCode,
+ IntPtr wParam, IntPtr lParam);
+
+ [DllImport("coredll.dll", CharSet = CharSet.Auto,
+ CallingConvention = CallingConvention.Winapi)]
+ private static extern IntPtr GetModuleHandle(string mod);
+
+#pragma warning disable 649
+ private struct KBDLLHOOKSTRUCT
+ {
+ public uint vkCode;
+ public uint scanCode;
+ public uint flags;
+ public uint time;
+ public IntPtr dwExtraInfo;
+ }
+#pragma warning restore 649
+
+ private const int WH_KEYBOARD = 2;
+ private const int WH_KEYBOARD_LL = 20;
+
+ #endregion Imports
+
+ #region Private
+
+ private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(typeof(PhoneButtonManager));
+ private static int _hHook = 0;
+ private static HookProc _kbdHookProcedure;
+ private static bool _buttonActive = false;
+ private static bool _allowCamera = false;
+ private static uint _lastDownTime = 0;
+ private static uint _requiredButtonTime = 1500;
+ private static uint _requiredEscapeTime = 1000;
+ private static bool _bCameraDown = false;
+
+ private const int TRAPALL_STATE = 0;
+ private const int TRAPMENU_STATE = 1;
+ private const int TRAPNOTHING_STATE = 2;
+ private static int _state = TRAPNOTHING_STATE;
+
+ private const uint CAMERA = 196;
+ private const uint RECORDER = 204;
+ private const uint VOICEDIAL = 193;
+ private const uint ESC1 = RECORDER;
+ private const uint ESC2 = VOICEDIAL;
+
+ #endregion Private
+
+ #region Properties
+
+ public static bool IsTrappingAll
+ { get { return (_state == TRAPALL_STATE); } }
+
+ public static bool IsTrappingMenu
+ { get { return (_state == TRAPMENU_STATE); } }
+
+ public static bool IsTrappingNothing
+ { get { return (_state == TRAPNOTHING_STATE); } }
+
+
+ public static uint RequiredEscapeTime
+ {
+ get { return _requiredEscapeTime; }
+ set { _requiredEscapeTime = value; }
+ }
+
+ public static uint RequiredButtonTime
+ {
+ get { return _requiredButtonTime; }
+ set { _requiredButtonTime = value; }
+ }
+
+ public static bool AllowCamera
+ {
+ get { return _allowCamera; }
+ set { _allowCamera = value; }
+ }
+
+ #endregion Properties
+
+ #region Methods
+
+ public bool StartPhoneButtonManager()
+ {
+ if (_hHook == 0)
+ {
+ // Create an instance of HookProc.
+ _kbdHookProcedure = new HookProc(OnKbdHookEvent);
+
+ _hHook = SetWindowsHookEx(WH_KEYBOARD_LL,
+ _kbdHookProcedure,
+ GetModuleHandle(null),
+ 0);
+ }
+
+ return (_hHook != 0);
+ }
+
+ public void StopPhoneButtonManager()
+ {
+ if (_hHook != 0)
+ UnhookWindowsHookEx(_hHook);
+
+ _hHook = 0;
+ }
+
+ public static void EnterTrapAllMode()
+ { SetState(TRAPALL_STATE); }
+
+ public static void EnterTrapMenuMode()
+ { SetState(TRAPMENU_STATE); }
+
+ public static void EnterTrapNothingMode()
+ { SetState(TRAPNOTHING_STATE); }
+
+
+ #endregion Methods
+
+
+ private static void SetState(int iNewState)
+ {
+ _state = iNewState;
+ }
+
+ private static int OnKbdHookEvent(int nCode, IntPtr wParam, IntPtr lParam)
+ {
+ if (nCode < 0) // || _buttonActive)
+ return CallNextHookEx(_hHook, nCode, wParam, lParam);
+
+ KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));
+ uint iVKCode = hookStruct.vkCode;
+ int iDirection = (wParam.ToInt32() == 257) ? 1 : -1;
+
+ if (iVKCode == CAMERA)
+ {
+ _bCameraDown = (iDirection < 0);
+ }
+ else if (iVKCode == ESC1 || iVKCode == ESC2)
+ {
+ //Check for escape button up action
+ if ((iDirection > 0) &&
+ ((hookStruct.time - _lastDownTime) >= _requiredEscapeTime))
+ {
+
+ if (!_buttonActive)
+ {
+ _buttonActive = true;
+
+ PhoneButtonEventArgs pbea = new PhoneButtonEventArgs(iVKCode, 1);
+ if (EscapeButtonEvent != null)
+ EscapeButtonEvent.Invoke(pbea);
+
+ _buttonActive = false;
+ }
+ }
+
+
+ return 1; // don't ever allow escape (up or down) to pass
+ }
+
+
+ if (_state != TRAPNOTHING_STATE)
+ {
+ // the camera button behaves differently than the others. If camera
+ // activity is allowed, then pass it through. Otherwise, forcefully block it
+ if (iVKCode == CAMERA)
+ {
+ // If the camera is special right now, allow all camera actions to pass
+ if (_allowCamera)
+ return CallNextHookEx(_hHook, nCode, wParam, lParam);
+ else
+ return 1;
+ }
+
+ // Stupid hack to fix problem with "bonus keys" when dealing with the camera
+ if (_allowCamera || _bCameraDown)
+ if (iVKCode == (uint)Keys.LWin || iVKCode == (uint)Keys.RWin ||
+ iVKCode == (uint)Keys.F21 || iVKCode == (uint)Keys.F23)
+ return 1;
+ }
+
+
+ // Now see if this was a button up and, if so, how long it's been
+ // since the last button down.
+ bool bDownLongEnough = false;
+ if (iDirection < 0)
+ _lastDownTime = hookStruct.time;
+ else
+ bDownLongEnough = ((hookStruct.time - _lastDownTime) >= _requiredButtonTime);
+
+ // look for Dpad, jog wheel, and enter keys
+ if (iVKCode == (uint)Keys.Left || iVKCode == (uint)Keys.Right ||
+ iVKCode == (uint)Keys.Up || iVKCode == (uint)Keys.Down ||
+ iVKCode == (uint)Keys.Enter)
+ {
+ if (bDownLongEnough && _state == TRAPALL_STATE)
+ {
+ if (!_buttonActive)
+ {
+ _buttonActive = true;
+
+ PhoneButtonEventArgs pbea = new PhoneButtonEventArgs(iVKCode, iDirection);
+ if (AnyButtonEvent != null)
+ AnyButtonEvent.Invoke(pbea);
+
+ _buttonActive = false;
+ }
+ }
+
+ // all direction and enter indicators pass to underlying OS
+ // regardless of state
+ return CallNextHookEx(_hHook, nCode, wParam, lParam);
+ }
+
+ // in system state, every thing passes (except escape as handled above
+ if (_state == TRAPNOTHING_STATE)
+ {
+ return CallNextHookEx(_hHook, nCode, wParam, lParam);
+ }
+
+ if (_state == TRAPALL_STATE)
+ {
+ if (bDownLongEnough) // implies iDirection == 1) // key up
+ {
+ //if ((iVKCode >= Keys.F1 && iVKCode <= Keys.F7) ||
+ // (iVKCode >= 193 && iVKCode <= 199))
+ if (iVKCode != (uint)Keys.LWin && iVKCode != (uint)Keys.RWin &&
+ iVKCode != (uint)Keys.F21 && iVKCode != (uint)Keys.F23 &&
+ iVKCode != (uint)RECORDER)
+ {
+ if (!_buttonActive)
+ {
+ _buttonActive = true;
+
+ PhoneButtonEventArgs pbea = new PhoneButtonEventArgs(iVKCode, 1);
+ if (AnyButtonEvent != null)
+ AnyButtonEvent.Invoke(pbea);
+
+ _buttonActive = false;
+ }
+ }
+ }
+
+ return 1;
+ }
+
+ //only manage up action of pseudo-menu keys in TRAP_MENU state
+ if ((_state == TRAPMENU_STATE) && (iDirection > 0)) // key up
+ {
+ if (iVKCode == (uint)Keys.LWin || iVKCode == (uint)Keys.F3 || iVKCode == (uint)Keys.F1)
+ {
+ //if (!_buttonActive)
+ {
+ //_buttonActive = true;
+
+ PhoneButtonEventArgs pbea = new PhoneButtonEventArgs(iVKCode, 1);
+ if (LeftMenuButtonEvent != null)
+ LeftMenuButtonEvent.Invoke(pbea);
+
+ //_buttonActive = false;
+ }
+ }
+ else if (iVKCode == (uint)Keys.RWin || iVKCode == (uint)Keys.F4 || iVKCode == (uint)Keys.F2)
+ {
+ //if (!_buttonActive)
+ {
+ //_buttonActive = true;
+
+ PhoneButtonEventArgs pbea = new PhoneButtonEventArgs(iVKCode, 1);
+ if (RightMenuButtonEvent != null)
+ RightMenuButtonEvent.Invoke(pbea);
+
+ //_buttonActive = false;
+ }
+ }
+ }
+
+ return 1;
+ }
+ }
+
+ // The class to hold the information about an event firing
+ public class PhoneButtonEventArgs : EventArgs
+ {
+ public PhoneButtonEventArgs(uint button, int direction)
+ {
+ this.button = button;
+ this.direction = direction;
+ }
+ public readonly uint button;
+ public readonly int direction;
+ }
+}
Added: Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.Designer.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,90 @@
+namespace Roam.Test.Sandbox
+{
+ partial class PhoneButtonManagerTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this._menuItemStartStop = new System.Windows.Forms.MenuItem();
+ this._scrollableLabel = new Roam.UI.Controls.ScrollableLabel();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this._menuItemStartStop);
+ this.menuItem2.Text = "Menu";
+ //
+ // _menuItemStartStop
+ //
+ this._menuItemStartStop.Text = "Stop";
+ this._menuItemStartStop.Click += new System.EventHandler(this.menuItem3_Click);
+ //
+ // _scrollableLabel
+ //
+ this._scrollableLabel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._scrollableLabel.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._scrollableLabel.Location = new System.Drawing.Point(0, 0);
+ this._scrollableLabel.Name = "_scrollableLabel";
+ this._scrollableLabel.Size = new System.Drawing.Size(240, 266);
+ this._scrollableLabel.TabIndex = 2;
+ this._scrollableLabel.Text = "scrollableLabel1";
+ //
+ // PhoneButtonManagerTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._scrollableLabel);
+ this.Menu = this.mainMenu1;
+ this.Name = "PhoneButtonManagerTest";
+ this.Text = "ButtonManagerTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem _menuItemStartStop;
+ private Roam.UI.Controls.ScrollableLabel _scrollableLabel;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Roam.Test.Sandbox
+{
+ public partial class PhoneButtonManagerTest : Form
+ {
+ PhoneButtonManager _phoneButtonManager = new PhoneButtonManager();
+
+ public PhoneButtonManagerTest()
+ {
+ PhoneButtonManager.LeftMenuButtonEvent += new PhoneButtonManager.PhoneButtonDelegate(PhoneButtonManager_LeftMenuButtonEvent);
+ PhoneButtonManager.EscapeButtonEvent += new PhoneButtonManager.PhoneButtonDelegate(PhoneButtonManager_EscapeButtonEvent);
+ PhoneButtonManager.AnyButtonEvent += new PhoneButtonManager.PhoneButtonDelegate(PhoneButtonManager_AnyButtonEvent);
+ PhoneButtonManager.RightMenuButtonEvent += new PhoneButtonManager.PhoneButtonDelegate(PhoneButtonManager_RightMenuButtonEvent);
+
+ _phoneButtonManager.StartPhoneButtonManager();
+ //PhoneButtonManager.EnterTrapAllMode();
+
+ InitializeComponent();
+ }
+
+ void PhoneButtonManager_RightMenuButtonEvent(PhoneButtonEventArgs args)
+ {
+ _scrollableLabel.AddLine("RMBE: btn: {0} dir: {1}", args.button, args.direction);
+ }
+
+ void PhoneButtonManager_AnyButtonEvent(PhoneButtonEventArgs args)
+ {
+ _scrollableLabel.AddLine("ABE: btn: {0} dir: {1}", args.button, args.direction);
+ }
+
+ void PhoneButtonManager_EscapeButtonEvent(PhoneButtonEventArgs args)
+ {
+ _scrollableLabel.AddLine("EBE: btn: {0} dir: {1}", args.button, args.direction);
+ }
+
+ private void PhoneButtonManager_LeftMenuButtonEvent(PhoneButtonEventArgs args)
+ {
+ _scrollableLabel.AddLine("LMBE: btn: {0} dir: {1}", args.button, args.direction);
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void menuItem3_Click(object sender, EventArgs e)
+ {
+ if (_menuItemStartStop.Text == "Stop")
+ {
+ _menuItemStartStop.Text = "Start";
+ _phoneButtonManager.StopPhoneButtonManager();
+ }
+ else
+ {
+ _menuItemStartStop.Text = "Stop";
+ _phoneButtonManager.StartPhoneButtonManager();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/PhoneButtonManagerTest.resx 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/TimeTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/TimeTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/TimeTest.Designer.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,83 @@
+namespace Roam.Test.Sandbox
+{
+ partial class TimeTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.scrollableLabel1 = new Roam.UI.Controls.ScrollableLabel();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // menuItem2
+ //
+ this.menuItem2.Text = "Refresh";
+ this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
+ //
+ // scrollableLabel1
+ //
+ this.scrollableLabel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.scrollableLabel1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this.scrollableLabel1.Location = new System.Drawing.Point(0, 0);
+ this.scrollableLabel1.Name = "scrollableLabel1";
+ this.scrollableLabel1.Size = new System.Drawing.Size(240, 266);
+ this.scrollableLabel1.TabIndex = 0;
+ this.scrollableLabel1.Text = "scrollableLabel1";
+ //
+ // TimeTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this.scrollableLabel1);
+ this.Menu = this.mainMenu1;
+ this.Name = "TimeTest";
+ this.Text = "TimeTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private Roam.UI.Controls.ScrollableLabel scrollableLabel1;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/TimeTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/TimeTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/TimeTest.cs 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.Utils;
+
+namespace Roam.Test.Sandbox
+{
+ public partial class TimeTest : Form
+ {
+ int lastTickCount = 0;
+ DateTime lastDateTime;
+ long lastPerformanceCount = 0;
+
+ int curTickCount = 0;
+ DateTime curDateTime;
+ long curPerformanceCount = 0;
+
+ public TimeTest()
+ {
+ InitializeComponent();
+ scrollableLabel1.Text = "";
+ TakeTimeSnapshot();
+ }
+
+ private void TakeTimeSnapshot()
+ {
+ lastTickCount = curTickCount;
+ lastDateTime = curDateTime;
+ lastPerformanceCount = curPerformanceCount;
+
+ curTickCount = Environment.TickCount;
+ curDateTime = DateTime.Now;
+ curPerformanceCount = PerformanceUtils.GetTimestampMs();
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void menuItem2_Click(object sender, EventArgs e)
+ {
+ TakeTimeSnapshot();
+ scrollableLabel1.AddLine("TickCountDiffMs: {0} RawCurrent: {1}", (curTickCount - lastTickCount), curTickCount);
+ scrollableLabel1.AddLine("DateTimeDiffMs: {0} RawCurrent: {1}", ((TimeSpan)(curDateTime - lastDateTime)).TotalMilliseconds, curDateTime);
+ scrollableLabel1.AddLine("PerformanceCountDiffMs: {0} RawCurrent: {1}", (curPerformanceCount - lastPerformanceCount), curPerformanceCount);
+
+ //The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001.
+ // 100 nanoseconds
+ // 100 x 10-9 seconds
+ // 100 x 10-6 milliseconds
+ // 10 x 10-5 milliseconds
+ // 100 nanoseconds x 1 microseconds x 1 millisecond = 100/1000000 millseconds = 1/10000
+ // ---- ----
+ // 1000 nanoseconds 1000 microseconds
+ scrollableLabel1.AddLine("TicksDiffMs: {0} RawCurrent: {1}", (curDateTime.Ticks - lastDateTime.Ticks) / 10000, curDateTime.Ticks);
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/TimeTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/TimeTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/TimeTest.resx 2007-07-01 22:43:14 UTC (rev 80)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - applicat...
[truncated message content] |
|
From: <jon...@us...> - 2007-04-25 06:42:53
|
Revision: 79
http://roam.svn.sourceforge.net/roam/?rev=79&view=rev
Author: jonfroehlich
Date: 2007-04-24 23:42:49 -0700 (Tue, 24 Apr 2007)
Log Message:
-----------
1. added ShapeContains abstract method to ShapeItem
2. implemented ShapeContains in all the ShapeItem derived classes.
3. added a polygon contains point algorithm in DrawingUtils
4. added hex print out of colors in ColorUtils
5. updated file size / directory info in DirectoryUtils
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/ColorUtils.cs
Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs
Trunk/Source/Roam.Common/Utils/MathUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test.Desktop/Program.cs
Trunk/Source/Roam.Test.Desktop/Roam.Test.Desktop.csproj
Trunk/Source/Roam.UI/Drawing/EllipseItem.cs
Trunk/Source/Roam.UI/Drawing/ImageItem.cs
Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
Trunk/Source/Roam.UI/Drawing/StarItem.cs
Trunk/Source/Roam.UI/Drawing/VisualItem.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test.Desktop/ShapeItemTest.Designer.cs
Trunk/Source/Roam.Test.Desktop/ShapeItemTest.cs
Trunk/Source/Roam.Test.Desktop/ShapeItemTest.resx
Trunk/Source/Roam.UI/Drawing/PolygonItem.cs
Trunk/Source/Roam.UI/Drawing/RectangleItem.cs
Modified: Trunk/Source/Roam.Common/Utils/ColorUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/ColorUtils.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.Common/Utils/ColorUtils.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -55,6 +55,16 @@
return GetStaticColors()[colorName];
}
+ public static string ToHexadecimalRgb(Color color)
+ {
+ return color.ToArgb().ToString("X").Substring(2);
+ }
+
+ public static string ToString(Color color)
+ {
+ return string.Format("[{0}, {1}, {2}, {3}]", color.R, color.G, color.B, color.A);
+ }
+
public static Color GetRandomColor()
{
Random rand = new Random();
@@ -74,6 +84,20 @@
return HsbToRgb(hsl);
}
+ public static Color Darken(Color c)
+ {
+ Hsb hsl = RgbToHsb(c);
+ hsl.Brightness = Math.Max(0, hsl.Brightness - 0.05);
+ return HsbToRgb(hsl);
+ }
+
+ public static Color Lighten(Color c)
+ {
+ Hsb hsl = RgbToHsb(c);
+ hsl.Brightness = Math.Min(1, hsl.Brightness + 0.05);
+ return HsbToRgb(hsl);
+ }
+
/// <summary>
/// Sets the absolute brightness of a colour
/// </summary>
Modified: Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -40,6 +40,11 @@
public static long GetSize(string directoryPath, bool recursive)
{
+ return GetSize(directoryPath, recursive, string.Empty);
+ }
+
+ public static long GetSize(string directoryPath, bool recursive, string fileSearchPattern)
+ {
long size = 0;
if (recursive)
@@ -47,11 +52,14 @@
string[] directories = Directory.GetDirectories(directoryPath);
foreach (string directory in directories)
{
- size += GetSize(directory, recursive);
+ size += GetSize(directory, recursive, fileSearchPattern);
}
}
- string[] files = Directory.GetFiles(directoryPath);
+ string[] files = string.IsNullOrEmpty(fileSearchPattern) ?
+ Directory.GetFiles(directoryPath) :
+ Directory.GetFiles(directoryPath, fileSearchPattern);
+
foreach (string file in files)
{
FileInfo fi = new FileInfo(file);
@@ -61,8 +69,39 @@
return size;
}
+ /// <summary>
+ /// Returns a list of FileInfo objects for this directory and all sub-directories
+ /// </summary>
+ /// <param name="directoryPath"></param>
+ /// <returns></returns>
+ public static List<FileInfo> GetFileInfos(string directoryPath)
+ {
+ return GetFileInfos(directoryPath, true);
+ }
+
+ /// <summary>
+ /// Returns a list of FileInfo objects. If recursive is true, this list includes
+ /// all FileInfo objects found in sub-directories
+ /// </summary>
+ /// <param name="directoryPath"></param>
+ /// <param name="recursive"></param>
+ /// <returns></returns>
public static List<FileInfo> GetFileInfos(string directoryPath, bool recursive)
{
+ return GetFileInfos(directoryPath, recursive, string.Empty);
+ }
+
+ /// <summary>
+ /// Returns a list of FileInfo objects. If recursive is true, this list includes
+ /// all FileInfo objects found in sub-directories. If fileSearchPattern != string.Empty,
+ /// this list only includes those files that match the file search pattern.
+ /// </summary>
+ /// <param name="directoryPath"></param>
+ /// <param name="recursive"></param>
+ /// <param name="fileSearchPattern"></param>
+ /// <returns></returns>
+ public static List<FileInfo> GetFileInfos(string directoryPath, bool recursive, string fileSearchPattern)
+ {
List<FileInfo> listFileInfos = new List<FileInfo>();
if (recursive)
@@ -70,11 +109,14 @@
string[] directories = Directory.GetDirectories(directoryPath);
foreach (string directory in directories)
{
- listFileInfos.AddRange(GetFileInfos(directoryPath, recursive));
+ listFileInfos.AddRange(GetFileInfos(directoryPath, recursive, fileSearchPattern));
}
}
- string[] files = Directory.GetFiles(directoryPath);
+ string[] files = string.IsNullOrEmpty(fileSearchPattern) ?
+ Directory.GetFiles(directoryPath) :
+ Directory.GetFiles(directoryPath, fileSearchPattern);
+
foreach (string file in files)
{
listFileInfos.Add(new FileInfo(file));
@@ -83,19 +125,31 @@
return listFileInfos;
}
+ public static int GetNumFiles(string directoryPath)
+ {
+ return GetNumFiles(directoryPath, true);
+ }
+
public static int GetNumFiles(string directoryPath, bool recursive)
{
+ return GetNumFiles(directoryPath, recursive, string.Empty);
+ }
+
+ public static int GetNumFiles(string directoryPath, bool recursive, string fileSearchPattern)
+ {
int numFiles = 0;
if (recursive)
{
string[] directories = Directory.GetDirectories(directoryPath);
foreach (string directory in directories)
{
- numFiles += GetNumFiles(directoryPath, recursive);
+ numFiles += GetNumFiles(directoryPath, recursive, fileSearchPattern);
}
}
- string[] files = Directory.GetFiles(directoryPath);
+ string[] files = string.IsNullOrEmpty(fileSearchPattern) ?
+ Directory.GetFiles(directoryPath) :
+ Directory.GetFiles(directoryPath, fileSearchPattern);
numFiles += files.Length;
return numFiles;
}
Modified: Trunk/Source/Roam.Common/Utils/MathUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -28,6 +28,14 @@
/// <author>Jon Froehlich</author>
public static class MathUtils
{
+
+ public static double GetDistance(Point ptStart, Point ptEnd)
+ {
+ int xDiff = ptEnd.X - ptStart.X;
+ int yDiff = ptEnd.Y - ptStart.Y;
+ return Math.Sqrt((xDiff * xDiff) + (yDiff * yDiff));
+ }
+
/// <summary>
/// Gets the angle in radians between these two points and the Vector (1,0)
/// </summary>
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-25 06:42:49 UTC (rev 79)
@@ -483,7 +483,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.Test.Desktop/Program.cs
===================================================================
--- Trunk/Source/Roam.Test.Desktop/Program.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.Test.Desktop/Program.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -35,7 +35,7 @@
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MeasureStringTest());
+ Application.Run(new ShapeItemTest());
}
}
}
Modified: Trunk/Source/Roam.Test.Desktop/Roam.Test.Desktop.csproj
===================================================================
--- Trunk/Source/Roam.Test.Desktop/Roam.Test.Desktop.csproj 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.Test.Desktop/Roam.Test.Desktop.csproj 2007-04-25 06:42:49 UTC (rev 79)
@@ -79,6 +79,10 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="ShapeItemTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>ShapeItemTest.cs</DependentUpon>
+ </EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
@@ -93,6 +97,12 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
+ <Compile Include="ShapeItemTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="ShapeItemTest.Designer.cs">
+ <DependentUpon>ShapeItemTest.cs</DependentUpon>
+ </Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Roam.Common\Roam.Common.csproj">
Added: Trunk/Source/Roam.Test.Desktop/ShapeItemTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test.Desktop/ShapeItemTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test.Desktop/ShapeItemTest.Designer.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -0,0 +1,47 @@
+namespace Roam.Test.Desktop
+{
+ partial class ShapeItemTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.SuspendLayout();
+ //
+ // ShapeItemTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(292, 273);
+ this.DoubleBuffered = true;
+ this.Name = "ShapeItemTest";
+ this.Text = "ShapeItemTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test.Desktop/ShapeItemTest.cs
===================================================================
--- Trunk/Source/Roam.Test.Desktop/ShapeItemTest.cs (rev 0)
+++ Trunk/Source/Roam.Test.Desktop/ShapeItemTest.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -0,0 +1,83 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.UI.Drawing;
+using System.Diagnostics;
+using Roam.UI.Utils;
+
+namespace Roam.Test.Desktop
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public partial class ShapeItemTest : Form
+ {
+ private ShapeItem _shapeItem;
+ private Insets _insets = new Insets(10, 10, 10, 10);
+
+ public ShapeItemTest()
+ {
+ InitializeComponent();
+ this.DoubleBuffered = true;
+ //_shapeItem = new StarItem(CalculateShapeSize(), new Point(_insets.Left, _insets.Top));
+ //_shapeItem = new EllipseItem(CalculateShapeSize(), new Point(_insets.Left, _insets.Top));
+ _shapeItem = new RectangleItem(CalculateShapeSize(), new Point(_insets.Left, _insets.Top));
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ _shapeItem.Draw(e.Graphics, _shapeItem.GetBounds(e.Graphics));
+ base.OnPaint(e);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ if (this.ClientSize.Width > 0 && this.ClientSize.Height > 0)
+ {
+ _shapeItem.ShapeSize = CalculateShapeSize();
+ this.Invalidate();
+ }
+
+ base.OnResize(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ Stopwatch sw = Stopwatch.StartNew();
+ bool contains = _shapeItem.ShapeContains(e.Location);
+ sw.Stop();
+ Debug.WriteLine(string.Format("Mouse point {0} is inside shape {1}? {2} (calculated in {3} ms)",
+ DrawingUtils.ToString(e.Location), DrawingUtils.ToString(new Rectangle(_shapeItem.Location, _shapeItem.ShapeSize)),
+ contains, sw.ElapsedMilliseconds));
+ base.OnMouseMove(e);
+ }
+
+ private Size CalculateShapeSize()
+ {
+ return new Size(ClientSize.Width - _insets.TotalHorizontalInset,
+ ClientSize.Height - _insets.TotalVerticalInset); ;
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test.Desktop/ShapeItemTest.resx
===================================================================
--- Trunk/Source/Roam.Test.Desktop/ShapeItemTest.resx (rev 0)
+++ Trunk/Source/Roam.Test.Desktop/ShapeItemTest.resx 2007-04-25 06:42:49 UTC (rev 79)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Modified: Trunk/Source/Roam.UI/Drawing/EllipseItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/EllipseItem.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Drawing/EllipseItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -28,6 +28,7 @@
/// <author>Jon Froehlich</author>
public class EllipseItem : ShapeItem
{
+ #region Constructors
public EllipseItem() : base() { }
public EllipseItem(string label) : base(label) { }
public EllipseItem(Size size)
@@ -36,48 +37,34 @@
: base(size, location) { }
public EllipseItem(Size size, Point location, string label)
: base(size, location, label) { }
-
+ #endregion Constructors
+
protected override void DrawShape(Graphics g, int x, int y)
{
- SolidBrush shapeBrush = new SolidBrush(BackColor);
- Pen shapePen = new Pen(BorderColor, PenWidth);
-
+ SolidBrush shapeBrush = new SolidBrush(GetCurrentShapeBackColor());
+ Pen shapePen = new Pen(GetCurrentBorderColor(), PenWidth);
+
g.FillEllipse(shapeBrush, x, y, ShapeSize.Width, ShapeSize.Height);
g.DrawEllipse(shapePen, x, y, ShapeSize.Width, ShapeSize.Height);
shapeBrush.Dispose();
shapePen.Dispose();
}
- }
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public class RectangleItem : ShapeItem
- {
- public RectangleItem() : base() { }
- public RectangleItem(string label) : base(label) { }
- public RectangleItem(Size size)
- : base(size) { }
- public RectangleItem(Size size, Point location)
- : base(size, location) { }
- public RectangleItem(Size size, Point location, string label)
- : base(size, location, label) { }
-
- protected override void DrawShape(Graphics g, int x, int y)
+ public override bool ShapeContains(Point p)
{
- SolidBrush shapeBrush = new SolidBrush(BackColor);
- Pen shapePen = new Pen(BorderColor, PenWidth);
+ //That point is inside the ellipse whenever
+ //((x-x0)/a)^2 + ((y-y0)/b)^2 <= 1
+
+ double xRadius = ShapeWidth / 2.0;
+ double yRadius = ShapeHeight / 2.0;
+ double x0 = xRadius;
+ double y0 = yRadius;
- g.FillEllipse(shapeBrush, x, y, ShapeSize.Width, ShapeSize.Height);
- g.DrawEllipse(shapePen, x, y, ShapeSize.Width, ShapeSize.Height);
+ double xCalc = (p.X - x0) / xRadius;
+ double yCalc = (p.Y - y0) / yRadius;
- shapeBrush.Dispose();
- shapePen.Dispose();
+ return xCalc * xCalc + yCalc * yCalc <= 1;
}
}
}
Modified: Trunk/Source/Roam.UI/Drawing/ImageItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ImageItem.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Drawing/ImageItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -79,6 +79,12 @@
}
#endregion Properties
+ #region Abstract Methods
+ protected abstract void DrawImage(Graphics g, int x, int y);
+ protected abstract void ResizeImage(float newWidth, float newHeight);
+ #endregion
+
+ #region Methods
protected override void DrawShape(Graphics g, int x, int y)
{
DrawImage(g, x, y);
@@ -89,7 +95,10 @@
ResizeImage(newWidth, newHeight);
}
- protected abstract void DrawImage(Graphics g, int x, int y);
- protected abstract void ResizeImage(float newWidth, float newHeight);
+ public override bool ShapeContains(Point p)
+ {
+ return new Rectangle(this.Location.X, this.Location.Y, this.ShapeWidth, this.ShapeHeight).Contains(p);
+ }
+ #endregion Methods
}
}
Added: Trunk/Source/Roam.UI/Drawing/PolygonItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/PolygonItem.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/PolygonItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -0,0 +1,125 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using Roam.UI.Utils;
+
+namespace Roam.UI.Drawing
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public abstract class PolygonItem : ShapeItem
+ {
+ private Point[] _pts;
+
+ #region Constructors
+ public PolygonItem() : base() { }
+ public PolygonItem(string label) : base(label) { }
+ public PolygonItem(string label, object item) : base(label, item) { }
+ public PolygonItem(Size size) : this(size, new Point(0, 0)) { }
+ public PolygonItem(Size size, Point location)
+ : this(size, location, string.Empty) { }
+ public PolygonItem(Size size, Point location, string label)
+ : base(size, location, label)
+ {
+ }
+ #endregion Constructors
+
+ #region Properties
+ public override Size ShapeSize
+ {
+ get { return base.ShapeSize; }
+ set
+ {
+ if (ShapeSize != value)
+ {
+ base.ShapeSize = value;
+ _pts = CreateShape();
+ }
+ }
+ }
+
+ public override int ShapeWidth
+ {
+ get { return base.ShapeWidth; }
+ set
+ {
+ if (ShapeSize.Width != value)
+ {
+ base.ShapeWidth = value;
+ _pts = CreateShape();
+ }
+ }
+ }
+
+ public override int ShapeHeight
+ {
+ get { return base.ShapeHeight; }
+ set
+ {
+ if (ShapeSize.Height != value)
+ {
+ base.ShapeHeight = value;
+ _pts = CreateShape();
+ }
+ }
+ }
+
+ protected virtual Point[] Points
+ {
+ get { return _pts; }
+ set { _pts = value; }
+ }
+ #endregion Properties
+
+ #region Abstract Methods
+ protected abstract Point[] CreateShape();
+ #endregion Abstract Methods
+
+ #region Methods
+ public override bool ShapeContains(Point p)
+ {
+ return DrawingUtils.IsPointInPolygon(p, _pts);
+ }
+
+ protected override void DrawShape(Graphics g, int x, int y)
+ {
+ if (_pts == null) { _pts = CreateShape(); }
+
+ Point[] pts = new Point[_pts.Length];
+ for (int i = 0; i < pts.Length; i++)
+ {
+ pts[i] = new Point(_pts[i].X + x, _pts[i].Y + y);
+ }
+
+ SolidBrush shapeBrush = new SolidBrush(GetCurrentShapeBackColor());
+ Pen shapePen = new Pen(GetCurrentBorderColor(), PenWidth);
+
+ g.FillPolygon(shapeBrush, pts);
+ g.DrawPolygon(shapePen, pts);
+
+ shapeBrush.Dispose();
+ shapePen.Dispose();
+ }
+ #endregion Methods
+ }
+}
Added: Trunk/Source/Roam.UI/Drawing/RectangleItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/RectangleItem.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/RectangleItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+
+namespace Roam.UI.Drawing
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class RectangleItem : ShapeItem
+ {
+ #region Constructors
+ public RectangleItem() : base() { }
+ public RectangleItem(string label) : base(label) { }
+ public RectangleItem(Size size)
+ : base(size) { }
+ public RectangleItem(Size size, Point location)
+ : base(size, location) { }
+ public RectangleItem(Size size, Point location, string label)
+ : base(size, location, label) { }
+ #endregion Constructors
+
+ public override bool ShapeContains(Point p)
+ {
+ return new Rectangle(this.Location.X, this.Location.Y, this.ShapeWidth, this.ShapeHeight).Contains(p);
+ }
+
+ protected override void DrawShape(Graphics g, int x, int y)
+ {
+ SolidBrush shapeBrush = new SolidBrush(GetCurrentShapeBackColor());
+ Pen shapePen = new Pen(GetCurrentBorderColor(), PenWidth);
+
+ g.FillRectangle(shapeBrush, x, y, ShapeSize.Width, ShapeSize.Height);
+ g.DrawRectangle(shapePen, x, y, ShapeSize.Width, ShapeSize.Height);
+
+ shapeBrush.Dispose();
+ shapePen.Dispose();
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ShapeItem.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Drawing/ShapeItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -16,6 +16,19 @@
private RelativeAlignment _textAlign = RelativeAlignment.Right;
private ContentAlignment _shapeAlign = ContentAlignment.TopCenter;
private ScaleMode _scaleMode = ScaleMode.None;
+
+ private Color _shapeBackColor = Color.LightBlue;
+ //private Color _shapeForeColor = Color.Black;
+ //private Color _shapeOutlineColor = Color.Black;
+
+ private Color _shapeSelectedBackColor = SystemColors.Highlight;
+ //private Color _shapeSelectedForeColor = SystemColors.HighlightText;
+ //private Color _shapeSelectedOutlineColor = Color.Black;
+
+ private Color _shapeDisabledBackColor = Color.LightGray;
+ //private Color _shapeDisabledForeColor = Color.Black;
+ //private Color _shapeDisabledOutlineColor = Color.Black;
+
#endregion Fields
#region Constructors
@@ -40,6 +53,70 @@
set { _penWidth = value; }
}
+ //public virtual Rectangle ShapeRectangle
+ //{
+ // get { return new Rectangle(this.Location.X, this.Location.Y, this.ShapeWidth, this.ShapeHeight); }
+ // set
+ // {
+ // ShapeSize = value.Size;
+ // Location = value.Location;
+ // }
+ //}
+
+ public virtual Color ShapeBackColor
+ {
+ get { return _shapeBackColor; }
+ set { _shapeBackColor = value; }
+ }
+
+ //public virtual Color ShapeForeColor
+ //{
+ // get { return _shapeForeColor; }
+ // set { _shapeForeColor = value; }
+ //}
+
+ //public virtual Color ShapeOutlineColor
+ //{
+ // get { return _shapeOutlineColor; }
+ // set { _shapeOutlineColor = value; }
+ //}
+
+ public virtual Color ShapeSelectedBackColor
+ {
+ get { return _shapeSelectedBackColor; }
+ set { _shapeSelectedBackColor = value; }
+ }
+
+ //public virtual Color ShapeSelectedForeColor
+ //{
+ // get { return _shapeSelectedForeColor; }
+ // set { _shapeSelectedForeColor = value; }
+ //}
+
+ //public virtual Color ShapeSelectedOutlineColor
+ //{
+ // get { return _shapeSelectedOutlineColor; }
+ // set { _shapeSelectedOutlineColor = value; }
+ //}
+
+ public virtual Color ShapeDisabledBackColor
+ {
+ get { return _shapeDisabledBackColor; }
+ set { _shapeDisabledBackColor = value; }
+ }
+
+ //public virtual Color ShapeDisabledForeColor
+ //{
+ // get { return _shapeDisabledForeColor; }
+ // set { _shapeDisabledForeColor = value; }
+ //}
+
+ //public virtual Color ShapeDisabledOutlineColor
+ //{
+ // get { return _shapeDisabledOutlineColor; }
+ // set { _shapeDisabledOutlineColor = value; }
+ //}
+
public virtual Size ShapeSize
{
get { return _shapeSize; }
@@ -113,10 +190,38 @@
#endregion Properties
#region Abstract Methods
+ /// <summary>
+ /// TODO : So, as of now, this abstract method is sort of weird because we don't actually define our
+ /// shape location until DrawShape which is based on a set of parameters such as TextAlign,
+ /// ShapeAlign, text size, etc. I'll need to change this in the future. For now, I'm
+ /// just writing the implementers like the shape is drawn at Location.X, Location.Y
+ /// </summary>
+ /// <param name="p"></param>
+ public abstract bool ShapeContains(Point p);
protected abstract void DrawShape(Graphics g, int x, int y);
#endregion Abstract Methods
#region Methods
+ //public virtual Color GetCurrentShapeOutlineColor()
+ //{
+ // if (Selected) { return ShapeSelectedBorderColor; }
+ // else if (!Enabled) { return ShapeDisabledBorderColor; }
+ // else { return ShapeOutlineColor; }
+ //}
+
+ //public virtual Color GetCurrentShapeForeColor()
+ //{
+ // if (Selected) { return ShapeSelectedForeColor; }
+ // else if (!Enabled) { return ShapeDisabledForeColor; }
+ // else { return ShapeForeColor; }
+ //}
+ public virtual Color GetCurrentShapeBackColor()
+ {
+ if (Selected) { return ShapeSelectedBackColor; }
+ else if (!Enabled) { return ShapeDisabledBackColor; }
+ else { return ShapeBackColor; }
+ }
+
public override Rectangle GetBounds(Graphics g)
{
SizeF prefixSize = GetPrefixSize(g);
@@ -253,7 +358,6 @@
RectangleF layoutRectangle = new RectangleF(xLabel + ptOffset.X,
yLabel + ptOffset.Y, labelSize.Width, labelSize.Height);
DrawText(g, layoutRectangle);
-
}
//public virtual ScaleMode GetAutoScaleMode()
@@ -337,7 +441,6 @@
{
this.ShapeSize = new Size((int)newWidth, (int)newHeight);
}
- #endregion Methods
-
+ #endregion Methods
}
}
Modified: Trunk/Source/Roam.UI/Drawing/StarItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -29,14 +29,14 @@
///
/// </remarks>
/// <author>Jon Froehlich</author>
- public class StarItem : ShapeItem
+ public class StarItem : PolygonItem
{
#region Fields
private int _numStarPoints = 5;
private double _pointiness = 2.5;
- private Point[] _pts;
#endregion Fields
+ #region Constructors
public StarItem() : base() { }
public StarItem(string label) : base(label) { }
public StarItem(Size size)
@@ -53,47 +53,9 @@
_numStarPoints = numStarPoints;
_pointiness = pointiness;
}
+ #endregion Constructors
#region Properties
- public override Size ShapeSize
- {
- get { return base.ShapeSize; }
- set
- {
- if (ShapeSize != value)
- {
- base.ShapeSize = value;
- _pts = CreateStar();
- }
- }
- }
-
- public override int ShapeWidth
- {
- get { return base.ShapeWidth; }
- set
- {
- if (ShapeSize.Width != value)
- {
- base.ShapeWidth = value;
- _pts = CreateStar();
- }
- }
- }
-
- public override int ShapeHeight
- {
- get { return base.ShapeHeight; }
- set
- {
- if (ShapeSize.Height != value)
- {
- base.ShapeHeight = value;
- _pts = CreateStar();
- }
- }
- }
-
public int NumPoints
{
get { return _numStarPoints; }
@@ -107,7 +69,7 @@
if (_numStarPoints != value)
{
_numStarPoints = value;
- _pts = CreateStar();
+ Points = CreateShape();
}
}
}
@@ -120,34 +82,15 @@
if (_pointiness != value)
{
_pointiness = value;
- _pts = CreateStar();
+ Points = CreateShape();
}
}
}
#endregion Properties
- protected override void DrawShape(Graphics g, int x, int y)
+ #region Methods
+ protected override Point[] CreateShape()
{
- if (_pts == null) { _pts = CreateStar(); }
-
- Point [] pts = new Point[_pts.Length];
- for (int i = 0; i < pts.Length; i++)
- {
- pts[i] = new Point(_pts[i].X + x, _pts[i].Y + y);
- }
-
- SolidBrush starBrush = new SolidBrush(BackColor);
- Pen starPen = new Pen(BorderColor, PenWidth);
-
- g.FillPolygon(starBrush, pts);
- g.DrawPolygon(starPen, pts);
-
- starBrush.Dispose();
- starPen.Dispose();
- }
-
- protected virtual Point[] CreateStar()
- {
return CreateStar(ShapeSize, _numStarPoints, _pointiness);
}
@@ -177,5 +120,6 @@
return pts;
}
+ #endregion Methods
}
}
Modified: Trunk/Source/Roam.UI/Drawing/VisualItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/VisualItem.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Drawing/VisualItem.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -38,6 +38,8 @@
private bool _isSelected = false;
private bool _isFiltered = false;
private bool _isEnabled = true;
+ private bool _isVisible = true;
+
private int _startTextHighlight = -1;
private int _textHighlightLength = -1;
private Font _font = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Regular);
@@ -120,6 +122,15 @@
set { _isFiltered = value; }
}
+ //TODO : just added this on 4/21, but i have not yet updated the classes that use
+ //VisualItems with functionality that looks to see if a item is visible before drawing it
+ //or calculating layout... Perhaps combine this and filtered? Do we need two separate flags for that?
+ public virtual bool Visible
+ {
+ get { return _isVisible; }
+ set { _isVisible = value; }
+ }
+
public virtual Font Font
{
get { return _font; }
@@ -155,36 +166,6 @@
}
}
- public virtual Color CurrentBorderColor
- {
- get
- {
- if (Selected) { return SelectedBorderColor; }
- else if (!Enabled) { return DisabledBorderColor; }
- else { return BorderColor; }
- }
- }
-
- public virtual Color CurrentForeColor
- {
- get
- {
- if (Selected) { return SelectedForeColor; }
- else if (!Enabled) { return DisabledForeColor; }
- else { return ForeColor; }
- }
- }
-
- public virtual Color CurrentBackColor
- {
- get
- {
- if (Selected) { return SelectedBackColor; }
- else if (!Enabled) { return DisabledBackColor; }
- else { return BackColor; }
- }
- }
-
public virtual Color BorderColor
{
get { return _borderColor; }
@@ -311,6 +292,27 @@
}
}
+ public virtual Color GetCurrentBorderColor()
+ {
+ if (Selected) { return SelectedBorderColor; }
+ else if (!Enabled) { return DisabledBorderColor; }
+ else { return BorderColor; }
+ }
+
+ public virtual Color GetCurrentForeColor()
+ {
+ if (Selected) { return SelectedForeColor; }
+ else if (!Enabled) { return DisabledForeColor; }
+ else { return ForeColor; }
+ }
+
+ public virtual Color GetCurrentBackColor()
+ {
+ if (Selected) { return SelectedBackColor; }
+ else if (!Enabled) { return DisabledBackColor; }
+ else { return BackColor; }
+ }
+
public virtual Rectangle GetBounds(Graphics g)
{
return GetTextBounds(g);
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-25 06:42:49 UTC (rev 79)
@@ -198,6 +198,7 @@
<Compile Include="Drawing\IVisualItem.cs" />
<Compile Include="Drawing\LinearGradient.cs" />
<Compile Include="Drawing\ListItem.cs" />
+ <Compile Include="Drawing\PolygonItem.cs" />
<Compile Include="Drawing\RadialGradient.cs" />
<Compile Include="Drawing\RadioItem.cs" />
<Compile Include="Drawing\RelativeAlignment.cs" />
@@ -227,6 +228,7 @@
<Compile Include="Forms\SplashForm.Designer.cs">
<DependentUpon>SplashForm.cs</DependentUpon>
</Compile>
+ <Compile Include="Drawing\RectangleItem.cs" />
<Compile Include="Utils\DesktopUtils.cs" />
<Compile Include="Utils\DrawingUtils.cs" />
<Compile Include="Forms\FormFactory.cs">
Modified: Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-04-17 07:41:29 UTC (rev 78)
+++ Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-04-25 06:42:49 UTC (rev 79)
@@ -370,6 +370,125 @@
return new Rectangle(topLeft.X, topLeft.Y, botRight.X - topLeft.X, botRight.Y - topLeft.Y);
}
+ /// <summary>
+ /// This routine determines if the point passed is in the polygon. It uses
+ /// the classical polygon hit-testing algorithm: a horizontal ray starting
+ /// at the point is extended infinitely rightwards and the number of
+ /// polygon edges that intersect the ray are counted. If the number is odd,
+ /// the point is inside the polygon.
+ ///
+ /// Code adapted from: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q121960
+ /// </summary>
+ /// <param name="polygon"></param>
+ /// <param name="ptTest"></param>
+ /// <returns></returns>
+ public static bool IsPointInPolygon(Point ptTest, Point[] polygon)
+ {
+ Rectangle boundingBox = GetMinimumAxisAlignedBoundingBox(polygon);
+ return IsPointInPolygon(ptTest, polygon, boundingBox);
+ }
+
+ /// <summary>
+ /// This routine determines if the point passed is in the polygon. It uses
+ /// the classical polygon hit-testing algorithm: a horizontal ray starting
+ /// at the point is extended infinitely rightwards and the number of
+ /// polygon edges that intersect the ray are counted. If the number is odd,
+ /// the point is inside the polygon.
+ ///
+ /// Code adapted from: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q121960
+ /// </summary>
+ /// <param name="polygon"></param>
+ /// <param name="ptTest"></param>
+ /// <param name="boundingBox"></param>
+ /// <returns>true if point is in polygon, false otherwise</returns>
+ public static bool IsPointInPolygon(Point ptTest, Point[] polygon, Rectangle boundingBox)
+ {
+ Point pt1, pt2;
+ int numIntersections = 0;
+
+ if (!boundingBox.Contains(ptTest)) { return false; }
+
+ pt1 = pt2 = ptTest;
+ pt2.X = boundingBox.Right + 50;
+
+ // Now go through each of the lines in the polygon and see if it
+ // intersects
+ for(int i=0; i<polygon.Length - 1; i++)
+ {
+ if (Intersect(ptTest, pt2, polygon[i], polygon[i + 1]))
+ {
+ numIntersections++;
+ }
+ }
+
+ // And the last line
+ if (Intersect(ptTest, pt2, polygon[polygon.Length - 1], polygon[0]))
+ {
+ numIntersections++;
+ }
+
+ //return (numIntersections & 1);
+ return (numIntersections % 2 == 1);
+ }
+
+ /// <summary>
+ /// Given two line segments, determine if they intersect.
+ ///
+ /// Code adapted from: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q121960
+ /// </summary>
+ /// <param name="p1"></param>
+ /// <param name="p2"></param>
+ /// <param name="p3"></param>
+ /// <param name="p4"></param>
+ /// <returns>true if they intersect, false otherwise</returns>
+ public static bool Intersect(Point p1, Point p2, Point p3, Point p4)
+ {
+ return (((CCW(p1, p2, p3) * CCW(p1, p2, p4)) <= 0)
+ && ((CCW(p3, p4, p1) * CCW(p3, p4, p2) <= 0)));
+ }
+
+ /// <summary>
+ /// Determines, given three points, if when travelling from the first to
+ /// the second to the third, we travel in a counterclockwise direction.
+ ///
+ /// Code adapted from: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q121960
+ /// </summary>
+ /// <param name="p0"></param>
+ /// <param name="p1"></param>
+ /// <param name="p2"></param>
+ /// <returns>1 if the movement is in a counterclockwise direction, -1 if not.</returns>
+ private static int CCW(Point p0, Point p1, Point p2)
+ {
+ long dx1, dx2;
+ long dy1, dy2;
+
+ dx1 = p1.X - p0.X; dx2 = p2.X - p0.X;
+ dy1 = p1.Y - p0.Y; dy2 = p2.Y - p0.Y;
+
+ /* This is basically a slope comparison: we don't do divisions because
+ * of divide by zero possibilities with pure horizontal and pure
+ * vertical lines.
+ */
+ return ((dx1 * dy2 > dy1 * dx2) ? 1 : -1);
+ }
+
+ //public static Rectangle GetBoundingBox(Point[] polygon)
+ //{
+ // int xmin = int.MaxValue, ymin = int.MaxValue;
+ // int xmax = int.MinValue, ymax = int.MinValue;
+ // foreach(Point p in polygon)
+ // {
+ // if (p.X < xmin) { xmin = ppt->x; }
+
+ // if (ppt->x > xmax) { xmax = ppt->x; }
+
+ // if (ppt->y < ymin)
+ // ymin = ppt->y;
+ // if (ppt->y > ymax)
+ // ymax = ppt->y;
+ // }
+ //}
+
}
/// <summary>
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-17 07:41:31
|
Revision: 78
http://roam.svn.sourceforge.net/roam/?rev=78&view=rev
Author: jonfroehlich
Date: 2007-04-17 00:41:29 -0700 (Tue, 17 Apr 2007)
Log Message:
-----------
fixed up auto scaling in ShapeItem
added EllipseItem and RectangleItem but have not tested them
Modified Paths:
--------------
Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
Trunk/Source/Roam.UI/Controls/ImageButton.cs
Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
Trunk/Source/Roam.UI/Drawing/StarItem.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.UI/Drawing/EllipseItem.cs
Modified: Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs 2007-04-16 09:22:14 UTC (rev 77)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs 2007-04-17 07:41:29 UTC (rev 78)
@@ -34,8 +34,11 @@
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this.menuItem6 = new System.Windows.Forms.MenuItem();
this._menuItemContentAlign = new System.Windows.Forms.MenuItem();
this._menuItemTextAlign = new System.Windows.Forms.MenuItem();
+ this._menuItemAutoScale = new System.Windows.Forms.MenuItem();
this.label5 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
@@ -45,7 +48,7 @@
this._numericTextBoxPointiness2 = new Roam.UI.Controls.NumericTextBox();
this._numericTextBoxPointiness1 = new Roam.UI.Controls.NumericTextBox();
this.label3 = new System.Windows.Forms.Label();
- this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this.menuItem7 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// mainMenu1
@@ -63,12 +66,15 @@
this.menuItem2.MenuItems.Add(this.menuItem3);
this.menuItem2.MenuItems.Add(this._menuItemContentAlign);
this.menuItem2.MenuItems.Add(this._menuItemTextAlign);
+ this.menuItem2.MenuItems.Add(this._menuItemAutoScale);
this.menuItem2.Text = "Menu";
//
// menuItem3
//
this.menuItem3.MenuItems.Add(this.menuItem4);
this.menuItem3.MenuItems.Add(this.menuItem5);
+ this.menuItem3.MenuItems.Add(this.menuItem6);
+ this.menuItem3.MenuItems.Add(this.menuItem7);
this.menuItem3.Text = "Set";
//
// menuItem4
@@ -76,6 +82,16 @@
this.menuItem4.Text = "Label";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
+ // menuItem5
+ //
+ this.menuItem5.Text = "BackColor";
+ this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
+ //
+ // menuItem6
+ //
+ this.menuItem6.Text = "MaximumWidth";
+ this.menuItem6.Click += new System.EventHandler(this.OnMenuItemMaximumWidth);
+ //
// _menuItemContentAlign
//
this._menuItemContentAlign.Text = "Content Align";
@@ -84,6 +100,11 @@
//
this._menuItemTextAlign.Text = "Text Align";
//
+ // _menuItemAutoScale
+ //
+ this._menuItemAutoScale.Text = "Auto Scale Shape To Text";
+ this._menuItemAutoScale.Click += new System.EventHandler(this.OnMenuItemAutoScale);
+ //
// label5
//
this.label5.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
@@ -171,10 +192,10 @@
this.label3.Size = new System.Drawing.Size(12, 18);
this.label3.Text = ".";
//
- // menuItem5
+ // menuItem7
//
- this.menuItem5.Text = "BackColor";
- this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
+ this.menuItem7.Text = "Random Label";
+ this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// StarItemTest
//
@@ -216,5 +237,8 @@
private System.Windows.Forms.MenuItem _menuItemContentAlign;
private System.Windows.Forms.MenuItem _menuItemTextAlign;
private System.Windows.Forms.MenuItem menuItem5;
+ private System.Windows.Forms.MenuItem _menuItemAutoScale;
+ private System.Windows.Forms.MenuItem menuItem6;
+ private System.Windows.Forms.MenuItem menuItem7;
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs 2007-04-16 09:22:14 UTC (rev 77)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs 2007-04-17 07:41:29 UTC (rev 78)
@@ -23,6 +23,7 @@
using Roam.UI.Forms;
using Roam.Common.Utils;
using Roam.UI.Controls;
+using Roam.Test.Utils;
namespace Roam.Test.Sandbox
{
@@ -162,6 +163,22 @@
}
}
+ private void OnMenuItemMaximumWidth(object sender, EventArgs e)
+ {
+ NumericTextBox numericTextBox = new NumericTextBox();
+ numericTextBox.SelectTextOnFocus = true;
+ numericTextBox.Text = _starItem.MaximumWidth.ToString();
+ Form form = FormFactory.Create("Maximum Width: ", numericTextBox);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (_starItem.MaximumWidth != numericTextBox.TextAsInt)
+ {
+ _starItem.MaximumWidth = numericTextBox.TextAsInt;
+ this.Invalidate();
+ }
+ }
+ }
+
private void menuItem5_Click(object sender, EventArgs e)
{
NumericTextBox redTextBox = new Roam.UI.Controls.NumericTextBox();
@@ -188,5 +205,35 @@
this.Invalidate();
}
}
+
+ private void OnMenuItemAutoScale(object sender, EventArgs e)
+ {
+ _menuItemAutoScale.Checked = !_menuItemAutoScale.Checked;
+ _numericTextBoxSizeWidth.Enabled = !_menuItemAutoScale.Checked;
+ _numericTextBoxSizeHeight.Enabled = !_menuItemAutoScale.Checked;
+
+ if (_menuItemAutoScale.Checked)
+ {
+ _starItem.AutoScaleMode = ScaleMode.ScaleToText;
+ //Graphics g = this.CreateGraphics();
+ //_starItem.SetAutoScaleMode(g, ScaleMode.ScaleToText);
+ //g.Dispose();
+ }
+ else
+ {
+ _starItem.AutoScaleMode = ScaleMode.None;
+ //Graphics g = this.CreateGraphics();
+ //_starItem.SetAutoScaleMode(g, ScaleMode.None);
+ //g.Dispose();
+ _starItem.ShapeSize = new Size(_numericTextBoxSizeWidth.TextAsInt, _numericTextBoxSizeHeight.TextAsInt);
+ }
+ this.Invalidate();
+ }
+
+ private void menuItem7_Click(object sender, EventArgs e)
+ {
+ _starItem.Label = TestUtils.GetRandomGettysburgString();
+ this.Invalidate();
+ }
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.UI/Controls/ImageButton.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ImageButton.cs 2007-04-16 09:22:14 UTC (rev 77)
+++ Trunk/Source/Roam.UI/Controls/ImageButton.cs 2007-04-17 07:41:29 UTC (rev 78)
@@ -141,12 +141,15 @@
public ScaleMode AutoScaleMode
{
- get { return _imageItem.AutoScaleMode; }
+ get { return _imageItem.AutoScaleMode; } //_imageItem.GetAutoScaleMode(); }
set
{
if (_imageItem.AutoScaleMode != value)
{
_imageItem.AutoScaleMode = value;
+ //Graphics g = this.CreateGraphics();
+ //_imageItem.SetAutoScaleMode(g, value);
+ //g.Dispose();
this.Invalidate();
}
}
Added: Trunk/Source/Roam.UI/Drawing/EllipseItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/EllipseItem.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/EllipseItem.cs 2007-04-17 07:41:29 UTC (rev 78)
@@ -0,0 +1,83 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+
+namespace Roam.UI.Drawing
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class EllipseItem : ShapeItem
+ {
+ public EllipseItem() : base() { }
+ public EllipseItem(string label) : base(label) { }
+ public EllipseItem(Size size)
+ : base(size) { }
+ public EllipseItem(Size size, Point location)
+ : base(size, location) { }
+ public EllipseItem(Size size, Point location, string label)
+ : base(size, location, label) { }
+
+ protected override void DrawShape(Graphics g, int x, int y)
+ {
+ SolidBrush shapeBrush = new SolidBrush(BackColor);
+ Pen shapePen = new Pen(BorderColor, PenWidth);
+
+ g.FillEllipse(shapeBrush, x, y, ShapeSize.Width, ShapeSize.Height);
+ g.DrawEllipse(shapePen, x, y, ShapeSize.Width, ShapeSize.Height);
+
+ shapeBrush.Dispose();
+ shapePen.Dispose();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class RectangleItem : ShapeItem
+ {
+ public RectangleItem() : base() { }
+ public RectangleItem(string label) : base(label) { }
+ public RectangleItem(Size size)
+ : base(size) { }
+ public RectangleItem(Size size, Point location)
+ : base(size, location) { }
+ public RectangleItem(Size size, Point location, string label)
+ : base(size, location, label) { }
+
+ protected override void DrawShape(Graphics g, int x, int y)
+ {
+ SolidBrush shapeBrush = new SolidBrush(BackColor);
+ Pen shapePen = new Pen(BorderColor, PenWidth);
+
+ g.FillEllipse(shapeBrush, x, y, ShapeSize.Width, ShapeSize.Height);
+ g.DrawEllipse(shapePen, x, y, ShapeSize.Width, ShapeSize.Height);
+
+ shapeBrush.Dispose();
+ shapePen.Dispose();
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ShapeItem.cs 2007-04-16 09:22:14 UTC (rev 77)
+++ Trunk/Source/Roam.UI/Drawing/ShapeItem.cs 2007-04-17 07:41:29 UTC (rev 78)
@@ -11,7 +11,7 @@
#region Fields
private int _vPadding = 2;
private int _hPadding = 3;
- private Size _size = new Size(50, 50);
+ private Size _shapeSize = new Size(50, 50);
private float _penWidth = 1;
private RelativeAlignment _textAlign = RelativeAlignment.Right;
private ContentAlignment _shapeAlign = ContentAlignment.TopCenter;
@@ -22,6 +22,15 @@
public ShapeItem() : base() { }
public ShapeItem(string label) : base(label) { }
public ShapeItem(string label, object item) : base(label, item) { }
+ public ShapeItem(Size size) : this(size, new Point(0, 0)) { }
+ public ShapeItem(Size size, Point location)
+ : this(size, location, string.Empty) { }
+ public ShapeItem(Size size, Point location, string label)
+ : base(label)
+ {
+ ShapeSize = size;
+ Location = location;
+ }
#endregion Constructors
#region Properties
@@ -33,7 +42,7 @@
public virtual Size ShapeSize
{
- get { return _size; }
+ get { return _shapeSize; }
set
{
if (value.Width < 1)
@@ -45,13 +54,13 @@
throw new ArgumentOutOfRangeException("Size", "The Size.Height must be greater than or equal to 1");
}
- _size = value;
+ _shapeSize = value;
}
}
public virtual int ShapeWidth
{
- get { return _size.Width; }
+ get { return _shapeSize.Width; }
set
{
if (value < 1)
@@ -65,7 +74,7 @@
public virtual int ShapeHeight
{
- get { return _size.Height; }
+ get { return _shapeSize.Height; }
set
{
if (value < 1)
@@ -101,7 +110,6 @@
get { return _scaleMode; }
set { _scaleMode = value; }
}
-
#endregion Properties
#region Abstract Methods
@@ -111,42 +119,25 @@
#region Methods
public override Rectangle GetBounds(Graphics g)
{
- SizeF prefixBounds = g.MeasureString(Prefix, Font);
-
- int availTextWidth = 0;
- if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below || _textAlign == RelativeAlignment.Over)
- {
- availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset);
- }
- else
- {
- availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset - ShapeWidth);
- }
-
- SizeF labelBounds = MaximumWidth > 0 ?
- GraphicsUtils.MeasureString(g, Label, Font, availTextWidth)
- : g.MeasureString(Label, Font);
- SizeF textBounds = new SizeF(labelBounds.Width + prefixBounds.Width,
- Math.Max(labelBounds.Height, prefixBounds.Height));
-
- if (AutoScaleMode == ScaleMode.ScaleToText)
- {
- ScaleShapeToText(labelBounds);
- }
-
+ SizeF prefixSize = GetPrefixSize(g);
+ SizeF labelSize = GetLabelSize(g);
+ SizeF labelPlusPrefixSize = new SizeF(labelSize.Width + prefixSize.Width,
+ Math.Max(labelSize.Height, prefixSize.Height));
int width = 0, height = 0;
if (_textAlign == RelativeAlignment.Left || _textAlign == RelativeAlignment.Right)
{
int horizSpaceBetweenImageAndText = string.IsNullOrEmpty(Label) ? 0 : _hPadding;
- width = (int)Math.Ceiling(textBounds.Width + horizSpaceBetweenImageAndText + ShapeWidth);
- height = (int)Math.Max(textBounds.Height, ShapeHeight);
+ width = (int)Math.Ceiling(labelPlusPrefixSize.Width + horizSpaceBetweenImageAndText + ShapeWidth);
+ height = (int)Math.Max(labelPlusPrefixSize.Height, ShapeHeight);
}
else if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below)
{
int vertSpaceBetweenImageAndText = string.IsNullOrEmpty(Label) ? 0 : _vPadding;
- width = (int)Math.Max(textBounds.Width, ShapeWidth);
- height = (int)Math.Ceiling(textBounds.Height + vertSpaceBetweenImageAndText + ShapeHeight);
+ width = (int)Math.Max(labelPlusPrefixSize.Width, ShapeWidth);
+ height = (int)Math.Ceiling(labelPlusPrefixSize.Height + vertSpaceBetweenImageAndText + ShapeHeight);
}
+
+ //TODO add in support for RelativeAlignment.Over
//else if (_textAlign == RelativeAlignment.Over)
//{
// width = (int)Math.Max(textBounds.Width, ImageWidth);
@@ -159,23 +150,11 @@
public override void Draw(Graphics g, Rectangle rectangle)
{
- SizeF prefixBounds = g.MeasureString(Prefix, Font);
- int availTextWidth = 0;
- if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below || _textAlign == RelativeAlignment.Over)
- {
- availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset);
- }
- else
- {
- availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset - ShapeWidth);
- }
+ SizeF prefixSize = GetPrefixSize(g);
+ SizeF labelSize = GetLabelSize(g);
+ SizeF labelPlusPrefixSize = new SizeF(labelSize.Width + prefixSize.Width,
+ Math.Max(labelSize.Height, prefixSize.Height));
- SizeF labelBounds = MaximumWidth > 0 ?
- GraphicsUtils.MeasureString(g, Label, Font, availTextWidth)
- : g.MeasureString(Label, Font);
- SizeF textBounds = new SizeF(labelBounds.Width + prefixBounds.Width,
- Math.Max(labelBounds.Height, prefixBounds.Height));
-
SizeF sampleBounds = g.MeasureString("1LQ!", Font);
int xShape = 0, yShape = 0, xLabel = 0, yLabel = 0;
int xOffset = 1, yOffset = 1;
@@ -184,7 +163,7 @@
if (TextAlign == RelativeAlignment.Left || TextAlign == RelativeAlignment.Right)
{
- if (textBounds.Height > ShapeHeight)
+ if (labelPlusPrefixSize.Height > ShapeHeight)
{
switch (_shapeAlign)
{
@@ -196,12 +175,12 @@
case ContentAlignment.MiddleLeft:
case ContentAlignment.MiddleCenter:
case ContentAlignment.MiddleRight:
- yShape = (int)(rectangle.Y + yOffset + textBounds.Height / 2.0f - ShapeHeight / 2.0f);
+ yShape = (int)(rectangle.Y + yOffset + labelPlusPrefixSize.Height / 2.0f - ShapeHeight / 2.0f);
break;
case ContentAlignment.BottomLeft:
case ContentAlignment.BottomCenter:
case ContentAlignment.BottomRight:
- yShape = (int)(rectangle.Y + textBounds.Height - sampleBounds.Height / 2.0f - ShapeHeight / 2.0f);
+ yShape = (int)(rectangle.Y + labelPlusPrefixSize.Height - sampleBounds.Height / 2.0f - ShapeHeight / 2.0f);
break;
}
yLabel = rectangle.Y + yOffset;
@@ -209,49 +188,49 @@
else
{
yShape = rectangle.Y + yOffset;
- yLabel = (int)(rectangle.Y + ShapeHeight / 2.0f - textBounds.Height / 2.0f);
+ yLabel = (int)(rectangle.Y + ShapeHeight / 2.0f - labelPlusPrefixSize.Height / 2.0f);
}
if (TextAlign == RelativeAlignment.Right)
{
- xShape = rectangle.X + xOffset + (int)prefixBounds.Width;
+ xShape = rectangle.X + xOffset + (int)prefixSize.Width;
xLabel = xShape + _hPadding + ShapeWidth;
}
else if (TextAlign == RelativeAlignment.Left)
{
- xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
- xShape = xLabel + _hPadding + (int)labelBounds.Width;
+ xLabel = rectangle.X + xOffset + (int)prefixSize.Width;
+ xShape = xLabel + _hPadding + (int)labelSize.Width;
}
}
else if (TextAlign == RelativeAlignment.Above || TextAlign == RelativeAlignment.Below)
{
- if (labelBounds.Width > ShapeWidth)
+ if (labelSize.Width > ShapeWidth)
{
switch (_shapeAlign)
{
case ContentAlignment.TopLeft:
case ContentAlignment.MiddleLeft:
case ContentAlignment.BottomLeft:
- xShape = (int)(rectangle.X + xOffset + (int)prefixBounds.Width);
+ xShape = (int)(rectangle.X + xOffset + (int)prefixSize.Width);
break;
case ContentAlignment.TopCenter:
case ContentAlignment.MiddleCenter:
case ContentAlignment.BottomCenter:
- xShape = (int)(rectangle.X + prefixBounds.Width + labelBounds.Width / 2.0f - ShapeWidth / 2.0f);
+ xShape = (int)(rectangle.X + prefixSize.Width + labelSize.Width / 2.0f - ShapeWidth / 2.0f);
break;
case ContentAlignment.TopRight:
case ContentAlignment.MiddleRight:
case ContentAlignment.BottomRight:
- xShape = (int)(rectangle.X + xOffset + prefixBounds.Width + textBounds.Width - ShapeWidth);
+ xShape = (int)(rectangle.X + xOffset + prefixSize.Width + labelPlusPrefixSize.Width - ShapeWidth);
break;
}
- xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
+ xLabel = rectangle.X + xOffset + (int)prefixSize.Width;
}
else
{
- xShape = rectangle.X + xOffset + (int)prefixBounds.Width;
- xLabel = (int)(rectangle.X + prefixBounds.Width + ShapeWidth / 2.0f - labelBounds.Width / 2.0f);
+ xShape = rectangle.X + xOffset + (int)prefixSize.Width;
+ xLabel = (int)(rectangle.X + prefixSize.Width + ShapeWidth / 2.0f - labelSize.Width / 2.0f);
}
if (TextAlign == RelativeAlignment.Below)
@@ -261,7 +240,7 @@
}
else if (TextAlign == RelativeAlignment.Above)
{
- yShape = (int)(rectangle.Y + _vPadding + textBounds.Height);
+ yShape = (int)(rectangle.Y + _vPadding + labelPlusPrefixSize.Height);
yLabel = rectangle.Y + yOffset;
}
}
@@ -270,14 +249,67 @@
Point ptOffset = GetAlignmentOffset(rectangle, rectBounds.Size);
DrawBackgroundAndBorder(g, rectangle);
DrawPrefix(g, xPrefix + ptOffset.X, yPrefix + ptOffset.Y);
- //DrawImage(g, xImage + ptOffset.X, yImage + ptOffset.Y);
DrawShape(g, xShape + ptOffset.X, yShape + ptOffset.Y);
RectangleF layoutRectangle = new RectangleF(xLabel + ptOffset.X,
- yLabel + ptOffset.Y, labelBounds.Width, labelBounds.Height);
+ yLabel + ptOffset.Y, labelSize.Width, labelSize.Height);
DrawText(g, layoutRectangle);
}
+ //public virtual ScaleMode GetAutoScaleMode()
+ //{
+ // return _scaleMode;
+ //}
+
+ //public virtual void SetAutoScaleMode(Graphics g, ScaleMode scaleMode)
+ //{
+ // _scaleMode = scaleMode;
+ // switch (scaleMode)
+ // {
+ // case ScaleMode.ScaleToText:
+ // ScaleShapeToText(g);
+ // break;
+ // case ScaleMode.None:
+ // break;
+ // default:
+ // break;
+ // }
+ //}
+
+ protected override SizeF GetLabelSize(Graphics g)
+ {
+ SizeF prefixSize = GetPrefixSize(g);
+ int availTextWidth = 0;
+ if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below || _textAlign == RelativeAlignment.Over)
+ {
+ availTextWidth = (int)(MaximumWidth - prefixSize.Width - Insets.TotalHorizontalInset);
+ }
+ else
+ {
+ availTextWidth = (int)(MaximumWidth - prefixSize.Width - Insets.TotalHorizontalInset - ShapeWidth);
+ }
+
+ availTextWidth = Math.Max(1, availTextWidth);
+ SizeF labelSize = MaximumWidth > 0 ?
+ GraphicsUtils.MeasureString(g, Label, Font, availTextWidth)
+ : g.MeasureString(Label, Font);
+
+ if (AutoScaleMode == ScaleMode.ScaleToText)
+ {
+ Size oldShapeSize = this.ShapeSize;
+ ScaleShapeToText(labelSize);
+ Size newShapeSize = this.ShapeSize;
+
+ if (Math.Abs(oldShapeSize.Width - newShapeSize.Width) > 2 ||
+ Math.Abs(oldShapeSize.Height - newShapeSize.Height) > 2)
+ {
+ labelSize = GetLabelSize(g);
+ }
+ }
+
+ return labelSize;
+ }
+
protected virtual void ScaleShapeToText(SizeF textBounds)
{
float scale = -1;
Modified: Trunk/Source/Roam.UI/Drawing/StarItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-16 09:22:14 UTC (rev 77)
+++ Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-17 07:41:29 UTC (rev 78)
@@ -141,7 +141,7 @@
g.FillPolygon(starBrush, pts);
g.DrawPolygon(starPen, pts);
-
+
starBrush.Dispose();
starPen.Dispose();
}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-16 09:22:14 UTC (rev 77)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-17 07:41:29 UTC (rev 78)
@@ -178,6 +178,7 @@
</Compile>
<Compile Include="Drawing\AngleGradient.cs" />
<Compile Include="Drawing\BitmapFactory.cs" />
+ <Compile Include="Drawing\EllipseItem.cs" />
<Compile Include="Drawing\FillImage.cs" />
<Compile Include="Drawing\FillNone.cs" />
<Compile Include="Drawing\FillRoundedRectangle.cs" />
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-16 09:22:15
|
Revision: 77
http://roam.svn.sourceforge.net/roam/?rev=77&view=rev
Author: jonfroehlich
Date: 2007-04-16 02:22:14 -0700 (Mon, 16 Apr 2007)
Log Message:
-----------
added top level shape item
ImageItem now derives from ShapeItem--this hierarchy isn't exactly how i want it but it's probably good enough
i still need to update ShapeItem so that the RelativeAlignment.Over is correctly handled
Modified Paths:
--------------
Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
Trunk/Source/Roam.Test/UI/Controls/CheckedListBoxTest.cs
Trunk/Source/Roam.Test/UI/Controls/ImageListBoxTest.cs
Trunk/Source/Roam.Test/UI/Controls/RadioListBoxTest.cs
Trunk/Source/Roam.UI/Drawing/BitmapItem.cs
Trunk/Source/Roam.UI/Drawing/ImageItem.cs
Trunk/Source/Roam.UI/Drawing/RelativeAlignment.cs
Trunk/Source/Roam.UI/Drawing/ScaleMode.cs
Trunk/Source/Roam.UI/Drawing/StarItem.cs
Trunk/Source/Roam.UI/Drawing/VisualItem.cs
Trunk/Source/Roam.UI/Forms/FormFactory.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
Modified: Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -31,6 +31,11 @@
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this._menuItemContentAlign = new System.Windows.Forms.MenuItem();
+ this._menuItemTextAlign = new System.Windows.Forms.MenuItem();
this.label5 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
@@ -40,9 +45,7 @@
this._numericTextBoxPointiness2 = new Roam.UI.Controls.NumericTextBox();
this._numericTextBoxPointiness1 = new Roam.UI.Controls.NumericTextBox();
this.label3 = new System.Windows.Forms.Label();
- this.menuItem2 = new System.Windows.Forms.MenuItem();
- this.menuItem3 = new System.Windows.Forms.MenuItem();
- this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// mainMenu1
@@ -55,6 +58,32 @@
this.menuItem1.Text = "Exit";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.MenuItems.Add(this._menuItemContentAlign);
+ this.menuItem2.MenuItems.Add(this._menuItemTextAlign);
+ this.menuItem2.Text = "Menu";
+ //
+ // menuItem3
+ //
+ this.menuItem3.MenuItems.Add(this.menuItem4);
+ this.menuItem3.MenuItems.Add(this.menuItem5);
+ this.menuItem3.Text = "Set";
+ //
+ // menuItem4
+ //
+ this.menuItem4.Text = "Label";
+ this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
+ //
+ // _menuItemContentAlign
+ //
+ this._menuItemContentAlign.Text = "Content Align";
+ //
+ // _menuItemTextAlign
+ //
+ this._menuItemTextAlign.Text = "Text Align";
+ //
// label5
//
this.label5.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
@@ -142,21 +171,11 @@
this.label3.Size = new System.Drawing.Size(12, 18);
this.label3.Text = ".";
//
- // menuItem2
+ // menuItem5
//
- this.menuItem2.MenuItems.Add(this.menuItem3);
- this.menuItem2.Text = "Menu";
+ this.menuItem5.Text = "BackColor";
+ this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
- // menuItem3
- //
- this.menuItem3.MenuItems.Add(this.menuItem4);
- this.menuItem3.Text = "Set";
- //
- // menuItem4
- //
- this.menuItem4.Text = "Label";
- this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
- //
// StarItemTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
@@ -194,5 +213,8 @@
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
+ private System.Windows.Forms.MenuItem _menuItemContentAlign;
+ private System.Windows.Forms.MenuItem _menuItemTextAlign;
+ private System.Windows.Forms.MenuItem menuItem5;
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -21,6 +21,8 @@
using System.Windows.Forms;
using Roam.UI.Drawing;
using Roam.UI.Forms;
+using Roam.Common.Utils;
+using Roam.UI.Controls;
namespace Roam.Test.Sandbox
{
@@ -30,8 +32,40 @@
public StarItemTest()
{
InitializeComponent();
+
+ foreach(string name in EnumUtils.GetNames(typeof(Roam.UI.Drawing.ContentAlignment)))
+ {
+ MenuItem mi = new MenuItem();
+ mi.Text = name;
+ mi.Click += new EventHandler(OnMenuItemContentAlignment);
+ _menuItemContentAlign.MenuItems.Add(mi);
+ }
+
+ foreach(string name in EnumUtils.GetNames(typeof(RelativeAlignment)))
+ {
+ MenuItem mi = new MenuItem();
+ mi.Text = name;
+ mi.Click += new EventHandler(OnMenuItemRelativeAlignment);
+ _menuItemTextAlign.MenuItems.Add(mi);
+ }
}
+ private void OnMenuItemRelativeAlignment(object sender, EventArgs e)
+ {
+ MenuItem mi = (MenuItem)sender;
+ RelativeAlignment textAlign = (RelativeAlignment)Enum.Parse(typeof(RelativeAlignment), mi.Text, true);
+ _starItem.TextAlign = textAlign;
+ this.Invalidate();
+ }
+
+ private void OnMenuItemContentAlignment(object sender, EventArgs e)
+ {
+ MenuItem mi = (MenuItem)sender;
+ Roam.UI.Drawing.ContentAlignment shapeAlign = (Roam.UI.Drawing.ContentAlignment)Enum.Parse(typeof(Roam.UI.Drawing.ContentAlignment), mi.Text, true);
+ _starItem.ShapeAlign = shapeAlign;
+ this.Invalidate();
+ }
+
protected override void OnPaint(PaintEventArgs e)
{
if (_starItem == null)
@@ -40,6 +74,7 @@
new Point(ClientRectangle.X, _numericTextBoxSizeWidth.Bottom + 2),
_numericTextBoxNumStarPoints.TextAsInt,
double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt));
+ _starItem.Label = "Label";
}
Rectangle rect = new Rectangle(ClientRectangle.X, _numericTextBoxSizeWidth.Bottom,
ClientRectangle.Width, ClientRectangle.Height - _numericTextBoxSizeWidth.Bottom);
@@ -55,20 +90,38 @@
private void OnNumStarPointsTextChanged(object sender, EventArgs e)
{
- _starItem.NumPoints = _numericTextBoxNumStarPoints.TextAsInt;
- this.Invalidate();
+ try
+ {
+ _starItem.NumPoints = _numericTextBoxNumStarPoints.TextAsInt;
+ this.Invalidate();
+ }
+ catch (Exception ex)
+ {
+ }
}
private void OnSizeWidthTextChanged(object sender, EventArgs e)
{
- _starItem.Width = _numericTextBoxSizeWidth.TextAsInt;
- this.Invalidate();
+ try
+ {
+ _starItem.ShapeWidth = _numericTextBoxSizeWidth.TextAsInt;
+ this.Invalidate();
+ }
+ catch (Exception ex)
+ {
+ }
}
private void OnSizeHeightTextChanged(object sender, EventArgs e)
{
- _starItem.Height = _numericTextBoxSizeHeight.TextAsInt;
- this.Invalidate();
+ try
+ {
+ _starItem.ShapeHeight = _numericTextBoxSizeHeight.TextAsInt;
+ this.Invalidate();
+ }
+ catch (Exception ex)
+ {
+ }
}
private void OnPointiness1TextChanged(object sender, EventArgs e)
@@ -83,8 +136,14 @@
private void UpdateStarPointiness()
{
- _starItem.Pointiness = double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt);
- this.Invalidate();
+ try
+ {
+ _starItem.Pointiness = double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt);
+ this.Invalidate();
+ }
+ catch (Exception ex)
+ {
+ }
}
private void menuItem4_Click(object sender, EventArgs e)
@@ -102,5 +161,32 @@
}
}
}
+
+ private void menuItem5_Click(object sender, EventArgs e)
+ {
+ NumericTextBox redTextBox = new Roam.UI.Controls.NumericTextBox();
+ redTextBox.SelectTextOnFocus = true;
+ redTextBox.Text = _starItem.BackColor.R.ToString();
+
+ NumericTextBox greenTextBox = new Roam.UI.Controls.NumericTextBox();
+ greenTextBox.SelectTextOnFocus = true;
+ greenTextBox.Text = _starItem.BackColor.G.ToString();
+
+ NumericTextBox blueTextBox = new Roam.UI.Controls.NumericTextBox();
+ blueTextBox.SelectTextOnFocus = true;
+ blueTextBox.Text = _starItem.BackColor.B.ToString();
+
+
+ Form form = FormFactory.Create(new LabelControlPair[]{
+ new LabelControlPair("Red: ", redTextBox),
+ new LabelControlPair("Green: ", greenTextBox),
+ new LabelControlPair("Blue: ", blueTextBox) });
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ _starItem.BackColor = Color.FromArgb(redTextBox.TextAsInt, greenTextBox.TextAsInt, blueTextBox.TextAsInt);
+ this.Invalidate();
+ }
+ }
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/UI/Controls/CheckedListBoxTest.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/CheckedListBoxTest.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.Test/UI/Controls/CheckedListBoxTest.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -41,82 +41,82 @@
CheckedItem.AutoScaleMode = ScaleMode.None;
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "Default-Scaled");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "10");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "11");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "12");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "13");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 13, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked,"14");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 14, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "15");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 15, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "20");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 20, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "25");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 25, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "30");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "40");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 40, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "50");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 50, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "60");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 60, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "70");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 70, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "80");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 80, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "100");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 100, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "110");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 110, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "120");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 120, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "130");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 130, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
CheckedItem = new CheckedItem(CheckState.Checked, "140");
- CheckedItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ CheckedItem.AutoScaleMode = ScaleMode.ScaleToText;
CheckedItem.Font = new Font(FontFamily.GenericSansSerif, 140, FontStyle.Bold);
checkedListBox1.Items.Add(CheckedItem);
Modified: Trunk/Source/Roam.Test/UI/Controls/ImageListBoxTest.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageListBoxTest.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageListBoxTest.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -43,28 +43,28 @@
//imageItem = new ImageItem("Survey", bitmap);
imageItem = new IImageItem("Survey", @"\Program Files\Roam.Test.UI.Controls\Survey48x48.png");
imageItem.TextAlign = RelativeAlignment.Right;
- imageItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ imageItem.AutoScaleMode = ScaleMode.ScaleToText;
imageListBox1.Items.Add(imageItem);
//bitmap = new Bitmap(@"\Program Files\Roam.Test.UI.Controls\Microphone48x48.png");
//imageItem = new ImageItem("Microphone", bitmap);
imageItem = new IImageItem("Microphone", @"\Program Files\Roam.Test.UI.Controls\Microphone48x48.png");
imageItem.TextAlign = RelativeAlignment.Below;// Left;
- imageItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ imageItem.AutoScaleMode = ScaleMode.ScaleToText;
imageListBox1.Items.Add(imageItem);
//bitmap = new Bitmap(@"\Program Files\Roam.Test.UI.Controls\Camera48x48.png");
//imageItem = new ImageItem("Camera", bitmap);
imageItem = new IImageItem("Camera", @"\Program Files\Roam.Test.UI.Controls\Camera48x48.png");
imageItem.TextAlign = RelativeAlignment.Above;
- imageItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ imageItem.AutoScaleMode = ScaleMode.ScaleToText;
imageListBox1.Items.Add(imageItem);
//bitmap = new Bitmap(@"\Program Files\Roam.Test.UI.Controls\VideoCamera48x48.png");
//imageItem = new ImageItem("VideoCamera", bitmap);
imageItem = new IImageItem("VideoCamera", @"\Program Files\Roam.Test.UI.Controls\VideoCamera48x48.png");
imageItem.TextAlign = RelativeAlignment.Right;// Below;
- imageItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ imageItem.AutoScaleMode = ScaleMode.ScaleToText;
imageListBox1.Items.Add(imageItem);
}
Modified: Trunk/Source/Roam.Test/UI/Controls/RadioListBoxTest.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RadioListBoxTest.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.Test/UI/Controls/RadioListBoxTest.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -41,82 +41,82 @@
RadioItem.AutoScaleMode = ScaleMode.None;
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "Default-Scaled");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "10");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "11");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "12");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "13");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 13, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "14");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 14, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "15");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 15, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "20");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 20, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "25");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 25, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "30");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "40");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 40, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "50");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 50, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "60");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 60, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "70");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 70, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "80");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 80, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "100");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 100, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "110");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 110, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "120");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 120, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "130");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 130, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
RadioItem = new RadioItem(false, "140");
- RadioItem.AutoScaleMode = ScaleMode.ScaleImageToText;
+ RadioItem.AutoScaleMode = ScaleMode.ScaleToText;
RadioItem.Font = new Font(FontFamily.GenericSansSerif, 140, FontStyle.Bold);
radioListBox1.Items.Add(RadioItem);
Modified: Trunk/Source/Roam.UI/Drawing/BitmapItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/BitmapItem.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.UI/Drawing/BitmapItem.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -37,13 +37,6 @@
private Color _transparentColorKey = Color.Empty;
#endregion Private Fields
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
#region Constructors
public BitmapItem()
: base()
Modified: Trunk/Source/Roam.UI/Drawing/ImageItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ImageItem.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.UI/Drawing/ImageItem.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -27,25 +27,11 @@
///
/// </remarks>
/// <author>Jon Froehlich</author>
- public abstract class ImageItem : VisualItem
+ public abstract class ImageItem : ShapeItem
{
- #region Private Fields
- private int _vPadding = 2;
- private int _hPadding = 3;
- private ScaleMode _scaleMode = ScaleMode.None;
- private RelativeAlignment _textAlign = RelativeAlignment.Right;
- private ContentAlignment _imageAlign = ContentAlignment.TopCenter;
- #endregion Private Fields
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
#region Constructors
public ImageItem()
+ : base()
{
}
@@ -58,13 +44,6 @@
: base(label, item)
{
}
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
#endregion Constructors
#region Properties
@@ -75,208 +54,42 @@
public abstract object DisabledImage { get; set; }
public abstract object SelectedImage { get; set; }
- public virtual RelativeAlignment TextAlign
+ public override Size ShapeSize
{
- get { return _textAlign; }
- set { _textAlign = value; }
+ get { return ImageSize; }
+ set { ImageSize = value; }
}
- public virtual ContentAlignment ImageAlign
+ public override int ShapeWidth
{
- get { return _imageAlign; }
- set { _imageAlign = value; }
+ get { return ImageWidth; }
+ set { ImageWidth = value; }
}
- public virtual ScaleMode AutoScaleMode
+ public override int ShapeHeight
{
- get { return _scaleMode; }
- set { _scaleMode = value; }
+ get { return ImageHeight; }
+ set { ImageHeight = value; }
}
- #endregion Properties
- #region Public Methods
- public override Rectangle GetBounds(Graphics g)
+ public virtual ContentAlignment ImageAlign
{
- if (Image == null)
- {
- return base.GetBounds(g);
- }
- else
- {
- SizeF prefixBounds = g.MeasureString(Prefix, Font);
- SizeF labelBounds = MaximumWidth > 0 ?
- GraphicsUtils.MeasureString(g, Label, Font, (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset - ImageWidth))
- : g.MeasureString(Label, Font);
- SizeF textBounds = new SizeF(labelBounds.Width + prefixBounds.Width,
- Math.Max(labelBounds.Height, prefixBounds.Height));
-
- if (AutoScaleMode == ScaleMode.ScaleImageToText)
- {
- ScaleImageToText(labelBounds);
- }
-
- int width = 0, height = 0;
- if (_textAlign == RelativeAlignment.Left || _textAlign == RelativeAlignment.Right)
- {
- int horizSpaceBetweenImageAndText = (Label == null || Label.Length <= 0) ? 0 : _hPadding;
- width = (int)Math.Ceiling(textBounds.Width + horizSpaceBetweenImageAndText + ImageWidth);
- height = (int)Math.Max(textBounds.Height, ImageHeight);
- }
- else if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below)
- {
- int vertSpaceBetweenImageAndText = (Label == null || Label.Length <= 0) ? 0 : _vPadding;
- width = (int)Math.Max(textBounds.Width, ImageWidth);
- height = (int)Math.Ceiling(textBounds.Height + vertSpaceBetweenImageAndText + ImageHeight);
- }
-
- return new Rectangle(Location.X, Location.Y,
- (int)Math.Max(width + Insets.TotalHorizontalInset, MaximumWidth), height + Insets.TotalVerticalInset);
- }
+ get { return ShapeAlign; }
+ set { ShapeAlign = value; }
}
+ #endregion Properties
- public override void Draw(Graphics g, Rectangle rectangle)
+ protected override void DrawShape(Graphics g, int x, int y)
{
- if (Image == null)
- {
- base.Draw(g, rectangle);
- }
- else
- {
- SizeF prefixBounds = g.MeasureString(Prefix, Font);
- SizeF labelBounds = MaximumWidth > 0 ?
- GraphicsUtils.MeasureString(g, Label, Font, (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset - ImageWidth))
- : g.MeasureString(Label, Font);
- SizeF textBounds = new SizeF(labelBounds.Width + prefixBounds.Width,
- Math.Max(labelBounds.Height, prefixBounds.Height));
-
- SizeF sampleBounds = g.MeasureString("1LQ!", Font);
- int xImage = 0, yImage = 0, xLabel = 0, yLabel = 0;
- int xOffset = 1, yOffset = 1;
- int xPrefix = xOffset + rectangle.X;
- int yPrefix = yOffset + rectangle.Y;
-
- if (TextAlign == RelativeAlignment.Left || TextAlign == RelativeAlignment.Right)
- {
- if (textBounds.Height > ImageHeight)
- {
- switch (_imageAlign)
- {
- case ContentAlignment.TopLeft:
- case ContentAlignment.TopCenter:
- case ContentAlignment.TopRight:
- yImage = (int)(rectangle.Y + yOffset + sampleBounds.Height / 2.0f - ImageHeight / 2.0f);
- break;
- case ContentAlignment.MiddleLeft:
- case ContentAlignment.MiddleCenter:
- case ContentAlignment.MiddleRight:
- yImage = (int)(rectangle.Y + yOffset + textBounds.Height / 2.0f - ImageHeight / 2.0f);
- break;
- case ContentAlignment.BottomLeft:
- case ContentAlignment.BottomCenter:
- case ContentAlignment.BottomRight:
- yImage = (int)(rectangle.Y + textBounds.Height - sampleBounds.Height / 2.0f - ImageHeight / 2.0f);
- break;
- }
- yLabel = rectangle.Y + yOffset;
- }
- else
- {
- yImage = rectangle.Y + yOffset;
- yLabel = (int)(rectangle.Y + ImageHeight / 2.0f - textBounds.Height / 2.0f);
- }
-
- if (TextAlign == RelativeAlignment.Right)
- {
- xImage = rectangle.X + xOffset + (int)prefixBounds.Width;
- xLabel = xImage + _hPadding + ImageWidth;
- }
- else if (TextAlign == RelativeAlignment.Left)
- {
- xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
- xImage = xLabel + _hPadding + (int)labelBounds.Width;
- }
- }
- else if (TextAlign == RelativeAlignment.Above || TextAlign == RelativeAlignment.Below)
- {
- if (labelBounds.Width > ImageWidth)
- {
- switch (_imageAlign)
- {
- case ContentAlignment.TopLeft:
- case ContentAlignment.MiddleLeft:
- case ContentAlignment.BottomLeft:
- xImage = (int)(rectangle.X + xOffset + (int)prefixBounds.Width);
- break;
- case ContentAlignment.TopCenter:
- case ContentAlignment.MiddleCenter:
- case ContentAlignment.BottomCenter:
- xImage = (int)(rectangle.X + prefixBounds.Width + labelBounds.Width / 2.0f - ImageWidth / 2.0f);
- break;
- case ContentAlignment.TopRight:
- case ContentAlignment.MiddleRight:
- case ContentAlignment.BottomRight:
- xImage = (int)(rectangle.X + xOffset + prefixBounds.Width + textBounds.Width - ImageWidth);
- break;
- }
-
- xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
- }
- else
- {
- xImage = rectangle.X + xOffset + (int)prefixBounds.Width;
- xLabel = (int)(rectangle.X + prefixBounds.Width + ImageWidth / 2.0f - labelBounds.Width / 2.0f);
- }
-
- if (TextAlign == RelativeAlignment.Below)
- {
- yImage = rectangle.Y + yOffset;
- yLabel = rectangle.Y + _vPadding + ImageHeight;
- }
- else if (TextAlign == RelativeAlignment.Above)
- {
- yImage = (int)(rectangle.Y + _vPadding + textBounds.Height);
- yLabel = rectangle.Y + yOffset;
- }
- }
-
- Rectangle rectBounds = GetBounds(g);
- Point ptOffset = GetAlignmentOffset(rectangle, rectBounds.Size);
- DrawBackgroundAndBorder(g, rectangle);
- DrawPrefix(g, xPrefix + ptOffset.X, yPrefix + ptOffset.Y);
- DrawImage(g, xImage + ptOffset.X, yImage + ptOffset.Y);
- RectangleF layoutRectangle = new RectangleF(xLabel + ptOffset.X,
- yLabel + ptOffset.Y, labelBounds.Width, labelBounds.Height);
- DrawText(g, layoutRectangle);
- }
+ DrawImage(g, x, y);
}
- #endregion
- #region Protected Methods
- protected void ScaleImageToText(SizeF textBounds)
+ protected override void ResizeShape(float newWidth, float newHeight)
{
- float scale = -1;
-
- if ((TextAlign == RelativeAlignment.Left || TextAlign == RelativeAlignment.Right)
- && textBounds.Height != ImageHeight)
- {
- //scale image based on text height
- scale = textBounds.Height / ImageHeight;
- }
- else if ((TextAlign == RelativeAlignment.Above || TextAlign == RelativeAlignment.Below)
- && textBounds.Width != ImageWidth)
- {
- //scale image based on text width
- scale = textBounds.Width / ImageWidth;
- }
-
- if (scale > 0)
- {
- ResizeImage(ImageWidth * scale, ImageHeight * scale);
- }
+ ResizeImage(newWidth, newHeight);
}
- protected abstract void DrawImage(Graphics g, int xImage, int yImage);
+ protected abstract void DrawImage(Graphics g, int x, int y);
protected abstract void ResizeImage(float newWidth, float newHeight);
- #endregion Protected Methods
}
}
Modified: Trunk/Source/Roam.UI/Drawing/RelativeAlignment.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/RelativeAlignment.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.UI/Drawing/RelativeAlignment.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -30,6 +30,7 @@
Left,
Right,
Above,
- Below
+ Below,
+ Over
}
}
Modified: Trunk/Source/Roam.UI/Drawing/ScaleMode.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ScaleMode.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.UI/Drawing/ScaleMode.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -27,7 +27,7 @@
/// <author>Jon Froehlich</author>
public enum ScaleMode
{
- ScaleImageToText,
+ ScaleToText,
None
}
}
Added: Trunk/Source/Roam.UI/Drawing/ShapeItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ShapeItem.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/ShapeItem.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -0,0 +1,311 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using Roam.Common.Utils;
+
+namespace Roam.UI.Drawing
+{
+ public abstract class ShapeItem : VisualItem
+ {
+ #region Fields
+ private int _vPadding = 2;
+ private int _hPadding = 3;
+ private Size _size = new Size(50, 50);
+ private float _penWidth = 1;
+ private RelativeAlignment _textAlign = RelativeAlignment.Right;
+ private ContentAlignment _shapeAlign = ContentAlignment.TopCenter;
+ private ScaleMode _scaleMode = ScaleMode.None;
+ #endregion Fields
+
+ #region Constructors
+ public ShapeItem() : base() { }
+ public ShapeItem(string label) : base(label) { }
+ public ShapeItem(string label, object item) : base(label, item) { }
+ #endregion Constructors
+
+ #region Properties
+ public virtual float PenWidth
+ {
+ get { return _penWidth; }
+ set { _penWidth = value; }
+ }
+
+ public virtual Size ShapeSize
+ {
+ get { return _size; }
+ set
+ {
+ if (value.Width < 1)
+ {
+ throw new ArgumentOutOfRangeException("Size", "The Size.Width must be greater than or equal to 1");
+ }
+ else if (value.Height < 1)
+ {
+ throw new ArgumentOutOfRangeException("Size", "The Size.Height must be greater than or equal to 1");
+ }
+
+ _size = value;
+ }
+ }
+
+ public virtual int ShapeWidth
+ {
+ get { return _size.Width; }
+ set
+ {
+ if (value < 1)
+ {
+ throw new ArgumentOutOfRangeException("Width", "The Width must be greater than or equal to 1");
+ }
+
+ ShapeSize = new Size(value, ShapeSize.Height);
+ }
+ }
+
+ public virtual int ShapeHeight
+ {
+ get { return _size.Height; }
+ set
+ {
+ if (value < 1)
+ {
+ throw new ArgumentOutOfRangeException("Height", "The Height must be greater than or equal to 1");
+ }
+
+ ShapeSize = new Size(ShapeSize.Width, value);
+ }
+ }
+
+ public virtual RelativeAlignment TextAlign
+ {
+ get { return _textAlign; }
+ set
+ {
+ if (value == RelativeAlignment.Over)
+ {
+ throw new ArgumentException("RelativeAlignment.Over is not yet supported");
+ }
+ _textAlign = value;
+ }
+ }
+
+ public virtual ContentAlignment ShapeAlign
+ {
+ get { return _shapeAlign; }
+ set { _shapeAlign = value; }
+ }
+
+ public virtual ScaleMode AutoScaleMode
+ {
+ get { return _scaleMode; }
+ set { _scaleMode = value; }
+ }
+
+ #endregion Properties
+
+ #region Abstract Methods
+ protected abstract void DrawShape(Graphics g, int x, int y);
+ #endregion Abstract Methods
+
+ #region Methods
+ public override Rectangle GetBounds(Graphics g)
+ {
+ SizeF prefixBounds = g.MeasureString(Prefix, Font);
+
+ int availTextWidth = 0;
+ if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below || _textAlign == RelativeAlignment.Over)
+ {
+ availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset);
+ }
+ else
+ {
+ availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset - ShapeWidth);
+ }
+
+ SizeF labelBounds = MaximumWidth > 0 ?
+ GraphicsUtils.MeasureString(g, Label, Font, availTextWidth)
+ : g.MeasureString(Label, Font);
+ SizeF textBounds = new SizeF(labelBounds.Width + prefixBounds.Width,
+ Math.Max(labelBounds.Height, prefixBounds.Height));
+
+ if (AutoScaleMode == ScaleMode.ScaleToText)
+ {
+ ScaleShapeToText(labelBounds);
+ }
+
+ int width = 0, height = 0;
+ if (_textAlign == RelativeAlignment.Left || _textAlign == RelativeAlignment.Right)
+ {
+ int horizSpaceBetweenImageAndText = string.IsNullOrEmpty(Label) ? 0 : _hPadding;
+ width = (int)Math.Ceiling(textBounds.Width + horizSpaceBetweenImageAndText + ShapeWidth);
+ height = (int)Math.Max(textBounds.Height, ShapeHeight);
+ }
+ else if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below)
+ {
+ int vertSpaceBetweenImageAndText = string.IsNullOrEmpty(Label) ? 0 : _vPadding;
+ width = (int)Math.Max(textBounds.Width, ShapeWidth);
+ height = (int)Math.Ceiling(textBounds.Height + vertSpaceBetweenImageAndText + ShapeHeight);
+ }
+ //else if (_textAlign == RelativeAlignment.Over)
+ //{
+ // width = (int)Math.Max(textBounds.Width, ImageWidth);
+ // height = (int)Math.Max(textBounds.Height, ImageHeight);
+ //}
+
+ return new Rectangle(Location.X, Location.Y,
+ (int)Math.Max(width + Insets.TotalHorizontalInset, MaximumWidth), height + Insets.TotalVerticalInset);
+ }
+
+ public override void Draw(Graphics g, Rectangle rectangle)
+ {
+ SizeF prefixBounds = g.MeasureString(Prefix, Font);
+ int availTextWidth = 0;
+ if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below || _textAlign == RelativeAlignment.Over)
+ {
+ availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset);
+ }
+ else
+ {
+ availTextWidth = (int)(MaximumWidth - prefixBounds.Width - Insets.TotalHorizontalInset - ShapeWidth);
+ }
+
+ SizeF labelBounds = MaximumWidth > 0 ?
+ GraphicsUtils.MeasureString(g, Label, Font, availTextWidth)
+ : g.MeasureString(Label, Font);
+ SizeF textBounds = new SizeF(labelBounds.Width + prefixBounds.Width,
+ Math.Max(labelBounds.Height, prefixBounds.Height));
+
+ SizeF sampleBounds = g.MeasureString("1LQ!", Font);
+ int xShape = 0, yShape = 0, xLabel = 0, yLabel = 0;
+ int xOffset = 1, yOffset = 1;
+ int xPrefix = xOffset + rectangle.X;
+ int yPrefix = yOffset + rectangle.Y;
+
+ if (TextAlign == RelativeAlignment.Left || TextAlign == RelativeAlignment.Right)
+ {
+ if (textBounds.Height > ShapeHeight)
+ {
+ switch (_shapeAlign)
+ {
+ case ContentAlignment.TopLeft:
+ case ContentAlignment.TopCenter:
+ case ContentAlignment.TopRight:
+ yShape = (int)(rectangle.Y + yOffset + sampleBounds.Height / 2.0f - ShapeHeight / 2.0f);
+ break;
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.MiddleRight:
+ yShape = (int)(rectangle.Y + yOffset + textBounds.Height / 2.0f - ShapeHeight / 2.0f);
+ break;
+ case ContentAlignment.BottomLeft:
+ case ContentAlignment.BottomCenter:
+ case ContentAlignment.BottomRight:
+ yShape = (int)(rectangle.Y + textBounds.Height - sampleBounds.Height / 2.0f - ShapeHeight / 2.0f);
+ break;
+ }
+ yLabel = rectangle.Y + yOffset;
+ }
+ else
+ {
+ yShape = rectangle.Y + yOffset;
+ yLabel = (int)(rectangle.Y + ShapeHeight / 2.0f - textBounds.Height / 2.0f);
+ }
+
+ if (TextAlign == RelativeAlignment.Right)
+ {
+ xShape = rectangle.X + xOffset + (int)prefixBounds.Width;
+ xLabel = xShape + _hPadding + ShapeWidth;
+ }
+ else if (TextAlign == RelativeAlignment.Left)
+ {
+ xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
+ xShape = xLabel + _hPadding + (int)labelBounds.Width;
+ }
+ }
+ else if (TextAlign == RelativeAlignment.Above || TextAlign == RelativeAlignment.Below)
+ {
+ if (labelBounds.Width > ShapeWidth)
+ {
+ switch (_shapeAlign)
+ {
+ case ContentAlignment.TopLeft:
+ case ContentAlignment.MiddleLeft:
+ case ContentAlignment.BottomLeft:
+ xShape = (int)(rectangle.X + xOffset + (int)prefixBounds.Width);
+ break;
+ case ContentAlignment.TopCenter:
+ case ContentAlignment.MiddleCenter:
+ case ContentAlignment.BottomCenter:
+ xShape = (int)(rectangle.X + prefixBounds.Width + labelBounds.Width / 2.0f - ShapeWidth / 2.0f);
+ break;
+ case ContentAlignment.TopRight:
+ case ContentAlignment.MiddleRight:
+ case ContentAlignment.BottomRight:
+ xShape = (int)(rectangle.X + xOffset + prefixBounds.Width + textBounds.Width - ShapeWidth);
+ break;
+ }
+
+ xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
+ }
+ else
+ {
+ xShape = rectangle.X + xOffset + (int)prefixBounds.Width;
+ xLabel = (int)(rectangle.X + prefixBounds.Width + ShapeWidth / 2.0f - labelBounds.Width / 2.0f);
+ }
+
+ if (TextAlign == RelativeAlignment.Below)
+ {
+ yShape = rectangle.Y + yOffset;
+ yLabel = rectangle.Y + _vPadding + ShapeHeight;
+ }
+ else if (TextAlign == RelativeAlignment.Above)
+ {
+ yShape = (int)(rectangle.Y + _vPadding + textBounds.Height);
+ yLabel = rectangle.Y + yOffset;
+ }
+ }
+
+ Rectangle rectBounds = GetBounds(g);
+ Point ptOffset = GetAlignmentOffset(rectangle, rectBounds.Size);
+ DrawBackgroundAndBorder(g, rectangle);
+ DrawPrefix(g, xPrefix + ptOffset.X, yPrefix + ptOffset.Y);
+ //DrawImage(g, xImage + ptOffset.X, yImage + ptOffset.Y);
+ DrawShape(g, xShape + ptOffset.X, yShape + ptOffset.Y);
+ RectangleF layoutRectangle = new RectangleF(xLabel + ptOffset.X,
+ yLabel + ptOffset.Y, labelBounds.Width, labelBounds.Height);
+ DrawText(g, layoutRectangle);
+
+ }
+
+ protected virtual void ScaleShapeToText(SizeF textBounds)
+ {
+ float scale = -1;
+
+ if ((TextAlign == RelativeAlignment.Left || TextAlign == RelativeAlignment.Right)
+ && textBounds.Height != ShapeHeight)
+ {
+ //scale image based on text height
+ scale = textBounds.Height / ShapeHeight;
+ }
+ else if ((TextAlign == RelativeAlignment.Above || TextAlign == RelativeAlignment.Below)
+ && textBounds.Width != ShapeWidth)
+ {
+ //scale image based on text width
+ scale = textBounds.Width / ShapeWidth;
+ }
+
+ if (scale > 0)
+ {
+ ResizeShape(ShapeWidth * scale, ShapeHeight * scale);
+ }
+ }
+
+ protected virtual void ResizeShape(float newWidth, float newHeight)
+ {
+ this.ShapeSize = new Size((int)newWidth, (int)newHeight);
+ }
+ #endregion Methods
+
+ }
+}
Modified: Trunk/Source/Roam.UI/Drawing/StarItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-15 23:11:08 UTC (rev 76)
+++ Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-16 09:22:14 UTC (rev 77)
@@ -29,15 +29,13 @@
///
/// </remarks>
/// <author>Jon Froehlich</author>
- public class StarItem : VisualItem
+ public class StarItem : ShapeItem
{
#region Fields
private int _numStarPoints = 5;
private double _pointiness = 2.5;
- private Size _size = new Size(50, 50);
private Point[] _pts;
- private float _penWidth = 1;
- #endregion Fielsd
+ #endregion Fields
public StarItem() : base() { }
public StarItem(string label) : base(label) { }
@@ -50,109 +48,47 @@
public StarItem(Size size, Point location, int numStarPoints, double pointiness, string label)
: base(label)
{
- _size = size;
+ ShapeSize = size;
this.Location = location;
_numStarPoints = numStarPoints;
_pointiness = pointiness;
}
- public override Rectangle GetBounds(Graphics g)
- {
- //return base.GetBounds(g);
- return new Rectangle(Location.X, Location.Y, _size.Width, _size.Height);
- }
-
- public override void Draw(Graphics g, Rectangle drawArea)
- {
- if (_pts == null) { _pts = CreateStar(); }
-
- SolidBrush backBrush = new SolidBrush(BackColor);
- Pen pen = new Pen(ForeColor, _penWidth);
-
- g.FillPolygon(backBrush, _pts);
- g.DrawPolygon(pen, _pts);
-
- backBrush.Dispose();
- pen.Dispose();
-
- //TODO: add textalign text drawing capabilities like ImageItem except that we also want
- //a textalign that says "within"... this would look something like below
-
- //draw text
- SizeF textBounds = GraphicsUtils.MeasureString(g, Label, this.Font, this.Width);
- float xText, yText;
- xText = (int)(this.Width / 2.0 - textBounds.Width / 2.0 + this.Location.X);
- if (textBounds.Height > _size.Height)
- {
- yText = this.Location.Y;
- }
- else
- {
- yText = (int)(this.Height / 2.0 - textBounds.Height / 2.0 + this.Location.Y);
- }
- DrawText(g, new RectangleF(xText, yText, textBounds.Width, textBounds.Height));
- }
-
#region Properties
- public float PenWidth
+ public override Size ShapeSize
{
- get { return _penWidth; }
- set { _penWidth = value; }
- }
-
- public Size Size
- {
- get { return _size; }
+ get { return base.ShapeSize; }
set
{
- if (value.Width < 1)
+ if (ShapeSize != value)
{
- throw new ArgumentOutOfRangeException("Size", "The Size.Width must be greater than or equal to 1");
- }
- else if (value.Height < 1)
- {
- throw new ArgumentOutOfRangeException("Size", "The Size.Height must be greater than or equal to 1");
- }
-
- if (_size != value)
- {
- _size = value;
+ base.ShapeSize = value;
_pts = CreateStar();
}
}
}
- public int Width
+ public override int ShapeWidth
{
- get { return _size.Width; }
+ get { return base.ShapeWidth; }
set
{
- if (value < 1)
+ if (ShapeSize.Width != value)
{
- throw new ArgumentOutOfRangeException("Width", "The Width must be greater than or equal to 1");
- }
-
- if (Size.Width != value)
- {
- _size = new Size(value, Size.Height);
+ base.ShapeWidth = value;
_pts = CreateStar();
}
}
}
- public int Height
+ public override int ShapeHeight
{
- get { return _size.Height; }
+ get { return base.ShapeHeight; }
set
{
- if (value < 1)
+ if (ShapeSize.Height != value)
{
- throw new ArgumentOutOfRangeException("Height", "The Height must be greater than or equal to 1");
- }
-
- if (Size.Height != value)
- {
- _size = new Size(Size.Width, value);
+ base.ShapeHeight = value;
_pts = CreateStar();
}
}
@@ -188,15 +124,34 @@
}
}
}
-
#endregion Properties
+ protected override void DrawShape(Graphics g, int x, int y)
+ {
+ if (_pts == null) { _pts = CreateStar(); }
+
+ Point [] pts = new Point[_pts.Length];
+ for (int i = 0; i < pts.Length; i++)
+ {
+ pts[i] = new Point(_pts[i].X + x, _pts[i].Y + y);
+ }
+
+ SolidBrush starBrush = new SolidBrush(BackColor);
+ Pen starPen = new Pen(BorderColor, PenWidth);
+
+ g.FillPolygon(starBrush, pts);
+ g.DrawPolygon(starPen, pts);
+
+ starBrush.Dispose();
+ starPen.Dispose();
+ }
+
protected virtual Point[] CreateStar()
{
- return CreateStar(_size, this.Location, _numStarPoints, _pointiness);
+ return CreateStar(ShapeSize, _numStarPoints, _pointiness);
}
- public static Point[] CreateStar(Size size, Point location, int numStarPoints, double pointiness)
+ public static Point[] CreateStar(Size size, int numStarPoints, double pointiness)
{
double wRadius = size.Width / 2.0;
double hRadius = size.Height / 2.0;
@@ -220,10 +175,6...
[truncated message content] |
|
From: <jon...@us...> - 2007-04-15 23:11:11
|
Revision: 76
http://roam.svn.sourceforge.net/roam/?rev=76&view=rev
Author: jonfroehlich
Date: 2007-04-15 16:11:08 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
added StarItem... will use this to build StarRater control like I had in the Itasca project at Intel Research
Modified Paths:
--------------
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx
Trunk/Source/Roam.UI/Drawing/StarItem.cs
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-12 22:41:01 UTC (rev 75)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-15 23:11:08 UTC (rev 76)
@@ -164,6 +164,10 @@
<SubType>Designer</SubType>
<DependentUpon>PhoneCallTalkingTest.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Sandbox\StarItemTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>StarItemTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Sandbox\TopMostFormTest.resx">
<SubType>Designer</SubType>
<DependentUpon>TopMostFormTest.cs</DependentUpon>
@@ -391,6 +395,12 @@
<Compile Include="Sandbox\PhoneCallTalkingTest.Designer.cs">
<DependentUpon>PhoneCallTalkingTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\StarItemTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Sandbox\StarItemTest.Designer.cs">
+ <DependentUpon>StarItemTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\TextBoxBackgroundTest.cs">
<SubType>Component</SubType>
</Compile>
Added: Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,198 @@
+namespace Roam.Test.Sandbox
+{
+ partial class StarItemTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this._numericTextBoxNumStarPoints = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxSizeHeight = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxSizeWidth = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxPointiness2 = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxPointiness1 = new Roam.UI.Controls.NumericTextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // label5
+ //
+ this.label5.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label5.Location = new System.Drawing.Point(3, 7);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(91, 18);
+ this.label5.Text = "Num Star Points:";
+ //
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label1.Location = new System.Drawing.Point(3, 28);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(67, 18);
+ this.label1.Text = "Pointiness:";
+ //
+ // label2
+ //
+ this.label2.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label2.Location = new System.Drawing.Point(3, 50);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(41, 18);
+ this.label2.Text = "Size:";
+ //
+ // _numericTextBoxNumStarPoints
+ //
+ this._numericTextBoxNumStarPoints.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxNumStarPoints.Location = new System.Drawing.Point(93, 7);
+ this._numericTextBoxNumStarPoints.Name = "_numericTextBoxNumStarPoints";
+ this._numericTextBoxNumStarPoints.SelectTextOnFocus = true;
+ this._numericTextBoxNumStarPoints.Size = new System.Drawing.Size(133, 18);
+ this._numericTextBoxNumStarPoints.TabIndex = 0;
+ this._numericTextBoxNumStarPoints.Text = "5";
+ this._numericTextBoxNumStarPoints.TextChanged += new System.EventHandler(this.OnNumStarPointsTextChanged);
+ //
+ // _numericTextBoxSizeHeight
+ //
+ this._numericTextBoxSizeHeight.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxSizeHeight.Location = new System.Drawing.Point(163, 50);
+ this._numericTextBoxSizeHeight.Name = "_numericTextBoxSizeHeight";
+ this._numericTextBoxSizeHeight.SelectTextOnFocus = true;
+ this._numericTextBoxSizeHeight.Size = new System.Drawing.Size(63, 18);
+ this._numericTextBoxSizeHeight.TabIndex = 4;
+ this._numericTextBoxSizeHeight.Text = "100";
+ this._numericTextBoxSizeHeight.TextChanged += new System.EventHandler(this.OnSizeHeightTextChanged);
+ //
+ // _numericTextBoxSizeWidth
+ //
+ this._numericTextBoxSizeWidth.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxSizeWidth.Location = new System.Drawing.Point(93, 50);
+ this._numericTextBoxSizeWidth.Name = "_numericTextBoxSizeWidth";
+ this._numericTextBoxSizeWidth.SelectTextOnFocus = true;
+ this._numericTextBoxSizeWidth.Size = new System.Drawing.Size(64, 18);
+ this._numericTextBoxSizeWidth.TabIndex = 3;
+ this._numericTextBoxSizeWidth.Text = "100";
+ this._numericTextBoxSizeWidth.TextChanged += new System.EventHandler(this.OnSizeWidthTextChanged);
+ //
+ // _numericTextBoxPointiness2
+ //
+ this._numericTextBoxPointiness2.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxPointiness2.Location = new System.Drawing.Point(140, 28);
+ this._numericTextBoxPointiness2.Name = "_numericTextBoxPointiness2";
+ this._numericTextBoxPointiness2.SelectTextOnFocus = true;
+ this._numericTextBoxPointiness2.Size = new System.Drawing.Size(86, 18);
+ this._numericTextBoxPointiness2.TabIndex = 2;
+ this._numericTextBoxPointiness2.Text = "5";
+ this._numericTextBoxPointiness2.TextChanged += new System.EventHandler(this.OnPointiness2TextChanged);
+ //
+ // _numericTextBoxPointiness1
+ //
+ this._numericTextBoxPointiness1.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxPointiness1.Location = new System.Drawing.Point(93, 28);
+ this._numericTextBoxPointiness1.Name = "_numericTextBoxPointiness1";
+ this._numericTextBoxPointiness1.SelectTextOnFocus = true;
+ this._numericTextBoxPointiness1.Size = new System.Drawing.Size(36, 18);
+ this._numericTextBoxPointiness1.TabIndex = 1;
+ this._numericTextBoxPointiness1.Text = "2";
+ this._numericTextBoxPointiness1.TextChanged += new System.EventHandler(this.OnPointiness1TextChanged);
+ //
+ // label3
+ //
+ this.label3.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label3.Location = new System.Drawing.Point(130, 31);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(12, 18);
+ this.label3.Text = ".";
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.Text = "Menu";
+ //
+ // menuItem3
+ //
+ this.menuItem3.MenuItems.Add(this.menuItem4);
+ this.menuItem3.Text = "Set";
+ //
+ // menuItem4
+ //
+ this.menuItem4.Text = "Label";
+ this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
+ //
+ // StarItemTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this._numericTextBoxPointiness2);
+ this.Controls.Add(this._numericTextBoxPointiness1);
+ this.Controls.Add(this._numericTextBoxNumStarPoints);
+ this.Controls.Add(this._numericTextBoxSizeHeight);
+ this.Controls.Add(this._numericTextBoxSizeWidth);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.label5);
+ this.Menu = this.mainMenu1;
+ this.Name = "StarItemTest";
+ this.Text = "StarItemTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxSizeWidth;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxSizeHeight;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxNumStarPoints;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxPointiness2;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxPointiness1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem menuItem3;
+ private System.Windows.Forms.MenuItem menuItem4;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,106 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.UI.Drawing;
+using Roam.UI.Forms;
+
+namespace Roam.Test.Sandbox
+{
+ public partial class StarItemTest : Form
+ {
+ private StarItem _starItem;
+ public StarItemTest()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (_starItem == null)
+ {
+ _starItem = new StarItem(new Size(_numericTextBoxSizeWidth.TextAsInt, _numericTextBoxSizeHeight.TextAsInt),
+ new Point(ClientRectangle.X, _numericTextBoxSizeWidth.Bottom + 2),
+ _numericTextBoxNumStarPoints.TextAsInt,
+ double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt));
+ }
+ Rectangle rect = new Rectangle(ClientRectangle.X, _numericTextBoxSizeWidth.Bottom,
+ ClientRectangle.Width, ClientRectangle.Height - _numericTextBoxSizeWidth.Bottom);
+
+ _starItem.Draw(e.Graphics, rect);
+ base.OnPaint(e);
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void OnNumStarPointsTextChanged(object sender, EventArgs e)
+ {
+ _starItem.NumPoints = _numericTextBoxNumStarPoints.TextAsInt;
+ this.Invalidate();
+ }
+
+ private void OnSizeWidthTextChanged(object sender, EventArgs e)
+ {
+ _starItem.Width = _numericTextBoxSizeWidth.TextAsInt;
+ this.Invalidate();
+ }
+
+ private void OnSizeHeightTextChanged(object sender, EventArgs e)
+ {
+ _starItem.Height = _numericTextBoxSizeHeight.TextAsInt;
+ this.Invalidate();
+ }
+
+ private void OnPointiness1TextChanged(object sender, EventArgs e)
+ {
+ UpdateStarPointiness();
+ }
+
+ private void OnPointiness2TextChanged(object sender, EventArgs e)
+ {
+ UpdateStarPointiness();
+ }
+
+ private void UpdateStarPointiness()
+ {
+ _starItem.Pointiness = double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt);
+ this.Invalidate();
+ }
+
+ private void menuItem4_Click(object sender, EventArgs e)
+ {
+ Roam.UI.Controls.TextBox textbox = new Roam.UI.Controls.TextBox();
+ textbox.SelectTextOnFocus = true;
+ textbox.Text = _starItem.Label;
+ Form form = FormFactory.Create("Star label: ", textbox);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (_starItem.Label != textbox.Text)
+ {
+ _starItem.Label = textbox.Text;
+ this.Invalidate();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Source/Roam.UI/Drawing/StarItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/StarItem.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,230 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using Roam.UI.Utils;
+using System.Diagnostics;
+using Roam.Common.Utils;
+
+namespace Roam.UI.Drawing
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class StarItem : VisualItem
+ {
+ #region Fields
+ private int _numStarPoints = 5;
+ private double _pointiness = 2.5;
+ private Size _size = new Size(50, 50);
+ private Point[] _pts;
+ private float _penWidth = 1;
+ #endregion Fielsd
+
+ public StarItem() : base() { }
+ public StarItem(string label) : base(label) { }
+ public StarItem(Size size)
+ : this(size, new Point(0,0)) { }
+ public StarItem(Size size, Point location)
+ : this(size, location, 5, 2.5) { }
+ public StarItem(Size size, Point location, int numStarPoints, double pointiness)
+ : this(size, location, numStarPoints, pointiness, string.Empty) { }
+ public StarItem(Size size, Point location, int numStarPoints, double pointiness, string label)
+ : base(label)
+ {
+ _size = size;
+ this.Location = location;
+ _numStarPoints = numStarPoints;
+ _pointiness = pointiness;
+ }
+
+ public override Rectangle GetBounds(Graphics g)
+ {
+ //return base.GetBounds(g);
+ return new Rectangle(Location.X, Location.Y, _size.Width, _size.Height);
+ }
+
+ public override void Draw(Graphics g, Rectangle drawArea)
+ {
+ if (_pts == null) { _pts = CreateStar(); }
+
+ SolidBrush backBrush = new SolidBrush(BackColor);
+ Pen pen = new Pen(ForeColor, _penWidth);
+
+ g.FillPolygon(backBrush, _pts);
+ g.DrawPolygon(pen, _pts);
+
+ backBrush.Dispose();
+ pen.Dispose();
+
+ //TODO: add textalign text drawing capabilities like ImageItem except that we also want
+ //a textalign that says "within"... this would look something like below
+
+ //draw text
+ SizeF textBounds = GraphicsUtils.MeasureString(g, Label, this.Font, this.Width);
+ float xText, yText;
+ xText = (int)(this.Width / 2.0 - textBounds.Width / 2.0 + this.Location.X);
+ if (textBounds.Height > _size.Height)
+ {
+ yText = this.Location.Y;
+ }
+ else
+ {
+ yText = (int)(this.Height / 2.0 - textBounds.Height / 2.0 + this.Location.Y);
+ }
+ DrawText(g, new RectangleF(xText, yText, textBounds.Width, textBounds.Height));
+ }
+
+ #region Properties
+ public float PenWidth
+ {
+ get { return _penWidth; }
+ set { _penWidth = value; }
+ }
+
+ public Size Size
+ {
+ get { return _size; }
+ set
+ {
+ if (value.Width < 1)
+ {
+ throw new ArgumentOutOfRangeException("Size", "The Size.Width must be greater than or equal to 1");
+ }
+ else if (value.Height < 1)
+ {
+ throw new ArgumentOutOfRangeException("Size", "The Size.Height must be greater than or equal to 1");
+ }
+
+ if (_size != value)
+ {
+ _size = value;
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public int Width
+ {
+ get { return _size.Width; }
+ set
+ {
+ if (value < 1)
+ {
+ throw new ArgumentOutOfRangeException("Width", "The Width must be greater than or equal to 1");
+ }
+
+ if (Size.Width != value)
+ {
+ _size = new Size(value, Size.Height);
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public int Height
+ {
+ get { return _size.Height; }
+ set
+ {
+ if (value < 1)
+ {
+ throw new ArgumentOutOfRangeException("Height", "The Height must be greater than or equal to 1");
+ }
+
+ if (Size.Height != value)
+ {
+ _size = new Size(Size.Width, value);
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public int NumPoints
+ {
+ get { return _numStarPoints; }
+ set
+ {
+ if (value < 2)
+ {
+ throw new ArgumentOutOfRangeException("NumPoints", "NumPoints must be greater than 1");
+ }
+
+ if (_numStarPoints != value)
+ {
+ _numStarPoints = value;
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public double Pointiness
+ {
+ get { return _pointiness; }
+ set
+ {
+ if (_pointiness != value)
+ {
+ _pointiness = value;
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ #endregion Properties
+
+ protected virtual Point[] CreateStar()
+ {
+ return CreateStar(_size, this.Location, _numStarPoints, _pointiness);
+ }
+
+ public static Point[] CreateStar(Size size, Point location, int numStarPoints, double pointiness)
+ {
+ double wRadius = size.Width / 2.0;
+ double hRadius = size.Height / 2.0;
+ double xMid = wRadius;
+ double yMid = hRadius;
+
+ Point[] pts = new Point[(int)(2 * numStarPoints + 1)];
+ for (int i = 0; i < numStarPoints; i++)
+ {
+ double x1 = xMid + wRadius *
+ -Math.Sin(i * (360 / (double)numStarPoints) * Math.PI / 180);
+ double y1 = yMid + hRadius *
+ -Math.Cos(i * (360 / (double)numStarPoints) * Math.PI / 180);
+ double x2 = xMid + wRadius /
+ pointiness * -Math.Sin((i * (360 / (double)numStarPoints) + (180 / (double)numStarPoints)) * Math.PI / 180);
+ double y2 = yMid + hRadius /
+ pointiness * -Math.Cos((i * (360 / (double)numStarPoints) + (180 / (double)numStarPoints)) * Math.PI / 180);
+
+ pts[2 * i] = new Point((int)x1, (int)y1);
+ pts[2 * i + 1] = new Point((int)x2, (int)y2);
+ }
+ pts[pts.Length - 1] = new Point((int)pts[0].X, (int)pts[0].Y);
+
+ for (int i = 0; i < pts.Length; i++)
+ {
+ pts[i] = new Point(pts[i].X + location.X, pts[i].Y + location.Y);
+ }
+ return pts;
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-12 22:41:01 UTC (rev 75)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-15 23:11:08 UTC (rev 76)
@@ -202,6 +202,7 @@
<Compile Include="Drawing\RelativeAlignment.cs" />
<Compile Include="Drawing\ScaleMode.cs" />
<Compile Include="Drawing\SimpleLinearGradient.cs" />
+ <Compile Include="Drawing\StarItem.cs" />
<Compile Include="Drawing\VerticalAlignment.cs" />
<Compile Include="Drawing\VisualItem.cs" />
<Compile Include="Drawing\VisualItemEventArgs.cs" />
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-12 22:41:02
|
Revision: 75
http://roam.svn.sourceforge.net/roam/?rev=75&view=rev
Author: jonfroehlich
Date: 2007-04-12 15:41:01 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
added ReadOnlyHashtable (which is self-explanatory)
slight update to comment block in PriorityQueue (removed old comment lines)
Modified Paths:
--------------
Trunk/Source/Roam.Common/Collections/PriorityQueue.cs
Trunk/Source/Roam.Common/Roam.Common.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Common/Collections/ReadOnlyHashtable.cs
Modified: Trunk/Source/Roam.Common/Collections/PriorityQueue.cs
===================================================================
--- Trunk/Source/Roam.Common/Collections/PriorityQueue.cs 2007-04-12 07:28:43 UTC (rev 74)
+++ Trunk/Source/Roam.Common/Collections/PriorityQueue.cs 2007-04-12 22:41:01 UTC (rev 75)
@@ -28,9 +28,6 @@
/// Note that the value which is used by the priority queue to compare items
/// must be immutable
/// </summary>
- /// <summary>
- ///
- /// </summary>
/// <remarks>
///
/// </remarks>
Added: Trunk/Source/Roam.Common/Collections/ReadOnlyHashtable.cs
===================================================================
--- Trunk/Source/Roam.Common/Collections/ReadOnlyHashtable.cs (rev 0)
+++ Trunk/Source/Roam.Common/Collections/ReadOnlyHashtable.cs 2007-04-12 22:41:01 UTC (rev 75)
@@ -0,0 +1,86 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections;
+
+namespace Roam.Common.Collections
+{
+ /// <summary>
+ /// Read only hashtable.
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class ReadOnlyHashtable : Hashtable
+ {
+ public ReadOnlyHashtable(IDictionary d)
+ : base()
+ {
+ foreach (DictionaryEntry de in d)
+ {
+ base.Add(de.Key, de.Value);
+ }
+ }
+
+ #region Properties
+ public override bool IsReadOnly
+ {
+ get { return true; }
+ }
+
+ public override bool IsFixedSize
+ {
+ get { return true; }
+ }
+
+ public override object this[object key]
+ {
+ get
+ {
+ return base[key];
+ }
+ set
+ {
+ ThrowReadonlyException(string.Empty);
+ }
+ }
+ #endregion Properties
+
+ #region Methods
+ public override void Clear()
+ {
+ ThrowReadonlyException("Clear failed. ");
+ }
+
+ public override void Add(object key, object value)
+ {
+ ThrowReadonlyException("Add failed. ");
+ }
+
+ public override void Remove(object key)
+ {
+ ThrowReadonlyException("Remove failed. ");
+ }
+
+ protected virtual void ThrowReadonlyException(string prefix)
+ {
+ throw new InvalidOperationException(prefix + "The ReadOnlyHashtable is readonly");
+ }
+ #endregion Methods
+ }
+}
Modified: Trunk/Source/Roam.Common/Roam.Common.csproj
===================================================================
--- Trunk/Source/Roam.Common/Roam.Common.csproj 2007-04-12 07:28:43 UTC (rev 74)
+++ Trunk/Source/Roam.Common/Roam.Common.csproj 2007-04-12 22:41:01 UTC (rev 75)
@@ -63,6 +63,7 @@
<Compile Include="Collections\DfsTreeWalker.cs" />
<Compile Include="Collections\HashSet.cs" />
<Compile Include="Collections\PriorityQueue.cs" />
+ <Compile Include="Collections\ReadOnlyHashtable.cs" />
<Compile Include="Collections\ReverseComparer.cs" />
<Compile Include="Collections\ReverseEnumerator.cs" />
<Compile Include="Collections\Tree.cs" />
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-12 07:28:44
|
Revision: 74
http://roam.svn.sourceforge.net/roam/?rev=74&view=rev
Author: jonfroehlich
Date: 2007-04-12 00:28:43 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
1. exposed BackFill in SmartListBox
2. added one more additional pixel padding for between image and text in ImageItem
Modified Paths:
--------------
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Controls/SmartListBox.cs
Trunk/Source/Roam.UI/Drawing/ImageItem.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-11 14:56:25 UTC (rev 73)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-12 07:28:43 UTC (rev 74)
@@ -73,6 +73,12 @@
<Compile Include="Media\SoundLoopPlayerTest.Designer.cs">
<DependentUpon>SoundLoopPlayerTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\Camera.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Sandbox\Camera.Designer.cs">
+ <DependentUpon>Camera.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\ColorsTest.cs">
<SubType>Form</SubType>
</Compile>
@@ -349,6 +355,12 @@
<DependentUpon>GradientFillTest.cs</DependentUpon>
</Compile>
<Compile Include="Sandbox\Gradient\Win32Helper.cs" />
+ <Compile Include="Sandbox\ImageMap.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Sandbox\ImageMap.Designer.cs">
+ <DependentUpon>ImageMap.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\MonthCalendarTest.cs">
<SubType>Form</SubType>
</Compile>
Modified: Trunk/Source/Roam.UI/Controls/SmartListBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/SmartListBox.cs 2007-04-11 14:56:25 UTC (rev 73)
+++ Trunk/Source/Roam.UI/Controls/SmartListBox.cs 2007-04-12 07:28:43 UTC (rev 74)
@@ -176,6 +176,25 @@
}
}
}
+
+ public virtual Fill BackFill
+ {
+ get { return _backFill; }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("BackFill", "BackFill cannot be null");
+ }
+
+ if (!_backFill.Equals(value))
+ {
+ _backFill = value;
+ this.Invalidate();
+ }
+ }
+ }
+
/// <summary>
/// Gets or sets the highlighted back color
/// </summary>
Modified: Trunk/Source/Roam.UI/Drawing/ImageItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/ImageItem.cs 2007-04-11 14:56:25 UTC (rev 73)
+++ Trunk/Source/Roam.UI/Drawing/ImageItem.cs 2007-04-12 07:28:43 UTC (rev 74)
@@ -30,8 +30,8 @@
public abstract class ImageItem : VisualItem
{
#region Private Fields
- private int _vSpacing = 2;
- private int _hSpacing = 2;
+ private int _vPadding = 2;
+ private int _hPadding = 3;
private ScaleMode _scaleMode = ScaleMode.None;
private RelativeAlignment _textAlign = RelativeAlignment.Right;
private ContentAlignment _imageAlign = ContentAlignment.TopCenter;
@@ -118,13 +118,13 @@
int width = 0, height = 0;
if (_textAlign == RelativeAlignment.Left || _textAlign == RelativeAlignment.Right)
{
- int horizSpaceBetweenImageAndText = (Label == null || Label.Length <= 0) ? 0 : _hSpacing;
+ int horizSpaceBetweenImageAndText = (Label == null || Label.Length <= 0) ? 0 : _hPadding;
width = (int)Math.Ceiling(textBounds.Width + horizSpaceBetweenImageAndText + ImageWidth);
height = (int)Math.Max(textBounds.Height, ImageHeight);
}
else if (_textAlign == RelativeAlignment.Above || _textAlign == RelativeAlignment.Below)
{
- int vertSpaceBetweenImageAndText = (Label == null || Label.Length <= 0) ? 0 : _vSpacing;
+ int vertSpaceBetweenImageAndText = (Label == null || Label.Length <= 0) ? 0 : _vPadding;
width = (int)Math.Max(textBounds.Width, ImageWidth);
height = (int)Math.Ceiling(textBounds.Height + vertSpaceBetweenImageAndText + ImageHeight);
}
@@ -188,12 +188,12 @@
if (TextAlign == RelativeAlignment.Right)
{
xImage = rectangle.X + xOffset + (int)prefixBounds.Width;
- xLabel = xImage + _hSpacing + ImageWidth;
+ xLabel = xImage + _hPadding + ImageWidth;
}
else if (TextAlign == RelativeAlignment.Left)
{
xLabel = rectangle.X + xOffset + (int)prefixBounds.Width;
- xImage = xLabel + _hSpacing + (int)labelBounds.Width;
+ xImage = xLabel + _hPadding + (int)labelBounds.Width;
}
}
else if (TextAlign == RelativeAlignment.Above || TextAlign == RelativeAlignment.Below)
@@ -230,11 +230,11 @@
if (TextAlign == RelativeAlignment.Below)
{
yImage = rectangle.Y + yOffset;
- yLabel = rectangle.Y + _vSpacing + ImageHeight;
+ yLabel = rectangle.Y + _vPadding + ImageHeight;
}
else if (TextAlign == RelativeAlignment.Above)
{
- yImage = (int)(rectangle.Y + _vSpacing + textBounds.Height);
+ yImage = (int)(rectangle.Y + _vPadding + textBounds.Height);
yLabel = rectangle.Y + yOffset;
}
}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-11 14:56:25 UTC (rev 73)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-12 07:28:43 UTC (rev 74)
@@ -121,12 +121,6 @@
<Compile Include="Controls\ImageListBox.Designer.cs">
<DependentUpon>ImageListBox.cs</DependentUpon>
</Compile>
- <Compile Include="Controls\ImageMap.cs">
- <SubType>Component</SubType>
- </Compile>
- <Compile Include="Controls\ImageMap.Designer.cs">
- <DependentUpon>ImageMap.cs</DependentUpon>
- </Compile>
<Compile Include="Controls\KeyFilteredListBox.cs">
<SubType>Component</SubType>
</Compile>
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-11 14:56:26
|
Revision: 73
http://roam.svn.sourceforge.net/roam/?rev=73&view=rev
Author: jonfroehlich
Date: 2007-04-11 07:56:25 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
1. overloaded SetWallpaper method in DesktopUtils to take in a bitmap and path
2. moved FormFactory from Roam.UI.Utils to Roam.UI.Forms
Modified Paths:
--------------
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.UI/Forms/FormFactory.cs
Added: Trunk/Source/Roam.UI/Forms/FormFactory.cs
===================================================================
--- Trunk/Source/Roam.UI/Forms/FormFactory.cs (rev 0)
+++ Trunk/Source/Roam.UI/Forms/FormFactory.cs 2007-04-11 14:56:25 UTC (rev 73)
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using Roam.UI.Controls;
+using System.Drawing;
+using Roam.UI.Forms;
+
+namespace Roam.UI.Forms
+{
+ public static class FormFactory
+ {
+ public static Form Create(string label, Control control)
+ {
+ FactoryForm form = new FactoryForm();
+
+ ScrollableLabel scrollableLabel = new ScrollableLabel(label);
+ form.Controls.Add(scrollableLabel);
+ form.Controls.Add(control);
+
+ scrollableLabel.Location = new Point(0, 0);
+ control.Location = new Point(0, scrollableLabel.Bottom + 1);
+
+ form.Menu = new MainMenu();
+ MenuItem menuItemLeft = new MenuItem();
+ menuItemLeft.Text = "OK";
+ menuItemLeft.Click += delegate(System.Object o, System.EventArgs e)
+ {
+ form.DialogResult = DialogResult.OK;
+ };
+ form.Menu.MenuItems.Add(menuItemLeft);
+
+ MenuItem menuItemRight = new MenuItem();
+ menuItemRight.Text = "Cancel";
+ menuItemRight.Click += delegate(System.Object o, System.EventArgs e)
+ {
+ form.DialogResult = DialogResult.Cancel;
+ };
+ form.Menu.MenuItems.Add(menuItemRight);
+ control.Focus();
+ return form;
+ }
+ }
+
+ public class FactoryForm : RoamForm
+ {
+ protected override void OnResize(EventArgs e)
+ {
+ int x = ClientRectangle.X; int y = ClientRectangle.Y;
+ foreach(Control c in this.Controls)
+ {
+ c.Width = this.ClientSize.Width;
+ c.Location = new Point(x, y);
+ if (c is ScrollableLabel)
+ {
+ c.Height = ((ScrollableLabel)c).PreferredHeight;
+ }
+
+ y = c.Bottom + 1;
+ }
+ base.OnResize(e);
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-09 08:03:58 UTC (rev 72)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-11 14:56:25 UTC (rev 73)
@@ -232,7 +232,7 @@
</Compile>
<Compile Include="Utils\DesktopUtils.cs" />
<Compile Include="Utils\DrawingUtils.cs" />
- <Compile Include="Utils\FormFactory.cs">
+ <Compile Include="Forms\FormFactory.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Utils\HotKeyManager.cs" />
Modified: Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DesktopUtils.cs 2007-04-09 08:03:58 UTC (rev 72)
+++ Trunk/Source/Roam.UI/Utils/DesktopUtils.cs 2007-04-11 14:56:25 UTC (rev 73)
@@ -21,6 +21,8 @@
using System.Runtime.InteropServices;
using OpenNETCF.WindowsCE;
using System.IO;
+using System.Drawing;
+using System.Drawing.Imaging;
namespace Roam.UI.Utils
{
@@ -63,6 +65,18 @@
/// </summary>
public static readonly int SPI_SETDESKWALLPAPER = 20;
+ public static void SetWallpaper(Image image, string tempFilePath)
+ {
+ if (File.Exists(tempFilePath))
+ {
+ File.Delete(tempFilePath);
+ }
+
+ FileStream fs = File.Create(tempFilePath);
+ image.Save(tempFilePath, ImageFormat.Jpeg);
+ SetWallpaper(tempFilePath);
+ }
+
public static void SetWallpaper(string imageFile)
{
if (DeviceManagement.PlatformName.IndexOf("SmartPhone") != -1)
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-09 08:04:00
|
Revision: 72
http://roam.svn.sourceforge.net/roam/?rev=72&view=rev
Author: jonfroehlich
Date: 2007-04-09 01:03:58 -0700 (Mon, 09 Apr 2007)
Log Message:
-----------
Added FormFactory that allows you to quickly create parameterized forms. For example,
NumericTextBox numericTextBox = new NumericTextBox();
numericTextBox.SelectTextOnFocus = true;
numericTextBox.Text = _strokePenWidth.ToString();
Form form = FormFactory.Create("Pen Width:", numericTextBox);
if (form.ShowDialog() == DialogResult.OK)
{
_strokePenWidth = numericTextBox.TextAsInt;
}
Modified Paths:
--------------
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.UI/Utils/FormFactory.cs
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-08 03:04:10 UTC (rev 71)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-09 08:03:58 UTC (rev 72)
@@ -461,7 +461,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-08 03:04:10 UTC (rev 71)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-09 08:03:58 UTC (rev 72)
@@ -232,6 +232,9 @@
</Compile>
<Compile Include="Utils\DesktopUtils.cs" />
<Compile Include="Utils\DrawingUtils.cs" />
+ <Compile Include="Utils\FormFactory.cs">
+ <SubType>Form</SubType>
+ </Compile>
<Compile Include="Utils\HotKeyManager.cs" />
<Compile Include="Utils\ScreenUtils.cs" />
<Compile Include="Utils\WindowsMessagingUtils.cs" />
Modified: Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-04-08 03:04:10 UTC (rev 71)
+++ Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-04-09 08:03:58 UTC (rev 72)
@@ -337,10 +337,39 @@
return "[" + r.X + ", " + r.Y + ", " + r.Width + ", " + r.Height + "]";
}
- public static Rectangle GetRectangle(RectangleF drawStringArea)
+ public static Rectangle GetMinimumAxisAlignedBoundingBox(Point p1, Point p2)
{
- return new Rectangle((int)drawStringArea.X, (int)drawStringArea.Y, (int)drawStringArea.Width, (int)drawStringArea.Height);
+ Point topLeft = Point.Empty, botRight = Point.Empty;
+ if (p1.X < p2.X) { topLeft.X = p1.X; botRight.X = p2.X; }
+ else { topLeft.X = p2.X; botRight.X = p1.X; }
+ if (p1.Y < p2.Y) { topLeft.Y = p1.Y; botRight.Y = p2.Y; }
+ else { topLeft.Y = p2.Y; botRight.Y = p1.Y; }
+ return new Rectangle(topLeft.X, topLeft.Y, botRight.X - topLeft.X, botRight.Y - topLeft.Y);
}
+
+ public static Rectangle GetMinimumAxisAlignedBoundingBox(ICollection<Point> points)
+ {
+ bool initialized = false;
+ Point topLeft = Point.Empty, botRight = Point.Empty;
+ foreach (Point p in points)
+ {
+ if (!initialized)
+ {
+ topLeft = p;
+ botRight = p;
+ initialized = true;
+ }
+ else
+ {
+ if (topLeft.X > p.X) { topLeft.X = p.X; }
+ if (botRight.X < p.X) { botRight.X = p.X; }
+ if (topLeft.Y > p.Y) { topLeft.Y = p.Y; }
+ if (botRight.Y < p.Y) { botRight.Y = p.Y; }
+ }
+ }
+ return new Rectangle(topLeft.X, topLeft.Y, botRight.X - topLeft.X, botRight.Y - topLeft.Y);
+ }
+
}
/// <summary>
Added: Trunk/Source/Roam.UI/Utils/FormFactory.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/FormFactory.cs (rev 0)
+++ Trunk/Source/Roam.UI/Utils/FormFactory.cs 2007-04-09 08:03:58 UTC (rev 72)
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using Roam.UI.Controls;
+using System.Drawing;
+using Roam.UI.Forms;
+
+namespace Roam.UI.Utils
+{
+ public static class FormFactory
+ {
+ public static Form Create(string label, Control control)
+ {
+ FactoryForm form = new FactoryForm();
+
+ ScrollableLabel scrollableLabel = new ScrollableLabel(label);
+ form.Controls.Add(scrollableLabel);
+ form.Controls.Add(control);
+
+ scrollableLabel.Location = new Point(0, 0);
+ control.Location = new Point(0, scrollableLabel.Bottom + 1);
+
+ form.Menu = new MainMenu();
+ MenuItem menuItemLeft = new MenuItem();
+ menuItemLeft.Text = "OK";
+ menuItemLeft.Click += delegate(System.Object o, System.EventArgs e)
+ {
+ form.DialogResult = DialogResult.OK;
+ };
+ form.Menu.MenuItems.Add(menuItemLeft);
+
+ MenuItem menuItemRight = new MenuItem();
+ menuItemRight.Text = "Cancel";
+ menuItemRight.Click += delegate(System.Object o, System.EventArgs e)
+ {
+ form.DialogResult = DialogResult.Cancel;
+ };
+ form.Menu.MenuItems.Add(menuItemRight);
+ control.Focus();
+ return form;
+ }
+ }
+
+ public class FactoryForm : RoamForm
+ {
+ protected override void OnResize(EventArgs e)
+ {
+ int x = ClientRectangle.X; int y = ClientRectangle.Y;
+ //for (int i = this.Controls.Count - 1; i >= 0; i--)
+ //{
+ // Control c = this.Controls[i];
+ foreach(Control c in this.Controls)
+ {
+ c.Width = this.ClientSize.Width;
+ c.Location = new Point(x, y);
+ if (c is ScrollableLabel)
+ {
+ c.Height = ((ScrollableLabel)c).PreferredHeight;
+ }
+
+ y = c.Bottom + 1;
+ }
+ base.OnResize(e);
+ }
+ }
+}
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-08 03:04:12
|
Revision: 71
http://roam.svn.sourceforge.net/roam/?rev=71&view=rev
Author: jonfroehlich
Date: 2007-04-07 20:04:10 -0700 (Sat, 07 Apr 2007)
Log Message:
-----------
added DirectoryUtils to Roam.Common, which contains a collection of directory-related static methods. For example, the size of the directory in bytes (including sub-directories is settable) and the number of files in a directory (with or without subdirectories)
Modified Paths:
--------------
Trunk/Source/Roam.Common/Roam.Common.csproj
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs
Modified: Trunk/Source/Roam.Common/Roam.Common.csproj
===================================================================
--- Trunk/Source/Roam.Common/Roam.Common.csproj 2007-04-02 05:26:29 UTC (rev 70)
+++ Trunk/Source/Roam.Common/Roam.Common.csproj 2007-04-08 03:04:10 UTC (rev 71)
@@ -74,6 +74,7 @@
<Compile Include="Collections\WalkUpTreeBranchEnumerator.cs" />
<Compile Include="Collections\WalkUpTreeBranch.cs" />
<Compile Include="Utils\DebugWriteAppender.cs" />
+ <Compile Include="Utils\DirectoryUtils.cs" />
<Compile Include="Utils\EnumUtils.cs" />
<Compile Include="Utils\ErrorUtils.cs" />
<Compile Include="Utils\ImagingUtils.cs" />
Added: Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs (rev 0)
+++ Trunk/Source/Roam.Common/Utils/DirectoryUtils.cs 2007-04-08 03:04:10 UTC (rev 71)
@@ -0,0 +1,103 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace Roam.Common.Utils
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public static class DirectoryUtils
+ {
+ /// <summary>
+ /// Returns the size of this directory and all sub-directories in bytes.
+ /// </summary>
+ /// <param name="path"></param>
+ /// <returns></returns>
+ public static long GetSize(string directoryPath)
+ {
+ return GetSize(directoryPath, true);
+ }
+
+ public static long GetSize(string directoryPath, bool recursive)
+ {
+ long size = 0;
+
+ if (recursive)
+ {
+ string[] directories = Directory.GetDirectories(directoryPath);
+ foreach (string directory in directories)
+ {
+ size += GetSize(directory, recursive);
+ }
+ }
+
+ string[] files = Directory.GetFiles(directoryPath);
+ foreach (string file in files)
+ {
+ FileInfo fi = new FileInfo(file);
+ size += fi.Length;
+ }
+
+ return size;
+ }
+
+ public static List<FileInfo> GetFileInfos(string directoryPath, bool recursive)
+ {
+ List<FileInfo> listFileInfos = new List<FileInfo>();
+
+ if (recursive)
+ {
+ string[] directories = Directory.GetDirectories(directoryPath);
+ foreach (string directory in directories)
+ {
+ listFileInfos.AddRange(GetFileInfos(directoryPath, recursive));
+ }
+ }
+
+ string[] files = Directory.GetFiles(directoryPath);
+ foreach (string file in files)
+ {
+ listFileInfos.Add(new FileInfo(file));
+ }
+
+ return listFileInfos;
+ }
+
+ public static int GetNumFiles(string directoryPath, bool recursive)
+ {
+ int numFiles = 0;
+ if (recursive)
+ {
+ string[] directories = Directory.GetDirectories(directoryPath);
+ foreach (string directory in directories)
+ {
+ numFiles += GetNumFiles(directoryPath, recursive);
+ }
+ }
+
+ string[] files = Directory.GetFiles(directoryPath);
+ numFiles += files.Length;
+ return numFiles;
+ }
+ }
+}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-02 05:26:29 UTC (rev 70)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-08 03:04:10 UTC (rev 71)
@@ -599,7 +599,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-04-02 05:26:31
|
Revision: 70
http://roam.svn.sourceforge.net/roam/?rev=70&view=rev
Author: jonfroehlich
Date: 2007-04-01 22:26:29 -0700 (Sun, 01 Apr 2007)
Log Message:
-----------
1. added XmlUtils for XML related utility functions. one method, for example, extracts XML attributes and values and adds them to a dictionary
2. added ImageMap--I'm just getting started with this (it should probably be in Sandbox or something)
Modified Paths:
--------------
Trunk/Source/Roam.Common/Roam.Common.csproj
Trunk/Source/Roam.Common/Utils/TimeUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Common/Utils/XmlUtils.cs
Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs
Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx
Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs
Trunk/Source/Roam.UI/Controls/ImageMap.cs
Modified: Trunk/Source/Roam.Common/Roam.Common.csproj
===================================================================
--- Trunk/Source/Roam.Common/Roam.Common.csproj 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.Common/Roam.Common.csproj 2007-04-02 05:26:29 UTC (rev 70)
@@ -98,6 +98,7 @@
<Compile Include="Utils\TimeUtils.cs" />
<Compile Include="Utils\TypeUtils.cs" />
<Compile Include="Utils\WindowUtils.cs" />
+ <Compile Include="Utils\XmlUtils.cs" />
</ItemGroup>
<Import Condition="'$(TargetFrameworkVersion)' == 'v1.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.v1.targets" />
<Import Condition="'$(TargetFrameworkVersion)' == 'v2.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
Modified: Trunk/Source/Roam.Common/Utils/TimeUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/TimeUtils.cs 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.Common/Utils/TimeUtils.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -115,5 +115,19 @@
throw new InvalidOperationException(String.Format("TimeResolution {0} not supported", timeResolution));
}
+
+ public static readonly DateTime UNIX_START_DATE = new DateTime(1970, 1, 1, 0, 0, 0);
+
+ public static long ConvertToUnixTimeStamp(DateTime dateTime)
+ {
+ TimeSpan ts = UNIX_START_DATE - UNIX_START_DATE;
+ return (long)ts.TotalSeconds;
+ }
+
+ public static DateTime ConvertToDateTime(long unixTimeStamp)
+ {
+ return UNIX_START_DATE.AddSeconds(unixTimeStamp);
+ }
+
}
}
Added: Trunk/Source/Roam.Common/Utils/XmlUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/XmlUtils.cs (rev 0)
+++ Trunk/Source/Roam.Common/Utils/XmlUtils.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+
+namespace Roam.Common.Utils
+{
+ public static class XmlUtils
+ {
+ public static IDictionary<string, string> GetAttributes(XmlReader xmlReader)
+ {
+ Dictionary<string, string> attributes = new Dictionary<string, string>(5);
+ if (xmlReader.HasAttributes)
+ {
+ while (xmlReader.MoveToNextAttribute())
+ {
+ attributes[xmlReader.Name.ToLower()] = xmlReader.Value;
+ }
+ }
+ return attributes;
+ }
+ }
+}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-02 05:26:29 UTC (rev 70)
@@ -190,6 +190,10 @@
<DependentUpon>CheckedListBoxTest.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="UI\Controls\ImageMapTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>ImageMapTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="UI\Controls\RoundedRectTest2.resx">
<SubType>Designer</SubType>
<DependentUpon>RoundedRectTest2.cs</DependentUpon>
@@ -438,6 +442,12 @@
<Compile Include="UI\Controls\CameraMediaSnifferTest.Designer.cs">
<DependentUpon>CameraMediaSnifferTest.cs</DependentUpon>
</Compile>
+ <Compile Include="UI\Controls\ImageMapTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="UI\Controls\ImageMapTest.Designer.cs">
+ <DependentUpon>ImageMapTest.cs</DependentUpon>
+ </Compile>
<Compile Include="UI\Controls\RoundedRectTest2.cs">
<SubType>Form</SubType>
</Compile>
@@ -451,7 +461,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
Added: Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,74 @@
+namespace Roam.Test.UI.Controls
+{
+ partial class ImageMapTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.imageMap1 = new Roam.UI.Controls.ImageMap();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // imageMap1
+ //
+ this.imageMap1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.imageMap1.Location = new System.Drawing.Point(0, 0);
+ this.imageMap1.Name = "imageMap1";
+ this.imageMap1.Size = new System.Drawing.Size(240, 266);
+ this.imageMap1.TabIndex = 0;
+ this.imageMap1.Text = "imageMap1";
+ //
+ // ImageMapTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this.imageMap1);
+ this.Menu = this.mainMenu1;
+ this.Name = "ImageMapTest";
+ this.Text = "ImageMapTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private Roam.UI.Controls.ImageMap imageMap1;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Roam.Test.UI.Controls
+{
+ public partial class ImageMapTest : Form
+ {
+ public ImageMapTest()
+ {
+ InitializeComponent();
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs (rev 0)
+++ Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,36 @@
+namespace Roam.UI.Controls
+{
+ partial class ImageMap
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
Added: Trunk/Source/Roam.UI/Controls/ImageMap.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ImageMap.cs (rev 0)
+++ Trunk/Source/Roam.UI/Controls/ImageMap.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Roam.UI.Controls
+{
+ public enum ImageMapOverlayMode
+ {
+ None,
+ DrawGrid,
+ DrawGridWithNumbers
+ }
+
+ public enum ImageMapSizeMode
+ {
+ /// <summary>
+ /// The image is placed in the upper-left corner of the ImageMap.
+ /// The image is clipped if it is larger than the ImageMap it is contained in.
+ /// </summary>
+ Normal,
+
+ /// <summary>
+ /// The image within the ImageMap is stretched or shrunk to fit the size of the ImageMap.
+ /// </summary>
+ StretchImage
+ }
+
+ public partial class ImageMap : Control
+ {
+ private Image _image;
+ private ImageMapOverlayMode _overlayMode = ImageMapOverlayMode.DrawGridWithNumbers;
+ private ImageMapSizeMode _sizeMode = ImageMapSizeMode.Normal;
+ private float _gridAlpha = 0.5f;
+ private Font _gridFont = new Font(FontFamily.GenericSansSerif, 14, FontStyle.Bold);
+ private Color _gridColor = Color.PowderBlue;
+ private float _gridThickness = 2;
+
+ public ImageMap()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnPaint(PaintEventArgs pe)
+ {
+ Graphics g = pe.Graphics;
+ DrawGrid(g, null, this.ClientRectangle);
+ // Calling the base class OnPaint
+ base.OnPaint(pe);
+ }
+
+ protected virtual void DrawGrid(Graphics g, Image bottomLayers, Rectangle drawingArea)
+ {
+ Pen gridPen = new Pen(_gridColor, _gridThickness);
+ SolidBrush gridBrush = new SolidBrush(_gridColor);
+
+ //split up area into a 3x3 grid
+ const int numGrids = 3;
+ Size gridSize = new Size((int)(drawingArea.Width / (float)numGrids), (int)(drawingArea.Height / (float)numGrids));
+ for (int gridLine = 1; gridLine < numGrids; gridLine++)
+ {
+ //draw horizontal horizontal line
+ int y = drawingArea.Top + gridLine * gridSize.Height;
+ g.DrawLine(gridPen, drawingArea.Left, y, drawingArea.Right, y);
+
+ //draw vertical grid line
+ int x = drawingArea.Left + gridLine * gridSize.Width;
+ g.DrawLine(gridPen, x, drawingArea.Top, x, drawingArea.Bottom);
+ }
+
+ //draw labels within grid
+ for (int i = 1; i <= numGrids * numGrids; i++)
+ {
+ string label = i.ToString();
+ SizeF labelSize = g.MeasureString(label, _gridFont);
+ int row = (int)Math.Floor(i / (float)numGrids);
+ int col = (i - 1) % numGrids;
+
+ int xLeftGrid = drawingArea.Left + col * gridSize.Width;
+ int yTopGrid = drawingArea.Top + row * gridSize.Height;
+
+ float xLabel = xLeftGrid + gridSize.Width / 2f - labelSize.Width / 2f;
+ float yLabel = yTopGrid + gridSize.Height / 2f - labelSize.Width / 2f;
+
+ g.DrawString(label, _gridFont, gridBrush, xLabel, yLabel);
+ }
+
+ gridPen.Dispose();
+ gridBrush.Dispose();
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-02 05:26:29 UTC (rev 70)
@@ -121,6 +121,12 @@
<Compile Include="Controls\ImageListBox.Designer.cs">
<DependentUpon>ImageListBox.cs</DependentUpon>
</Compile>
+ <Compile Include="Controls\ImageMap.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Controls\ImageMap.Designer.cs">
+ <DependentUpon>ImageMap.cs</DependentUpon>
+ </Compile>
<Compile Include="Controls\KeyFilteredListBox.cs">
<SubType>Component</SubType>
</Compile>
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-03-21 20:36:37
|
Revision: 69
http://roam.svn.sourceforge.net/roam/?rev=69&view=rev
Author: jonfroehlich
Date: 2007-03-21 13:36:36 -0700 (Wed, 21 Mar 2007)
Log Message:
-----------
1. added exit to RoundedRectTest2
2. made ismodal go false after ShowDialog returned in RoamForm
Modified Paths:
--------------
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx
Trunk/Source/Roam.UI/Forms/RoamForm.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-21 07:24:49 UTC (rev 68)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-21 20:36:36 UTC (rev 69)
@@ -589,7 +589,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs 2007-03-21 07:24:49 UTC (rev 68)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs 2007-03-21 20:36:36 UTC (rev 69)
@@ -29,7 +29,7 @@
/// </summary>
private void InitializeComponent()
{
- System.Windows.Forms.Label label1;
+ this.label1 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
@@ -42,9 +42,16 @@
this.label5 = new System.Windows.Forms.Label();
this._numericTextBoxRoundedCornerHeight = new Roam.UI.Controls.NumericTextBox();
this._numericTextBoxRoundedCornerWidth = new Roam.UI.Controls.NumericTextBox();
- label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label1.Location = new System.Drawing.Point(3, 12);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(61, 18);
+ this.label1.Text = "BackColor:";
+ //
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItem1);
@@ -53,19 +60,12 @@
// menuItem1
//
this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem2
//
this.menuItem2.Text = "Menu";
//
- // label1
- //
- label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
- label1.Location = new System.Drawing.Point(3, 12);
- label1.Name = "label1";
- label1.Size = new System.Drawing.Size(61, 18);
- label1.Text = "BackColor:";
- //
// label2
//
this.label2.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
@@ -156,7 +156,7 @@
this.Controls.Add(this._comboBoxBackColor);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
- this.Controls.Add(label1);
+ this.Controls.Add(this.label1);
this.Menu = this.mainMenu1;
this.Name = "RoundedRectTest2";
this.Text = "RoundedRectTest2";
@@ -177,5 +177,6 @@
private System.Windows.Forms.Label label5;
private Roam.UI.Controls.NumericTextBox _numericTextBoxRoundedCornerHeight;
private Roam.UI.Controls.NumericTextBox _numericTextBoxRoundedCornerWidth;
+ private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs 2007-03-21 07:24:49 UTC (rev 68)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs 2007-03-21 20:36:36 UTC (rev 69)
@@ -112,5 +112,10 @@
base.OnPaint(e);
}
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
}
}
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx 2007-03-21 07:24:49 UTC (rev 68)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx 2007-03-21 20:36:36 UTC (rev 69)
@@ -120,9 +120,6 @@
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
- <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>False</value>
- </metadata>
<metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
<value>Smartphone QVGA</value>
</metadata>
Modified: Trunk/Source/Roam.UI/Forms/RoamForm.cs
===================================================================
--- Trunk/Source/Roam.UI/Forms/RoamForm.cs 2007-03-21 07:24:49 UTC (rev 68)
+++ Trunk/Source/Roam.UI/Forms/RoamForm.cs 2007-03-21 20:36:36 UTC (rev 69)
@@ -61,13 +61,6 @@
//The following is a workaround relating to the differences between form.ShowDialog()
//and Application2.ShowDialog()
//
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
//Setting the DialogResult property with a value from the DialogResult enumeration
//sets the value of the dialog box result for the form, hides the modal
//dialog box, and returns control to the calling form. However, this does
@@ -87,7 +80,9 @@
public new DialogResult ShowDialog()
{
_isModal = true;
- return ShowDialog();
+ DialogResult dr = ShowDialog();
+ _isModal = false;
+ return dr;
}
public new void Show()
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-03-21 07:24:51
|
Revision: 68
http://roam.svn.sourceforge.net/roam/?rev=68&view=rev
Author: jonfroehlich
Date: 2007-03-21 00:24:49 -0700 (Wed, 21 Mar 2007)
Log Message:
-----------
1. added some indexer helper functions to TypeUtils
2. added a todo comment to SmartListBox
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/TypeUtils.cs
Trunk/Source/Roam.UI/Controls/SmartListBox.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Common/Utils/TypeUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/TypeUtils.cs 2007-03-12 09:27:15 UTC (rev 67)
+++ Trunk/Source/Roam.Common/Utils/TypeUtils.cs 2007-03-21 07:24:49 UTC (rev 68)
@@ -15,6 +15,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Reflection;
namespace Roam.Common.Utils
{
@@ -102,5 +103,41 @@
/// <author>Jon Froehlich</author>
return strReturn + className;
}
+
+ public static IList<PropertyInfo> GetIndexerProperties(Type t)
+ {
+ List<PropertyInfo> indexerProperties = new List<PropertyInfo>();
+ foreach (PropertyInfo pi in t.GetProperties())
+ {
+ if (pi.GetIndexParameters().Length > 0)
+ {
+ indexerProperties.Add(pi);
+ }
+ }
+ return indexerProperties;
+ }
+
+ public static PropertyInfo GetIndexProperty(Type t, Type parameterType)
+ {
+ PropertyInfo bestMatch = null;
+ ParameterInfo[] bestMatchParams = null;
+ foreach (PropertyInfo pi in t.GetProperties())
+ {
+ ParameterInfo[] paramInfos = pi.GetIndexParameters();
+ if (paramInfos.Length == 1 &&
+ (paramInfos[0].ParameterType == parameterType ||
+ parameterType.IsSubclassOf(paramInfos[0].ParameterType)))
+ {
+ if (bestMatch == null || bestMatchParams[0].ParameterType != parameterType)
+ {
+ bestMatch = pi;
+ bestMatchParams = paramInfos;
+
+ if (bestMatchParams[0].ParameterType == parameterType) { break; }
+ }
+ }
+ }
+ return bestMatch;
+ }
}
}
Modified: Trunk/Source/Roam.UI/Controls/SmartListBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/SmartListBox.cs 2007-03-12 09:27:15 UTC (rev 67)
+++ Trunk/Source/Roam.UI/Controls/SmartListBox.cs 2007-03-21 07:24:49 UTC (rev 68)
@@ -892,6 +892,7 @@
}
}
+ //jeffixme : change the 0,0 to ClientRectangle.X and ClientRectangle.Y?
pe.Graphics.DrawImage(_bmpOffScreen, 0, 0);
g.Dispose();
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-03-12 09:31:20
|
Revision: 67
http://roam.svn.sourceforge.net/roam/?rev=67&view=rev
Author: jonfroehlich
Date: 2007-03-12 02:27:15 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-10 10:11:55 UTC (rev 66)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-12 09:27:15 UTC (rev 67)
@@ -451,7 +451,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
@@ -589,7 +589,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-10 10:11:55 UTC (rev 66)
+++ Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-12 09:27:15 UTC (rev 67)
@@ -243,6 +243,11 @@
}
}
+ public bool IsBeginUpdateSet
+ {
+ get { return _beginUpdate; }
+ }
+
protected VScrollBar VScrollBar
{
get { return _vScrollBar; }
@@ -324,10 +329,6 @@
#endregion Public Methods
#region Protected Methods
- protected bool IsBeginUpdateSet
- {
- get { return _beginUpdate; }
- }
protected override void OnGotFocus(EventArgs e)
{
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-03-10 10:11:59
|
Revision: 66
http://roam.svn.sourceforge.net/roam/?rev=66&view=rev
Author: jonfroehlich
Date: 2007-03-10 02:11:55 -0800 (Sat, 10 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs 2007-03-10 09:19:14 UTC (rev 65)
+++ Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs 2007-03-10 10:11:55 UTC (rev 66)
@@ -33,19 +33,23 @@
private Color _foreColor = Color.Black;
private int _roundedCornerWidth = 5;
private int _roundedCornerHeight = 5;
- private float _penWidth = 2;
+ private float _penWidth = 1;
private bool _drawSolidBack = true;
private Color _solidBackColor = Color.White;
#endregion Fields
#region Constructors
- public FillRoundedRectangle(Color backColor) : this(backColor, Color.Black, 0) { }
- public FillRoundedRectangle(Color backColor, Color foreColor) : this(backColor, foreColor, 0) { }
+ public FillRoundedRectangle(Color backColor) : this(backColor, Color.Black, 1) { }
+ public FillRoundedRectangle(Color backColor, Color foreColor) : this(backColor, foreColor, 1) { }
public FillRoundedRectangle(Color backColor, Color foreColor, float alphaBlend)
: this(backColor, foreColor, 5, 5, alphaBlend) { }
public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight)
- : this(backColor, foreColor, roundedCornerWidth, roundedCornerHeight, 0) { }
- public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight, float alphaBlend)
+ : this(backColor, foreColor, roundedCornerWidth, roundedCornerHeight, 1) { }
+ public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight, float penWidth)
+ : this(backColor, foreColor, roundedCornerWidth, roundedCornerHeight, 1, 0)
+ {
+ }
+ public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight, float penWidth, float alphaBlend)
: base(alphaBlend, backColor)
{
_foreColor = foreColor;
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2007-03-10 09:19:15
|
Revision: 65
http://roam.svn.sourceforge.net/roam/?rev=65&view=rev
Author: jonfroehlich
Date: 2007-03-10 01:19:14 -0800 (Sat, 10 Mar 2007)
Log Message:
-----------
1. added static method to ColorUtils to retrieve all of the static colors in the Color class
2. updated ScrollableLabel to use Insets and fixed a scrolling bug
3. added a test for rounded rectangles (RoundedRectTest2)
4. Added a select text on focus feature to TextBox
5. Insets now implements IEquatable
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs
Trunk/Source/Roam.Common/Utils/ColorUtils.cs
Trunk/Source/Roam.Common/Utils/EnumUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs
Trunk/Source/Roam.UI/Controls/NumericTextBox.cs
Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
Trunk/Source/Roam.UI/Controls/TextBox.cs
Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
Trunk/Source/Roam.UI/Drawing/Insets.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx
Modified: Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -52,5 +52,10 @@
cnt++;
}
}
+
+ public static string GetExecutingAssemblyPath()
+ {
+ return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
+ }
}
}
Modified: Trunk/Source/Roam.Common/Utils/ColorUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/ColorUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Common/Utils/ColorUtils.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -17,6 +17,8 @@
using System;
using System.Drawing;
+using System.Collections.Generic;
+using System.Reflection;
namespace Roam.Common.Utils
{
@@ -29,6 +31,30 @@
/// <author>Jon Froehlich</author>
public static class ColorUtils
{
+ private static Dictionary<string, Color> _staticColorMap = null;
+
+ public static IDictionary<string, Color> GetStaticColors()
+ {
+ if(_staticColorMap == null)
+ {
+ Dictionary<string, Color> mapColors = new Dictionary<string, Color>();
+ foreach (PropertyInfo pi in typeof(Color).GetProperties())
+ {
+ if (pi.PropertyType == typeof(Color))
+ {
+ mapColors[pi.Name] = (Color)pi.GetValue(null, null);
+ }
+ }
+ _staticColorMap = mapColors;
+ }
+ return _staticColorMap;
+ }
+
+ public static Color GetStaticColorFromName(string colorName)
+ {
+ return GetStaticColors()[colorName];
+ }
+
public static Color GetRandomColor()
{
Random rand = new Random();
Modified: Trunk/Source/Roam.Common/Utils/EnumUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/EnumUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Common/Utils/EnumUtils.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -12,12 +12,17 @@
List<string> l = new List<string>();
foreach (FieldInfo fi in t.GetFields())
{
- if (fi.Name != "value__")
+ if (!IsReservedEnumName(fi.Name))
{
l.Add(fi.Name);
}
}
return l.ToArray();
}
+
+ public static bool IsReservedEnumName(string name)
+ {
+ return name == "value__";
+ }
}
}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-10 09:19:14 UTC (rev 65)
@@ -190,6 +190,10 @@
<DependentUpon>CheckedListBoxTest.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="UI\Controls\RoundedRectTest2.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>RoundedRectTest2.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="UI\Controls\TextBoxFilteredListTest.resx">
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
<SubType>Designer</SubType>
@@ -371,6 +375,9 @@
<Compile Include="Sandbox\PhoneCallTalkingTest.Designer.cs">
<DependentUpon>PhoneCallTalkingTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\TextBoxBackgroundTest.cs">
+ <SubType>Component</SubType>
+ </Compile>
<Compile Include="Sandbox\TopMostFormTest.cs">
<SubType>Form</SubType>
</Compile>
@@ -431,6 +438,12 @@
<Compile Include="UI\Controls\CameraMediaSnifferTest.Designer.cs">
<DependentUpon>CameraMediaSnifferTest.cs</DependentUpon>
</Compile>
+ <Compile Include="UI\Controls\RoundedRectTest2.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="UI\Controls\RoundedRectTest2.Designer.cs">
+ <DependentUpon>RoundedRectTest2.cs</DependentUpon>
+ </Compile>
<Compile Include="UI\Controls\TextBoxFilteredListTest.cs">
<SubType>Form</SubType>
</Compile>
Modified: Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -81,7 +81,6 @@
this.scrollableLabel1.ShowScrollBar = true;
this.scrollableLabel1.Size = new System.Drawing.Size(234, 58);
this.scrollableLabel1.TabIndex = 1;
- this.scrollableLabel1.TextPadding = 1;
//
// menuItem2
//
Added: Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,199 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.Diagnostics;
+
+namespace Roam.UI.Controls
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class TextBoxBackgroundTest : System.Windows.Forms.TextBox
+ {
+ private Color _borderColor = Color.Black;
+ private Color _selBorderColor = SystemColors.HighlightText;
+ private Color _selBackColor = SystemColors.Highlight;
+ private Color _selForeColor = SystemColors.HighlightText;
+ private Color _disabledBackColor = Color.Gray;
+ private Color _disabledForeColor = Color.DarkGray;
+ private Color _disabledBorderColor = Color.DarkGray;
+
+ public TextBoxBackgroundTest()
+ : base()
+ {
+ this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ }
+
+ #region Properties
+ public Color BorderColor
+ {
+ get { return _borderColor; }
+ set
+ {
+ if (_borderColor != value)
+ {
+ _borderColor = value;
+ if (!Focused && Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color SelectedBorderColor
+ {
+ get { return _selBorderColor; }
+ set
+ {
+ if (_selBorderColor != value)
+ {
+ _selBorderColor = value;
+ if (Focused)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color SelectedBackColor
+ {
+ get { return _selBackColor; }
+ set
+ {
+ if (_selBackColor != value)
+ {
+ _selBackColor = value;
+ if (Focused)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color SelectedForeColor
+ {
+ get { return _selForeColor; }
+ set
+ {
+ if (_selForeColor != value)
+ {
+ _selForeColor = value;
+ if (Focused)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color DisabledBorderColor
+ {
+ get { return _disabledBorderColor; }
+ set
+ {
+ if (_disabledBorderColor != value)
+ {
+ _disabledBorderColor = value;
+ if (!Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color DisabledBackColor
+ {
+ get { return _disabledBackColor; }
+ set
+ {
+ if (_disabledBackColor != value)
+ {
+ _disabledBackColor = value;
+ if (!Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color DisabledForeColor
+ {
+ get { return _disabledForeColor; }
+ set
+ {
+ if (_disabledForeColor != value)
+ {
+ _disabledForeColor = value;
+ if (!Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+ #endregion Properties
+
+ protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
+ {
+ Debug.WriteLine("OnPaintBackground entered.");
+ base.OnPaintBackground(e);
+
+ SolidBrush backBrush = new SolidBrush(this.BackColor);
+ SolidBrush frontBrush = new SolidBrush(this.ForeColor);
+ Pen borderPen = new Pen(this.BorderColor);
+
+ if (this.Focused)
+ {
+ backBrush.Color = this.SelectedBackColor;
+ frontBrush.Color = this.SelectedForeColor;
+ borderPen.Color = this.SelectedBorderColor;
+ }
+ else if (!this.Enabled)
+ {
+ backBrush.Color = this.DisabledBackColor;
+ frontBrush.Color = this.DisabledForeColor;
+ borderPen.Color = this.DisabledBorderColor;
+ }
+
+ if (BorderStyle == System.Windows.Forms.BorderStyle.FixedSingle)
+ {
+ Rectangle rectangle = this.ClientRectangle;
+ e.Graphics.DrawRectangle(borderPen, rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1);
+ }
+
+ backBrush.Dispose();
+ frontBrush.Dispose();
+ borderPen.Dispose();
+ }
+
+ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
+ {
+ Debug.WriteLine("OnPaint entered.");
+ base.OnPaint(e);
+ }
+ }
+}
Added: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,181 @@
+namespace Roam.Test.UI.Controls
+{
+ partial class RoundedRectTest2
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.Windows.Forms.Label label1;
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this._comboBoxBackColor = new System.Windows.Forms.ComboBox();
+ this._comboBoxForeColor = new System.Windows.Forms.ComboBox();
+ this._numericTextBoxPenSize = new Roam.UI.Controls.NumericTextBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this._numericTextBoxRoundedCornerHeight = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxRoundedCornerWidth = new Roam.UI.Controls.NumericTextBox();
+ label1 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ //
+ // menuItem2
+ //
+ this.menuItem2.Text = "Menu";
+ //
+ // label1
+ //
+ label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ label1.Location = new System.Drawing.Point(3, 12);
+ label1.Name = "label1";
+ label1.Size = new System.Drawing.Size(61, 18);
+ label1.Text = "BackColor:";
+ //
+ // label2
+ //
+ this.label2.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label2.Location = new System.Drawing.Point(3, 30);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(61, 18);
+ this.label2.Text = "ForeColor:";
+ //
+ // label3
+ //
+ this.label3.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label3.Location = new System.Drawing.Point(3, 48);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(52, 18);
+ this.label3.Text = "Pen Size:";
+ //
+ // _comboBoxBackColor
+ //
+ this._comboBoxBackColor.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._comboBoxBackColor.Location = new System.Drawing.Point(64, 9);
+ this._comboBoxBackColor.Name = "_comboBoxBackColor";
+ this._comboBoxBackColor.Size = new System.Drawing.Size(167, 18);
+ this._comboBoxBackColor.TabIndex = 5;
+ //
+ // _comboBoxForeColor
+ //
+ this._comboBoxForeColor.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._comboBoxForeColor.Location = new System.Drawing.Point(64, 27);
+ this._comboBoxForeColor.Name = "_comboBoxForeColor";
+ this._comboBoxForeColor.Size = new System.Drawing.Size(167, 18);
+ this._comboBoxForeColor.TabIndex = 6;
+ //
+ // _numericTextBoxPenSize
+ //
+ this._numericTextBoxPenSize.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxPenSize.Location = new System.Drawing.Point(126, 48);
+ this._numericTextBoxPenSize.Name = "_numericTextBoxPenSize";
+ this._numericTextBoxPenSize.Size = new System.Drawing.Size(105, 18);
+ this._numericTextBoxPenSize.TabIndex = 7;
+ this._numericTextBoxPenSize.Text = "1";
+ //
+ // label4
+ //
+ this.label4.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label4.Location = new System.Drawing.Point(3, 69);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(126, 18);
+ this.label4.Text = "Rounded Corner Height:";
+ //
+ // label5
+ //
+ this.label5.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label5.Location = new System.Drawing.Point(3, 88);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(126, 18);
+ this.label5.Text = "Rounded Corner Width:";
+ //
+ // _numericTextBoxRoundedCornerHeight
+ //
+ this._numericTextBoxRoundedCornerHeight.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxRoundedCornerHeight.Location = new System.Drawing.Point(126, 68);
+ this._numericTextBoxRoundedCornerHeight.Name = "_numericTextBoxRoundedCornerHeight";
+ this._numericTextBoxRoundedCornerHeight.Size = new System.Drawing.Size(105, 18);
+ this._numericTextBoxRoundedCornerHeight.TabIndex = 12;
+ this._numericTextBoxRoundedCornerHeight.Text = "10";
+ //
+ // _numericTextBoxRoundedCornerWidth
+ //
+ this._numericTextBoxRoundedCornerWidth.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxRoundedCornerWidth.Location = new System.Drawing.Point(126, 88);
+ this._numericTextBoxRoundedCornerWidth.Name = "_numericTextBoxRoundedCornerWidth";
+ this._numericTextBoxRoundedCornerWidth.Size = new System.Drawing.Size(105, 18);
+ this._numericTextBoxRoundedCornerWidth.TabIndex = 13;
+ this._numericTextBoxRoundedCornerWidth.Text = "10";
+ //
+ // RoundedRectTest2
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._numericTextBoxRoundedCornerWidth);
+ this.Controls.Add(this._numericTextBoxRoundedCornerHeight);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this._numericTextBoxPenSize);
+ this.Controls.Add(this._comboBoxForeColor);
+ this.Controls.Add(this._comboBoxBackColor);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(label1);
+ this.Menu = this.mainMenu1;
+ this.Name = "RoundedRectTest2";
+ this.Text = "RoundedRectTest2";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ComboBox _comboBoxBackColor;
+ private System.Windows.Forms.ComboBox _comboBoxForeColor;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxPenSize;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label5;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxRoundedCornerHeight;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxRoundedCornerWidth;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,116 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.Common.Utils;
+using Roam.UI.Drawing;
+
+namespace Roam.Test.UI.Controls
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public partial class RoundedRectTest2 : Form
+ {
+ private FillRoundedRectangle _fill = new FillRoundedRectangle(Color.Black);
+
+ public RoundedRectTest2()
+ {
+ InitializeComponent();
+ _comboBoxBackColor.BeginUpdate();
+ _comboBoxForeColor.BeginUpdate();
+ foreach (KeyValuePair<string, Color> colors in ColorUtils.GetStaticColors())
+ {
+ _comboBoxBackColor.Items.Add(colors.Key);
+ _comboBoxForeColor.Items.Add(colors.Key);
+ }
+ _comboBoxForeColor.EndUpdate();
+ _comboBoxBackColor.EndUpdate();
+
+ _numericTextBoxPenSize.TextChanged += new EventHandler(OnNumericTextBoxPenSizeTextChanged);
+ _comboBoxBackColor.SelectedIndexChanged += new EventHandler(OnComboBoxBackColorSelectedIndexChanged);
+ _comboBoxForeColor.SelectedIndexChanged += new EventHandler(OnComboBoxForeColorSelectedIndexChanged);
+ _numericTextBoxRoundedCornerHeight.TextChanged += new EventHandler(OnNumericTextBoxRoundedCornerHeight);
+ _numericTextBoxRoundedCornerWidth.TextChanged += new EventHandler(OnNumericTextBoxRoundedCornerWidth);
+
+ _comboBoxForeColor.SelectedIndex = 0;
+ _comboBoxBackColor.SelectedIndex = 0;
+
+ _numericTextBoxRoundedCornerWidth.SelectTextOnFocus = true;
+ _numericTextBoxRoundedCornerHeight.SelectTextOnFocus = true;
+ _numericTextBoxPenSize.SelectTextOnFocus = true;
+
+ }
+
+ void OnNumericTextBoxRoundedCornerWidth(object sender, EventArgs e)
+ {
+ _fill.RoundedCornerWidth = _numericTextBoxRoundedCornerWidth.TextAsInt;
+ this.Invalidate();
+ }
+
+ void OnNumericTextBoxRoundedCornerHeight(object sender, EventArgs e)
+ {
+ _fill.RoundedCornerHeight = _numericTextBoxRoundedCornerHeight.TextAsInt;
+ this.Invalidate();
+ }
+
+ void OnNumericTextBoxPenSizeTextChanged(object sender, EventArgs e)
+ {
+ _fill.PenWidth = _numericTextBoxPenSize.TextAsInt;
+ this.Invalidate();
+ }
+
+ void OnComboBoxForeColorSelectedIndexChanged(object sender, EventArgs e)
+ {
+ _fill.ForeColor = ColorUtils.GetStaticColorFromName(_comboBoxForeColor.SelectedItem.ToString());
+ this.Invalidate();
+ }
+
+ void OnComboBoxBackColorSelectedIndexChanged(object sender, EventArgs e)
+ {
+ _fill.Color = ColorUtils.GetStaticColorFromName(_comboBoxBackColor.SelectedItem.ToString());
+ this.Invalidate();
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ int y = -1;
+ foreach(Control c in this.Controls)
+ {
+ if (c.Bottom > y) { y = c.Bottom; }
+ }
+
+ int vSpace = 10;
+ y += vSpace;
+ int width = (int)(ClientSize.Width * .8f);
+ int x = (int)((ClientSize.Width - width) / 2f);
+ int height = ClientSize.Height - y - vSpace;
+
+ _fill.Draw(e.Graphics, new Rectangle(x, y, width, height));
+
+ base.OnPaint(e);
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>False</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -50,28 +50,43 @@
/// </summary>
private void InitializeComponent()
{
+ this.label1 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.menuItem17 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
+ this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
+ this.menuItem15 = new System.Windows.Forms.MenuItem();
this._menuBackFillImageMode = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItemBorderStyle = new System.Windows.Forms.MenuItem();
+ this.menuItemBorderBehavior = new System.Windows.Forms.MenuItem();
+ this._numericTextBoxBottom = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxTop = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxRight = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxLeft = new Roam.UI.Controls.NumericTextBox();
this.scrollableLabel1 = new Roam.UI.Controls.ScrollableLabel();
- this.menuItemBorderBehavior = new System.Windows.Forms.MenuItem();
- this.menuItem15 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label1.Location = new System.Drawing.Point(13, 224);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(39, 15);
+ this.label1.Text = "Insets:";
+ //
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItem1);
@@ -87,7 +102,9 @@
this.menuItem2.MenuItems.Add(this.menuItem3);
this.menuItem2.MenuItems.Add(this.menuItem5);
this.menuItem2.MenuItems.Add(this.menuItem4);
+ this.menuItem2.MenuItems.Add(this.menuItem17);
this.menuItem2.MenuItems.Add(this.menuItem6);
+ this.menuItem2.MenuItems.Add(this.menuItem16);
this.menuItem2.MenuItems.Add(this.menuItem7);
this.menuItem2.MenuItems.Add(this._menuBackFillImageMode);
this.menuItem2.MenuItems.Add(this.menuItemBorderStyle);
@@ -109,11 +126,21 @@
this.menuItem4.Text = "Clear";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
+ // menuItem17
+ //
+ this.menuItem17.Text = "Add Simple Line";
+ this.menuItem17.Click += new System.EventHandler(this.menuItem17_Click);
+ //
// menuItem6
//
- this.menuItem6.Text = "Add Line";
+ this.menuItem6.Text = "Add Long Line";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
+ // menuItem16
+ //
+ this.menuItem16.Text = "Add Random Text";
+ this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
+ //
// menuItem7
//
this.menuItem7.MenuItems.Add(this.menuItem8);
@@ -143,6 +170,11 @@
this.menuItem11.Text = "Random Rounded Rect";
this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
//
+ // menuItem15
+ //
+ this.menuItem15.Text = "Solid White Color";
+ this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
+ //
// _menuBackFillImageMode
//
this._menuBackFillImageMode.MenuItems.Add(this.menuItem14);
@@ -169,6 +201,46 @@
//
this.menuItemBorderStyle.Text = "Border Style";
//
+ // menuItemBorderBehavior
+ //
+ this.menuItemBorderBehavior.Text = "Border Behavior";
+ //
+ // _numericTextBoxBottom
+ //
+ this._numericTextBoxBottom.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxBottom.Location = new System.Drawing.Point(150, 224);
+ this._numericTextBoxBottom.Name = "_numericTextBoxBottom";
+ this._numericTextBoxBottom.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxBottom.TabIndex = 4;
+ this._numericTextBoxBottom.Text = "numericTextBox4";
+ //
+ // _numericTextBoxTop
+ //
+ this._numericTextBoxTop.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxTop.Location = new System.Drawing.Point(117, 224);
+ this._numericTextBoxTop.Name = "_numericTextBoxTop";
+ this._numericTextBoxTop.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxTop.TabIndex = 3;
+ this._numericTextBoxTop.Text = "numericTextBox3";
+ //
+ // _numericTextBoxRight
+ //
+ this._numericTextBoxRight.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxRight.Location = new System.Drawing.Point(84, 224);
+ this._numericTextBoxRight.Name = "_numericTextBoxRight";
+ this._numericTextBoxRight.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxRight.TabIndex = 2;
+ this._numericTextBoxRight.Text = "numericTextBox2";
+ //
+ // _numericTextBoxLeft
+ //
+ this._numericTextBoxLeft.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxLeft.Location = new System.Drawing.Point(51, 224);
+ this._numericTextBoxLeft.Name = "_numericTextBoxLeft";
+ this._numericTextBoxLeft.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxLeft.TabIndex = 1;
+ this._numericTextBoxLeft.Text = "numericTextBox1";
+ //
// scrollableLabel1
//
this.scrollableLabel1.Location = new System.Drawing.Point(13, 17);
@@ -176,24 +248,20 @@
this.scrollableLabel1.Name = "scrollableLabel1";
this.scrollableLabel1.ScrollLock = false;
this.scrollableLabel1.ShowScrollBar = true;
- this.scrollableLabel1.Size = new System.Drawing.Size(213, 231);
+ this.scrollableLabel1.Size = new System.Drawing.Size(213, 188);
this.scrollableLabel1.TabIndex = 0;
//
- // menuItemBorderBehavior
- //
- this.menuItemBorderBehavior.Text = "Border Behavior";
- //
- // menuItem15
- //
- this.menuItem15.Text = "Solid White Color";
- this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
- //
// ScrollableLabelTest2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._numericTextBoxBottom);
+ this.Controls.Add(this._numericTextBoxTop);
+ this.Controls.Add(this._numericTextBoxRight);
+ this.Controls.Add(this._numericTextBoxLeft);
+ this.Controls.Add(this.label1);
this.Controls.Add(this.scrollableLabel1);
this.Menu = this.mainMenu1;
this.Name = "ScrollableLabelTest2";
@@ -223,5 +291,12 @@
private System.Windows.Forms.MenuItem menuItemBorderStyle;
private System.Windows.Forms.MenuItem menuItemBorderBehavior;
private System.Windows.Forms.MenuItem menuItem15;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxLeft;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxRight;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxTop;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxBottom;
+ private System.Windows.Forms.MenuItem menuItem16;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.MenuItem menuItem17;
}
}
Modified: Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -64,8 +64,33 @@
mi.Click += new EventHandler(OnBorderBehaviorMenuItemClick);
menuItemBorderBehavior.MenuItems.Add(mi);
}
+
+ _numericTextBoxLeft.Text = scrollableLabel1.TextInsets.Left.ToString();
+ _numericTextBoxRight.Text = scrollableLabel1.TextInsets.Right.ToString();
+ _numericTextBoxTop.Text = scrollableLabel1.TextInsets.Top.ToString();
+ _numericTextBoxBottom.Text = scrollableLabel1.TextInsets.Bottom.ToString();
+
+ _numericTextBoxLeft.TextChanged += new EventHandler(OnInsetsTextChanged);
+ _numericTextBoxRight.TextChanged += new EventHandler(OnInsetsTextChanged);
+ _numericTextBoxTop.TextChanged += new EventHandler(OnInsetsTextChanged);
+ _numericTextBoxBottom.TextChanged += new EventHandler(OnInsetsTextChanged);
+
+ _numericTextBoxLeft.SelectTextOnFocus = true;
+ _numericTextBoxRight.SelectTextOnFocus = true;
+ _numericTextBoxTop.SelectTextOnFocus = true;
+ _numericTextBoxBottom.SelectTextOnFocus = true;
+
+ scrollableLabel1.Clear();
}
+ void OnInsetsTextChanged(object sender, EventArgs e)
+ {
+ scrollableLabel1.TextInsets = new Insets(_numericTextBoxLeft.TextAsInt,
+ _numericTextBoxRight.TextAsInt,
+ _numericTextBoxTop.TextAsInt,
+ _numericTextBoxBottom.TextAsInt);
+ }
+
private void OnBorderStyleMenuItemClick(object sender, EventArgs e)
{
MenuItem mi = (MenuItem)sender;
@@ -96,6 +121,7 @@
{
scrollableLabel1.Clear();
_lineCount = 0;
+ _simpleLineCnt = 0;
}
private void menuItem3_Click(object sender, EventArgs e)
@@ -120,18 +146,20 @@
private void menuItem6_Click(object sender, EventArgs e)
{
- Random rand = new Random();
- double r = rand.NextDouble();
- if (r < 0.5)
- {
- scrollableLabel1.AddLine(String.Format("This is line #{0} and\r\n this is also line #{0} but really on a new line", _lineCount++));
- }
- else
- {
- scrollableLabel1.AddLine(String.Format("ThisIsOneLongSentenceAllWithoutSpacesOrTabsToSeeIfMyNewMethodWorks.ItWillBeVeryInterestingI'mSure.ByTheWayWe'reOnLine#{0}", _lineCount++));
- }
+ scrollableLabel1.AddLine(String.Format("ThisIsOneLongSentenceAllWithoutSpacesOrTabsToSeeIfMyNewMethodWorks.ItWillBeVeryInterestingI'mSure.ByTheWayWe'reOnLine#{0}", _lineCount++));
}
+ private void menuItem16_Click(object sender, EventArgs e)
+ {
+ scrollableLabel1.AddLine(TestUtils.GetRandomGettysburgString());
+ }
+
+ private int _simpleLineCnt = 0;
+ private void menuItem17_Click(object sender, EventArgs e)
+ {
+ scrollableLabel1.AddLine("{0} This is a simple line of text", ++_simpleLineCnt);
+ }
+
//random image
private void menuItem8_Click(object sender, EventArgs e)
{
Modified: Trunk/Source/Roam.UI/Controls/NumericTextBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/NumericTextBox.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.UI/Controls/NumericTextBox.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -27,7 +27,7 @@
///
/// </remarks>
/// <author>Jon Froehlich</author>
- public class NumericTextBox : System.Windows.Forms.TextBox
+ public class NumericTextBox : TextBox
{
private bool _acceptDecimal = true;
Modified: Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -51,12 +51,12 @@
private SizeF _textBounds;
private VerticalAlignment _verticalAlignment = VerticalAlignment.Top;
private VScrollBar _vScrollBar;
- private int _textPadding = 1;
private int _borderThickness = 1;
private BorderStyle _borderStyle = BorderStyle.FixedSingle;
private BorderBehavior _borderBehavior = BorderBehavior.DrawBorderWhenFocused;
private Color _borderColor = Color.Black;
- private Fill _backFill = new FillSimpleLinearGradient(new SimpleLinearGradient(Color.FromArgb(206, 223, 239), Color.White, SimpleLinearGradient.FillDirection.TopToBottom));
+ private Fill _backFill = new FillSimpleLinearGradient(new SimpleLinearGradient(Color.FromArgb(206, 223, 239), Color.White, SimpleLinearGradient.FillDirection.TopToBottom));
+ private Insets _textInsets = new Insets(1, 1, 1, 1);
#endregion Private Fields
public ScrollableLabel()
@@ -77,6 +77,19 @@
#region Properties
+ public Insets TextInsets
+ {
+ get { return _textInsets; }
+ set
+ {
+ if (!_textInsets.Equals(value))
+ {
+ _textInsets = value;
+ UpdateLayout();
+ }
+ }
+ }
+
public Fill BackFill
{
get { return _backFill; }
@@ -221,28 +234,15 @@
get
{
int preferredHeight = (int)Math.Ceiling(_textBounds.Height);
- preferredHeight += 2 * _textPadding;
if (_borderStyle == BorderStyle.FixedSingle)
{
preferredHeight += 2 * _borderThickness;
}
+ preferredHeight += _textInsets.TotalVerticalInset;
return preferredHeight;
}
}
- public int TextPadding
- {
- get { return _textPadding; }
- set
- {
- if (value != _textPadding)
- {
- _textPadding = value;
- UpdateLayout();
- }
- }
- }
-
protected VScrollBar VScrollBar
{
get { return _vScrollBar; }
@@ -272,6 +272,21 @@
UpdateLayout();
}
+ public void AddLine(string str, object arg0)
+ {
+ AddLine(string.Format(str, arg0));
+ }
+
+ public void AddLine(string str, object arg0, object arg1)
+ {
+ AddLine(string.Format(str, arg0, arg1));
+ }
+
+ public void AddLine(string str, params object[] args)
+ {
+ AddLine(string.Format(str, args));
+ }
+
/// <summary>
///
/// </summary>
@@ -363,29 +378,45 @@
_vScrollBar.Size = new Size(_vScrollBar.Width, drawableArea.Height);
//get the text bounds
- _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font, drawableArea.Width - 2 * _textPadding);
+ _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font,
+ drawableArea.Width - _textInsets.TotalHorizontalInset);
+ float textHeightWithInsets = _textBounds.Height + _textInsets.TotalVerticalInset;
//set the scroll bar parameters based on text bounds
- if (_textBounds.Height > drawableArea.Height && _showScrollBar)
+ if (textHeightWithInsets > drawableArea.Height && _showScrollBar)
{
- //set the SmallChange and LargeChange values based on a percentage of the height
- //this will keep the scroll bar moving in proportion to its size
- _vScrollBar.LargeChange = (int)(_textBounds.Height / 10f);
- _vScrollBar.SmallChange = (int)(_textBounds.Height / 30f);
-
- _vScrollBar.Visible = true;
- _vScrollBar.Minimum = 0;
- _vScrollBar.Maximum = (int)(_textBounds.Height - drawableArea.Height + _vScrollBar.LargeChange - 1);
- if (!ScrollLock)
+ float lastHeight = -1;
+ do
{
- _vScrollBar.Value = _vScrollBar.Maximum;
- }
+ _vScrollBar.Visible = true;
- //now that the scroll bar is visible, we need to remeasure the string
- //with a smaller width
- //jeffixme : do we need to recalculate the scrollbar's min/max parameters then?
- _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font,
- drawableArea.Width - _vScrollBar.Width - 2 * _textPadding);
+ //set the SmallChange and LargeChange values based on a percentage of the height
+ //this will keep the scroll bar moving in proportion to its size
+ int largeChange = (int)(textHeightWithInsets / 10f);
+ int smallChange = (int)(textHeightWithInsets / 30f);
+
+ _vScrollBar.Minimum = 0;
+ _vScrollBar.Maximum = (int)(textHeightWithInsets - drawableArea.Height + largeChange - 1);
+
+ //LargeChange and SmallChange must be set after the Minimum/Maximum properties
+ //because largeChange could be greater than Maximum before the new Maximum
+ //is calculated
+ _vScrollBar.LargeChange = largeChange;
+ _vScrollBar.SmallChange = smallChange;
+
+ if (!ScrollLock)
+ {
+ _vScrollBar.Value = _vScrollBar.Maximum;
+ }
+
+ //now that the scroll bar is visible, we need to remeasure the string
+ //with a smaller width
+ //jeffixme : do we need to recalculate the scrollbar's min/max parameters then?
+ lastHeight = _textBounds.Height;
+ _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font,
+ drawableArea.Width - _vScrollBar.Width - _textInsets.TotalHorizontalInset);
+ textHeightWithInsets = _textBounds.Height + _textInsets.TotalVerticalInset;
+ } while (lastHeight != _textBounds.Height);
}
else
{
@@ -402,12 +433,17 @@
Rectangle drawableArea;
if (_borderStyle == BorderStyle.FixedSingle)
{
- drawableArea = new Rectangle(_borderThickness, _borderThickness,
- _bmpOffScreen.Width - 2 * _borderThickness, _bmpOffScreen.Height - 2 * _borderThickness);
+ drawableArea = new Rectangle(_borderThickness,
+ _borderThickness,
+ _bmpOffScreen.Width - (2 * _borderThickness),
+ _bmpOffScreen.Height - (2 * _borderThickness));
}
else
{
- drawableArea = new Rectangle(1, 1, _bmpOffScreen.Width - 2, _bmpOffScreen.Height - 2);
+ drawableArea = new Rectangle(0,
+ 0,
+ _bmpOffScreen.Width - 1,
+ _bmpOffScreen.Height - 1);
}
return drawableArea;
}
@@ -516,29 +552,31 @@
//g.Clip = new Region(new Rectangle(0, 0, (int)_bmpOffScreen.Width, (int)_bmpOffScreen.Height));
int vOffset = _vScrollBar.Visible ? (_vScrollBar.Maximum - _vScrollBar.Value - _vScrollBar.LargeChange) : 0;
- float xPos = drawableArea.Left, yPos = drawableArea.Top;
- if (_textBounds.Height > drawableArea.Height)
+ float xPos = drawableArea.Left + _textInsets.Left, yPos = drawableArea.Top + _textInsets.Top;
+ float textHeightWithInsets = _textBounds.Height + _textInsets.TotalVerticalInset;
+ if (textHeightWithInsets > drawableArea.Height)
{
- yPos = drawableArea.Height + vOffset - _textBounds.Height;
+ yPos = drawableArea.Height + vOffset - textHeightWithInsets + _textInsets.Top;
}
else
{
switch (_verticalAlignment)
{
case VerticalAlignment.Top:
- yPos = drawableArea.Top;
+ yPos = drawableArea.Top + _textInsets.Top;
break;
case VerticalAlignment.Bottom:
- yPos = drawableArea.Bottom - _textBounds.Height;
+ yPos = drawableArea.Bottom - _textBounds.Height - _textInsets.Bottom;
break;
case VerticalAlignment.Center:
- yPos = _bmpOffScreen.Height / 2f - _textBounds.Height / 2f;
+ yPos = _bmpOffScreen.Height / 2f - (textHeightWithInsets) / 2f;
break;
}
}
- float width = _vScrollBar.Visible ? drawableArea.Width - _vScrollBar.Width : drawableArea.Width;
- RectangleF drawStringArea = new RectangleF(xPos + _textPadding, yPos, width - 2 * _textPadding, _textBounds.Height);
+ float width = (_vScrollBar.Visible ?
+ drawableArea.Width - _vScrollBar.Width : drawableArea.Width) - _textInsets.TotalHorizontalInset;
+ RectangleF drawStringArea = new RectangleF(xPos, yPos, width, _textBounds.Height);
g.DrawString(str, this.Font, frontBrush, drawStringArea);
//debug - draw an outline in red
Modified: Trunk/Source/Roam.UI/Controls/TextBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/TextBox.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.UI/Controls/TextBox.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -12,11 +12,10 @@
// this source code distribution.
//
#endregion Copyright & License
+
using System;
using System.Collections.Generic;
using System.Text;
-using System.Drawing;
-using System.Diagnostics;
namespace Roam.UI.Controls
{
@@ -29,171 +28,22 @@
/// <author>Jon Froehlich</author>
public class TextBox : System.Windows.Forms.TextBox
{
- private Color _borderColor = Color.Black;
- private Color _selBorderColor = SystemColors.HighlightText;
- private Color _selBackColor = SystemColors.Highlight;
- private Color _selForeColor = SystemColors.HighlightText;
- private Color _disabledBackColor = Color.Gray;
- private Color _disabledForeColor = Color.DarkGray;
- private Color _disabledBorderColor = Color.DarkGray;
+ private bool _selectTextOnFocus = false;
- public TextBox()
- : base()
+ protected override void OnGotFocus(EventArgs e)
{
- this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- }
-
- #region Properties
- public Color BorderColor
- {
- get { return _borderColor; }
- set
+ if (_selectTextOnFocus)
{
- if (_borderColor != value)
- {
- _borderColor = value;
- if (!Focused && Enabled)
- {
- this.Invalidate();
- }
- }
+ this.SelectionStart = 0;
+ this.SelectionLength = this.Text.Length;
}
+ base.OnGotFocus(e);
}
- public Color SelectedBorderColor
+ public bool SelectTextOnFocus
{
- get { return _selBorderColor; }
- set
- {
- if (_selBorderColor != value)
- {
- _selBorderColor = value;
- if (Focused)
- {
- this.Invalidate();
- }
- }
- }
+ get { return _selectTextOnFocus; }
+ set { _selectTextOnFocus = value; }
}
-
- public Color SelectedBackColor
- {
- get { return _selBackColor; }
- set
- {
- if (_selBackColor != value)
- {
- _selBackColor = value;
- if (Focused)
- {
- this.Invalidate();
- }
- }
- }
- }
-
- public Color SelectedForeColor
- {
- get { return _selForeColor; }
- set
- {
- if (_selForeColor != value)
- {
- ...
[truncated message content] |
|
From: <jon...@us...> - 2007-03-08 07:01:12
|
Revision: 64
http://roam.svn.sourceforge.net/roam/?rev=64&view=rev
Author: jonfroehlich
Date: 2007-03-07 23:01:11 -0800 (Wed, 07 Mar 2007)
Log Message:
-----------
added StringUtils.Remove to remove instances of a substring instead a string
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/StringUtils.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Common/Utils/StringUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/StringUtils.cs 2007-03-06 11:57:11 UTC (rev 63)
+++ Trunk/Source/Roam.Common/Utils/StringUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
@@ -45,6 +45,22 @@
return str.Trim(new char[] { '\0' });
}
+ public static string Remove(string str, string remove)
+ {
+ int startIndex = str.IndexOf(remove);
+ if (startIndex == -1) { return str; }
+
+ StringBuilder sb = new StringBuilder();
+ while (startIndex != -1)
+ {
+ sb.Append(str.Substring(0, startIndex));
+ str = str.Substring(startIndex + remove.Length, str.Length - (startIndex + remove.Length));
+ startIndex = str.IndexOf(remove);
+ }
+ sb.Append(str);
+ return sb.ToString();
+ }
+
public static string [] ParseWords(string s)
{
char[] whitespace = new char[] { ' ', '\t', '\r', '\n' };
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|