[Roam-commit] SF.net SVN: roam: [77] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
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] |