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