DotNet 4.8.1 build of DotNetBar

This commit is contained in:
2025-02-07 10:35:23 -05:00
parent 33439b63a0
commit 6b0a5d60f4
2609 changed files with 989814 additions and 7 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,130 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="BtnBack.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAGYktHRAD/AP8A/6C9p5MAAAC5SURBVEhL7ZNLCsIwFEWrxQ8Ff6goFGelilPnTt2Qi3AFXYbr
05GeW5KiGVWaCmICB9IS7nnvpY2isP5+Ap2fnkDr1Utg8TqpGWkXeMAY+kbUWJKQcIa7CZdgB3PoQfwB
XbeoiROs8CYoT0VV9yjjAQq4vYSfzHt1ktck41wKmkgl0GYIazjC1Ui038IKljVYcEa8dWAt6mIAU9jA
HrzdAVnlksyKRuy9fkVW4spa/+FccXgOE/jyBJ539CM3bmc40AAAAABJRU5ErkJggg==
</value>
</data>
</root>

View File

@@ -0,0 +1,381 @@
#if FRAMEWORK20
using System;
using System.Text;
using DevComponents.DotNetBar;
using System.Drawing;
using System.ComponentModel;
using System.Drawing.Drawing2D;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Represents base class for the CalendarMonth and MultiMonthCalendar controls. This class is used internally by DotNetBar and is not intended for public use.
/// </summary>
public class CalendarBase : ImageItem, IDesignTimeProvider
{
#region Private Variables
private ElementStyle _BackgroundStyle = new ElementStyle();
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the MultiMonthCalendar class.
/// </summary>
public CalendarBase()
{
m_IsContainer = true;
this.AutoCollapseOnClick = true;
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
_BackgroundStyle.StyleChanged += BackgroundStyleChanged;
}
protected override void Dispose(bool disposing)
{
_BackgroundStyle.StyleChanged -= BackgroundStyleChanged;
_BackgroundStyle.Dispose();
base.Dispose(disposing);
}
#endregion
#region Internal Implementation
/// <summary>
/// Must be overridden by class that is inheriting to provide the painting for the item.
/// </summary>
public override void Paint(ItemPaintArgs p)
{
Graphics g = p.Graphics;
Region oldClip = null;
bool clipSet = false;
PaintBackground(p);
Rectangle clip = GetClipRectangle();
oldClip = g.Clip;
g.SetClip(clip, CombineMode.Intersect);
clipSet = true;
ItemDisplay display = GetItemDisplay();
display.Paint(this, p);
if (clipSet)
{
if (oldClip != null)
g.Clip = oldClip;
else
g.ResetClip();
}
if (oldClip != null)
oldClip.Dispose();
this.DrawInsertMarker(p.Graphics);
}
protected virtual Rectangle GetClipRectangle()
{
Rectangle clip = this.DisplayRectangle;
bool disposeStyle = false;
ElementStyle style = ElementStyleDisplay.GetElementStyle(_BackgroundStyle, out disposeStyle);
clip.X += ElementStyleLayout.LeftWhiteSpace(style);
clip.Width -= ElementStyleLayout.HorizontalStyleWhiteSpace(style);
clip.Y += ElementStyleLayout.TopWhiteSpace(style);
clip.Height -= ElementStyleLayout.VerticalStyleWhiteSpace(style);
if (disposeStyle) style.Dispose();
return clip;
}
/// <summary>
/// Paints background of the item.
/// </summary>
/// <param name="p">Provides painting arguments</param>
protected virtual void PaintBackground(ItemPaintArgs p)
{
_BackgroundStyle.SetColorScheme(p.Colors);
bool disposeStyle = false;
ElementStyle style = GetRenderBackgroundStyle(out disposeStyle);
Graphics g = p.Graphics;
ElementStyleDisplay.Paint(new ElementStyleDisplayInfo(style, g, this.DisplayRectangle));
if(disposeStyle)
style.Dispose();
}
protected virtual ElementStyle GetRenderBackgroundStyle(out bool disposeStyle)
{
disposeStyle = false;
return ElementStyleDisplay.GetElementStyle(_BackgroundStyle, out disposeStyle);
}
private ItemDisplay _ItemDisplay = null;
internal ItemDisplay GetItemDisplay()
{
if (_ItemDisplay == null)
_ItemDisplay = new ItemDisplay();
return _ItemDisplay;
}
private void BackgroundStyleChanged(object sender, EventArgs e)
{
this.OnAppearanceChanged();
}
/// <summary>
/// Specifies the container background style. Default value is an empty style which means that container does not display any background.
/// BeginGroup property set to true will override this style on some styles.
/// </summary>
[Browsable(true), Category("Style"), Description("Gets or sets container background style."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ElementStyle BackgroundStyle
{
get { return _BackgroundStyle; }
}
/// <summary>
/// Returns copy of the item.
/// </summary>
public override BaseItem Copy()
{
CalendarBase objCopy = new CalendarBase();
this.CopyToItem(objCopy);
return objCopy;
}
/// <summary>
/// Copies the CalendarMonth specific properties to new instance of the item.
/// </summary>
/// <param name="c">New ButtonItem instance.</param>
protected override void CopyToItem(BaseItem c)
{
CalendarBase copy = c as CalendarBase;
copy.BackgroundStyle.ApplyStyle(_BackgroundStyle);
base.CopyToItem(copy);
}
#endregion
#region Property Hiding
/// <summary>
/// Returns name of the item that can be used to identify item from the code.
/// </summary>
[DefaultValue(""), Category("Design"), Description("Indicates the name used to identify item.")]
public override string Name
{
get
{
return base.Name;
}
set
{
base.Name = value;
}
}
/// <summary>
/// Gets or sets the accessible role of the item.
/// </summary>
[DevCoBrowsable(true), Browsable(true), Category("Accessibility"), Description("Gets or sets the accessible role of the item."), DefaultValue(System.Windows.Forms.AccessibleRole.Grouping)]
public override System.Windows.Forms.AccessibleRole AccessibleRole
{
get { return base.AccessibleRole; }
set { base.AccessibleRole = value; }
}
// <summary>
/// Gets or sets the Key Tips access key or keys for the item when on Ribbon Control or Ribbon Bar. Use KeyTips property
/// when you want to assign the one or more letters to be used to access an item. For example assigning the FN to KeyTips property
/// will require the user to press F then N keys to select an item. Pressing the F letter will show only keytips for the items that start with letter F.
/// </summary>
[Browsable(false), Category("Appearance"), DefaultValue(""), Description("Indicates the Key Tips access key or keys for the item when on Ribbon Control or Ribbon Bar.")]
public override string KeyTips
{
get { return base.KeyTips; }
set { base.KeyTips = value; }
}
/// <summary>
/// Indicates whether the item will auto-collapse (fold) when clicked.
/// When item is on popup menu and this property is set to false, menu will not
/// close when item is clicked.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.Category("Behavior"), System.ComponentModel.DefaultValue(true), System.ComponentModel.Description("Indicates whether the item will auto-collapse (fold) when clicked.")]
public override bool AutoCollapseOnClick
{
get { return base.AutoCollapseOnClick; }
set { base.AutoCollapseOnClick = value; }
}
/// <summary>
/// Gets or sets whether item can be customized by end user.
/// </summary>
[Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Indicates whether item can be customized by user.")]
public override bool CanCustomize
{
get { return base.CanCustomize; }
set { base.CanCustomize = value; }
}
/// <summary>
/// Returns category for this item. If item cannot be customzied using the
/// customize dialog category is empty string.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(""), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Indicates item category used to group similar items at design-time.")]
public override string Category
{
get { return base.Category; }
set { base.Category = value; }
}
/// <summary>
/// Gets or sets whether Click event will be auto repeated when mouse button is kept pressed over the item.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Gets or sets whether Click event will be auto repeated when mouse button is kept pressed over the item.")]
public override bool ClickAutoRepeat
{
get { return base.ClickAutoRepeat; }
set { base.ClickAutoRepeat = value; }
}
/// <summary>
/// Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(600), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.")]
public override int ClickRepeatInterval
{
get { return base.ClickRepeatInterval; }
set { base.ClickRepeatInterval = value; }
}
/// <summary>
/// Specifies the mouse cursor displayed when mouse is over the item.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(null), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies the mouse cursor displayed when mouse is over the item.")]
public override System.Windows.Forms.Cursor Cursor
{
get { return base.Cursor; }
set { base.Cursor = value; }
}
/// <summary>
/// Gets or sets item description. This description is displayed in
/// Customize dialog to describe the item function in an application.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(""), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Indicates description of the item that is displayed during design.")]
public override string Description
{
get { return base.Description; }
set { base.Description = value; }
}
/// <summary>
/// Gets or sets whether item is global or not.
/// This flag is used to propagate property changes to all items with the same name.
/// Setting for example Visible property on the item that has GlobalItem set to true will
/// set visible property to the same value on all items with the same name.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Indicates whether certain global properties are propagated to all items with the same name when changed.")]
public override bool GlobalItem
{
get { return base.GlobalItem; }
set { base.GlobalItem = value; }
}
/// <summary>
/// Gets or sets item alignment inside the container.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(DevComponents.DotNetBar.eItemAlignment.Near), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Determines alignment of the item inside the container.")]
public override DevComponents.DotNetBar.eItemAlignment ItemAlignment
{
get { return base.ItemAlignment; }
set { base.ItemAlignment = value; }
}
/// <summary>
/// Gets or sets the collection of shortcut keys associated with the item.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Indicates list of shortcut keys for this item."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ShortcutsDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter("DevComponents.DotNetBar.Design.ShortcutsConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
public override ShortcutsCollection Shortcuts
{
get { return base.Shortcuts; }
set { base.Shortcuts = value; }
}
/// <summary>
/// Gets or sets whether item will display sub items.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Determines whether sub-items are displayed.")]
public override bool ShowSubItems
{
get { return base.ShowSubItems; }
set { base.ShowSubItems = value; }
}
/// <summary>
/// Gets or sets whether the item expands automatically to fill out the remaining space inside the container. Applies to Items on stretchable, no-wrap Bars only.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates whether item will stretch to consume empty space. Items on stretchable, no-wrap Bars only.")]
public override bool Stretch
{
get { return base.Stretch; }
set { base.Stretch = value; }
}
/// <summary>
/// Specifies whether item is drawn using Themes when running on OS that supports themes like Windows XP.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies whether item is drawn using Themes when running on OS that supports themes like Windows XP.")]
public override bool ThemeAware
{
get { return base.ThemeAware; }
set { base.ThemeAware = value; }
}
/// <summary>
/// Gets/Sets informational text (tooltip) for the item.
/// </summary>
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(""), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates the text that is displayed when mouse hovers over the item."), System.ComponentModel.Localizable(true)]
public override string Tooltip
{
get { return base.Tooltip; }
set { base.Tooltip = value; }
}
/// <summary>
/// Gets or sets the text associated with this item.
/// </summary>
[Browsable(false)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
#endregion
#region IDesignTimeProvider Implementation
protected virtual InsertPosition GetContainerInsertPosition(Point pScreen, BaseItem dragItem)
{
return DesignTimeProviderContainer.GetInsertPosition(this, pScreen, dragItem);
}
InsertPosition IDesignTimeProvider.GetInsertPosition(Point pScreen, BaseItem dragItem)
{
return GetContainerInsertPosition(pScreen, dragItem);
}
void IDesignTimeProvider.DrawReversibleMarker(int iPos, bool Before)
{
DesignTimeProviderContainer.DrawReversibleMarker(this, iPos, Before);
}
void IDesignTimeProvider.InsertItemAt(BaseItem objItem, int iPos, bool Before)
{
DesignTimeProviderContainer.InsertItemAt(this, objItem, iPos, Before);
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,253 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Defines the visual marking applied to dates through month calendar control.
/// </summary>
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class DateAppearanceDescription
{
#region Private Variables
private BaseItem _Parent = null;
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the DateAppearanceDescription class.
/// </summary>
public DateAppearanceDescription()
{
}
/// <summary>
/// Initializes a new instance of the DateAppearanceDescription class.
/// </summary>
/// <param name="parent"></param>
public DateAppearanceDescription(BaseItem parent)
{
_Parent = parent;
}
#endregion
#region Internal Implementation
/// <summary>
/// Applies all settings from this object to specified object.
/// </summary>
/// <param name="desc">Reference to object.</param>
public void ApplyTo(DateAppearanceDescription desc)
{
desc.BackColor = this.BackColor;
desc.BackColor2 = this.BackColor2;
desc.BackColorGradientAngle = this.BackColorGradientAngle;
desc.BorderColor = this.BorderColor;
desc.IsBold = this.IsBold;
desc.Selectable = this.Selectable;
desc.TextColor = this.TextColor;
}
private void Refresh()
{
if (_Parent != null)
_Parent.Refresh();
}
private bool _IsBold = false;
/// <summary>
/// Gets or sets whether text is drawn using bold font.
/// </summary>
[DefaultValue(false), Description("Indicates whether text is drawn using bold font.")]
public bool IsBold
{
get { return _IsBold; }
set
{
if (_IsBold != value)
{
_IsBold = value;
this.Refresh();
}
}
}
private Color _BackColor = Color.Empty;
/// <summary>
/// Gets or sets the background color for the marked day.
/// </summary>
[Category("Colors"), Description("Indicates background color for the marked day.")]
public Color BackColor
{
get { return _BackColor; }
set
{
_BackColor = value;
this.Refresh();
}
}
/// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeBackColor()
{
return !BackColor.IsEmpty;
}
/// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetBackColor()
{
BackColor = Color.Empty;
}
private Color _BackColor2 = Color.Empty;
/// <summary>
/// Gets or sets the background target gradient color for the marked date.
/// </summary>
[Category("Colors"), Description("Indicates background target gradient color for the marked date.")]
public Color BackColor2
{
get { return _BackColor2; }
set
{
_BackColor2 = value;
this.Refresh();
}
}
/// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeBackColor2()
{
return !BackColor2.IsEmpty;
}
/// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetBackColor2()
{
BackColor2 = Color.Empty;
}
private int _BackColorGradientAngle = 90;
/// <summary>
/// Gets or sets the background gradient fill angle. Default value is 90.
/// </summary>
[DefaultValue(90), Description("Indicates background gradient fill angle.")]
public int BackColorGradientAngle
{
get { return _BackColorGradientAngle; }
set
{
if (_BackColorGradientAngle != value)
{
_BackColorGradientAngle = value;
this.Refresh();
}
}
}
private Color _TextColor = Color.Empty;
/// <summary>
/// Gets or sets the text color for the marked date.
/// </summary>
[Category("Colors"), Description("Indicates text color for the marked date.")]
public Color TextColor
{
get { return _TextColor; }
set
{
_TextColor = value;
this.Refresh();
}
}
/// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeTextColor()
{
return !TextColor.IsEmpty;
}
/// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetTextColor()
{
TextColor = Color.Empty;
}
/// <summary>
/// Gets whether any of the appearance values have been changed.
/// </summary>
[Browsable(false)]
public bool IsCustomized
{
get
{
return !_BackColor.IsEmpty || !_BackColor2.IsEmpty || !_TextColor.IsEmpty || _IsBold || !_BorderColor.IsEmpty;
}
}
internal BaseItem Parent
{
get { return _Parent; }
set
{
if (_Parent != value)
{
_Parent = value;
}
}
}
private Color _BorderColor = Color.Empty;
/// <summary>
/// Gets or sets the border color.
/// </summary>
[Category("Colors"), Description("Indicates borderColor color.")]
public Color BorderColor
{
get { return _BorderColor; }
set
{
_BorderColor = value;
this.Refresh();
}
}
/// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeBorderColor()
{
return !BorderColor.IsEmpty;
}
/// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetBorderColor()
{
BorderColor = Color.Empty;
}
private bool _Selectable = true;
/// <summary>
/// Gets or sets whether day marked is selectable by end user. Default value is true.
/// </summary>
[DefaultValue(true), Description("Indicates whether day marked is selectable by end user.")]
public bool Selectable
{
get { return _Selectable; }
set
{
if (_Selectable != value)
{
_Selectable = value;
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,788 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Globalization;
namespace DevComponents.Editors.DateTimeAdv
{
public class DateTimeGroup : VisualInputGroup
{
#region Private Variables
private IDateTimePartInput _DayInput = null;
private IDateTimePartInput _MonthInput = null;
private IDateTimePartInput _YearInput = null;
private IDateTimePartInput _HourInput = null;
private IDateTimePartInput _MinuteInput = null;
private IDateTimePartInput _SecondInput = null;
private IDateTimePartInput _DayOfYearInput = null;
/// <summary>
/// Gets the minimum date value of the DateTimePicker control.
/// </summary>
public static readonly System.DateTime MinDateTime = new System.DateTime(1753, 1, 1);
/// <summary>
/// Specifies the maximum date value of the DateTimePicker control. This field is read-only.
/// </summary>
public static readonly System.DateTime MaxDateTime = new System.DateTime(9998, 12, 31);
#endregion
#region Events
/// <summary>
/// Occurs when Value or IsEmpty property has changed.
/// </summary>
public event EventHandler ValueChanged;
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override void OnItemsCollectionChanged(CollectionChangedInfo collectionChangedInfo)
{
if (collectionChangedInfo.ChangeType == eCollectionChangeType.Cleared)
{
_DayInput = null;
_MonthInput = null;
_YearInput = null;
_HourInput = null;
_MinuteInput = null;
_SecondInput = null;
_DayOfYearInput = null;
}
if (collectionChangedInfo.Removed != null)
{
foreach (VisualItem item in collectionChangedInfo.Removed)
{
if (item == _DayInput)
_DayInput = null;
else if (item == _MonthInput)
_MonthInput = null;
else if (item == _YearInput)
_YearInput = null;
else if (item == _HourInput)
_HourInput = null;
else if (item == _MinuteInput)
_MinuteInput = null;
else if (item == _SecondInput)
_SecondInput = null;
else if (item == _DayOfYearInput)
_DayOfYearInput = null;
}
}
if (collectionChangedInfo.Added != null)
{
List<VisualItem> hourLabels = new List<VisualItem>();
foreach (VisualItem item in collectionChangedInfo.Added)
{
if (item is HourPeriodLabel)
{
if (_HourInput != null && _HourInput is NumericHourInput)
((HourPeriodLabel)item).HourInput = (NumericHourInput)_HourInput;
}
else if (item is HourPeriodInput)
{
if (_HourInput != null && _HourInput is NumericHourInput)
((HourPeriodInput)item).HourInput = (NumericHourInput)_HourInput;
}
IDateTimePartInput idp = item as IDateTimePartInput;
if (idp == null)
continue;
if (idp.Part == eDateTimePart.Day)
_DayInput = idp;
else if (idp.Part == eDateTimePart.Hour)
{
_HourInput = idp;
if (_HourInput is NumericHourInput)
{
foreach (VisualItem vi in this.Items)
{
if (vi is HourPeriodLabel)
((HourPeriodLabel)vi).HourInput = (NumericHourInput)_HourInput;
else if (vi is HourPeriodInput)
((HourPeriodInput)vi).HourInput = (NumericHourInput)_HourInput;
}
}
}
else if (idp.Part == eDateTimePart.Minute)
_MinuteInput = idp;
else if (idp.Part == eDateTimePart.Month)
_MonthInput = idp;
else if (idp.Part == eDateTimePart.Second)
_SecondInput = idp;
else if (idp.Part == eDateTimePart.Year)
_YearInput = idp;
else if (idp.Part == eDateTimePart.DayOfYear)
_DayOfYearInput = idp;
}
}
UpdateInnerDateTimeGroupMinMax();
UpdateInputItems();
base.OnItemsCollectionChanged(collectionChangedInfo);
}
private bool _ProcessingInputChanged = false;
protected override void OnInputChanged(VisualInputBase input)
{
if (!_ProcessingInputChanged && !_ResettingDateValue)
{
try
{
_ProcessingInputChanged = true;
if (input == _MonthInput || input == _YearInput)
{
if (_DayInput != null)
{
// Assign day min max values
UpdateDayMaxValue();
}
}
if (input == _YearInput && _DayOfYearInput != null)
UpdateDayOfYearMaxValue();
if (input != _YearInput && _YearInput != null && _YearInput.IsEmpty && _DefaultInputValues)
_YearInput.Value = Math.Min(System.DateTime.Now.Year, _MaxDate.Year);
if (input != _MonthInput && _MonthInput != null && _MonthInput.IsEmpty)
{
if (_DefaultInputValues)
{
if (_YearInput != null && _YearInput.Value == _MaxDate.Year)
_MonthInput.Value = _MaxDate.Month;
else
_MonthInput.Value = System.DateTime.Now.Month;
}
// Assign day min max values
UpdateDayMaxValue();
}
if (input != _DayInput && _DayInput != null && _DayInput.IsEmpty && _DefaultInputValues)
{
if (_YearInput != null && _YearInput.Value == _MaxDate.Year && _MonthInput != null && _MonthInput.Value == _MaxDate.Month)
_DayInput.Value = _MaxDate.Day;
else
_DayInput.Value = System.DateTime.Now.Day;
}
if (input != _HourInput && _HourInput != null && _HourInput.IsEmpty && _DefaultInputValues)
{
_HourInput.Value = 0; // System.DateTime.Now.Hour;
}
if (input != _MinuteInput && _MinuteInput != null && _MinuteInput.IsEmpty && _DefaultInputValues)
{
_MinuteInput.Value = 0; // System.DateTime.Now.Minute;
}
if (input != _SecondInput && _SecondInput != null && _SecondInput.IsEmpty && _DefaultInputValues)
{
_SecondInput.Value = 0;
}
// Reset empty flag
if (_YearInput != null && !_YearInput.IsEmpty || _MonthInput != null && !_MonthInput.IsEmpty || _DayInput != null && !_DayInput.IsEmpty
|| _HourInput != null && !_HourInput.IsEmpty || _MinuteInput != null && !_MinuteInput.IsEmpty || _SecondInput != null && !_SecondInput.IsEmpty)
this.IsEmpty = false;
SyncValues(input);
}
finally
{
_ProcessingInputChanged = false;
}
if (IsUserInput && IsCurrentInputValid()) OnValueChanged();
}
base.OnInputChanged(input);
}
private void UpdateDayOfYearMaxValue()
{
if (_YearInput != null && !_YearInput.IsEmpty && _DayOfYearInput != null)
{
_DayOfYearInput.MaxValue = DateTimeInput.GetActiveCulture().Calendar.GetDaysInYear(_YearInput.Value);
}
}
protected override void OnFocusedItemChanged(VisualItem previousFocus)
{
if (this.FocusedItem == _DayInput && _DayInput is NumericDayInput)
{
UpdateDayMaxValue();
}
else if (previousFocus == _YearInput || previousFocus == _DayInput)
{
UpdateDayMaxValue();
}
else
{
SyncValues(previousFocus);
}
base.OnFocusedItemChanged(previousFocus);
}
private void UpdateDayMaxValue()
{
if (_DayInput != null && (this.FocusedItem == _DayInput || this.FocusedItem == _MonthInput) && _DayInput is NumericDayInput)
_DayInput.MaxValue = 31;
else if (_YearInput != null && _MonthInput != null && !_MonthInput.IsEmpty && _DayInput != null)
{
// Assign day min max values
_DayInput.MaxValue = System.DateTime.DaysInMonth(_YearInput.IsEmpty ? System.DateTime.Now.Year : _YearInput.Value, _MonthInput.Value);
}
}
protected override void OnInputComplete()
{
SyncValues(this.FocusedItem);
base.OnInputComplete();
}
//private bool _Validating = false;
//protected override bool ValidateInput(VisualItem inputItem)
//{
// if (!_Validating && inputItem is IDateTimePartInput && !this.IsEmpty)
// {
// IDateTimePartInput input = (IDateTimePartInput)inputItem;
// System.DateTime v = GetCurrentInputValue();
// if (v < _MinDate || v > _MaxDate)
// {
// try
// {
// _Validating = true;
// input.UndoInput();
// }
// finally
// {
// _Validating = false;
// }
// return false;
// }
// }
// return base.ValidateInput(inputItem);
//}
private void SyncValues(VisualItem visualItem)
{
IDateTimePartInput inputPart = visualItem as IDateTimePartInput;
if (inputPart == null)
return;
for (int i = 0; i < this.Items.Count; i++)
{
IDateTimePartInput part = this.Items[i] as IDateTimePartInput;
if (part == null) continue;
if (part.Part == inputPart.Part && part != inputPart)
part.Value = inputPart.Value;
else if (part != inputPart && inputPart.Part == eDateTimePart.DayOfYear && (part.Part == eDateTimePart.Day || part.Part == eDateTimePart.Month))
{
if (_YearInput != null && !_YearInput.IsEmpty)
{
System.DateTime d = CreateDateTime(_YearInput.Value, inputPart.Value);
if (part.Part == eDateTimePart.Day)
part.Value = d.Day;
else if (part.Part == eDateTimePart.Month)
part.Value = d.Month;
}
}
else if (part.Part == eDateTimePart.DayName)
{
if (_YearInput != null && !_YearInput.IsEmpty &&
(_MonthInput != null && !_MonthInput.IsEmpty && _DayInput != null && !_DayInput.IsEmpty ||
_DayOfYearInput != null && !_DayOfYearInput.IsEmpty))
{
try
{
System.DateTime date;
if (_DayOfYearInput != null)
date = CreateDateTime(_YearInput.Value, _DayOfYearInput.Value);
else
date = new System.DateTime(_YearInput.Value, _MonthInput.Value, _DayInput.Value);
part.Value = (int)date.DayOfWeek;
}
catch
{
part.IsEmpty = true;
}
}
else
part.IsEmpty = true;
}
}
}
internal static System.DateTime CreateDateTime(int year, int dayOfYear)
{
System.DateTime d = new System.DateTime(year, 1, 1);
if (dayOfYear > 0)
{
d.AddDays(dayOfYear - 1);
}
return d;
}
protected override void OnLostFocus()
{
UpdateValue(false);
base.OnLostFocus();
}
protected override void OnGroupInputComplete()
{
UpdateValue(false);
base.OnGroupInputComplete();
}
protected internal void UpdateValue(bool updateDirect)
{
// Validate Complete Input
System.DateTime v = System.DateTime.Now;
if (_YearInput != null && _YearInput.IsEmpty || _MonthInput != null && _MonthInput.IsEmpty ||
_DayInput != null && _DayInput.IsEmpty || _HourInput != null && _HourInput.IsEmpty ||
_MinuteInput != null && _MinuteInput.IsEmpty || _SecondInput != null && _SecondInput.IsEmpty)
{
if (HasNestedGroups)
UpdateIsEmpty();
else
{
if (!this.IsFocused || _DefaultInputValues)
this.IsEmpty = true;
}
}
else
{
v = GetCurrentInputValue();
if (v > _MaxDate)
v = _MaxDate;
else if (v < _MinDate)
v = _MinDate;
if (updateDirect)
_Value = v;
else
Value = v;
}
}
private bool IsCurrentInputValid()
{
DateTime d = GetCurrentInputValue();
if (d < _MinDate || d > _MaxDate) return false;
return true;
}
private bool HasNestedGroups
{
get
{
foreach (VisualItem item in this.Items)
{
if (item is VisualGroup)
return true;
}
return false;
}
}
private System.DateTime GetCurrentInputValue()
{
System.DateTime v = System.DateTime.Now;
if (_Value != DateTime.MinValue) v = _Value;
if (v < _MinDate)
v = _MinDate;
else if (v > _MaxDate)
v = _MaxDate;
int year = v.Year, month = v.Month, day = v.Day, hour = v.Hour, minute = v.Minute, second = v.Second, dayOfYear = v.DayOfYear;
if (_YearInput != null)
{
year = _YearInput.Value;
if (year < 30)
year += 2000;
else if (year < 100)
year += 1900;
}
else if (_Value != DateTime.MinValue)
year = _Value.Year;
if (_MonthInput != null)
month = _MonthInput.Value;
else if (_Value != DateTime.MinValue)
month = _Value.Month;
if (_DayInput != null)
{
day = _DayInput.Value;
if (_YearInput != null && _MonthInput != null)
day = Math.Min(day, System.DateTime.DaysInMonth(_YearInput.IsEmpty ? System.DateTime.Now.Year : _YearInput.Value, _MonthInput.Value));
}
else if (_Value != DateTime.MinValue)
day = _Value.Day;
if (_HourInput != null)
{
hour = _HourInput.Value;
if (hour == 12 && _HourInput is NumericHourInput && ((NumericHourInput)_HourInput).Period == eHourPeriod.AM && !((NumericHourInput)_HourInput).Is24HourFormat)
hour = 0;
else if (hour < 12 && _HourInput is NumericHourInput && ((NumericHourInput)_HourInput).Period == eHourPeriod.PM && !((NumericHourInput)_HourInput).Is24HourFormat)
{
hour += 12;
}
}
else if (_Value != DateTime.MinValue)
hour = _Value.Hour;
if (_MinuteInput != null)
minute = _MinuteInput.Value;
else if (_Value != DateTime.MinValue)
minute = _Value.Minute;
if (_SecondInput != null)
second = _SecondInput.Value;
else if (_Value != DateTime.MinValue)
second = _Value.Second;
else
second = 0;
if (_DayOfYearInput != null)
{
dayOfYear = _DayOfYearInput.Value;
if (dayOfYear > 0)
{
System.DateTime d = CreateDateTime(year, dayOfYear);
month = d.Month;
day = d.Day;
}
}
// Correct day for leap year etc. case
if (System.DateTime.DaysInMonth(year, month) < day)
day = System.DateTime.DaysInMonth(year, month);
if (_HourInput != null || _MinuteInput != null || _SecondInput != null || _Value != DateTime.MinValue)
v = new System.DateTime(year, month, day, hour, minute, second);
else
v = new System.DateTime(year, month, day);
return v;
}
private System.DateTime _Value;
/// <summary>
/// Gets or sets the date time.
/// </summary>
public System.DateTime Value
{
get
{
if (this.IsFocused) this.UpdateValue(true);
return _Value;
}
set
{
bool changed = _Value != value;
_Value = value;
this.IsEmpty = false;
UpdateInputItems();
if(changed)
OnValueChanged();
}
}
private bool _InValueChanged = false;
/// <summary>
/// Raises the ValueChanged event.
/// </summary>
protected virtual void OnValueChanged()
{
if (_InValueChanged) return;
try
{
_InValueChanged = true;
if (ValueChanged != null)
ValueChanged(this, new EventArgs());
if (this.Parent is DateTimeGroup)
((DateTimeGroup)this.Parent).OnValueChanged();
this.InvalidateArrange();
}
finally
{
_InValueChanged = false;
}
}
/// <summary>
/// Gets or sets the values of the nested DateTimeGroup items.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public System.DateTime[] Values
{
get
{
if (HasNestedGroups)
{
List<System.DateTime> dates = new List<System.DateTime>();
foreach (VisualItem item in this.Items)
{
DateTimeGroup group = item as DateTimeGroup;
if (group != null)
{
dates.Add(group.Value);
}
}
return dates.ToArray();
}
return new System.DateTime[] { this.Value };
}
set
{
if (value == null || value.Length == 0) return;
if (HasNestedGroups)
{
int i = 0;
foreach (VisualItem item in this.Items)
{
DateTimeGroup group = item as DateTimeGroup;
if (group != null)
{
group.Value = value[i];
i++;
if (i >= value.Length) break;
}
}
}
else
this.Value = value[0];
}
}
private void UpdateInputItems()
{
System.DateTime d = _Value;
if (_YearInput != null)
{
if (this.IsEmpty)
_YearInput.IsEmpty = true;
else
_YearInput.Value = d.Year;
}
if (_MonthInput != null)
{
if (this.IsEmpty)
_MonthInput.IsEmpty = true;
else
_MonthInput.Value = d.Month;
}
if (_DayInput != null)
{
if (this.IsEmpty)
_DayInput.IsEmpty = true;
else if (!(this.FocusedItem == _DayInput && _DayInput is NumericDayInput && _ProcessingInputChanged))
_DayInput.Value = d.Day;
}
if (_HourInput != null)
{
if (this.IsEmpty)
_HourInput.IsEmpty = true;
else
{
if (_HourInput is NumericHourInput)
((NumericHourInput)_HourInput).Period = eHourPeriod.AM;
_HourInput.Value = d.Hour;
if (_HourInput is NumericHourInput && !((NumericHourInput)_HourInput).Is24HourFormat && d.Hour >= 12)
((NumericHourInput)_HourInput).Period = eHourPeriod.PM;
}
}
if (_MinuteInput != null)
{
if (this.IsEmpty)
_MinuteInput.IsEmpty = true;
else
_MinuteInput.Value = d.Minute;
}
if (_SecondInput != null)
{
if (this.IsEmpty)
_SecondInput.IsEmpty = true;
else
_SecondInput.Value = d.Second;
}
for (int i = 0; i < this.Items.Count; i++)
{
IDateTimePartInput part = this.Items[i] as IDateTimePartInput;
if (part == null) continue;
if (part.Part == eDateTimePart.DayName)
part.Value = this.IsEmpty ? -1 : (int)_Value.DayOfWeek;
else if (part.Part == eDateTimePart.DayOfYear)
{
if (this.IsEmpty)
part.IsEmpty = true;
else
part.Value = _Value.DayOfYear;
}
}
InvalidateArrange();
}
private bool _ResettingDateValue = false;
protected override void ResetValue()
{
_ResettingDateValue = true;
try
{
if (this.AllowEmptyState)
{
if (_DayInput != null) _DayInput.IsEmpty = true;
if (_MonthInput != null) _MonthInput.IsEmpty = true;
if (_YearInput != null) _YearInput.IsEmpty = true;
if (_HourInput != null) _HourInput.IsEmpty = true;
if (_MinuteInput != null) _MinuteInput.IsEmpty = true;
if (_SecondInput != null) _SecondInput.IsEmpty = true;
foreach (VisualItem item in this.Items)
{
if (item is DateTimeGroup)
((DateTimeGroup)item).IsEmpty = true;
else if (item is IDateTimePartInput && !((IDateTimePartInput)item).IsEmpty)
((IDateTimePartInput)item).IsEmpty = true;
}
_Value = DateTime.MinValue;
}
else
{
SetNonEmptyValue();
}
}
finally
{
_ResettingDateValue = false;
}
OnValueChanged();
}
private System.DateTime _MinDate = MinDateTime;
/// <summary>
/// Gets or sets the minimum value represented by the group.
/// </summary>
public System.DateTime MinDate
{
get { return _MinDate; }
set { _MinDate = value; OnMinDateChanged(); }
}
private void OnMinDateChanged()
{
UpdateInnerDateTimeGroupMinMax();
}
private System.DateTime _MaxDate = MaxDateTime;
/// <summary>
/// Gets or sets maximum value represented by the group.
/// </summary>
public System.DateTime MaxDate
{
get { return _MaxDate; }
set { _MaxDate = value; OnMaxDateChanged(); }
}
private void OnMaxDateChanged()
{
UpdateInnerDateTimeGroupMinMax();
}
private void UpdateInnerDateTimeGroupMinMax()
{
foreach (VisualItem item in this.Items)
{
DateTimeGroup dg = item as DateTimeGroup;
if (dg != null)
{
dg.MinDate = _MinDate;
dg.MaxDate = _MaxDate;
}
}
}
protected override void OnAllowEmptyStateChanged()
{
if (!this.AllowEmptyState && this.IsEmpty)
{
SetNonEmptyValue();
}
base.OnAllowEmptyStateChanged();
}
private void SetNonEmptyValue()
{
if (this.MinDate > MinDateTime)
this.Value = this.MinDate;
else
this.Value = DateTime.Now;
}
internal override void ProcessKeyDown(System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode != System.Windows.Forms.Keys.Back && e.KeyCode != System.Windows.Forms.Keys.Delete)
IsUserInput = true;
base.ProcessKeyDown(e);
IsUserInput = false;
}
internal override void ProcessKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
IsUserInput = true;
base.ProcessKeyPress(e);
IsUserInput = false;
}
internal override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
IsUserInput = true;
bool b = base.ProcessCmdKey(ref msg, keyData);
IsUserInput = false;
return b;
}
internal override void ProcessMouseWheel(System.Windows.Forms.MouseEventArgs e)
{
IsUserInput = true;
base.ProcessMouseWheel(e);
IsUserInput = false;
}
private bool _DefaultInputValues = true;
/// <summary>
/// Gets or sets whether input values are set to defaults while user is entering data. Default value is true.
/// </summary>
public bool DefaultInputValues
{
get { return _DefaultInputValues; }
set
{
_DefaultInputValues = value;
}
}
#endregion
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,160 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.ComponentModel;
namespace DevComponents.Editors.DateTimeAdv
{
public class DayLabelItem : VisualLabel, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
private int _Day = -1;
/// <summary>
/// Gets or sets the day in numeric format to display. Allowed values are from -1 to 6. -1 represents an empty state.
/// 0 represents Sunday and 6 Represents Saturday.
/// </summary>
[DefaultValue(-1)]
public int Day
{
get { return _Day; }
set
{
if (_Day != value)
{
if (_Day < -1 || _Day > 6)
throw new ArgumentException("Day must be value between -1 and 6");
_Day = value;
OnDayChanged();
}
}
}
private void OnDayChanged()
{
UpdateLabelText();
}
private void UpdateLabelText()
{
if (_Day == -1)
Text = "";
else if (_DayNames != null)
Text = _DayNames[_Day];
else if (_UseAbbreviatedNames)
Text = DateTimeInput.GetActiveCulture().DateTimeFormat.AbbreviatedDayNames[_Day];
else
Text = DateTimeInput.GetActiveCulture().DateTimeFormat.DayNames[_Day];
}
private List<string> _DayNames = null;
/// <summary>
/// Gets or sets the array of custom names for days. The array must have exactly 7 elements representing day names from 0 to 6.
/// </summary>
public List<string> DayNames
{
get { return _DayNames; }
set
{
if (value != null && value.Count != 7)
throw new ArgumentException("DayNames must have exactly 7 items in collection.");
_DayNames = value;
}
}
private bool _UseAbbreviatedNames = false;
/// <summary>
/// Gets or sets whether abbreviated day names are used for display instead of full day names. Default value is false.
/// </summary>
[DefaultValue(false)]
public bool UseAbbreviatedNames
{
get { return _UseAbbreviatedNames; }
set
{
if (_UseAbbreviatedNames != value)
{
_UseAbbreviatedNames = value;
UpdateLabelText();
}
}
}
#endregion
#region IDateTimePartInput Members
int IDateTimePartInput.Value
{
get
{
return _Day;
}
set
{
Day = value;
}
}
int IDateTimePartInput.MinValue
{
get
{
return 0;
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
int IDateTimePartInput.MaxValue
{
get
{
return 6;
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.DayName; }
}
bool IDateTimePartInput.IsEmpty
{
get
{
return _Day == -1;
}
set
{
this.Day = -1;
}
}
void IDateTimePartInput.UndoInput()
{
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,970 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Data;
using System.Drawing;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Rendering;
namespace DevComponents.Editors.DateTimeAdv
{
public class DayLabel : PopupItem
{
#region Private Variables
private ElementStyle _BackgroundStyle = new ElementStyle();
private Rectangle _ImageRenderBounds = Rectangle.Empty;
#endregion
#region Events
/// <summary>
/// Occurs when label is rendered and it allows you to override default rendering.
/// </summary>
public event DayPaintEventHandler PaintLabel;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the DayLabel class.
/// </summary>
public DayLabel()
{
_BackgroundStyle.StyleChanged += new EventHandler(BackgroundStyleChanged);
MouseUpNotification = true;
}
protected override void Dispose(bool disposing)
{
if (BarUtilities.DisposeItemImages && !this.DesignMode)
{
BarUtilities.DisposeImage(ref _Image);
}
_BackgroundStyle.StyleChanged -= BackgroundStyleChanged;
_BackgroundStyle.Dispose();
base.Dispose(disposing);
}
#endregion
#region Internal Implementation
public override void Paint(ItemPaintArgs p)
{
DayPaintEventArgs e = new DayPaintEventArgs(p, this);
OnPaintLabel(e);
if (e.RenderParts == eDayPaintParts.None) return;
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null)
{
month.OnPaintLabel(this, e);
}
if (e.RenderParts == eDayPaintParts.None) return;
if (this.Enabled && (e.RenderParts & eDayPaintParts.Background) == eDayPaintParts.Background)
PaintBackground(p);
if ((e.RenderParts & eDayPaintParts.Text) == eDayPaintParts.Text)
PaintText(p, null, Color.Empty, _TextAlign);
if ((e.RenderParts & eDayPaintParts.Image) == eDayPaintParts.Image)
PaintImage(p, _Image, _ImageAlign);
}
internal void PaintImage(ItemPaintArgs p, Image image, eLabelPartAlignment imageAlign)
{
if (image == null) return;
Graphics g = p.Graphics;
Rectangle imageRect = GetAlignedRect(this.DisplayRectangle, image.Size, imageAlign);
CompositeImage ci = new CompositeImage(image, false);
ci.DrawImage(g, imageRect);
ci.Dispose();
_ImageRenderBounds = imageRect;
}
private Rectangle GetAlignedRect(Rectangle bounds, Size innerSize, eLabelPartAlignment partAlign)
{
Rectangle innerRect = new Rectangle(bounds.Right - innerSize.Width, bounds.Y, innerSize.Width, innerSize.Height);
if (partAlign == eLabelPartAlignment.BottomCenter)
innerRect.Location = new Point(bounds.X + (bounds.Width - innerSize.Width) / 2, bounds.Bottom - innerSize.Height);
else if (partAlign == eLabelPartAlignment.BottomLeft)
innerRect.Location = new Point(bounds.X, bounds.Bottom - innerSize.Height);
else if (partAlign == eLabelPartAlignment.BottomRight)
innerRect.Location = new Point(bounds.Right - innerSize.Width, bounds.Bottom - innerSize.Height);
else if (partAlign == eLabelPartAlignment.MiddleCenter)
innerRect.Location = new Point(bounds.X + (bounds.Width - innerSize.Width) / 2, bounds.Y + (bounds.Height - innerSize.Height) / 2);
else if (partAlign == eLabelPartAlignment.MiddleLeft)
innerRect.Location = new Point(bounds.X, bounds.Y + (bounds.Height - innerSize.Height) / 2);
else if (partAlign == eLabelPartAlignment.MiddleRight)
innerRect.Location = new Point(bounds.Right - innerSize.Width, bounds.Y + (bounds.Height - innerSize.Height) / 2);
else if (partAlign == eLabelPartAlignment.TopCenter)
innerRect.Location = new Point(bounds.X + (bounds.Width - innerSize.Width) / 2, bounds.Y);
else if (partAlign == eLabelPartAlignment.TopLeft)
innerRect.Location = new Point(bounds.X, bounds.Y);
return innerRect;
}
/// <summary>
/// Raises the PaintLabel event.
/// </summary>
/// <param name="e">Provides event data.</param>
protected virtual void OnPaintLabel(DayPaintEventArgs e)
{
if (PaintLabel != null)
PaintLabel(this, e);
}
internal void PaintBackground(ItemPaintArgs p)
{
Graphics g = p.Graphics;
Rectangle r = this.DisplayRectangle;
Color backColor = Color.Empty, backColor2 = Color.Empty, borderColor = Color.Empty;
if (_BackgroundStyle.Custom && (!this.IsMouseOver && !this.IsMouseDown || !_TrackMouse))
{
_BackgroundStyle.SetColorScheme(p.Colors);
bool disposeStyle = false;
ElementStyle style = ElementStyleDisplay.GetElementStyle(_BackgroundStyle, out disposeStyle);
ElementStyleDisplay.Paint(new ElementStyleDisplayInfo(style, g, r));
if(disposeStyle) style.Dispose();
}
bool customColors = false;
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
MonthCalendarColors colors = null;
if (month != null) colors = month.GetColors();
if (this.IsMouseDown && _TrackMouse)
{
backColor = p.Colors.ItemPressedBackground;
backColor2 = p.Colors.ItemPressedBackground2;
borderColor = p.Colors.ItemPressedBorder;
}
else if (this.IsMouseOver && _TrackMouse)
{
backColor = p.Colors.ItemHotBackground;
backColor2 = p.Colors.ItemHotBackground2;
borderColor = p.Colors.ItemHotBorder;
}
else if (this.IsSelected)
{
backColor = p.Colors.ItemCheckedBackground;
if (colors != null && colors.Selection.IsCustomized)
{
if (!colors.Selection.BackColor.IsEmpty)
{
backColor = colors.Selection.BackColor;
if (!colors.Selection.BackColor2.IsEmpty)
backColor2 = colors.Selection.BackColor2;
}
if (!colors.Selection.BorderColor.IsEmpty)
borderColor = colors.Selection.BorderColor;
customColors = true;
}
}
else if (_IsToday)
{
borderColor = p.Colors.ItemCheckedBorder;
if (colors != null && colors.Today.IsCustomized)
{
if (!colors.Today.BorderColor.IsEmpty)
borderColor = colors.Today.BorderColor;
if (!colors.Today.BackColor.IsEmpty)
{
backColor = colors.Today.BackColor;
if (!colors.Today.BackColor2.IsEmpty)
backColor2 = colors.Today.BackColor2;
}
customColors = true;
}
}
else if (this.IsWeekOfYear)
{
backColor = Color.LightGray;
if (colors != null && colors.WeekOfYear.IsCustomized)
{
if (!colors.WeekOfYear.BorderColor.IsEmpty)
borderColor = colors.WeekOfYear.BorderColor;
if (!colors.WeekOfYear.BackColor.IsEmpty)
{
backColor = colors.WeekOfYear.BackColor;
if (!colors.WeekOfYear.BackColor2.IsEmpty)
backColor2 = colors.WeekOfYear.BackColor2;
}
customColors = true;
}
}
else if (this.IsTrailing)
{
if (colors != null && colors.TrailingDay.IsCustomized)
{
if (!colors.TrailingDay.BackColor.IsEmpty)
{
backColor = colors.TrailingDay.BackColor;
if (!colors.TrailingDay.BackColor2.IsEmpty)
backColor2 = colors.TrailingDay.BackColor2;
}
if (!colors.TrailingDay.BorderColor.IsEmpty)
borderColor = colors.TrailingDay.BorderColor;
customColors = true;
}
if (IsWeekend(Date) && colors != null && colors.TrailingWeekend.IsCustomized)
{
if (!colors.TrailingWeekend.BackColor.IsEmpty)
{
backColor = colors.TrailingWeekend.BackColor;
if (!colors.TrailingWeekend.BackColor2.IsEmpty)
backColor2 = colors.TrailingWeekend.BackColor2;
}
if (!colors.TrailingWeekend.BorderColor.IsEmpty)
borderColor = colors.TrailingWeekend.BorderColor;
customColors = true;
}
}
else if (this.IsDayLabel)
{
if (colors != null && colors.DayLabel.IsCustomized)
{
if (!colors.DayLabel.BackColor.IsEmpty)
{
backColor = colors.DayLabel.BackColor;
if (!colors.DayLabel.BackColor2.IsEmpty)
backColor2 = colors.DayLabel.BackColor2;
}
if (!colors.DayLabel.BorderColor.IsEmpty)
borderColor = colors.DayLabel.BorderColor;
customColors = true;
}
}
else if (this.Date != DateTime.MinValue)
{
if (colors != null && colors.Day.IsCustomized)
{
if (!colors.Day.BackColor.IsEmpty)
{
backColor = colors.Day.BackColor;
if (!colors.Day.BackColor2.IsEmpty)
backColor2 = colors.Day.BackColor2;
}
if (!colors.Day.BorderColor.IsEmpty)
borderColor = colors.Day.BorderColor;
customColors = true;
}
if (IsWeekend(Date) && colors != null && colors.Weekend.IsCustomized)
{
if (!colors.Weekend.BackColor.IsEmpty)
{
backColor = colors.Weekend.BackColor;
if (!colors.Weekend.BackColor2.IsEmpty)
backColor2 = colors.Weekend.BackColor2;
}
if (!colors.Weekend.BorderColor.IsEmpty)
borderColor = colors.Weekend.BorderColor;
customColors = true;
}
}
if (BarFunctions.IsOffice2007Style(EffectiveStyle) && !this.FlatOffice2007Style && !customColors)
{
Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTable(p);
if (ct != null)
{
Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RectangleShape);
backColor = Color.Empty;
backColor2 = Color.Empty;
borderColor = Color.Empty;
}
}
SmoothingMode sm = g.SmoothingMode;
g.SmoothingMode = SmoothingMode.None;
if (!backColor.IsEmpty)
DisplayHelp.FillRectangle(g, r, backColor, backColor2);
if (!borderColor.IsEmpty)
DisplayHelp.DrawRectangle(g, borderColor, r);
if (this.IsDayLabel)
{
borderColor = p.Colors.BarDockedBorder;
if (colors != null && !colors.DaysDividerBorderColors.IsEmpty)
borderColor = colors.DaysDividerBorderColors;
if (!borderColor.IsEmpty)
DisplayHelp.DrawLine(g, r.X, r.Bottom - 1, r.Right, r.Bottom - 1, borderColor, 1);
}
g.SmoothingMode = sm;
}
protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTable(ItemPaintArgs p)
{
if (BarFunctions.IsOffice2007Style(EffectiveStyle) && !this.FlatOffice2007Style)
{
if (p.Renderer is Office2007Renderer)
{
Office2007ColorTable ct = ((Office2007Renderer)p.Renderer).ColorTable;
Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.Orange)];
if (!this.Enabled)
return buttonColorTable.Disabled;
else if (this.IsMouseDown && _TrackMouse)
return buttonColorTable.Pressed;
else if (this.IsMouseOver && _TrackMouse)
return buttonColorTable.MouseOver;
else if (this.IsSelected)
return buttonColorTable.Checked;
}
}
return null;
}
internal static bool IsWeekend(DateTime d)
{
return d.DayOfWeek == DayOfWeek.Saturday || d.DayOfWeek == DayOfWeek.Sunday;
}
internal void PaintText(ItemPaintArgs p, Font textFont, Color textColor, eLabelPartAlignment textAlign)
{
Graphics g = p.Graphics;
string text = this.Text;
if (_Date != DateTime.MinValue)
text = _Date.Day.ToString();
bool isBold = _IsBold;
if (textColor.IsEmpty)
{
if (!_TextColor.IsEmpty)
textColor = _TextColor;
else if (!this.Enabled)
{
textColor = p.Colors.ItemDisabledText;
}
else
{
textColor = _IsTrailing ? p.Colors.ItemDisabledText : p.Colors.ItemText;
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
MonthCalendarColors colors = null;
if (month != null) colors = month.GetColors();
if (colors != null)
{
if (_Date != DateTime.MinValue)
{
if (_IsSelected && colors.Selection.IsCustomized)
{
if (!colors.Selection.TextColor.IsEmpty)
textColor = colors.Selection.TextColor;
if (colors.Selection.IsBold)
isBold = colors.Selection.IsBold;
}
else
{
if (_IsTrailing)
{
if (!colors.TrailingDay.TextColor.IsEmpty)
textColor = colors.TrailingDay.TextColor;
if (colors.TrailingDay.IsBold)
isBold = colors.TrailingDay.IsBold;
}
else if (colors.Day.IsCustomized)
{
if (!colors.Day.TextColor.IsEmpty)
textColor = colors.Day.TextColor;
if (colors.Day.IsBold)
isBold = colors.Day.IsBold;
}
if (IsWeekend(_Date))
{
if (_IsTrailing)
{
if (!colors.TrailingWeekend.TextColor.IsEmpty)
textColor = colors.TrailingWeekend.TextColor;
if (colors.TrailingWeekend.IsBold)
isBold = colors.TrailingWeekend.IsBold;
}
else
{
if (!colors.Weekend.TextColor.IsEmpty)
textColor = colors.Weekend.TextColor;
if (colors.Weekend.IsBold)
isBold = colors.Weekend.IsBold;
}
}
}
}
else if (IsWeekOfYear)
{
if (colors.WeekOfYear.IsCustomized)
{
if (!colors.WeekOfYear.TextColor.IsEmpty)
textColor = colors.WeekOfYear.TextColor;
if (colors.WeekOfYear.IsBold)
isBold = colors.WeekOfYear.IsBold;
}
}
else if (IsDayLabel)
{
if (!colors.DayLabel.TextColor.IsEmpty)
textColor = colors.DayLabel.TextColor;
if (colors.DayLabel.IsBold)
isBold = colors.DayLabel.IsBold;
}
}
}
}
if (_IsMouseOver && TrackMouse && StyleManager.IsMetro(EffectiveStyle))
{
textColor = p.Colors.ItemHotText;
}
bool disposeFont = false;
if (textFont == null)
{
if (isBold)
{
textFont = new Font(p.Font, FontStyle.Bold);
disposeFont = true;
}
else
textFont = p.Font;
}
if (_Date != DateTime.MinValue)
{
Size size = TextDrawing.MeasureString(g, "32", textFont);
Rectangle r = GetAlignedRect(this.DisplayRectangle, size, textAlign);
eTextFormat format = eTextFormat.Right | eTextFormat.VerticalCenter;
TextDrawing.DrawString(g, text, textFont, textColor,
r, format);
}
else
{
eTextFormat format = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter;
if (textAlign == eLabelPartAlignment.BottomCenter)
format = eTextFormat.Bottom | eTextFormat.HorizontalCenter;
else if (textAlign == eLabelPartAlignment.BottomLeft)
format = eTextFormat.Left | eTextFormat.Bottom;
else if (textAlign == eLabelPartAlignment.BottomRight)
format = eTextFormat.Bottom | eTextFormat.Right;
else if (textAlign == eLabelPartAlignment.MiddleLeft)
format = eTextFormat.Left | eTextFormat.VerticalCenter;
else if (textAlign == eLabelPartAlignment.MiddleRight)
format = eTextFormat.Right | eTextFormat.VerticalCenter;
else if (textAlign == eLabelPartAlignment.TopCenter)
format = eTextFormat.Top | eTextFormat.VerticalCenter;
else if (textAlign == eLabelPartAlignment.TopLeft)
format = eTextFormat.Top | eTextFormat.Left;
else if (textAlign == eLabelPartAlignment.TopRight)
format = eTextFormat.Top | eTextFormat.Right;
TextDrawing.DrawString(g, text, textFont, textColor,
this.Bounds, format);
}
if (disposeFont) textFont.Dispose();
}
public override void RecalcSize()
{
this.Bounds = new Rectangle(this.Bounds.Location, SingleMonthCalendar._DefaultDaySize);
base.RecalcSize();
}
/// <summary>
/// Returns copy of the item.
/// </summary>
public override BaseItem Copy()
{
DayLabel objCopy = new DayLabel();
this.CopyToItem(objCopy);
return objCopy;
}
/// <summary>
/// Copies the DayLabel specific properties to new instance of the item.
/// </summary>
/// <param name="c">New ButtonItem instance.</param>
protected override void CopyToItem(BaseItem c)
{
DayLabel copy = c as DayLabel;
base.CopyToItem(copy);
}
private DateTime _Date = DateTime.MinValue;
/// <summary>
/// Gets or sets the date represented by this label. DateTime.MinValue indicates that label is either used as textual day representation
/// or the week number as specified by the IsWeekOfYear property.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DateTime Date
{
get { return _Date; }
set
{
if (_Date != value)
{
_Date = value;
}
}
}
private bool _IsDayLabel = false;
/// <summary>
/// Gets or sets whether this label is used as the label that displays the day name.
/// </summary>
[Browsable(false), DefaultValue(false)]
public bool IsDayLabel
{
get { return _IsDayLabel; }
set
{
if (_IsDayLabel != value)
{
_IsDayLabel = value;
this.Refresh();
}
}
}
private bool _IsWeekOfYear = false;
/// <summary>
/// Gets or sets whether this label is used as the week of year label.
/// </summary>
[Browsable(false), DefaultValue(false)]
public bool IsWeekOfYear
{
get { return _IsWeekOfYear; }
set
{
if (_IsWeekOfYear != value)
{
_IsWeekOfYear = value;
this.Refresh();
}
}
}
private bool _IsTrailing = false;
/// <summary>
/// Gets whether the label for date represents the trailing date, i.e. date that is from next or previous month for the month displayed.
/// </summary>
[Browsable(false), DefaultValue(false)]
public bool IsTrailing
{
get { return _IsTrailing; }
set
{
if (_IsTrailing != value)
{
_IsTrailing = value;
this.Refresh();
}
}
}
private bool _IsMouseOver = false;
/// <summary>
/// Gets or sets whether mouse is over the item.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsMouseOver
{
get { return _IsMouseOver; }
set
{
_IsMouseOver = value;
this.Refresh();
}
}
private bool _IsMouseDown = false;
/// <summary>
/// Gets or sets whether left-mouse button is pressed over the item.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsMouseDown
{
get { return _IsMouseDown; }
set
{
_IsMouseDown = value;
this.Refresh();
}
}
/// <summary>
/// Occurs when the mouse pointer enters the item. This is used by internal implementation only.
/// </summary>
public override void InternalMouseEnter()
{
this.IsMouseOver = true;
base.InternalMouseEnter();
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.OnLabelMouseEnter(this, new EventArgs());
}
/// <summary>
/// Occurs when the mouse pointer leaves the item. This is used by internal implementation only.
/// </summary>
public override void InternalMouseLeave()
{
this.IsMouseOver = false;
base.InternalMouseLeave();
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.OnLabelMouseLeave(this, new EventArgs());
}
/// <summary>
/// Occurs when the mouse pointer is over the item and a mouse button is pressed. This is used by internal implementation only.
/// </summary>
public override void InternalMouseDown(System.Windows.Forms.MouseEventArgs objArg)
{
if (objArg.Button == System.Windows.Forms.MouseButtons.Left)
this.IsMouseDown = true;
if (this.IsMouseDown && this.SubItems.Count > 0 && this.ShowSubItems &&
(_ImageRenderBounds.Contains(objArg.X, objArg.Y) || _ExpandOnMouseDown))
{
this.Expanded = !this.Expanded;
}
base.InternalMouseDown(objArg);
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.OnLabelMouseDown(this, objArg);
}
/// <summary>
/// Occurs when the mouse pointer is over the item and a mouse button is released. This is used by internal implementation only.
/// </summary>
public override void InternalMouseUp(System.Windows.Forms.MouseEventArgs objArg)
{
if (objArg.Button == System.Windows.Forms.MouseButtons.Left)
this.IsMouseDown = false;
base.InternalMouseUp(objArg);
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.OnLabelMouseUp(this, objArg);
}
protected override void OnClick()
{
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.DayLabelClick(this);
base.OnClick();
}
public override void InternalMouseMove(System.Windows.Forms.MouseEventArgs objArg)
{
base.InternalMouseMove(objArg);
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.OnLabelMouseMove(this, objArg);
}
public override void InternalMouseHover()
{
base.InternalMouseHover();
SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
if (month != null) month.OnLabelMouseHover(this, new EventArgs());
}
private void BackgroundStyleChanged(object sender, EventArgs e)
{
this.OnAppearanceChanged();
}
/// <summary>
/// Specifies the item background style. Default value is an empty style which means that container does not display any background.
/// BeginGroup property set to true will override this style on some styles.
/// </summary>
[Browsable(true), DevCoBrowsable(true), Category("Style"), Description("Gets or sets container background style."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ElementStyle BackgroundStyle
{
get { return _BackgroundStyle; }
}
private bool _IsSelected = false;
/// <summary>
/// Gets or sets whether label appears as selected.
/// </summary>
[DefaultValue(false), Browsable(false)]
public bool IsSelected
{
get { return _IsSelected; }
set
{
if (_IsSelected != value)
{
_IsSelected = value;
this.Refresh();
}
}
}
private bool _TrackMouse = true;
/// <summary>
/// Gets or sets whether label provides visual indicator when mouse is over the label or pressed while over the label. Default value is true.
/// </summary>
[DefaultValue(true), Description("Indicates whether label provides visual indicator when mouse is over the label or pressed while over the label.")]
public bool TrackMouse
{
get { return _TrackMouse; }
set
{
if (_TrackMouse != value)
{
_TrackMouse = value;
this.Refresh();
}
}
}
private bool _Selectable = true;
/// <summary>
/// Gets or sets whether label is selectable. IsSelected property returns whether label is selected. Default value is true.
/// </summary>
[DefaultValue(true), Description("Indicates whether label is selectable.")]
public bool Selectable
{
get { return _Selectable; }
set
{
if (_Selectable != value)
{
_Selectable = value;
this.Refresh();
}
}
}
private Color _TextColor = Color.Empty;
/// <summary>
/// Gets or sets the label text color. Default value is an empty color.
/// </summary>
[Category("Colors"), Description("Indicates label text color.")]
public Color TextColor
{
get { return _TextColor; }
set
{
_TextColor = value;
this.Refresh();
}
}
/// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeTextColor()
{
return !TextColor.IsEmpty;
}
/// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetTextColor()
{
TextColor = Color.Empty;
}
private bool _IsBold = false;
/// <summary>
/// Gets or sets whether text is drawn using Bold font. Default value is false.
/// </summary>
[DefaultValue(false), Description("Indicates whether text is drawn using Bold font.")]
public bool IsBold
{
get { return _IsBold; }
set
{
if (_IsBold != value)
{
_IsBold = value;
this.Refresh();
}
}
}
//private Color _BorderColor = Color.Empty;
///// <summary>
///// Gets or sets the label border color. Default value is an empty color.
///// </summary>
//[Category("Colors"), Description("Indicates label border color.")]
//public Color BorderColor
//{
// get { return _BorderColor; }
// set
// {
// _BorderColor = value;
// this.Refresh();
// }
//}
///// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
//[EditorBrowsable(EditorBrowsableState.Never)]
//public bool ShouldSerializeBorderColor()
//{
// return !BorderColor.IsEmpty;
//}
///// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
//[EditorBrowsable(EditorBrowsableState.Never)]
//public void ResetBorderColor()
//{
// BorderColor = Color.Empty;
//}
//private Color _BackColor = Color.Empty;
///// <summary>
///// Gets or sets the label back color.
///// </summary>
//[Category("Colors"), Description("Indicates label back color.")]
//public Color BackColor
//{
// get { return _BackColor; }
// set
// {
// _BackColor = value;
// this.Refresh();
// }
//}
///// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
//[EditorBrowsable(EditorBrowsableState.Never)]
//public bool ShouldSerializeBackColor()
//{
// return !BackColor.IsEmpty;
//}
///// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
//[EditorBrowsable(EditorBrowsableState.Never)]
//public void ResetBackColor()
//{
// BackColor = Color.Empty;
//}
private eLabelPartAlignment _TextAlign = eLabelPartAlignment.MiddleCenter;
/// <summary>
/// Gets or sets the text alignment.
/// </summary>
[DefaultValue(eLabelPartAlignment.MiddleCenter), Description("Indicates text alignment.")]
public eLabelPartAlignment TextAlign
{
get { return _TextAlign; }
set
{
if (_TextAlign != value)
{
_TextAlign = value;
this.Refresh();
}
}
}
private eLabelPartAlignment _ImageAlign = eLabelPartAlignment.MiddleRight;
/// <summary>
/// Gets or sets the image alignment.
/// </summary>
[DefaultValue(eLabelPartAlignment.MiddleRight), Description("Indicates image alignment.")]
public eLabelPartAlignment ImageAlign
{
get { return _ImageAlign; }
set
{
if (_ImageAlign != value)
{
_ImageAlign = value;
this.Refresh();
}
}
}
private Image _Image = null;
/// <summary>
/// Gets or sets the image displayed on the label.
/// </summary>
[DefaultValue(null), Description("Indicates image displayed on the label.")]
public Image Image
{
get { return _Image; }
set
{
if (_Image != value)
{
_Image = value;
_ImageRenderBounds = Rectangle.Empty;
this.Refresh();
}
}
}
private bool _FlatOffice2007Style = false;
/// <summary>
/// Gets or sets whether flat Office 2007 style is used to render the item. Default value is false.
/// </summary>
[DefaultValue(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public bool FlatOffice2007Style
{
get { return _FlatOffice2007Style; }
set
{
_FlatOffice2007Style = value;
this.Refresh();
}
}
private bool _IsToday = false;
/// <summary>
/// Gets or sets whether date represented by label is marked as todays date.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsToday
{
get { return _IsToday; }
set
{
if (_IsToday != value)
{
_IsToday = value;
this.Refresh();
}
}
}
private bool _ExpandOnMouseDown = false;
/// <summary>
/// Gets or sets whether popup is displayed when mouse is pressed anywhere over the item. Default value is false which indicates
/// that popup is displayed only if image assigned to the item and mouse is pressed over image.
/// </summary>
[DefaultValue(false), Description("Indicates whether popup is displayed when mouse is pressed anywhere over the item.")]
public bool ExpandOnMouseDown
{
get { return _ExpandOnMouseDown; }
set
{
if (_ExpandOnMouseDown != value)
{
_ExpandOnMouseDown = value;
}
}
}
#endregion
}
/// <summary>
/// Indicates the alignment of the DayLabel part like text or image.
/// </summary>
public enum eLabelPartAlignment
{
TopLeft,
TopCenter,
TopRight,
MiddleLeft,
MiddleCenter,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight
}
}
#endif

View File

@@ -0,0 +1,140 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Provides data for DayLabel painting events.
/// </summary>
public class DayPaintEventArgs : EventArgs
{
/// <summary>
/// Gets the graphics canvas for rendering.
/// </summary>
public readonly Graphics Graphics;
/// <summary>
/// Gets or sets which parts of the item will be drawn by the system. You can set this to None to completely disable system rendering.
/// </summary>
public eDayPaintParts RenderParts = eDayPaintParts.All;
internal DayLabel _Item = null;
internal ItemPaintArgs _ItemPaintArgs = null;
/// <summary>
/// Initializes a new instance of the DayPaintEventArgs class.
/// </summary>
/// <param name="graphics">Reference to Graphics canvas.</param>
/// <param name="item">Reference to item being rendered.</param>
public DayPaintEventArgs(ItemPaintArgs p, DayLabel item)
{
Graphics = p.Graphics;
_ItemPaintArgs = p;
_Item = item;
}
/// <summary>
/// Renders the background of the item.
/// </summary>
public void PaintBackground()
{
_Item.PaintBackground(_ItemPaintArgs);
}
/// <summary>
/// Renders the item text.
/// </summary>
public void PaintText()
{
_Item.PaintText(_ItemPaintArgs, null, Color.Empty, _Item.TextAlign);
}
/// <summary>
/// Renders the item text.
/// </summary>
public void PaintText(Color textColor)
{
_Item.PaintText(_ItemPaintArgs, null, textColor, _Item.TextAlign);
}
/// <summary>
/// Renders the item text.
/// </summary>
public void PaintText(Color textColor, eLabelPartAlignment textAlign)
{
_Item.PaintText(_ItemPaintArgs, null, textColor, textAlign);
}
/// <summary>
/// Renders the item text.
/// </summary>
public void PaintText(Color textColor, Font textFont)
{
_Item.PaintText(_ItemPaintArgs, textFont, textColor, _Item.TextAlign);
}
/// <summary>
/// Renders the item text.
/// </summary>
public void PaintText(Color textColor, Font textFont, eLabelPartAlignment textAlign)
{
_Item.PaintText(_ItemPaintArgs, textFont, textColor, textAlign);
}
/// <summary>
/// Renders items image.
/// </summary>
public void PaintImage()
{
_Item.PaintImage(_ItemPaintArgs, _Item.Image, _Item.ImageAlign);
}
/// <summary>
/// Renders items image.
/// </summary>
public void PaintImage(eLabelPartAlignment imageAlign)
{
_Item.PaintImage(_ItemPaintArgs, _Item.Image, imageAlign);
}
}
/// <summary>
/// Defines delegate for DayLabel painting events.
/// </summary>
/// <param name="sender">Source of the event.</param>
/// <param name="e">Provides event data.</param>
public delegate void DayPaintEventHandler(object sender, DayPaintEventArgs e);
/// <summary>
/// Specifies the parts of DayLabel control. Members of this enum are intended to be used as flags (combined).
/// </summary>
[Flags()]
public enum eDayPaintParts
{
/// <summary>
/// Specifies no part.
/// </summary>
None = 0,
/// <summary>
/// Specifies the label background.
/// </summary>
Background = 1,
/// <summary>
/// Specifies the label text.
/// </summary>
Text = 2,
/// <summary>
/// Specifies the label image.
/// </summary>
Image = 4,
/// <summary>
/// Specifies all parts.
/// </summary>
All = Background | Text | Image
}
}
#endif

View File

@@ -0,0 +1,148 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Globalization;
namespace DevComponents.Editors.DateTimeAdv
{
public class HourPeriodInput : VisualStringListInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
private NumericHourInput _HourInput;
public NumericHourInput HourInput
{
get { return _HourInput; }
set
{
if (_HourInput != null)
{
_HourInput.ValueChanged -= new EventHandler(HourChanged);
_HourInput.IsEmptyChanged -= new EventHandler(HourIsEmptyChanged);
}
_HourInput = value;
if (_HourInput != null)
{
_HourInput.ValueChanged += new EventHandler(HourChanged);
_HourInput.IsEmptyChanged += new EventHandler(HourIsEmptyChanged);
}
}
}
private void HourIsEmptyChanged(object sender, EventArgs e)
{
if (_HourInput != null && _HourInput.IsEmpty)
this.IsEmpty = true;
}
private void HourChanged(object sender, EventArgs e)
{
if (_HourInput == null) return;
if (!_HourInput.IsEmpty)
{
if (_HourInput.Period == eHourPeriod.AM)
{
this.SelectedIndex = 0;
}
else
{
this.SelectedIndex = 1;
}
}
else
this.SelectedIndex = -1;
}
protected override List<string> GetItems()
{
List<string> items = new List<string>(2);
items.Add(GetAMLabel());
items.Add(GetPMLabel());
return items;
}
private string GetPMLabel()
{
string s = "";
if (_PMText != null && _PMText.Length > 0)
s = _PMText;
else
s = DateTimeInput.GetActiveCulture().DateTimeFormat.PMDesignator;
if (_UseSingleLetterLabel && s.Length > 0)
s = s[0].ToString();
return s;
}
private string GetAMLabel()
{
string s = "";
if (_AMText != null && _AMText.Length > 0)
s = _AMText;
else
s = DateTimeInput.GetActiveCulture().DateTimeFormat.AMDesignator;
if (_UseSingleLetterLabel && s.Length > 0)
s = s[0].ToString();
return s;
}
private bool _UseSingleLetterLabel = false;
public bool UseSingleLetterLabel
{
get { return _UseSingleLetterLabel; }
set
{
if (_UseSingleLetterLabel != value)
{
_UseSingleLetterLabel = value;
this.InvalidateArrange();
}
}
}
private string _AMText = "";
/// <summary>
/// Gets or sets custom AM text used.
/// </summary>
[DefaultValue("")]
public string AMText
{
get { return _AMText; }
set { _AMText = value; InvalidateArrange(); }
}
private string _PMText = "";
/// <summary>
/// Gets or sets custom PM text used.
/// </summary>
[DefaultValue("")]
public string PMText
{
get { return _PMText; }
set { _PMText = value; InvalidateArrange(); }
}
protected override void OnSelectedIndexChanged(EventArgs eventArgs)
{
if (_HourInput != null && !_HourInput.IsEmpty)
{
eHourPeriod period = this.SelectedIndex == 1 ? eHourPeriod.PM : eHourPeriod.AM;
if (_HourInput.Period != period)
_HourInput.Period = period;
}
base.OnSelectedIndexChanged(eventArgs);
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,105 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Globalization;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Represents a label for the NumericHourInput control that shows whether time is AM or PM.
/// </summary>
public class HourPeriodLabel : VisualLabel
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
private NumericHourInput _HourInput;
public NumericHourInput HourInput
{
get { return _HourInput; }
set
{
if (_HourInput != null)
_HourInput.ValueChanged -= new EventHandler(HourChanged);
_HourInput = value;
if (_HourInput != null)
_HourInput.ValueChanged += new EventHandler(HourChanged);
}
}
private void HourChanged(object sender, EventArgs e)
{
if (_HourInput == null) return;
string s = "";
if (!_HourInput.IsEmpty)
{
if (_HourInput.Period == eHourPeriod.AM)
{
if (_AMText != null && _AMText.Length > 0)
s = _AMText;
else
s = DateTimeInput.GetActiveCulture().DateTimeFormat.AMDesignator;
}
else
{
if (_PMText != null && _PMText.Length > 0)
s = _PMText;
else
s = DateTimeInput.GetActiveCulture().DateTimeFormat.PMDesignator;
}
if (_UseSingleLetterLabel && s.Length > 0)
s = s[0].ToString();
}
this.Text = s;
}
private string _AMText = "";
/// <summary>
/// Gets or sets custom AM text used.
/// </summary>
[DefaultValue("")]
public string AMText
{
get { return _AMText; }
set { _AMText = value; InvalidateArrange(); }
}
private string _PMText = "";
/// <summary>
/// Gets or sets custom PM text used.
/// </summary>
[DefaultValue("")]
public string PMText
{
get { return _PMText; }
set { _PMText = value; InvalidateArrange(); }
}
private bool _UseSingleLetterLabel = false;
public bool UseSingleLetterLabel
{
get { return _UseSingleLetterLabel; }
set
{
if (_UseSingleLetterLabel != value)
{
_UseSingleLetterLabel = value;
this.InvalidateArrange();
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,44 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Defines an interface for the DateTime Part interaction.
/// </summary>
public interface IDateTimePartInput
{
/// <summary>
/// Gets or sets the date/time part value.
/// </summary>
int Value { get;set;}
/// <summary>
/// Gets or sets the minimum value for the date/time part entry.
/// </summary>
int MinValue { get;set;}
/// <summary>
/// Gets or sets the maximum value for the date/time part entry.
/// </summary>
int MaxValue { get;set;}
/// <summary>
/// Gets the date time part control represents.
/// </summary>
eDateTimePart Part { get;}
/// <summary>
/// Gets or sets whether input part is empty.
/// </summary>
bool IsEmpty { get; set;}
/// <summary>
/// Reverts to the last input value control held.
/// </summary>
void UndoInput();
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,277 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using DevComponents.DotNetBar;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Defines the MonthCalendar and SingleMonthCalendar colors for customization.
/// </summary>
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class MonthCalendarColors
{
private void Refresh()
{
if (_Parent != null)
{
_Parent.NeedRecalcSize = true;
_Parent.Refresh();
}
}
private BaseItem _Parent;
internal BaseItem Parent
{
get { return _Parent; }
set
{
_Parent = value;
_WeekOfYear.Parent = value;
_Day.Parent = value;
_Weekend.Parent = value;
_TrailingDay.Parent = value;
_Today.Parent = value;
_TrailingWeekend.Parent = value;
_DayLabel.Parent = value;
_DayMarker.Parent = value;
_MonthlyMarker.Parent = value;
_AnnualMarker.Parent = value;
_Selection.Parent = value;
}
}
private DateAppearanceDescription _Today = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for the todays date.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the todays date."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription Today
{
get { return _Today; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetToday()
{
_Today = new DateAppearanceDescription();
_Today.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _Selection = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for selected days.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for selected days."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription Selection
{
get { return _Selection; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetSelection()
{
_Selection = new DateAppearanceDescription();
_Selection.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _TrailingDay = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for the trailing days on calendar.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the trailing days on calendar."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription TrailingDay
{
get { return _TrailingDay; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetTrailingDay()
{
_TrailingDay = new DateAppearanceDescription();
_TrailingDay.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _WeekOfYear = new DateAppearanceDescription();
/// <summary>
/// Gets or sets the appearance settings for the labels that show week of year number.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the labels that show week of year number."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription WeekOfYear
{
get { return _WeekOfYear; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetWeekOfYear()
{
_WeekOfYear = new DateAppearanceDescription();
_WeekOfYear.Parent = _Parent;
this.Refresh();
}
private Color _DaysDividerBorderColors = Color.Empty;
/// <summary>
/// Gets or sets the days divider line color.
/// </summary>
[Category("Colors"), Description("Indicates days divider line color.")]
public Color DaysDividerBorderColors
{
get { return _DaysDividerBorderColors; }
set
{
_DaysDividerBorderColors = value;
this.Refresh();
}
}
/// <summary>Gets whether property should be serialized. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeDaysDividerBorderColors()
{
return !DaysDividerBorderColors.IsEmpty;
}
/// <summary>Resets property to its default value. Provided for WinForms designer support.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetDaysDividerBorderColors()
{
DaysDividerBorderColors = Color.Empty;
}
private DateAppearanceDescription _Day = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for the numeric day of month label.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the numeric day of month label."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription Day
{
get { return _Day; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetDay()
{
_Day = new DateAppearanceDescription();
_Day.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _Weekend = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for the weekend days on calendar (Saturday and Sunday).
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the weekend days on calendar (Saturday and Sunday)."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription Weekend
{
get { return _Weekend; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetWeekend()
{
_Weekend = new DateAppearanceDescription();
_Weekend.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _TrailingWeekend = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for the trailing weekend days on calendar (Saturday and Sunday).
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the trailing weekend days on calendar (Saturday and Sunday)."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription TrailingWeekend
{
get { return _TrailingWeekend; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetTrailingWeekend()
{
_TrailingWeekend = new DateAppearanceDescription();
_TrailingWeekend.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _DayLabel = new DateAppearanceDescription();
/// <summary>
/// Gets the appearance settings for the labels that display day name in calendar header.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Indicates appearance settings for the labels that display day name in calendar header."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription DayLabel
{
get { return _DayLabel; }
}
/// <summary>
/// Resets property to its default value. Provided for Windows Forms designer support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetDayLabel()
{
_DayLabel = new DateAppearanceDescription();
_DayLabel.Parent = _Parent;
this.Refresh();
}
private DateAppearanceDescription _MonthlyMarker = new DateAppearanceDescription();
/// <summary>
/// Gets or sets the marker settings for days specified by MonthCalendarItem.MonthlyMarkedDates property.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Gets marker settings for days specified by MonthCalendarAdv.MonthlyMarkedDates property."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription MonthlyMarker
{
get { return _MonthlyMarker; }
}
private DateAppearanceDescription _AnnualMarker = new DateAppearanceDescription();
/// <summary>
/// Gets or sets the marker settings for days specified by MonthCalendarItem.AnnuallyMarkedDates property.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Gets marker settings for days specified by MonthCalendarAdv.AnnuallyMarkedDates property."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription AnnualMarker
{
get { return _AnnualMarker; }
}
private DateAppearanceDescription _DayMarker = new DateAppearanceDescription();
/// <summary>
/// Gets or sets the marker settings for days specified by MonthCalendarItem.MarkedDates property.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Gets marker settings for days specified by MonthCalendarAdv.MarkedDates property."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription DayMarker
{
get { return _DayMarker; }
}
private DateAppearanceDescription _WeeklyMarker = new DateAppearanceDescription();
/// <summary>
/// Gets or sets the marker settings for days specified by MonthCalendarItem.WeeklyMarkedDays property.
/// </summary>
[NotifyParentPropertyAttribute(true), Description("Gets marker settings for days specified by MonthCalendarAdv.WeeklyMarkedDays property."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DateAppearanceDescription WeeklyMarker
{
get { return _WeeklyMarker; }
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,150 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.ComponentModel;
namespace DevComponents.Editors.DateTimeAdv
{
public class MonthNameInput : VisualStringListInput, IDateTimePartInput
{
#region Private Variables
private List<string> _Months = null;
private int _MinValue = 1;
private int _MaxValue = 12;
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override List<string> GetItems()
{
if (this.Items.Count != 12)
{
if (_Months == null)
{
_Months = new List<string>(12);
if (_UseAbbreviatedNames)
_Months.AddRange(DateTimeInput.GetActiveCulture().DateTimeFormat.AbbreviatedMonthNames);
else
_Months.AddRange(DateTimeInput.GetActiveCulture().DateTimeFormat.MonthNames);
if (_Months.Count == 13 && _Months[12] == "") _Months.RemoveAt(12);
}
return _Months;
}
return base.GetItems();
}
protected override bool ValidateNewInputStack(string s)
{
if (s.Length > 0)
{
// Parse also numeric input and map it to the month name
int month = 0;
int.TryParse(s, out month);
if (month > 0 && month >= _MinValue && month <= _MaxValue)
{
List<string> items = GetItems();
this.LastMatch = items[month - 1];
this.LastValidatedInputStack = s;
if (month > 1)
this.LastMatchComplete = true;
return true;
}
}
bool b = base.ValidateNewInputStack(s);
if (b && LastValidatedInputStack.Length > 0)
{
List<string> items = GetItems();
int index = items.IndexOf(LastMatch) + 1;
if (index < _MinValue || index > _MaxValue)
return false;
}
return b;
}
#endregion
#region IDateTimePartInput Members
int IDateTimePartInput.Value
{
get
{
return this.SelectedIndex + 1;
}
set
{
this.SelectedIndex = value - 1;
}
}
int IDateTimePartInput.MinValue
{
get
{
return _MinValue;
}
set
{
if (_MinValue != value)
{
_MinValue = value;
if (!this.IsEmpty && SelectedIndex < _MinValue)
this.SelectedIndex = _MinValue;
}
}
}
int IDateTimePartInput.MaxValue
{
get
{
return _MaxValue;
}
set
{
if (_MaxValue != value)
{
_MaxValue = value;
if (!this.IsEmpty && SelectedIndex > _MaxValue)
this.SelectedIndex = _MaxValue;
}
}
}
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.Month; }
}
private bool _UseAbbreviatedNames = false;
/// <summary>
/// Gets or sets whether abbreviated month names are used for display instead of full month names. Default value is false.
/// </summary>
[DefaultValue(false)]
public bool UseAbbreviatedNames
{
get { return _UseAbbreviatedNames; }
set
{
if (_UseAbbreviatedNames != value)
{
_UseAbbreviatedNames = value;
_Months = null;
InvalidateArrange();
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,43 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericDayInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericDayInput class.
/// </summary>
public NumericDayInput()
{
this.MinValue = 1;
this.MaxValue = 31;
}
#endregion
#region Internal Implementation
#endregion
#region IDateTimePartInput Members
public eDateTimePart Part
{
get { return eDateTimePart.Day; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,44 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericDayOfYearInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericDayOfYearInput class.
/// </summary>
public NumericDayOfYearInput()
{
this.MinValue = 1;
this.MaxValue = 366;
}
#endregion
#region Internal Implementation
#endregion
#region IDateTimePartInput Members
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.DayOfYear; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,174 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericHourInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericHourInput class.
/// </summary>
public NumericHourInput()
{
UpdateRange();
}
#endregion
#region Internal Implementation
private bool _Is24HourFormat = true;
public bool Is24HourFormat
{
get { return _Is24HourFormat; }
set
{
if (_Is24HourFormat != value)
{
_Is24HourFormat = value;
OnIs24HourFormatChanged();
}
}
}
private void OnIs24HourFormatChanged()
{
if (!_Is24HourFormat && this.Value > 12)
{
this.Value = Value;
}
UpdateRange();
}
private void UpdateRange()
{
if (_Is24HourFormat)
{
this.MinValue = 0;
this.MaxValue = 23;
}
else
{
if (_Period == eHourPeriod.AM)
{
this.MinValue = 1;
this.MaxValue = 12;
}
else
{
this.MinValue = 1;
this.MaxValue = 12;
}
//if (this.Value > this.MaxValue) this.Value = this.MaxValue;
//if (this.Value < this.MinValue) this.Value = this.MinValue;
}
}
protected override void OnValueChanged()
{
if (_Is24HourFormat)
{
if (Value >= 0 && Value <= 12)
this.Period = eHourPeriod.AM;
else
this.Period = eHourPeriod.PM;
}
base.OnValueChanged();
}
private eHourPeriod _Period;
public eHourPeriod Period
{
get { return _Period; }
set
{
if (_Period != value)
{
_Period = value;
if (!_Is24HourFormat)
{
UpdateRange();
this.Value = this.Value;
}
}
}
}
public override int Value
{
get { return base.Value; }
set
{
if (!_Is24HourFormat)
{
if (value == 0)
{
value = 12;
_Period = eHourPeriod.AM;
}
else if (value > 12)
{
_Period = eHourPeriod.PM;
value = value - 12;
}
//else
// _Period = eHourPeriod.AM;
UpdateRange();
}
base.Value = value;
}
}
protected override bool ValidateNewInputStack(string s)
{
if (!_Is24HourFormat && s.Length > 0)
{
int value = 0;
if (int.TryParse(s, out value))
{
if (value > 12 && value < 24 /*|| value == 12 && _Period == eHourPeriod.AM*/)
{
SetInputStack("");
SetInputPosition(0);
this.Value = value;
return false;
}
}
}
return base.ValidateNewInputStack(s);
}
protected override void OnIsEmptyChanged()
{
if (this.IsEmpty)
{
_Period = eHourPeriod.AM;
UpdateRange();
}
base.OnIsEmptyChanged();
}
#endregion
#region IDateTimePartInput Members
#region IDateTimePartInput Members
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.Hour; }
}
#endregion
#endregion
}
}
#endif

View File

@@ -0,0 +1,40 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericMinuteInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericMinuteInput class.
/// </summary>
public NumericMinuteInput()
{
this.MinValue = 0;
this.MaxValue = 59;
}
#endregion
#region Internal Implementation
#endregion
#region IDateTimePartInput Members
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.Minute; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,41 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericMonthInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericMonthInput class.
/// </summary>
public NumericMonthInput()
{
this.MinValue = 1;
this.MaxValue = 12;
}
#endregion
#region Internal Implementation
#endregion
#region IDateTimePartInput Members
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.Month; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,40 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericSecondInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericSecondInput class.
/// </summary>
public NumericSecondInput()
{
this.MinValue = 0;
this.MaxValue = 59;
}
#endregion
#region Internal Implementation
#endregion
#region IDateTimePartInput Members
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.Second; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,94 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace DevComponents.Editors.DateTimeAdv
{
public class NumericYearInput : VisualIntegerInput, IDateTimePartInput
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the NumericYearInput class.
/// </summary>
public NumericYearInput()
{
this.MinValue = System.DateTime.MinValue.Year;
this.MaxValue = System.DateTime.MaxValue.Year;
}
#endregion
#region Internal Implementation
private eYearDisplayFormat _YearDisplayFormat = eYearDisplayFormat.FourDigit;
/// <summary>
/// Gets or sets the year display format. Default value is four digit format.
/// </summary>
[DefaultValue(eYearDisplayFormat.FourDigit)]
public eYearDisplayFormat YearDisplayFormat
{
get { return _YearDisplayFormat; }
set
{
if (_YearDisplayFormat != value)
{
_YearDisplayFormat = value;
InvalidateArrange();
}
}
}
protected override string GetMeasureString()
{
return GetFormattedYear(base.GetMeasureString());
}
protected override string GetRenderString()
{
return GetFormattedYear(base.GetRenderString());
}
private string GetFormattedYear(string s)
{
if (this.IsFocused || s.Length < 4 || _YearDisplayFormat == eYearDisplayFormat.FourDigit) return s;
if (_YearDisplayFormat == eYearDisplayFormat.TwoDigit)
return s.Substring(2);
return s.Substring(3);
}
protected override void InputComplete(bool sendNotification)
{
UpdateYearValue();
base.InputComplete(sendNotification);
}
protected override void OnInputLostFocus()
{
UpdateYearValue();
base.OnInputLostFocus();
}
private void UpdateYearValue()
{
if (!this.IsEmpty && this.Value < 100)
this.Value = int.Parse(System.DateTime.Now.Year.ToString().Substring(0, 2) + this.Value.ToString("00"));
}
#endregion
#region IDateTimePartInput Members
eDateTimePart IDateTimePartInput.Part
{
get { return eDateTimePart.Year; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,58 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Defines data for the ParseValue event that allows you to provide custom parsing for values set to ValueObject property.
/// </summary>
public class ParseDateTimeValueEventArgs : EventArgs
{
/// <summary>
/// Get the value that was set to the ValueObject property and which should be converted to ParsedValue DateTime.
/// </summary>
public readonly object ValueObject = null;
/// <summary>
/// Gets or sets whether you have provided ParsedValue.
/// </summary>
public bool IsParsed = false;
/// <summary>
/// Initializes a new instance of the ParseDateTimeValueEventArgs class.
/// </summary>
/// <param name="valueObject">Indicates the value object.</param>
public ParseDateTimeValueEventArgs(object valueObject)
{
ValueObject = valueObject;
}
private System.DateTime _ParsedValue = DateTimeGroup.MinDateTime;
/// <summary>
/// /// <summary>
/// Gets or sets the parsed value from ValueObject property.
/// </summary>
/// </summary>
public System.DateTime ParsedValue
{
get { return _ParsedValue; }
set
{
_ParsedValue = value;
IsParsed = true;
}
}
}
/// <summary>
/// Defines delegate for ParseDateTimeValue event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void ParseDateTimeValueEventHandler(object sender, ParseDateTimeValueEventArgs e);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,353 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DevComponents.DotNetBar;
using System.Windows.Forms;
using System.Drawing;
using System.Globalization;
namespace DevComponents.Editors.DateTimeAdv
{
/// <summary>
/// Represents a control that enables the user to select time using visual time display.
/// </summary>
[ToolboxBitmap(typeof(DotNetBarManager), "TimeSelector.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.TimeSelectorDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
[DefaultEvent("SelectedTimeChanged"), DefaultProperty("SelectedTime")]
public class TimeSelector : ItemControl
{
#region Private Variables
private TimeSelectorItem _TimeSelector = null;
#endregion
#region Events
/// <summary>
/// Occurs after SelectedTime changes.
/// </summary>
[Description("Occurs after SelectedTime changes.")]
public event EventHandler SelectedTimeChanged;
/// <summary>
/// Raises SelectedTimeChanged event.
/// </summary>
/// <param name="e">Provides event arguments.</param>
protected virtual void OnSelectedTimeChanged(EventArgs e)
{
EventHandler handler = SelectedTimeChanged;
if (handler != null)
handler(this, e);
}
/// <summary>
/// Occurs when OK button is clicked.
/// </summary>
[Description("Occurs when OK button is clicked.")]
public event EventHandler OkClick;
/// <summary>
/// Raises OkClick event.
/// </summary>
/// <param name="e">Provides event arguments.</param>
protected virtual void OnOkClick(EventArgs e)
{
EventHandler handler = OkClick;
if (handler != null)
handler(this, e);
}
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the MonthCalendarAdv class.
/// </summary>
public TimeSelector()
{
this.SetStyle(ControlStyles.Selectable, false);
_TimeSelector = new TimeSelectorItem();
_TimeSelector.GlobalItem = false;
_TimeSelector.ContainerControl = this;
_TimeSelector.Stretch = false;
_TimeSelector.Displayed = true;
_TimeSelector.Style = eDotNetBarStyle.StyleManagerControlled;
this.ColorScheme.Style = eDotNetBarStyle.StyleManagerControlled;
_TimeSelector.SetOwner(this);
_TimeSelector.SelectedTimeChanged += new EventHandler(TimeSelector_SelectedTimeChanged);
_TimeSelector.OkClick += new EventHandler(TimeSelector_OkClick);
this.SetBaseItemContainer(_TimeSelector);
}
#endregion
#region Internal Implementation
void TimeSelector_OkClick(object sender, EventArgs e)
{
OnOkClick(e);
}
void TimeSelector_SelectedTimeChanged(object sender, EventArgs e)
{
OnSelectedTimeChanged(e);
}
internal bool GetDesignModeInternal()
{
return DesignMode;
}
/// <summary>
/// Gets or sets the text displayed on OK button.
/// </summary>
[DefaultValue("OK"), Category("Appearance"), Description("Indicates text displayed on OK button."), Localizable(true)]
public string OkText
{
get { return _TimeSelector.OkText; }
set { _TimeSelector.OkText = value; }
}
/// <summary>
/// Gets or sets whether Ok button is visible.
/// </summary>
[DefaultValue(true), Category("Appearance"), Description("Indicates whether Ok button is visible.")]
public bool OkButtonVisible
{
get { return _TimeSelector.OkButtonVisible; }
set
{
_TimeSelector.OkButtonVisible = value;
}
}
/// <summary>
/// Gets or sets the selected date time.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DateTime SelectedDateTime
{
get
{
return _TimeSelector.SelectedDateTime;
}
set
{
_TimeSelector.SelectedDateTime = value;
}
}
/// <summary>
/// Gets or sets selected time. Returns TimeSpan.Zero if there is no time selected.
/// </summary>
[Category("Data"), Description("Indicates selected time.")]
public TimeSpan SelectedTime
{
get { return _TimeSelector.SelectedTime; }
set
{
_TimeSelector.SelectedTime = value;
}
}
/// <summary>
/// Returns whether property should be serialized.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeSelectedTime()
{
return _TimeSelector.ShouldSerializeSelectedTime();
}
/// <summary>
/// Resets property to default value.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetSelectedTime()
{
_TimeSelector.ResetSelectedTime();
}
/// <summary>
/// Gets or sets the time format used to present time by the selector.
/// </summary>
[DefaultValue(eTimeSelectorFormat.System), Category("Appearance"), Description("Indicates time format used to present time by the selector."), Localizable(true)]
public eTimeSelectorFormat TimeFormat
{
get { return _TimeSelector.TimeFormat; }
set
{
_TimeSelector.TimeFormat = value;
_PreferredSize = Size.Empty;
AdjustSize();
}
}
/// <summary>
/// Gets or sets the format for the 12 Hour Time Display.
/// </summary>
[DefaultValue(TimeSelectorItem.DefaultTimeFormat12H), Category("Data"), Description("Indicates format for the 12 Hour Time Display."), Localizable(true)]
public string TimeFormat12H
{
get { return _TimeSelector.TimeFormat12H; }
set
{
_TimeSelector.TimeFormat12H = value;
}
}
/// <summary>
/// Gets or sets the format for the 24 Hour Time Display.
/// </summary>
[DefaultValue(TimeSelectorItem.DefaultTimeFormat24H), Category("Data"), Description("Indicates format for the 24 Hour Time Display."), Localizable(true)]
public string TimeFormat24H
{
get { return _TimeSelector.TimeFormat24H; }
set
{
_TimeSelector.TimeFormat24H = value;
}
}
private Size _PreferredSize = Size.Empty;
/// <summary>
/// Invalidates control auto-size and resizes the control if AutoSize is set to true.
/// </summary>
public void InvalidateAutoSize()
{
_PreferredSize = Size.Empty;
AdjustSize();
}
[Browsable(false)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
#if FRAMEWORK20
/// <summary>
/// Gets or sets a value indicating whether the control is automatically resized to display its entire contents. You can set MaximumSize.Width property to set the maximum width used by the control.
/// </summary>
[Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override bool AutoSize
{
get
{
return base.AutoSize;
}
set
{
if (this.AutoSize != value)
{
base.AutoSize = value;
AdjustSize();
}
}
}
private void AdjustSize()
{
if (this.AutoSize)
{
this.Size = base.PreferredSize;
}
}
protected override void OnFontChanged(EventArgs e)
{
InvalidateAutoSize();
base.OnFontChanged(e);
}
public override Size GetPreferredSize(Size proposedSize)
{
if (!_PreferredSize.IsEmpty) return _PreferredSize;
if (!BarFunctions.IsHandleValid(this))
return base.GetPreferredSize(proposedSize);
ElementStyle style = this.GetBackgroundStyle();
_TimeSelector.RecalcSize();
_PreferredSize = _TimeSelector.Size;
if (style != null)
{
_PreferredSize.Width += ElementStyleLayout.HorizontalStyleWhiteSpace(style);
_PreferredSize.Height += ElementStyleLayout.VerticalStyleWhiteSpace(style);
}
return _PreferredSize;
}
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
if (this.AutoSize)
{
Size preferredSize = base.PreferredSize;
width = preferredSize.Width;
height = preferredSize.Height;
}
base.SetBoundsCore(x, y, width, height, specified);
}
protected override void OnHandleCreated(EventArgs e)
{
if (this.AutoSize)
this.AdjustSize();
base.OnHandleCreated(e);
}
[Browsable(false)]
public override bool ThemeAware
{
get
{
return base.ThemeAware;
}
set
{
base.ThemeAware = value;
}
}
#endif
/// <summary>
/// Indicates the type of the selector used to select time.
/// </summary>
[DefaultValue(eTimeSelectorType.TouchStyle), Category("Appearance"), Description("Indicates the type of the selector used to select time.")]
public eTimeSelectorType SelectorType
{
get { return _TimeSelector.SelectorType; }
set
{
_TimeSelector.SelectorType = value;
_PreferredSize = Size.Empty;
AdjustSize();
}
}
/// <summary>
/// Gets or sets the text displayed on Clear button only when MonthCalendarStyle is used.
/// </summary>
[DefaultValue("Clear"), Category("Appearance"), Description("Indicates text displayed on Clear button only when MonthCalendarStyle is used."), Localizable(true)]
public string ClearText
{
get { return _TimeSelector.ClearText; }
set { _TimeSelector.ClearText = value; }
}
/// <summary>
/// Gets or sets the text displayed on Hour label.
/// </summary>
[DefaultValue("Hour"), Category("Appearance"), Description("Indicates text displayed on Hour label."), Localizable(true)]
public string HourText
{
get { return _TimeSelector.HourText; }
set { _TimeSelector.HourText = value; }
}
/// <summary>
/// Gets or sets the text displayed on Minute label.
/// </summary>
[DefaultValue("Minute"), Category("Appearance"), Description("Indicates text displayed on Minute label."), Localizable(true)]
public string MinuteText
{
get { return _TimeSelector.MinuteText; }
set { _TimeSelector.MinuteText = value; }
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,358 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
/// <summary>
/// Control for input of the integer value.
/// </summary>
[ToolboxBitmap(typeof(DotNetBarManager), "DoubleInput.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.NumericInputBaseDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
[DefaultBindingProperty("ValueObject"), DefaultProperty("ValueObject")]
public class DoubleInput : NumericInputBase
{
#region Private Variables
private VisualDoubleInput _DoubleInput = null;
private VisualInputGroup _InputGroup = null;
#endregion
#region Events
/// <summary>
/// Occurs when ValueObject property is set and it allows you to provide custom parsing for the values.
/// </summary>
public event ParseDoubleValueEventHandler ParseValue;
#endregion
#region Constructor
#endregion
#region Internal Implementation
/// <summary>
/// Copies the current value in the control to the Clipboard.
/// </summary>
public virtual void Copy()
{
if (_DoubleInput != null) _DoubleInput.ProcessClipboardCopy();
}
/// <summary>
/// Pastes the current Clipboard content if possible as the value into the control.
/// </summary>
public virtual void Paste()
{
if (_DoubleInput != null) _DoubleInput.ProcessClipboardPaste();
}
/// <summary>
/// Moves the current control value to the Clipboard.
/// </summary>
public virtual void Cut()
{
if (_DoubleInput != null) _DoubleInput.ProcessClipboardCut();
}
internal VisualInputGroup InputGroup
{
get { return (_InputGroup); }
}
protected override VisualItem CreateRootVisual()
{
VisualInputGroup g = new VisualInputGroup();
VisualDoubleInput i = new VisualDoubleInput();
i.ValueChanged += new EventHandler(InputItemValueChanged);
g.Items.Add(i);
_InputGroup = g;
_DoubleInput = i;
return g;
}
/// <summary>
/// Gets or sets whether mouse wheel increases or decreases the input value when used.
/// </summary>
[DefaultValue(true), Category("Behavior"), Description("Indicates whether mouse wheel increases or decreases the input value when used.")]
public bool MouseWheelValueChangeEnabled
{
get { return _DoubleInput.MouseWheelValueChangeEnabled; }
set
{
_DoubleInput.MouseWheelValueChangeEnabled = value;
}
}
protected override void UpdateInputFieldAlignment()
{
if (this.InputHorizontalAlignment == eHorizontalAlignment.Right)
{
if (!ButtonClear.Visible && !ButtonDropDown.Visible && !ButtonFreeText.Visible && !ButtonCustom.Visible && !ButtonCustom2.Visible && !ButtonCalculator.Visible && !ShowUpDown)
_DoubleInput.Alignment = eItemAlignment.Right;
else
_DoubleInput.Alignment = eItemAlignment.Left;
}
else
{
_DoubleInput.Alignment = eItemAlignment.Left;
}
base.UpdateInputFieldAlignment();
}
private void InputItemValueChanged(object sender, EventArgs e)
{
OnValueChanged(e);
if (this.FreeTextEntryMode && _FreeTextEntryBox != null && _FreeTextEntryBox.Text != this.Text)
_FreeTextEntryBox.Text = this.Text;
}
protected override void OnDisplayFormatChanged()
{
_DoubleInput.DisplayFormat = this.DisplayFormat;
}
/// <summary>
/// Gets or sets the value displayed in the control.
/// </summary>
[DefaultValue(0d), Description("Indicates value displayed in the control.")]
public double Value
{
get { return _DoubleInput.Value; }
set
{
if (Value != value || _DoubleInput.IsEmpty)
{
_DoubleInput.Value = value;
//OnValueChanged(new EventArgs());
}
}
}
/// <summary>
/// Gets or sets the value of the control as an object. This property allows you to bind to the database fields and supports
/// null values. Expected value is int type or null.
/// </summary>
[Bindable(true), RefreshProperties(RefreshProperties.All), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter))]
public object ValueObject
{
get
{
if (this.IsEmpty)
return null;
return Value;
}
set
{
if (AcceptCustomValueObject(value))
return;
else if (IsNull(value) || value is string && string.IsNullOrEmpty((string)value))
this.IsEmpty = true;
else if (value is double)
{
this.Value = (double)value;
}
else if (value is int)
{
this.Value = (double)(int)value;
}
else if (value is float)
{
this.Value = (double)(float)value;
}
else if (value is decimal)
{
this.Value = decimal.ToDouble((decimal)value);
}
else if (value is long)
{
string t = value.ToString();
this.Value = double.Parse(t);
}
else if (value is string)
{
double i = 0;
if (double.TryParse(value.ToString(), out i))
this.Value = i;
else
throw new ArgumentException("ValueObject property expects either null/nothing value or double type.");
}
else
throw new ArgumentException("ValueObject property expects either null/nothing value or double type.");
}
}
private bool AcceptCustomValueObject(object value)
{
ParseDoubleValueEventArgs e = new ParseDoubleValueEventArgs(value);
OnParseValue(e);
if (e.IsParsed)
{
this.Value = e.ParsedValue;
}
return e.IsParsed;
}
/// <summary>
/// Raises the ParseValue event.
/// </summary>
/// <param name="e">Provides event arguments.</param>
protected virtual void OnParseValue(ParseDoubleValueEventArgs e)
{
if (ParseValue != null)
ParseValue(this, e);
}
/// <summary>
/// Gets or sets the maximum value that can be entered.
/// </summary>
[DefaultValue(double.MaxValue), Description("Indicates maximum value that can be entered.")]
public double MaxValue
{
get { return _DoubleInput.MaxValue; }
set
{
_DoubleInput.MaxValue = value;
}
}
/// <summary>
/// Gets or sets the minimum value that can be entered.
/// </summary>
[DefaultValue(double.MinValue), Description("Indicates minimum value that can be entered.")]
public double MinValue
{
get { return _DoubleInput.MinValue; }
set
{
_DoubleInput.MinValue = value;
}
}
/// <summary>
/// Gets or sets the value to increment or decrement the value of the control when the up or down buttons are clicked.
/// </summary>
[DefaultValue(1), Description("Indicates value to increment or decrement the value of the control when the up or down buttons are clicked. ")]
public double Increment
{
get { return _DoubleInput.Increment; }
set { _DoubleInput.Increment = value; }
}
protected override bool IsWatermarkRendered
{
get
{
return !(this.Focused || _FreeTextEntryBox != null && _FreeTextEntryBox.Focused) && _DoubleInput.IsEmpty;
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string Text
{
get
{
return _DoubleInput.Text;
}
set
{
ValueObject = value;
}
}
/// <summary>
/// Decreases value of the control.
/// </summary>
public override void DecreaseValue()
{
if (this.FreeTextEntryMode)
ApplyFreeTextValue();
_DoubleInput.DecreaseValue();
if (this.FreeTextEntryMode && _FreeTextEntryBox != null)
_FreeTextEntryBox.Text = this.Text;
}
/// <summary>
/// Increases the value of the control.
/// </summary>
public override void IncreaseValue()
{
if (this.FreeTextEntryMode)
ApplyFreeTextValue();
_DoubleInput.IncreaseValue();
if (this.FreeTextEntryMode && _FreeTextEntryBox != null)
_FreeTextEntryBox.Text = this.Text;
}
internal VisualDoubleInput VisualDoubleInput
{
get { return (_DoubleInput); }
}
protected override void DropDownCalculatorValueChanged(object sender, ValueChangedEventArgs e)
{
this.Value = e.Value;
base.DropDownCalculatorValueChanged(sender, e);
}
protected override void UpdateCalculatorValue(Calculator calculator)
{
calculator.Value = this.Value;
}
#endregion
#region Free Text Entry Support
protected override void ApplyFreeTextValue()
{
if (_FreeTextEntryBox == null) return;
if (string.IsNullOrEmpty(_FreeTextEntryBox.Text))
this.ValueObject = null;
else
{
double value;
if (double.TryParse(_FreeTextEntryBox.Text, out value) && AutoResolveFreeTextEntries)
{
this.Value = value;
}
else
{
FreeTextEntryConversionEventArgs eventArgs = new FreeTextEntryConversionEventArgs(_FreeTextEntryBox.Text);
OnConvertFreeTextEntry(eventArgs);
if (eventArgs.IsValueConverted)
{
if (eventArgs.ControlValue is double)
this.Value = (double)eventArgs.ControlValue;
else if (eventArgs.ControlValue == null)
this.ValueObject = null;
else
throw new ArgumentException("ControlValue assigned is not double type.");
}
else
{
//if (_AutoResolveFreeTextEntries)
//{
// value = DateTime.MinValue;
// string text = _FreeTextEntryBox.Text.ToLower();
// if (text == "now")
// value = DateTime.Now;
// else if (text == "today")
// value = DateTime.Today;
// else if (text == "tomorrow")
// value = DateTime.Today.AddDays(1);
// else if (text == "yesterday")
// value = DateTime.Today.AddDays(-1);
// if (value == DateTime.MinValue)
// this.ValueObject = null;
// else
// this.Value = value;
//}
this.Value = 0;
}
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,181 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors
{
public enum eCollectionChangeType
{
Removing,
Removed,
Clearing,
Cleared,
Adding,
Added
}
/// <summary>
/// Indicates the hour format.
/// </summary>
public enum eHourPeriod
{
/// <summary>
/// Indicates Ante Meridiem period, before the middle day.
/// </summary>
AM,
/// <summary>
/// Indicates Post Meridiem after the middle day".
/// </summary>
PM
}
/// <summary>
/// Identifies the date time part.
/// </summary>
public enum eDateTimePart
{
Year,
Month,
Day,
DayName,
DayOfYear,
Hour,
Minute,
Second
}
/// <summary>
/// Specifies the input fields alignment inside of the control.
/// </summary>
public enum eHorizontalAlignment
{
Left,
Center,
Right
}
/// <summary>
/// Specifies the text alignment.
/// </summary>
public enum eTextAlignment
{
Left,
Center,
Right
}
/// <summary>
/// Specifies the format of the date time picker.
/// </summary>
public enum eDateTimePickerFormat
{
/// <summary>
/// Indicates that custom format specified by CustomFormat property is used.
/// </summary>
Custom,
/// <summary>
/// The DateTimePicker control displays the date/time value in the long date format set by the user's operating system.
/// </summary>
Long,
/// <summary>
/// The DateTimePicker control displays the date/time value in the short date format set by the user's operating system.
/// </summary>
Short,
/// <summary>
/// The DateTimePicker control displays the date/time value in the time format set by the user's operating system.
/// </summary>
LongTime,
/// <summary>
/// The DateTimePicker control displays the date/time value in the short time format set by the user's operating system.
/// </summary>
ShortTime
}
/// <summary>
/// Specifies the display format of the year in input control.
/// </summary>
public enum eYearDisplayFormat
{
FourDigit,
TwoDigit,
OneDigit
}
/// <summary>
/// Specifies the visual item alignment inside the parent group.
/// </summary>
public enum eItemAlignment
{
Left,
Right
}
/// <summary>
/// Specifies the vertical alignment.
/// </summary>
public enum eVerticalAlignment
{
Top,
Middle,
Bottom
}
internal enum eSystemItemType
{
Default,
/// <summary>
/// Describes the system button item type. System buttons are buttons created internally by controls.
/// </summary>
SystemButton
}
/// <summary>
/// Specifies the auto-change item when VisualUpDownButton control is clicked.
/// </summary>
public enum eUpDownButtonAutoChange
{
/// <summary>
/// No item is automatically changed.
/// </summary>
None,
/// <summary>
/// Auto-change focused item in parent group
/// </summary>
FocusedItem,
/// <summary>
/// Auto change first input item before the Up/Down button in parent group.
/// </summary>
PreviousInputItem
}
/// <summary>
/// Specifies the keys used for navigation between input fields.
/// </summary>
[Flags()]
public enum eInputFieldNavigation
{
/// <summary>
/// No key is used for the navigation.
/// </summary>
None = 0,
/// <summary>
/// Tab key is used to advance to the next input field.
/// </summary>
Tab = 1,
/// <summary>
/// Arrow keys are used to advance to the next input field.
/// </summary>
Arrows = 2,
/// <summary>
/// Enter key is used to advance to the next input field.
/// </summary>
Enter = 4,
/// <summary>
/// Tab, Arrows and Enter keys are used to advance to the next input field.
/// </summary>
All = Tab | Arrows | Enter
}
}
#endif

View File

@@ -0,0 +1,250 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors
{
public class IpAddressGroup : VisualInputGroup
{
#region Events
public event EventHandler ValueChanged;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the IPAddressGroup class.
/// </summary>
public IpAddressGroup()
{
// Create IP4 default items
for (int i = 0; i < 4; i++)
{
VisualIntegerInput input = new VisualIntegerInput();
input.MaxValue = 255;
input.MinValue = 0;
this.Items.Add(input);
if (i < 3)
{
VisualLabel label = new VisualLabel();
label.Text = ".";
this.Items.Add(label);
}
}
}
#endregion
#region Internal Implementation
private string _Value;
public string Value
{
get
{
if (this.IsFocused)
{
if (IsInputValid())
return GetCurrentInputValue();
}
return _Value;
}
set
{
bool valueChanged = _Value != value;
if (!string.IsNullOrEmpty(value))
{
if (!IsValueValid(value))
throw new ArgumentException("Value is not valid IP value");
}
_Value = value;
UpdateInputItems();
if(valueChanged)
OnValueChanged(EventArgs.Empty);
}
}
bool _UpdatingInputItems = false;
private void UpdateInputItems()
{
if (_UpdatingInputItems) return;
_UpdatingInputItems = true;
try
{
if (string.IsNullOrEmpty(_Value))
{
// Clear all input
for (int i = 0; i < this.Items.Count; i++)
{
if (this.Items[i] is VisualIntegerInput)
{
VisualIntegerInput input = this.Items[i] as VisualIntegerInput;
input.IsEmpty = true;
}
}
}
else
{
int[] value = ParseIPv4Value(_Value);
int index = 0;
for (int i = 0; i < this.Items.Count; i++)
{
if (this.Items[i] is VisualIntegerInput)
{
VisualIntegerInput input = this.Items[i] as VisualIntegerInput;
input.Value = value[index];
index++;
}
}
}
}
finally
{
_UpdatingInputItems = false;
}
}
private void OnValueChanged(EventArgs e)
{
EventHandler handler = ValueChanged;
if (handler != null) ValueChanged(this, e);
}
internal bool IsValueValid(string ipValue)
{
int[] value = ParseIPv4Value(ipValue);
return value != null;
}
private int[] ParseIPv4Value(string ipValue)
{
if (string.IsNullOrEmpty(ipValue)) return null;
string[] parts = ipValue.Split('.');
if (parts.Length != 4) return null;
int[] value = new int[4];
for (int i = 0; i < parts.Length; i++)
{
int partValue = 0;
if (int.TryParse(parts[i], out partValue))
{
if (partValue < 0 || partValue > 255) return null;
value[i] = partValue;
}
else return null;
}
return value;
}
private bool IsInputValid()
{
bool allEmpty = true;
for (int i = 0; i < this.Items.Count; i++)
{
VisualIntegerInput input = this.Items[i] as VisualIntegerInput;
if (input != null)
{
if (input.IsEmpty)
{
if (!allEmpty && AllowEmptyState) return false;
}
else
{
if (allEmpty && i > 0) return false;
allEmpty = false;
}
}
}
return true;
}
protected override void OnLostFocus()
{
UpdateValue();
base.OnLostFocus();
}
protected override void OnInputChanged(VisualInputBase input)
{
if (!_UpdatingInputItems && GetCurrentInputValue() != null)
{
_UpdatingInputItems = true; // Stop update of UI items
try
{
UpdateValue();
}
finally
{
_UpdatingInputItems = false;
}
}
base.OnInputChanged(input);
}
private string GetCurrentInputValue()
{
int[] value = new int[4];
int index = 0;
bool isInvalid = false;
for (int i = 0; i < this.Items.Count; i++)
{
VisualIntegerInput input = this.Items[i] as VisualIntegerInput;
if (input != null)
{
if (input.IsEmpty)
{
if (!this.AllowEmptyState)
value[index] = 0;
else
{
isInvalid = true;
break;
}
}
value[index] = input.Value;
index++;
}
}
if (isInvalid)
return null;
else
{
string s = "";
for (int i = 0; i < value.Length; i++)
{
s += value[i].ToString();
if (i < value.Length - 1)
s += ".";
}
return s;
}
}
private void UpdateValue()
{
Value = GetCurrentInputValue();
}
private bool _ResettingValue = false;
protected override void ResetValue()
{
_ResettingValue = true;
try
{
this.Value = null;
}
finally
{
_ResettingValue = false;
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,347 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
/// <summary>
/// Describes input button settings.
/// </summary>
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class InputButtonSettings : IComparable
{
#region Private Variables
private IInputButtonControl _Parent = null;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the InputButtonSettings class.
/// </summary>
public InputButtonSettings()
{
}
/// <summary>
/// Initializes a new instance of the InputButtonSettings class.
/// </summary>
/// <param name="parent"></param>
public InputButtonSettings(IInputButtonControl parent)
{
_Parent = parent;
}
#endregion
#region Internal Implementation
private bool _Visible = false;
/// <summary>
/// Gets or sets whether button is visible.
/// </summary>
[DefaultValue(false), Description("Indicates whether button is visible.")]
public bool Visible
{
get { return _Visible; }
set
{
if (_Visible != value)
{
_Visible = value;
OnVisibleChanged();
}
}
}
private void OnVisibleChanged()
{
NotifyParent();
}
private bool _Enabled = true;
/// <summary>
/// Gets or sets whether button is enabled.
/// </summary>
[DefaultValue(true), Description("Indicates whether button is enabled.")]
public bool Enabled
{
get { return _Enabled; }
set
{
if (_Enabled != value)
{
_Enabled = value;
NotifyParent();
}
}
}
private int _DisplayPosition = 0;
/// <summary>
/// Gets or sets the display position index of the button. Buttons are ordered from left to right with button with lowest index appearing as left-most button.
/// </summary>
[DefaultValue(0), Description("Indicates display position index of the button."), Localizable(true)]
public int DisplayPosition
{
get { return _DisplayPosition; }
set
{
if (_DisplayPosition != value)
{
_DisplayPosition = value;
OnDisplayPositionChanged();
}
}
}
private void OnDisplayPositionChanged()
{
NotifyParent();
}
private Image _Image = null;
/// <summary>
/// Gets or sets the image displayed on the face of the button.
/// </summary>
[DefaultValue(null), Description("Indicates image displayed on the face of the button."), Localizable(true)]
public Image Image
{
get { return _Image; }
set
{
if (_Image != value)
{
_Image = value;
OnImageChanged();
}
}
}
private void OnImageChanged()
{
NotifyParent();
}
private string _Text = "";
/// <summary>
/// Gets or sets the text displayed on the input button face.
/// </summary>
[DefaultValue(""), Description("Input text displayed on the input button face."), Localizable(true)]
public string Text
{
get { return _Text; }
set
{
if (value == null) value = "";
if (_Text != value)
{
_Text = value;
OnTextChanged();
}
}
}
private void OnTextChanged()
{
NotifyParent();
}
private bool _Checked = false;
[DefaultValue(false), Description("Gets or sets whether button is checked.")]
public bool Checked
{
get { return _Checked; }
set
{
if (_Checked!=value)
{
_Checked = value;
OnCheckedChanged();
}
}
}
private void OnCheckedChanged()
{
NotifyParent();
}
private void NotifyParent()
{
if (_Parent != null)
_Parent.InputButtonSettingsChanged(this);
}
private VisualItem _ItemReference = null;
/// <summary>
/// Gets or sets the visual item button references for its action.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public VisualItem ItemReference
{
get { return _ItemReference; }
set { _ItemReference = value; }
}
private eShortcut _Shortcut = eShortcut.None;
/// <summary>
/// Gets or sets the shortcut key which when pressed triggers button click event or its default function.
/// </summary>
[DefaultValue(eShortcut.None), Description("Indicates shortcut key which when pressed triggers button click event or its default function.")]
public eShortcut Shortcut
{
get { return _Shortcut; }
set
{
if (_Shortcut != value)
{
_Shortcut = value;
NotifyParent();
}
}
}
private string _Tooltip = "";
/// <summary>
/// Gets or sets tooltip displayed for the button when mouse hovers over it.
/// </summary>
[DefaultValue(""), Category("Appearance"), Description("Indicates tooltip displayed for the button when mouse hovers over it."), Localizable(true)]
public string Tooltip
{
get { return _Tooltip; }
set
{
if (value == null) value = "";
_Tooltip = value;
}
}
private string _Symbol = "";
/// <summary>
/// Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.
/// </summary>
[DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.")]
[Editor("DevComponents.DotNetBar.Design.SymbolTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
public string Symbol
{
get { return _Symbol; }
set
{
if (value != _Symbol)
{
string oldValue = _Symbol;
_Symbol = value;
OnSymbolChanged(oldValue, value);
}
}
}
/// <summary>
/// Called when Symbol property has changed.
/// </summary>
/// <param name="oldValue">Old property value</param>
/// <param name="newValue">New property value</param>
protected virtual void OnSymbolChanged(string oldValue, string newValue)
{
//OnPropertyChanged(new PropertyChangedEventArgs("Symbol"));
NotifyParent();
}
private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
/// <summary>
/// Gets or sets the symbol set used to represent the Symbol.
/// </summary>
[Browsable(false), DefaultValue(eSymbolSet.Awesome)]
public eSymbolSet SymbolSet
{
get { return _SymbolSet; }
set
{
if (_SymbolSet != value)
{
eSymbolSet oldValue = _SymbolSet;
_SymbolSet = value;
OnSymbolSetChanged(oldValue, value);
}
}
}
/// <summary>
/// Called when SymbolSet property value changes.
/// </summary>
/// <param name="oldValue">Indciates old value</param>
/// <param name="newValue">Indicates new value</param>
protected virtual void OnSymbolSetChanged(eSymbolSet oldValue, eSymbolSet newValue)
{
NotifyParent();
}
private Color _SymbolColor = Color.Empty;
/// <summary>
/// Gets or sets the color of the Symbol.
/// </summary>
[Category("Appearance"), Description("Indicates color of the Symbol.")]
public Color SymbolColor
{
get { return _SymbolColor; }
set { _SymbolColor = value; NotifyParent(); }
}
/// <summary>
/// Gets whether property should be serialized.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeSymbolColor()
{
return !_SymbolColor.IsEmpty;
}
/// <summary>
/// Resets property to its default value.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetSymbolColor()
{
this.SymbolColor = Color.Empty;
}
#endregion
/// <summary>
/// Copies properties to new instance of the item.
/// </summary>
/// <param name="copy">New InputButtonSettings instance</param>
internal void CopyToItem(InputButtonSettings copy)
{
copy.Visible = Visible;
copy.Enabled = Enabled;
copy.DisplayPosition = DisplayPosition;
copy.Image = Image;
copy.Text = Text;
copy.Checked = Checked;
copy.Shortcut = Shortcut;
}
#region IComparable Members
int IComparable.CompareTo(object obj)
{
if (obj is InputButtonSettings)
{
int pos = ((InputButtonSettings)obj).DisplayPosition - this.DisplayPosition;
if (pos == 0)
{
if (obj != this) pos = -1;
}
return pos;
}
return 0;
}
#endregion
}
public interface IInputButtonControl
{
void InputButtonSettingsChanged(InputButtonSettings button);
}
}
#endif

View File

@@ -0,0 +1,95 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Drawing;
using System.ComponentModel;
namespace DevComponents.Editors
{
/// <summary>
/// Defines the system colors used by the input controls.
/// </summary>
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class InputControlColors
{
/// <summary>
/// Occurs when color has changed.
/// </summary>
public event EventHandler ColorChanged;
private Color _Highlight = Color.Empty;
/// <summary>
/// Gets or sets the background color of input item part when part has input focus. Default value is Color.Empty which indicates that system Highlight color is used.
/// </summary>
public Color Highlight
{
get { return _Highlight; }
set
{
if (_Highlight != value)
{
_Highlight = value;
OnColorChanged();
}
}
}
/// <summary>
/// Resets property to its default value. Provided for design-time support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetHighlight()
{
Highlight = Color.Empty;
}
/// <summary>
/// Returns whether property should be serialized. Provided for design-time support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeHighlight()
{
return !Highlight.IsEmpty;
}
private Color _HighlightText = Color.Empty;
/// <summary>
/// Gets or sets the text color of input item part when part has input focus. Default value is Color.Empty which indicates that system HighlightText color is used.
/// </summary>
public Color HighlightText
{
get { return _HighlightText; }
set
{
if (_HighlightText != value)
{
_HighlightText = value;
OnColorChanged();
}
}
}
/// <summary>
/// Resets property to its default value. Provided for design-time support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetHighlightText()
{
HighlightText = Color.Empty;
}
/// <summary>
/// Returns whether property should be serialized. Provided for design-time support.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeHighlightText()
{
return !HighlightText.IsEmpty;
}
private void OnColorChanged()
{
if (ColorChanged != null)
ColorChanged(this, new EventArgs());
}
}
}
#endif

View File

@@ -0,0 +1,31 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors
{
public class InputValidationEventArgs : EventArgs
{
public readonly string Input = "";
public bool AcceptInput = true;
/// <summary>
/// Initializes a new instance of the InputValidationEventArgs class.
/// </summary>
/// <param name="input">Indicates current input.</param>
public InputValidationEventArgs(string input)
{
Input = input;
}
}
/// <summary>
/// Defines delegate for input validation event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void InputValidationEventHandler(object sender, InputValidationEventArgs e);
}
#endif

View File

@@ -0,0 +1,342 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
/// <summary>
/// Control for input of the integer value.
/// </summary>
[ToolboxBitmap(typeof(DotNetBarManager), "IntegerInput.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.NumericInputBaseDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
[DefaultBindingProperty("ValueObject"), DefaultProperty("ValueObject")]
public class IntegerInput : NumericInputBase
{
#region Private Variables
private VisualIntegerInput _IntegerInput = null;
private VisualInputGroup _InputGroup = null;
#endregion
#region Events
/// <summary>
/// Occurs when ValueObject property is set and it allows you to provide custom parsing for the values.
/// </summary>
public event ParseIntegerValueEventHandler ParseValue;
#endregion
#region Constructor
#endregion
#region Internal Implementation
/// <summary>
/// Decreases value of the control.
/// </summary>
public override void DecreaseValue()
{
if (this.FreeTextEntryMode)
ApplyFreeTextValue();
_IntegerInput.DecreaseValue();
if (this.FreeTextEntryMode && _FreeTextEntryBox != null)
_FreeTextEntryBox.Text = this.Text;
}
/// <summary>
/// Increases the value of the control.
/// </summary>
public override void IncreaseValue()
{
if (this.FreeTextEntryMode)
ApplyFreeTextValue();
_IntegerInput.IncreaseValue();
if (this.FreeTextEntryMode && _FreeTextEntryBox != null)
_FreeTextEntryBox.Text = this.Text;
}
/// <summary>
/// Copies the current value in the control to the Clipboard.
/// </summary>
public virtual void Copy()
{
if (_IntegerInput != null) _IntegerInput.ProcessClipboardCopy();
}
/// <summary>
/// Pastes the current Clipboard content if possible as the value into the control.
/// </summary>
public virtual void Paste()
{
if (_IntegerInput != null) _IntegerInput.ProcessClipboardPaste();
}
/// <summary>
/// Moves the current control value to the Clipboard.
/// </summary>
public virtual void Cut()
{
if (_IntegerInput != null) _IntegerInput.ProcessClipboardCut();
}
protected override VisualItem CreateRootVisual()
{
VisualInputGroup g = new VisualInputGroup();
VisualIntegerInput i = new VisualIntegerInput();
i.ValueChanged += new EventHandler(InputItemValueChanged);
g.Items.Add(i);
_InputGroup = g;
_IntegerInput = i;
return g;
}
/// <summary>
/// Gets or sets whether mouse wheel increases or decreases the input value when used.
/// </summary>
[DefaultValue(true), Category("Behavior"), Description("Indicates whether mouse wheel increases or decreases the input value when used.")]
public bool MouseWheelValueChangeEnabled
{
get { return _IntegerInput.MouseWheelValueChangeEnabled; }
set
{
_IntegerInput.MouseWheelValueChangeEnabled = value;
}
}
protected override void UpdateInputFieldAlignment()
{
if (this.InputHorizontalAlignment == eHorizontalAlignment.Right)
{
if (!ButtonClear.Visible && !ButtonDropDown.Visible && !ButtonFreeText.Visible && !ButtonCustom.Visible && !ButtonCustom2.Visible && !ButtonCalculator.Visible && !ShowUpDown)
_IntegerInput.Alignment = eItemAlignment.Right;
else
_IntegerInput.Alignment = eItemAlignment.Left;
}
else
{
_IntegerInput.Alignment = eItemAlignment.Left;
}
base.UpdateInputFieldAlignment();
}
private void InputItemValueChanged(object sender, EventArgs e)
{
OnValueChanged(e);
if (this.FreeTextEntryMode && _FreeTextEntryBox != null && _FreeTextEntryBox.Text != this.Text)
_FreeTextEntryBox.Text = this.Text;
}
protected override void OnDisplayFormatChanged()
{
_IntegerInput.DisplayFormat = this.DisplayFormat;
}
/// <summary>
/// Gets or sets the value displayed in the control.
/// </summary>
[DefaultValue(0), Description("Indicates value displayed in the control.")]
public int Value
{
get { return _IntegerInput.Value; }
set
{
if (Value != value || _IntegerInput.IsEmpty)
{
_IntegerInput.Value = value;
}
}
}
/// <summary>
/// Gets or sets the value of the control as an object. This property allows you to bind to the database fields and supports
/// null values. Expected value is int type or null.
/// </summary>
[Bindable(true), RefreshProperties(RefreshProperties.All), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter))]
public object ValueObject
{
get
{
if (this.IsEmpty)
return null;
return Value;
}
set
{
if (AcceptCustomValueObject(value))
return;
else if (IsNull(value) || value is string && string.IsNullOrEmpty((string)value))
this.IsEmpty = true;
else if (value is int)
{
this.Value = (int)value;
}
else if (value is byte || value is Int16)
{
this.Value = (int)value;
}
else if (value is string)
{
int i = 0;
if (int.TryParse(value.ToString(), out i))
this.Value = i;
else
throw new ArgumentException("ValueObject property expects either null/nothing value or int type.");
}
else
throw new ArgumentException("ValueObject property expects either null/nothing value or int type.");
}
}
private bool AcceptCustomValueObject(object value)
{
ParseIntegerValueEventArgs e = new ParseIntegerValueEventArgs(value);
OnParseValue(e);
if (e.IsParsed)
{
this.Value = e.ParsedValue;
}
return e.IsParsed;
}
/// <summary>
/// Raises the ParseValue event.
/// </summary>
/// <param name="e">Provides event arguments.</param>
protected virtual void OnParseValue(ParseIntegerValueEventArgs e)
{
if (ParseValue != null)
ParseValue(this, e);
}
/// <summary>
/// Gets or sets the maximum value that can be entered.
/// </summary>
[DefaultValue(int.MaxValue), Description("Indicates maximum value that can be entered.")]
public int MaxValue
{
get { return _IntegerInput.MaxValue; }
set
{
_IntegerInput.MaxValue = value;
}
}
/// <summary>
/// Gets or sets the minimum value that can be entered.
/// </summary>
[DefaultValue(int.MinValue), Description("Indicates minimum value that can be entered.")]
public int MinValue
{
get { return _IntegerInput.MinValue; }
set
{
_IntegerInput.MinValue = value;
}
}
/// <summary>
/// Gets or sets the value to increment or decrement the value of the control when the up or down buttons are clicked.
/// </summary>
[DefaultValue(1), Description("Indicates value to increment or decrement the value of the control when the up or down buttons are clicked. ")]
public int Increment
{
get { return _IntegerInput.Increment; }
set { _IntegerInput.Increment = value; }
}
protected override bool IsWatermarkRendered
{
get
{
return !(this.Focused || _FreeTextEntryBox != null && _FreeTextEntryBox.Focused) && _IntegerInput.IsEmpty;
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string Text
{
get
{
return _IntegerInput.Text;
}
set
{
ValueObject = value;
}
}
protected override void OnDropDownCalculatorCreated(Calculator calculator)
{
base.OnDropDownCalculatorCreated(calculator);
calculator.IsIntValue = true;
}
protected override void DropDownCalculatorValueChanged(object sender, ValueChangedEventArgs e)
{
this.Value = (int)e.Value;
base.DropDownCalculatorValueChanged(sender, e);
}
protected override void UpdateCalculatorValue(Calculator calculator)
{
calculator.Value = this.Value;
}
#endregion
#region Free Text Entry Support
protected override void ApplyFreeTextValue()
{
if (_FreeTextEntryBox == null) return;
if (string.IsNullOrEmpty(_FreeTextEntryBox.Text))
this.ValueObject = null;
else
{
int value;
if (int.TryParse(_FreeTextEntryBox.Text, out value) && AutoResolveFreeTextEntries)
{
this.Value = value;
}
else
{
FreeTextEntryConversionEventArgs eventArgs = new FreeTextEntryConversionEventArgs(_FreeTextEntryBox.Text);
OnConvertFreeTextEntry(eventArgs);
if (eventArgs.IsValueConverted)
{
if (eventArgs.ControlValue is int)
this.Value = (int)eventArgs.ControlValue;
else if (eventArgs.ControlValue == null)
this.ValueObject = null;
else
throw new ArgumentException("ControlValue assigned is not int type.");
}
else
{
//if (_AutoResolveFreeTextEntries)
//{
// value = DateTime.MinValue;
// string text = _FreeTextEntryBox.Text.ToLower();
// if (text == "now")
// value = DateTime.Now;
// else if (text == "today")
// value = DateTime.Today;
// else if (text == "tomorrow")
// value = DateTime.Today.AddDays(1);
// else if (text == "yesterday")
// value = DateTime.Today.AddDays(-1);
// if (value == DateTime.MinValue)
// this.ValueObject = null;
// else
// this.Value = value;
//}
this.Value = 0;
}
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,873 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.ComponentModel;
using DevComponents.DotNetBar;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
namespace DevComponents.Editors
{
/// <summary>
/// Control for input of the integer value.
/// </summary>
[ToolboxBitmap(typeof(DotNetBarManager), "IpAddressInput.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.IpAddressInputDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
public class IpAddressInput : VisualControlBase, ICommandSource
{
#region Events
/// <summary>
/// Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.
/// </summary>
public event CancelEventHandler ButtonClearClick;
/// <summary>
/// Occurs when Drop-Down button that shows calendar is clicked and allows you to cancel showing of the popup.
/// </summary>
public event CancelEventHandler ButtonDropDownClick;
/// <summary>
/// Occurs when ShowCheckBox property is set to true and user changes the lock status of the control by clicking the check-box.
/// </summary>
public event EventHandler LockUpdateChanged;
/// <summary>
/// Occurs when Value property has changed.
/// </summary>
public event EventHandler ValueChanged;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the IpAddressInput class.
/// </summary>
public IpAddressInput():base()
{
_ButtonClear = new InputButtonSettings(this);
_ButtonDropDown = new InputButtonSettings(this);
_ButtonFreeText = new InputButtonSettings(this);
_IpGroup = this.RootVisualItem as IpAddressGroup;
}
#endregion
#region Internal Implementation
private IpAddressGroup _IpGroup = null;
protected override VisualItem CreateRootVisual()
{
IpAddressGroup group = new IpAddressGroup();
group.SelectNextInputCharacters = ".";
group.ValueChanged += new EventHandler(InputItemValueChanged);
return group;
}
private void InputItemValueChanged(object sender, EventArgs e)
{
if (_Value != _IpGroup.Value)
this.Value = _IpGroup.Value;
}
/// <summary>
/// Copies the current value in the control to the Clipboard.
/// </summary>
public virtual void Copy()
{
if (_IpGroup != null) Clipboard.SetText(this.Text);
}
/// <summary>
/// Pastes the current Clipboard content if possible as the value into the control.
/// </summary>
public virtual void Paste()
{
if (_IpGroup != null) Text = Clipboard.GetText();
}
/// <summary>
/// Moves the current control value to the Clipboard.
/// </summary>
public virtual void Cut()
{
if (_IpGroup != null)
{
Copy();
if (this.AllowEmptyState)
Text = null;
}
}
private InputButtonSettings _ButtonDropDown = null;
/// <summary>
/// Gets the object that describes the settings for the button that shows drop-down when clicked.
/// </summary>
[Category("Buttons"), Description("Describes the settings for the button that shows drop-down when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public InputButtonSettings ButtonDropDown
{
get
{
return _ButtonDropDown;
}
}
private InputButtonSettings _ButtonClear = null;
/// <summary>
/// Gets the object that describes the settings for the button that clears the content of the control when clicked.
/// </summary>
[Category("Buttons"), Description("Describes the settings for the button that clears the content of the control when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public InputButtonSettings ButtonClear
{
get
{
return _ButtonClear;
}
}
private InputButtonSettings _ButtonFreeText = null;
/// <summary>
/// Gets the object that describes the settings for the button that switches the control into the free-text entry mode when clicked.
/// </summary>
[Category("Buttons"), Description("Describes the settings for the button that switches the control into the free-text entry mode when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public InputButtonSettings ButtonFreeText
{
get
{
return _ButtonFreeText;
}
}
protected override VisualItem CreateButton(InputButtonSettings buttonSettings)
{
VisualItem item = null;
if (buttonSettings == _ButtonDropDown)
{
item = new VisualDropDownButton();
ApplyButtonSettings(buttonSettings, item as VisualButton);
}
else
item = base.CreateButton(buttonSettings);
VisualButton button = item as VisualButton;
button.ClickAutoRepeat = false;
if (buttonSettings == _ButtonClear)
{
if (buttonSettings.Image == null && string.IsNullOrEmpty(buttonSettings.Text))
{
//if (Dpi.Factor.Width > 1)
button.Symbol = "\uf00d";
//else
// button.Image = DevComponents.DotNetBar.BarFunctions.LoadBitmap("SystemImages.DateReset.png");
}
}
else if (buttonSettings == _ButtonFreeText)
{
if (buttonSettings.Image == null && string.IsNullOrEmpty(buttonSettings.Text))
{
//if (Dpi.Factor.Width > 1)
button.Symbol = "\uf040";
//else
// button.Image = DevComponents.DotNetBar.BarFunctions.LoadBitmap("SystemImages.FreeText.png");
}
button.Checked = buttonSettings.Checked;
}
return item;
}
/// <summary>
/// Gets or sets whether auto-overwrite functionality for input is enabled. When in auto-overwrite mode input field will erase existing entry
/// and start new one if typing is continued after InputComplete method is called.
/// </summary>
[DefaultValue(false), Description("Indicates whether auto-overwrite functionality for input is enabled.")]
public bool AutoOverwrite
{
get { return _IpGroup.AutoOverwrite; }
set { _IpGroup.AutoOverwrite = value; }
}
/// <summary>
/// Gets or sets whether empty null/nothing state of the control is allowed. Default value is true which means that Text property
/// may return null if there is no input value.
/// </summary>
[DefaultValue(true), Description("Indicates whether empty null/nothing state of the control is allowed.")]
public bool AllowEmptyState
{
get { return _IpGroup.AllowEmptyState; }
set { _IpGroup.AllowEmptyState = value; this.Invalidate(); }
}
private Control _DropDownControl = null;
/// <summary>
/// Gets or sets the reference of the control that will be displayed on popup that is shown when drop-down button is clicked.
/// </summary>
[DefaultValue(null), Description("Indicates reference of the control that will be displayed on popup that is shown when drop-down button is clicked.")]
public Control DropDownControl
{
get { return _DropDownControl; }
set
{
_DropDownControl = value;
}
}
private ButtonItem _PopupItem = null;
protected override PopupItem CreatePopupItem()
{
ButtonItem button = new ButtonItem("sysPopupProvider");
button.PopupFinalized += new EventHandler(DropDownPopupClose);
_PopupItem = button;
return button;
}
/// <summary>
/// Gets the collection of BaseItem derived items displayed on popup menu.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public SubItemsCollection DropDownItems
{
get { return _PopupItem.SubItems; }
}
protected override System.Collections.SortedList CreateSortedButtonList()
{
SortedList list = base.CreateSortedButtonList();
if (_ButtonClear.Visible)
{
VisualItem button = CreateButton(_ButtonClear);
if (_ButtonClear.ItemReference != null)
_ButtonClear.ItemReference.Click -= new EventHandler(ClearButtonClick);
_ButtonClear.ItemReference = button;
button.Click += new EventHandler(ClearButtonClick);
list.Add(_ButtonClear, button);
}
if (_ButtonDropDown.Visible)
{
VisualItem button = CreateButton(_ButtonDropDown);
if (_ButtonDropDown.ItemReference != null)
{
_ButtonDropDown.ItemReference.MouseDown -= new MouseEventHandler(DropDownButtonMouseDown);
}
_ButtonDropDown.ItemReference = button;
button.MouseDown += new MouseEventHandler(DropDownButtonMouseDown);
list.Add(_ButtonDropDown, button);
}
if (_ButtonFreeText.Visible)
{
VisualItem button = CreateButton(_ButtonFreeText);
if (_ButtonFreeText.ItemReference != null)
_ButtonFreeText.ItemReference.Click -= new EventHandler(FreeTextButtonClick);
_ButtonFreeText.ItemReference = button;
button.Click += FreeTextButtonClick;
list.Add(_ButtonFreeText, button);
}
return list;
}
private Control _PreviousDropDownControlParent = null;
private void DropDownButtonMouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left || _CloseTime != DateTime.MinValue && DateTime.Now.Subtract(_CloseTime).TotalMilliseconds < 150)
{
_CloseTime = DateTime.MinValue;
return;
}
ShowDropDown();
}
private static string _DropDownControlContainerName = "sysPopupControlContainer";
private static string _DropDownItemContainerName = "sysPopupItemContainer";
/// <summary>
/// Shows drop-down popup. Note that popup will be shown only if there is a DropDownControl assigned or DropDownItems collection has at least one item.
/// </summary>
public void ShowDropDown()
{
if (_DropDownControl == null && _PopupItem.SubItems.Count == 0)
return;
if (_PopupItem.Expanded)
{
_PopupItem.Expanded = false;
return;
}
ControlContainerItem cc = null;
ItemContainer ic = null;
if (_DropDownControl != null)
{
ic = new ItemContainer();
ic.Name = _DropDownItemContainerName;
cc = new ControlContainerItem(_DropDownControlContainerName);
ic.SubItems.Add(cc);
_PopupItem.SubItems.Insert(0, ic);
}
CancelEventArgs cancelArgs = new CancelEventArgs();
OnButtonDropDownClick(cancelArgs);
if (cancelArgs.Cancel || _PopupItem.SubItems.Count == 0)
{
if (ic != null)
_PopupItem.SubItems.Remove(ic);
return;
}
_PreviousDropDownControlParent = _DropDownControl.Parent;
cc.Control = _DropDownControl;
_PopupItem.SetDisplayRectangle(this.ClientRectangle);
if (this.RightToLeft == RightToLeft.No)
{
Point pl = new Point(this.Width - _PopupItem.PopupSize.Width, this.Height);
ScreenInformation screen = BarFunctions.ScreenFromControl(this);
Point ps = PointToScreen(pl);
if (screen != null && screen.WorkingArea.X > ps.X)
{
pl.X = 0;
}
_PopupItem.PopupLocation = pl;
}
_PopupItem.Expanded = !_PopupItem.Expanded;
}
/// <summary>
/// Closes the drop-down popup if it is open.
/// </summary>
public void CloseDropDown()
{
if (_PopupItem.Expanded) _PopupItem.Expanded = false;
}
private DateTime _CloseTime = DateTime.MinValue;
private void DropDownPopupClose(object sender, EventArgs e)
{
_CloseTime = DateTime.Now;
ItemContainer ic = _PopupItem.SubItems[_DropDownItemContainerName] as ItemContainer;
if (ic != null)
{
ControlContainerItem cc = ic.SubItems[_DropDownControlContainerName] as ControlContainerItem;
if (cc != null)
{
cc.Control = null;
ic.SubItems.Remove(cc);
if (_DropDownControl != null)
{
_DropDownControl.Parent = _PreviousDropDownControlParent;
_PreviousDropDownControlParent = null;
}
}
_PopupItem.SubItems.Remove(ic);
}
}
private void ClearButtonClick(object sender, EventArgs e)
{
CancelEventArgs cancelArgs = new CancelEventArgs();
OnButtonClearClick(cancelArgs);
if (cancelArgs.Cancel) return;
_IpGroup.Value = null;
}
/// <summary>
/// Raises the ButtonClearClick event.
/// </summary>
/// <param name="e"></param>
protected virtual void OnButtonClearClick(CancelEventArgs e)
{
if (ButtonClearClick != null)
ButtonClearClick(this, e);
}
/// <summary>
/// Raises the ButtonDropDownClick event.
/// </summary>
/// <param name="e"></param>
protected virtual void OnButtonDropDownClick(CancelEventArgs e)
{
if (ButtonDropDownClick != null)
ButtonDropDownClick(this, e);
}
/// <summary>
/// Gets or sets whether input part of the control is read-only. When set to true the input part of the control becomes
/// read-only and does not allow the typing. However, drop-down part if visible still allows user to possibly change the value of the control
/// through the method you can provide on drop-down.
/// Use this property to allow change of the value through drop-down button only.
/// </summary>
[DefaultValue(false), Description("Indicates whether input part of the control is read-only.")]
public bool IsInputReadOnly
{
get { return _IpGroup.IsReadOnly; }
set
{
_IpGroup.IsReadOnly = value;
if (_FreeTextEntryBox != null)
_FreeTextEntryBox.ReadOnly = value;
}
}
private bool _ShowCheckBox = false;
/// <summary>
/// Gets or sets a value indicating whether a check box is displayed to the left of the input value.
/// Set to true if a check box is displayed to the left of the input value; otherwise, false. The default is false.
/// <remarks>
/// When the ShowCheckBox property is set to true, a check box is displayed to the left of the input in the control. When the check box is selected, the value can be updated. When the check box is cleared, the value is unable to be changed.
/// You can handle the LockUpdateChanged event to be notified when this check box is checked and unchecked. Use LockUpdateChecked property
/// to get or sets whether check box is checked.
/// </remarks>
/// </summary>
[DefaultValue(false), Description("Indicates whether a check box is displayed to the left of the input value which allows locking of the control.")]
public bool ShowCheckBox
{
get { return _ShowCheckBox; }
set
{
_ShowCheckBox = value;
OnShowCheckBoxChanged();
}
}
protected virtual void OnShowCheckBoxChanged()
{
LockUpdateCheckBox checkBox = LockUpdateCheckBox;
if (checkBox != null)
{
_IpGroup.Items.Remove(checkBox);
checkBox.CheckedChanged -= new EventHandler(LockCheckedChanged);
}
if (this.ShowCheckBox)
{
if (!(_IpGroup.Items[0] is LockUpdateCheckBox))
{
checkBox = new LockUpdateCheckBox();
checkBox.CheckedChanged += new EventHandler(LockCheckedChanged);
_IpGroup.Items.Insert(0, checkBox);
checkBox.Checked = _LockUpdateChecked;
}
}
}
private LockUpdateCheckBox LockUpdateCheckBox
{
get
{
if (_IpGroup.Items[0] is LockUpdateCheckBox)
return (LockUpdateCheckBox)_IpGroup.Items[0];
return null;
}
}
private void LockCheckedChanged(object sender, EventArgs e)
{
LockUpdateCheckBox checkBox = LockUpdateCheckBox;
if (checkBox != null)
_LockUpdateChecked = checkBox.Checked;
OnLockUpdateChanged(e);
}
private bool _LockUpdateChecked = false;
/// <summary>
/// Gets or sets whether check box shown using ShowCheckBox property which locks/unlocks the control update is checked.
/// </summary>
[DefaultValue(false), Description("Indicates whether check box shown using ShowCheckBox property which locks/unlocks the control update is checked.")]
public bool LockUpdateChecked
{
get { return _LockUpdateChecked; }
set
{
if (_LockUpdateChecked != value)
{
_LockUpdateChecked = value;
LockUpdateCheckBox checkBox = LockUpdateCheckBox;
if (checkBox != null)
checkBox.Checked = _LockUpdateChecked;
}
}
}
/// <summary>
/// Raises the LockUpdateChanged event.
/// </summary>
/// <param name="e">Provides event data./</param>
protected virtual void OnLockUpdateChanged(EventArgs e)
{
if (LockUpdateChanged != null)
LockUpdateChanged(this, e);
}
/// <summary>
/// List of characters that when pressed would select next input field. For example if you are
/// allowing time input you could set this property to : so when user presses the : character,
/// the input is forwarded to the next input field.
/// </summary>
[DefaultValue("."), Category("Behavior"), Description("List of characters that when pressed would select next input field.")]
public string SelectNextInputCharacters
{
get { return _IpGroup.SelectNextInputCharacters; }
set
{
if (_IpGroup.SelectNextInputCharacters != value)
{
_IpGroup.SelectNextInputCharacters = value;
}
}
}
private string _Value = null;
/// <summary>
/// Gets or sets the IP Address value represented by the control.
/// </summary>
[DefaultValue(null), Description("Gets or sets the IP Address value."), Bindable(true)]
public string Value
{
get { return _IpGroup.Value; }
set
{
_Value = value;
InternalValueChanged();
}
}
private void InternalValueChanged()
{
if (_Value != _IpGroup.Value)
{
_IpGroup.Value = _Value;
ExecuteCommand();
}
this.Text = _Value;
if (FreeTextEntryMode && _FreeTextEntryBox != null)
_FreeTextEntryBox.Text = _Value;
OnValueChanged(EventArgs.Empty);
}
/// <summary>
/// Raises ValueChanged event.
/// </summary>
/// <param name="eventArgs">Provides event arguments.</param>
protected virtual void OnValueChanged(EventArgs eventArgs)
{
EventHandler handler = ValueChanged;
if (handler != null) handler(this, eventArgs);
}
#endregion
#region Free-Text Entry Support
/// <summary>
/// Occurs if Free-Text entry value is not natively recognized by the control and provides you with opportunity to convert that value to the
/// value control expects.
/// </summary>
[Description("Occurs if Free-Text entry value is not natively recognized by the control and provides you with opportunity to convert that value to the value control expects."), Category("Free-Text")]
public event FreeTextEntryConversionEventHandler ConvertFreeTextEntry;
/// <summary>
/// Occurs when Free-Text button is clicked and allows you to cancel its default action.
/// </summary>
public event CancelEventHandler ButtonFreeTextClick;
private void FreeTextButtonClick(object sender, EventArgs e)
{
CancelEventArgs cancelArgs = new CancelEventArgs();
OnButtonFreeTextClick(cancelArgs);
if (cancelArgs.Cancel) return;
FreeTextEntryMode = !FreeTextEntryMode;
_ButtonFreeText.Checked = FreeTextEntryMode;
if (FreeTextEntryMode && _FreeTextEntryBox != null && !_FreeTextEntryBox.Focused)
_FreeTextEntryBox.Focus();
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected virtual void OnButtonFreeTextClick(CancelEventArgs e)
{
CancelEventHandler handler = ButtonFreeTextClick;
if (handler != null) handler(this, e);
}
protected override bool IsWatermarkRendered
{
get
{
return !(this.Focused || _FreeTextEntryBox != null && _FreeTextEntryBox.Focused) && _IpGroup.IsEmpty;
}
}
private bool _AutoResolveFreeTextEntries = true;
/// <summary>
/// Gets or sets whether free text entries are attempted to be auto-resolved to IP address as host/domain names. Default value is true.
/// </summary>
[DefaultValue(true), Category("Free-Text"), Description("Indicates whether free text entries are attempted to be auto-resolved to IP address as host/domain names.")]
public bool AutoResolveFreeTextEntries
{
get { return _AutoResolveFreeTextEntries; }
set
{
_AutoResolveFreeTextEntries = value;
}
}
private bool _AutoOffFreeTextEntry = false;
/// <summary>
/// Gets or sets whether free-text entry is automatically turned off when control loses input focus. Default value is false.
/// </summary>
[DefaultValue(false), Category("Free-Text"), Description("Indicates whether free-text entry is automatically turned off when control loses input focus.")]
public bool AutoOffFreeTextEntry
{
get { return _AutoOffFreeTextEntry; }
set
{
_AutoOffFreeTextEntry = value;
}
}
private bool _FreeTextEntryMode = false;
/// <summary>
/// Gets or sets whether control input is in free-text input mode. Default value is false.
/// </summary>
[DefaultValue(false), Category("Free-Text"), Description("Indicates whether control input is in free-text input mode.")]
public bool FreeTextEntryMode
{
get { return _FreeTextEntryMode; }
set
{
_FreeTextEntryMode = value;
OnFreeTextEntryModeChanged();
}
}
private void OnFreeTextEntryModeChanged()
{
if (!_FreeTextEntryMode)
{
if (_FreeTextEntryBox != null)
{
_FreeTextEntryBox.ApplyValue -= ApplyFreeTextValue;
_FreeTextEntryBox.RevertValue -= RevertFreeTextValue;
_FreeTextEntryBox.LostFocus -= FreeTextLostFocus;
this.Controls.Remove(_FreeTextEntryBox);
_FreeTextEntryBox.Dispose();
_FreeTextEntryBox = null;
}
}
else
{
UpdateFreeTextBoxVisibility();
}
if (_ButtonFreeText != null) _ButtonFreeText.Checked = _FreeTextEntryMode;
}
protected override void OnIsKeyboardFocusWithinChanged()
{
if (_FreeTextEntryMode)
{
UpdateFreeTextBoxVisibility();
if (this.IsKeyboardFocusWithin)
{
Control textBox = GetFreeTextBox();
if (!textBox.Focused)
textBox.Focus();
}
}
base.OnIsKeyboardFocusWithinChanged();
}
private void UpdateFreeTextBoxVisibility()
{
FreeTextEntryBox textBox = (FreeTextEntryBox)GetFreeTextBox();
if (this.IsKeyboardFocusWithin)
{
textBox.Visible = true;
textBox.Text = this.Value;
RootVisualItem.InvalidateArrange();
this.Invalidate();
}
else
{
if (textBox.Visible)
{
if (textBox.Focused)
textBox.HideOnLostFocus();
else
textBox.Visible = false;
RootVisualItem.InvalidateArrange();
this.Invalidate();
}
}
}
protected override bool SupportsFreeTextEntry
{
get
{
return true;
}
}
private FreeTextEntryBox _FreeTextEntryBox = null;
protected override Control GetFreeTextBox()
{
if (_FreeTextEntryBox == null)
{
_FreeTextEntryBox = new FreeTextEntryBox();
_FreeTextEntryBox.ApplyValue += ApplyFreeTextValue;
_FreeTextEntryBox.RevertValue += RevertFreeTextValue;
_FreeTextEntryBox.LostFocus += FreeTextLostFocus;
_FreeTextEntryBox.BorderStyle = BorderStyle.None;
_FreeTextEntryBox.ReadOnly = this.IsInputReadOnly;
this.Controls.Add(_FreeTextEntryBox);
}
return _FreeTextEntryBox;
}
private void RevertFreeTextValue(object sender, EventArgs e)
{
if (_FreeTextEntryBox != null) _FreeTextEntryBox.Text = this.Value;
}
protected virtual void OnConvertFreeTextEntry(FreeTextEntryConversionEventArgs e)
{
FreeTextEntryConversionEventHandler handler = this.ConvertFreeTextEntry;
if (handler != null) handler(this, e);
}
private void ApplyFreeTextValue(object sender, EventArgs e)
{
if (_FreeTextEntryBox == null) return;
if (string.IsNullOrEmpty(_FreeTextEntryBox.Text))
this.Value = null;
else if (_IpGroup.IsValueValid(_FreeTextEntryBox.Text) && _AutoResolveFreeTextEntries)
this.Value = _FreeTextEntryBox.Text;
else
{
FreeTextEntryConversionEventArgs eventArgs = new FreeTextEntryConversionEventArgs(_FreeTextEntryBox.Text);
OnConvertFreeTextEntry(eventArgs);
if (eventArgs.IsValueConverted)
{
if (eventArgs.ControlValue is string && _IpGroup.IsValueValid((string)eventArgs.ControlValue))
this.Value = (string)eventArgs.ControlValue;
else
throw new ArgumentException("ControlValue assigned is not recognized as valid IP value.");
}
else
{
string ipValue = null;
if (_AutoResolveFreeTextEntries)
{
try
{
System.Net.IPAddress[] addresses = System.Net.Dns.GetHostAddresses(_FreeTextEntryBox.Text);
if (addresses != null && addresses.Length > 0)
{
ipValue = addresses[0].ToString();
if (!_IpGroup.IsValueValid(ipValue))
ipValue = null;
}
}
catch
{
ipValue = null;
}
}
this.Value = ipValue;
}
}
}
private void FreeTextLostFocus(object sender, EventArgs e)
{
if (_AutoOffFreeTextEntry && !this.IsKeyboardFocusWithin)
this.FreeTextEntryMode = false;
}
protected override void HideFreeTextBoxEntry()
{
if (_FreeTextEntryBox != null) _FreeTextEntryBox.Visible = false;
}
protected override bool IsFreeTextEntryVisible
{
get
{
return _FreeTextEntryMode && this.IsKeyboardFocusWithin;
}
}
#endregion
#region ICommandSource Members
protected virtual void ExecuteCommand()
{
if (_Command == null) return;
CommandManager.ExecuteCommand(this);
}
/// <summary>
/// Gets or sets the command assigned to the item. Default value is null.
/// <remarks>Note that if this property is set to null Enabled property will be set to false automatically to disable the item.</remarks>
/// </summary>
[DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
public Command Command
{
get { return (Command)((ICommandSource)this).Command; }
set
{
((ICommandSource)this).Command = value;
}
}
private ICommand _Command = null;
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
ICommand ICommandSource.Command
{
get
{
return _Command;
}
set
{
bool changed = false;
if (_Command != value)
changed = true;
if (_Command != null)
CommandManager.UnRegisterCommandSource(this, _Command);
_Command = value;
if (value != null)
CommandManager.RegisterCommand(this, value);
if (changed)
OnCommandChanged();
}
}
/// <summary>
/// Called when Command property value changes.
/// </summary>
protected virtual void OnCommandChanged()
{
}
private object _CommandParameter = null;
/// <summary>
/// Gets or sets user defined data value that can be passed to the command when it is executed.
/// </summary>
[Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
public object CommandParameter
{
get
{
return _CommandParameter;
}
set
{
_CommandParameter = value;
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,53 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors
{
public class LockUpdateCheckBox : VisualCheckBox
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the LockUpdateCheckBox class.
/// </summary>
public LockUpdateCheckBox()
{
this.Checked = true;
}
#endregion
#region Internal Implementation
public override void PerformLayout(PaintInfo pi)
{
base.PerformLayout(pi);
this.Size = new System.Drawing.Size(this.Size.Width + 4, this.Size.Height);
}
protected override void OnCheckedChanged(EventArgs e)
{
if (this.Parent is VisualGroup)
{
VisualGroup g = this.Parent as VisualGroup;
for (int i = 0; i < g.Items.Count; i++)
{
VisualItem item = g.Items[i];
if (item == this) continue;
item.Enabled = this.Checked;
}
}
base.OnCheckedChanged(e);
}
#endregion
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Drawing;
namespace DevComponents.Editors
{
public class PaintInfo
{
private Graphics _Graphics;
public Graphics Graphics
{
get { return _Graphics; }
set { _Graphics = value; }
}
private Point _RenderOffset;
public Point RenderOffset
{
get { return _RenderOffset; }
set { _RenderOffset = value; }
}
private Font _DefaultFont = null;
public Font DefaultFont
{
get { return _DefaultFont; }
set { _DefaultFont = value; }
}
private Color _ForeColor = SystemColors.ControlText;
public Color ForeColor
{
get { return _ForeColor; }
set { _ForeColor = value; }
}
private Color _DisabledForeColor = SystemColors.ControlDark;
public Color DisabledForeColor
{
get { return _DisabledForeColor; }
set { _DisabledForeColor = value; }
}
private bool _WatermarkEnabled = false;
public bool WatermarkEnabled
{
get { return _WatermarkEnabled; }
set { _WatermarkEnabled = value; }
}
private Font _WatermarkFont = null;
public Font WatermarkFont
{
get { return _WatermarkFont; }
set { _WatermarkFont = value; }
}
private Color _WatermarkColor = Color.Empty;
public Color WatermarkColor
{
get { return _WatermarkColor; }
set { _WatermarkColor = value; }
}
private Size _AvailableSize;
/// <summary>
/// Gets or sets the size available for the item currently being arranged.
/// </summary>
public Size AvailableSize
{
get { return _AvailableSize; }
set { _AvailableSize = value; }
}
private bool _ParentEnabled = true;
public bool ParentEnabled
{
get { return _ParentEnabled; }
set
{
_ParentEnabled = value;
}
}
private bool _MouseOver = false;
/// <summary>
/// Gets or sets whether mouse is over the host control.
/// </summary>
public bool MouseOver
{
get { return _MouseOver; }
set { _MouseOver = value; }
}
private InputControlColors _Colors;
/// <summary>
/// Gets or sets system colors used by the control.
/// </summary>
public InputControlColors Colors
{
get { return _Colors; }
set { _Colors = value; }
}
private bool _RenderSystemItemsOnly = false;
public bool RenderSystemItemsOnly
{
get { return _RenderSystemItemsOnly; }
set
{
_RenderSystemItemsOnly = value;
}
}
}
}
#endif

View File

@@ -0,0 +1,55 @@
using System;
using System.Text;
namespace DevComponents.Editors
{
/// <summary>
/// Defines data for the ParseValue event that allows you to provide custom parsing for values set to ValueObject property.
/// </summary>
public class ParseDoubleValueEventArgs : EventArgs
{
/// <summary>
/// Get the value that was set to the ValueObject property and which should be converted to ParsedValue DateTime.
/// </summary>
public readonly object ValueObject = null;
/// <summary>
/// Gets or sets whether you have provided ParsedValue.
/// </summary>
public bool IsParsed = false;
/// <summary>
/// Initializes a new instance of the ParseDateTimeValueEventArgs class.
/// </summary>
/// <param name="valueObject">Indicates the value object.</param>
public ParseDoubleValueEventArgs(object valueObject)
{
ValueObject = valueObject;
}
private double _ParsedValue = 0;
/// <summary>
/// /// <summary>
/// Gets or sets the parsed value from ValueObject property.
/// </summary>
/// </summary>
public double ParsedValue
{
get { return _ParsedValue; }
set
{
_ParsedValue = value;
IsParsed = true;
}
}
}
/// <summary>
/// Defines delegate for ParseValue event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void ParseDoubleValueEventHandler(object sender, ParseDoubleValueEventArgs e);
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Text;
namespace DevComponents.Editors
{
/// <summary>
/// Defines data for the ParseValue event that allows you to provide custom parsing for values set to ValueObject property.
/// </summary>
public class ParseIntegerValueEventArgs : EventArgs
{
/// <summary>
/// Get the value that was set to the ValueObject property and which should be converted to ParsedValue DateTime.
/// </summary>
public readonly object ValueObject = null;
/// <summary>
/// Gets or sets whether you have provided ParsedValue.
/// </summary>
public bool IsParsed = false;
/// <summary>
/// Initializes a new instance of the ParseDateTimeValueEventArgs class.
/// </summary>
/// <param name="valueObject">Indicates the value object.</param>
public ParseIntegerValueEventArgs(object valueObject)
{
ValueObject = valueObject;
}
private int _ParsedValue = 0;
/// <summary>
/// /// <summary>
/// Gets or sets the parsed value from ValueObject property.
/// </summary>
/// </summary>
public int ParsedValue
{
get { return _ParsedValue; }
set
{
_ParsedValue = value;
IsParsed = true;
}
}
}
/// <summary>
/// Defines delegate for ParseValue event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void ParseIntegerValueEventHandler(object sender, ParseIntegerValueEventArgs e);
}

View File

@@ -0,0 +1,77 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors.Primitives
{
internal class StartsWithPredicate
{
private string _Prefix;
private int _MaxMatches = 0;
private int _MatchCount = 0;
// Initializes with prefix we want to match.
public StartsWithPredicate(string prefix)
{
_Prefix = prefix;
}
// Initializes with prefix we want to match.
public StartsWithPredicate(string prefix, int maxMatches)
{
_Prefix = prefix;
_MaxMatches = maxMatches;
}
// Sets a different prefix to match.
public string Prefix
{
get { return _Prefix; }
set { _Prefix = value; }
}
public void ResetMatchCount()
{
_MatchCount = 0;
}
public int MaxMatches
{
get { return _MaxMatches; }
set
{
_MaxMatches = value;
}
}
// Gets the predicate.
public Predicate<string> Match
{
get { return IsMatch; }
}
private bool IsMatch(string s)
{
return s.ToLower().StartsWith(_Prefix);
}
public Predicate<string> MatchTop
{
get
{
return IsMatchTop;
}
}
private bool IsMatchTop(string s)
{
if (_MatchCount > _MaxMatches) return false;
bool b = s.ToLower().StartsWith(_Prefix);
if (b && _MaxMatches > 0) _MatchCount++;
return b;
}
}
}
#endif

View File

@@ -0,0 +1,24 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.Editors
{
public class SystemOptions
{
internal static System.Windows.Forms.ControlStyles DoubleBufferFlag
{
get
{
#if FRAMEWORK20
return System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer;
#else
return System.Windows.Forms.ControlStyles.DoubleBuffer;
#endif
}
}
}
}
#endif

View File

@@ -0,0 +1,368 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Collections;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Rendering;
namespace DevComponents.Editors
{
public class VisualButton : VisualButtonBase
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
public override void PerformLayout(PaintInfo pi)
{
Size size = new Size(0, (_Height > 0 ? Dpi.Height(_Height) : pi.AvailableSize.Height));
Graphics g = pi.Graphics;
size.Width += Dpi.Width6; // Border 2 pixels on each side and 1 pixels of padding between border and content
if (_Text.Length > 0)
{
Size textSize = TextDrawing.MeasureString(g, _Text, pi.DefaultFont);
size.Width += textSize.Width;
if (_Image != null)
size.Width += Dpi.Width4; // Padding between text and image
}
if (!string.IsNullOrEmpty(_SymbolRealized))
{
size.Width += size.Height;
}
else if (_Image != null)
{
size.Width += Dpi.Width(_Image.Width);
}
if (_Text.Length == 0 && _Image == null && string.IsNullOrEmpty(_SymbolRealized))
size.Width += Dpi.Width9;
this.Size = size;
this.CalculatedSize = size;
base.PerformLayout(pi);
}
private int _Height = 0;
/// <summary>
/// Gets or sets the fixed button height.
/// </summary>
public int Height
{
get { return _Height; }
set { _Height = value; }
}
protected override void OnPaint(PaintInfo p)
{
Graphics g = p.Graphics;
Rectangle r = this.RenderBounds;
PaintButtonBackground(p);
Rectangle contentRect = r;
contentRect.Inflate(-3, -3); // Two pixels border + 1 pixels padding for content
if (!string.IsNullOrEmpty(_Text))
{
TextDrawing.DrawString(g, _Text, p.DefaultFont, GetIsEnabled(p) ? p.ForeColor : p.DisabledForeColor, contentRect, eTextFormat.Default | eTextFormat.VerticalCenter);
}
if (!string.IsNullOrEmpty(_SymbolRealized))
{
Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTable(p);
Color symbolColor=(GetIsEnabled(p) ? p.ForeColor : p.DisabledForeColor);
if (!_SymbolColor.IsEmpty)
symbolColor = _SymbolColor;
else if (!ct.Text.IsEmpty)
symbolColor = ct.Text;
float symbolSize = Math.Max(1, Math.Min(r.Width, r.Height) * 72 / g.DpiX - 1.5f);
Rectangle sr = contentRect;
if (!string.IsNullOrEmpty(_Text))
sr = new Rectangle(contentRect.Right - contentRect.Height, contentRect.Y, contentRect.Height, contentRect.Height);
sr.Inflate(3, 3);
TextDrawing.DrawStringLegacy(g, _SymbolRealized, Symbols.GetFont(symbolSize, _SymbolSet),
symbolColor, sr, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter);
}
else if (_Image != null)
{
Image image = GetIsEnabled(p) ? _Image : GetDisabledImage();
Size imageSize = Dpi.ImageSize(image.Size);
g.DrawImage(image, new Rectangle(contentRect.Right - (imageSize.Width + (string.IsNullOrEmpty(_Text)?(contentRect.Width - imageSize.Width) / 2:0)),
contentRect.Y + (contentRect.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height));
}
base.OnPaint(p);
}
protected virtual void PaintButtonBackground(PaintInfo p)
{
PaintButtonBackground(p, GetOffice2007StateColorTable(p));
}
protected virtual void PaintButtonBackground(PaintInfo p, Office2007ButtonItemStateColorTable ct)
{
Graphics g = p.Graphics;
Rectangle r = this.RenderBounds;
if (RenderBackground(p))
Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RectangleShape);
}
private bool RenderBackground(PaintInfo p)
{
if (RenderDefaultBackground) return true;
if (!p.MouseOver && !this.IsMouseDown && !this.IsMouseOver && !this.Checked || !this.GetIsEnabled())
return false;
return true;
}
protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTable(PaintInfo p)
{
if (GlobalManager.Renderer is Office2007Renderer)
{
Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)];
if (!this.GetIsEnabled(p))
return buttonColorTable.Disabled;
else if (this.IsMouseDown)
return buttonColorTable.Pressed;
else if (this.IsMouseOver)
return buttonColorTable.MouseOver;
else if (this.Checked)
return buttonColorTable.Checked;
else
return buttonColorTable.Default;
}
return null;
}
protected override void OnMouseEnter()
{
if (this.GetIsEnabled())
this.IsMouseOver = true;
base.OnMouseEnter();
}
protected override void OnMouseLeave()
{
this.IsMouseOver = false;
base.OnMouseLeave();
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
this.IsMouseDown = true;
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
this.IsMouseDown = false;
base.OnMouseUp(e);
}
private bool _IsMouseOver = false;
/// <summary>
/// Gets whether mouse is over the control.
/// </summary>
public bool IsMouseOver
{
get { return _IsMouseOver; }
internal set
{
if (_IsMouseOver != value)
{
_IsMouseOver = value;
this.InvalidateRender();
}
}
}
private bool _IsMouseDown = false;
/// <summary>
/// Gets whether mouse is pressed on the control.
/// </summary>
public bool IsMouseDown
{
get { return _IsMouseDown; }
internal set
{
if (_IsMouseDown != value)
{
_IsMouseDown = value;
this.InvalidateRender();
}
}
}
private bool _Checked;
public bool Checked
{
get { return _Checked; }
set
{
if (_Checked != value)
{
_Checked = value;
this.InvalidateRender();
}
}
}
private string _Text = "";
/// <summary>
/// Gets or sets the text displayed on the face of the button.
/// </summary>
[DefaultValue("")]
public string Text
{
get { return _Text; }
set
{
if (value == null) value = "";
if (_Text != value)
{
_Text = value;
this.InvalidateArrange();
}
}
}
private Image GetDisabledImage()
{
if (_DisabledImage == null && _Image != null)
{
_DisabledImage = ImageHelper.CreateGrayScaleImage(_Image as Bitmap);
}
return _DisabledImage;
}
private Image _DisabledImage = null;
private Image _Image = null;
/// <summary>
/// Gets or sets the image displayed on the face of the button.
/// </summary>
[DefaultValue(null)]
public Image Image
{
get { return _Image; }
set
{
if (_Image != value)
{
_Image = value;
if (_DisabledImage != null)
{
_DisabledImage.Dispose();
_DisabledImage = null;
}
this.InvalidateArrange();
}
}
}
/// <summary>
/// Gets the realized symbol string.
/// </summary>
[Browsable(false)]
public string SymbolRealized
{
get { return _SymbolRealized; }
}
private string _Symbol = "", _SymbolRealized = "";
/// <summary>
/// Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.
/// </summary>
[DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.")]
[Editor("DevComponents.DotNetBar.Design.SymbolTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
public string Symbol
{
get { return _Symbol; }
set
{
if (value != _Symbol)
{
string oldValue = _Symbol;
_Symbol = value;
OnSymbolChanged(oldValue, value);
}
}
}
/// <summary>
/// Called when Symbol property has changed.
/// </summary>
/// <param name="oldValue">Old property value</param>
/// <param name="newValue">New property value</param>
protected virtual void OnSymbolChanged(string oldValue, string newValue)
{
if (string.IsNullOrEmpty(newValue))
_SymbolRealized = "";
else
_SymbolRealized = Symbols.GetSymbol(newValue);
//OnPropertyChanged(new PropertyChangedEventArgs("Symbol"));
this.InvalidateArrange();
}
private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
/// <summary>
/// Gets or sets the symbol set used to represent the Symbol.
/// </summary>
[Browsable(false), DefaultValue(eSymbolSet.Awesome)]
public eSymbolSet SymbolSet
{
get { return _SymbolSet; }
set
{
if (_SymbolSet != value)
{
eSymbolSet oldValue = _SymbolSet;
_SymbolSet = value;
OnSymbolSetChanged(oldValue, value);
}
}
}
/// <summary>
/// Called when SymbolSet property value changes.
/// </summary>
/// <param name="oldValue">Indciates old value</param>
/// <param name="newValue">Indicates new value</param>
protected virtual void OnSymbolSetChanged(eSymbolSet oldValue, eSymbolSet newValue)
{
this.InvalidateArrange();
}
private Color _SymbolColor = Color.Empty;
/// <summary>
/// Gets or sets the color of the Symbol.
/// </summary>
[Category("Appearance"), Description("Indicates color of the Symbol.")]
public Color SymbolColor
{
get { return _SymbolColor; }
set { _SymbolColor = value; this.InvalidateRender(); }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,201 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
namespace DevComponents.Editors
{
public class VisualButtonBase : VisualItem
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
private bool _ClickAutoRepeat = false;
/// <summary>
/// Gets or sets whether button automatically gets Click events repeated when mouse is kept pressed on the button. Default value is false.
/// </summary>
[DefaultValue(false)]
public bool ClickAutoRepeat
{
get { return _ClickAutoRepeat; }
set
{
_ClickAutoRepeat = value;
}
}
private Timer _ClickTimer = null;
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && this.GetIsEnabled() && _ClickAutoRepeat)
{
if (_ClickTimer == null)
_ClickTimer = new Timer();
_ClickTimer.Interval = ClickRepeatInterval;
_ClickTimer.Tick += new EventHandler(this.ClickTimerTick);
_ClickTimer.Start();
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
DisposeAutoClickTimer();
base.OnMouseUp(e);
}
protected override void OnMouseLeave()
{
HideTooltip();
DisposeAutoClickTimer();
base.OnMouseLeave();
}
private void DisposeAutoClickTimer()
{
if (_ClickTimer != null)
{
Timer t = _ClickTimer;
_ClickTimer = null;
t.Stop();
t.Tick -= new EventHandler(this.ClickTimerTick);
t.Dispose();
}
}
private void ClickTimerTick(object sender, EventArgs e)
{
this.ProcessClick();
this.OnClickAutoRepeat();
}
protected virtual void OnClickAutoRepeat()
{
}
private int _ClickRepeatInterval = 300;
/// <summary>
/// Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.
/// </summary>
[Browsable(true), DefaultValue(300), Category("Behavior"), Description("Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.")]
public virtual int ClickRepeatInterval
{
get
{
return _ClickRepeatInterval;
}
set
{
_ClickRepeatInterval = value;
}
}
private bool _RenderDefaultBackground = true;
/// <summary>
/// Gets or sets whether default button background is rendered when mouse is not over the host control. Default value is true.
/// </summary>
public bool RenderDefaultBackground
{
get { return _RenderDefaultBackground; }
set
{
if (_RenderDefaultBackground != value)
{
_RenderDefaultBackground = value;
this.InvalidateRender();
}
}
}
private DevComponents.DotNetBar.eShortcut _Shortcut = DevComponents.DotNetBar.eShortcut.None;
/// <summary>
/// Gets or sets the shortcut key which when pressed triggers button click event or its default function.
/// </summary>
[DefaultValue(DevComponents.DotNetBar.eShortcut.None), Description("Indicates shortcut key which when pressed triggers button click event or its default function.")]
public DevComponents.DotNetBar.eShortcut Shortcut
{
get { return _Shortcut; }
set
{
_Shortcut = value;
}
}
protected override bool OnCmdKey(ref Message msg, Keys keyData)
{
if (_Shortcut != DevComponents.DotNetBar.eShortcut.None)
{
if (keyData == (Keys)_Shortcut)
{
OnClick(new KeyEventArgs(keyData));
return true;
}
}
return base.OnCmdKey(ref msg, keyData);
}
private string _Tooltip = "";
/// <summary>
/// Gets or sets the button tooltip.
/// </summary>
public string Tooltip
{
get { return _Tooltip; }
set
{
_Tooltip = value;
}
}
private DevComponents.DotNetBar.ToolTip _TooltipWnd = null;
protected override void OnMouseHover(EventArgs e)
{
ShowTooltip();
base.OnMouseHover(e);
}
private void ShowTooltip()
{
if (!string.IsNullOrEmpty(_Tooltip))
{
if (_TooltipWnd == null)
_TooltipWnd = new DevComponents.DotNetBar.ToolTip();
_TooltipWnd.Style = DevComponents.DotNetBar.StyleManager.GetEffectiveStyle();
_TooltipWnd.Text = _Tooltip;
_TooltipWnd.ShowToolTip();
}
}
private void HideTooltip()
{
if (_TooltipWnd != null)
{
try
{
if (_TooltipWnd != null)
{
_TooltipWnd.Hide();
_TooltipWnd.Dispose();
_TooltipWnd = null;
ResetHover();
}
}
catch { }
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,77 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using DevComponents.DotNetBar.Rendering;
using System.Windows.Forms;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
public class VisualCheckBox : VisualToggleButton
{
#region Private Variables
private Size _DefaultSize = new Size(13, 13);
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
public override void PerformLayout(PaintInfo pi)
{
this.Size = new System.Drawing.Size(Dpi.Width(_DefaultSize.Width + 2), Dpi.Height(_DefaultSize.Height));
this.CalculatedSize = this.Size;
base.PerformLayout(pi);
}
protected override void OnPaint(PaintInfo p)
{
Graphics g = p.Graphics;
Size defaultSize = Dpi.Size(_DefaultSize);
Rectangle r = new Rectangle(RenderBounds.X + 1, RenderBounds.Y + (RenderBounds.Height - defaultSize.Height) / 2,
defaultSize.Width, defaultSize.Height);
Office2007CheckBoxItemPainter painter = PainterFactory.CreateCheckBoxItemPainter(null);
Office2007CheckBoxColorTable ctt = GetCheckBoxColorTable();
Office2007CheckBoxStateColorTable ct = ctt.Default;
if (!this.GetIsEnabled(p))
ct = ctt.Disabled;
else if (this.IsMouseDown)
ct = ctt.Pressed;
else if (this.IsMouseOver)
ct = ctt.MouseOver;
painter.PaintCheckBox(g, r,
ct, this.Checked ? CheckState.Checked : CheckState.Unchecked);
base.OnPaint(p);
}
private Office2007CheckBoxColorTable GetCheckBoxColorTable()
{
Office2007Renderer r = this.GetRenderer() as Office2007Renderer;
if (r != null)
{
return r.ColorTable.CheckBoxItem;
}
return null;
}
private DevComponents.DotNetBar.Rendering.BaseRenderer GetRenderer()
{
return DevComponents.DotNetBar.Rendering.GlobalManager.Renderer;
}
#endregion
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
public class VisualCustomButton : VisualButton
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override void PaintButtonBackground(PaintInfo p, DevComponents.DotNetBar.Rendering.Office2007ButtonItemStateColorTable ct)
{
base.PaintButtonBackground(p, ct);
if (this.Text.Length == 0 && this.Image == null && string.IsNullOrEmpty(this.Symbol))
{
Point pt = new Point(RenderBounds.X + (RenderBounds.Width - Dpi.Width7) / 2, RenderBounds.Bottom - Dpi.Height6);
using (SolidBrush brush = new SolidBrush(ct.Text))
{
Size rs = new Size(Dpi.Width2, Dpi.Height2);
for (int i = 0; i < 3; i++)
{
//p.Graphics.FillRectangle(brush, new Rectangle(pt, rs));
p.Graphics.FillEllipse(brush, new Rectangle(pt, rs));
pt.X += rs.Width + Dpi.Width1;
}
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,563 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Globalization;
using System.Windows.Forms;
namespace DevComponents.Editors
{
public class VisualDoubleInput : VisualNumericInput
{
#region Private Variables
private double _Value = 0;
private double _MinValue = double.MinValue;
private double _MaxValue = double.MaxValue;
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override void OnLostFocus()
{
ValidateValue();
base.OnLostFocus();
}
protected virtual void ValidateValue()
{
if (_Value < _MinValue)
Value = _MinValue;
else if (_Value > _MaxValue)
Value = _MaxValue;
}
protected override bool AcceptKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
string decimalSeparator = NumberDecimalSeparator;
if (e.KeyChar.ToString() == decimalSeparator)
{
if (!this.InputStack.Contains(decimalSeparator))
return true;
else
return false;
}
return base.AcceptKeyPress(e);
}
protected override string ProcessNewInputStack(string s)
{
if (this.InputStack == "0" && s != "0" && s.StartsWith("0") && s.EndsWith(NumberDecimalSeparator))
return s;
return base.ProcessNewInputStack(s);
}
protected override void OnInputStackChanged()
{
if (this.InputStack.Length > 0)
{
this.IsEmpty = false;
if (this.InputStack == "-")
{
SetValue(0, true);
return;
}
else if (this.InputStack == NumberDecimalSeparator || this.InputStack == "-" + NumberDecimalSeparator)
{
SetValue(0, true);
return;
}
SetValue(Parse(this.InputStack), true);
}
else
{
if (this.AllowEmptyState)
this.IsEmpty = true;
SetValue(0);
}
base.OnInputStackChanged();
}
private double Parse(string s)
{
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null)
return double.Parse(s, formatProvider);
return double.Parse(s);
}
protected override void OnInputKeyAccepted()
{
CheckInputComplete(true);
base.OnInputKeyAccepted();
}
private void CheckInputComplete(bool sendNotification)
{
string predictedStack1 = "", predictedStack2 = "";
if (this.InputStack.Length > 0)
{
if (this.InputStack.Contains(NumberDecimalSeparator))
{
predictedStack1 = this.InputStack + "1";
predictedStack2 = predictedStack1;
}
else
{
predictedStack1 = this.InputStack + NumberDecimalSeparator;
predictedStack2 = this.InputStack + "0";
}
}
if (this.InputStack == "-" || this.InputStack.StartsWith(NumberDecimalSeparator) || this.InputStack == "-" + NumberDecimalSeparator)
return;
if (_Value == _MaxValue ||
!ValidateNewInputStack(predictedStack1) && !ValidateNewInputStack(predictedStack2))
InputComplete(sendNotification);
}
private void SetValue(double i, bool raiseValueChanged)
{
bool changed = _Value != i || raiseValueChanged;
_Value = i;
if (changed)
OnValueChanged();
InvalidateArrange();
}
private void SetValue(double i)
{
SetValue(i, false);
}
protected override string GetMeasureString()
{
string s = GetRenderString();
if (this.IsEmpty && this.AllowEmptyState)
s = "T";
else if (this.InputStack == "-" && _Value == 0)
s = "-";
else if ((this.InputStack == NumberDecimalSeparator || this.InputStack == "-" + NumberDecimalSeparator) && _Value == 0)
return this.InputStack;
return s;
}
protected override string GetRenderString()
{
if (this.InputStack == "-" && _Value == 0)
return "-";
else if ((this.InputStack == NumberDecimalSeparator || this.InputStack == "-" + NumberDecimalSeparator) && _Value == 0)
return this.InputStack;
else if (this.IsFocused && this.InputStack.Length > 0)
return this.InputStack;
string text = "";
text = ConvertToString(_Value, true);
return text;
}
protected override void NegateValue()
{
if (_MaxValue < 0) return;
double newValue = -_Value;
SetValueDirect(FormatNumber(newValue));
}
protected override void ResetValue()
{
ResetInputStack();
double v = 0;
if (_MinValue > v) v = _MinValue;
if (v > _MaxValue) v = _MaxValue;
SetValue(v);
InvalidateArrange();
}
public double MinValue
{
get { return _MinValue; }
set
{
if (_MinValue != value)
{
_MinValue = value;
if (_MinValue >= 0)
this.AllowsNegativeValue = false;
else
this.AllowsNegativeValue = true;
ValidateValue();
}
}
}
public double MaxValue
{
get { return _MaxValue; }
set
{
if (_MaxValue != value)
{
_MaxValue = value;
ValidateValue();
}
}
}
private bool TryParse(string s, out double value)
{
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null)
return double.TryParse(s, NumberStyles.Number, formatProvider, out value);
return double.TryParse(s, out value);
}
protected override void OnClipboardPaste()
{
if (Clipboard.ContainsText())
{
string s = Clipboard.GetText().Replace(" ", "");
s = StripNonNumeric(s);
double value = 0;
if (TryParse(s, out value))
{
if (value > _MaxValue || value < _MinValue) return;
if (SetInputStack(value.ToString()))
{
SetInputPosition(InputStack.Length);
OnInputKeyAccepted();
}
return;
}
else
return;
}
base.OnClipboardPaste();
}
protected override bool ValidateNewInputStack(string s)
{
if (s.Length > 0)
{
if (s == "-" && this.AllowsNegativeValue)
return true;
else if (s == NumberDecimalSeparator || s == "-" + NumberDecimalSeparator)
return true;
double value = 0;
if (TryParse(s, out value))
{
if (value > _MaxValue && _MaxValue >= 0 || value < _MinValue && _MinValue < 0)
return false;
// Check number of decimal places, do not allow entry of more decimals than needed
string formattedValue = ConvertToString(value, true, true);
if (s.Contains(NumberDecimalSeparator) && formattedValue.Contains(NumberDecimalSeparator))
{
int decimalPlaces = GetNumberOfDecimalPlaces(); // formattedValue.Substring(formattedValue.IndexOf(NumberDecimalSeparator) + 1).Length;
int inputDecimalPlaces = s.Substring(s.IndexOf(NumberDecimalSeparator) + 1).Length;
if (decimalPlaces > 0 && inputDecimalPlaces > decimalPlaces /*&& !s.EndsWith("0")*/)
return false;
}
else if (s.Contains(NumberDecimalSeparator) && GetNumberOfDecimalPlaces() == 0)
return false;
return true;
}
else
return false;
}
return base.ValidateNewInputStack(s);
}
private int GetNumberOfDecimalPlaces()
{
if (this.DisplayFormat == null || this.DisplayFormat.Length == 0)
{
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null && formatProvider is NumberFormatInfo)
{
NumberFormatInfo nfi = (NumberFormatInfo)formatProvider;
return nfi.NumberDecimalDigits;
}
}
else
{
string s = ConvertToString(11.111111111111d, true, true);
int sepIndex = s.IndexOf(NumberDecimalSeparator);
if (sepIndex < 0) return 0;
return s.Substring(sepIndex + 1).Length;
}
return 2;
}
public override void IncreaseValue()
{
if (_Increment > 0)
{
double newValue = _Value + _Increment;
if (newValue > _MaxValue)
newValue = _MaxValue;
else if (newValue < _MinValue)
newValue = _MinValue;
if (_Value < _MaxValue && newValue > _MaxValue) newValue = _MaxValue;
if (newValue <= _MaxValue)
{
if (this.IsEmpty && this.AllowEmptyState) newValue = Math.Max(0, _MinValue);
SetValueDirect(StripNonNumeric(FormatNumber(newValue)));
CheckInputComplete(false);
}
}
base.IncreaseValue();
}
public override void DecreaseValue()
{
if (_Increment > 0)
{
double newValue = _Value - _Increment;
if (newValue > _MaxValue)
newValue = _MaxValue;
else if (newValue < _MinValue)
newValue = _MinValue;
if (_Value > _MinValue && newValue < _MinValue) newValue = _MinValue;
if (newValue >= _MinValue)
{
SetValueDirect(StripNonNumeric(FormatNumber(newValue)));
CheckInputComplete(false);
}
}
base.DecreaseValue();
}
private double _Increment = 1;
/// <summary>
/// Gets or sets the value to increment or decrement the value of the control when the up or down buttons are clicked.
/// </summary>
[DefaultValue(1)]
public double Increment
{
get { return _Increment; }
set
{
value = Math.Abs(value);
if (_Increment != value)
{
_Increment = value;
}
}
}
private void SetValueDirect(string s)
{
string formattedValue = s;
if (s.Contains(NumberDecimalSeparator) && formattedValue.Contains(NumberDecimalSeparator))
{
int decimalPlaces = GetNumberOfDecimalPlaces(); // formattedValue.Substring(formattedValue.IndexOf(NumberDecimalSeparator) + 1).Length;
int inputDecimalPlaces = s.Substring(s.IndexOf(NumberDecimalSeparator) + 1).Length;
if (decimalPlaces > 0 && inputDecimalPlaces > decimalPlaces)
s = s.Substring(0, s.IndexOf(NumberDecimalSeparator) + 1 + decimalPlaces);
}
if (SetInputStack(s))
{
SetInputPosition(InputStack.Length);
}
}
private string ConvertToString(double d)
{
return ConvertToString(d, false, false);
}
private string ConvertToString(double d, bool useFormat)
{
return ConvertToString(d, useFormat, false);
}
private string ConvertToString(double d, bool useFormat, bool forceDisplayFormat)
{
string s = FormatNumber(d);
if (!forceDisplayFormat && (_DisplayFormat.Length == 0 || this.IsFocused || !useFormat))
{
if (this.InputStack.Contains(NumberDecimalSeparator))
{
if (!s.Contains(NumberDecimalSeparator))
s += this.InputStack.Substring(this.InputStack.IndexOf(NumberDecimalSeparator));
else if (s.Substring(s.IndexOf(NumberDecimalSeparator)) != this.InputStack.Substring(this.InputStack.IndexOf(NumberDecimalSeparator)))
s = s.Substring(0, s.IndexOf(NumberDecimalSeparator)) + this.InputStack.Substring(this.InputStack.IndexOf(NumberDecimalSeparator));
}
}
else if (_DisplayFormat.Length > 0)
{
try
{
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null)
s = d.ToString(_DisplayFormat, formatProvider);
else
s = d.ToString(_DisplayFormat);
}
catch
{
s = d.ToString();
}
}
return s;
}
private string FormatNumber(double d)
{
string format = null;
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
if (!string.IsNullOrEmpty(DisplayFormat) && DisplayFormat.ToLower()!="p" && this.IsFocused)
format = DisplayFormat;
else
{
format = "n";
int places = ci.NumberFormat.NumberDecimalDigits; // GetDecimalPlaces(d);
if (places > 0)
format += places.ToString();
}
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null)
{
if (format != null) return d.ToString(format, formatProvider);
return d.ToString(formatProvider);
}
if (format != null) return d.ToString(format);
return d.ToString();
}
private int GetDecimalPlaces(double d)
{
double dec = d - Math.Truncate(d);
if (dec == 0) return 0;
int places = 0;
while (dec < 1)
{
dec *= 10;
places++;
}
return places;
}
public double Value
{
get
{
if (_Value < _MinValue)
return _MinValue;
else if (_Value > _MaxValue)
return _MaxValue;
return _Value;
}
set
{
//if (_Value != value)
{
if (value < _MinValue) value = _MinValue;
if (value > _MaxValue) value = _MaxValue;
if (this.IsFocused)
{
SetValueDirect(StripNonNumeric(FormatNumber(value)));
if (this.IsFocused)
InputComplete(false);
}
else
{
IsEmpty = false;
SetValue(value, true);
}
}
}
}
private string StripNonNumeric(string p)
{
string s = "";
for (int i = 0; i < p.Length; i++)
{
if (p[i].ToString() == NumberDecimalSeparator || p[i] >= '0' && p[i] <= '9' || i == 0 && p[i] == '-')
s += p[i];
else if (s.Length > 0 && p[i].ToString() != NumberThousandsSeparator) break;
}
return s;
}
private string _DisplayFormat = "";
/// <summary>
/// Gets or sets the Numeric String Format that is used to format the numeric value entered for display purpose.
/// </summary>
[DefaultValue("")]
public string DisplayFormat
{
get { return _DisplayFormat; }
set
{
if (value != null)
_DisplayFormat = value;
}
}
private string NumberDecimalSeparator
{
get { return DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().NumberFormat.NumberDecimalSeparator; }
}
private string NumberThousandsSeparator
{
get { return DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().NumberFormat.NumberGroupSeparator; }
}
protected override string GetInputStringValue()
{
return ConvertToString(_Value);
}
[Browsable(false)]
public virtual string Text
{
get
{
if (this.IsEmpty && this.AllowEmptyState) return "";
return ConvertToString(_Value, true, true);
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,37 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using DevComponents.DotNetBar;
using System.Drawing;
namespace DevComponents.Editors
{
public class VisualDropDownButton : VisualButton
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override void PaintButtonBackground(PaintInfo p, DevComponents.DotNetBar.Rendering.Office2007ButtonItemStateColorTable ct)
{
base.PaintButtonBackground(p, ct);
if (this.Text.Length == 0 && this.Image == null)
{
using (SolidBrush brush = new SolidBrush(ct.Text))
p.Graphics.FillPolygon(brush, Office2007ButtonItemPainter.GetExpandPolygon(this.RenderBounds, ePopupSide.Default));
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,623 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
namespace DevComponents.Editors
{
public class VisualGroup : VisualItem
{
#region Private Variables
private VisualItem _MouseDownItem = null;
private VisualItem _MouseOverItem = null;
#endregion
#region Events
#endregion
#region Constructor
public VisualGroup()
: base()
{
_Items = new VisualItemCollection(this);
}
#endregion
#region Internal Implementation
internal virtual void ProcessItemsCollectionChanged(CollectionChangedInfo collectionChangedInfo)
{
OnItemsCollectionChanged(collectionChangedInfo);
}
protected virtual void OnItemsCollectionChanged(CollectionChangedInfo collectionChangedInfo)
{
if (collectionChangedInfo.ChangeType == eCollectionChangeType.Adding || collectionChangedInfo.ChangeType == eCollectionChangeType.Removing ||
collectionChangedInfo.ChangeType == eCollectionChangeType.Clearing)
{
if (collectionChangedInfo.Removed != null)
{
foreach (VisualItem item in collectionChangedInfo.Removed)
item.Parent = null;
}
if (collectionChangedInfo.ChangeType == eCollectionChangeType.Clearing)
{
foreach (VisualItem item in this.Items)
item.Parent = null;
}
if (collectionChangedInfo.Added != null)
{
foreach (VisualItem item in collectionChangedInfo.Added)
{
if (item.Parent != null && item.Parent != this)
{
item.Parent.Items.Remove(item);
}
item.Parent = this;
}
}
}
this.InvalidateArrange();
}
private VisualItemCollection _Items;
public virtual VisualItemCollection Items
{
get { return _Items; }
}
internal void OnChildItemVisibleChanged(VisualItem visualItem)
{
InvalidateArrange();
}
private VisualItem _FocusedItem;
public VisualItem FocusedItem
{
get { return _FocusedItem; }
internal set
{
if (_FocusedItem == value) return;
if (_FocusedItem != null)
_FocusedItem.ProcessLostFocus();
VisualItem oldFocus = _FocusedItem;
_FocusedItem = value;
if (_FocusedItem != null)
_FocusedItem.ProcessGotFocus();
OnFocusedItemChanged(oldFocus);
this.InvalidateArrange();
}
}
protected virtual void OnFocusedItemChanged(VisualItem previousFocus)
{
}
protected override void OnPaint(PaintInfo p)
{
if (!IsLayoutValid)
PerformLayout(p);
Point renderOffset = p.RenderOffset;
Point pr = p.RenderOffset;
pr.Offset(this.RenderBounds.Location);
p.RenderOffset = pr;
Graphics g = p.Graphics;
Region oldClip = null;
bool clipSet = false;
oldClip = g.Clip;
Rectangle renderBounds = this.RenderBounds;
renderBounds.Offset(renderOffset);
g.SetClip(renderBounds, CombineMode.Intersect);
clipSet = true;
bool parentEnabled = p.ParentEnabled;
p.ParentEnabled = p.ParentEnabled && this.Enabled;
bool renderSystemItemsOnly = p.RenderSystemItemsOnly;
foreach (VisualItem v in _Items)
{
if (renderSystemItemsOnly && v.ItemType != eSystemItemType.SystemButton) continue;
if (_VerticalItemAlignment == eVerticalAlignment.Middle)
{
if(_Orientation == DotNetBar.eOrientation.Horizontal)
v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X, p.RenderOffset.Y + v.Location.Y + (this.Size.Height - v.Size.Height) / 2, v.Size.Width, v.Size.Height);
else
v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X + (this.Size.Width - v.Size.Width) / 2, p.RenderOffset.Y + v.Location.Y, v.Size.Width, v.Size.Height);
}
else if (_VerticalItemAlignment == eVerticalAlignment.Bottom)
{
if(_Orientation == DotNetBar.eOrientation.Horizontal)
v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X, p.RenderOffset.Y + v.Location.Y + (this.Size.Height - v.Size.Height), v.Size.Width, v.Size.Height);
else
v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X + (this.Size.Width - v.Size.Width), p.RenderOffset.Y + v.Location.Y, v.Size.Width, v.Size.Height);
}
else
v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X, p.RenderOffset.Y + v.Location.Y, v.Size.Width, v.Size.Height);
if (v.RenderBounds.IntersectsWith(renderBounds))
{
p.RenderOffset = Point.Empty;
v.ProcessPaint(p);
p.RenderOffset = pr;
}
}
p.ParentEnabled = parentEnabled;
if (clipSet)
{
if (oldClip != null)
g.Clip = oldClip;
else
g.ResetClip();
}
if(oldClip!=null) oldClip.Dispose();
p.RenderOffset = renderOffset;
base.OnPaint(p);
}
protected override void OnIsRightToLeftChanged()
{
foreach (VisualItem vi in _Items)
vi.IsRightToLeft = this.IsRightToLeft;
base.OnIsRightToLeftChanged();
}
public override void PerformLayout(PaintInfo pi)
{
if (_Orientation == DotNetBar.eOrientation.Horizontal)
{
Point p = Point.Empty;
Size size = Size.Empty;
Size availableSize = pi.AvailableSize;
Size containerSize = availableSize;
bool usesFullWidth = false;
Size calcSize = Size.Empty;
foreach (VisualItem v in new VisualCollectionEnumerator(_Items, this.IsRightToLeft))
{
if (v.Visible)
{
v.Location = p;
pi.AvailableSize = new Size(availableSize.Width - p.X, availableSize.Height);
v.PerformLayout(pi);
if (v.Alignment == eItemAlignment.Right)
{
v.Location = new Point(containerSize.Width - v.Size.Width, p.Y);
containerSize.Width -= v.Size.Width + _HorizontalItemSpacing;
calcSize.Width += v.Size.Width + _HorizontalItemSpacing;
usesFullWidth = true;
}
else
{
p.X += v.Size.Width + _HorizontalItemSpacing;
size.Width += v.Size.Width + _HorizontalItemSpacing;
calcSize.Width += v.Size.Width + _HorizontalItemSpacing;
}
if (v.Size.Height > size.Height)
size.Height = v.Size.Height;
}
}
if (size.Width > 0)
size.Width -= +_HorizontalItemSpacing;
if (usesFullWidth && _HorizontalItemAlignment != eHorizontalAlignment.Left)
{
if (_HorizontalItemAlignment == eHorizontalAlignment.Right)
{
if (containerSize.Width < availableSize.Width) containerSize.Width--;
foreach (VisualItem v in new VisualCollectionEnumerator(_Items, !this.IsRightToLeft))
{
if (!v.Visible || v.Alignment == eItemAlignment.Right || v is LockUpdateCheckBox) continue;
v.Location = new Point(containerSize.Width - v.Size.Width, p.Y);
containerSize.Width -= v.Size.Width + _HorizontalItemSpacing;
}
}
else
{
int offset = (containerSize.Width - size.Width) / 2;
foreach (VisualItem v in new VisualCollectionEnumerator(_Items, this.IsRightToLeft))
{
if (!v.Visible || v.Alignment == eItemAlignment.Right || v is LockUpdateCheckBox) continue;
v.Location = new Point(v.Location.X + offset, v.Location.Y);
}
}
}
this.CalculatedSize = calcSize;
if (usesFullWidth)
size.Width = availableSize.Width;
pi.AvailableSize = availableSize;
this.Size = size;
this.RenderBounds = new Rectangle(pi.RenderOffset, size);
}
else
PerformVerticalLayout(pi);
base.PerformLayout(pi);
}
private void PerformVerticalLayout(PaintInfo pi)
{
Point p = Point.Empty;
Size size = Size.Empty;
Size availableSize = pi.AvailableSize;
Size containerSize = availableSize;
bool usesFullWidth = false;
Size calcSize = Size.Empty;
foreach (VisualItem v in new VisualCollectionEnumerator(_Items, this.IsRightToLeft))
{
if (v.Visible)
{
v.Location = p;
pi.AvailableSize = new Size(availableSize.Width, availableSize.Height - p.Y);
v.PerformLayout(pi);
if (v.Alignment == eItemAlignment.Right)
{
v.Location = new Point(p.X, containerSize.Height - v.Size.Height);
containerSize.Height -= v.Size.Height + _HorizontalItemSpacing;
calcSize.Height += v.Size.Height + _HorizontalItemSpacing;
usesFullWidth = true;
}
else
{
p.Y += v.Size.Height + _HorizontalItemSpacing;
size.Height += v.Size.Height + _HorizontalItemSpacing;
calcSize.Height += v.Size.Height + _HorizontalItemSpacing;
}
if (v.Size.Width > size.Width)
size.Width = v.Size.Width;
}
}
if (size.Height > 0)
size.Height -= +_HorizontalItemSpacing;
if (usesFullWidth && _HorizontalItemAlignment != eHorizontalAlignment.Left)
{
if (_HorizontalItemAlignment == eHorizontalAlignment.Right)
{
if (containerSize.Height < availableSize.Height) containerSize.Height--;
foreach (VisualItem v in new VisualCollectionEnumerator(_Items, !this.IsRightToLeft))
{
if (!v.Visible || v.Alignment == eItemAlignment.Right || v is LockUpdateCheckBox) continue;
v.Location = new Point(p.X, containerSize.Height - v.Size.Height);
containerSize.Height -= v.Size.Height + _HorizontalItemSpacing;
}
}
else
{
int offset = (containerSize.Height - size.Height) / 2;
foreach (VisualItem v in new VisualCollectionEnumerator(_Items, this.IsRightToLeft))
{
if (!v.Visible || v.Alignment == eItemAlignment.Right || v is LockUpdateCheckBox) continue;
v.Location = new Point(v.Location.X, v.Location.Y + offset);
}
}
}
this.CalculatedSize = calcSize;
if (usesFullWidth)
size.Height = availableSize.Height;
pi.AvailableSize = availableSize;
this.Size = size;
this.RenderBounds = new Rectangle(pi.RenderOffset, size);
}
private DevComponents.DotNetBar.eOrientation _Orientation=DevComponents.DotNetBar.eOrientation.Horizontal;
internal DevComponents.DotNetBar.eOrientation Orientation
{
get
{
return _Orientation;
}
set
{
_Orientation = value;
this.InvalidateArrange();
this.InvalidateRender();
}
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
VisualItem item = GetItemAt(e.X, e.Y);
if (item != null)
{
_MouseDownItem = item;
_MouseOverItem = item;
item.ProcessMouseDown(e);
if (_MouseDownItem == item && CanFocus(item))
this.FocusedItem = item;
}
else if (item == null && this.IsFocused)
{
// Find first available input and focus it instead
foreach (VisualItem visual in _Items)
{
if (visual is VisualInputBase && CanFocus(visual))
{
this.FocusedItem = visual;
break;
}
}
}
base.OnMouseDown(e);
}
protected override void OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
{
if (this.FocusedItem != null)
this.FocusedItem.ProcessMouseWheel(e);
base.OnMouseWheel(e);
}
protected virtual bool CanFocus(VisualItem v)
{
return v != null && v.Visible && (v.Focusable || v is VisualInputGroup) && v.Enabled;
}
protected override void OnClick(EventArgs e)
{
if (_MouseDownItem != null)
{
_MouseDownItem.ProcessClick();
}
base.OnClick(EventArgs.Empty);
}
protected override void OnMouseClick(System.Windows.Forms.MouseEventArgs e)
{
if (_MouseDownItem != null)
{
_MouseDownItem.ProcessMouseClick(e);
}
base.OnMouseClick(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
if (_MouseDownItem != null)
{
_MouseDownItem.ProcessMouseUp(e);
_MouseDownItem = null;
}
base.OnMouseUp(e);
}
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
if (_MouseDownItem != null)
_MouseDownItem.ProcessMouseMove(e);
else
{
VisualItem item = GetItemAt(e.X, e.Y);
if (item != _MouseOverItem && _MouseOverItem != null)
{
_MouseOverItem.ProcessMouseLeave();
_MouseOverItem = null;
}
if (item != null && _MouseOverItem == null)
{
_MouseOverItem = item;
_MouseOverItem.ProcessMouseEnter();
}
if (_MouseOverItem != null)
_MouseOverItem.ProcessMouseMove(e);
}
base.OnMouseMove(e);
}
protected override void OnMouseHover(EventArgs e)
{
if (_MouseOverItem != null)
_MouseOverItem.ProcessMouseHover(e);
base.OnMouseHover(e);
}
protected override void OnMouseLeave()
{
if (_MouseDownItem != null)
_MouseDownItem.ProcessMouseLeave();
else
{
if (_MouseOverItem != null)
{
_MouseOverItem.ProcessMouseLeave();
_MouseOverItem = null;
}
}
base.OnMouseLeave();
}
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
if (_FocusedItem != null)
_FocusedItem.ProcessKeyDown(e);
base.OnKeyDown(e);
}
protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e)
{
if (_FocusedItem != null)
_FocusedItem.ProcessKeyUp(e);
base.OnKeyUp(e);
}
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if (_FocusedItem != null)
_FocusedItem.ProcessKeyPress(e);
base.OnKeyPress(e);
}
protected override bool OnCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (_FocusedItem != null)
if (_FocusedItem.ProcessCmdKey(ref msg, keyData)) return true;
foreach (VisualItem item in this.Items)
{
if (item is VisualButtonBase)
{
if (item.ProcessCmdKey(ref msg, keyData)) return true;
}
}
return base.OnCmdKey(ref msg, keyData);
}
public VisualItem GetItemAt(int x, int y)
{
for (int i = _Items.Count - 1; i >= 0 ; i--)
{
VisualItem item = _Items[i];
if (!item.Visible) continue;
if (item.RenderBounds.Contains(x, y))
return item;
}
return null;
}
private VisualItem GetFirstVisibleItem()
{
foreach (VisualItem item in new VisualCollectionEnumerator(_Items, this.IsRightToLeft))
{
if (item.Visible) return item;
}
return null;
}
protected override void OnGotFocus()
{
OnGroupFocused();
base.OnGotFocus();
}
protected virtual void OnGroupFocused()
{
if (this.FocusedItem == null)
{
VisualItem item = GetFirstVisibleItem();
if (item != null) this.FocusedItem = item;
}
}
protected override void OnLostFocus()
{
this.FocusedItem = null;
base.OnLostFocus();
}
internal virtual void ProcessInputComplete()
{
OnInputComplete();
}
/// <summary>
/// Occurs when child item input is complete. Method should be used to forward the input focus onto the different field if desired.
/// </summary>
protected virtual void OnInputComplete()
{
}
/// <summary>
/// Occurs when input stack on the child control has changed.
/// </summary>
/// <param name="input">Control on which input has changed</param>
internal void ProcessInputChanged(VisualInputBase input)
{
OnInputChanged(input);
}
/// <summary>
/// Occurs when input stack on the child control has changed.
/// </summary>
/// <param name="input">Control on which input has changed</param>
protected virtual void OnInputChanged(VisualInputBase input)
{
}
private int _HorizontalItemSpacing = 0;
/// <summary>
/// Gets or sets the horizontal spacing in pixels between the items.
/// </summary>
[DefaultValue(0)]
public int HorizontalItemSpacing
{
get { return _HorizontalItemSpacing; }
set
{
if (_HorizontalItemSpacing != value)
{
_HorizontalItemSpacing = value;
this.InvalidateArrange();
}
}
}
private bool _IsRootVisual = false;
/// <summary>
/// Gets or sets whether visual is root visual directly parented to the control.
/// </summary>
[DefaultValue(false)]
public bool IsRootVisual
{
get { return _IsRootVisual; }
set { _IsRootVisual = value; }
}
private eVerticalAlignment _VerticalItemAlignment = eVerticalAlignment.Middle;
/// <summary>
/// Gets or sets group vertical alignment. Default value is middle.
/// </summary>
[DefaultValue(eVerticalAlignment.Middle)]
public eVerticalAlignment VerticalItemAlignment
{
get { return _VerticalItemAlignment; }
set
{
if (_VerticalItemAlignment != value)
{
_VerticalItemAlignment = value;
OnArrangeInvalid();
}
}
}
private eHorizontalAlignment _HorizontalItemAlignment = eHorizontalAlignment.Left;
/// <summary>
/// Gets or sets input group horizontal alignment. Default value is left.
/// </summary>
[DefaultValue(eHorizontalAlignment.Left)]
public eHorizontalAlignment HorizontalItemAlignment
{
get { return _HorizontalItemAlignment; }
set
{
if (_HorizontalItemAlignment != value)
{
_HorizontalItemAlignment = value;
OnArrangeInvalid();
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,481 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
public class VisualInputBase : VisualItem
{
#region Private Variables
private int _InputPosition = 0;
private string _InputStack = "";
private bool _InsertMode = true;
private string _UndoInputStack = "";
#endregion
#region Events
/// <summary>
/// Occurs when input on the control has changed.
/// </summary>
public event EventHandler InputChanged;
/// <summary>
/// Occurs when validation of the input is performed and it allows you to deny the input.
/// </summary>
public event InputValidationEventHandler ValidateInput;
/// <summary>
/// Occurs when IsEmpty property has changed.
/// </summary>
public event EventHandler IsEmptyChanged;
#endregion
#region Constructor
public VisualInputBase()
{
this.Focusable = true;
}
#endregion
#region Internal Implementation
internal override void ProcessKeyDown(KeyEventArgs e)
{
if (!_IsReadOnly || (e.KeyCode == Keys.C && e.Modifiers == Keys.Control))
base.ProcessKeyDown(e);
}
internal override void ProcessKeyPress(KeyPressEventArgs e)
{
if (!_IsReadOnly)
base.ProcessKeyPress(e);
}
internal override void ProcessKeyUp(KeyEventArgs e)
{
if (!_IsReadOnly)
base.ProcessKeyUp(e);
}
internal override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (!_IsReadOnly)
return base.ProcessCmdKey(ref msg, keyData);
return false;
}
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
OnInputKeyDown(e);
base.OnKeyDown(e);
}
protected virtual void OnInputKeyDown(System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == System.Windows.Forms.Keys.Back)
ProcessBackSpace(e);
else if (e.KeyCode == System.Windows.Forms.Keys.Delete)
ProcessDelete(e);
else if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
{
ProcessClipboardCopy();
e.Handled = true;
}
else if (e.KeyCode == Keys.X && e.Modifiers == Keys.Control)
{
ProcessClipboardCut();
e.Handled = true;
}
else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
{
ProcessClipboardPaste();
e.Handled = true;
}
else if (e.KeyCode == Keys.Z && e.Modifiers == Keys.Control)
{
ProcessUndo();
e.Handled = true;
}
}
internal virtual void ProcessClear()
{
OnClear();
}
internal virtual void ProcessClipboardCopy()
{
OnClipboardCopy();
}
internal virtual void ProcessClipboardCut()
{
OnClipboardCut();
}
internal virtual void ProcessClipboardPaste()
{
OnClipboardPaste();
}
internal virtual void ProcessUndo()
{
OnUndo();
}
protected virtual void OnUndo()
{
if (SetInputStack(_UndoInputStack))
{
_InputPosition = _InputStack.Length;
OnInputKeyAccepted();
}
}
/// <summary>
/// Reverts the input to the last stored value.
/// </summary>
public void UndoInput()
{
ProcessUndo();
}
protected virtual void OnClear()
{
if (SetInputStack(""))
{
_InputPosition = 0;
}
}
protected virtual void OnClipboardCut()
{
OnClipboardCopy();
OnClear();
}
protected virtual void OnClipboardPaste()
{
if (Clipboard.ContainsText())
{
if (SetInputStack(Clipboard.GetText()))
{
_InputPosition = _InputStack.Length;
OnInputKeyAccepted();
}
}
}
protected virtual void OnClipboardCopy()
{
Clipboard.SetText(GetInputStringValue());
}
protected virtual string GetInputStringValue()
{
return _InputStack;
}
protected virtual void ProcessDelete(System.Windows.Forms.KeyEventArgs e)
{
OnClear();
e.Handled = true;
}
protected virtual void ProcessBackSpace(System.Windows.Forms.KeyEventArgs e)
{
if (_InputStack.Length > 0 && _InputPosition > 0)
{
string s = _InputStack.Substring(0, _InputPosition - 1) + _InputStack.Substring(_InputPosition);
if (SetInputStack(s))
{
_InputPosition = Math.Max(0, _InputPosition - 1);
}
}
else
OnClear();
e.Handled = true;
}
protected virtual void ResetValue() { }
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
OnInputKeyPress(e);
base.OnKeyPress(e);
}
protected virtual void OnInputKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if (AcceptKeyPress(e))
UpdateInputStack(e.KeyChar);
}
protected virtual void UpdateInputStack(char c)
{
string s = _InputStack;
if (_InputPosition >= _InputStack.Length)
{
if (_InputPosition > _InputStack.Length)
_InputPosition = _InputStack.Length;
s += c.ToString();
}
else if (_InsertMode)
s.Insert(_InputPosition, c.ToString());
else
s = _InputStack.Substring(0, _InputPosition - 1) + c.ToString() + _InputStack.Substring(_InputPosition + 1);
if (SetInputStack(s))
{
_InputPosition++;
OnInputKeyAccepted();
}
}
protected virtual void OnInputKeyAccepted()
{
}
protected virtual bool SetInputStack(string s)
{
if (ValidateNewInputStack(s))
{
_InputStack = s;
OnInputStackChanged();
return true;
}
return false;
}
protected virtual bool ValidateNewInputStack(string s)
{
if (ValidateInput != null)
{
InputValidationEventArgs e = new InputValidationEventArgs(s);
ValidateInput(this, e);
return e.AcceptInput;
}
return true;
}
protected virtual void OnInputStackChanged()
{
OnInputChanged();
}
protected virtual void OnInputChanged()
{
if (this.Parent != null)
this.Parent.ProcessInputChanged(this);
if (InputChanged != null)
InputChanged(this, new EventArgs());
}
protected virtual bool AcceptKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled = true;
return true;
}
protected override void OnGotFocus()
{
OnInputGotFocus();
base.OnGotFocus();
}
protected override void OnLostFocus()
{
OnInputLostFocus();
base.OnLostFocus();
}
protected virtual void OnInputGotFocus()
{
ResetInputStack();
_UndoInputStack = GetInputStringValue();
this.InvalidateArrange();
}
protected virtual void OnInputLostFocus()
{
this.InvalidateArrange();
}
protected string InputStack
{
get
{
return _InputStack;
}
}
protected void SetInputPosition(int position)
{
_InputPosition = position;
}
public int InputPosition
{
get { return _InputPosition; }
}
//private bool _IsInputStackEmpty = true;
protected bool IsInputStackEmpty
{
get
{
return _InputStack.Length == 0;
}
}
/// <summary>
/// Called when input field is full, i.e. it has an complete entry. If auto-overwrite is enabled the continued typing after input is complete
/// will erase the existing entry and start new one.
/// </summary>
protected virtual void InputComplete(bool sendNotification)
{
if (_AutoOverwrite)
{
ResetInputStack();
}
if (sendNotification && this.Parent != null)
{
this.Parent.ProcessInputComplete();
}
}
/// <summary>
/// Resets the input position so the new input overwrites current value.
/// </summary>
public void ResetInputPosition()
{
ResetInputStack();
}
protected virtual void ResetInputStack()
{
_InputStack = "";
_InputPosition = 0;
}
public override void PerformLayout(PaintInfo p)
{
if (p.WatermarkEnabled && this.DrawWatermark)
{
Font font = p.DefaultFont;
if (p.WatermarkFont != null) font = p.WatermarkFont;
System.Drawing.Size size = TextDrawing.MeasureString(p.Graphics, this.WatermarkText, font, 0, eTextFormat.Default | eTextFormat.NoPadding);
this.Size = size;
}
base.PerformLayout(p);
}
protected override void OnPaint(PaintInfo p)
{
if (p.WatermarkEnabled && this.DrawWatermark)
{
Font font = p.DefaultFont;
if (p.WatermarkFont != null) font = p.WatermarkFont;
TextDrawing.DrawString(p.Graphics, this.WatermarkText, font, p.WatermarkColor, this.RenderBounds, eTextFormat.Default);
}
base.OnPaint(p);
}
/// <summary>
/// Gets whether watermark will be drawn in current control state.
/// </summary>
protected virtual bool DrawWatermark
{
get
{
return this.WatermarkEnabled && this.IsEmpty && this.WatermarkText.Length > 0 && !this.IsFocused;
}
}
private bool _IsEmpty = true;
/// <summary>
/// Gets or sets whether control is empty.
/// </summary>
public virtual bool IsEmpty
{
get { return _IsEmpty; }
set
{
if (value != _IsEmpty)
{
_IsEmpty = value;
InvalidateArrange();
if (this.Parent is VisualInputGroup)
((VisualInputGroup)this.Parent).UpdateIsEmpty();
if (value)
ResetValue();
OnIsEmptyChanged();
}
}
}
protected virtual void OnIsEmptyChanged()
{
if (IsEmptyChanged != null)
IsEmptyChanged(this, new EventArgs());
}
private bool _AutoOverwrite = true;
/// <summary>
/// Gets or sets whether auto-overwrite functionality for input is enabled. When in auto-overwrite mode input field will erase existing entry
/// and start new one if typing is continued after InputComplete method is called.
/// </summary>
public bool AutoOverwrite
{
get { return _AutoOverwrite; }
set { _AutoOverwrite = value; }
}
private string _WatermarkText = "";
/// <summary>
/// Gets or sets the watermark text displayed on the input control when control is empty.
/// </summary>
[Localizable(true)]
public string WatermarkText
{
get { return _WatermarkText; }
set
{
if (value != null)
_WatermarkText = value;
}
}
private bool _WatermarkEnabled = true;
/// <summary>
/// Gets or sets whether watermark text is displayed if set. Default value is true.
/// </summary>
[DefaultValue(true), Description("Indicates whether watermark text is displayed if set.")]
public virtual bool WatermarkEnabled
{
get { return _WatermarkEnabled; }
set { _WatermarkEnabled = value; }
}
private bool _IsReadOnly = false;
/// <summary>
/// Gets or sets whether input item is read-only.
/// </summary>
public virtual bool IsReadOnly
{
get { return _IsReadOnly; }
set
{
_IsReadOnly = value;
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,422 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
namespace DevComponents.Editors
{
/// <summary>
/// Represents the group of the input items with automatic and manual item focus change.
/// </summary>
public class VisualInputGroup : VisualGroup
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
/// <summary>
/// Resets the input position so the new input overwrites current value.
/// </summary>
public void ResetInputPosition()
{
foreach (VisualItem item in this.Items)
{
VisualInputBase input = item as VisualInputBase;
if (input != null)
input.ResetInputPosition();
}
}
protected override bool OnCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (keyData == Keys.Tab && (Control.ModifierKeys & Keys.Shift) != Keys.Shift && this.TabNavigationEnabled ||
keyData == Keys.Enter && this.EnterNavigationEnabled ||
keyData == Keys.Right && this.ArrowNavigationEnabled)
{
ValidateInput(this.FocusedItem);
if (SelectNextInput())
return true;
}
else if (keyData == Keys.Left && this.ArrowNavigationEnabled ||
(keyData & Keys.Tab) == Keys.Tab && (keyData & Keys.Shift) == Keys.Shift && this.TabNavigationEnabled)
{
ValidateInput(this.FocusedItem);
if (SelectPreviousInput())
return true;
}
return base.OnCmdKey(ref msg, keyData);
}
private bool _TabNavigationEnabled = true;
/// <summary>
/// Gets or sets whether Tab key is used to navigate between the fields. Default value is true.
/// </summary>
[DefaultValue(true)]
public bool TabNavigationEnabled
{
get
{
return _TabNavigationEnabled;
}
set
{
_TabNavigationEnabled = value;
}
}
private bool _EnterNavigationEnabled = true;
/// <summary>
/// Gets or sets whether Enter key is used to navigate between input fields. Default value is true.
/// </summary>
[DefaultValue(true)]
public bool EnterNavigationEnabled
{
get
{
return _EnterNavigationEnabled;
}
set
{
_EnterNavigationEnabled = value;
}
}
private bool _ArrowNavigationEnabled = true;
/// <summary>
/// Gets or sets whether Arrow keys are used to navigate between input fields. Default value is true.
/// </summary>
[DefaultValue(true)]
public bool ArrowNavigationEnabled
{
get
{
return _ArrowNavigationEnabled;
}
set
{
_ArrowNavigationEnabled = value;
}
}
private bool _AutoAdvance = false;
/// <summary>
/// Gets or sets whether input focus is automatically advanced to next input field when input is complete in current one.
/// </summary>
[DefaultValue(false)]
public bool AutoAdvance
{
get { return _AutoAdvance; }
set { _AutoAdvance = value; }
}
protected override void OnInputComplete()
{
if (ValidateInput(this.FocusedItem))
{
if (_AutoAdvance)
{
if (!this.SelectNextInput())
{
OnGroupInputComplete();
}
}
}
base.OnInputComplete();
}
protected virtual bool ValidateInput(VisualItem inputItem)
{
return true;
}
protected virtual void OnGroupInputComplete()
{
if (this.Parent != null)
{
this.Parent.ProcessInputComplete();
}
}
internal bool SelectNextInput()
{
return SelectInputItem(true);
}
internal bool SelectPreviousInput()
{
return SelectInputItem(false);
}
internal bool SelectInputItem(bool moveForward)
{
if (this.FocusedItem is VisualInputGroup)
{
VisualInputGroup group = this.FocusedItem as VisualInputGroup;
if (group.SelectInputItem(moveForward))
return true;
}
VisualCollectionEnumerator enumerator = new VisualCollectionEnumerator(this.Items, !moveForward || this.IsRightToLeft);
enumerator.CurrentIndex = this.Items.IndexOf(this.FocusedItem);
while (enumerator.MoveNext())
{
VisualInputBase vi = enumerator.Current as VisualInputBase;
if (vi != null && CanFocus(vi))
{
this.FocusedItem = vi;
return true;
}
else if (enumerator.Current is VisualInputGroup)
{
VisualInputGroup group = enumerator.Current as VisualInputGroup;
if (group.SelectInputItem(moveForward))
{
this.FocusedItem = group;
return true;
}
}
}
return false;
}
protected override void OnGroupFocused()
{
if (this.FocusedItem == null)
SelectInputItem(true);
}
private bool _IsReadOnly = false;
/// <summary>
/// Gets or sets whether input items are read-only.
/// </summary>
public bool IsReadOnly
{
get { return _IsReadOnly; }
set
{
if (_IsReadOnly != value)
{
_IsReadOnly = value;
OnIsReadOnlyChanged();
}
}
}
private void OnIsReadOnlyChanged()
{
for (int i = 0; i < this.Items.Count; i++)
{
VisualInputBase v = this.Items[i] as VisualInputBase;
if (v != null) v.IsReadOnly = this.IsReadOnly;
}
}
protected override void OnItemsCollectionChanged(CollectionChangedInfo collectionChangedInfo)
{
if (collectionChangedInfo.ChangeType == eCollectionChangeType.Adding || collectionChangedInfo.ChangeType == eCollectionChangeType.Removing ||
collectionChangedInfo.ChangeType == eCollectionChangeType.Clearing)
{
if (collectionChangedInfo.Added != null)
{
foreach (VisualItem item in collectionChangedInfo.Added)
{
VisualInputBase v = item as VisualInputBase;
if (v != null)
{
v.IsReadOnly = this.IsReadOnly;
v.AutoOverwrite = _AutoOverwrite;
}
}
}
}
base.OnItemsCollectionChanged(collectionChangedInfo);
}
private bool _AllowEmptyState = true;
[DefaultValue(true)]
public bool AllowEmptyState
{
get { return _AllowEmptyState; }
set
{
if (_AllowEmptyState != value)
{
_AllowEmptyState = value;
OnAllowEmptyStateChanged();
InvalidateArrange();
}
}
}
protected virtual void OnAllowEmptyStateChanged()
{
foreach (VisualItem item in this.Items)
{
if (item is VisualNumericInput) ((VisualNumericInput)item).AllowEmptyState = this.AllowEmptyState;
}
}
private bool _IsEmpty = true;
/// <summary>
/// Gets or sets whether input group is empty i.e. it does not hold any value.
/// </summary>
[DefaultValue(true), Browsable(false)]
public bool IsEmpty
{
get { return _IsEmpty; }
set
{
if (_IsEmpty != value)
{
_IsEmpty = value;
if (_IsEmpty)
{
ResetValue();
}
if (this.Parent is VisualInputGroup)
((VisualInputGroup)this.Parent).UpdateIsEmpty();
}
}
}
protected override void OnInputChanged(VisualInputBase input)
{
UpdateIsEmpty();
base.OnInputChanged(input);
}
/// <summary>
/// Updates the IsEmpty property value based on the contained input controls.
/// </summary>
public virtual void UpdateIsEmpty()
{
bool empty = true;
foreach (VisualItem item in this.Items)
{
if (item is VisualInputBase && !((VisualInputBase)item).IsEmpty)
{
empty = false;
break;
}
else if (item is VisualInputGroup && !((VisualInputGroup)item).IsEmpty)
{
empty = false;
break;
}
}
this.IsEmpty = empty;
}
private bool _ResettingValue = false;
protected virtual void ResetValue()
{
_ResettingValue = true;
try
{
VisualItem[] items = new VisualItem[this.Items.Count];
this.Items.CopyTo(items);
foreach (VisualItem item in items)
{
if (item is VisualInputGroup)
((VisualInputGroup)item).IsEmpty = true;
else if (item is VisualInputBase)
((VisualInputBase)item).IsEmpty = true;
}
}
finally
{
_ResettingValue = false;
}
}
private bool _AutoOverwrite = true;
/// <summary>
/// Gets or sets whether auto-overwrite functionality for input is enabled. When in auto-overwrite mode input field will erase existing entry
/// and start new one if typing is continued after InputComplete method is called.
/// </summary>
public bool AutoOverwrite
{
get { return _AutoOverwrite; }
set
{
if (_AutoOverwrite != value)
{
_AutoOverwrite = value;
OnAutoOverwriteChanged();
}
}
}
private void OnAutoOverwriteChanged()
{
foreach (VisualItem item in this.Items)
{
VisualInputBase input = item as VisualInputBase;
if (input != null && input.AutoOverwrite != _AutoOverwrite)
input.AutoOverwrite = _AutoOverwrite;
}
}
private bool _IsUserInput = false;
/// <summary>
/// Gets or sets whether current input is the user input.
/// </summary>
public bool IsUserInput
{
get { return _IsUserInput; }
set
{
_IsUserInput = value;
}
}
private string _SelectNextInputCharacters = "";
/// <summary>
/// List of characters that when pressed would select next input field.
/// </summary>
public string SelectNextInputCharacters
{
get { return _SelectNextInputCharacters; }
set
{
if (value == null) value = "";
if (_SelectNextInputCharacters != value)
{
_SelectNextInputCharacters = value;
}
}
}
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if (_SelectNextInputCharacters.Length > 0 && _SelectNextInputCharacters.Contains(e.KeyChar.ToString()))
{
if (SelectNextInput())
{
e.Handled = true;
return;
}
}
base.OnKeyPress(e);
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,421 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Globalization;
using System.Windows.Forms;
namespace DevComponents.Editors
{
public class VisualIntegerInput : VisualNumericInput
{
#region Private Variables
private int _Value = 0;
private int _MinValue = int.MinValue;
private int _MaxValue = int.MaxValue;
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override void OnInputStackChanged()
{
if (this.InputStack.Length > 0)
{
this.IsEmpty = false;
if (this.InputStack == "-")
{
SetValue(0, true);
return;
}
int newValue = int.Parse(this.InputStack);
SetValue(newValue, true);
}
else
{
if (this.AllowEmptyState)
this.IsEmpty = true;
SetValue(0, true);
}
base.OnInputStackChanged();
}
protected override void OnInputKeyAccepted()
{
CheckInputComplete(true);
base.OnInputKeyAccepted();
}
private void CheckInputComplete(bool sendNotification)
{
int predictedValue = GetNextPredictedValue(_Value);
if (_Value == _MaxValue || (ConvertToString(_Value).Length >= ConvertToString(_MaxValue).Length && ConvertToString(_Value).Length >= ConvertToString(_MinValue).Length) ||
predictedValue > _MaxValue)
InputComplete(sendNotification);
else if (IsLeadingZero && ConvertToString(_Value).Length + 1 >= ConvertToString(_MaxValue).Length)
InputComplete(sendNotification);
}
private int GetNextPredictedValue(int value)
{
string s = "";
if (value == 0)
s = "1";
else
s = ConvertToString(value) + "0";
int i = value;
int.TryParse(s, out i);
return i;
}
protected override void OnLostFocus()
{
ValidateValue();
base.OnLostFocus();
}
protected virtual void ValidateValue()
{
if (_Value < _MinValue && !this.IsEmpty)
Value = _MinValue;
else if (_Value > _MaxValue && !this.IsEmpty)
Value = _MaxValue;
}
private void SetValue(int i, bool raiseValueChanged)
{
bool changed = _Value != i || raiseValueChanged;
_Value = i;
if (changed)
OnValueChanged();
InvalidateArrange();
}
private void SetValue(int i)
{
SetValue(i, false);
}
protected override string GetMeasureString()
{
string s = ConvertToString(_Value, true);
if (this.IsEmpty && this.AllowEmptyState)
s = "T";
else if (this.InputStack == "-" && _Value == 0)
s = "-";
return s;
}
protected override string GetRenderString()
{
if (this.InputStack == "-" && _Value == 0)
return "-";
if (this.IsEmpty && this.AllowEmptyState)
return "";
string text = ConvertToString(_Value, true);
return text;
}
protected override void NegateValue()
{
if (!this.IsEmpty && _MaxValue >= 0)
{
int newValue = -_Value;
SetValueDirect(FormatNumber(newValue));
}
}
protected override void ResetValue()
{
ResetInputStack();
int i = 0;
if (_MinValue > i) i = _MinValue;
if (i > _MaxValue) i = _MaxValue;
SetValue(i);
InvalidateArrange();
}
public int MinValue
{
get { return _MinValue; }
set
{
if (_MinValue != value)
{
_MinValue = value;
if (_MinValue >= 0)
this.AllowsNegativeValue = false;
else
this.AllowsNegativeValue = true;
if (_Value < _MinValue && (!this.IsEmpty || this.IsEmpty && !this.AllowEmptyState))
{
if (this.IsFocused)
SetValueDirect(FormatNumber(_MinValue));
else
SetValue(_MinValue);
}
}
}
}
private string FormatNumber(int i)
{
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null)
return i.ToString(formatProvider);
return i.ToString();
}
public int MaxValue
{
get { return _MaxValue; }
set
{
if (_MaxValue != value)
{
_MaxValue = value;
if (_Value > _MaxValue && (!this.IsEmpty || this.IsEmpty && !this.AllowEmptyState))
{
if (this.IsFocused)
SetValueDirect(FormatNumber(_MaxValue));
else
SetValue(_MaxValue);
}
}
}
}
protected override void OnClipboardPaste()
{
if (Clipboard.ContainsText())
{
string s = StripNonNumeric(Clipboard.GetText().Replace(" ", ""));
int value = 0;
if (int.TryParse(s, out value))
{
if (value > _MaxValue || value < _MinValue) return;
if (SetInputStack(value.ToString()))
{
SetInputPosition(InputStack.Length);
OnInputKeyAccepted();
}
return;
}
else
return;
}
base.OnClipboardPaste();
}
private string StripNonNumeric(string p)
{
string s = "";
for (int i = 0; i < p.Length; i++)
{
if (p[i].ToString() == NumberDecimalSeparator)
break;
else if (p[i] >= '0' && p[i] <= '9' || i == 0 && p[i] == '-')
s += p[i];
else if (s.Length > 0 && p[i].ToString() != NumberThousandsSeparator) break;
}
return s;
}
private string NumberDecimalSeparator
{
get { return DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().NumberFormat.NumberDecimalSeparator; }
}
private string NumberThousandsSeparator
{
get { return DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().NumberFormat.NumberGroupSeparator; }
}
protected override bool ValidateNewInputStack(string s)
{
if (s.Length > 0)
{
if (s == "-" && this.AllowsNegativeValue)
return true;
int value = 0;
if (int.TryParse(s, out value))
{
if (value > _MaxValue && _MaxValue >= 0 || value < _MinValue && _MinValue < 0)
return false;
return true;
}
else
return false;
}
return base.ValidateNewInputStack(s);
}
public override void IncreaseValue()
{
if (_Increment > 0)
{
int newValue = _Value + _Increment;
if (newValue > _MaxValue)
newValue = _MaxValue;
else if (newValue < _MinValue)
newValue = _MinValue;
if (_Value < _MaxValue && newValue > _MaxValue) newValue = _MaxValue;
if (newValue <= _MaxValue)
{
if (this.IsEmpty && this.AllowEmptyState) newValue = Math.Max(0, _MinValue);
SetValueDirect(FormatNumber(newValue));
CheckInputComplete(false);
}
}
base.IncreaseValue();
}
public override void DecreaseValue()
{
if (_Increment > 0)
{
int newValue = _Value - _Increment;
if (newValue > _MaxValue)
newValue = _MaxValue;
else if (newValue < _MinValue)
newValue = _MinValue;
if (_Value > _MinValue && newValue < _MinValue) newValue = _MinValue;
if (newValue >= _MinValue)
{
SetValueDirect(FormatNumber(newValue));
CheckInputComplete(false);
}
}
base.DecreaseValue();
}
private int _Increment = 1;
/// <summary>
/// Gets or sets the value to increment or decrement the value of the control when the up or down buttons are clicked.
/// </summary>
[DefaultValue(1)]
public int Increment
{
get { return _Increment; }
set
{
value = Math.Abs(value);
if (_Increment != value)
{
_Increment = value;
}
}
}
private void SetValueDirect(string s)
{
if (SetInputStack(s))
{
SetInputPosition(InputStack.Length);
}
}
private string ConvertToString(int i)
{
return ConvertToString(i, false);
}
private string ConvertToString(int i, bool useFormat)
{
return ConvertToString(i, useFormat, false);
}
private string ConvertToString(int i, bool useFormat, bool forceFormat)
{
if (!forceFormat && (!useFormat || this.IsFocused) || _DisplayFormat.Length == 0)
return FormatNumber(i);
else
{
CultureInfo ci = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
IFormatProvider formatProvider = ci.GetFormat(typeof(NumberFormatInfo)) as IFormatProvider;
if (formatProvider != null)
return i.ToString(_DisplayFormat, formatProvider);
return i.ToString(_DisplayFormat);
}
}
[Browsable(false)]
public virtual string Text
{
get
{
if (this.IsEmpty && this.AllowEmptyState) return "";
return ConvertToString(_Value, true, true);
}
}
public virtual int Value
{
get
{
if (_Value < _MinValue)
return _MinValue;
if (_Value > _MaxValue)
return _MaxValue;
return _Value;
}
set
{
//if (_Value != value)
{
if (value < _MinValue) value = _MinValue;
if (value > _MaxValue) value = _MaxValue;
SetValueDirect(ConvertToString(value));
if (this.IsFocused)
InputComplete(false);
}
}
}
protected override string GetInputStringValue()
{
return ConvertToString(_Value);
}
private string _DisplayFormat = "";
/// <summary>
/// Gets or sets the Numeric String Format that is used to format the numeric value entered for display purpose.
/// </summary>
[Description("Indicates Numeric String Format that is used to format the numeric value entered for display purpose.")]
public string DisplayFormat
{
get { return _DisplayFormat; }
set
{
if (value != null)
_DisplayFormat = value;
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,501 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
namespace DevComponents.Editors
{
public class VisualItem
{
#region Private Variables
#endregion
#region Events
/// <summary>
/// Occurs when item arrange becomes invalid.
/// </summary>
public event EventHandler ArrangeInvalid;
/// <summary>
/// Occurs when item appearance becomes invalid and items needs to be repainted.
/// </summary>
public event EventHandler RenderInvalid;
/// <summary>
/// Occurs when item needs to signal to parent control that MouseHover needs to be reset usually in response to tooltip hiding.
/// </summary>
public event EventHandler ResetMouseHover;
/// <summary>
/// Occurs when item is clicked.
/// </summary>
public event EventHandler Click;
/// <summary>
/// Occurs when item is clicked using mouse.
/// </summary>
public event MouseEventHandler MouseClick;
/// <summary>
/// Occurs when mouse button is pressed over the item.
/// </summary>
public event MouseEventHandler MouseDown;
/// <summary>
/// Occurs when mouse button is pressed over the item.
/// </summary>
public event MouseEventHandler MouseUp;
/// <summary>
/// Occurs when mouse hovers over the item.
/// </summary>
public event EventHandler MouseHover;
#endregion
#region Constructor
#endregion
#region Internal Implementation
internal virtual void ProcessMouseEnter()
{
if (this.GetIsEnabled())
OnMouseEnter();
}
protected virtual void OnMouseEnter()
{
}
internal virtual void ProcessMouseLeave()
{
if (this.GetIsEnabled())
OnMouseLeave();
}
protected virtual void OnMouseLeave()
{
}
internal virtual void ProcessMouseMove(MouseEventArgs e)
{
if (this.GetIsEnabled())
OnMouseMove(e);
}
protected virtual void OnMouseMove(MouseEventArgs e)
{
}
internal virtual void ProcessMouseWheel(MouseEventArgs e)
{
if (this.GetIsEnabled())
OnMouseWheel(e);
}
protected virtual void OnMouseWheel(MouseEventArgs e)
{
}
internal virtual void ProcessMouseDown(MouseEventArgs e)
{
if (this.GetIsEnabled())
OnMouseDown(e);
}
protected virtual void OnMouseDown(MouseEventArgs e)
{
if (MouseDown != null)
MouseDown(this, e);
}
internal virtual void ProcessMouseUp(MouseEventArgs e)
{
if (this.GetIsEnabled())
OnMouseUp(e);
}
protected virtual void OnMouseUp(MouseEventArgs e)
{
if (MouseUp != null)
MouseUp(this, e);
}
internal virtual void ProcessMouseHover(EventArgs e)
{
if (this.GetIsEnabled())
OnMouseHover(e);
}
protected virtual void OnMouseHover(EventArgs e)
{
if (MouseHover != null)
MouseHover(this, e);
}
internal virtual void ProcessClick()
{
if (this.GetIsEnabled())
OnClick(EventArgs.Empty);
}
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
Click(this, e);
}
internal virtual void ProcessMouseClick(MouseEventArgs e)
{
if (this.GetIsEnabled())
OnMouseClick(e);
}
protected virtual void OnMouseClick(MouseEventArgs e)
{
if (MouseClick != null)
MouseClick(this, e);
}
internal virtual void ProcessKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
}
protected virtual void OnKeyDown(KeyEventArgs e)
{
}
internal virtual void ProcessKeyUp(KeyEventArgs e)
{
OnKeyUp(e);
}
protected virtual void OnKeyUp(KeyEventArgs e)
{
}
internal virtual void ProcessKeyPress(KeyPressEventArgs e)
{
OnKeyPress(e);
}
protected virtual void OnKeyPress(KeyPressEventArgs e)
{
}
internal virtual bool ProcessCmdKey(ref Message msg, Keys keyData)
{
return OnCmdKey(ref msg, keyData);
}
protected virtual bool OnCmdKey(ref Message msg, Keys keyData)
{
return false;
}
internal virtual void ProcessGotFocus()
{
OnGotFocus();
}
protected virtual void OnGotFocus()
{
_IsFocused = true;
OnFocusChanged();
}
internal virtual void ProcessLostFocus()
{
OnLostFocus();
}
protected virtual void OnLostFocus()
{
_IsFocused = false;
OnFocusChanged();
}
protected virtual void OnFocusChanged()
{
}
internal virtual void ProcessPaint(PaintInfo p)
{
if (!IsRendered) return;
OnPaint(p);
}
protected virtual void OnPaint(PaintInfo p)
{
}
private bool _Focusable = false;
public bool Focusable
{
get { return _Focusable; }
set
{
if (_Focusable != value)
{
_Focusable = value;
OnFocusableChanged();
}
}
}
protected virtual void OnFocusableChanged()
{
}
private bool _Enabled = true;
/// <summary>
/// Gets or sets whether item is Enabled.
/// </summary>
[DefaultValue(true)]
public bool Enabled
{
get { return _Enabled; }
set
{
if (_Enabled != value)
{
_Enabled = value;
OnRenderInvalid();
}
}
}
protected virtual bool GetIsEnabled()
{
if (!_Enabled) return _Enabled;
VisualItem p = this.Parent;
while (p != null)
{
if (!p.Enabled) return false;
p = p.Parent;
}
return _Enabled;
}
protected virtual bool GetIsEnabled(PaintInfo p)
{
return p.ParentEnabled && _Enabled;
}
private bool _Visible = true;
public bool Visible
{
get { return _Visible; }
set
{
if (_Visible != value)
{
_Visible = value;
OnVisibleChanged();
}
}
}
protected virtual void OnVisibleChanged()
{
if (_Parent != null)
{
_Parent.OnChildItemVisibleChanged(this);
}
}
private bool _IsRendered = true;
/// <summary>
/// Gets or sets whether visual is rendered. Default value is true.
/// </summary>
public virtual bool IsRendered
{
get { return _IsRendered; }
set
{
_IsRendered = value;
}
}
public virtual void InvalidateArrange()
{
_RenderBounds = Rectangle.Empty;
_Location = Point.Empty;
_IsLayoutValid = false;
if (_Parent != null)
_Parent.InvalidateArrange();
OnArrangeInvalid();
}
public virtual void InvalidateRender()
{
if (_Parent != null)
_Parent.InvalidateRender();
OnRenderInvalid();
}
/// <summary>
/// Raises the RenderInvalid event.
/// </summary>
protected virtual void OnRenderInvalid()
{
if (RenderInvalid != null)
RenderInvalid(this, new EventArgs());
}
/// <summary>
/// Raises the ArrangeInvalid event.
/// </summary>
protected virtual void OnArrangeInvalid()
{
if (ArrangeInvalid != null)
ArrangeInvalid(this, new EventArgs());
}
private VisualGroup _Parent;
/// <summary>
/// Gets the parent of the item.
/// </summary>
public VisualGroup Parent
{
get { return _Parent; }
internal set
{
if (_Parent != value)
{
_Parent = value;
OnParentChanged();
}
}
}
protected virtual void OnParentChanged()
{
}
private Size _ItemSize = Size.Empty;
public Size Size
{
get { return _ItemSize; }
internal set
{
_ItemSize = value;
}
}
private Rectangle _RenderBounds = Rectangle.Empty;
public Rectangle RenderBounds
{
get { return _RenderBounds; }
internal set
{
_RenderBounds = value;
}
}
private Point _Location;
/// <summary>
/// Gets the relative location of the element inside of its parent item.
/// </summary>
public Point Location
{
get { return _Location; }
internal set { _Location = value; }
}
private bool _IsRightToLeft;
public bool IsRightToLeft
{
get { return _IsRightToLeft; }
set
{
if (_IsRightToLeft != value)
{
_IsRightToLeft = value;
OnIsRightToLeftChanged();
}
}
}
protected virtual void OnIsRightToLeftChanged()
{
InvalidateArrange();
}
private bool _IsLayoutValid = false;
public virtual bool IsLayoutValid
{
get { return _IsLayoutValid; }
}
public virtual void PerformLayout(PaintInfo pi) { _IsLayoutValid = true; }
private bool _IsFocused = false;
public bool IsFocused
{
get { return _IsFocused; }
}
private eItemAlignment _Alignment = eItemAlignment.Left;
/// <summary>
/// Gets or sets the item horizontal alignment inside of the parent group. Default value is left.
/// </summary>
[DefaultValue(eItemAlignment.Left)]
public eItemAlignment Alignment
{
get { return _Alignment; }
set
{
if (_Alignment != value)
{
_Alignment = value;
this.InvalidateArrange();
}
}
}
private eSystemItemType _ItemType = eSystemItemType.Default;
internal eSystemItemType ItemType
{
get { return _ItemType; }
set
{
_ItemType = value;
}
}
private Size _CalculatedSize;
public Size CalculatedSize
{
get { return _CalculatedSize; }
internal set { _CalculatedSize = value; }
}
public virtual void ResetHover()
{
if (_Parent != null)
_Parent.ResetHover();
OnResetMouseHover();
}
/// <summary>
/// Raises the ResetMouseHover event.
/// </summary>
protected virtual void OnResetMouseHover()
{
if (ResetMouseHover != null)
ResetMouseHover(this, new EventArgs());
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,305 @@
#if FRAMEWORK20
using System;
using System.Text;
using System.Collections;
namespace DevComponents.Editors
{
public class VisualItemCollection : CollectionBase
{
#region Internal Implementation
/// <summary>Creates new instance of the class.</summary>
public VisualItemCollection() { }
/// <summary>Creates new instance of the class.</summary>
public VisualItemCollection(VisualGroup parent)
{
_Parent = parent;
}
private VisualGroup _Parent = null;
internal VisualGroup Parent
{
get { return _Parent; }
set { _Parent = value; }
}
/// <summary>
/// Adds new object to the collection.
/// </summary>
/// <param name="item">Object to add.</param>
/// <returns>Index of newly added object.</returns>
public int Add(VisualItem item)
{
return List.Add(item);
}
/// <summary>
/// Adds array of new objects to the collection.
/// </summary>
/// <param name="items">Array of object to add.</param>
public void AddRange(VisualItem[] items)
{
foreach (VisualItem item in items)
this.Add(item);
}
/// <summary>
/// Adds array of new objects to the collection.
/// </summary>
/// <param name="items">Array of object to add.</param>
public void AddRange(IList items)
{
for (int i = 0; i < items.Count; i++)
{
this.Add((VisualItem)items[i]);
}
}
/// <summary>
/// Returns reference to the object in collection based on it's index.
/// </summary>
public VisualItem this[int index]
{
get { return (VisualItem)(List[index]); }
set { List[index] = value; }
}
/// <summary>
/// Inserts new object into the collection.
/// </summary>
/// <param name="index">Position of the object.</param>
/// <param name="value">Object to insert.</param>
public void Insert(int index, VisualItem value)
{
List.Insert(index, value);
}
/// <summary>
/// Returns index of the object inside of the collection.
/// </summary>
/// <param name="value">Reference to the object.</param>
/// <returns>Index of the object.</returns>
public int IndexOf(VisualItem value)
{
return List.IndexOf(value);
}
/// <summary>
/// Returns whether collection contains specified object.
/// </summary>
/// <param name="value">Object to look for.</param>
/// <returns>true if object is part of the collection, otherwise false.</returns>
public bool Contains(VisualItem value)
{
return List.Contains(value);
}
/// <summary>
/// Removes specified object from the collection.
/// </summary>
/// <param name="value"></param>
public void Remove(VisualItem value)
{
List.Remove(value);
}
protected override void OnRemove(int index, object value)
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(null, new VisualItem[] { (VisualItem)value }, eCollectionChangeType.Removing));
}
base.OnRemove(index, value);
}
protected override void OnRemoveComplete(int index, object value)
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(null, new VisualItem[] { (VisualItem)value }, eCollectionChangeType.Removed));
}
base.OnRemoveComplete(index, value);
}
protected override void OnInsert(int index, object value)
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(new VisualItem[] { (VisualItem)value }, null, eCollectionChangeType.Adding));
}
base.OnInsert(index, value);
}
protected override void OnInsertComplete(int index, object value)
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(new VisualItem[] { (VisualItem)value }, null, eCollectionChangeType.Added));
}
base.OnInsertComplete(index, value);
}
protected override void OnClear()
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(null, null, eCollectionChangeType.Clearing));
}
base.OnClear();
}
protected override void OnClearComplete()
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(null, null, eCollectionChangeType.Cleared));
}
base.OnClearComplete();
}
protected override void OnSet(int index, object oldValue, object newValue)
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(new VisualItem[] { (VisualItem)oldValue },
new VisualItem[] { (VisualItem)newValue }, eCollectionChangeType.Removing));
}
base.OnSet(index, oldValue, newValue);
}
protected override void OnSetComplete(int index, object oldValue, object newValue)
{
if (_Parent != null)
{
_Parent.ProcessItemsCollectionChanged(new CollectionChangedInfo(new VisualItem[] { (VisualItem)oldValue },
new VisualItem[] { (VisualItem)newValue }, eCollectionChangeType.Removed));
}
base.OnSetComplete(index, oldValue, newValue);
}
/// <summary>
/// Copies collection into the specified array.
/// </summary>
/// <param name="array">Array to copy collection to.</param>
/// <param name="index">Starting index.</param>
public void CopyTo(VisualItem[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Copies contained items to the VisualItem array.
/// </summary>
/// <param name="array">Array to copy to.</param>
internal void CopyTo(VisualItem[] array)
{
List.CopyTo(array, 0);
}
#endregion
}
public class CollectionChangedInfo
{
public CollectionChangedInfo(VisualItem[] added, VisualItem[] removed, eCollectionChangeType changeType)
{
_Added = added;
_Removed = removed;
_ChangeType = changeType;
}
private VisualItem[] _Added;
public VisualItem[] Added
{
get { return _Added; }
}
private VisualItem[] _Removed;
public VisualItem[] Removed
{
get { return _Removed; }
}
private eCollectionChangeType _ChangeType;
public eCollectionChangeType ChangeType
{
get { return _ChangeType; }
}
}
internal class VisualCollectionEnumerator : IEnumerable, IEnumerator
{
private IList _ParentCollection = null;
private int _CurrentIndex = -1;
private int _Direction = 1, _Start = -1, _End = -1;
public VisualCollectionEnumerator(VisualItemCollection parentCollection, bool rightToLeft)
{
_ParentCollection = parentCollection;
if (rightToLeft)
{
_Direction = -1;
_Start = parentCollection.Count - 1;
_End = -1;
}
else
{
_Start = 0;
_End = parentCollection.Count;
}
}
#region IEnumerable Members
public IEnumerator GetEnumerator()
{
return this;
}
#endregion
#region IEnumerator Members
public object Current
{
get
{
if (_CurrentIndex < 0)
throw new InvalidOperationException("IEnumerator Pointer is invalid. Use MoveNext to advance enumerator.");
return _ParentCollection[_CurrentIndex];
}
}
internal int CurrentIndex
{
get
{
return _CurrentIndex;
}
set
{
_CurrentIndex = value;
}
}
public bool MoveNext()
{
if (_CurrentIndex == _End && _CurrentIndex >= 0)
throw new InvalidOperationException("Enumerator cannot advance beyond the boundaries of array. Use Reset to reset enumerator");
if (_CurrentIndex == -1) _CurrentIndex = _Start - _Direction;
_CurrentIndex += _Direction;
if (_CurrentIndex == _End) return false;
return true;
}
public void Reset()
{
_CurrentIndex = -1;
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,93 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
public class VisualLabel : VisualItem
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
private Padding _TextPadding = new Padding(0);
/// <summary>
/// Gets or sets the amount of padding added to text.
/// </summary>
public Padding TextPadding
{
get { return _TextPadding; }
set { _TextPadding = value; InvalidateArrange(); }
}
private string _Text = "";
/// <summary>
/// Gets or sets the text displayed by the label.
/// </summary>
public string Text
{
get { return _Text; }
set
{
if (value == null) value = "";
if (_Text != value)
{
_Text = value;
InvalidateArrange();
}
}
}
public override void PerformLayout(PaintInfo p)
{
Size size = Size.Empty;
Graphics g = p.Graphics;
Font font = p.DefaultFont;
eTextFormat textFormat = eTextFormat.Default | eTextFormat.GlyphOverhangPadding | eTextFormat.LeftAndRightPadding;
if (_Text.Length > 0)
{
if (Text.Trim().Length == 0)
{
size = TextDrawing.MeasureString(g, Text.Replace(' ', '-'), font, 0, textFormat);
size.Width = (int)(size.Width);
}
else
size = TextDrawing.MeasureString(g, Text, font, 0, textFormat);
}
size.Height += _TextPadding.Vertical;
size.Width += _TextPadding.Horizontal;
this.Size = size;
base.PerformLayout(p);
}
protected override void OnPaint(PaintInfo p)
{
Graphics g = p.Graphics;
Font font = p.DefaultFont;
Rectangle r = this.RenderBounds;
eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding;
Color color = p.ForeColor;
r.X += _TextPadding.Left;
r.Y += _TextPadding.Top;
if (!GetIsEnabled(p))
color = p.DisabledForeColor;
if (_Text.Length > 0)
TextDrawing.DrawString(g, _Text, font, color, r, textFormat);
base.OnPaint(p);
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,207 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
public class VisualListInput : VisualInputBase
{
#region Private Variables
#endregion
#region Events
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override bool OnCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (keyData == System.Windows.Forms.Keys.Up)
{
SelectPrevious();
return true;
}
else if (keyData == System.Windows.Forms.Keys.Down)
{
SelectNext();
return true;
}
return base.OnCmdKey(ref msg, keyData);
}
protected override void OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
{
if (!this.IsReadOnly)
{
if (e.Delta > 0)
{
SelectNext();
}
else
{
SelectPrevious();
}
}
base.OnMouseWheel(e);
}
protected override bool ValidateNewInputStack(string s)
{
if (s.Length == 0 && !_AllowEmptyState)
return false;
return base.ValidateNewInputStack(s);
}
public virtual void SelectNext()
{
if (this.IsReadOnly) return;
ResetInputStack();
InputComplete(false);
}
public virtual void SelectPrevious()
{
if (this.IsReadOnly) return;
ResetInputStack();
InputComplete(false);
}
protected override void ResetValue()
{
if (SetInputStack(""))
{
SetInputPosition(InputStack.Length);
}
base.ResetValue();
}
public override void PerformLayout(PaintInfo p)
{
Size size = Size.Empty;
Graphics g = p.Graphics;
Font font = p.DefaultFont;
eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding;
string s = GetMeasureString();
size = TextDrawing.MeasureString(g, s, font, 0, textFormat);
size.Width++; // Additional pixel for selection
this.Size = size;
base.PerformLayout(p);
}
protected virtual string GetMeasureString()
{
string s = GetRenderString();
if (s.Length == 0) s = "T";
return s;
}
protected override void OnPaint(PaintInfo p)
{
Graphics g = p.Graphics;
Font font = p.DefaultFont;
Color color = p.ForeColor;
if (!GetIsEnabled(p))
color = p.DisabledForeColor;
eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding;
string text = GetRenderString();
Rectangle selectionBounds = this.RenderBounds;
Region oldClip = null;
if (this.IsFocused && this.InputStack.Length > 0 && this.InputStack.Length < text.Length)
{
// Render partial selection based on the input stack
Size inputSize = TextDrawing.MeasureString(g, text.Substring(0, this.InputStack.Length), font);
oldClip = g.Clip;
Rectangle newClip = selectionBounds;
if (this.IsRightToLeft)
{
newClip.X += newClip.Width - inputSize.Width;
newClip.Width = inputSize.Width;
selectionBounds.Width -= inputSize.Width;
}
else
{
newClip.Width = inputSize.Width;
selectionBounds.X += inputSize.Width;
selectionBounds.Width -= inputSize.Width;
}
g.SetClip(newClip, System.Drawing.Drawing2D.CombineMode.Intersect);
TextDrawing.DrawString(g, text, font, color, RenderBounds, textFormat);
g.Clip = oldClip;
g.SetClip(selectionBounds, System.Drawing.Drawing2D.CombineMode.Intersect);
}
if (this.IsFocused)
{
if (p.Colors.Highlight.IsEmpty)
g.FillRectangle(SystemBrushes.Highlight, selectionBounds);
else
{
using (SolidBrush brush = new SolidBrush(p.Colors.Highlight))
g.FillRectangle(brush, selectionBounds);
}
color = p.Colors.HighlightText.IsEmpty ? SystemColors.HighlightText : p.Colors.HighlightText;
}
if (!this.IsEmpty)
{
TextDrawing.DrawString(g, text, font, color, RenderBounds, textFormat);
}
if (oldClip != null)
g.Clip = oldClip;
base.OnPaint(p);
}
protected virtual string GetRenderString()
{
return GetInputStringValue();
}
public override bool IsEmpty
{
get
{
return GetInputStringValue().Length == 0;
}
set
{
if (value != IsEmpty)
{
if (value && _AllowEmptyState)
{
ResetValue();
}
}
}
}
private bool _AllowEmptyState = true;
/// <summary>
/// Gets or sets whether control allows empty input state i.e. does not have an text entered. Default value is true.
/// </summary>
public bool AllowEmptyState
{
get { return _AllowEmptyState; }
set { _AllowEmptyState = value; }
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,240 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using DevComponents.DotNetBar;
using System.ComponentModel;
namespace DevComponents.Editors
{
public class VisualNumericInput : VisualInputBase
{
#region Private Variables
#endregion
#region Events
/// <summary>
/// Occurs when Value property has changed.
/// </summary>
public event EventHandler ValueChanged;
#endregion
#region Constructor
#endregion
#region Internal Implementation
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Subtract || e.KeyCode == System.Windows.Forms.Keys.OemMinus) && AllowsNegativeValue && this.InputStack.Length>0)
{
if (!this.IsEmpty)
NegateValue();
e.Handled = true;
}
base.OnKeyDown(e);
}
protected override bool OnCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (!this.IsReadOnly)
{
if (keyData == System.Windows.Forms.Keys.Up)
{
IncreaseValue();
return true;
}
else if (keyData == System.Windows.Forms.Keys.Down)
{
DecreaseValue();
return true;
}
}
return base.OnCmdKey(ref msg, keyData);
}
private bool _MouseWheelValueChangeEnabled = true;
/// <summary>
/// Gets or sets whether mouse wheel increases or decreases the input value when used.
/// </summary>
[DefaultValue(true), Category("Behavior"), Description("Indicates whether mouse wheel increases or decreases the input value when used.")]
public bool MouseWheelValueChangeEnabled
{
get { return _MouseWheelValueChangeEnabled; }
set
{
_MouseWheelValueChangeEnabled = value;
}
}
protected override void OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
{
if (_MouseWheelValueChangeEnabled && !this.IsReadOnly)
{
if (e.Delta > 0)
{
IncreaseValue();
}
else
{
DecreaseValue();
}
}
base.OnMouseWheel(e);
}
public virtual void DecreaseValue()
{
InputComplete(false);
ResetInputPosition();
}
public virtual void IncreaseValue()
{
InputComplete(false);
ResetInputPosition();
}
protected virtual void NegateValue()
{
}
protected override bool AcceptKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar >= 48 && e.KeyChar <= 57 ||
this.AllowsNegativeValue && e.KeyChar == '-' && (this.IsEmpty || !this.IsEmpty && (this.InputStack=="" || this.InputStack=="0")))
{
e.Handled = true;
return true;
}
return false;
}
public override void PerformLayout(PaintInfo p)
{
Size size = Size.Empty;
Graphics g = p.Graphics;
Font font = p.DefaultFont;
eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding;
string s = GetMeasureString();
size = TextDrawing.MeasureString(g, s, font, 0, textFormat);
//size.Width++;
this.Size = size;
base.PerformLayout(p);
}
protected virtual string GetMeasureString()
{
return "";
}
protected override void OnPaint(PaintInfo p)
{
Graphics g = p.Graphics;
Font font = p.DefaultFont;
Color color = p.ForeColor;
if (!this.GetIsEnabled(p))
color = p.DisabledForeColor;
eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding;
if (this.IsFocused)
{
if (p.Colors.Highlight.IsEmpty)
g.FillRectangle(SystemBrushes.Highlight, this.RenderBounds);
else
{
using (SolidBrush brush = new SolidBrush(p.Colors.Highlight))
g.FillRectangle(brush, this.RenderBounds);
}
color = p.Colors.HighlightText.IsEmpty ? SystemColors.HighlightText : p.Colors.HighlightText;
}
if (!(this.IsEmpty && this.AllowEmptyState))
{
string text = GetRenderString();
TextDrawing.DrawString(g, text, font, color, RenderBounds, textFormat);
}
base.OnPaint(p);
}
protected virtual string GetRenderString()
{
return "";
}
private bool _AllowEmptyState = true;
/// <summary>
/// Gets or sets whether control allows empty input state i.e. does not have an number entered. Default value is true. When control is empty
/// IsEmpty property returns true and control does not display number. Set to false to always force control to have number displayed.
/// </summary>
public bool AllowEmptyState
{
get { return _AllowEmptyState; }
set { _AllowEmptyState = value; }
}
private bool _AllowsNegativeValue = true;
public bool AllowsNegativeValue
{
get { return _AllowsNegativeValue; }
set { _AllowsNegativeValue = value; }
}
protected override bool SetInputStack(string s)
{
s = ProcessNewInputStack(s);
return base.SetInputStack(s);
}
private bool _LeadingZero = false;
protected virtual string ProcessNewInputStack(string s)
{
if (this.InputStack == "0" && s != "0" && s.StartsWith("0"))
{
s = s.Substring(1);
this.SetInputPosition(this.InputPosition - 1);
_LeadingZero = true;
}
else
_LeadingZero = false;
return s;
}
protected virtual bool IsLeadingZero
{
get
{
return _LeadingZero;
}
}
protected override void ResetInputStack()
{
_LeadingZero = false;
base.ResetInputStack();
}
protected virtual void OnValueChanged()
{
if (ValueChanged != null)
ValueChanged(this, new EventArgs());
}
protected override void OnInputLostFocus()
{
if (this.InputStack == "-")
OnClear();
else
ResetInputStack();
base.OnInputLostFocus();
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,242 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using DevComponents.Editors.Primitives;
using System.ComponentModel;
namespace DevComponents.Editors
{
public class VisualStringListInput : VisualListInput
{
#region Private Variables
private List<string> _Items = new List<string>();
private string _Text = "";
private string _LastValidatedInputStack = "", _LastMatch = "";
private bool _LastMatchComplete = false;
#endregion
#region Events
/// <summary>
/// Occurs when SelectedIndex property has changed.
/// </summary>
public event EventHandler SelectedIndexChanged;
#endregion
#region Constructor
public VisualStringListInput()
{
}
#endregion
#region Internal Implementation
public List<String> Items
{
get
{
return _Items;
}
}
protected virtual List<String> GetItems()
{
return _Items;
}
protected override bool ValidateNewInputStack(string s)
{
_LastValidatedInputStack = "";
_LastMatch = "";
_LastMatchComplete = false;
if (s.Length > 0)
{
List<String> items = GetItems();
StartsWithPredicate p = new StartsWithPredicate(s.ToLower(), 2);
List<string> match = items.FindAll(p.MatchTop);
if (match == null || match.Count == 0)
return false;
_LastMatch = match[0];
_LastValidatedInputStack = s;
_LastMatchComplete = match.Count == 1;
return true;
}
return base.ValidateNewInputStack(s);
}
protected string LastValidatedInputStack
{
get
{
return _LastValidatedInputStack;
}
set
{
_LastValidatedInputStack = value;
}
}
protected string LastMatch
{
get
{
return _LastMatch;
}
set
{
_LastMatch = value;
}
}
protected bool LastMatchComplete
{
get
{
return _LastMatchComplete;
}
set
{
_LastMatchComplete = value;
}
}
protected override void OnInputStackChanged()
{
bool changed = false;
if (_LastValidatedInputStack.Length > 0 && this.InputStack == _LastValidatedInputStack)
{
changed = _Text != _LastMatch;
_Text = _LastMatch;
}
else if (this.InputStack.Length == 0)
{
changed = _Text != "";
_Text = "";
}
InvalidateArrange();
if (changed)
OnSelectedIndexChanged(new EventArgs());
base.OnInputStackChanged();
}
protected override void OnInputKeyAccepted()
{
if (_LastMatchComplete)
{
InputComplete(true);
_LastMatchComplete = false;
}
base.OnInputKeyAccepted();
}
/// <summary>
/// Gets or sets the text that is selected by the control.
/// </summary>
[DefaultValue("")]
public string Text
{
get
{
return GetInputStringValue();
}
set
{
if (_Text != value)
{
List<String> items = GetItems();
if (value == "" && !AllowEmptyState && items.Count > 0)
value = items[0];
else if (value != null && value.Length > 0)
{
if (!items.Contains(value))
{
if (!AllowEmptyState && items.Count > 0)
value = items[0];
else
value = "";
}
}
_Text = value;
ResetInputStack();
OnInputChanged();
OnSelectedIndexChanged(new EventArgs());
InvalidateArrange();
if (this.IsEmpty) this.IsEmpty = false;
}
}
}
/// <summary>
/// Raises SelectedIndexChanged event
/// </summary>
protected virtual void OnSelectedIndexChanged(EventArgs e)
{
if (SelectedIndexChanged != null)
SelectedIndexChanged(this, e);
}
/// <summary>
/// Gets or sets the currently selected index. -1 is returned if nothing is selected.
/// </summary>
[DefaultValue(-1), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int SelectedIndex
{
get
{
if (this.IsEmpty || _Text == "") return -1;
List<string> items = GetItems();
return items.IndexOf(this.Text);
}
set
{
if (value >= 0)
{
List<string> items = GetItems();
this.Text = items[value];
}
else
this.Text = "";
}
}
protected override string GetInputStringValue()
{
if (_Text == null) return "";
return _Text;
}
public override void SelectNext()
{
int index = this.SelectedIndex + 1;
List<string> items = GetItems();
if (index >= items.Count)
index = 0;
this.SelectedIndex = index;
base.SelectNext();
}
public override void SelectPrevious()
{
int index = this.SelectedIndex - 1;
if (index < 0)
{
List<string> items = GetItems();
index = items.Count - 1;
}
this.SelectedIndex = index;
base.SelectPrevious();
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,147 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
namespace DevComponents.Editors
{
public class VisualToggleButton : VisualItem
{
#region Private Variables
#endregion
#region Events
/// <summary>
/// Occurs when Checked property has changed.
/// </summary>
public event EventHandler CheckedChanged;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the VisualToggleButton class.
/// </summary>
public VisualToggleButton()
{
this.Focusable = true;
}
#endregion
#region Internal Implementation
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left && GetIsEnabled())
{
ToggleChecked();
IsMouseDown = true;
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
IsMouseDown = false;
base.OnMouseUp(e);
}
protected override void OnMouseEnter()
{
this.IsMouseOver = true;
base.OnMouseEnter();
}
protected override void OnMouseLeave()
{
this.IsMouseOver = false;
base.OnMouseLeave();
}
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == System.Windows.Forms.Keys.Space && GetIsEnabled())
{
ToggleChecked();
e.Handled = true;
}
base.OnKeyDown(e);
}
private void ToggleChecked()
{
this.Checked = !this.Checked;
}
/// <summary>
/// Raises the CheckedChanged event.
/// </summary>
protected virtual void OnCheckedChanged(EventArgs e)
{
if (CheckedChanged != null)
CheckedChanged(this, e);
}
private bool _Checked = false;
/// <summary>
/// Gets or sets whether item is checked.
/// </summary>
[DefaultValue(false)]
public virtual bool Checked
{
get { return _Checked; }
set
{
if (_Checked != value)
{
_Checked = value;
InvalidateRender();
OnCheckedChanged(new EventArgs());
}
}
}
private bool _IsMouseDown;
/// <summary>
/// Gets whether left mouse button is pressed over the item.
/// </summary>
[Browsable(false)]
public bool IsMouseDown
{
get { return _IsMouseDown; }
internal set
{
if (value != _IsMouseDown)
{
_IsMouseDown = value;
this.InvalidateRender();
}
}
}
private bool _IsMouseOver = false;
/// <summary>
/// Gets whether mouse is over the item.
/// </summary>
[Browsable(false)]
public bool IsMouseOver
{
get { return _IsMouseOver; }
internal set
{
if (value != _IsMouseOver)
{
_IsMouseOver = value;
this.InvalidateRender();
}
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,497 @@
#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using DevComponents.DotNetBar.Rendering;
using DevComponents.DotNetBar;
namespace DevComponents.Editors
{
/// <summary>
/// Represents the up down button which allows change of the value in currently focused input control.
/// </summary>
public class VisualUpDownButton : VisualButtonBase
{
#region Private Variables
private bool _MouseOverButtonUp = false;
private bool _MouseOverButtonDown = false;
private bool _MouseDownButtonUp = false;
private bool _MouseDownButtonDown = false;
private Rectangle _DownButtonRectangle = Rectangle.Empty;
private Rectangle _UpButtonRectangle = Rectangle.Empty;
#endregion
#region Events
/// <summary>
/// Occurs when Up part of the button has been clicked.
/// </summary>
public event EventHandler UpClick;
/// <summary>
/// Occurs when Down part of the button has been clicked.
/// </summary>
public event EventHandler DownClick;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the VisualUpDownButton class.
/// </summary>
public VisualUpDownButton()
{
this.Focusable = false;
this.ClickAutoRepeat = true;
}
#endregion
#region Internal Implementation
public override void PerformLayout(PaintInfo pi)
{
int height = pi.AvailableSize.Height;
if (height % 2 != 0)
height++;
Size size = new Size(Dpi.Width(_ButtonWidth), height);
if (_UpImage != null && _DownImage != null)
size.Width = Math.Max(Dpi.Width(_UpImage.Width), Dpi.Width(_DownImage.Width));
this.Size = size;
this.CalculatedSize = size;
base.PerformLayout(pi);
}
protected override void OnPaint(PaintInfo p)
{
Graphics g = p.Graphics;
Rectangle r = this.RenderBounds;
if (r.Width <= 0 || r.Height <= 0)
return;
Rectangle buttonRect = new Rectangle(r.X, r.Y, r.Width, r.Height / 2);
if (_UpImage != null)
g.DrawImage(_UpImage, buttonRect.Location);
else
{
Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTableButtonUp(p);
PaintButtonBackground(p, ct, buttonRect);
using (SolidBrush brush = new SolidBrush(ct.Text))
p.Graphics.FillPolygon(brush, Office2007ButtonItemPainter.GetExpandPolygon(buttonRect, ePopupSide.Top));
}
_UpButtonRectangle = buttonRect;
buttonRect = new Rectangle(r.X, buttonRect.Bottom, r.Width, r.Height - buttonRect.Height);
if (_DownImage != null)
g.DrawImage(_DownImage, buttonRect.Location);
else
{
Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTableButtonDown(p);
PaintButtonBackground(p, ct, buttonRect);
using (SolidBrush brush = new SolidBrush(ct.Text))
p.Graphics.FillPolygon(brush, Office2007ButtonItemPainter.GetExpandPolygon(buttonRect, ePopupSide.Bottom));
}
_DownButtonRectangle = buttonRect;
base.OnPaint(p);
}
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
if (this.GetIsEnabled())
{
if (_DownButtonRectangle.Contains(e.X, e.Y))
{
this.MouseOverButtonDown = true;
this.MouseOverButtonUp = false;
}
else if (_UpButtonRectangle.Contains(e.X, e.Y))
{
this.MouseOverButtonUp = true;
this.MouseOverButtonDown = false;
}
else
{
this.MouseOverButtonUp = false;
this.MouseOverButtonDown = false;
}
}
base.OnMouseMove(e);
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left && this.GetIsEnabled())
{
if (this.MouseOverButtonUp)
this.MouseDownButtonUp = true;
else if (this.MouseOverButtonDown)
this.MouseDownButtonDown = true;
ExecuteClickAction();
}
base.OnMouseDown(e);
}
private void ExecuteClickAction()
{
if (this.MouseOverButtonUp)
{
if (_AutoChange != eUpDownButtonAutoChange.None || _AutoChangeItem != null)
UpClickFocusedInputValue();
OnUpClick(new EventArgs());
}
else if (this.MouseOverButtonDown)
{
if (_AutoChange != eUpDownButtonAutoChange.None || _AutoChangeItem != null)
DownClickFocusedInputValue();
OnDownClick(new EventArgs());
}
}
protected override void OnClickAutoRepeat()
{
ExecuteClickAction();
base.OnClickAutoRepeat();
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
this.MouseDownButtonDown = false;
this.MouseDownButtonUp = false;
base.OnMouseUp(e);
}
protected override void OnMouseLeave()
{
this.MouseOverButtonDown = false;
this.MouseOverButtonUp = false;
base.OnMouseLeave();
}
private void DownClickFocusedInputValue()
{
VisualItem focusedItem = GetAutoChangeItem();
if (focusedItem == null) return;
VisualInputGroup parent = null;
if (focusedItem.Parent is VisualInputGroup && !((VisualInputGroup)this.Parent).IsUserInput)
{
parent = (VisualInputGroup)this.Parent;
parent.IsUserInput = true;
}
if (focusedItem is VisualNumericInput)
((VisualNumericInput)focusedItem).DecreaseValue();
else if (focusedItem is VisualListInput)
((VisualListInput)focusedItem).SelectNext();
if (parent != null)
parent.IsUserInput = false;
}
private void UpClickFocusedInputValue()
{
VisualItem focusedItem = GetAutoChangeItem();
if (focusedItem == null) return;
VisualInputGroup parent=null;
if (focusedItem.Parent is VisualInputGroup && !((VisualInputGroup)this.Parent).IsUserInput)
{
parent = (VisualInputGroup)this.Parent;
parent.IsUserInput = true;
}
if (focusedItem is VisualNumericInput)
((VisualNumericInput)focusedItem).IncreaseValue();
else if (focusedItem is VisualListInput)
((VisualListInput)focusedItem).SelectPrevious();
if (parent != null)
parent.IsUserInput = false;
}
private VisualItem GetAutoChangeItem()
{
if (_AutoChangeItem != null) return _AutoChangeItem;
if (_AutoChange == eUpDownButtonAutoChange.None || this.Parent == null || !(this.Parent is VisualGroup))
return null;
VisualGroup group = this.Parent as VisualGroup;
if (_AutoChange == eUpDownButtonAutoChange.FocusedItem)
{
if (group.FocusedItem is VisualInputGroup)
{
VisualInputGroup g = group.FocusedItem as VisualInputGroup;
while (g.FocusedItem is VisualInputGroup)
g = g.FocusedItem as VisualInputGroup;
return g.FocusedItem;
}
if (!(group.FocusedItem is VisualInputBase))
{
foreach (VisualItem item in group.Items)
{
if (item is VisualInputBase && item.Enabled && item.Visible && item.Focusable)
return item;
}
}
return group.FocusedItem;
}
int start = group.Items.IndexOf(this);
for (int i = start; i >= 0; i--)
{
VisualItem item = group.Items[i];
if (item is VisualInputBase && item.Visible)
return item;
}
return null;
}
/// <summary>
/// Raises the UpClick event.
/// </summary>
/// <param name="e">Provides event data.</param>
protected virtual void OnUpClick(EventArgs e)
{
if (UpClick != null)
UpClick(this, e);
}
/// <summary>
/// Raises the DownClick event.
/// </summary>
/// <param name="e">Provides event data.</param>
protected virtual void OnDownClick(EventArgs e)
{
if (DownClick != null)
DownClick(this, e);
}
private Image _UpImage = null;
/// <summary>
/// Gets or sets the image displayed on the face of the button.
/// </summary>
[DefaultValue(null)]
public Image UpImage
{
get { return _UpImage; }
set
{
if (_UpImage != value)
{
_UpImage = value;
this.InvalidateArrange();
}
}
}
private Image _DownImage = null;
/// <summary>
/// Gets or sets the image displayed on the face of the button.
/// </summary>
[DefaultValue(null)]
public Image DownImage
{
get { return _DownImage; }
set
{
if (_DownImage != value)
{
_DownImage = value;
this.InvalidateArrange();
}
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool MouseOverButtonUp
{
get { return _MouseOverButtonUp; }
set
{
if (_MouseOverButtonUp != value)
{
_MouseOverButtonUp = value;
this.InvalidateRender();
}
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool MouseOverButtonDown
{
get { return _MouseOverButtonDown; }
set
{
if (_MouseOverButtonDown != value)
{
_MouseOverButtonDown = value;
this.InvalidateRender();
}
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool MouseDownButtonDown
{
get { return _MouseDownButtonDown; }
set
{
if (_MouseDownButtonDown != value)
{
_MouseDownButtonDown = value;
this.InvalidateRender();
}
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool MouseDownButtonUp
{
get { return _MouseDownButtonUp; }
set
{
if (_MouseDownButtonUp != value)
{
_MouseDownButtonUp = value;
this.InvalidateRender();
}
}
}
private int _ButtonWidth = 15;
/// <summary>
/// Gets or sets the default width of the buttons.
/// </summary>
[DefaultValue(15)]
public int ButtonWidth
{
get { return _ButtonWidth; }
set
{
if (_ButtonWidth != value)
{
_ButtonWidth = value;
this.InvalidateArrange();
}
}
}
private eUpDownButtonAutoChange _AutoChange = eUpDownButtonAutoChange.None;
/// <summary>
/// Gets or sets whether control automatically tries to increase/decrease the value of the item that has input focus in the same
/// parent group as the button. Default value is false.
/// </summary>
[DefaultValue(eUpDownButtonAutoChange.None)]
public eUpDownButtonAutoChange AutoChange
{
get { return _AutoChange; }
set
{
_AutoChange = value;
}
}
private VisualItem _AutoChangeItem;
/// <summary>
/// Gets or sets the item that is automatically changed when buttons are pressed.
/// </summary>
[DefaultValue(null)]
public VisualItem AutoChangeItem
{
get { return _AutoChangeItem; }
set { _AutoChangeItem = value; }
}
private bool RenderBackground(PaintInfo p)
{
if (RenderDefaultBackground) return true;
if (!p.MouseOver && !(this.MouseDownButtonUp || this.MouseDownButtonDown) && !(this.MouseOverButtonUp || this.MouseOverButtonDown) || !this.GetIsEnabled())
return false;
return true;
}
protected virtual void PaintButtonBackground(PaintInfo p, Office2007ButtonItemStateColorTable ct, Rectangle r)
{
Graphics g = p.Graphics;
if(RenderBackground(p))
Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RectangleShape);
}
protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTableButtonUp(PaintInfo p)
{
if (GlobalManager.Renderer is Office2007Renderer)
{
Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)];
if (!this.GetIsEnabled(p) || !_UpEnabled)
return buttonColorTable.Disabled;
else if (this.MouseDownButtonUp)
return buttonColorTable.Pressed;
else if (this.MouseOverButtonUp)
return buttonColorTable.MouseOver;
else
return buttonColorTable.Default;
}
return null;
}
protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTableButtonDown(PaintInfo p)
{
if (GlobalManager.Renderer is Office2007Renderer)
{
Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)];
if (!this.GetIsEnabled(p) || !_DownEnabled)
return buttonColorTable.Disabled;
else if (this.MouseDownButtonDown)
return buttonColorTable.Pressed;
else if (this.MouseOverButtonDown)
return buttonColorTable.MouseOver;
else
return buttonColorTable.Default;
}
return null;
}
private bool _UpEnabled = true;
[DefaultValue(true)]
public bool UpEnabled
{
get { return _UpEnabled; }
set
{
if (_UpEnabled != value)
{
_UpEnabled = value;
this.InvalidateRender();
}
}
}
private bool _DownEnabled = true;
[DefaultValue(true)]
public bool DownEnabled
{
get { return _DownEnabled; }
set
{
if (_DownEnabled != value)
{
_DownEnabled = value;
this.InvalidateRender();
}
}
}
#endregion
}
}
#endif