using System; using System.ComponentModel; using System.Drawing; namespace DevComponents.DotNetBar.SuperGrid.Style { /// /// GroupHeaderVisualStyles /// public class GroupHeaderVisualStyles : VisualStyles { } /// /// RowHeaderVisualStyle /// public class GroupHeaderVisualStyle : BaseVisualStyle { #region Static data /// /// Empty /// public static GroupHeaderVisualStyle Empty { get { return (new GroupHeaderVisualStyle()); } } #endregion #region Private variables private Font _Font; private Alignment _Alignment = Alignment.NotSet; private Tbool _AllowWrap = Tbool.NotSet; private Color _TextColor = Color.Empty; private Color _UnderlineColor = Color.Empty; private Background _Background; private Padding _Padding; private RowHeaderVisualStyle _RowHeaderStyle; #endregion #region Public properties #region Alignment /// /// Gets or sets the alignment of the content within the cell /// [DefaultValue(Alignment.NotSet), Category("Appearance")] [Description("Indicates the alignment of the content.")] public Alignment Alignment { get { return (_Alignment); } set { if (_Alignment != value) { _Alignment = value; OnPropertyChangedEx("Alignment", VisualChangeType.Layout); } } } #endregion #region AllowWrap /// /// Gets or sets whether text wrapping is permitted /// [DefaultValue(Tbool.NotSet), Category("Appearance")] [Description("Indicates whether text wrapping is permitted")] public Tbool AllowWrap { get { return (_AllowWrap); } set { if (_AllowWrap != value) { _AllowWrap = value; OnPropertyChangedEx("AllowWrap", VisualChangeType.Layout); } } } #endregion #region Background /// /// Gets or sets the style background. /// [Description("Indicates the style 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 Font /// /// Gets or sets the style Font. /// [DefaultValue(null)] [Description("Indicates the style Font")] public Font Font { get { return (_Font); } set { if (_Font != value) { _Font = value; OnPropertyChangedEx("Font", VisualChangeType.Layout); } } } #endregion #region Padding /// /// Gets or sets the spacing between the content and edges of the element /// [Description("Indicates the spacing between the content and edges of the element")] public Padding Padding { get { if (_Padding == null) { _Padding = Padding.Empty; UpdateChangeHandler(null, _Padding); } return (_Padding); } set { if (_Padding != value) { UpdateChangeHandler(_Padding, value); _Padding = value; OnPropertyChangedEx("Padding", VisualChangeType.Layout); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializePadding() { return (_Padding != null && _Padding.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetPadding() { Padding = null; } #endregion #region RowHeaderStyle /// /// Gets or sets the GroupHeader RowHeader Style /// [Category("Appearance")] [Description("Indicates the GroupHeader RowHeader Style")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public RowHeaderVisualStyle RowHeaderStyle { get { if (_RowHeaderStyle == null) { _RowHeaderStyle = RowHeaderVisualStyle.Empty; UpdateChangeHandler(null, _RowHeaderStyle); } return (_RowHeaderStyle); } set { if (_RowHeaderStyle != value) { UpdateChangeHandler(_RowHeaderStyle, value); _RowHeaderStyle = value; OnPropertyChangedEx("RowHeaderStyle", VisualChangeType.Render); } } } #endregion #region TextColor /// /// Gets or sets the Text color /// [Category("Appearance"), Description("Indicates the Text color")] public Color TextColor { get { return (_TextColor); } set { if (_TextColor != value) { _TextColor = value; OnPropertyChangedEx("TextColor", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeTextColor() { return (_TextColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetTextColor() { _TextColor = Color.Empty; } #endregion #region UnderlineColor /// /// Gets or sets the text Underline Color /// [Description("Indicates the text Underline Color")] public Color UnderlineColor { get { return (_UnderlineColor); } set { if (_UnderlineColor != value) { _UnderlineColor = value; OnPropertyChangedEx("UnderlineColor", VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeUnderlineColor() { return (_UnderlineColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetUnderlineColor() { _UnderlineColor = Color.Empty; } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(GroupHeaderVisualStyle style) { base.ApplyStyle(style); if (style.Alignment != Alignment.NotSet) Alignment = style.Alignment; if (style.AllowWrap != Tbool.NotSet) AllowWrap = style.AllowWrap; if (style._Background != null && style._Background.IsEmpty == false) Background = style._Background.Copy(); if (style.Font != null) Font = style.Font; if (style._Padding != null && style._Padding.IsEmpty == false) Padding = style._Padding.Copy(); if (style.TextColor.IsEmpty == false) TextColor = style.TextColor; if (style.UnderlineColor.IsEmpty == false) UnderlineColor = style.UnderlineColor; if (style._RowHeaderStyle != null) RowHeaderStyle.ApplyStyle(style._RowHeaderStyle); } #endregion #region GetTextFormatFlags internal eTextFormat GetTextFormatFlags() { eTextFormat tf = eTextFormat.WordEllipsis | eTextFormat.NoPadding | eTextFormat.NoPrefix; if (AllowWrap == Tbool.True) tf |= eTextFormat.WordBreak; switch (Alignment) { case Alignment.TopCenter: tf |= eTextFormat.HorizontalCenter; break; case Alignment.TopRight: tf |= eTextFormat.Right; break; case Alignment.MiddleLeft: tf |= eTextFormat.VerticalCenter; break; case Alignment.MiddleCenter: tf |= eTextFormat.HorizontalCenter; tf |= eTextFormat.VerticalCenter; break; case Alignment.MiddleRight: tf |= eTextFormat.Right; tf |= eTextFormat.VerticalCenter; break; case Alignment.BottomLeft: tf |= eTextFormat.Bottom; break; case Alignment.BottomCenter: tf |= eTextFormat.Bottom; tf |= eTextFormat.HorizontalCenter; break; case Alignment.BottomRight: tf |= eTextFormat.Bottom; tf |= eTextFormat.Right; break; } return (tf); } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new GroupHeaderVisualStyle Copy() { GroupHeaderVisualStyle copy = new GroupHeaderVisualStyle(); CopyTo(copy); return (copy); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(GroupHeaderVisualStyle copy) { base.CopyTo(copy); copy.Alignment = _Alignment; copy.AllowWrap = _AllowWrap; if (_Background != null) copy.Background = _Background.Copy(); if (_Font != null) copy.Font = (Font)_Font.Clone(); if (_Padding != null) copy.Padding = _Padding.Copy(); copy.TextColor = _TextColor; copy.UnderlineColor = _UnderlineColor; if (_RowHeaderStyle != null) copy.RowHeaderStyle = _RowHeaderStyle.Copy(); } #endregion #region IDisposable /// /// Dispose /// public override void Dispose() { Background = null; Padding = null; RowHeaderStyle = null; base.Dispose(); } #endregion } }