[Roam-commit] SF.net SVN: roam: [65] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-03-10 09:19:15
|
Revision: 65
http://roam.svn.sourceforge.net/roam/?rev=65&view=rev
Author: jonfroehlich
Date: 2007-03-10 01:19:14 -0800 (Sat, 10 Mar 2007)
Log Message:
-----------
1. added static method to ColorUtils to retrieve all of the static colors in the Color class
2. updated ScrollableLabel to use Insets and fixed a scrolling bug
3. added a test for rounded rectangles (RoundedRectTest2)
4. Added a select text on focus feature to TextBox
5. Insets now implements IEquatable
Modified Paths:
--------------
Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs
Trunk/Source/Roam.Common/Utils/ColorUtils.cs
Trunk/Source/Roam.Common/Utils/EnumUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs
Trunk/Source/Roam.UI/Controls/NumericTextBox.cs
Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
Trunk/Source/Roam.UI/Controls/TextBox.cs
Trunk/Source/Roam.UI/Drawing/FillRoundedRectangle.cs
Trunk/Source/Roam.UI/Drawing/Insets.cs
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs
Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx
Modified: Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Common/Utils/AssemblyUtils.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -52,5 +52,10 @@
cnt++;
}
}
+
+ public static string GetExecutingAssemblyPath()
+ {
+ return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
+ }
}
}
Modified: Trunk/Source/Roam.Common/Utils/ColorUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/ColorUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Common/Utils/ColorUtils.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -17,6 +17,8 @@
using System;
using System.Drawing;
+using System.Collections.Generic;
+using System.Reflection;
namespace Roam.Common.Utils
{
@@ -29,6 +31,30 @@
/// <author>Jon Froehlich</author>
public static class ColorUtils
{
+ private static Dictionary<string, Color> _staticColorMap = null;
+
+ public static IDictionary<string, Color> GetStaticColors()
+ {
+ if(_staticColorMap == null)
+ {
+ Dictionary<string, Color> mapColors = new Dictionary<string, Color>();
+ foreach (PropertyInfo pi in typeof(Color).GetProperties())
+ {
+ if (pi.PropertyType == typeof(Color))
+ {
+ mapColors[pi.Name] = (Color)pi.GetValue(null, null);
+ }
+ }
+ _staticColorMap = mapColors;
+ }
+ return _staticColorMap;
+ }
+
+ public static Color GetStaticColorFromName(string colorName)
+ {
+ return GetStaticColors()[colorName];
+ }
+
public static Color GetRandomColor()
{
Random rand = new Random();
Modified: Trunk/Source/Roam.Common/Utils/EnumUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/EnumUtils.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Common/Utils/EnumUtils.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -12,12 +12,17 @@
List<string> l = new List<string>();
foreach (FieldInfo fi in t.GetFields())
{
- if (fi.Name != "value__")
+ if (!IsReservedEnumName(fi.Name))
{
l.Add(fi.Name);
}
}
return l.ToArray();
}
+
+ public static bool IsReservedEnumName(string name)
+ {
+ return name == "value__";
+ }
}
}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-10 09:19:14 UTC (rev 65)
@@ -190,6 +190,10 @@
<DependentUpon>CheckedListBoxTest.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="UI\Controls\RoundedRectTest2.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>RoundedRectTest2.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="UI\Controls\TextBoxFilteredListTest.resx">
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
<SubType>Designer</SubType>
@@ -371,6 +375,9 @@
<Compile Include="Sandbox\PhoneCallTalkingTest.Designer.cs">
<DependentUpon>PhoneCallTalkingTest.cs</DependentUpon>
</Compile>
+ <Compile Include="Sandbox\TextBoxBackgroundTest.cs">
+ <SubType>Component</SubType>
+ </Compile>
<Compile Include="Sandbox\TopMostFormTest.cs">
<SubType>Form</SubType>
</Compile>
@@ -431,6 +438,12 @@
<Compile Include="UI\Controls\CameraMediaSnifferTest.Designer.cs">
<DependentUpon>CameraMediaSnifferTest.cs</DependentUpon>
</Compile>
+ <Compile Include="UI\Controls\RoundedRectTest2.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="UI\Controls\RoundedRectTest2.Designer.cs">
+ <DependentUpon>RoundedRectTest2.cs</DependentUpon>
+ </Compile>
<Compile Include="UI\Controls\TextBoxFilteredListTest.cs">
<SubType>Form</SubType>
</Compile>
Modified: Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/Sandbox/Gradient/GradientFillTest.Designer.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -81,7 +81,6 @@
this.scrollableLabel1.ShowScrollBar = true;
this.scrollableLabel1.Size = new System.Drawing.Size(234, 58);
this.scrollableLabel1.TabIndex = 1;
- this.scrollableLabel1.TextPadding = 1;
//
// menuItem2
//
Added: Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/TextBoxBackgroundTest.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,199 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.Diagnostics;
+
+namespace Roam.UI.Controls
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public class TextBoxBackgroundTest : System.Windows.Forms.TextBox
+ {
+ private Color _borderColor = Color.Black;
+ private Color _selBorderColor = SystemColors.HighlightText;
+ private Color _selBackColor = SystemColors.Highlight;
+ private Color _selForeColor = SystemColors.HighlightText;
+ private Color _disabledBackColor = Color.Gray;
+ private Color _disabledForeColor = Color.DarkGray;
+ private Color _disabledBorderColor = Color.DarkGray;
+
+ public TextBoxBackgroundTest()
+ : base()
+ {
+ this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ }
+
+ #region Properties
+ public Color BorderColor
+ {
+ get { return _borderColor; }
+ set
+ {
+ if (_borderColor != value)
+ {
+ _borderColor = value;
+ if (!Focused && Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color SelectedBorderColor
+ {
+ get { return _selBorderColor; }
+ set
+ {
+ if (_selBorderColor != value)
+ {
+ _selBorderColor = value;
+ if (Focused)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color SelectedBackColor
+ {
+ get { return _selBackColor; }
+ set
+ {
+ if (_selBackColor != value)
+ {
+ _selBackColor = value;
+ if (Focused)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color SelectedForeColor
+ {
+ get { return _selForeColor; }
+ set
+ {
+ if (_selForeColor != value)
+ {
+ _selForeColor = value;
+ if (Focused)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color DisabledBorderColor
+ {
+ get { return _disabledBorderColor; }
+ set
+ {
+ if (_disabledBorderColor != value)
+ {
+ _disabledBorderColor = value;
+ if (!Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color DisabledBackColor
+ {
+ get { return _disabledBackColor; }
+ set
+ {
+ if (_disabledBackColor != value)
+ {
+ _disabledBackColor = value;
+ if (!Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+
+ public Color DisabledForeColor
+ {
+ get { return _disabledForeColor; }
+ set
+ {
+ if (_disabledForeColor != value)
+ {
+ _disabledForeColor = value;
+ if (!Enabled)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+ }
+ #endregion Properties
+
+ protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
+ {
+ Debug.WriteLine("OnPaintBackground entered.");
+ base.OnPaintBackground(e);
+
+ SolidBrush backBrush = new SolidBrush(this.BackColor);
+ SolidBrush frontBrush = new SolidBrush(this.ForeColor);
+ Pen borderPen = new Pen(this.BorderColor);
+
+ if (this.Focused)
+ {
+ backBrush.Color = this.SelectedBackColor;
+ frontBrush.Color = this.SelectedForeColor;
+ borderPen.Color = this.SelectedBorderColor;
+ }
+ else if (!this.Enabled)
+ {
+ backBrush.Color = this.DisabledBackColor;
+ frontBrush.Color = this.DisabledForeColor;
+ borderPen.Color = this.DisabledBorderColor;
+ }
+
+ if (BorderStyle == System.Windows.Forms.BorderStyle.FixedSingle)
+ {
+ Rectangle rectangle = this.ClientRectangle;
+ e.Graphics.DrawRectangle(borderPen, rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1);
+ }
+
+ backBrush.Dispose();
+ frontBrush.Dispose();
+ borderPen.Dispose();
+ }
+
+ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
+ {
+ Debug.WriteLine("OnPaint entered.");
+ base.OnPaint(e);
+ }
+ }
+}
Added: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.Designer.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,181 @@
+namespace Roam.Test.UI.Controls
+{
+ partial class RoundedRectTest2
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.Windows.Forms.Label label1;
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this._comboBoxBackColor = new System.Windows.Forms.ComboBox();
+ this._comboBoxForeColor = new System.Windows.Forms.ComboBox();
+ this._numericTextBoxPenSize = new Roam.UI.Controls.NumericTextBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this._numericTextBoxRoundedCornerHeight = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxRoundedCornerWidth = new Roam.UI.Controls.NumericTextBox();
+ label1 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ //
+ // menuItem2
+ //
+ this.menuItem2.Text = "Menu";
+ //
+ // label1
+ //
+ label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ label1.Location = new System.Drawing.Point(3, 12);
+ label1.Name = "label1";
+ label1.Size = new System.Drawing.Size(61, 18);
+ label1.Text = "BackColor:";
+ //
+ // label2
+ //
+ this.label2.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label2.Location = new System.Drawing.Point(3, 30);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(61, 18);
+ this.label2.Text = "ForeColor:";
+ //
+ // label3
+ //
+ this.label3.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label3.Location = new System.Drawing.Point(3, 48);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(52, 18);
+ this.label3.Text = "Pen Size:";
+ //
+ // _comboBoxBackColor
+ //
+ this._comboBoxBackColor.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._comboBoxBackColor.Location = new System.Drawing.Point(64, 9);
+ this._comboBoxBackColor.Name = "_comboBoxBackColor";
+ this._comboBoxBackColor.Size = new System.Drawing.Size(167, 18);
+ this._comboBoxBackColor.TabIndex = 5;
+ //
+ // _comboBoxForeColor
+ //
+ this._comboBoxForeColor.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._comboBoxForeColor.Location = new System.Drawing.Point(64, 27);
+ this._comboBoxForeColor.Name = "_comboBoxForeColor";
+ this._comboBoxForeColor.Size = new System.Drawing.Size(167, 18);
+ this._comboBoxForeColor.TabIndex = 6;
+ //
+ // _numericTextBoxPenSize
+ //
+ this._numericTextBoxPenSize.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxPenSize.Location = new System.Drawing.Point(126, 48);
+ this._numericTextBoxPenSize.Name = "_numericTextBoxPenSize";
+ this._numericTextBoxPenSize.Size = new System.Drawing.Size(105, 18);
+ this._numericTextBoxPenSize.TabIndex = 7;
+ this._numericTextBoxPenSize.Text = "1";
+ //
+ // label4
+ //
+ this.label4.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label4.Location = new System.Drawing.Point(3, 69);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(126, 18);
+ this.label4.Text = "Rounded Corner Height:";
+ //
+ // label5
+ //
+ this.label5.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label5.Location = new System.Drawing.Point(3, 88);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(126, 18);
+ this.label5.Text = "Rounded Corner Width:";
+ //
+ // _numericTextBoxRoundedCornerHeight
+ //
+ this._numericTextBoxRoundedCornerHeight.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxRoundedCornerHeight.Location = new System.Drawing.Point(126, 68);
+ this._numericTextBoxRoundedCornerHeight.Name = "_numericTextBoxRoundedCornerHeight";
+ this._numericTextBoxRoundedCornerHeight.Size = new System.Drawing.Size(105, 18);
+ this._numericTextBoxRoundedCornerHeight.TabIndex = 12;
+ this._numericTextBoxRoundedCornerHeight.Text = "10";
+ //
+ // _numericTextBoxRoundedCornerWidth
+ //
+ this._numericTextBoxRoundedCornerWidth.Font = new System.Drawing.Font("Segoe Condensed", 6F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxRoundedCornerWidth.Location = new System.Drawing.Point(126, 88);
+ this._numericTextBoxRoundedCornerWidth.Name = "_numericTextBoxRoundedCornerWidth";
+ this._numericTextBoxRoundedCornerWidth.Size = new System.Drawing.Size(105, 18);
+ this._numericTextBoxRoundedCornerWidth.TabIndex = 13;
+ this._numericTextBoxRoundedCornerWidth.Text = "10";
+ //
+ // RoundedRectTest2
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._numericTextBoxRoundedCornerWidth);
+ this.Controls.Add(this._numericTextBoxRoundedCornerHeight);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this._numericTextBoxPenSize);
+ this.Controls.Add(this._comboBoxForeColor);
+ this.Controls.Add(this._comboBoxBackColor);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(label1);
+ this.Menu = this.mainMenu1;
+ this.Name = "RoundedRectTest2";
+ this.Text = "RoundedRectTest2";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ComboBox _comboBoxBackColor;
+ private System.Windows.Forms.ComboBox _comboBoxForeColor;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxPenSize;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label5;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxRoundedCornerHeight;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxRoundedCornerWidth;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,116 @@
+#region Copyright & License
+//
+// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
+// Research Seattle, and the Roam project. All rights reserved.
+//
+// This software is open-source under the BSD license. You may obtain a copy
+// of this license at
+//
+// http://roam.sourceforge.net/license.txt
+//
+// Alternatively, please see "license.txt" which should be included in
+// this source code distribution.
+//
+#endregion Copyright & License
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.Common.Utils;
+using Roam.UI.Drawing;
+
+namespace Roam.Test.UI.Controls
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <remarks>
+ ///
+ /// </remarks>
+ /// <author>Jon Froehlich</author>
+ public partial class RoundedRectTest2 : Form
+ {
+ private FillRoundedRectangle _fill = new FillRoundedRectangle(Color.Black);
+
+ public RoundedRectTest2()
+ {
+ InitializeComponent();
+ _comboBoxBackColor.BeginUpdate();
+ _comboBoxForeColor.BeginUpdate();
+ foreach (KeyValuePair<string, Color> colors in ColorUtils.GetStaticColors())
+ {
+ _comboBoxBackColor.Items.Add(colors.Key);
+ _comboBoxForeColor.Items.Add(colors.Key);
+ }
+ _comboBoxForeColor.EndUpdate();
+ _comboBoxBackColor.EndUpdate();
+
+ _numericTextBoxPenSize.TextChanged += new EventHandler(OnNumericTextBoxPenSizeTextChanged);
+ _comboBoxBackColor.SelectedIndexChanged += new EventHandler(OnComboBoxBackColorSelectedIndexChanged);
+ _comboBoxForeColor.SelectedIndexChanged += new EventHandler(OnComboBoxForeColorSelectedIndexChanged);
+ _numericTextBoxRoundedCornerHeight.TextChanged += new EventHandler(OnNumericTextBoxRoundedCornerHeight);
+ _numericTextBoxRoundedCornerWidth.TextChanged += new EventHandler(OnNumericTextBoxRoundedCornerWidth);
+
+ _comboBoxForeColor.SelectedIndex = 0;
+ _comboBoxBackColor.SelectedIndex = 0;
+
+ _numericTextBoxRoundedCornerWidth.SelectTextOnFocus = true;
+ _numericTextBoxRoundedCornerHeight.SelectTextOnFocus = true;
+ _numericTextBoxPenSize.SelectTextOnFocus = true;
+
+ }
+
+ void OnNumericTextBoxRoundedCornerWidth(object sender, EventArgs e)
+ {
+ _fill.RoundedCornerWidth = _numericTextBoxRoundedCornerWidth.TextAsInt;
+ this.Invalidate();
+ }
+
+ void OnNumericTextBoxRoundedCornerHeight(object sender, EventArgs e)
+ {
+ _fill.RoundedCornerHeight = _numericTextBoxRoundedCornerHeight.TextAsInt;
+ this.Invalidate();
+ }
+
+ void OnNumericTextBoxPenSizeTextChanged(object sender, EventArgs e)
+ {
+ _fill.PenWidth = _numericTextBoxPenSize.TextAsInt;
+ this.Invalidate();
+ }
+
+ void OnComboBoxForeColorSelectedIndexChanged(object sender, EventArgs e)
+ {
+ _fill.ForeColor = ColorUtils.GetStaticColorFromName(_comboBoxForeColor.SelectedItem.ToString());
+ this.Invalidate();
+ }
+
+ void OnComboBoxBackColorSelectedIndexChanged(object sender, EventArgs e)
+ {
+ _fill.Color = ColorUtils.GetStaticColorFromName(_comboBoxBackColor.SelectedItem.ToString());
+ this.Invalidate();
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ int y = -1;
+ foreach(Control c in this.Controls)
+ {
+ if (c.Bottom > y) { y = c.Bottom; }
+ }
+
+ int vSpace = 10;
+ y += vSpace;
+ int width = (int)(ClientSize.Width * .8f);
+ int x = (int)((ClientSize.Width - width) / 2f);
+ int height = ClientSize.Height - y - vSpace;
+
+ _fill.Draw(e.Graphics, new Rectangle(x, y, width, height));
+
+ base.OnPaint(e);
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/RoundedRectTest2.resx 2007-03-10 09:19:14 UTC (rev 65)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>False</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
Modified: Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.Designer.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -50,28 +50,43 @@
/// </summary>
private void InitializeComponent()
{
+ this.label1 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.menuItem17 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
+ this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
+ this.menuItem15 = new System.Windows.Forms.MenuItem();
this._menuBackFillImageMode = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItemBorderStyle = new System.Windows.Forms.MenuItem();
+ this.menuItemBorderBehavior = new System.Windows.Forms.MenuItem();
+ this._numericTextBoxBottom = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxTop = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxRight = new Roam.UI.Controls.NumericTextBox();
+ this._numericTextBoxLeft = new Roam.UI.Controls.NumericTextBox();
this.scrollableLabel1 = new Roam.UI.Controls.ScrollableLabel();
- this.menuItemBorderBehavior = new System.Windows.Forms.MenuItem();
- this.menuItem15 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Bold);
+ this.label1.Location = new System.Drawing.Point(13, 224);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(39, 15);
+ this.label1.Text = "Insets:";
+ //
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItem1);
@@ -87,7 +102,9 @@
this.menuItem2.MenuItems.Add(this.menuItem3);
this.menuItem2.MenuItems.Add(this.menuItem5);
this.menuItem2.MenuItems.Add(this.menuItem4);
+ this.menuItem2.MenuItems.Add(this.menuItem17);
this.menuItem2.MenuItems.Add(this.menuItem6);
+ this.menuItem2.MenuItems.Add(this.menuItem16);
this.menuItem2.MenuItems.Add(this.menuItem7);
this.menuItem2.MenuItems.Add(this._menuBackFillImageMode);
this.menuItem2.MenuItems.Add(this.menuItemBorderStyle);
@@ -109,11 +126,21 @@
this.menuItem4.Text = "Clear";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
+ // menuItem17
+ //
+ this.menuItem17.Text = "Add Simple Line";
+ this.menuItem17.Click += new System.EventHandler(this.menuItem17_Click);
+ //
// menuItem6
//
- this.menuItem6.Text = "Add Line";
+ this.menuItem6.Text = "Add Long Line";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
+ // menuItem16
+ //
+ this.menuItem16.Text = "Add Random Text";
+ this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
+ //
// menuItem7
//
this.menuItem7.MenuItems.Add(this.menuItem8);
@@ -143,6 +170,11 @@
this.menuItem11.Text = "Random Rounded Rect";
this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
//
+ // menuItem15
+ //
+ this.menuItem15.Text = "Solid White Color";
+ this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
+ //
// _menuBackFillImageMode
//
this._menuBackFillImageMode.MenuItems.Add(this.menuItem14);
@@ -169,6 +201,46 @@
//
this.menuItemBorderStyle.Text = "Border Style";
//
+ // menuItemBorderBehavior
+ //
+ this.menuItemBorderBehavior.Text = "Border Behavior";
+ //
+ // _numericTextBoxBottom
+ //
+ this._numericTextBoxBottom.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxBottom.Location = new System.Drawing.Point(150, 224);
+ this._numericTextBoxBottom.Name = "_numericTextBoxBottom";
+ this._numericTextBoxBottom.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxBottom.TabIndex = 4;
+ this._numericTextBoxBottom.Text = "numericTextBox4";
+ //
+ // _numericTextBoxTop
+ //
+ this._numericTextBoxTop.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxTop.Location = new System.Drawing.Point(117, 224);
+ this._numericTextBoxTop.Name = "_numericTextBoxTop";
+ this._numericTextBoxTop.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxTop.TabIndex = 3;
+ this._numericTextBoxTop.Text = "numericTextBox3";
+ //
+ // _numericTextBoxRight
+ //
+ this._numericTextBoxRight.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxRight.Location = new System.Drawing.Point(84, 224);
+ this._numericTextBoxRight.Name = "_numericTextBoxRight";
+ this._numericTextBoxRight.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxRight.TabIndex = 2;
+ this._numericTextBoxRight.Text = "numericTextBox2";
+ //
+ // _numericTextBoxLeft
+ //
+ this._numericTextBoxLeft.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._numericTextBoxLeft.Location = new System.Drawing.Point(51, 224);
+ this._numericTextBoxLeft.Name = "_numericTextBoxLeft";
+ this._numericTextBoxLeft.Size = new System.Drawing.Size(30, 15);
+ this._numericTextBoxLeft.TabIndex = 1;
+ this._numericTextBoxLeft.Text = "numericTextBox1";
+ //
// scrollableLabel1
//
this.scrollableLabel1.Location = new System.Drawing.Point(13, 17);
@@ -176,24 +248,20 @@
this.scrollableLabel1.Name = "scrollableLabel1";
this.scrollableLabel1.ScrollLock = false;
this.scrollableLabel1.ShowScrollBar = true;
- this.scrollableLabel1.Size = new System.Drawing.Size(213, 231);
+ this.scrollableLabel1.Size = new System.Drawing.Size(213, 188);
this.scrollableLabel1.TabIndex = 0;
//
- // menuItemBorderBehavior
- //
- this.menuItemBorderBehavior.Text = "Border Behavior";
- //
- // menuItem15
- //
- this.menuItem15.Text = "Solid White Color";
- this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
- //
// ScrollableLabelTest2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._numericTextBoxBottom);
+ this.Controls.Add(this._numericTextBoxTop);
+ this.Controls.Add(this._numericTextBoxRight);
+ this.Controls.Add(this._numericTextBoxLeft);
+ this.Controls.Add(this.label1);
this.Controls.Add(this.scrollableLabel1);
this.Menu = this.mainMenu1;
this.Name = "ScrollableLabelTest2";
@@ -223,5 +291,12 @@
private System.Windows.Forms.MenuItem menuItemBorderStyle;
private System.Windows.Forms.MenuItem menuItemBorderBehavior;
private System.Windows.Forms.MenuItem menuItem15;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxLeft;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxRight;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxTop;
+ private Roam.UI.Controls.NumericTextBox _numericTextBoxBottom;
+ private System.Windows.Forms.MenuItem menuItem16;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.MenuItem menuItem17;
}
}
Modified: Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.Test/UI/Controls/ScrollableLabelTest2.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -64,8 +64,33 @@
mi.Click += new EventHandler(OnBorderBehaviorMenuItemClick);
menuItemBorderBehavior.MenuItems.Add(mi);
}
+
+ _numericTextBoxLeft.Text = scrollableLabel1.TextInsets.Left.ToString();
+ _numericTextBoxRight.Text = scrollableLabel1.TextInsets.Right.ToString();
+ _numericTextBoxTop.Text = scrollableLabel1.TextInsets.Top.ToString();
+ _numericTextBoxBottom.Text = scrollableLabel1.TextInsets.Bottom.ToString();
+
+ _numericTextBoxLeft.TextChanged += new EventHandler(OnInsetsTextChanged);
+ _numericTextBoxRight.TextChanged += new EventHandler(OnInsetsTextChanged);
+ _numericTextBoxTop.TextChanged += new EventHandler(OnInsetsTextChanged);
+ _numericTextBoxBottom.TextChanged += new EventHandler(OnInsetsTextChanged);
+
+ _numericTextBoxLeft.SelectTextOnFocus = true;
+ _numericTextBoxRight.SelectTextOnFocus = true;
+ _numericTextBoxTop.SelectTextOnFocus = true;
+ _numericTextBoxBottom.SelectTextOnFocus = true;
+
+ scrollableLabel1.Clear();
}
+ void OnInsetsTextChanged(object sender, EventArgs e)
+ {
+ scrollableLabel1.TextInsets = new Insets(_numericTextBoxLeft.TextAsInt,
+ _numericTextBoxRight.TextAsInt,
+ _numericTextBoxTop.TextAsInt,
+ _numericTextBoxBottom.TextAsInt);
+ }
+
private void OnBorderStyleMenuItemClick(object sender, EventArgs e)
{
MenuItem mi = (MenuItem)sender;
@@ -96,6 +121,7 @@
{
scrollableLabel1.Clear();
_lineCount = 0;
+ _simpleLineCnt = 0;
}
private void menuItem3_Click(object sender, EventArgs e)
@@ -120,18 +146,20 @@
private void menuItem6_Click(object sender, EventArgs e)
{
- Random rand = new Random();
- double r = rand.NextDouble();
- if (r < 0.5)
- {
- scrollableLabel1.AddLine(String.Format("This is line #{0} and\r\n this is also line #{0} but really on a new line", _lineCount++));
- }
- else
- {
- scrollableLabel1.AddLine(String.Format("ThisIsOneLongSentenceAllWithoutSpacesOrTabsToSeeIfMyNewMethodWorks.ItWillBeVeryInterestingI'mSure.ByTheWayWe'reOnLine#{0}", _lineCount++));
- }
+ scrollableLabel1.AddLine(String.Format("ThisIsOneLongSentenceAllWithoutSpacesOrTabsToSeeIfMyNewMethodWorks.ItWillBeVeryInterestingI'mSure.ByTheWayWe'reOnLine#{0}", _lineCount++));
}
+ private void menuItem16_Click(object sender, EventArgs e)
+ {
+ scrollableLabel1.AddLine(TestUtils.GetRandomGettysburgString());
+ }
+
+ private int _simpleLineCnt = 0;
+ private void menuItem17_Click(object sender, EventArgs e)
+ {
+ scrollableLabel1.AddLine("{0} This is a simple line of text", ++_simpleLineCnt);
+ }
+
//random image
private void menuItem8_Click(object sender, EventArgs e)
{
Modified: Trunk/Source/Roam.UI/Controls/NumericTextBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/NumericTextBox.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.UI/Controls/NumericTextBox.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -27,7 +27,7 @@
///
/// </remarks>
/// <author>Jon Froehlich</author>
- public class NumericTextBox : System.Windows.Forms.TextBox
+ public class NumericTextBox : TextBox
{
private bool _acceptDecimal = true;
Modified: Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -51,12 +51,12 @@
private SizeF _textBounds;
private VerticalAlignment _verticalAlignment = VerticalAlignment.Top;
private VScrollBar _vScrollBar;
- private int _textPadding = 1;
private int _borderThickness = 1;
private BorderStyle _borderStyle = BorderStyle.FixedSingle;
private BorderBehavior _borderBehavior = BorderBehavior.DrawBorderWhenFocused;
private Color _borderColor = Color.Black;
- private Fill _backFill = new FillSimpleLinearGradient(new SimpleLinearGradient(Color.FromArgb(206, 223, 239), Color.White, SimpleLinearGradient.FillDirection.TopToBottom));
+ private Fill _backFill = new FillSimpleLinearGradient(new SimpleLinearGradient(Color.FromArgb(206, 223, 239), Color.White, SimpleLinearGradient.FillDirection.TopToBottom));
+ private Insets _textInsets = new Insets(1, 1, 1, 1);
#endregion Private Fields
public ScrollableLabel()
@@ -77,6 +77,19 @@
#region Properties
+ public Insets TextInsets
+ {
+ get { return _textInsets; }
+ set
+ {
+ if (!_textInsets.Equals(value))
+ {
+ _textInsets = value;
+ UpdateLayout();
+ }
+ }
+ }
+
public Fill BackFill
{
get { return _backFill; }
@@ -221,28 +234,15 @@
get
{
int preferredHeight = (int)Math.Ceiling(_textBounds.Height);
- preferredHeight += 2 * _textPadding;
if (_borderStyle == BorderStyle.FixedSingle)
{
preferredHeight += 2 * _borderThickness;
}
+ preferredHeight += _textInsets.TotalVerticalInset;
return preferredHeight;
}
}
- public int TextPadding
- {
- get { return _textPadding; }
- set
- {
- if (value != _textPadding)
- {
- _textPadding = value;
- UpdateLayout();
- }
- }
- }
-
protected VScrollBar VScrollBar
{
get { return _vScrollBar; }
@@ -272,6 +272,21 @@
UpdateLayout();
}
+ public void AddLine(string str, object arg0)
+ {
+ AddLine(string.Format(str, arg0));
+ }
+
+ public void AddLine(string str, object arg0, object arg1)
+ {
+ AddLine(string.Format(str, arg0, arg1));
+ }
+
+ public void AddLine(string str, params object[] args)
+ {
+ AddLine(string.Format(str, args));
+ }
+
/// <summary>
///
/// </summary>
@@ -363,29 +378,45 @@
_vScrollBar.Size = new Size(_vScrollBar.Width, drawableArea.Height);
//get the text bounds
- _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font, drawableArea.Width - 2 * _textPadding);
+ _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font,
+ drawableArea.Width - _textInsets.TotalHorizontalInset);
+ float textHeightWithInsets = _textBounds.Height + _textInsets.TotalVerticalInset;
//set the scroll bar parameters based on text bounds
- if (_textBounds.Height > drawableArea.Height && _showScrollBar)
+ if (textHeightWithInsets > drawableArea.Height && _showScrollBar)
{
- //set the SmallChange and LargeChange values based on a percentage of the height
- //this will keep the scroll bar moving in proportion to its size
- _vScrollBar.LargeChange = (int)(_textBounds.Height / 10f);
- _vScrollBar.SmallChange = (int)(_textBounds.Height / 30f);
-
- _vScrollBar.Visible = true;
- _vScrollBar.Minimum = 0;
- _vScrollBar.Maximum = (int)(_textBounds.Height - drawableArea.Height + _vScrollBar.LargeChange - 1);
- if (!ScrollLock)
+ float lastHeight = -1;
+ do
{
- _vScrollBar.Value = _vScrollBar.Maximum;
- }
+ _vScrollBar.Visible = true;
- //now that the scroll bar is visible, we need to remeasure the string
- //with a smaller width
- //jeffixme : do we need to recalculate the scrollbar's min/max parameters then?
- _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font,
- drawableArea.Width - _vScrollBar.Width - 2 * _textPadding);
+ //set the SmallChange and LargeChange values based on a percentage of the height
+ //this will keep the scroll bar moving in proportion to its size
+ int largeChange = (int)(textHeightWithInsets / 10f);
+ int smallChange = (int)(textHeightWithInsets / 30f);
+
+ _vScrollBar.Minimum = 0;
+ _vScrollBar.Maximum = (int)(textHeightWithInsets - drawableArea.Height + largeChange - 1);
+
+ //LargeChange and SmallChange must be set after the Minimum/Maximum properties
+ //because largeChange could be greater than Maximum before the new Maximum
+ //is calculated
+ _vScrollBar.LargeChange = largeChange;
+ _vScrollBar.SmallChange = smallChange;
+
+ if (!ScrollLock)
+ {
+ _vScrollBar.Value = _vScrollBar.Maximum;
+ }
+
+ //now that the scroll bar is visible, we need to remeasure the string
+ //with a smaller width
+ //jeffixme : do we need to recalculate the scrollbar's min/max parameters then?
+ lastHeight = _textBounds.Height;
+ _textBounds = GraphicsUtils.MeasureString(g, _sb.ToString(), this.Font,
+ drawableArea.Width - _vScrollBar.Width - _textInsets.TotalHorizontalInset);
+ textHeightWithInsets = _textBounds.Height + _textInsets.TotalVerticalInset;
+ } while (lastHeight != _textBounds.Height);
}
else
{
@@ -402,12 +433,17 @@
Rectangle drawableArea;
if (_borderStyle == BorderStyle.FixedSingle)
{
- drawableArea = new Rectangle(_borderThickness, _borderThickness,
- _bmpOffScreen.Width - 2 * _borderThickness, _bmpOffScreen.Height - 2 * _borderThickness);
+ drawableArea = new Rectangle(_borderThickness,
+ _borderThickness,
+ _bmpOffScreen.Width - (2 * _borderThickness),
+ _bmpOffScreen.Height - (2 * _borderThickness));
}
else
{
- drawableArea = new Rectangle(1, 1, _bmpOffScreen.Width - 2, _bmpOffScreen.Height - 2);
+ drawableArea = new Rectangle(0,
+ 0,
+ _bmpOffScreen.Width - 1,
+ _bmpOffScreen.Height - 1);
}
return drawableArea;
}
@@ -516,29 +552,31 @@
//g.Clip = new Region(new Rectangle(0, 0, (int)_bmpOffScreen.Width, (int)_bmpOffScreen.Height));
int vOffset = _vScrollBar.Visible ? (_vScrollBar.Maximum - _vScrollBar.Value - _vScrollBar.LargeChange) : 0;
- float xPos = drawableArea.Left, yPos = drawableArea.Top;
- if (_textBounds.Height > drawableArea.Height)
+ float xPos = drawableArea.Left + _textInsets.Left, yPos = drawableArea.Top + _textInsets.Top;
+ float textHeightWithInsets = _textBounds.Height + _textInsets.TotalVerticalInset;
+ if (textHeightWithInsets > drawableArea.Height)
{
- yPos = drawableArea.Height + vOffset - _textBounds.Height;
+ yPos = drawableArea.Height + vOffset - textHeightWithInsets + _textInsets.Top;
}
else
{
switch (_verticalAlignment)
{
case VerticalAlignment.Top:
- yPos = drawableArea.Top;
+ yPos = drawableArea.Top + _textInsets.Top;
break;
case VerticalAlignment.Bottom:
- yPos = drawableArea.Bottom - _textBounds.Height;
+ yPos = drawableArea.Bottom - _textBounds.Height - _textInsets.Bottom;
break;
case VerticalAlignment.Center:
- yPos = _bmpOffScreen.Height / 2f - _textBounds.Height / 2f;
+ yPos = _bmpOffScreen.Height / 2f - (textHeightWithInsets) / 2f;
break;
}
}
- float width = _vScrollBar.Visible ? drawableArea.Width - _vScrollBar.Width : drawableArea.Width;
- RectangleF drawStringArea = new RectangleF(xPos + _textPadding, yPos, width - 2 * _textPadding, _textBounds.Height);
+ float width = (_vScrollBar.Visible ?
+ drawableArea.Width - _vScrollBar.Width : drawableArea.Width) - _textInsets.TotalHorizontalInset;
+ RectangleF drawStringArea = new RectangleF(xPos, yPos, width, _textBounds.Height);
g.DrawString(str, this.Font, frontBrush, drawStringArea);
//debug - draw an outline in red
Modified: Trunk/Source/Roam.UI/Controls/TextBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/TextBox.cs 2007-03-08 07:01:11 UTC (rev 64)
+++ Trunk/Source/Roam.UI/Controls/TextBox.cs 2007-03-10 09:19:14 UTC (rev 65)
@@ -12,11 +12,10 @@
// this source code distribution.
//
#endregion Copyright & License
+
using System;
using System.Collections.Generic;
using System.Text;
-using System.Drawing;
-using System.Diagnostics;
namespace Roam.UI.Controls
{
@@ -29,171 +28,22 @@
/// <author>Jon Froehlich</author>
public class TextBox : System.Windows.Forms.TextBox
{
- private Color _borderColor = Color.Black;
- private Color _selBorderColor = SystemColors.HighlightText;
- private Color _selBackColor = SystemColors.Highlight;
- private Color _selForeColor = SystemColors.HighlightText;
- private Color _disabledBackColor = Color.Gray;
- private Color _disabledForeColor = Color.DarkGray;
- private Color _disabledBorderColor = Color.DarkGray;
+ private bool _selectTextOnFocus = false;
- public TextBox()
- : base()
+ protected override void OnGotFocus(EventArgs e)
{
- this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- }
-
- #region Properties
- public Color BorderColor
- {
- get { return _borderColor; }
- set
+ if (_selectTextOnFocus)
{
- if (_borderColor != value)
- {
- _borderColor = value;
- if (!Focused && Enabled)
- {
- this.Invalidate();
- }
- }
+ this.SelectionStart = 0;
+ this.SelectionLength = this.Text.Length;
}
+ base.OnGotFocus(e);
}
- public Color SelectedBorderColor
+ public bool SelectTextOnFocus
{
- get { return _selBorderColor; }
- set
- {
- if (_selBorderColor != value)
- {
- _selBorderColor = value;
- if (Focused)
- {
- this.Invalidate();
- }
- }
- }
+ get { return _selectTextOnFocus; }
+ set { _selectTextOnFocus = value; }
}
-
- public Color SelectedBackColor
- {
- get { return _selBackColor; }
- set
- {
- if (_selBackColor != value)
- {
- _selBackColor = value;
- if (Focused)
- {
- this.Invalidate();
- }
- }
- }
- }
-
- public Color SelectedForeColor
- {
- get { return _selForeColor; }
- set
- {
- if (_selForeColor != value)
- {
- ...
[truncated message content] |