[Roam-commit] SF.net SVN: roam: [63] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-03-06 11:57:15
|
Revision: 63
http://roam.svn.sourceforge.net/roam/?rev=63&view=rev
Author: jonfroehlich
Date: 2007-03-06 03:57:11 -0800 (Tue, 06 Mar 2007)
Log Message:
-----------
1. Refactored the Fill.cs file into multiple Fill classes
2. Updated FillRoundedRectangle to have exposed properties and to use a pen/brush
3. Worked on ScrollableLabelTest2 to test borders and FillSimpleLinearGradient
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/StringUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs
Trunk/Source/Roam.UI/Drawing/Fill.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.UI/Drawing/FillImage.cs
Trunk/Source/Roam.UI/Drawing/FillNone.cs
Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
Trunk/Source/Roam.UI/Drawing/FillSimpleLinearGradient.cs
Trunk/Source/Roam.UI/Drawing/FillSolid.cs
Modified: Trunk/Source/Roam.Common/Utils/StringUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/StringUtils.cs 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.Common/Utils/StringUtils.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -60,5 +60,37 @@
}
return list.ToArray();
}
+
+ public static bool ContainsMultiple(string s, char ch)
+ {
+ int index = s.IndexOf(ch);
+ if (index == -1) return false;
+
+ int nextIndex = s.IndexOf(ch, index);
+ if (nextIndex == -1) return false;
+
+ return true;
+ }
+
+ public static bool Contains(string s, char ch)
+ {
+ return s.IndexOf(ch) != -1;
+ }
+
+ public static bool ContainsMultiple(string s, string value)
+ {
+ int index = s.IndexOf(value);
+ if (index == -1) return false;
+
+ int nextIndex = s.IndexOf(value, index);
+ if (nextIndex == -1) return false;
+
+ return true;
+ }
+
+ public static bool Contains(string s, string value)
+ {
+ return s.IndexOf(value) != -1;
+ }
}
}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-06 11:57:11 UTC (rev 63)
@@ -438,7 +438,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/UI/Controls/ScrollableLabelTest2.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -61,11 +61,15 @@
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
- this.scrollableLabel1 = new Roam.UI.Controls.ScrollableLabel();
+ this.menuItem11 = 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.menuItem14 = new System.Windows.Forms.MenuItem();
+ this.menuItemBorderStyle = new System.Windows.Forms.MenuItem();
+ this.scrollableLabel1 = new Roam.UI.Controls.ScrollableLabel();
+ this.menuItemBorderBehavior = new System.Windows.Forms.MenuItem();
+ this.menuItem15 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// mainMenu1
@@ -86,6 +90,8 @@
this.menuItem2.MenuItems.Add(this.menuItem6);
this.menuItem2.MenuItems.Add(this.menuItem7);
this.menuItem2.MenuItems.Add(this._menuBackFillImageMode);
+ this.menuItem2.MenuItems.Add(this.menuItemBorderStyle);
+ this.menuItem2.MenuItems.Add(this.menuItemBorderBehavior);
this.menuItem2.Text = "Menu";
//
// menuItem3
@@ -113,6 +119,8 @@
this.menuItem7.MenuItems.Add(this.menuItem8);
this.menuItem7.MenuItems.Add(this.menuItem9);
this.menuItem7.MenuItems.Add(this.menuItem10);
+ this.menuItem7.MenuItems.Add(this.menuItem11);
+ this.menuItem7.MenuItems.Add(this.menuItem15);
this.menuItem7.Text = "BackFill";
//
// menuItem8
@@ -122,7 +130,7 @@
//
// menuItem9
//
- this.menuItem9.Text = "Random Color";
+ this.menuItem9.Text = "Random Solid Color";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem10
@@ -130,15 +138,10 @@
this.menuItem10.Text = "Random Gradient";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
- // scrollableLabel1
+ // menuItem11
//
- this.scrollableLabel1.Location = new System.Drawing.Point(13, 17);
- this.scrollableLabel1.MaxLines = 100;
- this.scrollableLabel1.Name = "scrollableLabel1";
- this.scrollableLabel1.ScrollLock = false;
- this.scrollableLabel1.ShowScrollBar = true;
- this.scrollableLabel1.Size = new System.Drawing.Size(213, 231);
- this.scrollableLabel1.TabIndex = 0;
+ this.menuItem11.Text = "Random Rounded Rect";
+ this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
//
// _menuBackFillImageMode
//
@@ -147,6 +150,11 @@
this._menuBackFillImageMode.MenuItems.Add(this.menuItem13);
this._menuBackFillImageMode.Text = "BackFill Image Mode";
//
+ // menuItem14
+ //
+ this.menuItem14.Text = "Center";
+ this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
+ //
// menuItem12
//
this.menuItem12.Text = "Normal";
@@ -157,11 +165,29 @@
this.menuItem13.Text = "Stretch";
this.menuItem13.Click += new System.EventHandler(this.menuItem13_Click);
//
- // menuItem14
+ // menuItemBorderStyle
//
- this.menuItem14.Text = "Center";
- this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
+ this.menuItemBorderStyle.Text = "Border Style";
//
+ // scrollableLabel1
+ //
+ this.scrollableLabel1.Location = new System.Drawing.Point(13, 17);
+ this.scrollableLabel1.MaxLines = 100;
+ this.scrollableLabel1.Name = "scrollableLabel1";
+ this.scrollableLabel1.ScrollLock = false;
+ this.scrollableLabel1.ShowScrollBar = true;
+ this.scrollableLabel1.Size = new System.Drawing.Size(213, 231);
+ 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);
@@ -193,5 +219,9 @@
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
+ private System.Windows.Forms.MenuItem menuItem11;
+ private System.Windows.Forms.MenuItem menuItemBorderStyle;
+ private System.Windows.Forms.MenuItem menuItemBorderBehavior;
+ private System.Windows.Forms.MenuItem menuItem15;
}
}
Modified: Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -23,6 +23,7 @@
using Roam.UI.Drawing;
using Roam.Test.Utils;
using Roam.Common.Utils;
+using Roam.UI.Controls;
namespace MyExperience.Test
{
@@ -47,8 +48,36 @@
_timer.Tick += new EventHandler(OnTimerTick);
_timer.Enabled = false;
menuItem3.Text = _timer.Enabled ? "Stop" : "Start";
+
+ foreach(string name in EnumUtils.GetNames(typeof(BorderStyle)))
+ {
+ MenuItem mi = new MenuItem();
+ mi.Text = name;
+ mi.Click += new EventHandler(OnBorderStyleMenuItemClick);
+ menuItemBorderStyle.MenuItems.Add(mi);
+ }
+
+ foreach (string name in EnumUtils.GetNames(typeof(BorderBehavior)))
+ {
+ MenuItem mi = new MenuItem();
+ mi.Text = name;
+ mi.Click += new EventHandler(OnBorderBehaviorMenuItemClick);
+ menuItemBorderBehavior.MenuItems.Add(mi);
+ }
}
+ private void OnBorderStyleMenuItemClick(object sender, EventArgs e)
+ {
+ MenuItem mi = (MenuItem)sender;
+ scrollableLabel1.BorderStyle = (BorderStyle)Enum.Parse(typeof(BorderStyle), mi.Text, true);
+ }
+
+ private void OnBorderBehaviorMenuItemClick(object sender, EventArgs e)
+ {
+ MenuItem mi = (MenuItem)sender;
+ scrollableLabel1.BorderBehavior = (BorderBehavior)Enum.Parse(typeof(BorderBehavior), mi.Text, true);
+ }
+
private void OnTimerTick(object sender, EventArgs e)
{
Debug.WriteLine(String.Format("Timer tick in {0} milliseconds", ((TimeSpan)(DateTime.Now - _timeStamp)).TotalMilliseconds));
@@ -125,6 +154,12 @@
scrollableLabel1.BackFill = new FillSolid(ColorUtils.GetRandomColor());
}
+ //solid white color
+ private void menuItem15_Click(object sender, EventArgs e)
+ {
+ scrollableLabel1.BackFill = new FillSolid(Color.White);
+ }
+
//random gradient
private void menuItem10_Click(object sender, EventArgs e)
{
@@ -134,6 +169,16 @@
new SimpleLinearGradient(ColorUtils.GetRandomColor(), ColorUtils.GetRandomColor(), fillDirect));
}
+ //random fill rounded rect
+ private void menuItem11_Click(object sender, EventArgs e)
+ {
+ Random random = new Random();
+ int corner = random.Next(5, (int)(this.Width / 2f));
+ scrollableLabel1.BackFill = new FillRoundedRectangle(
+ ColorUtils.GetRandomColor(), ColorUtils.GetRandomColor(), corner, corner);
+
+ }
+
//normal
private void menuItem12_Click(object sender, EventArgs e)
{
Modified: Trunk/Source/Roam.UI/Drawing/Fill.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/Fill.cs 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.UI/Drawing/Fill.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -102,229 +102,4 @@
}
protected abstract void DrawInternal(Graphics g, Rectangle rect);
}
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public class FillNone : Fill
- {
- public static FillNone Empty = new FillNone();
-
- public FillNone() : base(0) {}
- public override float AlphaBlend
- {
- get { return base.AlphaBlend; }
- set { throw new InvalidOperationException("AlphaBlend cannot be set in FillNone"); }
- }
-
- public override void Draw(Graphics g, Rectangle rect)
- {
- //do nothing
- }
-
- protected override void DrawInternal(Graphics g, Rectangle rect)
- {
- //do nothing
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public class FillRoundedRectangle : Fill
- {
- private Color _foreColor = Color.Black;
- private int _roundedCornerWidth = 5;
- private int _roundedCornerHeight = 5;
-
- public FillRoundedRectangle(Color backColor) : this(backColor, Color.Black, 0) { }
- public FillRoundedRectangle(Color backColor, Color foreColor) : this(backColor, foreColor, 0) { }
- public FillRoundedRectangle(Color backColor, Color foreColor, float alphaBlend)
- : this(backColor, foreColor, 5, 5, alphaBlend)
- {
- }
-
- public FillRoundedRectangle(Color backColor, Color foreColor, int roundedCornerWidth, int roundedCornerHeight, float alphaBlend)
- : base(alphaBlend, backColor)
- {
- _foreColor = foreColor;
- _roundedCornerWidth = roundedCornerWidth;
- _roundedCornerHeight = roundedCornerHeight;
- }
-
- protected override void DrawInternal(Graphics g, Rectangle rect)
- {
- Pen pen = new Pen(_foreColor);
- SolidBrush solidBrush = new SolidBrush(Color);
- DrawingUtils.RoundRect(g, rect.X, rect.Y, rect.Right, rect.Bottom,
- _roundedCornerWidth, _roundedCornerHeight);
- pen.Dispose();
- solidBrush.Dispose();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public class FillSolid : Fill
- {
- public FillSolid(Color color) : this(color, 0) { }
- public FillSolid(Color color, float alphaBlend) : base(alphaBlend, color) { }
-
- protected override void DrawInternal(Graphics g, Rectangle rect)
- {
- SolidBrush solidBrush = new SolidBrush(Color);
- g.FillRectangle(solidBrush, rect);
- solidBrush.Dispose();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public class FillSimpleLinearGradient : Fill
- {
- private SimpleLinearGradient _gradient;
- public FillSimpleLinearGradient(SimpleLinearGradient gradient) : this(gradient, 0) { }
- public FillSimpleLinearGradient(SimpleLinearGradient gradient, float alphaBlend)
- : base(alphaBlend)
- {
- _gradient = gradient;
- }
-
- public SimpleLinearGradient Gradient { get { return _gradient; } set { _gradient = value; } }
-
- protected override void DrawInternal(Graphics g, Rectangle rect)
- {
- _gradient.Fill(g, rect);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public class FillImage : Fill
- {
- private Image _image;
- private bool _useTransparencyKey = false;
- private Color _tranparencyKey;
- private FillImageSizeMode _fillSizeMode = FillImageSizeMode.Normal;
-
- public FillImage(Image image) : this(image, 0) { }
- public FillImage(Image image, Color transparencyKey) : this(image, transparencyKey, FillImageSizeMode.Normal, 0) { }
- public FillImage(Image image, Color transparencyKey, FillImageSizeMode fillImageSizeMode, float alphaBlend)
- : base(alphaBlend)
- {
- _image = image;
- _useTransparencyKey = true;
- _tranparencyKey = transparencyKey;
- _fillSizeMode = fillImageSizeMode;
- }
-
- public FillImage(Image image, float alphaBlend)
- : base(alphaBlend)
- {
- _image = image;
- }
-
- public Image Image { get { return _image; } set { _image = value; } }
- public FillImageSizeMode SizeMode { get { return _fillSizeMode; } set { _fillSizeMode = value; } }
- public Color TransparencyKey { get { return _tranparencyKey; } set { _tranparencyKey = value; } }
- public bool UseTransparencyKey { get { return _useTransparencyKey; } set { _useTransparencyKey = value; } }
-
- public override void Dispose()
- {
- if (_image != null)
- {
- _image.Dispose();
- _image = null;
- }
- base.Dispose();
- }
-
- protected override void DrawInternal(Graphics g, Rectangle rect)
- {
- ImageAttributes attr = new ImageAttributes();
- if (_useTransparencyKey) { attr.SetColorKey(_tranparencyKey, _tranparencyKey); }
- else
- {
- SolidBrush solidBrush = new SolidBrush(this.Color);
- g.FillRectangle(solidBrush, rect);
- solidBrush.Dispose();
- }
-
- if (_fillSizeMode == FillImageSizeMode.StretchImage)
- {
- g.DrawImage(_image, rect, 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel, attr);
- }
- else if (_fillSizeMode == FillImageSizeMode.CenterImage)
- {
- int x = (int)(rect.X + rect.Width / 2f - _image.Width / 2f);
- int y = (int)(rect.Y + rect.Height / 2f - _image.Height / 2f);
- g.Clip = new Region(rect);
- g.DrawImage(_image, new Rectangle(x, y, _image.Width, _image.Height),
- 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel, attr);
- g.Clip.MakeInfinite();
- }
- else if (_fillSizeMode == FillImageSizeMode.Normal)
- {
- g.Clip = new Region(rect);
- g.DrawImage(_image, new Rectangle(rect.X, rect.Y, _image.Width, _image.Height),
- 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel, attr);
- g.Clip.MakeInfinite();
- }
- }
- }
-
- /// <summary>
- /// Specifies how an image is positioned within a FillImage
- /// </summary>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public enum FillImageSizeMode
- {
- /// <summary>
- /// The image is placed in the upper-left corner of the Fill rectangle.
- /// The image is clipped if it is larger than the provided area
- /// it is contained in.
- /// </summary>
- Normal,
-
- /// <summary>
- /// The image within the Fill is stretched or shrunk to fit the size of the provided rectangle
- /// </summary>
- StretchImage,
-
- /// <summary>
- /// The image is displayed in the center if the given area is larger than the image. If the
- /// image is larger than the area, the picture is placed in the center of the area
- /// and the outside edges are clipped.
- /// </summary>
- CenterImage
- }
}
Added: Trunk/Source/Roam.UI/Drawing/FillImage.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillImage.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/FillImage.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -0,0 +1,137 @@
+#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.Drawing.Imaging;
+
+namespace Roam.UI.Drawing
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class FillImage : Fill
+ {
+ #region Fields
+ private Image _image;
+ private bool _useTransparencyKey = false;
+ private Color _tranparencyKey;
+ private FillImageSizeMode _fillSizeMode = FillImageSizeMode.Normal;
+ #endregion Fields
+
+ #region Constructors
+ public FillImage(Image image) : this(image, 0) { }
+ public FillImage(Image image, Color transparencyKey) : this(image, transparencyKey, FillImageSizeMode.Normal, 0) { }
+ public FillImage(Image image, Color transparencyKey, FillImageSizeMode fillImageSizeMode, float alphaBlend)
+ : base(alphaBlend)
+ {
+ _image = image;
+ _useTransparencyKey = true;
+ _tranparencyKey = transparencyKey;
+ _fillSizeMode = fillImageSizeMode;
+ }
+
+ public FillImage(Image image, float alphaBlend)
+ : base(alphaBlend)
+ {
+ _image = image;
+ }
+ #endregion Constructors
+
+ #region Properties
+ public Image Image { get { return _image; } set { _image = value; } }
+ public FillImageSizeMode SizeMode { get { return _fillSizeMode; } set { _fillSizeMode = value; } }
+ public Color TransparencyKey { get { return _tranparencyKey; } set { _tranparencyKey = value; } }
+ public bool UseTransparencyKey { get { return _useTransparencyKey; } set { _useTransparencyKey = value; } }
+ #endregion Properties
+
+ public override void Dispose()
+ {
+ if (_image != null)
+ {
+ _image.Dispose();
+ _image = null;
+ }
+ base.Dispose();
+ }
+
+ protected override void DrawInternal(Graphics g, Rectangle rect)
+ {
+ ImageAttributes attr = new ImageAttributes();
+ if (_useTransparencyKey) { attr.SetColorKey(_tranparencyKey, _tranparencyKey); }
+ else
+ {
+ SolidBrush solidBrush = new SolidBrush(this.Color);
+ g.FillRectangle(solidBrush, rect);
+ solidBrush.Dispose();
+ }
+
+ if (_fillSizeMode == FillImageSizeMode.StretchImage)
+ {
+ g.DrawImage(_image, rect, 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel, attr);
+ }
+ else if (_fillSizeMode == FillImageSizeMode.CenterImage)
+ {
+ int x = (int)(rect.X + rect.Width / 2f - _image.Width / 2f);
+ int y = (int)(rect.Y + rect.Height / 2f - _image.Height / 2f);
+ g.Clip = new Region(rect);
+ g.DrawImage(_image, new Rectangle(x, y, _image.Width, _image.Height),
+ 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel, attr);
+ g.Clip.MakeInfinite();
+ }
+ else if (_fillSizeMode == FillImageSizeMode.Normal)
+ {
+ g.Clip = new Region(rect);
+ g.DrawImage(_image, new Rectangle(rect.X, rect.Y, _image.Width, _image.Height),
+ 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel, attr);
+ g.Clip.MakeInfinite();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Specifies how an image is positioned within a FillImage
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public enum FillImageSizeMode
+ {
+ /// <summary>
+ /// The image is placed in the upper-left corner of the Fill rectangle.
+ /// The image is clipped if it is larger than the provided area
+ /// it is contained in.
+ /// </summary>
+ Normal,
+
+ /// <summary>
+ /// The image within the Fill is stretched or shrunk to fit the size of the provided rectangle
+ /// </summary>
+ StretchImage,
+
+ /// <summary>
+ /// The image is displayed in the center if the given area is larger than the image. If the
+ /// image is larger than the area, the picture is placed in the center of the area
+ /// and the outside edges are clipped.
+ /// </summary>
+ CenterImage
+ }
+}
Added: Trunk/Source/Roam.UI/Drawing/FillNone.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillNone.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/FillNone.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -0,0 +1,51 @@
+#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 FillNone : Fill
+ {
+ public static FillNone Empty = new FillNone();
+
+ public FillNone() : base(0) { }
+
+ public override float AlphaBlend
+ {
+ get { return base.AlphaBlend; }
+ set { throw new InvalidOperationException("AlphaBlend cannot be set in FillNone"); }
+ }
+
+ public override void Draw(Graphics g, Rectangle rect)
+ {
+ //do nothing
+ }
+
+ protected override void DrawInternal(Graphics g, Rectangle rect)
+ {
+ //do nothing
+ }
+ }
+}
Added: Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -0,0 +1,107 @@
+#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 class FillRoundedRectangle : Fill
+ {
+ #region Fields
+ private Color _foreColor = Color.Black;
+ private int _roundedCornerWidth = 5;
+ private int _roundedCornerHeight = 5;
+ private int _penWidth = 2;
+ 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, 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)
+ : base(alphaBlend, backColor)
+ {
+ _foreColor = foreColor;
+ _roundedCornerWidth = roundedCornerWidth;
+ _roundedCornerHeight = roundedCornerHeight;
+ }
+ #endregion Constructors
+
+ #region Properties
+ public float PenWidth
+ {
+ get { return _penWidth; }
+ set { _penWidth = value; }
+ }
+
+ public int RoundedCornerWidth
+ {
+ get { return _roundedCornerWidth; }
+ set { _roundedCornerWidth = value; }
+ }
+
+ public int RoundedCornerHeight
+ {
+ get { return _roundedCornerHeight; }
+ set { _roundedCornerHeight = value; }
+ }
+
+ public bool DrawSolidBackColor
+ {
+ get { return _drawSolidBack; }
+ set { _drawSolidBack = value; }
+ }
+
+ public Color SolidBackColor
+ {
+ get { return _solidBackColor; }
+ set { _solidBackColor = value; }
+ }
+ #endregion Properties
+
+ protected override void DrawInternal(Graphics g, Rectangle rect)
+ {
+ if (_drawSolidBack)
+ {
+ SolidBrush backBrush = new SolidBrush(_solidBackColor);
+ g.FillRectangle(backBrush, rect);
+ backBrush.Dispose();
+ }
+
+ SolidBrush solidBrush = new SolidBrush(Color);
+ Pen pen = new Pen(_foreColor);
+ pen.Width = _penWidth;
+ DrawingUtils.RoundRect(g, pen, solidBrush, rect.X, rect.Y, rect.Right, rect.Bottom,
+ _roundedCornerWidth, _roundedCornerHeight);
+ pen.Dispose();
+ solidBrush.Dispose();
+ }
+ }
+}
Added: Trunk/Source/Roam.UI/Drawing/FillSimpleLinearGradient.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillSimpleLinearGradient.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/FillSimpleLinearGradient.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -0,0 +1,46 @@
+#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 FillSimpleLinearGradient : Fill
+ {
+ private SimpleLinearGradient _gradient;
+ public FillSimpleLinearGradient(SimpleLinearGradient gradient) : this(gradient, 0) { }
+ public FillSimpleLinearGradient(SimpleLinearGradient gradient, float alphaBlend)
+ : base(alphaBlend)
+ {
+ _gradient = gradient;
+ }
+
+ public SimpleLinearGradient Gradient { get { return _gradient; } set { _gradient = value; } }
+
+ protected override void DrawInternal(Graphics g, Rectangle rect)
+ {
+ _gradient.Fill(g, rect);
+ }
+ }
+}
Added: Trunk/Source/Roam.UI/Drawing/FillSolid.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/FillSolid.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/FillSolid.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -0,0 +1,41 @@
+#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 FillSolid : Fill
+ {
+ public FillSolid(Color color) : this(color, 0) { }
+ public FillSolid(Color color, float alphaBlend) : base(alphaBlend, color) { }
+
+ protected override void DrawInternal(Graphics g, Rectangle rect)
+ {
+ SolidBrush solidBrush = new SolidBrush(Color);
+ g.FillRectangle(solidBrush, rect);
+ solidBrush.Dispose();
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-03-06 11:57:11 UTC (rev 63)
@@ -175,6 +175,11 @@
</Compile>
<Compile Include="Drawing\AngleGradient.cs" />
<Compile Include="Drawing\BitmapFactory.cs" />
+ <Compile Include="Drawing\FillImage.cs" />
+ <Compile Include="Drawing\FillNone.cs" />
+ <Compile Include="Drawing\FillRoundedRectangle.cs" />
+ <Compile Include="Drawing\FillSimpleLinearGradient.cs" />
+ <Compile Include="Drawing\FillSolid.cs" />
<Compile Include="Drawing\OrthogonalGradient.cs" />
<Compile Include="Drawing\Fill.cs" />
<Compile Include="Drawing\BitmapItem.cs" />
Modified: Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-03-05 09:02:39 UTC (rev 62)
+++ Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-03-06 11:57:11 UTC (rev 63)
@@ -192,6 +192,18 @@
return ret;
}
+ public static bool RoundRect(Graphics g, SolidBrush brush, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidth, int nHeight)
+ {
+ IntPtr hdc = g.GetHdc();
+ IntPtr hNewBrush = CreateSolidBrush(ColorUtils.ToRgb(brush.Color));
+ IntPtr hOldBrush = SelectObject(hdc, hNewBrush);
+ bool ret = RoundRect(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect, nWidth, nHeight);
+ SelectObject(hdc, hOldBrush);
+ DeleteObject(hNewBrush);
+ g.ReleaseHdc(hdc);
+ return ret;
+ }
+
public static bool RoundRect(Graphics g, Pen pen, SolidBrush brush, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidth, int nHeight)
{
IntPtr hdc = g.GetHdc();
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.
|