using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Text; namespace DevComponents.DotNetBar.Controls { /// /// Class represents single token in TokenEditor control. /// [ToolboxItem(false)] public class EditToken : Component { #region Constructor /// /// Initializes a new instance of the EditToken class. /// /// Indicates token value. public EditToken(string value) { _Value = value; } /// /// Initializes a new instance of the EditToken class. /// /// Indicates token value /// Indicates token text public EditToken(string value, string text) { _Value = value; _Text = text; } /// /// Initializes a new instance of the EditToken class. /// /// Indicates token value /// Indicates token text /// Indicates token image public EditToken(string value, string text, Image image) { _Value = value; _Text = text; _Image = image; } #endregion #region Implementation private eTokenPart _MouseOverPart; private string _Value = ""; /// /// Indicates the token value, for example an email token has email address as token Value and full name as token Text. /// [DefaultValue(""), Category("Data"), Description("Indicates the token value, for example an email token has email address as token Value and full name as token Text.")] public string Value { get { return _Value; } set { if (value != _Value) { string oldValue = _Value; _Value = value; OnValueChanged(oldValue, value); } } } /// /// Called when Value property has changed. /// /// Old property value /// New property value protected virtual void OnValueChanged(string oldValue, string newValue) { //OnPropertyChanged(new PropertyChangedEventArgs("Value")); } private string _Text = ""; /// /// Indicates the token text, for example an email token has email address as token Value and full name as token Text. /// [DefaultValue(""), Category("Data"), Description("Indicates the token text, for example an email token has email address as token Value and full name as token Text.")] public string Text { get { return _Text; } set { if (value != _Text) { string oldValue = _Text; _Text = value; OnTextChanged(oldValue, value); } } } /// /// Called when Text property has changed. /// /// Old property value /// New property value protected virtual void OnTextChanged(string oldValue, string newValue) { //OnPropertyChanged(new PropertyChangedEventArgs("Text")); } private object _Tag = null; /// /// Gets or sets custom data associated with the object. /// [DefaultValue((string)null), Localizable(false), TypeConverter(typeof(StringConverter)), Category("Data"), Description("Custom data associated with the object")] public object Tag { get { return _Tag; } set { _Tag = value; } } private Rectangle _Bounds = Rectangle.Empty; /// /// Gets the display bounds of the token, if displayed, inside of TokenEditor control. /// [Browsable(false)] public Rectangle Bounds { get { return _Bounds; } internal set { _Bounds = value; } } private Image _Image = null; /// /// Indicates the image that is displayed next to the token /// [DefaultValue(null), Category("Appearance"), Description("Indicates the image that is displayed next to the token")] public Image Image { get { return _Image; } set { if (value != _Image) { Image oldValue = _Image; _Image = value; OnImageChanged(oldValue, value); } } } /// /// Called when Image property has changed. /// /// Old property value /// New property value protected virtual void OnImageChanged(Image oldValue, Image newValue) { //OnPropertyChanged(new PropertyChangedEventArgs("Image")); } /// /// Gets the realized symbol string. /// [Browsable(false)] public string SymbolRealized { get { return _SymbolRealized; } } private string _Symbol = "", _SymbolRealized = ""; /// /// Indicates the symbol displayed on face of the token instead of the image. Setting the symbol overrides the image setting. /// [DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the token 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) { if (string.IsNullOrEmpty(newValue)) _SymbolRealized = ""; else _SymbolRealized = Symbols.GetSymbol(newValue); //OnPropertyChanged(new PropertyChangedEventArgs("Symbol")); this.Invalidate(); } 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) { this.Invalidate(); } private void Invalidate() { //throw new NotImplementedException(); } 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; this.Invalidate(); } } /// /// 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; } private string _Tooltip = ""; /// /// Indicates tooltip that is displayed when mouse is over the token and token is selected. /// [DefaultValue(""), Category("Behavior"), Description("Indicates tooltip that is displayed when mouse is over the token and token is selected")] public string Tooltip { get { return _Tooltip; } set { if (value !=_Tooltip) { string oldValue = _Tooltip; _Tooltip = value; OnTooltipChanged(oldValue, value); } } } /// /// Called when Tooltip property has changed. /// /// Old property value /// New property value protected virtual void OnTooltipChanged(string oldValue, string newValue) { //OnPropertyChanged(new PropertyChangedEventArgs("Tooltip")); } /// /// Gets the part of the token mouse is over. Valid only when token is selected. /// [Browsable(false)] public eTokenPart MouseOverPart { get { return _MouseOverPart; } internal set { if (value !=_MouseOverPart) { eTokenPart oldValue = _MouseOverPart; _MouseOverPart = value; OnMouseOverPartChanged(oldValue, value); } } } /// /// Called when MouseOverPart property has changed. /// /// Old property value /// New property value protected virtual void OnMouseOverPartChanged(eTokenPart oldValue, eTokenPart newValue) { //OnPropertyChanged(new PropertyChangedEventArgs("MouseOverPart")); } private Rectangle _RemoveButtonBounds = Rectangle.Empty; /// /// Gets the bounds of the remove button if displayed. Valid only when token is selected. /// [Browsable(false)] public Rectangle RemoveButtonBounds { get { return _RemoveButtonBounds; } internal set { _RemoveButtonBounds = value; } } private Rectangle _ImageBounds = Rectangle.Empty; /// /// Gets the bounds of the image if displayed. Valid only when token is selected. /// [Browsable(false)] public Rectangle ImageBounds { get { return _ImageBounds; } internal set { _ImageBounds = value; } } private bool _IsSelected = false; /// /// Indicates whether token is selected. /// [Browsable(false)] public bool IsSelected { get { return _IsSelected; } internal set { _IsSelected = value; } } private bool _IsFocused = false; /// /// Indicates whether token is focused while selected. /// [Browsable(false)] public bool IsFocused { get { return _IsFocused; } internal set { _IsFocused = value; } } #endregion } /// /// Defines the token parts. /// public enum eTokenPart { /// /// Identifies no token part. /// None, /// /// Identifies the token body/text. /// Token, /// /// Identifies the remove token button. /// RemoveButton, /// /// Identifies the token image. /// Image } }