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