[Roam-commit] SF.net SVN: roam: [76] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-04-15 23:11:11
|
Revision: 76
http://roam.svn.sourceforge.net/roam/?rev=76&view=rev
Author: jonfroehlich
Date: 2007-04-15 16:11:08 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
added StarItem... will use this to build StarRater control like I had in the Itasca project at Intel Research
Modified Paths:
--------------
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx
Trunk/Source/Roam.UI/Drawing/StarItem.cs
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-12 22:41:01 UTC (rev 75)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-15 23:11:08 UTC (rev 76)
@@ -164,6 +164,10 @@
<SubType>Designer</SubType>
<DependentUpon>PhoneCallTalkingTest.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Sandbox\StarItemTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>StarItemTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Sandbox\TopMostFormTest.resx">
<SubType>Designer</SubType>
<DependentUpon>TopMostFormTest.cs</DependentUpon>
@@ -391,6 +395,12 @@
<Compile Include="Sandbox\PhoneCallTalkingTest.Designer.cs">
<DependentUpon>PhoneCallTalkingTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\StarItemTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Sandbox\StarItemTest.Designer.cs">
+ <DependentUpon>StarItemTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Sandbox\TextBoxBackgroundTest.cs">
<SubType>Component</SubType>
</Compile>
Added: Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.Designer.cs 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,198 @@
+namespace Roam.Test.Sandbox
+{
+ partial class StarItemTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this._numericTextBoxNumStarPoints = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxSizeHeight = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxSizeWidth = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxPointiness2 = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxPointiness1 = new Roam.UI.Controls.NumericTextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // label5
+ //
+ this.label5.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label5.Location = new System.Drawing.Point(3, 7);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(91, 18);
+ this.label5.Text = "Num Star Points:";
+ //
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label1.Location = new System.Drawing.Point(3, 28);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(67, 18);
+ this.label1.Text = "Pointiness:";
+ //
+ // label2
+ //
+ this.label2.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label2.Location = new System.Drawing.Point(3, 50);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(41, 18);
+ this.label2.Text = "Size:";
+ //
+ // _numericTextBoxNumStarPoints
+ //
+ this._numericTextBoxNumStarPoints.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxNumStarPoints.Location = new System.Drawing.Point(93, 7);
+ this._numericTextBoxNumStarPoints.Name = "_numericTextBoxNumStarPoints";
+ this._numericTextBoxNumStarPoints.SelectTextOnFocus = true;
+ this._numericTextBoxNumStarPoints.Size = new System.Drawing.Size(133, 18);
+ this._numericTextBoxNumStarPoints.TabIndex = 0;
+ this._numericTextBoxNumStarPoints.Text = "5";
+ this._numericTextBoxNumStarPoints.TextChanged += new System.EventHandler(this.OnNumStarPointsTextChanged);
+ //
+ // _numericTextBoxSizeHeight
+ //
+ this._numericTextBoxSizeHeight.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxSizeHeight.Location = new System.Drawing.Point(163, 50);
+ this._numericTextBoxSizeHeight.Name = "_numericTextBoxSizeHeight";
+ this._numericTextBoxSizeHeight.SelectTextOnFocus = true;
+ this._numericTextBoxSizeHeight.Size = new System.Drawing.Size(63, 18);
+ this._numericTextBoxSizeHeight.TabIndex = 4;
+ this._numericTextBoxSizeHeight.Text = "100";
+ this._numericTextBoxSizeHeight.TextChanged += new System.EventHandler(this.OnSizeHeightTextChanged);
+ //
+ // _numericTextBoxSizeWidth
+ //
+ this._numericTextBoxSizeWidth.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxSizeWidth.Location = new System.Drawing.Point(93, 50);
+ this._numericTextBoxSizeWidth.Name = "_numericTextBoxSizeWidth";
+ this._numericTextBoxSizeWidth.SelectTextOnFocus = true;
+ this._numericTextBoxSizeWidth.Size = new System.Drawing.Size(64, 18);
+ this._numericTextBoxSizeWidth.TabIndex = 3;
+ this._numericTextBoxSizeWidth.Text = "100";
+ this._numericTextBoxSizeWidth.TextChanged += new System.EventHandler(this.OnSizeWidthTextChanged);
+ //
+ // _numericTextBoxPointiness2
+ //
+ this._numericTextBoxPointiness2.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxPointiness2.Location = new System.Drawing.Point(140, 28);
+ this._numericTextBoxPointiness2.Name = "_numericTextBoxPointiness2";
+ this._numericTextBoxPointiness2.SelectTextOnFocus = true;
+ this._numericTextBoxPointiness2.Size = new System.Drawing.Size(86, 18);
+ this._numericTextBoxPointiness2.TabIndex = 2;
+ this._numericTextBoxPointiness2.Text = "5";
+ this._numericTextBoxPointiness2.TextChanged += new System.EventHandler(this.OnPointiness2TextChanged);
+ //
+ // _numericTextBoxPointiness1
+ //
+ this._numericTextBoxPointiness1.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxPointiness1.Location = new System.Drawing.Point(93, 28);
+ this._numericTextBoxPointiness1.Name = "_numericTextBoxPointiness1";
+ this._numericTextBoxPointiness1.SelectTextOnFocus = true;
+ this._numericTextBoxPointiness1.Size = new System.Drawing.Size(36, 18);
+ this._numericTextBoxPointiness1.TabIndex = 1;
+ this._numericTextBoxPointiness1.Text = "2";
+ this._numericTextBoxPointiness1.TextChanged += new System.EventHandler(this.OnPointiness1TextChanged);
+ //
+ // label3
+ //
+ this.label3.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label3.Location = new System.Drawing.Point(130, 31);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(12, 18);
+ this.label3.Text = ".";
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.Text = "Menu";
+ //
+ // menuItem3
+ //
+ this.menuItem3.MenuItems.Add(this.menuItem4);
+ this.menuItem3.Text = "Set";
+ //
+ // menuItem4
+ //
+ this.menuItem4.Text = "Label";
+ this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
+ //
+ // StarItemTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this._numericTextBoxPointiness2);
+ this.Controls.Add(this._numericTextBoxPointiness1);
+ this.Controls.Add(this._numericTextBoxNumStarPoints);
+ this.Controls.Add(this._numericTextBoxSizeHeight);
+ this.Controls.Add(this._numericTextBoxSizeWidth);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.label5);
+ this.Menu = this.mainMenu1;
+ this.Name = "StarItemTest";
+ this.Text = "StarItemTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxSizeWidth;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxSizeHeight;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxNumStarPoints;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxPointiness2;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxPointiness1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem menuItem3;
+ private System.Windows.Forms.MenuItem menuItem4;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.cs 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,106 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.UI.Drawing;
+using Roam.UI.Forms;
+
+namespace Roam.Test.Sandbox
+{
+ public partial class StarItemTest : Form
+ {
+ private StarItem _starItem;
+ public StarItemTest()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (_starItem == null)
+ {
+ _starItem = new StarItem(new Size(_numericTextBoxSizeWidth.TextAsInt, _numericTextBoxSizeHeight.TextAsInt),
+ new Point(ClientRectangle.X, _numericTextBoxSizeWidth.Bottom + 2),
+ _numericTextBoxNumStarPoints.TextAsInt,
+ double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt));
+ }
+ Rectangle rect = new Rectangle(ClientRectangle.X, _numericTextBoxSizeWidth.Bottom,
+ ClientRectangle.Width, ClientRectangle.Height - _numericTextBoxSizeWidth.Bottom);
+
+ _starItem.Draw(e.Graphics, rect);
+ base.OnPaint(e);
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void OnNumStarPointsTextChanged(object sender, EventArgs e)
+ {
+ _starItem.NumPoints = _numericTextBoxNumStarPoints.TextAsInt;
+ this.Invalidate();
+ }
+
+ private void OnSizeWidthTextChanged(object sender, EventArgs e)
+ {
+ _starItem.Width = _numericTextBoxSizeWidth.TextAsInt;
+ this.Invalidate();
+ }
+
+ private void OnSizeHeightTextChanged(object sender, EventArgs e)
+ {
+ _starItem.Height = _numericTextBoxSizeHeight.TextAsInt;
+ this.Invalidate();
+ }
+
+ private void OnPointiness1TextChanged(object sender, EventArgs e)
+ {
+ UpdateStarPointiness();
+ }
+
+ private void OnPointiness2TextChanged(object sender, EventArgs e)
+ {
+ UpdateStarPointiness();
+ }
+
+ private void UpdateStarPointiness()
+ {
+ _starItem.Pointiness = double.Parse(_numericTextBoxPointiness1.TextAsInt + "." + _numericTextBoxPointiness2.TextAsInt);
+ this.Invalidate();
+ }
+
+ private void menuItem4_Click(object sender, EventArgs e)
+ {
+ Roam.UI.Controls.TextBox textbox = new Roam.UI.Controls.TextBox();
+ textbox.SelectTextOnFocus = true;
+ textbox.Text = _starItem.Label;
+ Form form = FormFactory.Create("Star label: ", textbox);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (_starItem.Label != textbox.Text)
+ {
+ _starItem.Label = textbox.Text;
+ this.Invalidate();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/StarItemTest.resx 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: Trunk/Source/Roam.UI/Drawing/StarItem.cs
===================================================================
--- Trunk/Source/Roam.UI/Drawing/StarItem.cs (rev 0)
+++ Trunk/Source/Roam.UI/Drawing/StarItem.cs 2007-04-15 23:11:08 UTC (rev 76)
@@ -0,0 +1,230 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using Roam.UI.Utils;
+using System.Diagnostics;
+using Roam.Common.Utils;
+
+namespace Roam.UI.Drawing
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class StarItem : VisualItem
+ {
+ #region Fields
+ private int _numStarPoints = 5;
+ private double _pointiness = 2.5;
+ private Size _size = new Size(50, 50);
+ private Point[] _pts;
+ private float _penWidth = 1;
+ #endregion Fielsd
+
+ public StarItem() : base() { }
+ public StarItem(string label) : base(label) { }
+ public StarItem(Size size)
+ : this(size, new Point(0,0)) { }
+ public StarItem(Size size, Point location)
+ : this(size, location, 5, 2.5) { }
+ public StarItem(Size size, Point location, int numStarPoints, double pointiness)
+ : this(size, location, numStarPoints, pointiness, string.Empty) { }
+ public StarItem(Size size, Point location, int numStarPoints, double pointiness, string label)
+ : base(label)
+ {
+ _size = size;
+ this.Location = location;
+ _numStarPoints = numStarPoints;
+ _pointiness = pointiness;
+ }
+
+ public override Rectangle GetBounds(Graphics g)
+ {
+ //return base.GetBounds(g);
+ return new Rectangle(Location.X, Location.Y, _size.Width, _size.Height);
+ }
+
+ public override void Draw(Graphics g, Rectangle drawArea)
+ {
+ if (_pts == null) { _pts = CreateStar(); }
+
+ SolidBrush backBrush = new SolidBrush(BackColor);
+ Pen pen = new Pen(ForeColor, _penWidth);
+
+ g.FillPolygon(backBrush, _pts);
+ g.DrawPolygon(pen, _pts);
+
+ backBrush.Dispose();
+ pen.Dispose();
+
+ //TODO: add textalign text drawing capabilities like ImageItem except that we also want
+ //a textalign that says "within"... this would look something like below
+
+ //draw text
+ SizeF textBounds = GraphicsUtils.MeasureString(g, Label, this.Font, this.Width);
+ float xText, yText;
+ xText = (int)(this.Width / 2.0 - textBounds.Width / 2.0 + this.Location.X);
+ if (textBounds.Height > _size.Height)
+ {
+ yText = this.Location.Y;
+ }
+ else
+ {
+ yText = (int)(this.Height / 2.0 - textBounds.Height / 2.0 + this.Location.Y);
+ }
+ DrawText(g, new RectangleF(xText, yText, textBounds.Width, textBounds.Height));
+ }
+
+ #region Properties
+ public float PenWidth
+ {
+ get { return _penWidth; }
+ set { _penWidth = value; }
+ }
+
+ public Size Size
+ {
+ get { return _size; }
+ set
+ {
+ if (value.Width < 1)
+ {
+ throw new ArgumentOutOfRangeException("Size", "The Size.Width must be greater than or equal to 1");
+ }
+ else if (value.Height < 1)
+ {
+ throw new ArgumentOutOfRangeException("Size", "The Size.Height must be greater than or equal to 1");
+ }
+
+ if (_size != value)
+ {
+ _size = value;
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public int Width
+ {
+ get { return _size.Width; }
+ set
+ {
+ if (value < 1)
+ {
+ throw new ArgumentOutOfRangeException("Width", "The Width must be greater than or equal to 1");
+ }
+
+ if (Size.Width != value)
+ {
+ _size = new Size(value, Size.Height);
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public int Height
+ {
+ get { return _size.Height; }
+ set
+ {
+ if (value < 1)
+ {
+ throw new ArgumentOutOfRangeException("Height", "The Height must be greater than or equal to 1");
+ }
+
+ if (Size.Height != value)
+ {
+ _size = new Size(Size.Width, value);
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public int NumPoints
+ {
+ get { return _numStarPoints; }
+ set
+ {
+ if (value < 2)
+ {
+ throw new ArgumentOutOfRangeException("NumPoints", "NumPoints must be greater than 1");
+ }
+
+ if (_numStarPoints != value)
+ {
+ _numStarPoints = value;
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ public double Pointiness
+ {
+ get { return _pointiness; }
+ set
+ {
+ if (_pointiness != value)
+ {
+ _pointiness = value;
+ _pts = CreateStar();
+ }
+ }
+ }
+
+ #endregion Properties
+
+ protected virtual Point[] CreateStar()
+ {
+ return CreateStar(_size, this.Location, _numStarPoints, _pointiness);
+ }
+
+ public static Point[] CreateStar(Size size, Point location, int numStarPoints, double pointiness)
+ {
+ double wRadius = size.Width / 2.0;
+ double hRadius = size.Height / 2.0;
+ double xMid = wRadius;
+ double yMid = hRadius;
+
+ Point[] pts = new Point[(int)(2 * numStarPoints + 1)];
+ for (int i = 0; i < numStarPoints; i++)
+ {
+ double x1 = xMid + wRadius *
+ -Math.Sin(i * (360 / (double)numStarPoints) * Math.PI / 180);
+ double y1 = yMid + hRadius *
+ -Math.Cos(i * (360 / (double)numStarPoints) * Math.PI / 180);
+ double x2 = xMid + wRadius /
+ pointiness * -Math.Sin((i * (360 / (double)numStarPoints) + (180 / (double)numStarPoints)) * Math.PI / 180);
+ double y2 = yMid + hRadius /
+ pointiness * -Math.Cos((i * (360 / (double)numStarPoints) + (180 / (double)numStarPoints)) * Math.PI / 180);
+
+ pts[2 * i] = new Point((int)x1, (int)y1);
+ pts[2 * i + 1] = new Point((int)x2, (int)y2);
+ }
+ pts[pts.Length - 1] = new Point((int)pts[0].X, (int)pts[0].Y);
+
+ for (int i = 0; i < pts.Length; i++)
+ {
+ pts[i] = new Point(pts[i].X + location.X, pts[i].Y + location.Y);
+ }
+ return pts;
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-12 22:41:01 UTC (rev 75)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-15 23:11:08 UTC (rev 76)
@@ -202,6 +202,7 @@
<Compile Include="Drawing\RelativeAlignment.cs" />
<Compile Include="Drawing\ScaleMode.cs" />
<Compile Include="Drawing\SimpleLinearGradient.cs" />
+ <Compile Include="Drawing\StarItem.cs" />
<Compile Include="Drawing\VerticalAlignment.cs" />
<Compile Include="Drawing\VisualItem.cs" />
<Compile Include="Drawing\VisualItemEventArgs.cs" />
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|