DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,444 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Tickmark Label element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class TickmarkLabelVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Font _Font;
|
||||
|
||||
private Tbool _AllowWrap = Tbool.NotSet;
|
||||
|
||||
private Color _TextColor = Color.Empty;
|
||||
private Alignment _TextAlignment = Alignment.NotSet;
|
||||
private string _TextFormat;
|
||||
|
||||
private int _MaxLineCount = -1;
|
||||
private int _MaxWidth = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AllowWrap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether text wrapping is permitted
|
||||
/// </summary>
|
||||
[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 Font
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style Font
|
||||
/// </summary>
|
||||
[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 MaxLineCount
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of Label Text lines.
|
||||
/// </summary>
|
||||
[DefaultValue(-1), Category("Appearance")]
|
||||
[Description("Indicates the maximum number of Label Text lines.")]
|
||||
public int MaxLineCount
|
||||
{
|
||||
get { return (_MaxLineCount); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MaxLineCount)
|
||||
{
|
||||
_MaxLineCount = value;
|
||||
|
||||
OnPropertyChangedEx("MaxLineCount", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MaxWidth
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum width of the lable.
|
||||
/// </summary>
|
||||
[DefaultValue(-1), Category("Appearance")]
|
||||
[Description("Indicates the maximum width of the lable.")]
|
||||
public int MaxWidth
|
||||
{
|
||||
get { return (_MaxWidth); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MaxWidth)
|
||||
{
|
||||
_MaxWidth = value;
|
||||
|
||||
OnPropertyChangedEx("MaxWidth", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextAlignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the axis Text
|
||||
/// </summary>
|
||||
[DefaultValue(Alignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the alignment of the axis Text.")]
|
||||
public Alignment TextAlignment
|
||||
{
|
||||
get { return (_TextAlignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextAlignment != value)
|
||||
{
|
||||
_TextAlignment = value;
|
||||
|
||||
OnPropertyChangedEx("TextAlignment", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Text color
|
||||
/// </summary>
|
||||
[Description("Indicates the Text color")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return (_TextColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextColor != value)
|
||||
{
|
||||
_TextColor = value;
|
||||
|
||||
OnPropertyChangedEx("TextColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeTextColor()
|
||||
{
|
||||
return (_TextColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetTextColor()
|
||||
{
|
||||
TextColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextFormat
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Text Format specifier
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
[Description("Indicates the Text Format specifier")]
|
||||
public string TextFormat
|
||||
{
|
||||
get { return (_TextFormat); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextFormat != value)
|
||||
{
|
||||
_TextFormat = value;
|
||||
|
||||
OnPropertyChangedEx("TextFormat", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the style is logically Empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("Gets whether the style is logically Empty.")]
|
||||
public override bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((_AllowWrap == Tbool.NotSet) &&
|
||||
(_Font == null) &&
|
||||
(_MaxLineCount < 0) &&
|
||||
(_MaxWidth < 0) &&
|
||||
(_TextAlignment == Alignment.NotSet) &&
|
||||
(_TextColor.IsEmpty == true) &&
|
||||
(string.IsNullOrEmpty(_TextFormat) == true) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTextFormatFlags
|
||||
|
||||
internal eTextFormat GetTextFormatFlags()
|
||||
{
|
||||
eTextFormat tf = eTextFormat.WordEllipsis |
|
||||
eTextFormat.NoPadding | eTextFormat.NoPrefix;
|
||||
|
||||
if (AllowWrap == Tbool.True)
|
||||
tf |= eTextFormat.WordBreak;
|
||||
|
||||
tf |= eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter;
|
||||
|
||||
return (tf);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetStringFormatFlags
|
||||
|
||||
internal void GetStringFormatFlags(StringFormat sf)
|
||||
{
|
||||
if (AllowWrap == Tbool.False)
|
||||
sf.FormatFlags |= StringFormatFlags.NoWrap;
|
||||
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(TickmarkLabelVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.AllowWrap != Tbool.NotSet)
|
||||
AllowWrap = style.AllowWrap;
|
||||
|
||||
if (style.Font != null)
|
||||
Font = style.Font;
|
||||
|
||||
if (style.MaxLineCount > 0)
|
||||
MaxLineCount = style.MaxLineCount;
|
||||
|
||||
if (style.MaxWidth > 0)
|
||||
MaxWidth = style.MaxWidth;
|
||||
|
||||
if (style.TextAlignment != Alignment.NotSet)
|
||||
TextAlignment = style.TextAlignment;
|
||||
|
||||
if (style.TextColor.IsEmpty == false)
|
||||
TextColor = style.TextColor;
|
||||
|
||||
if (string.IsNullOrEmpty(style.TextFormat) == false)
|
||||
TextFormat = style.TextFormat;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new TickmarkLabelVisualStyle Copy()
|
||||
{
|
||||
TickmarkLabelVisualStyle style = new TickmarkLabelVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(TickmarkLabelVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AllowWrap = _AllowWrap;
|
||||
|
||||
style.Font = (_Font != null) ? (Font)_Font.Clone() : null;
|
||||
|
||||
style.MaxLineCount = _MaxLineCount;
|
||||
style.MaxWidth = _MaxWidth;
|
||||
|
||||
style.TextAlignment = _TextAlignment;
|
||||
style.TextColor = _TextColor;
|
||||
style.TextFormat = _TextFormat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "TickmarkLabelVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("AllowWrap", AllowWrap, Tbool.NotSet);
|
||||
|
||||
if (_Font != null)
|
||||
sec.AddValue("Font", XmlSerializableFont.ConvertToString(Font));
|
||||
|
||||
sec.AddValue("MaxLineCount", MaxLineCount, -1);
|
||||
sec.AddValue("MaxWidth", MaxWidth, -1);
|
||||
|
||||
sec.AddValue("TextAlignment", TextAlignment, Alignment.NotSet);
|
||||
sec.AddValue("TextColor", TextColor, Color.Empty);
|
||||
sec.AddValue("TextFormat", TextFormat, null);
|
||||
|
||||
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 "AllowWrap":
|
||||
AllowWrap = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
case "Font":
|
||||
Font = XmlSerializableFont.ConvertFromString(se.StringValue);
|
||||
break;
|
||||
|
||||
case "MaxLineCount":
|
||||
MaxLineCount = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "MaxWidth":
|
||||
MaxWidth = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "TextAlignment":
|
||||
TextAlignment = (Alignment)se.GetValueEnum(typeof(Alignment));
|
||||
break;
|
||||
|
||||
case "TextColor":
|
||||
TextColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "TextFormat":
|
||||
TextFormat = se.StringValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user