DotNet 4.8.1 build of DotNetBar
This commit is contained in:
2045
PROMS/DotNetBar Source Code/PropertyGrid/AdvPropertyGrid.cs
Normal file
2045
PROMS/DotNetBar Source Code/PropertyGrid/AdvPropertyGrid.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class AdvPropertyGridAppearance : Component, INotifyPropertyChanged
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (BarUtilities.DisposeItemImages && !this.DesignMode)
|
||||
{
|
||||
BarUtilities.DisposeImage(ref _PropertyValueErrorImage);
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private Color _ErrorHighlightColor = ColorScheme.GetColor(0xD99694);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the node highlight when error has occurred while setting property value.
|
||||
/// </summary>
|
||||
[Category("Colors"), Description("Indicates color of the node highlight when error has occurred while setting property value.")]
|
||||
public Color ErrorHighlightColor
|
||||
{
|
||||
get { return _ErrorHighlightColor; }
|
||||
set
|
||||
{
|
||||
_ErrorHighlightColor = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ErrorHighlightColor"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeErrorHighlightColor()
|
||||
{
|
||||
return !_ErrorHighlightColor.Equals(ColorScheme.GetColor(0xD99694));
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetErrorHighlightColor()
|
||||
{
|
||||
this.ErrorHighlightColor = ColorScheme.GetColor(0xD99694);
|
||||
}
|
||||
|
||||
private Color _SuccessHighlightColor = ColorScheme.GetColor(0x9BBB59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the node highlight when property update was successful.
|
||||
/// </summary>
|
||||
[Category("Colors"), Description("Indicates color of node highlight when property update was successful.")]
|
||||
public Color SuccessHighlightColor
|
||||
{
|
||||
get { return _SuccessHighlightColor; }
|
||||
set
|
||||
{
|
||||
_SuccessHighlightColor = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("SuccessHighlightColor"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeSuccessHighlightColor()
|
||||
{
|
||||
return !_SuccessHighlightColor.Equals(ColorScheme.GetColor(0x9BBB59));
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetSuccessHighlightColor()
|
||||
{
|
||||
this.SuccessHighlightColor = ColorScheme.GetColor(0x9BBB59);
|
||||
}
|
||||
|
||||
private ElementStyle _DefaultPropertyStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets default style for property node.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Gets or sets default style for property node.")]
|
||||
public ElementStyle DefaultPropertyStyle
|
||||
{
|
||||
get { return _DefaultPropertyStyle; }
|
||||
set
|
||||
{
|
||||
if (_DefaultPropertyStyle != value)
|
||||
{
|
||||
if (_DefaultPropertyStyle != null)
|
||||
_DefaultPropertyStyle.StyleChanged -= new EventHandler(this.DefaultPropertyStyleChanged);
|
||||
if (value != null)
|
||||
value.StyleChanged += new EventHandler(DefaultPropertyStyleChanged);
|
||||
_DefaultPropertyStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("DefaultPropertyStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DefaultPropertyStyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private ElementStyle _ReadOnlyPropertyStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets style for property node when in read-only state.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Gets or sets style for property node when in read-only state.")]
|
||||
public ElementStyle ReadOnlyPropertyStyle
|
||||
{
|
||||
get { return _ReadOnlyPropertyStyle; }
|
||||
set
|
||||
{
|
||||
if (_ReadOnlyPropertyStyle != value)
|
||||
{
|
||||
if (_ReadOnlyPropertyStyle != null)
|
||||
_ReadOnlyPropertyStyle.StyleChanged -= this.ReadOnlyPropertyStyleChanged;
|
||||
if (value != null)
|
||||
value.StyleChanged += ReadOnlyPropertyStyleChanged;
|
||||
_ReadOnlyPropertyStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ReadOnlyPropertyStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ReadOnlyPropertyStyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private ElementStyle _ValueChangedPropertyStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets style for property node when in read-only state.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Gets or sets style for property node when in read-only state.")]
|
||||
public ElementStyle ValueChangedPropertyStyle
|
||||
{
|
||||
get { return _ValueChangedPropertyStyle; }
|
||||
set
|
||||
{
|
||||
if (_ValueChangedPropertyStyle != value)
|
||||
{
|
||||
if (_ValueChangedPropertyStyle != null)
|
||||
_ValueChangedPropertyStyle.StyleChanged -= this.ValueChangedPropertyStyleChanged;
|
||||
if (value != null)
|
||||
value.StyleChanged += ValueChangedPropertyStyleChanged;
|
||||
_ValueChangedPropertyStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ValueChangedPropertyStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ValueChangedPropertyStyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private ElementStyle _DefaultEditCellStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets style for property node edit cell when displaying unchanged property value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Indicates style for property node edit cell when displaying unchanged property value.")]
|
||||
public ElementStyle DefaultEditCellStyle
|
||||
{
|
||||
get { return _DefaultEditCellStyle; }
|
||||
set
|
||||
{
|
||||
if (_DefaultEditCellStyle != value)
|
||||
{
|
||||
if (_DefaultEditCellStyle != null)
|
||||
_DefaultEditCellStyle.StyleChanged -= this.DefaultEditCellStyleChanged;
|
||||
if (value != null)
|
||||
value.StyleChanged += ValueChangedPropertyStyleChanged;
|
||||
_DefaultEditCellStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("DefaultEditCellStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DefaultEditCellStyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private ElementStyle _CategoryStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets style for property node when in read-only state.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Gets or sets style for property node when in read-only state.")]
|
||||
public ElementStyle CategoryStyle
|
||||
{
|
||||
get { return _CategoryStyle; }
|
||||
set
|
||||
{
|
||||
if (_CategoryStyle != value)
|
||||
{
|
||||
if (_CategoryStyle != null)
|
||||
_CategoryStyle.StyleChanged -= this.CategoryStyleChanged;
|
||||
if (value != null)
|
||||
value.StyleChanged += CategoryStyleChanged;
|
||||
_CategoryStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("CategoryStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CategoryStyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private Image _PropertyValueErrorImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image that is displayed in property name cell when property value has failed the validation.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Description("Indicates image that is displayed in property name cell when property value has failed the validation.")]
|
||||
public Image PropertyValueErrorImage
|
||||
{
|
||||
get { return _PropertyValueErrorImage; }
|
||||
set
|
||||
{
|
||||
if (_PropertyValueErrorImage == value) return;
|
||||
_PropertyValueErrorImage = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("PropertyValueErrorImage"));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
private void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,130 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the class that stores text used by property grid control for localization purposes.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
|
||||
public class AdvPropertyGridLocalization : INotifyPropertyChanged
|
||||
{
|
||||
#region Internal Implementation
|
||||
private string _CategorizeToolbarTooltip = "Categorized";
|
||||
/// <summary>
|
||||
/// Gets or sets tooltip used by Categorized toolbar button.
|
||||
/// </summary>
|
||||
[DefaultValue("Categorized"), Description("Tooltip used by Categorize toolbar button"), Localizable(true)]
|
||||
public string CategorizeToolbarTooltip
|
||||
{
|
||||
get { return _CategorizeToolbarTooltip; }
|
||||
set
|
||||
{
|
||||
if (value != _CategorizeToolbarTooltip)
|
||||
{
|
||||
string oldValue = _CategorizeToolbarTooltip;
|
||||
_CategorizeToolbarTooltip = value;
|
||||
OnCategorizeToolbarTooltipChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnCategorizeToolbarTooltipChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("CategorizeToolbarTooltip"));
|
||||
}
|
||||
|
||||
private string _AlphabeticalToolbarTooltip = "Alphabetical";
|
||||
/// <summary>
|
||||
/// Gets or sets tooltip used by Alphabetical toolbar button.
|
||||
/// </summary>
|
||||
[DefaultValue("Alphabetical"), Description("Tooltip used by Alphabetical toolbar button"), Localizable(true)]
|
||||
public string AlphabeticalToolbarTooltip
|
||||
{
|
||||
get { return _AlphabeticalToolbarTooltip; }
|
||||
set
|
||||
{
|
||||
if (value != _AlphabeticalToolbarTooltip)
|
||||
{
|
||||
string oldValue = _AlphabeticalToolbarTooltip;
|
||||
_AlphabeticalToolbarTooltip = value;
|
||||
OnAplhabeticalToolbarTooltipChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnAplhabeticalToolbarTooltipChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("AlphabeticalToolbarTooltip"));
|
||||
}
|
||||
|
||||
private string _ErrorSettingPropertyValueTooltip = "Error setting the value. ";
|
||||
/// <summary>
|
||||
/// Gets or sets the tooltip text used in tooltip when error occurred during property value setting.
|
||||
/// </summary>
|
||||
[DefaultValue("Error setting the value. "), Description(""), Localizable(true)]
|
||||
public string ErrorSettingPropertyValueTooltip
|
||||
{
|
||||
get { return _ErrorSettingPropertyValueTooltip; }
|
||||
set
|
||||
{
|
||||
if (value != _ErrorSettingPropertyValueTooltip)
|
||||
{
|
||||
string oldValue = _ErrorSettingPropertyValueTooltip;
|
||||
_ErrorSettingPropertyValueTooltip = value;
|
||||
OnErrorSettingPropertyValueTooltipChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnErrorSettingPropertyValueTooltipChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ErrorSettingPropertyValueTooltip"));
|
||||
|
||||
}
|
||||
|
||||
private string _SearchBoxWatermarkText = "Quick Search";
|
||||
/// <summary>
|
||||
/// Gets or sets the watermark text displayed in search text-box.
|
||||
/// </summary>
|
||||
[DefaultValue("Quick Search"), Localizable(true), Description("Indicates watermark text displayed in search text-box.")]
|
||||
public string SearchBoxWatermarkText
|
||||
{
|
||||
get { return _SearchBoxWatermarkText; }
|
||||
set
|
||||
{
|
||||
if (value != _SearchBoxWatermarkText)
|
||||
{
|
||||
string oldValue = _SearchBoxWatermarkText;
|
||||
_SearchBoxWatermarkText = value;
|
||||
OnSearchBoxWatermarkTextChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchBoxWatermarkTextChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("SearchBoxWatermarkText"));
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null) handler(this, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when property defined by AdvPropertyGridLocalization class has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,16 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the property category in AdvPropertyGrid.
|
||||
/// </summary>
|
||||
public class PropertyCategoryNode : DevComponents.AdvTree.Node
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,77 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.AdvTree;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents check-box style property node in AdvPropertyGrid.
|
||||
/// </summary>
|
||||
public class PropertyCheckBoxNode : PropertyNode
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyNode class.
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
public PropertyCheckBoxNode(PropertyDescriptor property):base(property)
|
||||
{
|
||||
}
|
||||
|
||||
internal override void OnLoaded()
|
||||
{
|
||||
base.OnLoaded();
|
||||
Cell cell = this.EditCell;
|
||||
cell.CheckBoxStyle = eCheckBoxStyle.CheckBox;
|
||||
cell.CheckBoxAlignment = eCellPartAlignment.NearCenter;
|
||||
cell.CheckBoxVisible = true;
|
||||
}
|
||||
|
||||
protected override void UpdateDisplayedValue(object propertyValue, bool refreshSubProperties)
|
||||
{
|
||||
base.UpdateDisplayedValue(propertyValue, refreshSubProperties);
|
||||
if (propertyValue is bool)
|
||||
{
|
||||
this.EditCell.Checked = (bool)propertyValue;
|
||||
}
|
||||
else
|
||||
this.EditCell.Checked = false;
|
||||
}
|
||||
|
||||
public override void EnterEditorMode(eTreeAction action, bool focusEditor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBeforeCellCheck(Cell cell, AdvTreeCellBeforeCheckEventArgs e)
|
||||
{
|
||||
if (this.IsReadOnly && e.Action != eTreeAction.Code)
|
||||
e.Cancel = true;
|
||||
else
|
||||
{
|
||||
if (e.Action != eTreeAction.Code)
|
||||
{
|
||||
bool newValue = (e.NewCheckState == System.Windows.Forms.CheckState.Checked);
|
||||
e.Cancel = !ApplyValue(newValue, null);
|
||||
}
|
||||
}
|
||||
base.OnBeforeCellCheck(cell, e);
|
||||
}
|
||||
|
||||
protected internal override void InvokeNodeClick(object sender, EventArgs e)
|
||||
{
|
||||
base.InvokeNodeClick(sender, e);
|
||||
if (e is TreeNodeMouseEventArgs)
|
||||
{
|
||||
Cell editCell = EditCell;
|
||||
TreeNodeMouseEventArgs me = (TreeNodeMouseEventArgs)e;
|
||||
if (editCell.Bounds.Contains(me.X, me.Y) && !editCell.CheckBoxBounds.Contains(me.X, me.Y))
|
||||
editCell.SetChecked(!editCell.Checked, eTreeAction.Mouse);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,225 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.Editors;
|
||||
using DevComponents.Editors.DateTimeAdv;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a attribute which applies an date-time editor to a property when used with AdvPropertyGrid control. Applies to DateTime property types only.
|
||||
/// </summary>
|
||||
public class PropertyDateTimeEditor : PropertyValueEditor
|
||||
{
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Gets or sets pre-defined format for date-time input.
|
||||
/// </summary>
|
||||
public eDateTimePickerFormat Format = eDateTimePickerFormat.Short;
|
||||
/// <summary>
|
||||
/// Gets or sets custom format for date-time input.
|
||||
/// </summary>
|
||||
public string CustomFormat = "";
|
||||
/// <summary>
|
||||
/// Gets or sets whether empty null/nothing state of the control is allowed. Default value is false.
|
||||
/// </summary>
|
||||
public bool AllowEmptyState = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether drop-down button that shows calendar is visible. Default value is true.
|
||||
/// </summary>
|
||||
public bool ShowDropDownButton = true;
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum date that control accepts.
|
||||
/// </summary>
|
||||
public DateTime MinDate = DateTimeGroup.MinDateTime;
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum date that control accepts.
|
||||
/// </summary>
|
||||
public DateTime MaxDate = DateTimeGroup.MaxDateTime;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
public PropertyDateTimeEditor(eDateTimePickerFormat format)
|
||||
{
|
||||
Format = format;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minDate"></param>
|
||||
/// <param name="maxDate"></param>
|
||||
public PropertyDateTimeEditor(DateTime minDate, DateTime maxDate)
|
||||
{
|
||||
MinDate = minDate;
|
||||
MaxDate = maxDate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="minDate"></param>
|
||||
/// <param name="maxDate"></param>
|
||||
public PropertyDateTimeEditor(eDateTimePickerFormat format, DateTime minDate, DateTime maxDate)
|
||||
{
|
||||
Format = format;
|
||||
MinDate = minDate;
|
||||
MaxDate = maxDate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="customFormat"></param>
|
||||
/// <param name="allowEmptyState"></param>
|
||||
/// <param name="showDropDownButton"></param>
|
||||
/// <param name="minDate"></param>
|
||||
/// <param name="maxDate"></param>
|
||||
public PropertyDateTimeEditor(eDateTimePickerFormat format, string customFormat, bool allowEmptyState, bool showDropDownButton, DateTime minDate, DateTime maxDate)
|
||||
{
|
||||
Format = format;
|
||||
CustomFormat = customFormat;
|
||||
AllowEmptyState = allowEmptyState;
|
||||
ShowDropDownButton = showDropDownButton;
|
||||
MinDate = minDate;
|
||||
MaxDate = maxDate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="allowEmptyState"></param>
|
||||
public PropertyDateTimeEditor(eDateTimePickerFormat format, bool allowEmptyState)
|
||||
{
|
||||
Format = format;
|
||||
AllowEmptyState = allowEmptyState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="customFormat"></param>
|
||||
public PropertyDateTimeEditor(string customFormat)
|
||||
{
|
||||
CustomFormat = customFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
/// <param name="customFormat"></param>
|
||||
/// <param name="allowEmptyState"></param>
|
||||
public PropertyDateTimeEditor(string customFormat, bool allowEmptyState)
|
||||
{
|
||||
CustomFormat = customFormat;
|
||||
AllowEmptyState = allowEmptyState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDateTimeEditor class.
|
||||
/// </summary>
|
||||
public PropertyDateTimeEditor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override IPropertyValueEditor CreateEditor(System.ComponentModel.PropertyDescriptor propertyDescriptor, object targetObject)
|
||||
{
|
||||
if (propertyDescriptor.PropertyType != typeof(DateTime) && propertyDescriptor.PropertyType != typeof(DateTime?))
|
||||
throw new InvalidOperationException("PropertyDateTimeEditor works only with DateTime type properties");
|
||||
|
||||
DateTimeValueEditor editor = new DateTimeValueEditor();
|
||||
editor.AutoBorderSize = 1;
|
||||
|
||||
if (!string.IsNullOrEmpty(CustomFormat))
|
||||
{
|
||||
editor.Format = eDateTimePickerFormat.Custom;
|
||||
editor.CustomFormat = CustomFormat;
|
||||
}
|
||||
else
|
||||
editor.Format = Format;
|
||||
editor.AllowEmptyState = AllowEmptyState;
|
||||
editor.BackgroundStyle.Class = "";
|
||||
editor.BackgroundStyle.BackColor = Color.White;
|
||||
editor.MinDate = this.MinDate;
|
||||
editor.MaxDate = this.MaxDate;
|
||||
|
||||
if (AllowEmptyState)
|
||||
{
|
||||
editor.ButtonClear.Visible = true;
|
||||
editor.ButtonDropDown.DisplayPosition = 1;
|
||||
}
|
||||
editor.Height = Dpi.Height14;
|
||||
editor.ButtonDropDown.Visible = ShowDropDownButton;
|
||||
|
||||
return editor;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DateTimeValueEditor
|
||||
private class DateTimeValueEditor : DateTimeInput, IPropertyValueEditor
|
||||
{
|
||||
#region IPropertyValueEditor Members
|
||||
|
||||
public System.Drawing.Font EditorFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEditorFocused
|
||||
{
|
||||
get { return this.Focused; }
|
||||
}
|
||||
|
||||
public void FocusEditor()
|
||||
{
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
public object EditValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ValueObject;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.ValueObject = null;
|
||||
else if (this.Value != (DateTime)value)
|
||||
this.Value = (DateTime)value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged(EventArgs e)
|
||||
{
|
||||
OnEditValueChanged(e);
|
||||
base.OnValueChanged(e);
|
||||
}
|
||||
|
||||
private void OnEditValueChanged(EventArgs e)
|
||||
{
|
||||
EventHandler ev = EditValueChanged;
|
||||
if (ev != null) ev(this, e);
|
||||
}
|
||||
|
||||
public event EventHandler EditValueChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
184
PROMS/DotNetBar Source Code/PropertyGrid/PropertyDoubleEditor.cs
Normal file
184
PROMS/DotNetBar Source Code/PropertyGrid/PropertyDoubleEditor.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.Editors;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a attribute which applies an double type numeric editor to a property when used with AdvPropertyGrid control. Applies to double property types only.
|
||||
/// </summary>
|
||||
public class PropertyDoubleEditor : PropertyValueEditor
|
||||
{
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Gets or sets whether up/down button is shown.
|
||||
/// </summary>
|
||||
public bool ShowUpDownButton = true;
|
||||
/// <summary>
|
||||
/// Gets or sets the display format for the control when control does not have input focus.
|
||||
/// </summary>
|
||||
public string DisplayFormat = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value that can be entered.
|
||||
/// </summary>
|
||||
public double MinValue = double.MinValue;
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum value that can be entered.
|
||||
/// </summary>
|
||||
public double MaxValue = double.MaxValue;
|
||||
/// <summary>
|
||||
/// Gets or sets whether empty state i.e. null/nothing value is allowed when editor is used with nullable types.
|
||||
/// </summary>
|
||||
public bool AllowEmptyState = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDoubleEditor class.
|
||||
/// </summary>
|
||||
public PropertyDoubleEditor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDoubleEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
public PropertyDoubleEditor(bool showUpDownButton)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDoubleEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public PropertyDoubleEditor(double minValue, double maxValue)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDoubleEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public PropertyDoubleEditor(bool showUpDownButton, double minValue, double maxValue)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDoubleEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
/// <param name="displayFormat"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public PropertyDoubleEditor(bool showUpDownButton, string displayFormat, double minValue, double maxValue)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
DisplayFormat = displayFormat;
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyDoubleEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
/// <param name="displayFormat"></param>
|
||||
public PropertyDoubleEditor(bool showUpDownButton, string displayFormat)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
DisplayFormat = displayFormat;
|
||||
}
|
||||
|
||||
public override IPropertyValueEditor CreateEditor(System.ComponentModel.PropertyDescriptor propertyDescriptor, object targetObject)
|
||||
{
|
||||
if (propertyDescriptor.PropertyType != typeof(double) && propertyDescriptor.PropertyType != typeof(double?))
|
||||
throw new InvalidOperationException("PropertyDateTimeEditor works only with double type properties");
|
||||
|
||||
DoubleValueEditor editor = new DoubleValueEditor();
|
||||
editor.AutoBorderSize = 1;
|
||||
|
||||
if (!string.IsNullOrEmpty(DisplayFormat))
|
||||
{
|
||||
editor.DisplayFormat = DisplayFormat;
|
||||
}
|
||||
editor.ShowUpDown = ShowUpDownButton;
|
||||
editor.Height = Dpi.Height14;
|
||||
editor.BackgroundStyle.Class = "";
|
||||
editor.BackgroundStyle.BackColor = Color.White;
|
||||
editor.MinValue = MinValue;
|
||||
editor.MaxValue = MaxValue;
|
||||
editor.AllowEmptyState = AllowEmptyState;
|
||||
return editor;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private class DoubleValueEditor : DoubleInput, IPropertyValueEditor
|
||||
{
|
||||
#region IPropertyValueEditor Members
|
||||
|
||||
public System.Drawing.Font EditorFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEditorFocused
|
||||
{
|
||||
get { return this.Focused; }
|
||||
}
|
||||
|
||||
public void FocusEditor()
|
||||
{
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
public object EditValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ValueObject;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.ValueObject = null;
|
||||
else
|
||||
this.Value = (double)value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged(EventArgs e)
|
||||
{
|
||||
OnEditValueChanged(e);
|
||||
base.OnValueChanged(e);
|
||||
}
|
||||
|
||||
private void OnEditValueChanged(EventArgs e)
|
||||
{
|
||||
EventHandler ev = EditValueChanged;
|
||||
if (ev != null) ev(this, e);
|
||||
}
|
||||
|
||||
public event EventHandler EditValueChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.Editors;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a attribute which applies an integer type numeric editor to a property when used with AdvPropertyGrid control. Applies to int property types only.
|
||||
/// </summary>
|
||||
public class PropertyIntegerEditor : PropertyValueEditor
|
||||
{
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Gets or sets whether up/down button is shown.
|
||||
/// </summary>
|
||||
public bool ShowUpDownButton = true;
|
||||
/// <summary>
|
||||
/// Gets or sets the display format for the control when control does not have input focus.
|
||||
/// </summary>
|
||||
public string DisplayFormat = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value that can be entered.
|
||||
/// </summary>
|
||||
public int MinValue = int.MinValue;
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum value that can be entered.
|
||||
/// </summary>
|
||||
public int MaxValue = int.MaxValue;
|
||||
/// <summary>
|
||||
/// Gets or sets whether empty state i.e. null/nothing value is allowed when editor is used with nullable types.
|
||||
/// </summary>
|
||||
public bool AllowEmptyState = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyIntegerEditor class.
|
||||
/// </summary>
|
||||
public PropertyIntegerEditor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyIntegerEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
public PropertyIntegerEditor(bool showUpDownButton)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyIntegerEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public PropertyIntegerEditor(int minValue, int maxValue)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyIntegerEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public PropertyIntegerEditor(bool showUpDownButton, int minValue, int maxValue)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyIntegerEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
/// <param name="displayFormat"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public PropertyIntegerEditor(bool showUpDownButton, string displayFormat, int minValue, int maxValue)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
DisplayFormat = displayFormat;
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyIntegerEditor class.
|
||||
/// </summary>
|
||||
/// <param name="showUpDownButton"></param>
|
||||
/// <param name="displayFormat"></param>
|
||||
public PropertyIntegerEditor(bool showUpDownButton, string displayFormat)
|
||||
{
|
||||
ShowUpDownButton = showUpDownButton;
|
||||
DisplayFormat = displayFormat;
|
||||
}
|
||||
|
||||
public override IPropertyValueEditor CreateEditor(System.ComponentModel.PropertyDescriptor propertyDescriptor, object targetObject)
|
||||
{
|
||||
if (propertyDescriptor.PropertyType != typeof(int) && propertyDescriptor.PropertyType != typeof(int?) &&
|
||||
propertyDescriptor.PropertyType != typeof(byte) && propertyDescriptor.PropertyType != typeof(byte?))
|
||||
throw new InvalidOperationException("PropertyIntegerEditor works only with int or byte type properties");
|
||||
|
||||
IntegerValueEditor editor = new IntegerValueEditor();
|
||||
editor.AutoBorderSize = 1;
|
||||
|
||||
if (!string.IsNullOrEmpty(DisplayFormat))
|
||||
{
|
||||
editor.DisplayFormat = DisplayFormat;
|
||||
}
|
||||
editor.ShowUpDown = ShowUpDownButton;
|
||||
editor.Height = Dpi.Height14;
|
||||
editor.BackgroundStyle.Class = "";
|
||||
editor.BackgroundStyle.BackColor = Color.White;
|
||||
editor.AllowEmptyState = this.AllowEmptyState;
|
||||
if (propertyDescriptor.PropertyType == typeof(byte) || propertyDescriptor.PropertyType == typeof(byte?))
|
||||
{
|
||||
editor.MinValue = Math.Max(byte.MinValue, MinValue);
|
||||
editor.MaxValue = Math.Min(byte.MaxValue, MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.MinValue = MinValue;
|
||||
editor.MaxValue = MaxValue;
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private class IntegerValueEditor : IntegerInput, IPropertyValueEditor
|
||||
{
|
||||
#region IPropertyValueEditor Members
|
||||
|
||||
public System.Drawing.Font EditorFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEditorFocused
|
||||
{
|
||||
get { return this.Focused; }
|
||||
}
|
||||
|
||||
public void FocusEditor()
|
||||
{
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
public object EditValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ValueObject;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.ValueObject = null;
|
||||
else
|
||||
this.Value = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged(EventArgs e)
|
||||
{
|
||||
OnEditValueChanged(e);
|
||||
base.OnValueChanged(e);
|
||||
}
|
||||
|
||||
private void OnEditValueChanged(EventArgs e)
|
||||
{
|
||||
EventHandler ev = EditValueChanged;
|
||||
if (ev != null) ev(this, e);
|
||||
}
|
||||
|
||||
public event EventHandler EditValueChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines multiple choice, option or check-boxes, in-line AdvPropertyGrid property value editor.
|
||||
/// </summary>
|
||||
public class PropertyMultiChoiceEditor : PropertyValueEditor
|
||||
{
|
||||
private KeyValuePair<object, string>[] _Items = null;
|
||||
private Color _TextColor = Color.Black;
|
||||
private bool _MultiSelect = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
public PropertyMultiChoiceEditor()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
public PropertyMultiChoiceEditor(KeyValuePair<object, string>[] items)
|
||||
{
|
||||
_Items = items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertyMultiChoiceEditor(KeyValuePair<object, string>[] items, Color textColor)
|
||||
{
|
||||
_Items = items;
|
||||
_TextColor = textColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertyMultiChoiceEditor(KeyValuePair<object, string>[] items, Color textColor, bool multiSelect)
|
||||
{
|
||||
_Items = items;
|
||||
_TextColor = textColor;
|
||||
_MultiSelect = multiSelect;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertyMultiChoiceEditor(KeyValuePair<object, string>[] items, bool multiSelect)
|
||||
{
|
||||
_Items = items;
|
||||
_MultiSelect = multiSelect;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="commaSeparatedItemList"></param>
|
||||
public PropertyMultiChoiceEditor(string commaSeparetedItemList)
|
||||
: this(commaSeparetedItemList, Color.Black)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="commaSeparatedItemList"></param>
|
||||
public PropertyMultiChoiceEditor(string commaSeparetedItemList, bool multiSelect)
|
||||
: this(commaSeparetedItemList, Color.Black, multiSelect)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertyMultiChoiceEditor(string commaSeparatedItemList, Color textColor) :
|
||||
this(commaSeparatedItemList, textColor, false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertyMultiChoiceEditor(string commaSeparatedItemList, Color textColor, bool multiSelect)
|
||||
{
|
||||
string[] items = commaSeparatedItemList.Split(',');
|
||||
_Items = new KeyValuePair<object, string>[items.Length];
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
_Items[i] = new KeyValuePair<object, string>(items[i], items[i]);
|
||||
}
|
||||
|
||||
_TextColor = textColor;
|
||||
_MultiSelect = multiSelect;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="keys"></param>
|
||||
public PropertyMultiChoiceEditor(string[] values, object[] keys)
|
||||
: this(values, keys, Color.Black)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceEditor class.
|
||||
/// </summary>
|
||||
/// <param name="displayValues"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertyMultiChoiceEditor(string[] displayValues, object[] keys, Color textColor)
|
||||
{
|
||||
if (displayValues.Length != keys.Length)
|
||||
throw new ArgumentException("values.Length must be same as keys.Length");
|
||||
if (displayValues.Length == 0)
|
||||
throw new ArgumentException("values.Length must be greater than 0");
|
||||
|
||||
_Items = new KeyValuePair<object, string>[displayValues.Length];
|
||||
for (int i = 0; i < displayValues.Length; i++)
|
||||
{
|
||||
_Items[i] = new KeyValuePair<object, string>(keys[i], displayValues[i]);
|
||||
}
|
||||
|
||||
_TextColor = textColor;
|
||||
}
|
||||
|
||||
|
||||
public override IPropertyValueEditor CreateEditor(System.ComponentModel.PropertyDescriptor propertyDescriptor, object targetObject)
|
||||
{
|
||||
KeyValuePair<object, string>[] items = null;
|
||||
bool isMultiSelect = _MultiSelect;
|
||||
string selectedValue = string.Empty;
|
||||
if (_Items == null)
|
||||
{
|
||||
if (propertyDescriptor.PropertyType.IsEnum)
|
||||
{
|
||||
string[] enumNames = Enum.GetNames(propertyDescriptor.PropertyType);
|
||||
Array enumValue = Enum.GetValues(propertyDescriptor.PropertyType);
|
||||
items = new KeyValuePair<object, string>[enumNames.Length];
|
||||
for (int i = 0; i < enumValue.Length; i++)
|
||||
{
|
||||
items[i] = new KeyValuePair<object, string>(enumValue.GetValue(i), enumNames[i]);
|
||||
}
|
||||
FlagsAttribute flags = propertyDescriptor.Attributes[typeof(FlagsAttribute)] as FlagsAttribute;
|
||||
if (flags != null) isMultiSelect = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new KeyValuePair<object, string>[1];
|
||||
items[0] = new KeyValuePair<object, string>(null, "Values not provided");
|
||||
}
|
||||
}
|
||||
else
|
||||
items = _Items;
|
||||
|
||||
if (targetObject != null)
|
||||
{
|
||||
if (propertyDescriptor.PropertyType.IsEnum)
|
||||
selectedValue = (string)Enum.GetName(propertyDescriptor.PropertyType, propertyDescriptor.GetValue(targetObject));
|
||||
else
|
||||
selectedValue = (string)propertyDescriptor.GetValue(targetObject);
|
||||
}
|
||||
|
||||
|
||||
PropertyMultiChoiceItemEditor editor = new PropertyMultiChoiceItemEditor(items, isMultiSelect, _TextColor, selectedValue);
|
||||
return editor;
|
||||
}
|
||||
|
||||
private class PropertyMultiChoiceItemEditor : ItemContainer, IPropertyValueEditor
|
||||
{
|
||||
private KeyValuePair<object, string>[] _ItemsDefinition = null;
|
||||
private bool _IsMultiChoice = false;
|
||||
private Color _TextColor = Color.Black;
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyMultiChoiceItemEditor class.
|
||||
/// </summary>
|
||||
/// <param name="itemsDefinition"></param>
|
||||
/// <param name="isMultiChoice"></param>
|
||||
public PropertyMultiChoiceItemEditor(KeyValuePair<object, string>[] itemsDefinition, bool isMultiChoice, Color textColor, string initialSelection)
|
||||
{
|
||||
_ItemsDefinition = itemsDefinition;
|
||||
_IsMultiChoice = isMultiChoice;
|
||||
_TextColor = textColor;
|
||||
CreateItems(initialSelection);
|
||||
}
|
||||
|
||||
private void CreateItems(string initialSelection)
|
||||
{
|
||||
this.LayoutOrientation = eOrientation.Vertical;
|
||||
this.SubItems.Clear();
|
||||
this.ItemSpacing = 0;
|
||||
|
||||
foreach (KeyValuePair<object, string> definition in _ItemsDefinition)
|
||||
{
|
||||
CheckBoxItem item = new CheckBoxItem();
|
||||
item.Text = definition.Value;
|
||||
if (item.Text == initialSelection) item.Checked = true;
|
||||
item.Tag = definition.Key;
|
||||
item.TextColor = _TextColor;
|
||||
if (_IsMultiChoice)
|
||||
item.CheckBoxStyle = eCheckBoxStyle.CheckBox;
|
||||
else
|
||||
item.CheckBoxStyle = eCheckBoxStyle.RadioButton;
|
||||
item.CheckedChanged += new CheckBoxChangeEventHandler(ItemCheckedChanged);
|
||||
this.SubItems.Add(item);
|
||||
}
|
||||
this.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
}
|
||||
|
||||
private void ItemCheckedChanged(object sender, CheckBoxChangeEventArgs e)
|
||||
{
|
||||
if (_SettingEditValue) return;
|
||||
OnEditValueChanged(EventArgs.Empty);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IPropertyValueEditor Members
|
||||
|
||||
public System.Drawing.Font EditorFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEditorFocused
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public void FocusEditor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool _SettingEditValue = false;
|
||||
private char StringValueSeparator = ',';
|
||||
public object EditValue
|
||||
{
|
||||
get
|
||||
{
|
||||
object value = null;
|
||||
foreach (CheckBoxItem item in this.SubItems)
|
||||
{
|
||||
if (item.Checked)
|
||||
{
|
||||
if (_IsMultiChoice)
|
||||
{
|
||||
if (value == null)
|
||||
value = item.Tag;
|
||||
else if (value is string)
|
||||
value = (string)value + StringValueSeparator + (string)item.Tag;
|
||||
else if (value is uint)
|
||||
value = (uint)value | (uint)item.Tag;
|
||||
else if (value is int)
|
||||
value = (int)value | (int)item.Tag;
|
||||
else if (value is long)
|
||||
value = (long)value | (long)item.Tag;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = item.Tag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_SettingEditValue = true;
|
||||
List<string> valueList = null;
|
||||
if (_IsMultiChoice)
|
||||
{
|
||||
if (value is string)
|
||||
valueList = new List<string>(value.ToString().Split(StringValueSeparator));
|
||||
else if (value is string[])
|
||||
valueList = new List<string>((string[])value);
|
||||
}
|
||||
foreach (CheckBoxItem item in this.SubItems)
|
||||
{
|
||||
if (_IsMultiChoice)
|
||||
{
|
||||
if (valueList != null && valueList.Contains(item.Tag.ToString()))
|
||||
item.Checked = true;
|
||||
else if (item.Checked)
|
||||
item.Checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value == item.Tag || value!=null && value.Equals(item.Tag))
|
||||
{
|
||||
item.Checked = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_SettingEditValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEditValueChanged(EventArgs e)
|
||||
{
|
||||
EventHandler ev = EditValueChanged;
|
||||
if (ev != null) ev(this, e);
|
||||
}
|
||||
public event EventHandler EditValueChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
2502
PROMS/DotNetBar Source Code/PropertyGrid/PropertyNode.cs
Normal file
2502
PROMS/DotNetBar Source Code/PropertyGrid/PropertyNode.cs
Normal file
File diff suppressed because it is too large
Load Diff
145
PROMS/DotNetBar Source Code/PropertyGrid/PropertyNodeColor.cs
Normal file
145
PROMS/DotNetBar Source Code/PropertyGrid/PropertyNodeColor.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Drawing2D;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines Advanced Property Grid Node for Color type.
|
||||
/// </summary>
|
||||
public class PropertyNodeColor : PropertyNode
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyNode class.
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
public PropertyNodeColor(PropertyDescriptor property) : base(property)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
private Image _SwatchImage = null;
|
||||
protected override void UpdateDisplayedValue(object propertyValue, bool refreshSubProperties)
|
||||
{
|
||||
base.UpdateDisplayedValue(propertyValue, refreshSubProperties);
|
||||
if (IsDisposing || IsDisposed) return;
|
||||
|
||||
Cell cell = this.EditCell;
|
||||
if (propertyValue is Color)
|
||||
{
|
||||
Color color = (Color)propertyValue;
|
||||
if (_SwatchImage == null || !((Color)_SwatchImage.Tag).Equals(color))
|
||||
{
|
||||
DisposeSwatchImage();
|
||||
_SwatchImage = CreateSwatchImage(color);
|
||||
cell.Images.Image = _SwatchImage;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisposeSwatchImage();
|
||||
cell.Images.Image = null;
|
||||
}
|
||||
}
|
||||
protected override bool IsTypeEditorPaintValueSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private Image CreateSwatchImage(Color color)
|
||||
{
|
||||
Rectangle r = new Rectangle(0, 0, 20, 13);
|
||||
Bitmap image = new Bitmap(r.Width, r.Height, PixelFormat.Format32bppArgb);
|
||||
using (Graphics g = Graphics.FromImage(image))
|
||||
{
|
||||
DisplayHelp.DrawRectangle(g, SwatchBorderColor, r);
|
||||
r.Inflate(-1, -1);
|
||||
|
||||
if (color == Color.Empty)
|
||||
{
|
||||
using (HatchBrush brush = new HatchBrush(HatchStyle.BackwardDiagonal, SwatchHatchForeColor, SwatchBackColor))
|
||||
g.FillRectangle(brush, r);
|
||||
}
|
||||
else if (color == Color.Transparent || color.A < 255)
|
||||
{
|
||||
using (HatchBrush brush = new HatchBrush(HatchStyle.LargeCheckerBoard, SwatchHatchForeColor, SwatchBackColor))
|
||||
g.FillRectangle(brush, r);
|
||||
|
||||
if (color != Color.Transparent)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
g.FillRectangle(brush, r);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
g.FillRectangle(brush, r);
|
||||
}
|
||||
|
||||
}
|
||||
image.Tag = color;
|
||||
return image;
|
||||
}
|
||||
|
||||
private Color _SwatchHatchForeColor = ColorScheme.GetColor(0xC5C5C5);
|
||||
private Color SwatchHatchForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SwatchHatchForeColor;
|
||||
}
|
||||
}
|
||||
|
||||
private Color _SwatchBorderColor = Color.Black;
|
||||
private Color SwatchBorderColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SwatchBorderColor;
|
||||
}
|
||||
}
|
||||
private Color _SwatchBackColor = Color.White;
|
||||
private Color SwatchBackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SwatchBackColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeSwatchImage()
|
||||
{
|
||||
if (_SwatchImage != null)
|
||||
{
|
||||
_SwatchImage.Dispose();
|
||||
_SwatchImage = null;
|
||||
Cell cell = this.EditCell;
|
||||
if (cell != null)
|
||||
cell.Images.Image = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
DisposeSwatchImage();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,95 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.AdvTree;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
internal class PropertyNodeFactory
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyNodeFactory class.
|
||||
/// </summary>
|
||||
/// <param name="categoryStyle"></param>
|
||||
public PropertyNodeFactory(IPropertyElementStyleProvider styleProvider)
|
||||
{
|
||||
_StyleProvider = styleProvider;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public PropertyNode CreatePropertyNode(PropertyDescriptor item, object targetComponent, IPropertyGridLocalizer localizer, PropertySettingsCollection propertySettings, bool isMultiObject)
|
||||
{
|
||||
PropertySettings settings = propertySettings[item, item.Name];
|
||||
return CreatePropertyNode(item, targetComponent, localizer, settings, isMultiObject);
|
||||
}
|
||||
public PropertyNode CreatePropertyNode(PropertyDescriptor item, object targetComponent, IPropertyGridLocalizer localizer, PropertySettings settings, bool isMultiObject)
|
||||
{
|
||||
PropertyNode node = null;
|
||||
|
||||
if (item.PropertyType == typeof(Color) && (settings == null || settings.ValueEditor == null))
|
||||
node = new PropertyNodeColor(item);
|
||||
else if (item.PropertyType == typeof(bool) && (settings == null || settings.ValueEditor == null))
|
||||
node = new PropertyCheckBoxNode(item);
|
||||
else if (settings != null && settings.PropertyNodeType == ePropertyNodeType.RadioButtonList)
|
||||
node = new PropertyOptionListNode(item);
|
||||
else
|
||||
node = new PropertyNode(item);
|
||||
|
||||
node.IsMultiObject = isMultiObject;
|
||||
node.NodesIndent = _ChildPropertiesIndent;
|
||||
node.ImageAlignment = eCellPartAlignment.FarCenter;
|
||||
string name = localizer.GetPropertyName(item.Name);
|
||||
if (string.IsNullOrEmpty(name)) name = item.DisplayName;
|
||||
node.Text = name;
|
||||
node.TargetComponent = targetComponent;
|
||||
Cell cell = new Cell();
|
||||
cell.Selectable = false;
|
||||
cell.TextMarkupEnabled = false;
|
||||
node.Cells.Add(cell);
|
||||
|
||||
node.PropertySettings = settings;
|
||||
|
||||
return node;
|
||||
}
|
||||
public Node CreateCategoryNode(string category, IPropertyGridLocalizer localizer)
|
||||
{
|
||||
PropertyCategoryNode node = new PropertyCategoryNode();
|
||||
if (_StyleProvider != null)
|
||||
node.Style = _StyleProvider.CategoryStyle;
|
||||
string name = localizer.GetCategoryName(category);
|
||||
if (string.IsNullOrEmpty(name)) name = category;
|
||||
node.Text = name;
|
||||
node.Expanded = true;
|
||||
node.FullRowBackground = true;
|
||||
node.Selectable = true;
|
||||
node.CellNavigationEnabled = false;
|
||||
return node;
|
||||
}
|
||||
|
||||
private int _ChildPropertiesIndent = 9;
|
||||
public int ChildPropertiesIndent
|
||||
{
|
||||
get { return _ChildPropertiesIndent; }
|
||||
set
|
||||
{
|
||||
_ChildPropertiesIndent = value;
|
||||
}
|
||||
}
|
||||
|
||||
private IPropertyElementStyleProvider _StyleProvider;
|
||||
public IPropertyElementStyleProvider StyleProvider
|
||||
{
|
||||
get { return _StyleProvider; }
|
||||
set { _StyleProvider = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,99 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the option list property node for AdvPropertyGrid.
|
||||
/// </summary>
|
||||
public class PropertyOptionListNode : PropertyNode
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyNode class.
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
public PropertyOptionListNode(PropertyDescriptor property)
|
||||
: base(property)
|
||||
{
|
||||
}
|
||||
|
||||
internal override void OnLoaded()
|
||||
{
|
||||
base.OnLoaded();
|
||||
|
||||
Cell cell = this.EditCell;
|
||||
|
||||
ItemContainer container = new ItemContainer();
|
||||
container.LayoutOrientation = eOrientation.Vertical;
|
||||
|
||||
string[] optionsList = GetPopupListContent();
|
||||
foreach (string optionText in optionsList)
|
||||
{
|
||||
CheckBoxItem item = new CheckBoxItem();
|
||||
item.CheckBoxStyle = eCheckBoxStyle.RadioButton;
|
||||
item.Text = optionText;
|
||||
item.TextColor = Color.Black;
|
||||
item.VerticalPadding = 0;
|
||||
item.CheckSignSize = new Size(11, 11);
|
||||
item.CheckedChanging += ItemCheckedChanging;
|
||||
container.SubItems.Add(item);
|
||||
}
|
||||
container.Style = eDotNetBarStyle.Office2007;
|
||||
cell.HostedItem = container;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
BaseItem container = this.EditCell.HostedItem;
|
||||
if (container != null)
|
||||
{
|
||||
this.EditCell.HostedItem = null;
|
||||
foreach (BaseItem item in container.SubItems)
|
||||
{
|
||||
CheckBoxItem checkItem = item as CheckBoxItem;
|
||||
if (checkItem != null) checkItem.CheckedChanging -= ItemCheckedChanging;
|
||||
}
|
||||
container.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
void ItemCheckedChanging(object sender, CheckBoxChangeEventArgs e)
|
||||
{
|
||||
if (e.EventSource != eEventSource.Code)
|
||||
{
|
||||
Exception valueException = null;
|
||||
object value = GetValueFromString(((CheckBoxItem)sender).Text, out valueException);
|
||||
e.Cancel = !ApplyValue(value, valueException);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateDisplayedValue(object propertyValue, bool refreshSubProperties)
|
||||
{
|
||||
base.UpdateDisplayedValue(propertyValue, refreshSubProperties);
|
||||
string text = GetPropertyTextValue(propertyValue);
|
||||
Cell cell = this.EditCell;
|
||||
if (cell.HostedItem == null) return;
|
||||
foreach (BaseItem item in cell.HostedItem.SubItems)
|
||||
{
|
||||
CheckBoxItem checkItem = item as CheckBoxItem;
|
||||
if (checkItem != null)
|
||||
checkItem.Checked = checkItem.Text.Equals(text);
|
||||
}
|
||||
}
|
||||
|
||||
public override void EnterEditorMode(eTreeAction action, bool focusEditor)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
340
PROMS/DotNetBar Source Code/PropertyGrid/PropertyParser.cs
Normal file
340
PROMS/DotNetBar Source Code/PropertyGrid/PropertyParser.cs
Normal file
@@ -0,0 +1,340 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
internal class PropertyParser
|
||||
{
|
||||
private const string STR_Misc = "Misc.";
|
||||
|
||||
#region Constructors
|
||||
private object _SelectedObject = null;
|
||||
private object[] _SelectedObjects = null;
|
||||
private TypeConverter _Converter = null;
|
||||
private Attribute[] _AttributeFilter = null;
|
||||
private PropertyNodeFactory _PropertyNodeFactory = null;
|
||||
private List<string> _IgnoredProperties = null;
|
||||
private List<string> _IgnoredCategories = null;
|
||||
private IPropertyGridLocalizer _Localizer = null;
|
||||
private PropertySettingsCollection _PropertySettings = null;
|
||||
private ITypeDescriptorContext _TypeDescriptorContext = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyParser class.
|
||||
/// </summary>
|
||||
/// <param name="selectedObject"></param>
|
||||
public PropertyParser(object selectedObject,
|
||||
Attribute[] attributeFilter,
|
||||
PropertyNodeFactory nodeFactory,
|
||||
List<string> ignoredProperties,
|
||||
List<string> ignoredCategories,
|
||||
IPropertyGridLocalizer localizer,
|
||||
PropertySettingsCollection propertySettings)
|
||||
{
|
||||
_SelectedObject = selectedObject;
|
||||
_AttributeFilter = attributeFilter;
|
||||
_PropertyNodeFactory = nodeFactory;
|
||||
_IgnoredProperties = ignoredProperties;
|
||||
_IgnoredCategories = ignoredCategories;
|
||||
_Localizer = localizer;
|
||||
_PropertySettings = propertySettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyParser class.
|
||||
/// </summary>
|
||||
/// <param name="selectedObject"></param>
|
||||
public PropertyParser(
|
||||
ITypeDescriptorContext context,
|
||||
object selectedObject,
|
||||
Attribute[] attributeFilter,
|
||||
PropertyNodeFactory nodeFactory,
|
||||
List<string> ignoredProperties,
|
||||
List<string> ignoredCategories,
|
||||
IPropertyGridLocalizer localizer,
|
||||
PropertySettingsCollection propertySettings)
|
||||
{
|
||||
_TypeDescriptorContext = context;
|
||||
_SelectedObject = selectedObject;
|
||||
_AttributeFilter = attributeFilter;
|
||||
_PropertyNodeFactory = nodeFactory;
|
||||
_IgnoredProperties = ignoredProperties;
|
||||
_IgnoredCategories = ignoredCategories;
|
||||
_Localizer = localizer;
|
||||
_PropertySettings = propertySettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyParser class.
|
||||
/// </summary>
|
||||
/// <param name="selectedObject"></param>
|
||||
public PropertyParser(object[] selectedObjects,
|
||||
Attribute[] attributeFilter,
|
||||
PropertyNodeFactory nodeFactory,
|
||||
List<string> ignoredProperties,
|
||||
List<string> ignoredCategories,
|
||||
IPropertyGridLocalizer localizer,
|
||||
PropertySettingsCollection propertySettings)
|
||||
{
|
||||
_SelectedObjects = selectedObjects;
|
||||
_AttributeFilter = attributeFilter;
|
||||
_PropertyNodeFactory = nodeFactory;
|
||||
_IgnoredProperties = ignoredProperties;
|
||||
_IgnoredCategories = ignoredCategories;
|
||||
_Localizer = localizer;
|
||||
_PropertySettings = propertySettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyParser class.
|
||||
/// </summary>
|
||||
/// <param name="selectedObject"></param>
|
||||
public PropertyParser(
|
||||
ITypeDescriptorContext context,
|
||||
object[] selectedObjects,
|
||||
Attribute[] attributeFilter,
|
||||
PropertyNodeFactory nodeFactory,
|
||||
List<string> ignoredProperties,
|
||||
List<string> ignoredCategories,
|
||||
IPropertyGridLocalizer localizer,
|
||||
PropertySettingsCollection propertySettings)
|
||||
{
|
||||
_TypeDescriptorContext = context;
|
||||
_SelectedObjects = selectedObjects;
|
||||
_AttributeFilter = attributeFilter;
|
||||
_PropertyNodeFactory = nodeFactory;
|
||||
_IgnoredProperties = ignoredProperties;
|
||||
_IgnoredCategories = ignoredCategories;
|
||||
_Localizer = localizer;
|
||||
_PropertySettings = propertySettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
internal void Parse(NodeCollection nodeCollection, ePropertySort propertySort, SuperTooltip helpTooltip)
|
||||
{
|
||||
PropertyDescriptorCollection propertyCollection = GetProperties();
|
||||
bool hasIgnoredProperties = _IgnoredProperties.Count > 0;
|
||||
bool hasIgnoredCategories = _IgnoredCategories.Count > 0;
|
||||
|
||||
if (propertySort == ePropertySort.Categorized || propertySort == ePropertySort.CategorizedAlphabetical)
|
||||
{
|
||||
Dictionary<string, Node> table = new Dictionary<string, Node>();
|
||||
foreach (PropertyDescriptor item in propertyCollection)
|
||||
{
|
||||
if (item == null || hasIgnoredProperties && _IgnoredProperties.Contains(item.Name)) continue;
|
||||
|
||||
string category = GetCategory(item);
|
||||
PropertySettings settings = _PropertySettings[item, item.Name];
|
||||
if (settings != null && settings.Category != null)
|
||||
category = settings.Category;
|
||||
|
||||
if (hasIgnoredCategories && !string.IsNullOrEmpty(category) && _IgnoredCategories.Contains(category)) continue;
|
||||
|
||||
Node categoryNode = null;
|
||||
if (!table.TryGetValue(category, out categoryNode))
|
||||
{
|
||||
categoryNode = _PropertyNodeFactory.CreateCategoryNode(category, _Localizer);
|
||||
nodeCollection.Add(categoryNode);
|
||||
table.Add(category, categoryNode);
|
||||
}
|
||||
PropertyNode node = _PropertyNodeFactory.CreatePropertyNode(item, _SelectedObject ?? _SelectedObjects, _Localizer, settings, _SelectedObjects != null);
|
||||
categoryNode.Nodes.Add(node);
|
||||
node.OnLoaded();
|
||||
if (_HelpType == ePropertyGridHelpType.SuperTooltip && helpTooltip != null)
|
||||
node.SetHelpTooltip(helpTooltip);
|
||||
node.UpdateDisplayedValue();
|
||||
}
|
||||
|
||||
if (propertySort == ePropertySort.CategorizedAlphabetical)
|
||||
{
|
||||
foreach (Node item in table.Values)
|
||||
{
|
||||
item.Nodes.Sort();
|
||||
}
|
||||
|
||||
nodeCollection.Sort();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (PropertyDescriptor item in propertyCollection)
|
||||
{
|
||||
if (item == null || _IgnoredProperties.Contains(item.Name)) continue;
|
||||
|
||||
PropertyNode node = _PropertyNodeFactory.CreatePropertyNode(item, _SelectedObject ?? _SelectedObjects, _Localizer, _PropertySettings, _SelectedObjects != null);
|
||||
nodeCollection.Add(node);
|
||||
node.OnLoaded();
|
||||
if (_HelpType == ePropertyGridHelpType.SuperTooltip && helpTooltip != null)
|
||||
node.SetHelpTooltip(helpTooltip);
|
||||
node.UpdateDisplayedValue();
|
||||
}
|
||||
if (propertySort == ePropertySort.Alphabetical)
|
||||
nodeCollection.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool GetReadOnlyAttribute(PropertyDescriptor item, object instance)
|
||||
{
|
||||
bool readOnly = TypeDescriptor.GetAttributes(instance).Contains(InheritanceAttribute.InheritedReadOnly);
|
||||
// if (item.Attributes[typeof(ReadOnlyAttribute)].Equals(ReadOnlyAttribute.Yes))
|
||||
if (TypeDescriptor.GetAttributes(instance).Contains(ReadOnlyAttribute.Yes))
|
||||
{
|
||||
readOnly |= true;
|
||||
}
|
||||
//if(_Converter!=null && _Converter)
|
||||
|
||||
ReadOnlyAttribute readOnlyAttribute = item.Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute;
|
||||
if (!readOnly && readOnlyAttribute != null && readOnlyAttribute.IsReadOnly && !readOnlyAttribute.IsDefaultAttribute())
|
||||
readOnly |= true;
|
||||
|
||||
if (!readOnly)
|
||||
{
|
||||
readOnly = item.IsReadOnly;
|
||||
}
|
||||
//if (item.Attributes[typeof(ImmutableObjectAttribute)].Equals(ImmutableObjectAttribute.Yes))
|
||||
// readOnly |= true;
|
||||
|
||||
return readOnly; // item.IsReadOnly;
|
||||
}
|
||||
|
||||
private static CategoryAttribute _CategoryAttribute = new CategoryAttribute();
|
||||
private string GetCategory(PropertyDescriptor item)
|
||||
{
|
||||
string s = item.Category;
|
||||
if (!string.IsNullOrEmpty(s)) return s;
|
||||
|
||||
CategoryAttribute cat = item.Attributes[_CategoryAttribute.GetType()] as CategoryAttribute;
|
||||
if (cat != null && !string.IsNullOrEmpty(cat.Category)) return cat.Category;
|
||||
|
||||
return STR_Misc;
|
||||
}
|
||||
|
||||
private TypeConverter GetConverter(object component)
|
||||
{
|
||||
if (_Converter != null && _SelectedObject != null) return _Converter;
|
||||
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(component);
|
||||
if(converter.GetPropertiesSupported())
|
||||
return converter;
|
||||
return null;
|
||||
}
|
||||
private PropertyDescriptorCollection GetProperties()
|
||||
{
|
||||
Attribute[] attributes = _AttributeFilter;
|
||||
|
||||
if (_SelectedObject != null)
|
||||
{
|
||||
object component = _SelectedObject;
|
||||
return GetProperties(_TypeDescriptorContext, attributes, component, GetConverter(component));
|
||||
}
|
||||
|
||||
int selectedObjectsCount = _SelectedObjects.Length;
|
||||
List<PropertyDescriptor> mergedProperties = new List<PropertyDescriptor>();
|
||||
|
||||
List<PropertyDescriptorCollection> allProperties = new List<PropertyDescriptorCollection>(selectedObjectsCount);
|
||||
foreach (object selectedObject in _SelectedObjects)
|
||||
{
|
||||
allProperties.Add(GetProperties(_TypeDescriptorContext, attributes, selectedObject, GetConverter(selectedObject)));
|
||||
}
|
||||
|
||||
PropertyDescriptorCollection col1 = allProperties[0];
|
||||
|
||||
for (int i = 0; i < col1.Count; i++)
|
||||
{
|
||||
PropertyDescriptor propDesc = col1[i];
|
||||
bool mergable = propDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute();
|
||||
if (!mergable) continue;
|
||||
|
||||
int childPropertyOccurrenceCount = 1;
|
||||
for (int j = 1; j < allProperties.Count; j++)
|
||||
{
|
||||
PropertyDescriptorCollection col2 = allProperties[j];
|
||||
foreach (PropertyDescriptor propDesc2 in col2)
|
||||
{
|
||||
if (ArePropertiesSame(propDesc2, propDesc) && propDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute())
|
||||
{
|
||||
childPropertyOccurrenceCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (childPropertyOccurrenceCount == selectedObjectsCount)
|
||||
{
|
||||
mergedProperties.Add(propDesc);
|
||||
}
|
||||
}
|
||||
|
||||
return new PropertyDescriptorCollection(mergedProperties.ToArray());
|
||||
}
|
||||
|
||||
private bool ArePropertiesSame(PropertyDescriptor propDesc2, PropertyDescriptor propDesc)
|
||||
{
|
||||
return propDesc2.Name == propDesc.Name && propDesc2.PropertyType == propDesc.PropertyType;
|
||||
}
|
||||
public static PropertyDescriptor GetProperty(string propertyName, object component, TypeConverter converter)
|
||||
{
|
||||
PropertyDescriptorCollection col = GetProperties(null, component, converter);
|
||||
foreach (PropertyDescriptor item in col)
|
||||
{
|
||||
if (item.Name == propertyName)
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PropertyDescriptorCollection GetProperties(Attribute[] attributes, object component, TypeConverter converter)
|
||||
{
|
||||
return GetProperties(null, attributes, component, converter);
|
||||
}
|
||||
|
||||
public static PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, Attribute[] attributes, object component, TypeConverter converter)
|
||||
{
|
||||
if (component == null) return null;
|
||||
|
||||
if (component is ICustomTypeDescriptor)
|
||||
{
|
||||
ICustomTypeDescriptor descriptor = (ICustomTypeDescriptor)component;
|
||||
if (attributes != null)
|
||||
return descriptor.GetProperties(attributes);
|
||||
return descriptor.GetProperties();
|
||||
}
|
||||
|
||||
// Note that this assumes that converter supports GetProperties!
|
||||
if (converter != null)
|
||||
{
|
||||
return converter.GetProperties(context, component, attributes);
|
||||
}
|
||||
|
||||
Type type = component.GetType();
|
||||
|
||||
if (attributes != null)
|
||||
return TypeDescriptor.GetProperties(component, attributes);
|
||||
|
||||
return TypeDescriptor.GetProperties(component);
|
||||
}
|
||||
|
||||
private ePropertyGridHelpType _HelpType = ePropertyGridHelpType.HelpHidden;
|
||||
public ePropertyGridHelpType HelpType
|
||||
{
|
||||
get { return _HelpType; }
|
||||
set { _HelpType = value; }
|
||||
}
|
||||
|
||||
public TypeConverter TypeConverter
|
||||
{
|
||||
get { return _Converter; }
|
||||
set { _Converter = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
608
PROMS/DotNetBar Source Code/PropertyGrid/PropertySettings.cs
Normal file
608
PROMS/DotNetBar Source Code/PropertyGrid/PropertySettings.cs
Normal file
@@ -0,0 +1,608 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the property settings applied to the property on AdvPropertyGrid control.
|
||||
/// </summary>
|
||||
[ToolboxItem(false)]
|
||||
public class PropertySettings : Component, INotifyPropertyChanged
|
||||
{
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Occurs when property value is being converted to text representation for display. You can handle this event
|
||||
/// to provide custom conversion for property values. You must set IsConverted=true on event arguments to indicate that you have performed value conversion.
|
||||
/// </summary>
|
||||
[Description("Occurs when property value is being converted to text representation for display.")]
|
||||
public event ConvertValueEventHandler ConvertPropertyValueToString;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when text entered by user is being converted to typed property value to be assigned to the property. You can handle this event
|
||||
/// to provide custom conversion for property values. You must set IsConverted=true on event arguments to indicate that you have performed value conversion.
|
||||
/// </summary>
|
||||
[Description("Occurs when text entered by user is being converted to typed property value to be assigned to the property.")]
|
||||
public event ConvertValueEventHandler ConvertFromStringToPropertyValue;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property looks for the list of valid values for the property to show on either drop-down or use
|
||||
/// in auto-complete list. For example when property type is enum the internal implementation will convert available enum
|
||||
/// values into string list and use on drop-down and in auto-complete list. You can use this event to provide
|
||||
/// custom value list in combination with ConvertPropertyValueToString, ConvertFromStringToPropertyValue events.
|
||||
/// You must set IsListValid=true on event arguments to indicate that list your provided should be used.
|
||||
/// </summary>
|
||||
[Description("Occurs when property looks for the list of valid values for the property to show on either drop-down or use in auto-complete list.")]
|
||||
public event PropertyValueListEventHandler ProvidePropertyValueList;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySettings class.
|
||||
/// </summary>
|
||||
public PropertySettings()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySettings class.
|
||||
/// </summary>
|
||||
/// <param name="propertyName"></param>
|
||||
public PropertySettings(string propertyName)
|
||||
{
|
||||
_PropertyName = propertyName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySettings class.
|
||||
/// </summary>
|
||||
/// <param name="propertyDescriptor"></param>
|
||||
public PropertySettings(PropertyDescriptor propertyDescriptor)
|
||||
{
|
||||
_PropertyDescriptor = propertyDescriptor;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (BarUtilities.DisposeItemImages && !this.DesignMode)
|
||||
{
|
||||
BarUtilities.DisposeImage(ref _Image);
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
private ElementStyle _ReadOnlyStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets read-only property style.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Indicates read-only property style.")]
|
||||
public ElementStyle ReadOnlyStyle
|
||||
{
|
||||
get { return _ReadOnlyStyle; }
|
||||
set
|
||||
{
|
||||
if (_ReadOnlyStyle != value)
|
||||
{
|
||||
if (_ReadOnlyStyle != null)
|
||||
_ReadOnlyStyle.StyleChanged -= ReadOnlyStyleChanged;
|
||||
if (value != null)
|
||||
value.StyleChanged += ReadOnlyStyleChanged;
|
||||
_ReadOnlyStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ReadOnlyStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ReadOnlyStyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private bool _ReadOnly = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether property is in read-only state. Default value is false.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Description("Indicates whether property is in read-only state."), Category("Behavior")]
|
||||
public bool ReadOnly
|
||||
{
|
||||
get { return _ReadOnly; }
|
||||
set
|
||||
{
|
||||
if (value != _ReadOnly)
|
||||
{
|
||||
bool oldValue = _ReadOnly;
|
||||
_ReadOnly = value;
|
||||
OnReadOnlyChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnReadOnlyChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ReadOnly"));
|
||||
}
|
||||
|
||||
private SuperTooltipInfo _ReadOnlyTooltip;
|
||||
/// <summary>
|
||||
/// Gets or sets the SuperTooltip that is displayed when property is in read-only state (ReadOnly=true).
|
||||
/// </summary>
|
||||
[DefaultValue(null), Description("Indicates SuperTooltip that is displayed when property is in read-only state (ReadOnly=true)"), Category("Behavior")]
|
||||
public SuperTooltipInfo ReadOnlyTooltip
|
||||
{
|
||||
get { return _ReadOnlyTooltip; }
|
||||
set
|
||||
{
|
||||
if (value != _ReadOnlyTooltip)
|
||||
{
|
||||
SuperTooltipInfo oldValue = _ReadOnlyTooltip;
|
||||
_ReadOnlyTooltip = value;
|
||||
OnReadOnlyTooltipChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnReadOnlyTooltipChanged(SuperTooltipInfo oldValue, SuperTooltipInfo newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ReadOnlyTooltip"));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the ConvertPropertyValueToString event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event data</param>
|
||||
protected virtual void OnConvertPropertyValueToString(ConvertValueEventArgs e)
|
||||
{
|
||||
ConvertValueEventHandler handler = ConvertPropertyValueToString;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
internal void InvokeConvertPropertyValueToString(ConvertValueEventArgs e)
|
||||
{
|
||||
OnConvertPropertyValueToString(e);
|
||||
}
|
||||
internal bool HasConvertPropertyValueToStringHandler
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConvertPropertyValueToString != null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the ConvertFromStringToPropertyValue event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event data</param>
|
||||
protected virtual void OnConvertFromStringToPropertyValue(ConvertValueEventArgs e)
|
||||
{
|
||||
ConvertValueEventHandler handler = ConvertFromStringToPropertyValue;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
internal void InvokeConvertFromStringToPropertyValue(ConvertValueEventArgs e)
|
||||
{
|
||||
OnConvertFromStringToPropertyValue(e);
|
||||
}
|
||||
internal bool HasConvertFromStringToPropertyValueHandler
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConvertFromStringToPropertyValue != null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the ProvidePropertyValueList event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event data</param>
|
||||
protected virtual void OnProvidePropertyValueList(PropertyValueListEventArgs e)
|
||||
{
|
||||
PropertyValueListEventHandler handler = ProvidePropertyValueList;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
internal void InvokeProvidePropertyValueList(PropertyValueListEventArgs e)
|
||||
{
|
||||
OnProvidePropertyValueList(e);
|
||||
}
|
||||
internal bool HasProvidePropertyValueListHandler
|
||||
{
|
||||
get
|
||||
{
|
||||
return ProvidePropertyValueList != null;
|
||||
}
|
||||
}
|
||||
|
||||
private SuperTooltipInfo _Tooltip = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the SuperTooltip that is assigned to the property.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Localizable(true), Category("Appearance"), Description("Indicates SuperTooltip that is assigned to the property.")]
|
||||
public SuperTooltipInfo Tooltip
|
||||
{
|
||||
get { return _Tooltip; }
|
||||
set
|
||||
{
|
||||
if (value != _Tooltip)
|
||||
{
|
||||
SuperTooltipInfo oldValue = _Tooltip;
|
||||
_Tooltip = value;
|
||||
OnTooltipChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnTooltipChanged(SuperTooltipInfo oldValue, SuperTooltipInfo newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Tooltip"));
|
||||
}
|
||||
|
||||
private Image _Image = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image that is displayed next to the property name in the grid.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Localizable(true), Description("Indicates image that is displayed next to the property name in the grid.")]
|
||||
public Image Image
|
||||
{
|
||||
get { return _Image; }
|
||||
set
|
||||
{
|
||||
if (value != _Image)
|
||||
{
|
||||
Image oldValue = _Image;
|
||||
_Image = value;
|
||||
OnImageChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnImageChanged(Image oldValue, Image newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Image"));
|
||||
}
|
||||
|
||||
private eCellPartAlignment _ImageAlignment = eCellPartAlignment.NearCenter;
|
||||
/// <summary>
|
||||
/// Gets or sets the image alignment in relation to the property name inside of the grid cell.
|
||||
/// </summary>
|
||||
[DefaultValue(eCellPartAlignment.NearCenter), Category("Appearance"), Description("Indicates image alignment in relation to the property name inside of the grid cell.")]
|
||||
public eCellPartAlignment ImageAlignment
|
||||
{
|
||||
get { return _ImageAlignment; }
|
||||
set
|
||||
{
|
||||
if (value != _ImageAlignment)
|
||||
{
|
||||
eCellPartAlignment oldValue = _ImageAlignment;
|
||||
_ImageAlignment = value;
|
||||
OnImageAlignmentChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnImageAlignmentChanged(eCellPartAlignment oldValue, eCellPartAlignment newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ImageAlignment"));
|
||||
}
|
||||
|
||||
private string _Category = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the custom category node will be placed in instead of category specified by Category attribute.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Localizable(true), Description("Indicates custom category node will be placed in instead of category specified by Category attribute.")]
|
||||
public string Category
|
||||
{
|
||||
get { return _Category; }
|
||||
set
|
||||
{
|
||||
if (value != _Category)
|
||||
{
|
||||
string oldValue = _Category;
|
||||
_Category = value;
|
||||
OnCategoryChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCategoryChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Category"));
|
||||
}
|
||||
|
||||
private string _DisplayName = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the custom property name that is displayed in the grid instead of the real property name.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Localizable(true), Description("Indicates custom property name that is displayed in the grid instead of the real property name.")]
|
||||
public string DisplayName
|
||||
{
|
||||
get { return _DisplayName; }
|
||||
set
|
||||
{
|
||||
if (value != _DisplayName)
|
||||
{
|
||||
string oldValue = _DisplayName;
|
||||
_DisplayName = value;
|
||||
OnDisplayNameChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDisplayNameChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("DisplayName"));
|
||||
}
|
||||
|
||||
private string _PropertyName = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the property that is managed by this informational object. If you set PropertyDescriptor than that is the value
|
||||
/// that will be used by the control regardless of PropertyName value.
|
||||
/// If you set PropertyName but not PropertyDescriptor then all properties with given name
|
||||
/// regardless of type will use these settings.
|
||||
/// </summary>
|
||||
[DefaultValue("Indicates the name of the properties that settings are applied to.")]
|
||||
public string PropertyName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_PropertyDescriptor != null) return _PropertyDescriptor.Name;
|
||||
return _PropertyName;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_PropertyName == value) return;
|
||||
_PropertyName = value;
|
||||
OnPropertyNameChanged();
|
||||
}
|
||||
}
|
||||
private void OnPropertyNameChanged()
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("PropertyName"));
|
||||
}
|
||||
|
||||
private PropertyDescriptor _PropertyDescriptor = null;
|
||||
/// <summary>
|
||||
/// Gets or sets property descriptor that identifies the property settings apply to. If you set PropertyDescriptor than that is the value
|
||||
/// that will be used by the control regardless of PropertyName value.
|
||||
/// If you set PropertyName but not PropertyDescriptor then all properties with given name
|
||||
/// regardless of type will use these settings.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Description("Indicates property descriptor that identifies the property that uses these settings.")]
|
||||
public PropertyDescriptor PropertyDescriptor
|
||||
{
|
||||
get { return _PropertyDescriptor; }
|
||||
set
|
||||
{
|
||||
if (_PropertyDescriptor != value)
|
||||
{
|
||||
_PropertyDescriptor = value;
|
||||
OnPropertyDescriptorChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnPropertyDescriptorChanged()
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("PropertyDescriptor"));
|
||||
}
|
||||
|
||||
private ElementStyle _Style = null;
|
||||
/// <summary>
|
||||
/// Gets or sets default property style.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// Default value is null.
|
||||
/// </value>
|
||||
[DefaultValue(null), /*Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),*/ Description("Indicates default property style.")]
|
||||
public ElementStyle Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set
|
||||
{
|
||||
if (_Style != value)
|
||||
{
|
||||
if (_Style != null)
|
||||
_Style.StyleChanged -= StyleChanged;
|
||||
if (value != null)
|
||||
value.StyleChanged += StyleChanged;
|
||||
_Style = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Style"));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void StyleChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private UITypeEditor _UITypeEditor = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the UITypeEditor used to edit the property.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Behavior"), Browsable(false)]
|
||||
public UITypeEditor UITypeEditor
|
||||
{
|
||||
get { return _UITypeEditor; }
|
||||
set
|
||||
{
|
||||
if (value != _UITypeEditor)
|
||||
{
|
||||
UITypeEditor oldValue = _UITypeEditor;
|
||||
_UITypeEditor = value;
|
||||
OnUITypeEditorChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnUITypeEditorChanged(UITypeEditor oldValue, UITypeEditor newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("UITypeEditor"));
|
||||
}
|
||||
|
||||
private PropertyValueEditor _ValueEditor = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the custom in-line property value editor. Property value editor is created by inheriting from PropertyValueEditor class.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Browsable(false)]
|
||||
public PropertyValueEditor ValueEditor
|
||||
{
|
||||
get { return _ValueEditor; }
|
||||
set
|
||||
{
|
||||
if (value != _ValueEditor)
|
||||
{
|
||||
PropertyValueEditor oldValue = _ValueEditor;
|
||||
_ValueEditor = value;
|
||||
OnValueEditorChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnValueEditorChanged(PropertyValueEditor oldValue, PropertyValueEditor newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ValueEditor"));
|
||||
|
||||
}
|
||||
|
||||
private bool _Visible = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether node is visible in property grid. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance"), Description("Indicates whether node is visible in property grid.")]
|
||||
public bool Visible
|
||||
{
|
||||
get { return _Visible; }
|
||||
set
|
||||
{
|
||||
if (value != _Visible)
|
||||
{
|
||||
bool oldValue = _Visible;
|
||||
_Visible = value;
|
||||
OnVisibleChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnVisibleChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Visible"));
|
||||
|
||||
}
|
||||
|
||||
private ePropertyNodeType _PropertyNodeType = ePropertyNodeType.Default;
|
||||
/// <summary>
|
||||
/// Gets or sets the property node type that is used to edit this property value. Note that content of property grid would need to be
|
||||
/// reloaded to apply any changes to this property.
|
||||
/// </summary>
|
||||
[DefaultValue(ePropertyNodeType.Default), Description("Indicates property node type that is used to edit this property value.")]
|
||||
public ePropertyNodeType PropertyNodeType
|
||||
{
|
||||
get { return _PropertyNodeType; }
|
||||
set
|
||||
{
|
||||
if (value != _PropertyNodeType)
|
||||
{
|
||||
ePropertyNodeType oldValue = _PropertyNodeType;
|
||||
_PropertyNodeType = value;
|
||||
OnPropertyNodeTypeChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnPropertyNodeTypeChanged(ePropertyNodeType oldValue, ePropertyNodeType newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("PropertyNodeType"));
|
||||
}
|
||||
|
||||
private string _Description = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the property description that overrides description specified on property through DescriptionAttribute.
|
||||
/// Default value is null.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Description("Indicates property description that overrides description specified on property through DescriptionAttribute. "), Localizable(true)]
|
||||
public string Description
|
||||
{
|
||||
get { return _Description; }
|
||||
set
|
||||
{
|
||||
if (value != _Description)
|
||||
{
|
||||
string oldValue = _Description;
|
||||
_Description = value;
|
||||
OnDescriptionChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDescriptionChanged(string oldValue, string newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Description"));
|
||||
}
|
||||
|
||||
private TypeConverter _TypeConverter = null;
|
||||
/// <summary>
|
||||
/// Gets or sets custom TypeConverter assigned to the property which will override any TypeConverter that is returned by the PropertyDescriptor.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(null)]
|
||||
public TypeConverter TypeConverter
|
||||
{
|
||||
get { return _TypeConverter; }
|
||||
set
|
||||
{
|
||||
if (value != _TypeConverter)
|
||||
{
|
||||
TypeConverter oldValue = _TypeConverter;
|
||||
_TypeConverter = value;
|
||||
OnTypeConverterChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when TypeConverter property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnTypeConverterChanged(TypeConverter oldValue, TypeConverter newValue)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("TypeConverter"));
|
||||
|
||||
}
|
||||
|
||||
internal static string NamePropertyName = "PropertyName";
|
||||
internal static string NamePropertyDescriptor = "PropertyDescriptor";
|
||||
internal static string NameVisible = "Visible";
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
/// <summary>
|
||||
/// Raises PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event data.</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when property value on the object changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the type of the property node in grid that is assigned to property.
|
||||
/// </summary>
|
||||
public enum ePropertyNodeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies default node type for the property.
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// Specifies the node type that is constructed as group of option buttons that represent all values for the property. Works best
|
||||
/// for smaller set of Enum values.
|
||||
/// </summary>
|
||||
RadioButtonList
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,138 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
public class PropertySettingsCollection : Collection<PropertySettings>
|
||||
{
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertyGridInfoCollection class.
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
public PropertySettingsCollection(AdvPropertyGrid owner)
|
||||
{
|
||||
_Owner = owner;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
protected override void InsertItem(int index, PropertySettings item)
|
||||
{
|
||||
base.InsertItem(index, item);
|
||||
OnAfterItemAdded(item);
|
||||
}
|
||||
|
||||
private void OnAfterItemAdded(PropertySettings item)
|
||||
{
|
||||
_Owner.PropertySettingsItemAdded(item);
|
||||
}
|
||||
|
||||
protected override void ClearItems()
|
||||
{
|
||||
PropertySettings[] items = new PropertySettings[this.Count];
|
||||
this.CopyTo(items, 0);
|
||||
|
||||
base.ClearItems();
|
||||
|
||||
foreach (PropertySettings item in items)
|
||||
{
|
||||
OnAfterItemRemoved(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
PropertySettings info = this[index];
|
||||
base.RemoveItem(index);
|
||||
OnAfterItemRemoved(info);
|
||||
}
|
||||
|
||||
private void OnAfterItemRemoved(PropertySettings info)
|
||||
{
|
||||
_Owner.PropertySettingsItemRemoved(info);
|
||||
}
|
||||
|
||||
protected override void SetItem(int index, PropertySettings item)
|
||||
{
|
||||
PropertySettings oldItem = this[index];
|
||||
base.SetItem(index, item);
|
||||
|
||||
OnAfterItemRemoved(oldItem);
|
||||
OnAfterItemAdded(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets property info object based on property name.
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Property name.</param>
|
||||
/// <returns>PropertyGridInfo instance or null if it cannot be found.</returns>
|
||||
public virtual PropertySettings this[string propertyName]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (PropertySettings item in this)
|
||||
{
|
||||
if (item.PropertyName == propertyName) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<PropertyDescriptor, PropertySettings> _DictionaryByDescriptor = new Dictionary<PropertyDescriptor, PropertySettings>();
|
||||
/// <summary>
|
||||
/// Gets property info object based on property descriptor.
|
||||
/// </summary>
|
||||
/// <param name="propertyDescriptor">Property descriptor.</param>
|
||||
/// <returns>PropertyGridInfo instance or null if it cannot be found.</returns>
|
||||
public virtual PropertySettings this[PropertyDescriptor propertyDescriptor]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (PropertySettings item in this)
|
||||
{
|
||||
if (item.PropertyDescriptor.Equals(propertyDescriptor)) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns property setting based on property descriptor or name if property descriptor is not set on property settings
|
||||
/// Property descriptor takes precedence.
|
||||
/// </summary>
|
||||
/// <param name="propertyDescriptor">Property descriptor to look for.</param>
|
||||
/// <param name="propertyName">Property Name to look for.</param>
|
||||
/// <returns>Property settings instance or null</returns>
|
||||
public virtual PropertySettings this[PropertyDescriptor propertyDescriptor, string propertyName]
|
||||
{
|
||||
get
|
||||
{
|
||||
PropertySettings settingByName = null;
|
||||
foreach (PropertySettings item in this)
|
||||
{
|
||||
if (item.PropertyDescriptor != null && item.PropertyDescriptor.Equals(propertyDescriptor))
|
||||
return item;
|
||||
else if (item.PropertyName == propertyName)
|
||||
settingByName = item;
|
||||
}
|
||||
return settingByName;
|
||||
}
|
||||
}
|
||||
|
||||
private AdvPropertyGrid _Owner = null;
|
||||
/// <summary>
|
||||
/// Gets the owner of the collection.
|
||||
/// </summary>
|
||||
public AdvPropertyGrid Owner
|
||||
{
|
||||
get { return _Owner; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
218
PROMS/DotNetBar Source Code/PropertyGrid/PropertySliderEditor.cs
Normal file
218
PROMS/DotNetBar Source Code/PropertyGrid/PropertySliderEditor.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines base attribute for custom AdvPropertyGrid in-line property value editors.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||
public abstract class PropertyValueEditor : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a control that is used as property value in-line editor. Control must implement IPropertyValueEditor interface.
|
||||
/// </summary>
|
||||
/// <param name="propertyDescriptor">PropertyDescriptor for the property being edited.</param>
|
||||
/// <param name="targetObject">Target object that owns the property.</param>
|
||||
/// <returns>Control that represents in-line editor.</returns>
|
||||
public abstract IPropertyValueEditor CreateEditor(PropertyDescriptor propertyDescriptor, object targetObject);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Defines a attribute which applies an slider in-line editor to a property when used with AdvPropertyGrid control.
|
||||
/// </summary>
|
||||
public class PropertySliderEditor : PropertyValueEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum slider value.
|
||||
/// </summary>
|
||||
public int MinValue = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum slider value.
|
||||
/// </summary>
|
||||
public int MaxValue = 100;
|
||||
/// <summary>
|
||||
/// Gets or sets whether slider text label is visible.
|
||||
/// </summary>
|
||||
public bool LabelVisible = true;
|
||||
/// <summary>
|
||||
/// Gets or sets the slider label width. Default value is 18.
|
||||
/// </summary>
|
||||
public int LabelWidth = 22;
|
||||
/// <summary>
|
||||
/// Gets or sets label text color.
|
||||
/// </summary>
|
||||
public Color TextColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySliderEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue">Minimum value for slider.</param>
|
||||
/// <param name="maxValue">Maximum value for slider.</param>
|
||||
public PropertySliderEditor(int minValue, int maxValue)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySliderEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertySliderEditor(int minValue, int maxValue, Color textColor)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
TextColor = textColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySliderEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="labelVisible"></param>
|
||||
/// <param name="labelWidth"></param>
|
||||
/// <param name="textColor"></param>
|
||||
public PropertySliderEditor(int minValue, int maxValue, bool labelVisible, int labelWidth, Color textColor)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
LabelVisible = labelVisible;
|
||||
LabelWidth = labelWidth;
|
||||
TextColor = textColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySliderEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="labelVisible"></param>
|
||||
public PropertySliderEditor(int minValue, int maxValue, bool labelVisible)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
LabelVisible = labelVisible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the PropertySliderEditor class.
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="labelVisible"></param>
|
||||
/// <param name="labelWidth"></param>
|
||||
public PropertySliderEditor(int minValue, int maxValue, bool labelVisible, int labelWidth)
|
||||
{
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
LabelVisible = labelVisible;
|
||||
LabelWidth = labelWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a control that is used as property value in-line editor. Control must implement IPropertyValueEditor interface.
|
||||
/// </summary>
|
||||
/// <param name="propertyDescriptor">PropertyDescriptor for the property being edited.</param>
|
||||
/// <param name="targetObject">Target object that owns the property.</param>
|
||||
/// <returns>Control that represents in-line editor.</returns>
|
||||
public override IPropertyValueEditor CreateEditor(PropertyDescriptor propertyDescriptor, object targetObject)
|
||||
{
|
||||
SliderPropertyEditor editor = new SliderPropertyEditor();
|
||||
editor.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
editor.LabelVisible = LabelVisible;
|
||||
editor.LabelWidth = LabelWidth;
|
||||
editor.Minimum = MinValue;
|
||||
editor.Maximum = MaxValue;
|
||||
editor.Height = Dpi.Height16;
|
||||
editor.FocusCuesEnabled = false;
|
||||
if (!TextColor.IsEmpty)
|
||||
editor.TextColor = TextColor;
|
||||
return editor;
|
||||
}
|
||||
|
||||
private class SliderPropertyEditor : Slider, IPropertyValueEditor
|
||||
{
|
||||
#region IPropertyValueEditor Members
|
||||
|
||||
public System.Drawing.Font EditorFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEditorFocused
|
||||
{
|
||||
get { return this.Focused; }
|
||||
}
|
||||
|
||||
public void FocusEditor()
|
||||
{
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
public object EditValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value is int)
|
||||
this.Value = (int)value;
|
||||
else if (value is double)
|
||||
this.Value = (int)(double)value;
|
||||
else if (value is float)
|
||||
this.Value = (int)(float)value;
|
||||
else if (value is decimal)
|
||||
this.Value = (int)(decimal)value;
|
||||
else if (value is byte)
|
||||
this.Value = (int)(byte)value;
|
||||
else if (value is long)
|
||||
this.Value = (int)(long)value;
|
||||
else if (value is Single)
|
||||
this.Value = (int)(Single)value;
|
||||
this.Text = this.Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
//protected override void OnValueChanged()
|
||||
//{
|
||||
// this.Text = this.Value.ToString();
|
||||
// OnEditValueChanged(EventArgs.Empty);
|
||||
// base.OnValueChanged();
|
||||
//}
|
||||
|
||||
protected override void OnValueChanged(EventArgs e)
|
||||
{
|
||||
this.Text = this.Value.ToString();
|
||||
OnEditValueChanged(e);
|
||||
base.OnValueChanged(e);
|
||||
}
|
||||
|
||||
private void OnEditValueChanged(EventArgs e)
|
||||
{
|
||||
EventHandler ev = EditValueChanged;
|
||||
if (ev != null) ev(this, e);
|
||||
}
|
||||
public event EventHandler EditValueChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user