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

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