using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace DevComponents.DotNetBar.Charts.Style { /// /// Represents the visual style of an element. /// [TypeConverter(typeof(VisualStylesConverter))] public class ChartTitleVisualStyle : ContainerVisualStyle { #region Private variables private int _MaxLineCount = -1; private Tbool _Stretch = Tbool.NotSet; #endregion #region Public properties #region MaxLineCount /// /// Gets or sets the maximum number of Text lines. /// [DefaultValue(-1), Category("Appearance")] [Description("Indicates the maximum number of Text lines.")] public int MaxLineCount { get { return (_MaxLineCount); } set { if (value != _MaxLineCount) { _MaxLineCount = value; OnPropertyChangedEx("MaxLineCount", VisualChangeType.Layout); } } } #endregion #region Stretch /// /// Gets or sets whether text is 'stretched' to consume entire XyAlignment area. /// [DefaultValue(Tbool.NotSet), Category("Appearance")] [Description("Indicates whether text is 'stretched' to consume entire XyAlignment area.")] public Tbool Stretch { get { return (_Stretch); } set { if (_Stretch != value) { _Stretch = value; OnPropertyChangedEx("Stretch", 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 override bool IsEmpty { get { return ((_MaxLineCount < 0) && (_Stretch == Tbool.NotSet) && (base.IsEmpty == true)); } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(ChartTitleVisualStyle style) { if (style != null) { base.ApplyStyle(style); if (style.MaxLineCount > 0) _MaxLineCount = style.MaxLineCount; if (style.Stretch != Tbool.NotSet) _Stretch = style.Stretch; } } #endregion #region ApplyDefaults public override void ApplyDefaults() { base.ApplyDefaults(); if (TextColor.IsEmpty) TextColor = Color.Black; if (MaxLineCount < 0) MaxLineCount = 3; } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new ChartTitleVisualStyle Copy() { ChartTitleVisualStyle style = new ChartTitleVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(ChartTitleVisualStyle style) { base.CopyTo(style); style.MaxLineCount = _MaxLineCount; style.Stretch = _Stretch; } #endregion #region GetSerialData internal override SerialElementCollection GetSerialData(string serialName) { SerialElementCollection sec = new SerialElementCollection(); if (serialName != null) { if (serialName.Equals("") == true) serialName = "ChartTitleVisualStyle"; sec.AddStartElement(serialName); } sec.AddValue("MaxLineCount", MaxLineCount, -1); sec.AddValue("Stretch", Stretch, Tbool.NotSet); sec.AddElement(base.GetSerialData(null)); if (serialName != null) sec.AddEndElement(serialName); return (sec); } #endregion #region PutSerialData #region ProcessValue internal override void ProcessValue(SerialElement se) { switch (se.Name) { case "MaxLineCount": MaxLineCount = int.Parse(se.StringValue); break; case "Stretch": Stretch = (Tbool)se.GetValueEnum(typeof(Tbool)); break; default: base.ProcessValue(se); break; } } #endregion #endregion #region IDisposable /// /// Dispose /// public override void Dispose() { base.Dispose(); } #endregion } #region RotateDegrees /// /// Specifies the degrees to rotate the element. /// public enum RotateDegrees { /// /// Not set /// NotSet = -1, /// /// None /// None, /// /// Rotate as needed /// Auto, /// /// Rotate 90 degrees /// Rotate90, /// /// Rotate 180 degrees /// Rotate180, /// /// Rotate 270 degrees /// Rotate270, } #endregion }