using System; using System.ComponentModel; using System.Drawing; namespace DevComponents.DotNetBar.SuperGrid.Style { /// /// Represents the visual style of a Row. /// [ToolboxItem(false), DesignTimeVisible(false)] [TypeConverter(typeof(BlankExpandableObjectConverter))] public class BaseTreeButtonVisualStyle : BaseVisualStyle { #region Static data /// /// Empty /// public static BaseTreeButtonVisualStyle Empty { get { return (new BaseTreeButtonVisualStyle()); } } #endregion #region Private variables private Color _BorderColor = Color.Empty; private Color _HotBorderColor = Color.Empty; private Color _LineColor = Color.Empty; private Color _HotLineColor = Color.Empty; private Background _Background; private Background _HotBackground; #endregion #region Public properties #region Background /// /// Gets or sets the TreeButton background. /// [Description("Indicates the TreeButton background")] public Background Background { get { if (_Background == null) { _Background = Background.Empty; UpdateChangeHandler(null, _Background); } return (_Background); } set { if (_Background != value) { UpdateChangeHandler(_Background, value); _Background = value; OnPropertyChangedEx("Background", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeBackground() { return (_Background != null && _Background.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetBackground() { _Background = null; } #endregion #region HotBackground /// /// Gets or sets the Hot background. /// [Description("Indicates the Hot background")] public Background HotBackground { get { if (_HotBackground == null) { _HotBackground = Background.Empty; UpdateChangeHandler(null, _HotBackground); } return (_HotBackground); } set { if (_HotBackground != value) { UpdateChangeHandler(_HotBackground, value); _HotBackground = value; OnPropertyChangedEx("HotBackground", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeHotBackground() { return (_HotBackground != null && _HotBackground.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetHotBackground() { HotBackground = null; } #endregion #region BorderColor /// /// Gets or sets the border Color /// [Category("Appearance")] [Description("Indicates the border Color.")] public Color BorderColor { get { return (_BorderColor); } set { if (_BorderColor != value) { _BorderColor = value; OnPropertyChangedEx("BorderColor", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeBorderColor() { return (_BorderColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetBorderColor() { BorderColor = Color.Empty; } #endregion #region HotBorderColor /// /// Gets or sets the Hot border Color /// [Category("Appearance")] [Description("Indicates the Hot border Color.")] public Color HotBorderColor { get { return (_HotBorderColor); } set { if (_HotBorderColor != value) { _HotBorderColor = value; OnPropertyChangedEx("HotBorderColor", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeHotBorderColor() { return (_HotBorderColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetHotBorderColor() { HotBorderColor = Color.Empty; } #endregion #region LineColor /// /// Gets or sets the button interior line Color /// [Category("Appearance")] [Description("Indicates the button interior line Color.")] public Color LineColor { get { return (_LineColor); } set { if (_LineColor != value) { _LineColor = value; OnPropertyChangedEx("LineColor", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeLineColor() { return (_LineColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetLineColor() { LineColor = Color.Empty; } #endregion #region HotLineColor /// /// Gets or sets the Hot button interior line Color /// [Category("Appearance")] [Description("Indicates the Hot button interior line Color.")] public Color HotLineColor { get { return (_HotLineColor); } set { if (_HotLineColor != value) { _HotLineColor = value; OnPropertyChangedEx("HotLineColor", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeHotLineColor() { return (_HotLineColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetHotLineColor() { HotLineColor = Color.Empty; } #endregion #region IsEmpty /// /// IsEmpty /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public override bool IsEmpty { get { return ((_Background == null || _Background.IsEmpty) && (_HotBackground == null || _HotBackground.IsEmpty) && (_BorderColor == Color.Empty && _HotBorderColor == Color.Empty && base.IsEmpty)); } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(BaseTreeButtonVisualStyle style) { if (style != null) { base.ApplyStyle(style); if (style.BorderColor.IsEmpty == false) BorderColor = style.BorderColor; if (style.HotBorderColor.IsEmpty == false) HotBorderColor = style.HotBorderColor; if (style.Background != null && style.Background.IsEmpty == false) Background = style.Background.Copy(); if (style.HotBackground != null && style.HotBackground.IsEmpty == false) HotBackground = style.HotBackground.Copy(); if (style.LineColor.IsEmpty == false) LineColor = style.LineColor; if (style.HotLineColor.IsEmpty == false) HotLineColor = style.HotLineColor; } } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new BaseTreeButtonVisualStyle Copy() { BaseTreeButtonVisualStyle style = new BaseTreeButtonVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(BaseTreeButtonVisualStyle copy) { base.CopyTo(copy); copy.BorderColor = _BorderColor; copy.HotBorderColor = _HotBorderColor; copy.LineColor = _LineColor; copy.HotLineColor = _HotLineColor; if (Background != null) copy.Background = _Background.Copy(); if (HotBackground != null) copy.HotBackground = _HotBackground.Copy(); } #endregion #region IDisposable /// /// Dispose /// public override void Dispose() { Background = null; HotBackground = null; base.Dispose(); } #endregion } /// /// Represents the visual style of a Row. /// [ToolboxItem(false), DesignTimeVisible(false)] [TypeConverter(typeof(BlankExpandableObjectConverter))] public class TreeButtonVisualStyle : BaseVisualStyle { #region Static data /// /// Empty /// public static TreeButtonVisualStyle Empty { get { return (new TreeButtonVisualStyle()); } } #endregion #region Private variables private BaseTreeButtonVisualStyle _ExpandButton; private BaseTreeButtonVisualStyle _CollapseButton; #endregion #region Public properties #region CollapseButton /// /// Gets or sets the CollapseButton. /// [Description("Indicates the CollapseButton")] public BaseTreeButtonVisualStyle CollapseButton { get { if (_CollapseButton == null) { _CollapseButton = BaseTreeButtonVisualStyle.Empty; UpdateChangeHandler(null, _CollapseButton); } return (_CollapseButton); } set { if (_CollapseButton != value) { UpdateChangeHandler(_CollapseButton, value); _CollapseButton = value; OnPropertyChangedEx("CollapseButton", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeCollapseButton() { return (_CollapseButton != null && _CollapseButton.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetCollapseButton() { CollapseButton = null; } #endregion #region ExpandButton /// /// Gets or sets the ExpandButton. /// [Description("Indicates the ExpandButton")] public BaseTreeButtonVisualStyle ExpandButton { get { if (_ExpandButton == null) { _ExpandButton = BaseTreeButtonVisualStyle.Empty; UpdateChangeHandler(null, _ExpandButton); } return (_ExpandButton); } set { if (_ExpandButton != value) { UpdateChangeHandler(_ExpandButton, value); _ExpandButton = value; OnPropertyChangedEx("ExpandButton", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeExpandButton() { return (_ExpandButton != null && _ExpandButton.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetExpandButton() { ExpandButton = null; } #endregion #region IsEmpty /// /// IsEmpty /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public override bool IsEmpty { get { return ((_CollapseButton == null || _CollapseButton.IsEmpty) && (_ExpandButton == null || _ExpandButton.IsEmpty) && base.IsEmpty); } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(TreeButtonVisualStyle style) { if (style != null) { base.ApplyStyle(style); if (style._CollapseButton != null) CollapseButton.ApplyStyle(style._CollapseButton); if (style._ExpandButton != null) ExpandButton.ApplyStyle(style._ExpandButton); } } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new TreeButtonVisualStyle Copy() { TreeButtonVisualStyle style = new TreeButtonVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(TreeButtonVisualStyle copy) { base.CopyTo(copy); if (_CollapseButton != null) copy.CollapseButton = _CollapseButton.Copy(); if (_ExpandButton != null) copy.ExpandButton = _ExpandButton.Copy(); } #endregion #region IDisposable /// /// Dispose /// public override void Dispose() { CollapseButton = null; ExpandButton = null; base.Dispose(); } #endregion } }