using System; using System.ComponentModel; namespace DevComponents.DotNetBar.SuperGrid.Style { /// /// Represents the base visual style. /// [ToolboxItem(false), DesignTimeVisible(false)] public class BaseVisualStyle : INotifyPropertyChanged, IDisposable { #region Private variables private string _Class = ""; private object _Tag; #endregion #region Public properties #region Class /// /// Gets or sets the class style belongs to. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Class { get { return (_Class); } set { if (_Class != value) { _Class = value; OnPropertyChangedEx("Class", VisualChangeType.Layout); } } } #endregion #region IsEmpty /// /// Gets whether the style is logically Empty. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Gets whether the style is logically Empty.")] public virtual bool IsEmpty { get { return (_Tag == null); } } #endregion #region Tag /// /// Gets or sets the user defined reference Tag. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("User defined reference Tag.")] public object Tag { get { return (_Tag); } set { _Tag = value; } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(BaseVisualStyle style) { } #endregion #region GetApplyStyleTypes internal StyleType[] GetApplyStyleTypes(StyleType e) { StyleType[] css = null; switch (e) { case StyleType.Default: css = new StyleType[] { StyleType.Default}; break; case StyleType.Empty: case StyleType.MouseOver: case StyleType.ReadOnly: case StyleType.Selected: case StyleType.NotSelectable: css = new StyleType[] { StyleType.Default, e }; break; case StyleType.SelectedMouseOver: css = new StyleType[] { StyleType.Default, StyleType.Selected, e }; break; case StyleType.ReadOnlyMouseOver: css = new StyleType[] { StyleType.Default, StyleType.ReadOnly, e }; break; case StyleType.ReadOnlySelected: css = new StyleType[] { StyleType.Default, StyleType.Selected, StyleType.ReadOnly, e }; break; case StyleType.ReadOnlySelectedMouseOver: css = new StyleType[] { StyleType.Default, StyleType.Selected, StyleType.ReadOnly, StyleType.ReadOnlySelected, e }; break; } return (css); } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public BaseVisualStyle Copy() { BaseVisualStyle style = new BaseVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(BaseVisualStyle copy) { copy.Class = _Class; copy.Tag = _Tag; } #endregion #region INotifyPropertyChanged Members /// /// Occurs when property value has changed. /// public event PropertyChangedEventHandler PropertyChanged; /// /// Raises the PropertyChanged event. /// /// Event arguments protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) { PropertyChangedEventHandler eh = PropertyChanged; if (eh != null) eh(this, e); } /// /// Default PropertyChanged processing /// /// protected void OnPropertyChanged(string s) { if (PropertyChanged != null) OnPropertyChanged(new VisualPropertyChangedEventArgs(s)); } /// /// Default PropertyChanged processing /// /// /// invalidate protected void OnPropertyChangedEx(string s, VisualChangeType changeType) { if (PropertyChanged != null) OnPropertyChanged(new VisualPropertyChangedEventArgs(s, changeType)); } #endregion #region UpdateChangeHandler /// /// UpdateChangeHandler /// /// /// protected void UpdateChangeHandler( INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue) { if (oldValue != null) oldValue.PropertyChanged -= ValuePropertyChanged; if (newValue != null) newValue.PropertyChanged += ValuePropertyChanged; } void ValuePropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e); } #endregion #region IDisposable /// /// Dispose /// public virtual void Dispose() { } #endregion } #region enums #region Alignment /// /// Alignment of the content /// public enum Alignment { /// /// NotSet = -1, /// /// TopLeft /// TopLeft, /// /// TopCenter /// TopCenter, /// /// TopRight /// TopRight, /// /// MiddleLeft /// MiddleLeft, /// /// MiddleCenter /// MiddleCenter, /// /// MiddleRight /// MiddleRight, /// /// BottomLeft /// BottomLeft, /// /// BottomCenter /// BottomCenter, /// /// BottomRight /// BottomRight, } #endregion #region BorderSide internal enum BorderSide { Top, Left, Bottom, Right } #endregion #region CellHighlightMode /// /// Specifies the mode of cell highlighting /// to employ when a grid cell is selected /// public enum CellHighlightMode { /// /// No highlighting /// None, /// /// Entire cell will be Highlighted /// Full, /// /// Partial cell will be Highlighted /// Partial, /// /// Cell content only will be Highlighted /// Content, } #endregion #region ImageHighlightMode /// /// ImageHighlightMode /// public enum ImageHighlightMode { /// /// NotSet /// NotSet = -1, /// /// Default /// Default, /// /// Always /// Always, /// /// Never /// Never, } #endregion #region ImageOverlay /// /// How to Overlay the Image with /// respect to the content /// public enum ImageOverlay { /// /// NotSet = -1, /// /// None /// None, /// /// Top /// Top, /// /// Bottom /// Bottom, } #endregion #region Tbool /// /// TBool - Three state boolean /// public enum Tbool { /// /// NotSet /// NotSet, /// /// True /// True, /// /// False /// False } #endregion #region VisualChangeType /// /// Defines visual property change type. /// public enum VisualChangeType { /// /// Visual style has changed so layout is impacted /// Layout, /// /// Visual style has changed so visuals are impacted, but not layout /// Render } #endregion #endregion }