DotNet 4.8.1 build of DotNetBar
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
using DevComponents.Charts.TextMarkup;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the collection of ChartAnnotations.
|
||||
/// </summary>
|
||||
[Editor("DevComponents.ChartControl.Design.AnnotationCollectionEditor, DevComponents.ChartControl.Design, " +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
|
||||
public class ChartAnnotationCollection : CustomNamedCollection<Annotation>
|
||||
{
|
||||
}
|
||||
|
||||
public class Annotation : ChartNote
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private States _States;
|
||||
|
||||
private float _ShapeRotation;
|
||||
|
||||
private float _ConnectorRotation;
|
||||
private float _ConnectorLength;
|
||||
|
||||
private AnnotationVisualStyles _AnnotationVisualStyles;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AnnotationVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles for the Annotation.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual styles for the Annotation.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public AnnotationVisualStyles AnnotationVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AnnotationVisualStyles == null)
|
||||
{
|
||||
_AnnotationVisualStyles = new AnnotationVisualStyles();
|
||||
|
||||
StyleVisualChangeHandler(null, _AnnotationVisualStyles);
|
||||
}
|
||||
|
||||
return (_AnnotationVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AnnotationVisualStyles != value)
|
||||
{
|
||||
AnnotationVisualStyles oldValue = _AnnotationVisualStyles;
|
||||
|
||||
_AnnotationVisualStyles = value;
|
||||
|
||||
OnStyleChanged("AnnotationVisualStyles", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConnectorLength
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the length of the Annotation Connector.
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the length of the Annotation Connector.")]
|
||||
public float ConnectorLength
|
||||
{
|
||||
get { return (_ConnectorLength); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ConnectorLength != value)
|
||||
{
|
||||
_ConnectorLength = value;
|
||||
|
||||
OnPropertyChangedEx("ConnectorLength", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConnectorRotation
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the rotation of the Annotation Connector.
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the rotation of the Annotation Connector.")]
|
||||
public float ConnectorRotation
|
||||
{
|
||||
get { return (_ConnectorRotation); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ConnectorRotation != value)
|
||||
{
|
||||
_ConnectorRotation = value;
|
||||
|
||||
OnPropertyChangedEx("ConnectorRotation", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShapeRotation
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the rotation of the Annotation Shape.
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the rotation of the Annotation Shape.")]
|
||||
public float ShapeRotation
|
||||
{
|
||||
get { return (_ShapeRotation); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ShapeRotation != value)
|
||||
{
|
||||
_ShapeRotation = value;
|
||||
|
||||
OnPropertyChangedEx("ShapeRotation", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region Annotation States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region AnnotationShape
|
||||
|
||||
public enum AnnotationShape
|
||||
{
|
||||
NotSet = 0,
|
||||
|
||||
Ellipse,
|
||||
Rectangular,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConnectorShape
|
||||
|
||||
public enum ConnectorShape
|
||||
{
|
||||
NotSet = 0,
|
||||
|
||||
None,
|
||||
|
||||
Arrow,
|
||||
Line,
|
||||
Tail,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,895 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Crosshair element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class ChartCrosshair : ChartVisualElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private States _States;
|
||||
|
||||
private PointIntersectMode _PointIntersectMode = PointIntersectMode.Edge;
|
||||
private int _PointIntersectMargin = 2;
|
||||
|
||||
private AxisOrientation _AxisOrientation = AxisOrientation.X;
|
||||
private CrosshairLabelMode _CrosshairLabelMode = CrosshairLabelMode.Common;
|
||||
|
||||
private CrosshairVisualStyle _CrosshairVisualStyle;
|
||||
private EffectiveStyle<CrosshairVisualStyle> _EffectiveCrosshairStyle;
|
||||
|
||||
private CrosshairValueVisualStyle _CrosshairLabelVisualStyle;
|
||||
private EffectiveStyle<CrosshairValueVisualStyle> _EffectiveCrosshairLabelStyle;
|
||||
|
||||
#endregion
|
||||
|
||||
public ChartCrosshair()
|
||||
{
|
||||
InitDefaultStates();
|
||||
|
||||
_EffectiveCrosshairStyle = new EffectiveStyle<CrosshairVisualStyle>(this);
|
||||
_EffectiveCrosshairLabelStyle = new EffectiveStyle<CrosshairValueVisualStyle>(this);
|
||||
}
|
||||
|
||||
#region InitDefaultStates
|
||||
|
||||
private void InitDefaultStates()
|
||||
{
|
||||
SetState(States.ShowCrosshairLabelMarkers, true);
|
||||
SetState(States.ShowGroupHeader, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AxisOrientation
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the axis orientation driving the crosshair display.
|
||||
/// </summary>
|
||||
[DefaultValue(AxisOrientation.X), Category("Appearance")]
|
||||
[Description("Indicates the axis orientation driving the crosshair display.")]
|
||||
public AxisOrientation AxisOrientation
|
||||
{
|
||||
get { return (_AxisOrientation); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _AxisOrientation)
|
||||
{
|
||||
_AxisOrientation = value;
|
||||
|
||||
OnPropertyChanged("AxisOrientation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CrosshairLabelMode
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the mode used to display the Crosshair label.
|
||||
/// </summary>
|
||||
[DefaultValue(CrosshairLabelMode.Common), Category("Behavior")]
|
||||
[Description("Indicates the mode used to display the Crosshair label.")]
|
||||
public CrosshairLabelMode CrosshairLabelMode
|
||||
{
|
||||
get { return (_CrosshairLabelMode); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _CrosshairLabelMode)
|
||||
{
|
||||
_CrosshairLabelMode = value;
|
||||
|
||||
OnPropertyChangedEx("CrosshairLabelMode", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PointIntersectMode
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the the Crosshair point intersection mode.
|
||||
/// </summary>
|
||||
[DefaultValue(PointIntersectMode.Edge), Category("Behavior")]
|
||||
[Description("Indicates the Crosshair point intersection mode.")]
|
||||
public PointIntersectMode PointIntersectMode
|
||||
{
|
||||
get { return (_PointIntersectMode); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _PointIntersectMode)
|
||||
{
|
||||
_PointIntersectMode = value;
|
||||
|
||||
OnPropertyChangedEx("PointIntersectMode", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PointIntersectMargin
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the the Crosshair point intersection margin.
|
||||
/// </summary>
|
||||
[DefaultValue(2), Category("Layout")]
|
||||
[Description("Indicates the Crosshair point intersection margin.")]
|
||||
public int PointIntersectMargin
|
||||
{
|
||||
get { return (_PointIntersectMargin); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _PointIntersectMargin)
|
||||
{
|
||||
_PointIntersectMargin = value;
|
||||
|
||||
OnPropertyChangedEx("PointIntersectMargin", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CrosshairLabelVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default visual style to be used for Crosshair
|
||||
/// values rendered on the X and Y axes.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates visual style to be used for Crosshair values rendered on the X and Y axes")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public CrosshairValueVisualStyle CrosshairLabelVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CrosshairLabelVisualStyle == null)
|
||||
{
|
||||
_CrosshairLabelVisualStyle = new CrosshairValueVisualStyle();
|
||||
|
||||
StyleVisualChangeHandler(null, _CrosshairLabelVisualStyle);
|
||||
}
|
||||
|
||||
return (_CrosshairLabelVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_CrosshairLabelVisualStyle != value)
|
||||
{
|
||||
CrosshairValueVisualStyle oldValue = _CrosshairLabelVisualStyle;
|
||||
_CrosshairLabelVisualStyle = value;
|
||||
|
||||
OnVisualStyleChanged("CrosshairLabelVisualStyle", oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CrosshairVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Crosshair.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Crosshair.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public CrosshairVisualStyle CrosshairVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CrosshairVisualStyle == null)
|
||||
{
|
||||
_CrosshairVisualStyle = new CrosshairVisualStyle();
|
||||
|
||||
StyleVisualChangeHandler(null, _CrosshairVisualStyle);
|
||||
}
|
||||
|
||||
return (_CrosshairVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_CrosshairVisualStyle != value)
|
||||
{
|
||||
CrosshairVisualStyle oldValue = _CrosshairVisualStyle;
|
||||
|
||||
_CrosshairVisualStyle = value;
|
||||
|
||||
OnVisualStyleChanged("CrosshairVisualStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EffectiveCrosshairLabelStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the Crosshair label's Effective (cached, composite) style.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public CrosshairValueVisualStyle EffectiveCrosshairLabelStyle
|
||||
{
|
||||
get { return (_EffectiveCrosshairLabelStyle.Style); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EffectiveCrosshairStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the Crosshair's Effective (cached, composite) style.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public CrosshairVisualStyle EffectiveCrosshairStyle
|
||||
{
|
||||
get { return (_EffectiveCrosshairStyle.Style); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HighlightPoints
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether series points are highlighted
|
||||
/// when the Crosshair cursor intersects with them.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether series points are highlighted when the Crosshair cursor intersects with them.")]
|
||||
public bool HighlightPoints
|
||||
{
|
||||
get { return (TestState(States.HighlightPoints)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != HighlightPoints)
|
||||
{
|
||||
SetState(States.HighlightPoints, value);
|
||||
|
||||
OnPropertyChangedEx("HighlightPoints", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HighlightSinglePoint
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether only single series points are highlighted
|
||||
/// when the Crosshair cursor intersects with them.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether only single series points are highlighted when the Crosshair cursor intersects with them.")]
|
||||
public bool HighlightSinglePoint
|
||||
{
|
||||
get { return (TestState(States.HighlightSinglePoint)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != HighlightSinglePoint)
|
||||
{
|
||||
SetState(States.HighlightSinglePoint, value);
|
||||
|
||||
OnPropertyChangedEx("HighlightSinglePoint", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowValueXLabels
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether ValueX Labels are shown.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether ValueX Labels are shown.")]
|
||||
public bool ShowValueXLabels
|
||||
{
|
||||
get { return (TestState(States.ShowValueXLabels)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowValueXLabels)
|
||||
{
|
||||
SetState(States.ShowValueXLabels, value);
|
||||
|
||||
OnPropertyChangedEx("ShowValueXLabels", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowValueXLine
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether a ValueX line is shown.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether a ValueX line is shown.")]
|
||||
public bool ShowValueXLine
|
||||
{
|
||||
get { return (TestState(States.ShowValueXLine)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowValueXLine)
|
||||
{
|
||||
SetState(States.ShowValueXLine, value);
|
||||
|
||||
OnPropertyChangedEx("ShowValueXLine", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowCrosshairLabelMarkers
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Crosshair label markers are shown.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance")]
|
||||
[Description("Indicates whether Crosshair label markers are shown.")]
|
||||
public bool ShowCrosshairLabelMarkers
|
||||
{
|
||||
get { return (TestState(States.ShowCrosshairLabelMarkers)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowCrosshairLabelMarkers)
|
||||
{
|
||||
SetState(States.ShowCrosshairLabelMarkers, value);
|
||||
|
||||
OnPropertyChangedEx("ShowCrosshairLabelMarkers", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowCrosshairLabels
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Crosshair labels are shown.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether Crosshair labels are shown.")]
|
||||
public bool ShowCrosshairLabels
|
||||
{
|
||||
get { return (TestState(States.ShowCrosshairLabels)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowCrosshairLabels)
|
||||
{
|
||||
SetState(States.ShowCrosshairLabels, value);
|
||||
|
||||
OnPropertyChangedEx("ShowCrosshairLabels", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowGroupHeaders
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Group Headers are shown for each series.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance")]
|
||||
[Description("Indicates whether Group Headers are shown for each series.")]
|
||||
public bool ShowGroupHeaders
|
||||
{
|
||||
get { return (TestState(States.ShowGroupHeader)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowGroupHeaders)
|
||||
{
|
||||
SetState(States.ShowGroupHeader, value);
|
||||
|
||||
OnPropertyChangedEx("ShowGroupHeaders", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowValueYLabels
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether a ValueY label is shown.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether a ValueY label is shown.")]
|
||||
public bool ShowValueYLabels
|
||||
{
|
||||
get { return (TestState(States.ShowValueYLabels)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowValueYLabels)
|
||||
{
|
||||
SetState(States.ShowValueYLabels, value);
|
||||
|
||||
OnPropertyChangedEx("ShowValueYLabels", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowValueYLine
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether a ValueY line is shown.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether a ValueY line is shown.")]
|
||||
public bool ShowValueYLine
|
||||
{
|
||||
get { return (TestState(States.ShowValueYLine)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowValueYLine)
|
||||
{
|
||||
SetState(States.ShowValueYLine, value);
|
||||
|
||||
OnPropertyChangedEx("ShowValueYLine", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style support
|
||||
|
||||
#region ApplyStyles
|
||||
|
||||
public override void ApplyStyles(BaseVisualStyle style)
|
||||
{
|
||||
base.ApplyStyles(style);
|
||||
|
||||
CrosshairVisualStyle cstyle = style as CrosshairVisualStyle;
|
||||
|
||||
if (cstyle != null)
|
||||
{
|
||||
ApplyParentStyles(cstyle, Parent as ChartContainer);
|
||||
|
||||
cstyle.ApplyStyle(CrosshairVisualStyle);
|
||||
|
||||
ApplyDefaultLineStyles(cstyle.ValueXLineStyle);
|
||||
ApplyDefaultLineStyles(cstyle.ValueYLineStyle);
|
||||
|
||||
if (cstyle.GroupHeaderFont == null)
|
||||
cstyle.GroupHeaderFont = SystemFonts.CaptionFont;
|
||||
|
||||
if (cstyle.GroupHeaderTextColor.IsEmpty)
|
||||
cstyle.GroupHeaderTextColor = Color.Black;
|
||||
|
||||
if (cstyle.Padding.IsEmpty == true)
|
||||
cstyle.Padding = new Style.Padding(4);
|
||||
|
||||
if (cstyle.BorderThickness <= 0)
|
||||
cstyle.BorderThickness = 1;
|
||||
|
||||
if (cstyle.BorderPattern == LinePattern.NotSet)
|
||||
cstyle.BorderPattern = LinePattern.Solid;
|
||||
|
||||
if (cstyle.BorderColor.IsEmpty == true)
|
||||
cstyle.BorderColor = Color.Black;
|
||||
|
||||
if (cstyle.Background.IsEmpty == true)
|
||||
cstyle.Background = new Background(Color.White);
|
||||
|
||||
if (cstyle.Font == null)
|
||||
cstyle.Font = SystemFonts.DefaultFont;
|
||||
}
|
||||
}
|
||||
|
||||
#region ApplyParentStyles
|
||||
|
||||
private void ApplyParentStyles(
|
||||
CrosshairVisualStyle pstyle, ChartContainer item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
ApplyParentStyles(pstyle, item.Parent as ChartContainer);
|
||||
|
||||
if (item is ChartPanel)
|
||||
pstyle.ApplyStyle(((ChartPanel)item).DefaultVisualStyles.CrosshairVisualStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pstyle.ApplyStyle(ChartControl.BaseVisualStyles.CrosshairVisualStyle);
|
||||
pstyle.ApplyStyle(ChartControl.DefaultVisualStyles.CrosshairVisualStyle);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaultLineStyles
|
||||
|
||||
private void ApplyDefaultLineStyles(ChartLineVisualStyle style)
|
||||
{
|
||||
if (style.LineColor.IsEmpty == true)
|
||||
style.LineColor = Color.Fuchsia;
|
||||
|
||||
if (style.LinePattern == LinePattern.NotSet)
|
||||
style.LinePattern = LinePattern.Solid;
|
||||
|
||||
if (style.LineWidth < 0)
|
||||
style.LineWidth = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
///<summary>
|
||||
///Invalidate the cached Styles
|
||||
///</summary>
|
||||
public void InvalidateStyle()
|
||||
{
|
||||
ClearEffectiveStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearEffectiveStyles
|
||||
|
||||
protected override void ClearEffectiveStyles()
|
||||
{
|
||||
_EffectiveCrosshairStyle.InvalidateStyle();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Crosshair States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
HighlightPoints = (1U << 0),
|
||||
HighlightSinglePoint = (1U << 1),
|
||||
|
||||
ShowValueXLabels = (1U << 2),
|
||||
ShowValueXLine = (1U << 3),
|
||||
|
||||
ShowCrosshairLabels = (1U << 4),
|
||||
ShowGroupHeader = (1U << 5),
|
||||
ShowCrosshairLabelMarkers = (1U << 6),
|
||||
|
||||
ShowValueYLabels = (1U << 7),
|
||||
ShowValueYLine = (1U << 8),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartCrosshair copy = new ChartCrosshair();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartCrosshair c = copy as ChartCrosshair;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.AxisOrientation = AxisOrientation;
|
||||
c.CrosshairLabelMode = CrosshairLabelMode;
|
||||
c.PointIntersectMode = PointIntersectMode;
|
||||
c.PointIntersectMargin = PointIntersectMargin;
|
||||
|
||||
c.CrosshairLabelVisualStyle = (_CrosshairLabelVisualStyle != null) ? CrosshairLabelVisualStyle.Copy() : null;
|
||||
c.CrosshairVisualStyle = (_CrosshairVisualStyle != null) ? CrosshairVisualStyle.Copy() : null;
|
||||
|
||||
c.HighlightPoints = HighlightPoints;
|
||||
c.HighlightSinglePoint = HighlightSinglePoint;
|
||||
|
||||
c.ShowValueXLabels = ShowValueXLabels;
|
||||
c.ShowValueXLine = ShowValueXLine;
|
||||
c.ShowCrosshairLabels = ShowCrosshairLabels;
|
||||
c.ShowGroupHeaders = ShowGroupHeaders;
|
||||
c.ShowValueYLabels = ShowValueYLabels;
|
||||
c.ShowValueYLine = ShowValueYLine;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartCrosshair";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("AxisOrientation", AxisOrientation, AxisOrientation.X);
|
||||
sec.AddValue("CrosshairLabelMode", CrosshairLabelMode, CrosshairLabelMode.Common);
|
||||
sec.AddValue("PointIntersectMode", PointIntersectMode, PointIntersectMode.Edge);
|
||||
sec.AddValue("PointIntersectMargin", PointIntersectMargin, 2);
|
||||
|
||||
if (_CrosshairLabelVisualStyle != null && _CrosshairLabelVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_CrosshairLabelVisualStyle.GetSerialData("CrosshairLabelVisualStyle"));
|
||||
|
||||
if (_CrosshairVisualStyle != null && _CrosshairVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_CrosshairVisualStyle.GetSerialData("CrosshairVisualStyle"));
|
||||
|
||||
sec.AddValue("HighlightPoints", HighlightPoints, false);
|
||||
sec.AddValue("HighlightSinglePoint", HighlightSinglePoint, false);
|
||||
|
||||
sec.AddValue("ShowValueXLabels", ShowValueXLabels, false);
|
||||
sec.AddValue("ShowValueXLine", ShowValueXLine, false);
|
||||
sec.AddValue("ShowCrosshairLabels", ShowCrosshairLabels, false);
|
||||
sec.AddValue("ShowGroupHeaders", ShowGroupHeaders, true);
|
||||
sec.AddValue("ShowValueYLabels", ShowValueYLabels, false);
|
||||
sec.AddValue("ShowValueYLine", ShowValueYLine, false);
|
||||
|
||||
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 "AxisOrientation":
|
||||
AxisOrientation = (AxisOrientation)se.GetValueEnum(typeof(AxisOrientation));
|
||||
break;
|
||||
|
||||
case "CrosshairLabelMode":
|
||||
CrosshairLabelMode = (CrosshairLabelMode)se.GetValueEnum(typeof(CrosshairLabelMode));
|
||||
break;
|
||||
|
||||
case "PointIntersectMode":
|
||||
PointIntersectMode = (PointIntersectMode)se.GetValueEnum(typeof(PointIntersectMode));
|
||||
break;
|
||||
|
||||
case "PointIntersectMargin":
|
||||
PointIntersectMargin = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "HighlightPoints":
|
||||
HighlightPoints = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "HighlightSinglePoint":
|
||||
HighlightSinglePoint = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowValueXLabels":
|
||||
ShowValueXLabels = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowValueXLine":
|
||||
ShowValueXLine = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowCrosshairLabels":
|
||||
ShowCrosshairLabels = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowGroupHeaders":
|
||||
ShowGroupHeaders = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowValueYLabels":
|
||||
ShowValueYLabels = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowValueYLine":
|
||||
ShowValueYLine = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "CrosshairLabelVisualStyle":
|
||||
sec.PutSerialData(CrosshairLabelVisualStyle);
|
||||
break;
|
||||
|
||||
case "CrosshairVisualStyle":
|
||||
sec.PutSerialData(CrosshairVisualStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
CrosshairLabelVisualStyle = null;
|
||||
CrosshairVisualStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region CrosshairLabelMode
|
||||
|
||||
public enum CrosshairLabelMode
|
||||
{
|
||||
/// <summary>
|
||||
/// A common Crosshair label is shown for all series
|
||||
/// </summary>
|
||||
Common,
|
||||
|
||||
/// <summary>
|
||||
/// A crosshair label is shown for the nearest series
|
||||
/// </summary>
|
||||
NearestSeries,
|
||||
|
||||
/// <summary>
|
||||
/// A crosshair label is shown for each series
|
||||
/// </summary>
|
||||
EachSeries,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CrosshairLabelPosition
|
||||
|
||||
public enum CrosshairLabelPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// Crosshair labels positioned relative to the Chart
|
||||
/// </summary>
|
||||
ChartRelative,
|
||||
|
||||
/// <summary>
|
||||
/// Crosshair labels positioned relative to the Mouse
|
||||
/// </summary>
|
||||
MouseRelative,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PointIntersectMode
|
||||
|
||||
public enum PointIntersectMode
|
||||
{
|
||||
/// <summary>
|
||||
/// From center.
|
||||
/// </summary>
|
||||
Center,
|
||||
|
||||
/// <summary>
|
||||
/// From edge.
|
||||
/// </summary>
|
||||
Edge,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,261 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// ChartAxisLable
|
||||
/// </summary>
|
||||
public class ChartAxisLable : ChartVisualElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private States _States;
|
||||
|
||||
private string _Text;
|
||||
private int _FixedHeight;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region FixedHeight
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fixed Text height of the label (0 to auto-size)
|
||||
/// </summary>
|
||||
[DefaultValue(0), Category("Layout")]
|
||||
[Description("Indicates the fixed Text height of the label (0 to auto-size)")]
|
||||
public int FixedHeight
|
||||
{
|
||||
get { return (_FixedHeight); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _FixedHeight)
|
||||
{
|
||||
_FixedHeight = value;
|
||||
|
||||
OnPropertyChangedEx("FixedHeight", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label Text.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance")]
|
||||
[Description("Indicates the label Text.")]
|
||||
public string Text
|
||||
{
|
||||
get { return (_Text); }
|
||||
|
||||
set
|
||||
{
|
||||
_Text = value;
|
||||
|
||||
OnPropertyChangedEx("Text", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse handling
|
||||
|
||||
#region OnMouseEnter
|
||||
|
||||
protected override bool OnMouseEnter(EventArgs e)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseLeave
|
||||
|
||||
protected override bool OnMouseLeave(EventArgs e)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseMove
|
||||
|
||||
protected override bool OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
ChartCursor = Cursors.Default;
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseDown
|
||||
|
||||
protected override bool OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseUp
|
||||
|
||||
protected override bool OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartAxisLable copy = new ChartAxisLable();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartAxisLable c = copy as ChartAxisLable;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.FixedHeight = FixedHeight;
|
||||
c.Text = Text;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "BaseChart";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("FixedHeight", FixedHeight, 0);
|
||||
sec.AddValue("Text", Text, 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 "FixedHeight":
|
||||
FixedHeight = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "Text":
|
||||
Text = se.StringValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
EnableTextMarkup = (1U << 0),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the layout information for chart layout pass
|
||||
/// </summary>
|
||||
public class ChartLayoutInfo
|
||||
{
|
||||
#region Public variables
|
||||
|
||||
public Graphics Graphics;
|
||||
|
||||
public Rectangle ClientBounds;
|
||||
public Rectangle LayoutBounds;
|
||||
|
||||
public Point ScrollOffset;
|
||||
|
||||
public bool LayoutBoundsAdjusted;
|
||||
|
||||
#endregion
|
||||
|
||||
public ChartLayoutInfo(Graphics graphics, Rectangle clientBounds)
|
||||
{
|
||||
Graphics = graphics;
|
||||
ClientBounds = clientBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,362 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.Charts.TextMarkup;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// ChartNote.
|
||||
/// </summary>
|
||||
public class ChartNote : ChartVisualElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private States _States;
|
||||
|
||||
private string _Text;
|
||||
private BodyElement _TextMarkup;
|
||||
private int _FixedHeight;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region EnableTextMarkup
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether text-markup support is enabled
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether text-markup support is enabled.")]
|
||||
public bool EnableTextMarkup
|
||||
{
|
||||
get { return (TestState(States.EnableTextMarkup)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (EnableTextMarkup != value)
|
||||
{
|
||||
SetState(States.EnableTextMarkup, value);
|
||||
|
||||
MarkupTextChanged();
|
||||
|
||||
OnPropertyChangedEx("EnableTextMarkup", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region MarkupTextChanged
|
||||
|
||||
private void MarkupTextChanged()
|
||||
{
|
||||
if (_TextMarkup != null)
|
||||
_TextMarkup.HyperLinkClick -= TextMarkupLinkClick;
|
||||
|
||||
_TextMarkup = null;
|
||||
|
||||
if (EnableTextMarkup == true)
|
||||
{
|
||||
if (MarkupParser.IsMarkup(_Text) == true)
|
||||
{
|
||||
_TextMarkup = MarkupParser.Parse(_Text);
|
||||
|
||||
if (_TextMarkup != null)
|
||||
_TextMarkup.HyperLinkClick += TextMarkupLinkClick;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextMarkupLinkClick
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a text markup link is clicked
|
||||
/// </summary>
|
||||
protected virtual void TextMarkupLinkClick(object sender, EventArgs e)
|
||||
{
|
||||
HyperLink link = sender as HyperLink;
|
||||
|
||||
if (link != null)
|
||||
ChartControl.DoChartTitleMarkupLinkClickEvent(this, link);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region PlainText
|
||||
|
||||
/// <summary>
|
||||
/// Gets text without text-markup (if text-markup is used in Text)
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string PlainText
|
||||
{
|
||||
get { return (_TextMarkup != null ? _TextMarkup.PlainText : _Text); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FixedHeight
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fixed Text height (0 to auto-size)
|
||||
/// </summary>
|
||||
[DefaultValue(0), Category("Layout")]
|
||||
[Description("Indicates the fixed Text height (0 to auto-size)")]
|
||||
public int FixedHeight
|
||||
{
|
||||
get { return (_FixedHeight); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _FixedHeight)
|
||||
{
|
||||
_FixedHeight = value;
|
||||
|
||||
OnPropertyChangedEx("FixedHeight", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item Text.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance")]
|
||||
[Description("Indicates the item Text.")]
|
||||
[Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public string Text
|
||||
{
|
||||
get { return (_Text); }
|
||||
|
||||
set
|
||||
{
|
||||
_Text = value;
|
||||
|
||||
MarkupTextChanged();
|
||||
|
||||
OnPropertyChangedEx("Text", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region TextMarkup
|
||||
|
||||
internal BodyElement TextMarkup
|
||||
{
|
||||
get { return (_TextMarkup); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse handling
|
||||
|
||||
#region OnMouseEnter
|
||||
|
||||
protected override bool OnMouseEnter(EventArgs e)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseLeave
|
||||
|
||||
protected override bool OnMouseLeave(EventArgs e)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseMove
|
||||
|
||||
protected override bool OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
ChartCursor = Cursors.Default;
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseDown
|
||||
|
||||
protected override bool OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseUp
|
||||
|
||||
protected override bool OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartNote copy = new ChartNote();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartNote c = copy as ChartNote;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.EnableTextMarkup = EnableTextMarkup;
|
||||
c.FixedHeight = FixedHeight;
|
||||
c.Text = Text;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartNote";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("EnableTextMarkup", EnableTextMarkup, false);
|
||||
sec.AddValue("FixedHeight", FixedHeight, 0);
|
||||
sec.AddValue("Text", Text, 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 "EnableTextMarkup":
|
||||
EnableTextMarkup = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "FixedHeight":
|
||||
FixedHeight = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "Text":
|
||||
Text = se.StringValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
EnableTextMarkup = (1U << 0),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the rendering information for chart render pass.
|
||||
/// </summary>
|
||||
public class ChartRenderInfo
|
||||
{
|
||||
#region Public properties
|
||||
|
||||
public readonly Graphics Graphics;
|
||||
public readonly Rectangle ClipRectangle;
|
||||
|
||||
#endregion
|
||||
|
||||
public ChartRenderInfo(Graphics graphics, Rectangle clipRectangle)
|
||||
{
|
||||
Graphics = graphics;
|
||||
ClipRectangle = clipRectangle;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,408 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.DotNetBar.Charts;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the collection of DataLabels.
|
||||
/// </summary>
|
||||
[Editor("DevComponents.Charts.Design.DataLabelCollectionEditor, DevComponents.Charts.Design, " +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
|
||||
public class DataLabelCollection : CustomNamedCollection<DataLabel>
|
||||
{
|
||||
#region GetUniqueName
|
||||
|
||||
public string GetUniqueName()
|
||||
{
|
||||
return (GetUniqueName("DataLabel"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
public class DataLabel : ChartVisualElement, IEffectiveStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _Text;
|
||||
|
||||
private DataLabelVisualStyle _DataLabelVisualStyle;
|
||||
private EffectiveStyle<DataLabelVisualStyle> _EffectiveDataLabelStyle;
|
||||
|
||||
private object _ValueX;
|
||||
private object _ValueY;
|
||||
|
||||
private BarLabelPosition _BarLabelPosition = BarLabelPosition.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// DataLabel
|
||||
/// </summary>
|
||||
/// <param name="sp">Associated SeriesPoint</param>
|
||||
/// <param name="text">Label text</param>
|
||||
public DataLabel(SeriesPoint sp, string text)
|
||||
: this(sp)
|
||||
{
|
||||
_Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DataLabel
|
||||
/// </summary>
|
||||
/// <param name="sp">Associated SeriesPoint</param>
|
||||
public DataLabel(SeriesPoint sp)
|
||||
: this()
|
||||
{
|
||||
if (sp.ValueX == null)
|
||||
throw new Exception("DataLabel Value X must be defined.");
|
||||
|
||||
if (sp.ValueY == null || sp.ValueY.Length == 0)
|
||||
throw new Exception("DataLabel Value Y must be defined.");
|
||||
|
||||
ValueX = sp.ValueX;
|
||||
ValueY = sp.ValueY[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DataLabel
|
||||
/// </summary>
|
||||
public DataLabel()
|
||||
{
|
||||
_EffectiveDataLabelStyle = new EffectiveStyle<DataLabelVisualStyle>(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region BarLabelPosition
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position of bar series labels.
|
||||
/// </summary>
|
||||
[DefaultValue(BarLabelPosition.NotSet), Category("Bar Display")]
|
||||
[Description("Indicates the position of bar series labels.")]
|
||||
public BarLabelPosition BarLabelPosition
|
||||
{
|
||||
get { return (_BarLabelPosition); }
|
||||
set { _BarLabelPosition = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DataLabelVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the data label.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the data label.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public DataLabelVisualStyle DataLabelVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DataLabelVisualStyle == null)
|
||||
{
|
||||
_DataLabelVisualStyle = new DataLabelVisualStyle();
|
||||
|
||||
StyleVisualChangeHandler(null, _DataLabelVisualStyle);
|
||||
}
|
||||
|
||||
return (_DataLabelVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_DataLabelVisualStyle != value)
|
||||
{
|
||||
DataLabelVisualStyle oldValue = _DataLabelVisualStyle;
|
||||
|
||||
_DataLabelVisualStyle = value;
|
||||
|
||||
OnVisualStyleChanged("DataLabelVisualStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EffectiveDataLabelStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the DataLabel effective (cached, composite) style.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("Indicates a reference to the DataLabel effective (cached, composite) style.")]
|
||||
public DataLabelVisualStyle EffectiveDataLabelStyle
|
||||
{
|
||||
get { return (_EffectiveDataLabelStyle.Style); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ValueX
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the X-Axis Value.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
[Description("Indicates the X-Axis Value.")]
|
||||
[TypeConverter("DevComponents.Charts.Design.PointValueConverter, DevComponents.Charts.Design," +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public object ValueX
|
||||
{
|
||||
get { return (_ValueX); }
|
||||
set { _ValueX = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ValueY
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Y-Axis Value.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
[Description("Indicates the Y-Axis Value.")]
|
||||
[TypeConverter("DevComponents.Charts.Design.PointValueConverter, DevComponents.Charts.Design," +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public object ValueY
|
||||
{
|
||||
get { return (_ValueY); }
|
||||
set { _ValueY = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the DataLabel text.
|
||||
///</summary>
|
||||
[DefaultValue(null), Category("Appearance")]
|
||||
[Description("Indicates the DataLabel text.")]
|
||||
public string Text
|
||||
{
|
||||
get { return (_Text); }
|
||||
|
||||
set
|
||||
{
|
||||
_Text = value;
|
||||
|
||||
OnPropertyChangedEx("Text", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style handling
|
||||
|
||||
#region ApplyStyles
|
||||
|
||||
public override void ApplyStyles(BaseVisualStyle style)
|
||||
{
|
||||
DataLabelVisualStyle dstyle = style as DataLabelVisualStyle;
|
||||
|
||||
if (dstyle != null)
|
||||
{
|
||||
ChartSeries series = Parent as ChartSeries;
|
||||
|
||||
dstyle.ApplyStyle(series.EffectiveDataLabelStyle);
|
||||
dstyle.ApplyStyle(DataLabelVisualStyle);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
///<summary>
|
||||
///Invalidate the cached Style definition
|
||||
///</summary>
|
||||
public void InvalidateStyle()
|
||||
{
|
||||
ClearEffectiveStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearEffectiveStyles
|
||||
|
||||
protected override void ClearEffectiveStyles()
|
||||
{
|
||||
if (_EffectiveDataLabelStyle.InvalidateStyle() == true)
|
||||
InvalidateLayout();
|
||||
|
||||
ChartXy chartXy = ParentChartContainer as ChartXy;
|
||||
|
||||
if (chartXy != null)
|
||||
chartXy.InvalidatePointLabels();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
DataLabel copy = new DataLabel();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
DataLabel c = copy as DataLabel;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.DataLabelVisualStyle =
|
||||
(_DataLabelVisualStyle != null) ? DataLabelVisualStyle.Copy() : null;
|
||||
|
||||
c.ValueX = ValueX;
|
||||
c.ValueY = ValueY;
|
||||
|
||||
c.Text = (Text != null) ? (string)Text.Clone() : null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "DataLabel";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_DataLabelVisualStyle != null && _DataLabelVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_DataLabelVisualStyle.GetSerialData("DataLabelVisualStyle"));
|
||||
|
||||
sec.AddDataValue("ValueX", ValueX, null);
|
||||
sec.AddDataValue("ValueY", ValueY, null);
|
||||
|
||||
sec.AddValue("Text", Text, 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 "ValueX":
|
||||
ValueX = se.DataValue;
|
||||
break;
|
||||
|
||||
case "ValueY":
|
||||
ValueY = se.DataValue;
|
||||
break;
|
||||
|
||||
case "Text":
|
||||
Text = se.StringValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "DataLabelVisualStyle":
|
||||
sec.PutSerialData(DataLabelVisualStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
DataLabelVisualStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,280 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a PieLabel (label associated with a pie data slice in the chart).
|
||||
/// </summary>
|
||||
public class PieLabel : IDisposable
|
||||
{
|
||||
#region Private data
|
||||
|
||||
private PieSeriesPoint _PieSeriesPoint;
|
||||
|
||||
private float _Angle;
|
||||
private Rectangle _Bounds;
|
||||
private Rectangle _ConnectorBounds;
|
||||
|
||||
private Point _PtBoxEdge;
|
||||
private Point _PtBoxBend;
|
||||
private Point _PtSliceEdge;
|
||||
|
||||
private double _Radius;
|
||||
private double _OuterRadius;
|
||||
|
||||
private string _Label;
|
||||
private Size _LabelSize;
|
||||
|
||||
private SliceOuterLabelVisualStyle _SliceLabelVisualStyle;
|
||||
|
||||
private States _States;
|
||||
|
||||
#endregion
|
||||
|
||||
public PieLabel(PieSeriesPoint sp, string label)
|
||||
{
|
||||
_PieSeriesPoint = sp;
|
||||
_Label = label;
|
||||
|
||||
InitDefaultStates();
|
||||
}
|
||||
|
||||
#region InitDefaultStates
|
||||
|
||||
private void InitDefaultStates()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Angle
|
||||
|
||||
/// <summary>
|
||||
/// Gets the angle used to display the point label
|
||||
/// associated with the data point.
|
||||
/// </summary>
|
||||
public float Angle
|
||||
{
|
||||
get { return (_Angle); }
|
||||
internal set { _Angle = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bounds
|
||||
|
||||
/// <summary>
|
||||
/// Gets the label text bounds.
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return (_Bounds); }
|
||||
internal set { _Bounds = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsLeftlabel
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the label is a left positioned
|
||||
/// label (with respect to the chart slice).
|
||||
/// </summary>
|
||||
public bool IsLeftlabel
|
||||
{
|
||||
get { return (!TestState(States.RightLabel)); }
|
||||
internal set { SetState(States.RightLabel, !value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsRightlabel
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the label is a right positioned
|
||||
/// label (with respect to the chart slice).
|
||||
/// </summary>
|
||||
public bool IsRightlabel
|
||||
{
|
||||
get { return (TestState(States.RightLabel)); }
|
||||
internal set { SetState(States.RightLabel, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Label
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label text
|
||||
/// </summary>
|
||||
public string Label
|
||||
{
|
||||
get { return (_Label); }
|
||||
internal set { _Label = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LabelSize
|
||||
|
||||
/// <summary>
|
||||
/// Gets the label size.
|
||||
/// </summary>
|
||||
public Size LabelSize
|
||||
{
|
||||
get { return (_LabelSize); }
|
||||
internal set { _LabelSize = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PieSeriesPoint
|
||||
|
||||
/// <summary>
|
||||
/// Gets the associated PieSeriesPoint.
|
||||
/// </summary>
|
||||
public PieSeriesPoint PieSeriesPoint
|
||||
{
|
||||
get { return (_PieSeriesPoint); }
|
||||
internal set { _PieSeriesPoint = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PtBoxBend
|
||||
|
||||
/// <summary>
|
||||
/// Gets the middle connector point located
|
||||
/// at the 'bend' of the connector.
|
||||
/// </summary>
|
||||
public Point PtBoxBend
|
||||
{
|
||||
get { return (_PtBoxBend); }
|
||||
internal set { _PtBoxBend = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PtBoxEdge
|
||||
|
||||
/// <summary>
|
||||
/// Gets the connector point located and the
|
||||
/// 'edge' of the label text bounding box.
|
||||
/// </summary>
|
||||
public Point PtBoxEdge
|
||||
{
|
||||
get { return (_PtBoxEdge); }
|
||||
internal set { _PtBoxEdge = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PtSliceEdge
|
||||
|
||||
/// <summary>
|
||||
/// Gets the initial connector point, located at
|
||||
/// the edge of the pie slice.
|
||||
/// </summary>
|
||||
public Point PtSliceEdge
|
||||
{
|
||||
get { return (_PtSliceEdge); }
|
||||
internal set { _PtSliceEdge = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SliceLabelVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current slice label VisualStyle for the label.
|
||||
/// </summary>
|
||||
public SliceOuterLabelVisualStyle LabelStyle
|
||||
{
|
||||
get { return (_SliceLabelVisualStyle); }
|
||||
internal set { _SliceLabelVisualStyle = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region ConnectorBounds
|
||||
|
||||
internal Rectangle ConnectorBounds
|
||||
{
|
||||
get { return (_ConnectorBounds); }
|
||||
set { _ConnectorBounds = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OuterRadius
|
||||
|
||||
internal double OuterRadius
|
||||
{
|
||||
get { return (_OuterRadius); }
|
||||
set { _OuterRadius = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Radius
|
||||
|
||||
internal double Radius
|
||||
{
|
||||
get { return (_Radius); }
|
||||
set { _Radius = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
RightLabel = (1U << 0),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.Charts.TextMarkup;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the collection of PieReferenceLines.
|
||||
/// </summary>
|
||||
[Editor("DevComponents.Charts.Design.PieReferenceCollectionEditor, DevComponents.Charts.Design, " +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
|
||||
public class PieReferenceLineCollection : CustomNamedCollection<PieReferenceLine>
|
||||
{
|
||||
#region GetUniqueName
|
||||
|
||||
/// <summary>
|
||||
/// Gets a unique (unused) reference line Name.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetUniqueName()
|
||||
{
|
||||
return (GetUniqueName("PieRefLine"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a reference line (a radial line on the chart
|
||||
/// that can be used to signify, or reference, a specific chart value).
|
||||
/// </summary>
|
||||
public class PieReferenceLine : ChartVisualElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private double _Value;
|
||||
|
||||
private PieReferenceLineVisualStyle _ReferenceLineVisualStyle;
|
||||
private EffectiveStyle<PieReferenceLineVisualStyle> _EffectiveStyle;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// PieReferenceLine
|
||||
/// </summary>
|
||||
public PieReferenceLine()
|
||||
{
|
||||
_EffectiveStyle = new EffectiveStyle<PieReferenceLineVisualStyle>(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PieReferenceLine
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public PieReferenceLine(string name)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PieReferenceLine
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="radialValue"></param>
|
||||
public PieReferenceLine(string name, double value)
|
||||
: this(name)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region EffectiveStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the ReferenceLine's Effective (cached, composite) style.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public PieReferenceLineVisualStyle EffectiveStyle
|
||||
{
|
||||
get { return (_EffectiveStyle.Style); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReferenceLineVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Reference Line.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the ReferenceLine.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public PieReferenceLineVisualStyle ReferenceLineVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ReferenceLineVisualStyle == null)
|
||||
{
|
||||
_ReferenceLineVisualStyle = new PieReferenceLineVisualStyle();
|
||||
|
||||
StyleVisualChangeHandler(null, _ReferenceLineVisualStyle);
|
||||
}
|
||||
|
||||
return (_ReferenceLineVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_ReferenceLineVisualStyle != value)
|
||||
{
|
||||
PieReferenceLineVisualStyle oldValue = _ReferenceLineVisualStyle;
|
||||
|
||||
_ReferenceLineVisualStyle = value;
|
||||
|
||||
OnVisualStyleChanged("ReferenceLineVisualStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Value
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the associated radial grid value of the reference line.
|
||||
///</summary>
|
||||
[DefaultValue(null), Category("Appearance")]
|
||||
[Description("Indicates the associated radial grid value of the reference line.")]
|
||||
//[TypeConverter("DevComponents.Charts.Design.PointValueConverter," +
|
||||
// "DevComponents.Charts.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public double Value
|
||||
{
|
||||
get { return (_Value); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _Value)
|
||||
{
|
||||
_Value = value;
|
||||
|
||||
OnPropertyChangedEx("Value", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#region RenderLine
|
||||
|
||||
internal void RenderLine(ChartRenderInfo renderInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateRender
|
||||
|
||||
public override void InvalidateRender()
|
||||
{
|
||||
ChartVisualElement cve = Parent as ChartVisualElement;
|
||||
|
||||
if (cve != null)
|
||||
cve.InvalidateRender();
|
||||
else
|
||||
base.InvalidateRender();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style handling
|
||||
|
||||
#region ApplyStyles
|
||||
|
||||
public override void ApplyStyles(BaseVisualStyle style)
|
||||
{
|
||||
ChartLineVisualStyle rstyle = style as ChartLineVisualStyle;
|
||||
|
||||
if (rstyle != null)
|
||||
{
|
||||
ApplyParentStyles(rstyle, Parent as ChartContainer);
|
||||
|
||||
rstyle.ApplyStyle(ReferenceLineVisualStyle);
|
||||
|
||||
if (rstyle.LineColor.IsEmpty == true)
|
||||
rstyle.LineColor = Color.Red;
|
||||
|
||||
if (rstyle.LineWidth < 0)
|
||||
rstyle.LineWidth = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#region ApplyParentStyles
|
||||
|
||||
private void ApplyParentStyles(ChartLineVisualStyle pstyle, ChartContainer item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
ApplyParentStyles(pstyle, item.Parent as ChartContainer);
|
||||
|
||||
ChartPanel chartPanel = item as ChartPanel;
|
||||
|
||||
if (chartPanel != null)
|
||||
{
|
||||
pstyle.ApplyStyle(chartPanel.DefaultVisualStyles.PieChartVisualStyle.ReferenceLineVisualStyle);
|
||||
}
|
||||
else if (item is PieChart)
|
||||
{
|
||||
PieChart pieChart = (PieChart)item;
|
||||
|
||||
pstyle.ApplyStyle(pieChart.ChartVisualStyle.ReferenceLineVisualStyle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pstyle.ApplyStyle(ChartControl.BaseVisualStyles.ReferenceLineVisualStyle);
|
||||
pstyle.ApplyStyle(ChartControl.DefaultVisualStyles.ReferenceLineVisualStyle);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
///<summary>
|
||||
///Invalidate the cached Style definition
|
||||
///</summary>
|
||||
public void InvalidateStyle()
|
||||
{
|
||||
ClearEffectiveStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearEffectiveStyles
|
||||
|
||||
protected override void ClearEffectiveStyles()
|
||||
{
|
||||
if (_EffectiveStyle.InvalidateStyle() == true)
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
PieReferenceLine copy = new PieReferenceLine();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
PieReferenceLine c = copy as PieReferenceLine;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.Value = Value;
|
||||
|
||||
c.ReferenceLineVisualStyle =
|
||||
(_ReferenceLineVisualStyle != null) ? ReferenceLineVisualStyle.Copy() : null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "PieReferenceLine";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_ReferenceLineVisualStyle != null && _ReferenceLineVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_ReferenceLineVisualStyle.GetSerialData("ReferenceLineVisualStyle"));
|
||||
|
||||
sec.AddValue("Value", Value, 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 "Value":
|
||||
Value = double.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "ReferenceLineVisualStyle":
|
||||
sec.PutSerialData(ReferenceLineVisualStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ReferenceLineVisualStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,918 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
public class PieRing : ILegendItem, ILegendItemEx, INotifyPropertyChanged
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _RingLevel;
|
||||
private int _RingWeight = -1;
|
||||
|
||||
private int _InnerRadius;
|
||||
private int _OuterRadius;
|
||||
private int _ExtentRadius;
|
||||
|
||||
private PieSeries _ChartSeries;
|
||||
private List<PieSeriesPoint> _Psps;
|
||||
|
||||
private ChartLegendItem _LegendItem;
|
||||
private string _LegendText;
|
||||
private ChartLegendItemVisualStyles _ChartLegendItemVisualStyles;
|
||||
|
||||
private string _Name;
|
||||
|
||||
private States _States;
|
||||
|
||||
#endregion
|
||||
|
||||
public PieRing()
|
||||
{
|
||||
InitDefaultStates();
|
||||
}
|
||||
|
||||
public PieRing(int ringLevel)
|
||||
: this()
|
||||
{
|
||||
RingLevel = ringLevel;
|
||||
}
|
||||
|
||||
#region InitDefaultStates
|
||||
|
||||
private void InitDefaultStates()
|
||||
{
|
||||
SetState(States.AllowDetach, true);
|
||||
SetState(States.AllowSelect, true);
|
||||
|
||||
SetState(States.CheckedInLegend, true);
|
||||
SetState(States.ShowInLegend, true);
|
||||
SetState(States.ShowInParentLegend, true);
|
||||
SetState(States.ShowMarkerInLegend, true);
|
||||
|
||||
SetState(States.Visible, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AllowDetach
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the element can be 'detached' from
|
||||
/// the center of the pie by the user. Defaults to true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior")]
|
||||
[Description("Indicates whether the element can be 'detached' from the center of the pie by the user. Defaults to true.")]
|
||||
public bool AllowDetach
|
||||
{
|
||||
get { return (TestState(States.AllowDetach)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != AllowDetach)
|
||||
{
|
||||
SetState(States.AllowDetach, value);
|
||||
|
||||
OnPropertyChanged("AllowDetach");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AllowSelect
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the ring can be selected by clicking on it. Defaults to true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior")]
|
||||
[Description("Indicates whether the ring can be selected by clicking on it. Defaults to true.")]
|
||||
public bool AllowSelect
|
||||
{
|
||||
get { return (TestState(States.AllowSelect)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != AllowSelect)
|
||||
{
|
||||
SetState(States.AllowSelect, value);
|
||||
|
||||
OnPropertyChanged("AllowSelect");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsDisplayed
|
||||
|
||||
///<summary>
|
||||
/// Gets whether the ring is displayed (based upon Visibility and Legend state).
|
||||
///</summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsDisplayed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ChartSeries != null)
|
||||
{
|
||||
PieChart pieChart = ChartSeries.Parent as PieChart;
|
||||
|
||||
if (pieChart != null)
|
||||
{
|
||||
ItemCheckAction ica = (pieChart != null)
|
||||
? pieChart.Legend.ItemCheckAction : ItemCheckAction.ShowItem;
|
||||
|
||||
return ((Visible == true) &&
|
||||
(ica == ItemCheckAction.None ||
|
||||
(ShowCheckBoxInLegend == false || CheckedInLegend == true)));
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Name
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user assigned Name of the item.
|
||||
/// </summary>
|
||||
[DefaultValue("")]
|
||||
[Description("Indicates the Name of the item.")]
|
||||
public virtual string Name
|
||||
{
|
||||
get { return (_Name); }
|
||||
set { _Name = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RingWeight
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the 'relative' thickness of the series ring, as
|
||||
/// compared to the relative thickness of other series
|
||||
/// rings.
|
||||
///</summary>
|
||||
[DefaultValue(-1), Category("Display")]
|
||||
[Description("Indicates the 'relative' thickness of the series ring, as compared to the relative thickness of other series rings.")]
|
||||
public int RingWeight
|
||||
{
|
||||
get { return (_RingWeight); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _RingWeight)
|
||||
{
|
||||
_RingWeight = value;
|
||||
|
||||
OnPropertyChangedEx("RingWeight", Style.VisualChangeType.Recalc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Visible
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets whether the item is visible
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance")]
|
||||
[Description("Indicates whether the item is visible")]
|
||||
public virtual bool Visible
|
||||
{
|
||||
get { return (TestState(States.Visible)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (Visible != value)
|
||||
{
|
||||
SetState(States.Visible, value);
|
||||
|
||||
OnPropertyChangedEx("Visible", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region ChartSeries
|
||||
|
||||
internal PieSeries ChartSeries
|
||||
{
|
||||
get { return (_ChartSeries); }
|
||||
set { _ChartSeries = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ExtentRadius
|
||||
|
||||
internal int ExtentRadius
|
||||
{
|
||||
get { return (_ExtentRadius); }
|
||||
set { _ExtentRadius = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InnerRadius
|
||||
|
||||
internal int InnerRadius
|
||||
{
|
||||
get { return (_InnerRadius); }
|
||||
set { _InnerRadius = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEnabled
|
||||
|
||||
internal bool IsEnabled
|
||||
{
|
||||
get { return (IsRingEnabled()); }
|
||||
}
|
||||
|
||||
#region IsRingEnabled
|
||||
|
||||
private bool IsRingEnabled()
|
||||
{
|
||||
if (ChartSeries != null)
|
||||
{
|
||||
int index = ChartSeries.PieRings.IndexOf(this);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
for (int i = index - 1; i >= 0; i--)
|
||||
{
|
||||
PieRing pieRing = ChartSeries.PieRings[i];
|
||||
|
||||
if (pieRing.IsDisplayed == false)
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
return (ChartSeries.IsDisplayed);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsInitialRing
|
||||
|
||||
internal bool IsInnerRing
|
||||
{
|
||||
get { return (TestState(States.InnerRing)); }
|
||||
set { SetState(States.InnerRing, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsOuterRing
|
||||
|
||||
internal bool IsOuterRing
|
||||
{
|
||||
get { return (TestState(States.OuterRing)); }
|
||||
set { SetState(States.OuterRing, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OuterRadius
|
||||
|
||||
internal int OuterRadius
|
||||
{
|
||||
get { return (_OuterRadius); }
|
||||
set { _OuterRadius = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Psps
|
||||
|
||||
internal List<PieSeriesPoint> Psps
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Psps == null)
|
||||
_Psps = new List<PieSeriesPoint>();
|
||||
|
||||
return (_Psps);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RingLevel
|
||||
|
||||
internal int RingLevel
|
||||
{
|
||||
get { return (_RingLevel); }
|
||||
set { _RingLevel = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSelectionCount
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of the visible selected pie series points.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetSelectionCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
foreach (PieSeriesPoint psp in Psps)
|
||||
{
|
||||
if (psp.Visible == true)
|
||||
{
|
||||
if (psp.IsSelected == true)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateRender
|
||||
|
||||
internal void InvalidateRender(PieChart pieChart)
|
||||
{
|
||||
foreach (PieSeriesPoint psp in Psps)
|
||||
pieChart.InvalidateRender(psp.PathBounds);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ILegendItem
|
||||
|
||||
#region ChartLegendItemVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles for the Legend item.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual styles for the Legend item.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLegendItemVisualStyles ChartLegendItemVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ChartLegendItemVisualStyles == null)
|
||||
{
|
||||
_ChartLegendItemVisualStyles = new ChartLegendItemVisualStyles();
|
||||
|
||||
StyleChangeHandler(null, _ChartLegendItemVisualStyles);
|
||||
}
|
||||
|
||||
return (_ChartLegendItemVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_ChartLegendItemVisualStyles != value)
|
||||
{
|
||||
ChartLegendItemVisualStyles oldValue = _ChartLegendItemVisualStyles;
|
||||
|
||||
_ChartLegendItemVisualStyles = value;
|
||||
|
||||
OnStyleChanged("ChartLegendItemVisualStyles", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckedInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the item is checked in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the item is checked in the Legend.")]
|
||||
public bool CheckedInLegend
|
||||
{
|
||||
get { return (TestState(States.CheckedInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != CheckedInLegend)
|
||||
{
|
||||
SetState(States.CheckedInLegend, value);
|
||||
|
||||
ChartSeries.InvalidateLayout();
|
||||
|
||||
if (LegendItem != null)
|
||||
LegendItem.UpdateCheckState();
|
||||
|
||||
foreach (PieSeriesPoint psp in Psps)
|
||||
{
|
||||
if (psp.LegendItem != null)
|
||||
psp.LegendItem.IsEnabled = psp.IsEnabled;
|
||||
}
|
||||
|
||||
OnPropertyChangedEx("CheckedInLegend", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowCheckBoxInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether a checkbox for the item is shown in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Legend")]
|
||||
[Description("Indicates whether a checkbox for the item is shown in the Legend.")]
|
||||
public bool ShowCheckBoxInLegend
|
||||
{
|
||||
get { return (TestState(States.ShowCheckBoxInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowCheckBoxInLegend)
|
||||
{
|
||||
SetState(States.ShowCheckBoxInLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowCheckBoxInLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the item is shown in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the item is shown in the Legend.")]
|
||||
public bool ShowInLegend
|
||||
{
|
||||
get { return (TestState(States.ShowInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowInLegend)
|
||||
{
|
||||
SetState(States.ShowInLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowInLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowInParentLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the item Line is shown in parent Legend(s).
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the item Line is shown in parent Legend(s).")]
|
||||
public bool ShowInParentLegend
|
||||
{
|
||||
get { return (TestState(States.ShowInParentLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowInParentLegend)
|
||||
{
|
||||
SetState(States.ShowInParentLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowInParentLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowMarkerInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the item Marker is shown in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the item Marker is shown in the Legend.")]
|
||||
public bool ShowMarkerInLegend
|
||||
{
|
||||
get { return (TestState(States.ShowMarkerInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowMarkerInLegend)
|
||||
{
|
||||
SetState(States.ShowMarkerInLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowMarkerInLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LegendItem
|
||||
|
||||
///<summary>
|
||||
/// Gets the item's parent LegendItem.
|
||||
///</summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("Indicates the item's parent LegendItem.")]
|
||||
public ChartLegendItem LegendItem
|
||||
{
|
||||
get { return (_LegendItem); }
|
||||
internal set { _LegendItem = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LegendText
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the text to display in the legend.
|
||||
///</summary>
|
||||
[DefaultValue(null), Category("Legend")]
|
||||
[Description("Indicates the text to display in the legend.")]
|
||||
[NotifyParentProperty(true)]
|
||||
public string LegendText
|
||||
{
|
||||
get { return (_LegendText); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _LegendText)
|
||||
{
|
||||
_LegendText = value;
|
||||
|
||||
OnPropertyChangedEx("LegendText", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLegendItem
|
||||
|
||||
/// <summary>
|
||||
/// Creates the LegendItem for the item.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ChartLegendItem GetLegendItem()
|
||||
{
|
||||
_LegendItem = null;
|
||||
|
||||
if (ShowInLegend == true)
|
||||
{
|
||||
_LegendItem = new ChartLegendItem();
|
||||
|
||||
if (CheckedInLegend == true)
|
||||
_LegendItem.CheckState = CheckState.Checked;
|
||||
|
||||
_LegendItem.Name = Name;
|
||||
_LegendItem.ItemText = LegendText;
|
||||
|
||||
if (string.IsNullOrEmpty(_LegendItem.Name) == true)
|
||||
_LegendItem.Name = "(PieRing " + (RingLevel + 1) + ")";
|
||||
|
||||
_LegendItem.IsEnabled = IsEnabled;
|
||||
|
||||
_LegendItem.ChartItems.Add(this);
|
||||
}
|
||||
|
||||
return (_LegendItem);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLegendItems
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of legend items associated with
|
||||
/// the item.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ChartLegendItem> GetLegendItems()
|
||||
{
|
||||
List<ChartLegendItem> list = new List<ChartLegendItem>();
|
||||
|
||||
for (int i = 0; i < Psps.Count; i++)
|
||||
{
|
||||
PieSeriesPoint psp = Psps[i];
|
||||
|
||||
if (psp.IsDisplayable == true)
|
||||
{
|
||||
List<ChartLegendItem> items = psp.GetLegendItems();
|
||||
|
||||
if (items != null && items.Count > 0)
|
||||
list.AddRange(items);
|
||||
}
|
||||
}
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLegendItemColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default color associated with the legend item.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Color GetLegendItemColor()
|
||||
{
|
||||
if (Psps.Count > 0)
|
||||
return (Psps[0].GetLegendItemColor());
|
||||
|
||||
return (ChartSeries.GetLegendItemColor());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderLegendItemMarker
|
||||
|
||||
/// <summary>
|
||||
/// Renders the Legend item Marker.
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="litem"></param>
|
||||
/// <param name="style"></param>
|
||||
public void RenderLegendItemMarker(Graphics g,
|
||||
ChartLegendItem litem, ChartLegendItemVisualStyle style)
|
||||
{
|
||||
Rectangle bounds = litem.MarkerBounds;
|
||||
bounds.Inflate(-1, -1);
|
||||
|
||||
bounds.Width--;
|
||||
bounds.Height--;
|
||||
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
if (IsEnabled == true)
|
||||
{
|
||||
Color color = GetLegendItemColor();
|
||||
|
||||
using (Pen pen = new Pen(color, 2))
|
||||
g.DrawEllipse(pen, bounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
Color color = style.DisabledMarkerBackground.Color1;
|
||||
|
||||
if (color.IsEmpty == true)
|
||||
color = style.DisabledTextColor;
|
||||
|
||||
if (color.IsEmpty == true)
|
||||
color = Color.LightGray;
|
||||
|
||||
using (Pen pen = new Pen(color, 2))
|
||||
g.DrawEllipse(pen, bounds);
|
||||
}
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
AllowSelect = (1U << 0),
|
||||
AllowDetach = (1U << 1),
|
||||
|
||||
InnerRing = (1U << 2),
|
||||
OuterRing = (1U << 3),
|
||||
|
||||
CheckedInLegend = (1U << 4),
|
||||
ShowInLegend = (1U << 5),
|
||||
ShowInParentLegend = (1U << 6),
|
||||
ShowCheckBoxInLegend = (1U << 7),
|
||||
ShowMarkerInLegend = (1U << 8),
|
||||
|
||||
Visible = (1U << 9),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
#region OnPropertyChanged
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnPropertyChanged(string s)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="changeType">invalidate</param>
|
||||
protected void OnPropertyChangedEx(string s, VisualChangeType changeType)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s, changeType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NotifyVisualParent
|
||||
|
||||
internal void NotifyVisualParent(object sender, VisualChangeType vct)
|
||||
{
|
||||
object parent = sender;
|
||||
|
||||
PieSeries series = ChartSeries;
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
if (vct == VisualChangeType.Layout)
|
||||
series.InvalidateLayout();
|
||||
else
|
||||
series.InvalidateRender();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnStyleChanged
|
||||
|
||||
protected virtual void OnStyleChanged(string property,
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
StyleChangeHandler(oldValue, newValue);
|
||||
|
||||
OnPropertyChanged(property);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleChangeHandler
|
||||
|
||||
protected void StyleChangeHandler(
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
oldValue.PropertyChanged -= StyleChanged;
|
||||
|
||||
if (newValue != null)
|
||||
newValue.PropertyChanged += StyleChanged;
|
||||
}
|
||||
|
||||
#region StyleChanged
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when one of element visual styles has property changes.
|
||||
/// Default implementation invalidates visual appearance of element.
|
||||
/// </summary>
|
||||
/// <param name="sender">VisualStyle that changed.</param>
|
||||
/// <param name="e">Event arguments.</param>
|
||||
protected void StyleChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
VisualChangeType changeType = ((VisualPropertyChangedEventArgs)e).ChangeType;
|
||||
|
||||
PieSeries series = ChartSeries;
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
if (series.ChartControl != null)
|
||||
series.ChartControl.GlobalUpdateCount++;
|
||||
|
||||
if (changeType == VisualChangeType.Layout)
|
||||
series.InvalidateLayout();
|
||||
else
|
||||
series.InvalidateRender();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateRender
|
||||
|
||||
public void InvalidateRender()
|
||||
{
|
||||
PieSeries series = ChartSeries;
|
||||
|
||||
if (series != null)
|
||||
series.InvalidateRender();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TrackLegendItem
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether legend item tracking is enabled.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool TrackLegendItem
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ChartSeries != null)
|
||||
return (ChartSeries.TrackLegendItem);
|
||||
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FormatItemText
|
||||
|
||||
/// <summary>
|
||||
/// Formats the provided item text.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public string FormatItemText(string text)
|
||||
{
|
||||
return (text);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,614 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
class RadialAlign
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private List<PieLabel> _PieLabels;
|
||||
|
||||
#endregion
|
||||
|
||||
public RadialAlign(List<PieLabel> pieLabels)
|
||||
{
|
||||
_PieLabels = pieLabels;
|
||||
|
||||
foreach (PieLabel pl in _PieLabels)
|
||||
pl.Bounds = Rectangle.Empty;
|
||||
}
|
||||
|
||||
#region Iterate
|
||||
|
||||
public bool Iterate(Graphics g, PieChart pieChart, Rectangle bounds)
|
||||
{
|
||||
if (_PieLabels.Count > 0)
|
||||
{
|
||||
PositionLabels(pieChart, bounds);
|
||||
|
||||
List<PieLabel>[] plist = SortLabels();
|
||||
|
||||
for (int i = 0; i < plist.Length; i++)
|
||||
{
|
||||
List<PieLabel> pls = plist[i];
|
||||
|
||||
if (pls.Count > 0)
|
||||
{
|
||||
if (IsAnyOverlap(pieChart, pls) == true)
|
||||
{
|
||||
AdjustDownwards(pieChart, pls, bounds);
|
||||
|
||||
if (IsAnyOverlap(pieChart, pls) == true)
|
||||
AdjustUpwards(pieChart, pls, bounds);
|
||||
}
|
||||
|
||||
AdjustLabelSizes(g, pieChart, pls, bounds);
|
||||
|
||||
if (IsAnyOverlap(pieChart, pls) == true)
|
||||
{
|
||||
AdjustDownwards(pieChart, pls, bounds);
|
||||
|
||||
if (IsAnyOverlap(pieChart, pls) == true)
|
||||
AdjustUpwards(pieChart, pls, bounds);
|
||||
}
|
||||
|
||||
if (pieChart.SliceLabelOverlapMode != SliceLabelOverlapMode.ShowOverlapping)
|
||||
{
|
||||
if (IsAnyOverlap(pieChart, pls) == true)
|
||||
HideOverLapping(pls, bounds);
|
||||
}
|
||||
|
||||
UpdateBoxPoints(pieChart, pls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#region PositionLabels
|
||||
|
||||
private void PositionLabels(PieChart pieChart, Rectangle bounds)
|
||||
{
|
||||
foreach (PieLabel pl in _PieLabels)
|
||||
{
|
||||
PieSeriesPoint psp = pl.PieSeriesPoint;
|
||||
PieSeriesPointCollection spc = psp.Parent as PieSeriesPointCollection;
|
||||
|
||||
if (spc != null)
|
||||
{
|
||||
bool showWhiteSpace = psp.ShowSliceWhiteSpaceEx;
|
||||
|
||||
int width = psp.OuterRadius - psp.InnerRadius;
|
||||
|
||||
int outerRadius = (psp.ShowSliceWhiteSpaceEx == true)
|
||||
? psp.OuterRadius : (int)(psp.InnerRadius + psp.SliceExtent * width);
|
||||
|
||||
pl.LabelStyle = psp.GetEffectiveSliceStyle(pieChart, psp.ChartSeries).SliceOuterLabelStyle;
|
||||
|
||||
pl.OuterRadius = outerRadius;
|
||||
pl.Radius = outerRadius + pl.LabelStyle.ConnectorLength;
|
||||
|
||||
UpdateBoundingRect(pieChart, psp, pl, psp.CenterAngle);
|
||||
}
|
||||
}
|
||||
|
||||
AdjustForChartBounds(pieChart, _PieLabels);
|
||||
}
|
||||
|
||||
#region UpdateBoundingRect
|
||||
|
||||
private void UpdateBoundingRect(PieChart pieChart, PieSeriesPoint psp, PieLabel pl, double angle)
|
||||
{
|
||||
pl.PtSliceEdge = psp.GetRayEndPoint(angle, pl.OuterRadius);
|
||||
|
||||
Point pt = psp.GetRayEndPoint(angle, pl.Radius);
|
||||
|
||||
Rectangle r = new Rectangle(pt, pl.LabelSize);
|
||||
r.Y -= (r.Size.Height / 2);
|
||||
|
||||
angle = (angle + 360000) % 360;
|
||||
|
||||
int n = (pl.LabelStyle.DrawConnector == Tbool.True)
|
||||
? Dpi.Width(pl.LabelStyle.ConnectorTickLength) : 0;
|
||||
|
||||
r.X += ((angle >= 270 || angle <= 90) ? n : -(r.Size.Width + n));
|
||||
|
||||
pl.Bounds = r;
|
||||
|
||||
AdjustForPieIntersect(pl);
|
||||
}
|
||||
|
||||
#region AdjustForPieIntersect
|
||||
|
||||
private void AdjustForPieIntersect(PieLabel pl)
|
||||
{
|
||||
PieSeriesPoint psp = pl.PieSeriesPoint;
|
||||
|
||||
Point pto = GetClosestOffset(psp.SliceCenter, pl.Bounds);
|
||||
|
||||
Point ptr = psp.SliceCenter;
|
||||
ptr.X += pto.X;
|
||||
ptr.Y += pto.Y;
|
||||
|
||||
if (Intersects(psp, ptr, pl) == true)
|
||||
{
|
||||
Rectangle r = pl.Bounds;
|
||||
|
||||
double ihyp = Math.Sqrt(pto.X * pto.X + pto.Y * pto.Y);
|
||||
double ohyp = (psp.OuterRadius + pl.LabelStyle.LabelMargin) - ihyp;
|
||||
|
||||
double scale = ohyp / ihyp;
|
||||
|
||||
int dx = (int)(pto.X * scale);
|
||||
int dy = (int)(pto.Y * scale);
|
||||
|
||||
r.X += dx;
|
||||
r.Y += dy;
|
||||
|
||||
pl.Bounds = r;
|
||||
}
|
||||
}
|
||||
|
||||
#region GetClosestOffset
|
||||
|
||||
private Point GetClosestOffset(Point ptc, Rectangle r)
|
||||
{
|
||||
Point pt = new Point();
|
||||
|
||||
int dx1 = r.X - ptc.X;
|
||||
int dx2 = r.Right - ptc.X;
|
||||
|
||||
int dy1 = r.Y - ptc.Y;
|
||||
int dy2 = r.Bottom - ptc.Y;
|
||||
|
||||
pt.X = Math.Abs(dx1) < Math.Abs(dx2) ? dx1 : dx2;
|
||||
pt.Y = Math.Abs(dy1) < Math.Abs(dy2) ? dy1 : dy2;
|
||||
|
||||
return (pt);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Intersects
|
||||
|
||||
private bool Intersects(
|
||||
PieSeriesPoint psp, Point ptr, PieLabel pl)
|
||||
{
|
||||
int radius = psp.OuterRadius + pl.LabelStyle.LabelMargin;
|
||||
|
||||
int dx = psp.SliceCenter.X - ptr.X;
|
||||
int dy = psp.SliceCenter.Y - ptr.Y;
|
||||
|
||||
float dsq = (dx * dx) + (dy * dy);
|
||||
|
||||
return (dsq < (radius * radius));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdjustForChartBounds
|
||||
|
||||
private void AdjustForChartBounds(PieChart pieChart, List<PieLabel> pls)
|
||||
{
|
||||
Rectangle r = pieChart.ContentBoundsEx;
|
||||
|
||||
for (int i = 0; i < pls.Count; i++)
|
||||
{
|
||||
PieLabel pl = pls[i];
|
||||
|
||||
if (pl.Bounds.IsEmpty == false)
|
||||
{
|
||||
int margin = Dpi.Width(pl.LabelStyle.LabelMargin);
|
||||
|
||||
if (pl.Bounds.Bottom + margin > r.Bottom)
|
||||
{
|
||||
Rectangle t = pl.Bounds;
|
||||
t.Y = (r.Bottom - t.Height - margin);
|
||||
pl.Bounds = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region SortLabels
|
||||
|
||||
private List<PieLabel>[] SortLabels()
|
||||
{
|
||||
List<PieLabel>[] plist = new List<PieLabel>[2];
|
||||
|
||||
plist[0] = new List<PieLabel>();
|
||||
plist[1] = new List<PieLabel>();
|
||||
|
||||
foreach (PieLabel pl in _PieLabels)
|
||||
{
|
||||
double angle = pl.PieSeriesPoint.CenterAngle % 360;
|
||||
|
||||
pl.IsRightlabel = (angle >= 270 || angle <= 90);
|
||||
|
||||
if (pl.IsRightlabel == true)
|
||||
plist[1].Add(pl);
|
||||
else
|
||||
plist[0].Add(pl);
|
||||
}
|
||||
|
||||
plist[0].Sort(new PieLabelYComparer());
|
||||
plist[1].Sort(new PieLabelYComparer());
|
||||
|
||||
return (plist);
|
||||
}
|
||||
|
||||
#region PieLabelYComparer
|
||||
|
||||
private class PieLabelYComparer : IComparer<PieLabel>
|
||||
{
|
||||
public int Compare(PieLabel pl1, PieLabel pl2)
|
||||
{
|
||||
return (pl1.PtSliceEdge.Y - pl2.PtSliceEdge.Y);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsAnyOverlap
|
||||
|
||||
private bool IsAnyOverlap(PieChart pieChart, List<PieLabel> pls)
|
||||
{
|
||||
if (pls.Count <= 0)
|
||||
return (false);
|
||||
|
||||
PieSeriesPoint psp = pls[0].PieSeriesPoint;
|
||||
|
||||
if (psp.SliceLabelVisibilityEx == SliceLabelVisibility.SliceMouseOver)
|
||||
return (false);
|
||||
|
||||
int maxy = 0;
|
||||
|
||||
for (int i = 0; i < pls.Count; i++)
|
||||
{
|
||||
PieLabel pl = pls[i];
|
||||
|
||||
if (pl.Bounds.IsEmpty == false)
|
||||
{
|
||||
if (maxy > pl.Bounds.Y)
|
||||
return (IsAnyOverlapEx(pieChart, pls));
|
||||
|
||||
int margin = Dpi.Width(pl.LabelStyle.LabelMargin);
|
||||
|
||||
if (pl.Bounds.Bottom + margin > maxy)
|
||||
maxy = pl.Bounds.Bottom + margin;
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#region IsAnyOverlapEx
|
||||
|
||||
private bool IsAnyOverlapEx(PieChart pieChart, List<PieLabel> pls)
|
||||
{
|
||||
for (int i = 0; i < pls.Count; i++)
|
||||
{
|
||||
PieLabel pl = pls[i];
|
||||
|
||||
if (pl.Bounds.IsEmpty == false)
|
||||
{
|
||||
int margin = pl.LabelStyle.LabelMargin;
|
||||
|
||||
Rectangle r = pl.Bounds;
|
||||
r.Inflate(margin, margin);
|
||||
|
||||
for (int j = i + 1; j < pls.Count; j++)
|
||||
{
|
||||
PieLabel pl2 = pls[j];
|
||||
|
||||
if (r.IntersectsWith(pl2.Bounds) == true)
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region HideOverLapping
|
||||
|
||||
private void HideOverLapping(List<PieLabel> pls, Rectangle bounds)
|
||||
{
|
||||
for (int i = 0; i < pls.Count; i++)
|
||||
{
|
||||
PieLabel pl = pls[i];
|
||||
|
||||
if (pl.Bounds.IsEmpty == false)
|
||||
{
|
||||
for (int j = i + 1; j < pls.Count; j++)
|
||||
{
|
||||
PieLabel pl2 = pls[j];
|
||||
|
||||
if (pl.Bounds.IntersectsWith(pl2.Bounds) == true)
|
||||
pl2.Bounds = Rectangle.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdjustUpwards
|
||||
|
||||
private void AdjustUpwards(PieChart pieChart, List<PieLabel> pls, Rectangle bounds)
|
||||
{
|
||||
for (int i = pls.Count - 1; i > 0; i--)
|
||||
{
|
||||
PieLabel pl0 = pls[i];
|
||||
PieLabel pl1 = pls[i - 1];
|
||||
|
||||
int margin = Dpi.Width(pl0.LabelStyle.LabelMargin);
|
||||
|
||||
Rectangle t = pl0.Bounds;
|
||||
t.Inflate(margin, margin);
|
||||
|
||||
if (pl1.Bounds.Bottom > t.Y)
|
||||
{
|
||||
if ((pl1.Bounds.X < t.Right) && (t.X < pl1.Bounds.Right))
|
||||
{
|
||||
Rectangle r = pl1.Bounds;
|
||||
|
||||
r.Y = Math.Max(bounds.Y + margin, pl0.Bounds.Y - pl1.Bounds.Height - margin);
|
||||
|
||||
pl1.Bounds = r;
|
||||
|
||||
AdjustForPieIntersect(pl1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdjustDownwards
|
||||
|
||||
private void AdjustDownwards(PieChart pieChart, List<PieLabel> pls, Rectangle bounds)
|
||||
{
|
||||
for (int i = 0; i < pls.Count - 1; i++)
|
||||
{
|
||||
PieLabel pl0 = pls[i];
|
||||
PieLabel pl1 = pls[i + 1];
|
||||
|
||||
int margin = Dpi.Width(pl0.LabelStyle.LabelMargin) + 4;
|
||||
|
||||
Rectangle t = pl0.Bounds;
|
||||
t.Inflate(margin, margin);
|
||||
|
||||
if (pl1.Bounds.Bottom < t.Bottom)
|
||||
{
|
||||
if ((pl1.Bounds.X < t.Right) && (t.X < pl1.Bounds.Right))
|
||||
{
|
||||
Rectangle r = pl1.Bounds;
|
||||
|
||||
r.Y = Math.Min(bounds.Bottom - r.Height - margin, t.Bottom);
|
||||
|
||||
pl1.Bounds = r;
|
||||
|
||||
AdjustForPieIntersect(pl1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdjustSpread
|
||||
|
||||
private void AdjustSpread(List<PieLabel> pls, Rectangle bounds)
|
||||
{
|
||||
int height = 0;
|
||||
|
||||
for (int i = 0; i < pls.Count; i++)
|
||||
height += pls[i].Bounds.Height;
|
||||
|
||||
int margin = bounds.Height - height;
|
||||
|
||||
if (pls.Count > 1)
|
||||
margin /= (pls.Count - 1);
|
||||
|
||||
int y = bounds.Y;
|
||||
|
||||
for (int i = 0; i < pls.Count; i++)
|
||||
{
|
||||
PieLabel pl = pls[i];
|
||||
|
||||
Rectangle r = pl.Bounds;
|
||||
|
||||
r.Y = y;
|
||||
pl.Bounds = r;
|
||||
|
||||
y = (pl.Bounds.Bottom + margin);
|
||||
|
||||
AdjustForPieIntersect(pl);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdjustLabelSizes
|
||||
|
||||
private void AdjustLabelSizes(Graphics g,
|
||||
PieChart pieChart, List<PieLabel> pls, Rectangle bounds)
|
||||
{
|
||||
Rectangle r = pieChart.ContentBoundsEx;
|
||||
|
||||
foreach (PieLabel pl in pls)
|
||||
{
|
||||
PieSeriesPoint psp = pl.PieSeriesPoint;
|
||||
|
||||
ChartSliceVisualStyle sstyle =
|
||||
psp.GetEffectiveSliceStyle(pieChart, psp.ChartSeries);
|
||||
|
||||
Rectangle t = GetChartBounds(pieChart, pl);
|
||||
|
||||
if (pl.LabelSize.Width != t.Width)
|
||||
{
|
||||
PieSeries series = psp.ChartSeries;
|
||||
|
||||
Size size = series.MeasurePieLabel(g,
|
||||
pieChart, psp, pl, t.Width, sstyle.SliceOuterLabelStyle);
|
||||
|
||||
if (size != pl.Bounds.Size)
|
||||
{
|
||||
if (t.X != pl.Bounds.X && size.Width < t.Size.Width)
|
||||
t.X += (t.Size.Width - size.Width);
|
||||
|
||||
if (size.Height > t.Size.Height)
|
||||
t.Y -= (size.Height - t.Size.Height) / 2;
|
||||
|
||||
t.Size = size;
|
||||
}
|
||||
|
||||
pl.Bounds = t;
|
||||
|
||||
AdjustForPieIntersect(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region GetChartBounds
|
||||
|
||||
private Rectangle GetChartBounds(PieChart pieChart, PieLabel pl)
|
||||
{
|
||||
Rectangle r = pl.Bounds;
|
||||
|
||||
r.Inflate(4, 4);
|
||||
|
||||
if (r.X < pieChart.ContentBoundsEx.X)
|
||||
{
|
||||
r.Width -= (pieChart.ContentBoundsEx.X - r.X);
|
||||
r.X = pieChart.ContentBoundsEx.X;
|
||||
|
||||
if (r.Width <= 0)
|
||||
return (Rectangle.Empty);
|
||||
}
|
||||
|
||||
if (r.Right >= pieChart.ContentBoundsEx.Right)
|
||||
{
|
||||
r.Width -= (r.Right - pieChart.ContentBoundsEx.Right + 1);
|
||||
|
||||
if (r.Width <= 0)
|
||||
return (Rectangle.Empty);
|
||||
}
|
||||
|
||||
if (r.Y < pieChart.ContentBoundsEx.Y)
|
||||
{
|
||||
r.Height -= (pieChart.ContentBoundsEx.Y - r.Y);
|
||||
r.Y = pieChart.ContentBoundsEx.Y;
|
||||
|
||||
if (r.Height <= 0)
|
||||
return (Rectangle.Empty);
|
||||
}
|
||||
|
||||
if (r.Bottom >= pieChart.ContentBoundsEx.Bottom)
|
||||
{
|
||||
int n = (r.Bottom - pieChart.ContentBoundsEx.Bottom + 1);
|
||||
|
||||
r.Y -= n;
|
||||
r.Width++;
|
||||
|
||||
if (r.Height <= 0)
|
||||
return (Rectangle.Empty);
|
||||
}
|
||||
|
||||
r.Inflate(-4, -4);
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateBoxPoints
|
||||
|
||||
private void UpdateBoxPoints(PieChart pieChart, List<PieLabel> pls)
|
||||
{
|
||||
foreach (PieLabel pl in pls)
|
||||
{
|
||||
Rectangle t = new Rectangle();
|
||||
|
||||
Rectangle r = pl.Bounds;
|
||||
|
||||
if (r.IsEmpty == false)
|
||||
{
|
||||
if (pl.LabelStyle.DrawConnector == Tbool.True)
|
||||
{
|
||||
int tick = pl.LabelStyle.ConnectorTickLength;
|
||||
|
||||
if (pl.IsLeftlabel == true)
|
||||
{
|
||||
pl.PtBoxEdge = new Point(r.Right, r.Y + r.Height / 2);
|
||||
pl.PtBoxBend = new Point(pl.PtBoxEdge.X + tick, pl.PtBoxEdge.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
pl.PtBoxEdge = new Point(r.X, r.Y + r.Height / 2);
|
||||
pl.PtBoxBend = new Point(pl.PtBoxEdge.X - tick, pl.PtBoxEdge.Y);
|
||||
}
|
||||
|
||||
Point ptMin = new Point();
|
||||
Point ptMax = new Point();
|
||||
|
||||
if (pl.PtBoxEdge.X < pl.PtSliceEdge.X)
|
||||
{
|
||||
ptMin.X = pl.PtBoxEdge.X;
|
||||
ptMax.X = pl.PtSliceEdge.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptMin.X = pl.PtSliceEdge.X;
|
||||
ptMax.X = pl.PtBoxEdge.X;
|
||||
}
|
||||
|
||||
if (pl.PtBoxEdge.Y < pl.PtSliceEdge.Y)
|
||||
{
|
||||
ptMin.Y = pl.PtBoxEdge.Y;
|
||||
ptMax.Y = pl.PtSliceEdge.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptMin.Y = pl.PtSliceEdge.Y;
|
||||
ptMax.Y = pl.PtBoxEdge.Y;
|
||||
}
|
||||
|
||||
t.Location = ptMin;
|
||||
t.Width = ptMax.X - ptMin.X + 1;
|
||||
t.Height = ptMax.Y - ptMin.Y + 1;
|
||||
}
|
||||
}
|
||||
|
||||
pl.Bounds = r;
|
||||
pl.ConnectorBounds = t;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,250 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
internal class TextDrawing
|
||||
{
|
||||
#region Public / internal variables
|
||||
|
||||
public static bool UseTextRenderer = true;
|
||||
public static bool TextDrawingEnabled = true;
|
||||
|
||||
internal static bool UseGenericDefault = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawString
|
||||
|
||||
public static void DrawString(Graphics g,
|
||||
string text, Font font, Color color, int x, int y, eTextFormat format)
|
||||
{
|
||||
DrawString(g, text, font, color, new Rectangle(x, y, 0, 0), format);
|
||||
}
|
||||
|
||||
public static void DrawString(Graphics g,
|
||||
string text, Font font, Color color, Rectangle bounds, eTextFormat format)
|
||||
{
|
||||
if (UseTextRenderer && (format & eTextFormat.Vertical) == 0)
|
||||
TextRenderer.DrawText(g, text, font, bounds, color, GetTextFormatFlags(format));
|
||||
else
|
||||
DrawStringLegacy(g, text, font, color, bounds, format);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawStringLegacy
|
||||
|
||||
public static void DrawStringLegacy(Graphics g,
|
||||
string text, Font font, Color color, Rectangle bounds, eTextFormat format)
|
||||
{
|
||||
if (color.IsEmpty == false && TextDrawingEnabled == true)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
{
|
||||
using (StringFormat sf = GetStringFormat(format))
|
||||
g.DrawString(text, font, brush, bounds, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureString
|
||||
|
||||
public static Size MeasureString(Graphics g,
|
||||
string text, Font font)
|
||||
{
|
||||
return MeasureString(g, text, font, Size.Empty, eTextFormat.Default);
|
||||
}
|
||||
|
||||
public static Size MeasureString(Graphics g,
|
||||
string text, Font font, int proposedWidth, eTextFormat format)
|
||||
{
|
||||
return MeasureString(g, text, font, new Size(proposedWidth, 0), format);
|
||||
}
|
||||
|
||||
public static Size MeasureString(Graphics g,
|
||||
string text, Font font, int proposedWidth)
|
||||
{
|
||||
return MeasureString(g, text, font, new Size(proposedWidth, 0), eTextFormat.Default);
|
||||
}
|
||||
|
||||
public static Size MeasureString(Graphics g,
|
||||
string text, Font font, Size proposedSize, eTextFormat format)
|
||||
{
|
||||
if (UseTextRenderer && (format & eTextFormat.Vertical) == 0)
|
||||
{
|
||||
format = format & ~(format & eTextFormat.VerticalCenter); // Bug in .NET Framework 2.0
|
||||
format = format & ~(format & eTextFormat.Bottom); // Bug in .NET Framework 2.0
|
||||
format = format & ~(format & eTextFormat.HorizontalCenter); // Bug in .NET Framework 2.0
|
||||
format = format & ~(format & eTextFormat.Right); // Bug in .NET Framework 2.0
|
||||
format = format & ~(format & eTextFormat.EndEllipsis); // Bug in .NET Framework 2.0
|
||||
|
||||
return (Size.Ceiling(TextRenderer.MeasureText(g, text, font, proposedSize, GetTextFormatFlags(format))));
|
||||
}
|
||||
|
||||
using (StringFormat sf = GetStringFormat(format))
|
||||
return Size.Ceiling(g.MeasureString(text, font, proposedSize, sf));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureStringLegacy
|
||||
|
||||
public static Size MeasureStringLegacy(Graphics g,
|
||||
string text, Font font, Size proposedSize, eTextFormat format)
|
||||
{
|
||||
using (StringFormat sf = GetStringFormat(format))
|
||||
return (g.MeasureString(text, font, proposedSize, sf).ToSize());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TranslateHorizontal
|
||||
|
||||
public static eTextFormat TranslateHorizontal(StringAlignment align)
|
||||
{
|
||||
if (align == StringAlignment.Center)
|
||||
return (eTextFormat.HorizontalCenter);
|
||||
|
||||
if (align == StringAlignment.Far)
|
||||
return (eTextFormat.Right);
|
||||
|
||||
return (eTextFormat.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TranslateVertical
|
||||
|
||||
public static eTextFormat TranslateVertical(StringAlignment align)
|
||||
{
|
||||
if (align == StringAlignment.Center)
|
||||
return (eTextFormat.VerticalCenter);
|
||||
|
||||
if (align == StringAlignment.Far)
|
||||
return (eTextFormat.Bottom);
|
||||
|
||||
return (eTextFormat.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTextFormatFlags
|
||||
|
||||
private static TextFormatFlags GetTextFormatFlags(eTextFormat format)
|
||||
{
|
||||
format |= eTextFormat.PreserveGraphicsTranslateTransform |
|
||||
eTextFormat.PreserveGraphicsClipping;
|
||||
|
||||
if ((format & eTextFormat.SingleLine) == eTextFormat.SingleLine &&
|
||||
(format & eTextFormat.WordBreak) == eTextFormat.WordBreak)
|
||||
{
|
||||
format = format & ~(format & eTextFormat.SingleLine);
|
||||
}
|
||||
|
||||
return (TextFormatFlags)format;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetStringFormat
|
||||
|
||||
public static StringFormat GetStringFormat(eTextFormat format)
|
||||
{
|
||||
StringFormat sf = new StringFormat(UseGenericDefault
|
||||
? StringFormat.GenericDefault : StringFormat.GenericTypographic);
|
||||
|
||||
if (format == eTextFormat.Default)
|
||||
return sf;
|
||||
|
||||
if ((format & eTextFormat.HorizontalCenter) == eTextFormat.HorizontalCenter)
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
|
||||
else if ((format & eTextFormat.Right) == eTextFormat.Right)
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
|
||||
if ((format & eTextFormat.VerticalCenter) == eTextFormat.VerticalCenter)
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
|
||||
else if ((format & eTextFormat.Bottom) == eTextFormat.Bottom)
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
|
||||
if ((format & eTextFormat.EndEllipsis) == eTextFormat.EndEllipsis)
|
||||
sf.Trimming = StringTrimming.EllipsisCharacter;
|
||||
else
|
||||
sf.Trimming = StringTrimming.Character;
|
||||
|
||||
if ((format & eTextFormat.HidePrefix) == eTextFormat.HidePrefix)
|
||||
sf.HotkeyPrefix = HotkeyPrefix.Hide;
|
||||
else if ((format & eTextFormat.NoPrefix) == eTextFormat.NoPrefix)
|
||||
sf.HotkeyPrefix = HotkeyPrefix.None;
|
||||
else
|
||||
sf.HotkeyPrefix = HotkeyPrefix.Show;
|
||||
|
||||
if ((format & eTextFormat.WordBreak) == eTextFormat.WordBreak)
|
||||
sf.FormatFlags = sf.FormatFlags & ~(sf.FormatFlags & StringFormatFlags.NoWrap);
|
||||
else
|
||||
sf.FormatFlags |= StringFormatFlags.NoWrap;
|
||||
|
||||
if ((format & eTextFormat.LeftAndRightPadding) == eTextFormat.LeftAndRightPadding)
|
||||
sf.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
|
||||
|
||||
if ((format & eTextFormat.RightToLeft) == eTextFormat.RightToLeft)
|
||||
sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
|
||||
|
||||
if ((format & eTextFormat.Vertical) == eTextFormat.Vertical)
|
||||
sf.FormatFlags |= StringFormatFlags.DirectionVertical;
|
||||
|
||||
if ((format & eTextFormat.NoClipping) == eTextFormat.NoClipping)
|
||||
sf.FormatFlags |= StringFormatFlags.NoClip;
|
||||
|
||||
return (sf);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region eTextFormat
|
||||
[Flags]
|
||||
internal enum eTextFormat
|
||||
{
|
||||
Bottom = 8,
|
||||
Default = 0,
|
||||
EndEllipsis = 0x8000,
|
||||
ExpandTabs = 0x40,
|
||||
ExternalLeading = 0x200,
|
||||
GlyphOverhangPadding = 0,
|
||||
HidePrefix = 0x100000,
|
||||
HorizontalCenter = 1,
|
||||
Internal = 0x1000,
|
||||
Left = 0,
|
||||
LeftAndRightPadding = 0x20000000,
|
||||
ModifyString = 0x10000,
|
||||
NoClipping = 0x100,
|
||||
NoFullWidthCharacterBreak = 0x80000,
|
||||
NoPadding = 0x10000000,
|
||||
NoPrefix = 0x800,
|
||||
PathEllipsis = 0x4000,
|
||||
PrefixOnly = 0x200000,
|
||||
PreserveGraphicsClipping = 0x1000000,
|
||||
PreserveGraphicsTranslateTransform = 0x2000000,
|
||||
Right = 2,
|
||||
RightToLeft = 0x20000,
|
||||
SingleLine = 0x20,
|
||||
TextBoxControl = 0x2000,
|
||||
Top = 0,
|
||||
VerticalCenter = 4,
|
||||
WordBreak = 0x10,
|
||||
WordEllipsis = 0x40000,
|
||||
Vertical = 0x40000000
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
public class TreeMap : BaseChart
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,814 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the collection of Axis Stripes.
|
||||
/// </summary>
|
||||
[Editor("DevComponents.Charts.Design.AxisStripeCollectionEditor, DevComponents.Charts.Design, " +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
|
||||
public class AxisStripeCollection : CustomNamedCollection<AxisStripe>
|
||||
{
|
||||
public AxisStripeCollection()
|
||||
{
|
||||
}
|
||||
|
||||
#region GetUniqueName
|
||||
|
||||
public string GetUniqueName()
|
||||
{
|
||||
return (GetUniqueName("Stripe"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Element describing a color stripe on the chart. Each AxisStripe
|
||||
/// is associated with a primary or Ancillary Axis.
|
||||
/// </summary>
|
||||
public class AxisStripe : ChartVisualElement, ILegendItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private States _States;
|
||||
|
||||
private object _MinValue;
|
||||
private object _MaxValue;
|
||||
private AxisStripeVisualStyle _AxisStripeVisualStyle;
|
||||
|
||||
private string _LegendText;
|
||||
private ChartLegendItem _LegendItem;
|
||||
private ChartLegendItemVisualStyles _ChartLegendItemVisualStyles;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a new AxisStripe.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public AxisStripe(string name, object minValue, object maxValue)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
|
||||
MinValue = minValue;
|
||||
MaxValue = maxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new AxisStripe.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public AxisStripe(string name)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new AxisStripe.
|
||||
/// </summary>
|
||||
public AxisStripe()
|
||||
{
|
||||
InitDefaultStates();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InitDefaultStates
|
||||
|
||||
private void InitDefaultStates()
|
||||
{
|
||||
SetState(States.CheckedInLegend, true);
|
||||
SetState(States.ShowInLegend, true);
|
||||
SetState(States.ShowInParentLegend, true);
|
||||
SetState(States.ShowCheckBoxInLegend, true);
|
||||
SetState(States.ShowMarkerInLegend, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AxisStripeVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the AxisStripe.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the AxisStripe.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public AxisStripeVisualStyle AxisStripeVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AxisStripeVisualStyle == null)
|
||||
{
|
||||
_AxisStripeVisualStyle = new AxisStripeVisualStyle();
|
||||
|
||||
StyleVisualChangeHandler(null, _AxisStripeVisualStyle);
|
||||
}
|
||||
|
||||
return (_AxisStripeVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AxisStripeVisualStyle != value)
|
||||
{
|
||||
AxisStripeVisualStyle oldValue = _AxisStripeVisualStyle;
|
||||
|
||||
_AxisStripeVisualStyle = value;
|
||||
|
||||
OnVisualStyleChanged("AxisStripeVisualStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsDisplayed
|
||||
|
||||
///<summary>
|
||||
/// Gets whether the Stripe is displayed (must be Visible
|
||||
/// and appropriately 'checked' if presented in the Legend).
|
||||
///</summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsDisplayed
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((Visible == true) &&
|
||||
(ShowCheckBoxInLegend == false || CheckedInLegend == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MaxValue
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the maximum axis stripe value.
|
||||
///</summary>
|
||||
[DefaultValue(null), Category("Data")]
|
||||
[Description("Indicates the maximum axis stripe value.")]
|
||||
[TypeConverter("DevComponents.Charts.Design.PointValueConverter, DevComponents.Charts.Design," +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public object MaxValue
|
||||
{
|
||||
get { return (_MaxValue); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MaxValue)
|
||||
{
|
||||
_MaxValue = value;
|
||||
|
||||
OnPropertyChangedEx("MaxValue", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MinValue
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the minimum axis stripe value.
|
||||
///</summary>
|
||||
[DefaultValue(null), Category("Data")]
|
||||
[Description("Indicates the minimum axis stripe value.")]
|
||||
[TypeConverter("DevComponents.Charts.Design.PointValueConverter, DevComponents.Charts.Design," +
|
||||
"Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public object MinValue
|
||||
{
|
||||
get { return (_MinValue); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MinValue)
|
||||
{
|
||||
_MinValue = value;
|
||||
|
||||
OnPropertyChangedEx("MinValue", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style support
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
///<summary>
|
||||
///Invalidate the cached Styles
|
||||
///</summary>
|
||||
public void InvalidateStyle()
|
||||
{
|
||||
ClearEffectiveStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearEffectiveStyles
|
||||
|
||||
protected override void ClearEffectiveStyles()
|
||||
{
|
||||
base.ClearEffectiveStyles();
|
||||
|
||||
if (LegendItem != null)
|
||||
LegendItem.EffectiveStyles.InvalidateStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleChanged
|
||||
|
||||
protected override void StyleChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
base.StyleChanged(sender, e);
|
||||
|
||||
if (sender is ChartLegendItemVisualStyles && LegendItem != null)
|
||||
InvalidateRender(LegendItem.Bounds);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ILegendItem
|
||||
|
||||
#region ChartLegendItemVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles for the Legend item.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual styles for the Legend item.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLegendItemVisualStyles ChartLegendItemVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ChartLegendItemVisualStyles == null)
|
||||
{
|
||||
_ChartLegendItemVisualStyles = new ChartLegendItemVisualStyles();
|
||||
|
||||
StyleVisualChangeHandler(null, _ChartLegendItemVisualStyles);
|
||||
}
|
||||
|
||||
return (_ChartLegendItemVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_ChartLegendItemVisualStyles != value)
|
||||
{
|
||||
ChartLegendItemVisualStyles oldValue = _ChartLegendItemVisualStyles;
|
||||
|
||||
_ChartLegendItemVisualStyles = value;
|
||||
|
||||
OnStyleChanged("ChartLegendItemVisualStyles", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckedInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the ReferenceLine is checked in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the ReferenceLine is checked in the Legend.")]
|
||||
public bool CheckedInLegend
|
||||
{
|
||||
get { return (TestState(States.CheckedInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != CheckedInLegend)
|
||||
{
|
||||
SetState(States.CheckedInLegend, value);
|
||||
|
||||
if (LegendItem != null)
|
||||
LegendItem.UpdateCheckState();
|
||||
|
||||
OnPropertyChangedEx("CheckedInLegend", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowCheckBoxInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether a checkbox for the ReferenceLine is shown in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether a checkbox for the ReferenceLine is shown in the Legend.")]
|
||||
public bool ShowCheckBoxInLegend
|
||||
{
|
||||
get { return (TestState(States.ShowCheckBoxInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowCheckBoxInLegend)
|
||||
{
|
||||
SetState(States.ShowCheckBoxInLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowCheckBoxInLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the ReferenceLine is shown in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the ReferenceLine is shown in the Legend.")]
|
||||
public bool ShowInLegend
|
||||
{
|
||||
get { return (TestState(States.ShowInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowInLegend)
|
||||
{
|
||||
SetState(States.ShowInLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowInLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowInParentLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the Reference Line is shown in parent Legend(s).
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the Reference Line is shown in parent Legend(s).")]
|
||||
public bool ShowInParentLegend
|
||||
{
|
||||
get { return (TestState(States.ShowInParentLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowInParentLegend)
|
||||
{
|
||||
SetState(States.ShowInParentLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowInParentLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowMarkerInLegend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the ReferenceLine Marker is shown in the Legend.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Legend")]
|
||||
[Description("Indicates whether the ReferenceLine Marker is shown in the Legend.")]
|
||||
public bool ShowMarkerInLegend
|
||||
{
|
||||
get { return (TestState(States.ShowMarkerInLegend)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != ShowMarkerInLegend)
|
||||
{
|
||||
SetState(States.ShowMarkerInLegend, value);
|
||||
|
||||
OnPropertyChangedEx("ShowMarkerInLegend", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LegendItem
|
||||
|
||||
///<summary>
|
||||
/// Gets the item's parent LegendItem.
|
||||
///</summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("Indicates the item's parent LegendItem.")]
|
||||
public ChartLegendItem LegendItem
|
||||
{
|
||||
get { return (_LegendItem); }
|
||||
internal set { _LegendItem = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LegendText
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the text to display in the legend.
|
||||
///</summary>
|
||||
[DefaultValue(null), Category("Legend")]
|
||||
[Description("Indicates the text to display in the legend.")]
|
||||
[NotifyParentProperty(true)]
|
||||
public string LegendText
|
||||
{
|
||||
get { return (_LegendText); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _LegendText)
|
||||
{
|
||||
_LegendText = value;
|
||||
|
||||
OnPropertyChangedEx("LegendText", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLegendItem
|
||||
|
||||
/// <summary>
|
||||
/// Creates the LegendItem for the AxisStripe.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ChartLegendItem GetLegendItem()
|
||||
{
|
||||
_LegendItem = null;
|
||||
|
||||
if (ShowInLegend == true)
|
||||
{
|
||||
_LegendItem = new ChartLegendItem();
|
||||
|
||||
if (CheckedInLegend == true)
|
||||
_LegendItem.CheckState = CheckState.Checked;
|
||||
|
||||
_LegendItem.Name = Name;
|
||||
_LegendItem.ItemText = LegendText;
|
||||
|
||||
if (string.IsNullOrEmpty(_LegendItem.Name) == true)
|
||||
_LegendItem.Name = "(RefLine)";
|
||||
|
||||
_LegendItem.ChartItems.Add(this);
|
||||
}
|
||||
|
||||
return (_LegendItem);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLegendItems
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of legend items associated with
|
||||
/// the AxisStripe.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ChartLegendItem> GetLegendItems()
|
||||
{
|
||||
List<ChartLegendItem> list = null;
|
||||
|
||||
ChartLegendItem item = GetLegendItem();
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
list = new List<ChartLegendItem>(1);
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLegendItemColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default color associated with the
|
||||
/// AxisStripe legend item.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Color GetLegendItemColor()
|
||||
{
|
||||
AxisStripeVisualStyle astyle = AxisStripeVisualStyle;
|
||||
|
||||
Color color = astyle.Background.Color1;
|
||||
|
||||
if (color.IsEmpty == false)
|
||||
return (color);
|
||||
|
||||
return (Color.DimGray);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderLegendItemMarker
|
||||
|
||||
/// <summary>
|
||||
/// Renders the Legend item Marker.
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="litem"></param>
|
||||
/// <param name="style"></param>
|
||||
public void RenderLegendItemMarker(Graphics g,
|
||||
ChartLegendItem litem, ChartLegendItemVisualStyle style)
|
||||
{
|
||||
AxisStripeVisualStyle astyle = AxisStripeVisualStyle;
|
||||
|
||||
Rectangle bounds = litem.MarkerBounds;
|
||||
|
||||
if (astyle.Background.IsEmpty == true)
|
||||
{
|
||||
g.FillRectangle(Brushes.LightPink, bounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Brush br = astyle.Background.GetBrush(bounds))
|
||||
g.FillRectangle(br, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of the element.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
AxisStripe copy = new AxisStripe();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the current element properties and styles
|
||||
/// to the provided "copy".
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
AxisStripe c = copy as AxisStripe;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.AxisStripeVisualStyle = (_AxisStripeVisualStyle != null) ? _AxisStripeVisualStyle.Copy() : null;
|
||||
c.ChartLegendItemVisualStyles = (_ChartLegendItemVisualStyles != null) ? ChartLegendItemVisualStyles.Copy() : null;
|
||||
|
||||
c.MaxValue = MaxValue;
|
||||
c.MinValue = MinValue;
|
||||
|
||||
c.CheckedInLegend = CheckedInLegend;
|
||||
c.ShowCheckBoxInLegend = ShowCheckBoxInLegend;
|
||||
c.ShowInLegend = ShowInLegend;
|
||||
c.ShowInParentLegend = ShowInParentLegend;
|
||||
c.LegendText = LegendText;
|
||||
c.ShowMarkerInLegend = ShowMarkerInLegend;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartAxis";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_AxisStripeVisualStyle != null && _AxisStripeVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_AxisStripeVisualStyle.GetSerialData("AxisStripeVisualStyle"));
|
||||
|
||||
if (_ChartLegendItemVisualStyles != null)
|
||||
sec.AddElement(_ChartLegendItemVisualStyles.GetSerialData("ChartLegendItemVisualStyles"));
|
||||
|
||||
sec.AddDataValue("MaxValue", MaxValue, null);
|
||||
sec.AddDataValue("MinValue", MinValue, null);
|
||||
|
||||
sec.AddValue("CheckedInLegend", CheckedInLegend, true);
|
||||
sec.AddValue("LegendText", LegendText, null);
|
||||
sec.AddValue("ShowCheckBoxInLegend", ShowCheckBoxInLegend, true);
|
||||
sec.AddValue("ShowInLegend", ShowInLegend, true);
|
||||
sec.AddValue("ShowInParentLegend", ShowInParentLegend, true);
|
||||
sec.AddValue("ShowMarkerInLegend", ShowMarkerInLegend, true);
|
||||
|
||||
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 "CheckedInLegend":
|
||||
CheckedInLegend = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "LegendText":
|
||||
LegendText = se.StringValue;
|
||||
break;
|
||||
|
||||
case "MaxValue":
|
||||
MaxValue = se.DataValue;
|
||||
break;
|
||||
|
||||
case "MinValue":
|
||||
MinValue = se.DataValue;
|
||||
break;
|
||||
|
||||
case "ShowCheckBoxInLegend":
|
||||
ShowCheckBoxInLegend = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowInLegend":
|
||||
ShowInLegend = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowInParentLegend":
|
||||
ShowInParentLegend = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "ShowMarkerInLegend":
|
||||
ShowMarkerInLegend = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "AxisStripeVisualStyle":
|
||||
sec.PutSerialData(AxisStripeVisualStyle);
|
||||
break;
|
||||
|
||||
case "ChartLegendItemVisualStyles":
|
||||
sec.PutSerialData(ChartLegendItemVisualStyles);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region GetAncillaryAxis
|
||||
|
||||
private ChartAxis GetAncillaryAxis(ChartAxesCollection axes, string name)
|
||||
{
|
||||
foreach (ChartAxis axis in axes)
|
||||
{
|
||||
if (name.Equals(axis.Name) == true)
|
||||
return (axis);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
CheckedInLegend = (1U << 1),
|
||||
ShowCheckBoxInLegend = (1U << 2),
|
||||
ShowInLegend = (1U << 3),
|
||||
ShowInParentLegend = (1U << 4),
|
||||
ShowMarkerInLegend = (1U << 5),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
AxisStripeVisualStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,800 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
#region ChartMajorGridLines
|
||||
|
||||
#region ChartMajorGridLinesX
|
||||
|
||||
/// <summary>
|
||||
/// Represents a chart's MajorGridLines for the X-Axis.
|
||||
/// </summary>
|
||||
public class ChartMajorGridLinesX : ChartMajorGridLines
|
||||
{
|
||||
public ChartMajorGridLinesX()
|
||||
: base(AxisOrientation.X)
|
||||
{
|
||||
}
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
if (Visible == true)
|
||||
{
|
||||
TickmarkTick[] ticks = TickmarkLayout.Ticks;
|
||||
|
||||
if (ticks != null)
|
||||
{
|
||||
Graphics g = renderInfo.Graphics;
|
||||
|
||||
ChartAxis axis = Parent as ChartAxis;
|
||||
ChartXy chartXy = axis.Parent as ChartXy;
|
||||
|
||||
PieGridLineVisualStyle gstyle = EffectiveStyle;
|
||||
Rectangle scContentBounds = GetScrollBounds(chartXy.ContentBounds);
|
||||
|
||||
if (gstyle.LinePattern != LinePattern.None &&
|
||||
gstyle.LinePattern != LinePattern.NotSet && gstyle.LineWidth > 0)
|
||||
{
|
||||
using (Pen pen = new Pen(gstyle.LineColor, Dpi.Width(gstyle.LineWidth)))
|
||||
{
|
||||
pen.DashStyle = (DashStyle)gstyle.LinePattern;
|
||||
|
||||
Point pt = chartXy.GetLocalAdjustedPoint(Point.Empty);
|
||||
|
||||
foreach (TickmarkTick tmi in ticks)
|
||||
{
|
||||
Point pt1 = tmi.TickPoint;
|
||||
pt1.X += pt.X;
|
||||
pt1.Y = scContentBounds.Y;
|
||||
|
||||
Point pt2 = pt1;
|
||||
pt2.Y = scContentBounds.Bottom;
|
||||
|
||||
g.DrawLine(pen, pt1, pt2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of the MajorGridLine.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartMajorGridLinesX copy = new ChartMajorGridLinesX();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the MajorGridLine to the given "copy".
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartMajorGridLinesX c = copy as ChartMajorGridLinesX;
|
||||
|
||||
if (c != null)
|
||||
base.CopyTo(c);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartMajorGridLinesY
|
||||
|
||||
/// <summary>
|
||||
/// Represents a chart's MajorGridLines for the Y-Axis.
|
||||
/// </summary>
|
||||
public class ChartMajorGridLinesY : ChartMajorGridLines
|
||||
{
|
||||
public ChartMajorGridLinesY()
|
||||
: base(AxisOrientation.Y)
|
||||
{
|
||||
}
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
if (Visible == true)
|
||||
{
|
||||
TickmarkTick[] ticks = TickmarkLayout.Ticks;
|
||||
|
||||
if (ticks != null)
|
||||
{
|
||||
Graphics g = renderInfo.Graphics;
|
||||
|
||||
ChartAxis axis = Parent as ChartAxis;
|
||||
ChartXy chartXy = axis.Parent as ChartXy;
|
||||
|
||||
PieGridLineVisualStyle gstyle = EffectiveStyle;
|
||||
Rectangle scContentBounds = GetScrollBounds(chartXy.ContentBounds);
|
||||
|
||||
if (gstyle.LinePattern != LinePattern.None &&
|
||||
gstyle.LinePattern != LinePattern.NotSet && gstyle.LineWidth > 0)
|
||||
{
|
||||
using (Pen pen = new Pen(gstyle.LineColor, Dpi.Height(gstyle.LineWidth)))
|
||||
{
|
||||
pen.DashStyle = (DashStyle)gstyle.LinePattern;
|
||||
|
||||
Point pt = chartXy.GetLocalAdjustedPoint(Point.Empty);
|
||||
|
||||
foreach (TickmarkTick tmi in ticks)
|
||||
{
|
||||
Point pt1 = tmi.TickPoint;
|
||||
pt1.X = scContentBounds.X;
|
||||
pt1.Y += pt.Y;
|
||||
|
||||
Point pt2 = pt1;
|
||||
pt2.X = scContentBounds.Right;
|
||||
|
||||
g.DrawLine(pen, pt1, pt2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of the MajorGridLine.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartMajorGridLinesY copy = new ChartMajorGridLinesY();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the MajorGridLine to the given "copy".
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartMajorGridLinesY c = copy as ChartMajorGridLinesY;
|
||||
|
||||
if (c != null)
|
||||
base.CopyTo(c);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartMajorGridLines
|
||||
|
||||
/// <summary>
|
||||
/// Represents a chart's MajorGridLines.
|
||||
/// </summary>
|
||||
public class ChartMajorGridLines : ChartGridLines
|
||||
{
|
||||
public ChartMajorGridLines(AxisOrientation orientation)
|
||||
: base(orientation)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartMinorGridLines
|
||||
|
||||
#region ChartMinorGridLinesX
|
||||
|
||||
public class ChartMinorGridLinesX : ChartMinorGridLines
|
||||
{
|
||||
public ChartMinorGridLinesX()
|
||||
: base(AxisOrientation.X)
|
||||
{
|
||||
}
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
if (Visible == true)
|
||||
{
|
||||
TickmarkTick[] ticks = TickmarkLayout.Ticks;
|
||||
|
||||
if (ticks != null && ticks.Length > 1)
|
||||
{
|
||||
Graphics g = renderInfo.Graphics;
|
||||
|
||||
ChartAxis axis = Parent as ChartAxis;
|
||||
ChartXy chartXy = axis.Parent as ChartXy;
|
||||
|
||||
PieGridLineVisualStyle gstyle = EffectiveStyle;
|
||||
Rectangle scContentBounds = GetScrollBounds(chartXy.ContentBounds);
|
||||
|
||||
if (gstyle.LinePattern != LinePattern.None &&
|
||||
gstyle.LinePattern != LinePattern.NotSet && gstyle.LineWidth > 0)
|
||||
{
|
||||
using (Pen pen = new Pen(gstyle.LineColor, Dpi.Width(gstyle.LineWidth)))
|
||||
{
|
||||
pen.DashStyle = (DashStyle)gstyle.LinePattern;
|
||||
|
||||
int minorTickCount = axis.MinorTickmarks.TickmarkCount;
|
||||
Point pt = chartXy.GetLocalAdjustedPoint(Point.Empty);
|
||||
|
||||
for (int i = 0; i < ticks.Length - 1; i++)
|
||||
{
|
||||
TickmarkTick tick = ticks[i];
|
||||
|
||||
Point pt1 = tick.TickPoint;
|
||||
pt1.Y = scContentBounds.Y;
|
||||
|
||||
Point pt2 = pt1;
|
||||
pt2.Y = scContentBounds.Bottom;
|
||||
|
||||
double dx = (double)(ticks[i + 1].TickPoint.X - tick.TickPoint.X) / (minorTickCount + 1);
|
||||
double ddx = dx;
|
||||
|
||||
for (int j = 0; j < minorTickCount; j++)
|
||||
{
|
||||
pt1.X = pt.X + (int)(tick.TickPoint.X + ddx);
|
||||
pt2.X = pt1.X;
|
||||
|
||||
ddx += dx;
|
||||
|
||||
g.DrawLine(pen, pt1, pt2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of the MinorGridLine.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartMinorGridLinesX copy = new ChartMinorGridLinesX();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the MinorGridLine to the given "copy".
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartMinorGridLinesX c = copy as ChartMinorGridLinesX;
|
||||
|
||||
if (c != null)
|
||||
base.CopyTo(c);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartMinorGridLinesY
|
||||
|
||||
public class ChartMinorGridLinesY : ChartMinorGridLines
|
||||
{
|
||||
public ChartMinorGridLinesY()
|
||||
: base(AxisOrientation.Y)
|
||||
{
|
||||
}
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
if (Visible == true)
|
||||
{
|
||||
TickmarkTick[] ticks = TickmarkLayout.Ticks;
|
||||
|
||||
if (ticks != null)
|
||||
{
|
||||
Graphics g = renderInfo.Graphics;
|
||||
|
||||
ChartAxis axis = Parent as ChartAxis;
|
||||
ChartXy chartXy = axis.Parent as ChartXy;
|
||||
|
||||
PieGridLineVisualStyle gstyle = EffectiveStyle;
|
||||
Rectangle scContentBounds = GetScrollBounds(chartXy.ContentBounds);
|
||||
|
||||
if (gstyle.LinePattern != LinePattern.None &&
|
||||
gstyle.LinePattern != LinePattern.NotSet && gstyle.LineWidth > 0)
|
||||
{
|
||||
using (Pen pen = new Pen(gstyle.LineColor, Dpi.Height(gstyle.LineWidth)))
|
||||
{
|
||||
pen.DashStyle = (DashStyle)gstyle.LinePattern;
|
||||
|
||||
int minorTickCount = axis.MinorTickmarks.TickmarkCount;
|
||||
Point pt = chartXy.GetLocalAdjustedPoint(Point.Empty);
|
||||
|
||||
for (int i = 0; i < ticks.Length - 1; i++)
|
||||
{
|
||||
TickmarkTick tick = ticks[i];
|
||||
|
||||
Point pt1 = tick.TickPoint;
|
||||
pt1.X = scContentBounds.X;
|
||||
|
||||
Point pt2 = pt1;
|
||||
pt2.X = scContentBounds.Right;
|
||||
|
||||
double dy = (double)(ticks[i + 1].TickPoint.Y - tick.TickPoint.Y) / (minorTickCount + 1);
|
||||
double ddy = dy;
|
||||
|
||||
for (int j = 0; j < axis.MinorTickmarks.TickmarkCount; j++)
|
||||
{
|
||||
pt1.Y = pt.Y + (int)(tick.TickPoint.Y + ddy);
|
||||
pt2.Y = pt1.Y;
|
||||
|
||||
ddy += dy;
|
||||
|
||||
g.DrawLine(pen, pt1, pt2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of the MinorGridLine.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override ChartVisualElement Copy()
|
||||
{
|
||||
ChartMinorGridLinesY copy = new ChartMinorGridLinesY();
|
||||
|
||||
CopyTo(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the MinorGridLine to the given "copy".
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartMinorGridLinesY c = copy as ChartMinorGridLinesY;
|
||||
|
||||
if (c != null)
|
||||
base.CopyTo(c);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartMinorGridLines
|
||||
|
||||
public class ChartMinorGridLines : ChartGridLines
|
||||
{
|
||||
public ChartMinorGridLines(AxisOrientation orientation)
|
||||
: base(orientation)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartGridLines
|
||||
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public abstract class ChartGridLines : ChartVisualElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private States _States;
|
||||
|
||||
private AxisOrientation _AxisOrientation;
|
||||
private TickmarkLayout _TickmarkLayout;
|
||||
|
||||
private PieGridLineVisualStyle _GridLinesVisualStyle;
|
||||
private EffectiveStyle<PieGridLineVisualStyle> _EffectiveStyle;
|
||||
|
||||
#endregion
|
||||
|
||||
public ChartGridLines(AxisOrientation orientation)
|
||||
{
|
||||
_AxisOrientation = orientation;
|
||||
|
||||
InitDefaultStates();
|
||||
|
||||
_EffectiveStyle = new EffectiveStyle<PieGridLineVisualStyle>(this);
|
||||
}
|
||||
|
||||
#region InitDefaultStates
|
||||
|
||||
private void InitDefaultStates()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region DisplayOnTop
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether grid lines are displayed on top of chart data.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance")]
|
||||
[Description("Indicates whether grid lines are displayed on top of chart data.")]
|
||||
public bool DisplayOnTop
|
||||
{
|
||||
get { return (TestState(States.DisplayOnTop)); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != DisplayOnTop)
|
||||
{
|
||||
SetState(States.DisplayOnTop, value);
|
||||
|
||||
OnPropertyChangedEx("DisplayOnTop", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EffectiveStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the GridLine's Effective (cached, composite) style.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public PieGridLineVisualStyle EffectiveStyle
|
||||
{
|
||||
get { return (_EffectiveStyle.Style); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GridLinesVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the GridLines.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the GridLines.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public PieGridLineVisualStyle GridLinesVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_GridLinesVisualStyle == null)
|
||||
{
|
||||
_GridLinesVisualStyle = new PieGridLineVisualStyle();
|
||||
|
||||
StyleVisualChangeHandler(null, _GridLinesVisualStyle);
|
||||
}
|
||||
|
||||
return (_GridLinesVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_GridLinesVisualStyle != value)
|
||||
{
|
||||
PieGridLineVisualStyle oldValue = _GridLinesVisualStyle;
|
||||
|
||||
_GridLinesVisualStyle = value;
|
||||
|
||||
OnVisualStyleChanged("GridLinesVisualStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region TickmarkLayout
|
||||
|
||||
internal TickmarkLayout TickmarkLayout
|
||||
{
|
||||
get { return (_TickmarkLayout); }
|
||||
set { _TickmarkLayout = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MeasureOverride
|
||||
|
||||
protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ArrangeOverride
|
||||
|
||||
protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
|
||||
{
|
||||
BoundsRelative = layoutInfo.LayoutBounds;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderOverride
|
||||
|
||||
protected override void RenderOverride(ChartRenderInfo renderInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Render
|
||||
|
||||
internal override void Render(ChartRenderInfo renderInfo)
|
||||
{
|
||||
if (Displayed == true)
|
||||
{
|
||||
Rectangle bounds = BoundsRelative;
|
||||
|
||||
if (renderInfo.ClipRectangle.IntersectsWith(bounds))
|
||||
RenderOverride(renderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style handling
|
||||
|
||||
#region ApplyStyles
|
||||
|
||||
public override void ApplyStyles(BaseVisualStyle style)
|
||||
{
|
||||
PieGridLineVisualStyle sstyle = style as PieGridLineVisualStyle;
|
||||
|
||||
if (sstyle != null)
|
||||
{
|
||||
ApplyParentStyles(sstyle, Parent as ChartContainer);
|
||||
|
||||
sstyle.ApplyStyle(GridLinesVisualStyle);
|
||||
|
||||
if (sstyle.LineColor.IsEmpty == true)
|
||||
{
|
||||
if (this is ChartMajorGridLines)
|
||||
sstyle.LineColor = Color.DimGray;
|
||||
else
|
||||
sstyle.LineColor = Color.LightGray;
|
||||
}
|
||||
|
||||
if (sstyle.LinePattern == LinePattern.NotSet)
|
||||
sstyle.LinePattern = LinePattern.Solid;
|
||||
|
||||
if (sstyle.LineWidth < 0)
|
||||
sstyle.LineWidth = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#region ApplyParentStyles
|
||||
|
||||
private void ApplyParentStyles(PieGridLineVisualStyle pstyle, ChartContainer item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
ApplyParentStyles(pstyle, item.Parent as ChartContainer);
|
||||
|
||||
if (item is ChartPanel)
|
||||
{
|
||||
pstyle.ApplyStyle(((ChartPanel)item).DefaultVisualStyles.GridLineVisualStyle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pstyle.ApplyStyle(ChartControl.BaseVisualStyles.GridLineVisualStyle);
|
||||
pstyle.ApplyStyle(ChartControl.DefaultVisualStyles.GridLineVisualStyle);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearEffectiveStyles
|
||||
|
||||
protected override void ClearEffectiveStyles()
|
||||
{
|
||||
base.ClearEffectiveStyles();
|
||||
|
||||
if (_EffectiveStyle.InvalidateStyle() == true)
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy/CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Copies the chart element to the given "copy".
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public override void CopyTo(ChartVisualElement copy)
|
||||
{
|
||||
ChartGridLines c = copy as ChartGridLines;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyTo(c);
|
||||
|
||||
c.DisplayOnTop = DisplayOnTop;
|
||||
|
||||
c.GridLinesVisualStyle = (_GridLinesVisualStyle != null) ? GridLinesVisualStyle.Copy() : null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartGridLines";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("DisplayOnTop", DisplayOnTop, false);
|
||||
|
||||
if (_GridLinesVisualStyle != null && _GridLinesVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_GridLinesVisualStyle.GetSerialData("GridLinesVisualStyle"));
|
||||
|
||||
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 "DisplayOnTop":
|
||||
DisplayOnTop = bool.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "GridLinesVisualStyle":
|
||||
sec.PutSerialData(GridLinesVisualStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
DisplayOnTop = (1U << 0),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
GridLinesVisualStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,922 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
class FlockAlign
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const long RemovePenalty = 1;
|
||||
private const int MovesPerIteration = 500;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private List<PointLabelGroup> _LabelGroups;
|
||||
|
||||
#endregion
|
||||
|
||||
public FlockAlign(List<PointLabelGroup> labelGroups)
|
||||
{
|
||||
_LabelGroups = labelGroups;
|
||||
|
||||
foreach (PointLabelGroup lg in _LabelGroups)
|
||||
{
|
||||
foreach (PointLabel pl in lg.PointLabels)
|
||||
pl.Bounds = Rectangle.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#region Iterate
|
||||
|
||||
public bool Iterate(Rectangle bounds, DataLabelOverlapMode ovlMode)
|
||||
{
|
||||
if (ovlMode == DataLabelOverlapMode.NotSet)
|
||||
ovlMode = DataLabelOverlapMode.RotateAroundPoint;
|
||||
|
||||
for (int i = 0; i < _LabelGroups.Count; i++)
|
||||
{
|
||||
PointLabelGroup lg = _LabelGroups[i];
|
||||
List<PointLabel> lps = lg.PointLabels;
|
||||
ChartSeries series = lg.ChartSeries;
|
||||
|
||||
Point lp = Point.Empty;
|
||||
|
||||
for (int j = 0; j < lps.Count; j++)
|
||||
{
|
||||
PointLabel pl = lps[j];
|
||||
|
||||
if (pl.Visible == true )
|
||||
{
|
||||
DataLabelVisualStyle dstyle = pl.DataLabelVisualStyle ?? series.EffectiveDataLabelStyle;
|
||||
|
||||
if (series.IsBarSeries == true)
|
||||
{
|
||||
if (series.IsRotated == true)
|
||||
IterateHBar(series, pl, bounds, ovlMode, dstyle);
|
||||
else
|
||||
IterateVBar(series, pl, bounds, ovlMode, dstyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
IteratePoint(series, pl, bounds, lp, ovlMode, dstyle);
|
||||
}
|
||||
}
|
||||
|
||||
lp = pl.Point;
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#region IterateHBar
|
||||
|
||||
private void IterateHBar(ChartSeries series, PointLabel pl,
|
||||
Rectangle bounds, DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
ChartXy chartXy = series.Parent as ChartXy;
|
||||
|
||||
int start = (pl.IsDataLabel == true)
|
||||
? pl.Point.X - 1 : series.GetHBarStart(chartXy, pl.SeriesPoint);
|
||||
|
||||
int end = pl.Point.X;
|
||||
|
||||
BarLabelPosition labelPos = pl.BarLabelPosition;
|
||||
|
||||
if (labelPos == BarLabelPosition.NotSet)
|
||||
labelPos = series.GetBarLabelPosition(chartXy);
|
||||
|
||||
switch (labelPos)
|
||||
{
|
||||
case BarLabelPosition.Near:
|
||||
SetHBarLabelNear(series, pl, bounds, ovlMode, dstyle, start, end, false);
|
||||
break;
|
||||
|
||||
case BarLabelPosition.NearInside:
|
||||
SetHBarLabelNear(series, pl, bounds, ovlMode, dstyle, start, end, true);
|
||||
break;
|
||||
|
||||
case BarLabelPosition.Far:
|
||||
SetHBarLabelFar(series, pl, bounds, ovlMode, dstyle, start, end, false);
|
||||
break;
|
||||
|
||||
case BarLabelPosition.FarInside:
|
||||
SetHBarLabelFar(series, pl, bounds, ovlMode, dstyle, start, end, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetHBarLabelCenter(series, pl, bounds, ovlMode, dstyle, start, end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region SetHBarLabelNear
|
||||
|
||||
private void SetHBarLabelNear(ChartSeries series, PointLabel pl, Rectangle bounds,
|
||||
DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle, int start, int end, bool inside)
|
||||
{
|
||||
ConnectorLineVisualStyle cstyle = dstyle.ConnectorLineStyle;
|
||||
|
||||
Point pt = new Point(start, pl.Point.Y + series.BarOffset);
|
||||
|
||||
Size size = GetBoundsSize(series, pl, dstyle);
|
||||
Rectangle t = Rectangle.Empty;
|
||||
|
||||
int minLength = Dpi.Width(cstyle.MinLength);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int clen = (inside == false && minLength > 0) ? minLength + Dpi.Width2 : Dpi.Width4;
|
||||
|
||||
int step = cstyle.LengthStep;
|
||||
int offset = (size.Width / 2 + clen);
|
||||
|
||||
if (inside ? end < start : end > start)
|
||||
{
|
||||
step *= -1;
|
||||
offset *= -1;
|
||||
}
|
||||
|
||||
Point ptc = pt;
|
||||
ptc.X += offset;
|
||||
|
||||
t = GetCenteredRectangle(series, ptc, size);
|
||||
|
||||
while (step < 0 ? t.X > bounds.X : t.Right < bounds.Right)
|
||||
{
|
||||
if (SetHBarLabelPos(pl, ovlMode, bounds, ptc, t, start, end) == true)
|
||||
return;
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
t.X += step;
|
||||
|
||||
if (cstyle.MaxLength > 0)
|
||||
{
|
||||
if (Math.Abs(t.X - ptc.X) > cstyle.MaxLength)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inside = !inside;
|
||||
}
|
||||
|
||||
SetHBarDefaultLabelPos(series, ref pl, pt, t, ovlMode, start, end);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetHBarLabelFar
|
||||
|
||||
private void SetHBarLabelFar(ChartSeries series, PointLabel pl, Rectangle bounds,
|
||||
DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle, int start, int end, bool inside)
|
||||
{
|
||||
ConnectorLineVisualStyle cstyle = dstyle.ConnectorLineStyle;
|
||||
|
||||
Point pt = new Point(end, pl.Point.Y + series.BarOffset);
|
||||
Size size = GetBoundsSize(series, pl, dstyle);
|
||||
|
||||
Rectangle t = Rectangle.Empty;
|
||||
|
||||
int minLength = Dpi.Width(cstyle.MinLength);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int clen = (inside == false && minLength >= 0) ? minLength + Dpi.Width2 : Dpi.Width4;
|
||||
|
||||
int step = cstyle.LengthStep;
|
||||
int offset = (size.Width / 2 + clen);
|
||||
|
||||
if (inside ? end > start : end < start)
|
||||
{
|
||||
step *= -1;
|
||||
offset *= -1;
|
||||
}
|
||||
|
||||
Point ptc = pt;
|
||||
ptc.X += offset;
|
||||
|
||||
t = GetCenteredRectangle(series, ptc, size);
|
||||
|
||||
while (step < 0 ? t.X > bounds.X : t.Right < bounds.Right)
|
||||
{
|
||||
if (SetHBarLabelPos(pl, ovlMode, bounds, ptc, t, start, end) == true)
|
||||
return;
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
t.X += step;
|
||||
|
||||
if (cstyle.MaxLength > 0)
|
||||
{
|
||||
if (Math.Abs(t.X - ptc.X) > cstyle.MaxLength)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inside = !inside;
|
||||
}
|
||||
|
||||
SetHBarDefaultLabelPos(series, ref pl, pt, t, ovlMode, start, end);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetHBarLabelCenter
|
||||
|
||||
private void SetHBarLabelCenter(ChartSeries series, PointLabel pl,
|
||||
Rectangle bounds, DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle,
|
||||
int start, int end)
|
||||
{
|
||||
Point pt = new Point((end + start) / 2, pl.Point.Y + series.BarOffset);
|
||||
|
||||
int pass = 0;
|
||||
int step = 2;
|
||||
int startx = pt.X;
|
||||
|
||||
Size size = GetBoundsSize(series, pl, dstyle);
|
||||
|
||||
Rectangle t = GetCenteredRectangle(series, pt, size);
|
||||
|
||||
int len = (end + start) / 2;
|
||||
|
||||
while (pass <= len)
|
||||
{
|
||||
if (SetHBarLabelPos(pl, ovlMode, bounds, pt, t, start, end) == true)
|
||||
return;
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
int pval = pass / 2 + 1;
|
||||
|
||||
if (pass % 2 > 0)
|
||||
pval = -pval;
|
||||
|
||||
t.X = (startx + (pval * step));
|
||||
|
||||
pass++;
|
||||
}
|
||||
|
||||
SetHBarDefaultLabelPos(series, ref pl, pt, t, ovlMode, start, end);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetHBarLabelPos
|
||||
|
||||
private bool SetHBarLabelPos(PointLabel pl,
|
||||
DataLabelOverlapMode ovlMode, Rectangle bounds, Point pt, Rectangle t, int start, int end)
|
||||
{
|
||||
if (IsFreeArea(t, bounds, ovlMode, false, true) == true)
|
||||
{
|
||||
pl.Bounds = t;
|
||||
|
||||
SetHBarEdgePoint(pl, pt, t, start, end);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (ovlMode == DataLabelOverlapMode.HideOverlapping)
|
||||
return (true);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetHBarDefaultLabelPos
|
||||
|
||||
private void SetHBarDefaultLabelPos(ChartSeries series, ref PointLabel pl,
|
||||
Point pt, Rectangle t, DataLabelOverlapMode ovlMode, int start, int end)
|
||||
{
|
||||
if (ovlMode == DataLabelOverlapMode.RotateAroundPoint)
|
||||
{
|
||||
if (t.X < start)
|
||||
t.X = start + Dpi.Width4;
|
||||
else
|
||||
t.X = end - (t.Width + Dpi.Width4);
|
||||
|
||||
ChartXy chartXy = series.Parent as ChartXy;
|
||||
|
||||
Rectangle bounds = chartXy.ContentBoundsEx;
|
||||
|
||||
if (t.Right > bounds.Right)
|
||||
t.X -= (t.Right - bounds.Right + Dpi.Width4);
|
||||
|
||||
if (t.X < bounds.X)
|
||||
t.X = bounds.X + Dpi.Width4;
|
||||
|
||||
pl.Bounds = t;
|
||||
|
||||
SetHBarEdgePoint(pl, pt, t, start, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
pl.Bounds = Rectangle.Empty;
|
||||
pl.EdgePoint = Point.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetHBarEdgePoint
|
||||
|
||||
private void SetHBarEdgePoint(PointLabel pl, Point pt, Rectangle t, int start, int end)
|
||||
{
|
||||
if (t.X > start && t.X > end)
|
||||
{
|
||||
pt.X = Math.Max(start, end);
|
||||
pl.EdgePoint = new Point(t.X, pt.Y);
|
||||
}
|
||||
else if (t.X < start && t.X < end)
|
||||
{
|
||||
pt.X = Math.Min(start, end);
|
||||
pl.EdgePoint = new Point(t.Right, pt.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
pl.EdgePoint = Point.Empty;
|
||||
}
|
||||
|
||||
pl.Point = pt;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IterateVBar
|
||||
|
||||
private void IterateVBar(ChartSeries series, PointLabel pl,
|
||||
Rectangle bounds, DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
ChartXy chartXy = series.Parent as ChartXy;
|
||||
|
||||
int start = series.GetVBarStart(chartXy, pl.SeriesPoint);
|
||||
int end = pl.Point.Y;
|
||||
|
||||
BarLabelPosition labelPos = series.GetBarLabelPosition(chartXy);
|
||||
|
||||
switch (labelPos)
|
||||
{
|
||||
case BarLabelPosition.Near:
|
||||
SetVBarLabelNear(series, pl, bounds, ovlMode, dstyle, start, end, false);
|
||||
break;
|
||||
|
||||
case BarLabelPosition.NearInside:
|
||||
SetVBarLabelNear(series, pl, bounds, ovlMode, dstyle, start, end, true);
|
||||
break;
|
||||
|
||||
case BarLabelPosition.Far:
|
||||
SetVBarLabelFar(series, pl, bounds, ovlMode, dstyle, start, end, false);
|
||||
break;
|
||||
|
||||
case BarLabelPosition.FarInside:
|
||||
SetVBarLabelFar(series, pl, bounds, ovlMode, dstyle, start, end, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetVBarLabelCenter(series, pl, bounds, ovlMode, dstyle, start, end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region SetVBarLabelNear
|
||||
|
||||
private void SetVBarLabelNear(ChartSeries series, PointLabel pl, Rectangle bounds,
|
||||
DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle, int start, int end, bool inside)
|
||||
{
|
||||
ConnectorLineVisualStyle cstyle = dstyle.ConnectorLineStyle;
|
||||
|
||||
Point pt = new Point(pl.Point.X + series.BarOffset, start);
|
||||
Size size = GetBoundsSize(series, pl, dstyle);
|
||||
|
||||
int minLength = Dpi.Width(cstyle.MinLength);
|
||||
|
||||
int clen = (inside == false && minLength >= 0) ? minLength + Dpi.Width2 : Dpi.Width4;
|
||||
|
||||
int step = cstyle.LengthStep;
|
||||
int offset = (size.Height / 2 + clen);
|
||||
|
||||
Rectangle t = Rectangle.Empty;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (inside ? end < start : end > start)
|
||||
{
|
||||
step *= -1;
|
||||
offset *= -1;
|
||||
}
|
||||
|
||||
Point ptc = pt;
|
||||
ptc.Y += offset;
|
||||
|
||||
t = GetCenteredRectangle(series, ptc, size);
|
||||
|
||||
while (t.Y < bounds.Bottom)
|
||||
{
|
||||
if (SetVBarLabelPos(pl, ovlMode, bounds, ptc, t, start, end) == true)
|
||||
return;
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
t.Y += step;
|
||||
|
||||
if (cstyle.MaxLength > 0)
|
||||
{
|
||||
if (Math.Abs(t.Y - ptc.Y) > cstyle.MaxLength)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inside = !inside;
|
||||
}
|
||||
|
||||
SetVBarDefaultLabelPos(series, ref pl, pt, t, ovlMode, start, end);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetVBarLabelFar
|
||||
|
||||
private void SetVBarLabelFar(ChartSeries series, PointLabel pl, Rectangle bounds,
|
||||
DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle, int start, int end, bool inside)
|
||||
{
|
||||
ConnectorLineVisualStyle cstyle = dstyle.ConnectorLineStyle;
|
||||
|
||||
Point pt = new Point(pl.Point.X + series.BarOffset, end);
|
||||
Size size = GetBoundsSize(series, pl, dstyle);
|
||||
|
||||
int minLength = Dpi.Width(cstyle.MinLength);
|
||||
|
||||
Rectangle t = Rectangle.Empty;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int clen = (inside == false && minLength >= 0) ? minLength + Dpi.Width2 : Dpi.Width4;
|
||||
|
||||
int step = cstyle.LengthStep;
|
||||
int offset = (size.Height / 2 + clen);
|
||||
|
||||
if (inside ? end > start : end < start)
|
||||
{
|
||||
step *= -1;
|
||||
offset *= -1;
|
||||
}
|
||||
|
||||
Point ptc = pt;
|
||||
ptc.Y += offset;
|
||||
|
||||
t = GetCenteredRectangle(series, ptc, size);
|
||||
|
||||
while (step < 0 ? t.Y > bounds.Y : t.Y < bounds.Bottom)
|
||||
{
|
||||
if (SetVBarLabelPos(pl, ovlMode, bounds, ptc, t, start, end) == true)
|
||||
return;
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
t.Y += step;
|
||||
|
||||
if (cstyle.MaxLength > 0)
|
||||
{
|
||||
if (Math.Abs(t.Y - ptc.Y) > cstyle.MaxLength)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inside = !inside;
|
||||
}
|
||||
|
||||
SetVBarDefaultLabelPos(series, ref pl, pt, t, ovlMode, start, end);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetVBarLabelCenter
|
||||
|
||||
private void SetVBarLabelCenter(ChartSeries series, PointLabel pl,
|
||||
Rectangle bounds, DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle,
|
||||
int origin, int end)
|
||||
{
|
||||
Point pt = new Point(pl.Point.X + series.BarOffset, (end + origin) / 2);
|
||||
|
||||
int pass = 0;
|
||||
int step = 2;
|
||||
int starty = pt.Y;
|
||||
|
||||
Size size = GetBoundsSize(series, pl, dstyle);
|
||||
|
||||
Rectangle t = GetCenteredRectangle(series, pt, size);
|
||||
|
||||
int len = (end + origin) / 2;
|
||||
|
||||
while (pass <= len)
|
||||
{
|
||||
if (SetVBarLabelPos(pl, ovlMode, bounds, pt, t, origin, end) == true)
|
||||
return;
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
int pval = pass / 2 + 1;
|
||||
|
||||
if (pass % 2 > 0)
|
||||
pval = -pval;
|
||||
|
||||
t.Y = (starty + (pval * step));
|
||||
|
||||
pass++;
|
||||
}
|
||||
|
||||
SetVBarDefaultLabelPos(series, ref pl, pt, t, ovlMode, origin, end);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetVBarLabelPos
|
||||
|
||||
private bool SetVBarLabelPos(PointLabel pl,
|
||||
DataLabelOverlapMode ovlMode, Rectangle bounds, Point pt, Rectangle t, int start, int end)
|
||||
{
|
||||
if (IsFreeArea(t, bounds, ovlMode, false, true) == true)
|
||||
{
|
||||
pl.Bounds = t;
|
||||
|
||||
SetVBarEdgePoint(pl, pt, t, start, end);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (ovlMode == DataLabelOverlapMode.HideOverlapping)
|
||||
return (true);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetVBarDefaultLabelPos
|
||||
|
||||
private void SetVBarDefaultLabelPos(ChartSeries series, ref PointLabel pl,
|
||||
Point pt, Rectangle t, DataLabelOverlapMode ovlMode, int start, int end)
|
||||
{
|
||||
if (ovlMode == DataLabelOverlapMode.RotateAroundPoint)
|
||||
{
|
||||
if (t.Y > start)
|
||||
t.Y = start - (t.Height + Dpi.Height4);
|
||||
else
|
||||
t.Y = end + Dpi.Height4;
|
||||
|
||||
ChartXy chartXy = series.Parent as ChartXy;
|
||||
|
||||
Rectangle bounds = chartXy.ContentBoundsEx;
|
||||
|
||||
if (t.Y > bounds.Bottom)
|
||||
t.Y -= (t.Bottom - bounds.Bottom + Dpi.Height4);
|
||||
|
||||
if (t.Y < bounds.Y)
|
||||
t.Y = bounds.Y + Dpi.Height4;
|
||||
|
||||
pl.Bounds = t;
|
||||
|
||||
SetVBarEdgePoint(pl, pt, t, start, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
pl.Bounds = Rectangle.Empty;
|
||||
pl.EdgePoint = Point.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetVBarEdgePoint
|
||||
|
||||
private void SetVBarEdgePoint(PointLabel pl, Point pt, Rectangle t, int start, int end)
|
||||
{
|
||||
if (t.Y > start && t.Y > end)
|
||||
{
|
||||
pt.Y = Math.Max(start, end);
|
||||
pl.EdgePoint = new Point(pt.X, t.Y);
|
||||
}
|
||||
else if (t.Y < start && t.Y < end)
|
||||
{
|
||||
pt.Y = Math.Min(start, end);
|
||||
pl.EdgePoint = new Point(pt.X, t.Bottom);
|
||||
}
|
||||
else
|
||||
{
|
||||
pl.EdgePoint = Point.Empty;
|
||||
}
|
||||
|
||||
pl.Point = pt;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IteratePoint
|
||||
|
||||
private void IteratePoint(ChartSeries series, PointLabel pl,
|
||||
Rectangle bounds, Point lp, DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
if ((dstyle.CenterLabel != Tbool.True) ||
|
||||
SetLabelCenter(series, pl, bounds, ovlMode, dstyle) == false)
|
||||
{
|
||||
ConnectorLineVisualStyle cstyle = dstyle.ConnectorLineStyle;
|
||||
|
||||
int step;
|
||||
int startAngle = GetStartAngle(lp, pl, cstyle, out step);
|
||||
|
||||
int offset = 0;
|
||||
|
||||
if (cstyle.Origin == ConnectorOrigin.Edge)
|
||||
{
|
||||
offset = Math.Max(
|
||||
pl.SeriesPoint.PointSize.Width,
|
||||
pl.SeriesPoint.PointSize.Height) / 2;
|
||||
}
|
||||
|
||||
SetLabel(series, pl, startAngle, step,
|
||||
cstyle.MinLength + offset, cstyle.MaxLength + offset, ovlMode, bounds, dstyle);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetBoundsSize
|
||||
|
||||
private Size GetBoundsSize(
|
||||
ChartSeries series, PointLabel pl, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
RotateDegrees rotate = series.GetRotateDegrees(dstyle);
|
||||
|
||||
Size size = (rotate == RotateDegrees.Rotate90 || rotate == RotateDegrees.Rotate270)
|
||||
? new Size(pl.LabelSize.Height, pl.LabelSize.Width) : pl.LabelSize;
|
||||
|
||||
if (dstyle.HasBorder == true)
|
||||
{
|
||||
size.Width += (dstyle.BorderThickness << 1);
|
||||
size.Height += (dstyle.BorderThickness << 1);
|
||||
}
|
||||
|
||||
size.Width += dstyle.Padding.Horizontal;
|
||||
size.Height += dstyle.Padding.Vertical;
|
||||
|
||||
return (size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetLabelCenter
|
||||
|
||||
private bool SetLabelCenter(ChartSeries series, PointLabel pl,
|
||||
Rectangle bounds, DataLabelOverlapMode ovlMode, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
Rectangle t = GetCenteredRectangle(series, pl.Point, pl.LabelSize);
|
||||
|
||||
if (IsFreeArea(t, bounds, ovlMode, true, true) == true)
|
||||
{
|
||||
pl.Bounds = t;
|
||||
pl.EdgePoint = new Point(t.Right, t.Bottom);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (ovlMode == DataLabelOverlapMode.HideOverlapping)
|
||||
return (true);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetLabel
|
||||
|
||||
private bool SetLabel(ChartSeries series, PointLabel pl, int startAngle, int step,
|
||||
int radius, int maxRadius, DataLabelOverlapMode ovlMode, Rectangle bounds, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
int angle = startAngle;
|
||||
int pass = 0;
|
||||
|
||||
radius = Dpi.Width(radius);
|
||||
maxRadius = Dpi.Width(maxRadius);
|
||||
|
||||
while (radius <= maxRadius)
|
||||
{
|
||||
Point calcPoint;
|
||||
Rectangle r = GetAreaRectangle(series, pl, angle, radius, out calcPoint, dstyle);
|
||||
|
||||
if (IsFreeArea(r, bounds, ovlMode, true, true) == true)
|
||||
{
|
||||
pl.Angle = angle;
|
||||
pl.Bounds = r;
|
||||
pl.EdgePoint = calcPoint;
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (ovlMode != DataLabelOverlapMode.RotateAroundPoint)
|
||||
break;
|
||||
|
||||
int pval = pass / 2 + 1;
|
||||
|
||||
if (pass % 2 > 0)
|
||||
pval = -pval;
|
||||
|
||||
angle = (startAngle + (pval * step)) % 360;
|
||||
|
||||
pass++;
|
||||
|
||||
if (pass * step >= 360)
|
||||
{
|
||||
radius += Dpi.Width15;
|
||||
pass = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pl.Bounds = Rectangle.Empty;
|
||||
pl.EdgePoint = Point.Empty;
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetStartAngle
|
||||
|
||||
private int GetStartAngle(Point lp,
|
||||
PointLabel pl, ConnectorLineVisualStyle cstyle, out int step)
|
||||
{
|
||||
step = cstyle.AngleStep;
|
||||
|
||||
if (cstyle.DefaultAngle >= 0)
|
||||
return (cstyle.DefaultAngle);
|
||||
|
||||
Point pt = pl.Point;
|
||||
|
||||
int rise = lp.Y - pt.Y;
|
||||
int run = lp.X - pt.X;
|
||||
|
||||
double slope = (run == 0) ? 0 : (double)rise / run;
|
||||
|
||||
return ((slope < 1) ? 270 : (slope > 0) ? 315 : 225);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCenteredRectangle
|
||||
|
||||
private Rectangle GetCenteredRectangle(
|
||||
ChartSeries series, Point pt, Size labelSize)
|
||||
{
|
||||
Rectangle r = new Rectangle(pt, labelSize);
|
||||
|
||||
r.X -= (r.Width / 2);
|
||||
r.Y -= (r.Height / 2);
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetAreaRectangle
|
||||
|
||||
private Rectangle GetAreaRectangle(ChartSeries series, PointLabel pl,
|
||||
int angle, int radius, out Point calcPoint, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
Rectangle r = new Rectangle(pl.Point, pl.LabelSize);
|
||||
|
||||
RotateDegrees rotate = series.GetRotateDegrees(dstyle);
|
||||
|
||||
if (rotate == RotateDegrees.Rotate90 || rotate == RotateDegrees.Rotate270)
|
||||
{
|
||||
r.Width = pl.LabelSize.Height;
|
||||
r.Height = pl.LabelSize.Width;
|
||||
}
|
||||
|
||||
if (dstyle.HasBorder == true)
|
||||
{
|
||||
int n = Dpi.Width(dstyle.BorderThickness) << 1;
|
||||
|
||||
r.Width += n;
|
||||
r.Height += n;
|
||||
}
|
||||
|
||||
r.Width += Dpi.Width(dstyle.Padding.Horizontal);
|
||||
r.Height += Dpi.Height(dstyle.Padding.Vertical);
|
||||
|
||||
r.X += (int)(radius * Math.Cos(MathHelper.ToRadians(angle)));
|
||||
r.Y += (int)(radius * Math.Sin(MathHelper.ToRadians(angle)));
|
||||
|
||||
calcPoint = r.Location;
|
||||
|
||||
return (OffsetAreaRectangle(r, angle, ref calcPoint, dstyle));
|
||||
}
|
||||
|
||||
#region OffsetAreaRectangle
|
||||
|
||||
private Rectangle OffsetAreaRectangle(Rectangle r,
|
||||
int angle, ref Point calcPoint, DataLabelVisualStyle dstyle)
|
||||
{
|
||||
if (angle == 0)
|
||||
{
|
||||
r.Y -= (r.Height / 2);
|
||||
}
|
||||
else if (angle == 90)
|
||||
{
|
||||
r.X -= (r.Width / 2);
|
||||
}
|
||||
else if (angle == 180)
|
||||
{
|
||||
r.X -= r.Width;
|
||||
r.Y -= (r.Height / 2);
|
||||
}
|
||||
else if (angle == 270)
|
||||
{
|
||||
r.X -= (r.Width / 2);
|
||||
r.Y -= r.Height;
|
||||
}
|
||||
else if (angle < 90)
|
||||
{
|
||||
}
|
||||
else if (angle < 180)
|
||||
{
|
||||
r.X -= r.Width;
|
||||
}
|
||||
else if (angle < 270)
|
||||
{
|
||||
r.X -= r.Width;
|
||||
r.Y -= r.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Y -= r.Height;
|
||||
}
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsFreeArea
|
||||
|
||||
private bool IsFreeArea(
|
||||
Rectangle r, Rectangle bounds, DataLabelOverlapMode ovlMode, bool xos, bool yos)
|
||||
{
|
||||
if (xos == true)
|
||||
{
|
||||
if (r.X < bounds.X || r.Right > bounds.Right)
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (yos == true)
|
||||
{
|
||||
if (r.Y < bounds.Y || r.Bottom > bounds.Bottom)
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (ovlMode == DataLabelOverlapMode.ShowOverlapping)
|
||||
return (true);
|
||||
|
||||
r.Inflate(3, 3);
|
||||
|
||||
for (int i = 0; i < _LabelGroups.Count; i++)
|
||||
{
|
||||
List<PointLabel> lps = _LabelGroups[i].PointLabels;
|
||||
|
||||
for (int j = 0; j < lps.Count; j++)
|
||||
{
|
||||
PointLabel pl = lps[j];
|
||||
|
||||
if (pl.Bounds.IsEmpty == false)
|
||||
{
|
||||
if (pl.Bounds.IntersectsWith(r) == true)
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a PointLabel group.
|
||||
/// </summary>
|
||||
public class PointLabelGroup
|
||||
{
|
||||
#region Private data
|
||||
|
||||
private ChartSeries _ChartSeries;
|
||||
private List<PointLabel> _PointLabels;
|
||||
|
||||
#endregion
|
||||
|
||||
public PointLabelGroup(ChartSeries chartSeries, List<PointLabel> pointLabels)
|
||||
{
|
||||
_ChartSeries = chartSeries;
|
||||
_PointLabels = pointLabels;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region ChartSeries
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the associated chart series.
|
||||
/// </summary>
|
||||
public ChartSeries ChartSeries
|
||||
{
|
||||
get { return (_ChartSeries); }
|
||||
set { _ChartSeries = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PointLabels
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the associated list of PointLabels.
|
||||
/// </summary>
|
||||
public List<PointLabel> PointLabels
|
||||
{
|
||||
get { return (_PointLabels); }
|
||||
set { _PointLabels = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a PointLabel (label associated with a data point in the chart).
|
||||
/// </summary>
|
||||
public class PointLabel : IDisposable
|
||||
{
|
||||
#region Private data
|
||||
|
||||
private SeriesPoint _SeriesPoint;
|
||||
|
||||
private float _Angle;
|
||||
private Rectangle _Bounds;
|
||||
private Point _EdgePoint;
|
||||
private Point _Point;
|
||||
|
||||
private string _Label;
|
||||
private Size _LabelSize;
|
||||
|
||||
private BarLabelPosition _BarLabelPosition = BarLabelPosition.NotSet;
|
||||
|
||||
private DataLabelVisualStyle _DataLabelVisualStyle;
|
||||
|
||||
private States _States;
|
||||
|
||||
#endregion
|
||||
|
||||
public PointLabel(SeriesPoint sp, Point pt, string label)
|
||||
{
|
||||
_SeriesPoint = sp;
|
||||
_Point = pt;
|
||||
_Label = label;
|
||||
|
||||
InitDefaultStates();
|
||||
}
|
||||
|
||||
#region InitDefaultStates
|
||||
|
||||
private void InitDefaultStates()
|
||||
{
|
||||
SetState(States.Visible, true);
|
||||
SetState(States.NeedsMeasured, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Angle
|
||||
|
||||
/// <summary>
|
||||
/// Gets the angle used to display the point label
|
||||
/// associated with the data point.
|
||||
/// </summary>
|
||||
public float Angle
|
||||
{
|
||||
get { return (_Angle); }
|
||||
internal set { _Angle = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BarLabelPosition
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position of bar series labels.
|
||||
/// </summary>
|
||||
[Description("Indicates the position of bar series labels.")]
|
||||
public BarLabelPosition BarLabelPosition
|
||||
{
|
||||
get { return (_BarLabelPosition); }
|
||||
set { _BarLabelPosition = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DataLabelVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the data label.
|
||||
/// </summary>
|
||||
public DataLabelVisualStyle DataLabelVisualStyle
|
||||
{
|
||||
get { return (_DataLabelVisualStyle); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _DataLabelVisualStyle)
|
||||
{
|
||||
DataLabelVisualStyle oldValue = _DataLabelVisualStyle;
|
||||
|
||||
_DataLabelVisualStyle = value;
|
||||
|
||||
StyleVisualChangeHandler(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FixedSize
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set whether the LabelSize is a fixed size.
|
||||
/// </summary>
|
||||
public bool IsFixedSize
|
||||
{
|
||||
get { return (TestState(States.IsFixedSize)); }
|
||||
set { SetState(States.IsFixedSize, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Label
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label text
|
||||
/// </summary>
|
||||
public string Label
|
||||
{
|
||||
get { return (_Label); }
|
||||
|
||||
set
|
||||
{
|
||||
NeedsMeasured = true;
|
||||
|
||||
_Label = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LabelSize
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label size.
|
||||
/// </summary>
|
||||
public Size LabelSize
|
||||
{
|
||||
get { return (_LabelSize); }
|
||||
|
||||
set
|
||||
{
|
||||
_LabelSize = value;
|
||||
|
||||
NeedsMeasured = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SeriesPoint
|
||||
|
||||
/// <summary>
|
||||
/// Gets the associated SeriesPoint.
|
||||
/// </summary>
|
||||
public SeriesPoint SeriesPoint
|
||||
{
|
||||
get { return (_SeriesPoint); }
|
||||
internal set { _SeriesPoint = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Visible
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the label is visible.
|
||||
/// </summary>
|
||||
public bool Visible
|
||||
{
|
||||
get { return (TestState(States.Visible)); }
|
||||
set { SetState(States.Visible, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region Bounds
|
||||
|
||||
internal Rectangle Bounds
|
||||
{
|
||||
get { return (_Bounds); }
|
||||
set { _Bounds = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EdgePoint
|
||||
|
||||
internal Point EdgePoint
|
||||
{
|
||||
get { return (_EdgePoint); }
|
||||
set { _EdgePoint = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsDataLabel
|
||||
|
||||
internal bool IsDataLabel
|
||||
{
|
||||
get { return (TestState(States.IsDataLabel)); }
|
||||
set { SetState(States.IsDataLabel, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NeedsMeasured
|
||||
|
||||
internal bool NeedsMeasured
|
||||
{
|
||||
get { return (TestState(States.NeedsMeasured)); }
|
||||
set { SetState(States.NeedsMeasured, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Point
|
||||
|
||||
internal Point Point
|
||||
{
|
||||
get { return (_Point); }
|
||||
set { _Point = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region States
|
||||
|
||||
[Flags]
|
||||
private enum States : uint
|
||||
{
|
||||
IsFixedSize = (1U << 0),
|
||||
NeedsMeasured = (1U << 1),
|
||||
Visible = (1U << 2),
|
||||
IsDataLabel = (1U << 3),
|
||||
}
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(States state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(States state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleVisualChangeHandler
|
||||
|
||||
private void StyleVisualChangeHandler(
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
oldValue.PropertyChanged -= StyleChanged;
|
||||
|
||||
if (newValue != null)
|
||||
newValue.PropertyChanged += StyleChanged;
|
||||
}
|
||||
|
||||
private void StyleChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
NeedsMeasured = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DataLabelVisualStyle = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,565 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
internal class PointMarker : IDisposable
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private List<BitmapEntry> _Bitmaps = new List<BitmapEntry>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMarkerBitmap
|
||||
|
||||
public Bitmap GetMarkerBitmap(Graphics g, PointMarkerType markerType, int markerPoints,
|
||||
Size size, int markerRotation, Background background, Color borderColor, int borderWidth)
|
||||
{
|
||||
if (markerType == PointMarkerType.None || markerType == PointMarkerType.NotSet)
|
||||
return (null);
|
||||
|
||||
if (markerType == PointMarkerType.Cross ||
|
||||
background == null || background.IsEmpty)
|
||||
{
|
||||
if (borderColor.IsEmpty)
|
||||
borderColor = Color.Black;
|
||||
}
|
||||
|
||||
// Add margin to permit better antialiasing of image
|
||||
|
||||
size.Width++;
|
||||
size.Height++;
|
||||
|
||||
Bitmap bitmap = null;
|
||||
|
||||
bitmap = FindBitmap(markerType, markerPoints,
|
||||
size, markerRotation, background, borderColor, borderWidth);
|
||||
|
||||
if (bitmap == null)
|
||||
{
|
||||
size.Width = Math.Max(size.Width, 3);
|
||||
size.Height = Math.Max(size.Height, 3);
|
||||
|
||||
Rectangle r = new Rectangle(Point.Empty, size);
|
||||
|
||||
using (GraphicsPath path =
|
||||
GetMarkerPath(markerType, markerPoints, markerRotation, r, borderWidth))
|
||||
{
|
||||
if (path != null)
|
||||
{
|
||||
bitmap = new Bitmap(size.Width, size.Height, g);
|
||||
|
||||
using (Graphics gBmp = Graphics.FromImage(bitmap))
|
||||
{
|
||||
gBmp.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
FillMarkerPath(gBmp, path, r, markerType, background, borderColor, borderWidth);
|
||||
|
||||
if (markerRotation != 0 && markerRotation != -1)
|
||||
{
|
||||
Bitmap bitmap2 = RotatePic(bitmap, markerRotation);
|
||||
|
||||
bitmap.Dispose();
|
||||
|
||||
bitmap = bitmap2;
|
||||
}
|
||||
|
||||
_Bitmaps.Add(new BitmapEntry(markerType, size, markerPoints,
|
||||
markerRotation, background, borderColor, borderWidth, bitmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (bitmap);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FindBitmap
|
||||
|
||||
public Bitmap FindBitmap(PointMarkerType markerType, int markerPoints,
|
||||
Size size, int markerRotation, Background background, Color borderColor, int borderWidth)
|
||||
{
|
||||
foreach (BitmapEntry entry in _Bitmaps)
|
||||
{
|
||||
if (entry.MarkerType == markerType &&
|
||||
entry.MarkerPoints == markerPoints &&
|
||||
entry.MarkerRotation == markerRotation &&
|
||||
entry.MarkerSize.Equals(size) &&
|
||||
entry.BorderWidth == borderWidth &&
|
||||
entry.BorderColor.Equals(borderColor) &&
|
||||
entry.Background.IsEqualTo(background))
|
||||
{
|
||||
return (entry.Bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMarkerPath
|
||||
|
||||
internal GraphicsPath GetMarkerPath( PointMarkerType markerType,
|
||||
int markerPoints, int markerRotation, Rectangle r, int borderWidth)
|
||||
{
|
||||
r.Inflate(-borderWidth, -borderWidth);
|
||||
|
||||
if (r.Width > 0 && r.Height > 0)
|
||||
{
|
||||
switch (markerType)
|
||||
{
|
||||
case PointMarkerType.Ellipse:
|
||||
return (GetCirclePath(r));
|
||||
|
||||
case PointMarkerType.Cross:
|
||||
return (GetCrossPath(r, markerPoints));
|
||||
|
||||
case PointMarkerType.Diamond:
|
||||
return (GetDiamondPath(r));
|
||||
|
||||
case PointMarkerType.Rectangle:
|
||||
return (GetRectanglePath(r));
|
||||
|
||||
case PointMarkerType.Star:
|
||||
return (GetStarPath(r, markerPoints));
|
||||
|
||||
case PointMarkerType.Triangle:
|
||||
return (GetTrianglePath(r));
|
||||
|
||||
default:
|
||||
return (GetPolygonPath(r, markerPoints));
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#region GetCirclePath
|
||||
|
||||
private GraphicsPath GetCirclePath(Rectangle r)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
path.AddEllipse(r);
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCrossPath
|
||||
|
||||
private GraphicsPath GetCrossPath(Rectangle r, int points)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
PointF[] pts = new PointF[2 * points];
|
||||
|
||||
double rx1 = r.Width / 2;
|
||||
double ry1 = r.Height / 2;
|
||||
|
||||
if (rx1 < 2)
|
||||
rx1 = 2;
|
||||
|
||||
if (ry1 < 2)
|
||||
ry1 = 2;
|
||||
|
||||
double cx = r.X + rx1;
|
||||
double cy = r.Y + ry1;
|
||||
|
||||
double theta = MathHelper.ToRadians(270);
|
||||
double dtheta = Math.PI / points;
|
||||
|
||||
for (int i = 0; i < 2 * points; i += 2)
|
||||
{
|
||||
pts[i] = new PointF(
|
||||
(float)(cx + rx1 * Math.Cos(theta)),
|
||||
(float)(cy + ry1 * Math.Sin(theta)));
|
||||
|
||||
pts[i + 1] = new PointF((float)cx, (float)cy);
|
||||
|
||||
theta += (dtheta * 2);
|
||||
}
|
||||
|
||||
path.AddPolygon(pts);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDiamondPath
|
||||
|
||||
private GraphicsPath GetDiamondPath(Rectangle r)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
int dx = r.Width / 2;
|
||||
int dy = r.Height / 2;
|
||||
|
||||
int mx = r.X + dx;
|
||||
int my = r.Y + dy;
|
||||
|
||||
Point[] pts =
|
||||
{
|
||||
new Point(mx, my - dy),
|
||||
new Point(mx + dx, my),
|
||||
new Point(mx, my + dy),
|
||||
new Point(mx - dx, my),
|
||||
};
|
||||
|
||||
path.AddPolygon(pts);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPolygonPath
|
||||
|
||||
private GraphicsPath GetPolygonPath(Rectangle r, int sides)
|
||||
{
|
||||
if (sides <= 4)
|
||||
return (GetRectanglePath(r));
|
||||
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
int radius = Math.Min(r.Width, r.Height);
|
||||
|
||||
float dx = (float)radius / 2;
|
||||
float radians = (float)MathHelper.ToRadians(270);
|
||||
float delta = (float)MathHelper.ToRadians((float)360 / sides);
|
||||
|
||||
Point[] pts = new Point[sides];
|
||||
|
||||
for (int i = 0; i < sides; i++)
|
||||
{
|
||||
pts[i] = new Point(
|
||||
(int)(dx * Math.Cos(radians) + dx + r.X),
|
||||
(int)(dx * Math.Sin(radians) + dx + r.Y));
|
||||
|
||||
radians += delta;
|
||||
}
|
||||
|
||||
path.AddPolygon(pts);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
if (r.Width != r.Height)
|
||||
{
|
||||
PointF[] dp =
|
||||
{
|
||||
new PointF(0, 0),
|
||||
new PointF(r.Width, 0),
|
||||
new PointF(0, r.Height),
|
||||
};
|
||||
|
||||
path.Warp(dp, new RectangleF(0, 0, radius, radius));
|
||||
}
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRectanglePath
|
||||
|
||||
private GraphicsPath GetRectanglePath(Rectangle r)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
path.AddRectangle(r);
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetStarPath
|
||||
|
||||
private GraphicsPath GetStarPath(Rectangle r, int points)
|
||||
{
|
||||
if (points < 2)
|
||||
points = 2;
|
||||
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
PointF[] pts = new PointF[2 * points];
|
||||
|
||||
double rx1 = r.Width / 2;
|
||||
double ry1 = r.Height / 2;
|
||||
|
||||
if (rx1 < 2)
|
||||
rx1 = 2;
|
||||
|
||||
if (ry1 < 2)
|
||||
ry1 = 2;
|
||||
|
||||
double rx2 = rx1 / 2;
|
||||
double ry2 = ry1 / 2;
|
||||
|
||||
double cx = r.X + rx1;
|
||||
double cy = r.Y + ry1;
|
||||
|
||||
double theta = MathHelper.ToRadians(270);
|
||||
double dtheta = Math.PI / points;
|
||||
|
||||
for (int i = 0; i < 2 * points; i += 2)
|
||||
{
|
||||
pts[i] = new PointF(
|
||||
(float)(cx + rx1 * Math.Cos(theta)),
|
||||
(float)(cy + ry1 * Math.Sin(theta)));
|
||||
|
||||
theta += dtheta;
|
||||
|
||||
pts[i + 1] = new PointF(
|
||||
(float)(cx + rx2 * Math.Cos(theta)),
|
||||
(float)(cy + ry2 * Math.Sin(theta)));
|
||||
|
||||
theta += dtheta;
|
||||
}
|
||||
|
||||
path.AddPolygon(pts);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTrianglePath
|
||||
|
||||
private GraphicsPath GetTrianglePath(Rectangle r)
|
||||
{
|
||||
// Equal height and width will not be adjusted to make
|
||||
// an equalaterial triangle - thus rotation will skew image.
|
||||
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
int dx = r.Width / 2;
|
||||
int dy = r.Height / 2;
|
||||
|
||||
Point[] pts = {
|
||||
new Point(r.X + dx, r.Y),
|
||||
new Point(r.X , r.Y + dy * 2),
|
||||
new Point(r.X + dx * 2, r.Y + dy * 2),
|
||||
};
|
||||
|
||||
path.AddPolygon(pts);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region FillMarkerPath
|
||||
|
||||
internal void FillMarkerPath(Graphics g, GraphicsPath path, Rectangle r,
|
||||
PointMarkerType markerType, Background background, Color borderColor, int borderWidth)
|
||||
{
|
||||
if (markerType != PointMarkerType.Cross)
|
||||
{
|
||||
BackFillType fillType = GetMarkerFillType(markerType, background);
|
||||
|
||||
using (Brush br = background.GetBrush(r, -1, fillType))
|
||||
g.FillPath(br, path);
|
||||
}
|
||||
|
||||
if (borderColor.IsEmpty == false && borderWidth > 0)
|
||||
{
|
||||
using (Pen pen = new Pen(borderColor, borderWidth))
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
|
||||
#region GetMarkerFillType
|
||||
|
||||
private BackFillType GetMarkerFillType(PointMarkerType markerType, Background background)
|
||||
{
|
||||
if (background.Color2.IsEmpty == true)
|
||||
return (BackFillType.None);
|
||||
|
||||
if (background.BackFillType == BackFillType.Auto)
|
||||
{
|
||||
switch (markerType)
|
||||
{
|
||||
case PointMarkerType.Ellipse:
|
||||
case PointMarkerType.Star:
|
||||
return (BackFillType.Center);
|
||||
|
||||
default:
|
||||
return (BackFillType.VerticalCenter);
|
||||
}
|
||||
}
|
||||
|
||||
return (background.BackFillType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RotatePic
|
||||
|
||||
private Bitmap RotatePic(Bitmap obmp, float angle)
|
||||
{
|
||||
float rad = (float)MathHelper.ToRadians(angle);
|
||||
|
||||
double fW = Math.Abs((Math.Cos(rad) * obmp.Width)) + Math.Abs((Math.Sin(rad) * obmp.Height));
|
||||
double fH = Math.Abs((Math.Sin(rad) * obmp.Width)) + Math.Abs((Math.Cos(rad) * obmp.Height));
|
||||
|
||||
Bitmap nbmp = new Bitmap((int)Math.Ceiling(fW), (int)Math.Ceiling(fH));
|
||||
|
||||
using (Graphics g = Graphics.FromImage(nbmp))
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
||||
float hw = nbmp.Width / 2f;
|
||||
float hh = nbmp.Height / 2f;
|
||||
|
||||
Matrix m = g.Transform;
|
||||
|
||||
m.RotateAt(angle, new PointF(hw, hh), MatrixOrder.Append);
|
||||
|
||||
g.Transform = m;
|
||||
|
||||
g.DrawImage(obmp, new PointF((float)((nbmp.Width - obmp.Width) / 2), (float)((nbmp.Height - obmp.Height) / 2)));
|
||||
}
|
||||
|
||||
return nbmp;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (BitmapEntry entry in _Bitmaps)
|
||||
{
|
||||
entry.Background.Dispose();
|
||||
entry.Bitmap.Dispose();
|
||||
}
|
||||
|
||||
_Bitmaps.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BitmapEntry
|
||||
|
||||
private class BitmapEntry
|
||||
{
|
||||
public PointMarkerType MarkerType;
|
||||
public Size MarkerSize;
|
||||
public int MarkerPoints;
|
||||
public int MarkerRotation;
|
||||
|
||||
public Background Background;
|
||||
public Color BorderColor;
|
||||
public int BorderWidth;
|
||||
|
||||
public Bitmap Bitmap;
|
||||
|
||||
public BitmapEntry(PointMarkerType markerType, Size markerSize, int markerPoints,
|
||||
int markerRotation, Background background, Color borderColor, int borderWidth, Bitmap bitmap)
|
||||
{
|
||||
MarkerType = markerType;
|
||||
MarkerSize = markerSize;
|
||||
MarkerPoints = markerPoints;
|
||||
MarkerRotation = markerRotation;
|
||||
|
||||
Background = background.Copy();
|
||||
BorderColor = borderColor;
|
||||
BorderWidth = borderWidth;
|
||||
|
||||
Bitmap = bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region PointMarkerType
|
||||
|
||||
public enum PointMarkerType
|
||||
{
|
||||
/// <summary>
|
||||
/// Type not set.
|
||||
/// </summary>
|
||||
NotSet = -1,
|
||||
|
||||
/// <summary>
|
||||
/// No Marker
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Cross
|
||||
/// </summary>
|
||||
Cross,
|
||||
|
||||
/// <summary>
|
||||
/// Diamond
|
||||
/// </summary>
|
||||
Diamond,
|
||||
|
||||
/// <summary>
|
||||
/// Ellipse
|
||||
/// </summary>
|
||||
Ellipse,
|
||||
|
||||
/// <summary>
|
||||
/// Polygon (Pentagon, Hexagon, etc)
|
||||
/// </summary>
|
||||
Polygon,
|
||||
|
||||
/// <summary>
|
||||
/// Rectangle
|
||||
/// </summary>
|
||||
Rectangle,
|
||||
|
||||
/// <summary>
|
||||
/// Star
|
||||
/// </summary>
|
||||
Star,
|
||||
|
||||
/// <summary>
|
||||
/// Triangle
|
||||
/// </summary>
|
||||
Triangle,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class ChartPrint : PrintDocument
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ChartControl _ChartControl;
|
||||
private Image _ChartImage;
|
||||
|
||||
private Rectangle _PrintBounds;
|
||||
|
||||
private int _Columns;
|
||||
private int _Rows;
|
||||
|
||||
private int _CurCell;
|
||||
|
||||
private FitToPageScale _FitToPageScale = FitToPageScale.Normal;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// ChartPrint
|
||||
/// </summary>
|
||||
public ChartPrint()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ChartPrint
|
||||
/// </summary>
|
||||
/// <param name="chartControl">ChartControl</param>
|
||||
public ChartPrint(ChartControl chartControl)
|
||||
: base()
|
||||
{
|
||||
_ChartControl = chartControl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ChartPrint
|
||||
/// </summary>
|
||||
/// <param name="chartControl">ChartControl</param>
|
||||
/// <param name="fitToPageScale">FitToPageScale</param>
|
||||
public ChartPrint(ChartControl chartControl, FitToPageScale fitToPageScale)
|
||||
: base()
|
||||
{
|
||||
_ChartControl = chartControl;
|
||||
_FitToPageScale = fitToPageScale;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region FitToPageScale
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how the chart is scaled
|
||||
/// to fit the page when printing.
|
||||
/// </summary>
|
||||
public FitToPageScale FitToPageScale
|
||||
{
|
||||
get { return (_FitToPageScale); }
|
||||
set { _FitToPageScale = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnBeginPrint
|
||||
|
||||
protected override void OnBeginPrint(PrintEventArgs e)
|
||||
{
|
||||
base.OnBeginPrint(e);
|
||||
|
||||
if (_ChartControl == null)
|
||||
throw new Exception("ChartControl has not been set.");
|
||||
|
||||
Size size = _ChartControl.ClientSize;
|
||||
|
||||
_PrintBounds = DefaultPageSettings.Bounds;
|
||||
|
||||
Margins margins = DefaultPageSettings.Margins;
|
||||
|
||||
_PrintBounds.X += margins.Left;
|
||||
_PrintBounds.Width -= (margins.Left + margins.Right);
|
||||
|
||||
_PrintBounds.Y += margins.Top;
|
||||
_PrintBounds.Height -= (margins.Top + margins.Bottom);
|
||||
|
||||
_Columns = (int)Math.Ceiling((double)size.Width / _PrintBounds.Width);
|
||||
_Rows = (int)Math.Ceiling((double)size.Height / _PrintBounds.Height);
|
||||
|
||||
_CurCell = 0;
|
||||
|
||||
_ChartImage = new Bitmap(size.Width, size.Height);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(_ChartImage))
|
||||
_ChartControl.PaintTo(g);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnPrintPage
|
||||
|
||||
protected override void OnPrintPage(PrintPageEventArgs e)
|
||||
{
|
||||
base.OnPrintPage(e);
|
||||
|
||||
switch (FitToPageScale)
|
||||
{
|
||||
case Charts.FitToPageScale.Stretch:
|
||||
PrintStretchPage(e);
|
||||
break;
|
||||
|
||||
case Charts.FitToPageScale.Zoom:
|
||||
PrintZoomPage(e);
|
||||
break;
|
||||
|
||||
default:
|
||||
PrintNormalPage(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region PrintNormalPage
|
||||
|
||||
private void PrintNormalPage(PrintPageEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
int curRow = _CurCell / _Columns;
|
||||
int curColumn = _CurCell % _Columns;
|
||||
|
||||
int x = curColumn * _PrintBounds.Width;
|
||||
int y = curRow * _PrintBounds.Height;
|
||||
|
||||
Rectangle rs = new Rectangle(x, y, _ChartImage.Width - x, _ChartImage.Height - y);
|
||||
Rectangle rd = new Rectangle(_PrintBounds.X, _PrintBounds.Y, _ChartImage.Width - x, _ChartImage.Height - y);
|
||||
|
||||
Region saveClip = g.Clip;
|
||||
|
||||
g.SetClip(_PrintBounds);
|
||||
g.DrawImage(_ChartImage, rd, rs, GraphicsUnit.Pixel);
|
||||
g.Clip = saveClip;
|
||||
|
||||
_CurCell++;
|
||||
|
||||
e.HasMorePages = (_CurCell < _Columns * _Rows);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrintStretchPage
|
||||
|
||||
private void PrintStretchPage(PrintPageEventArgs e)
|
||||
{
|
||||
Rectangle rs = new Rectangle(0, 0, _ChartImage.Width, _ChartImage.Height);
|
||||
|
||||
e.Graphics.DrawImage(_ChartImage, _PrintBounds, rs, GraphicsUnit.Pixel);
|
||||
|
||||
e.HasMorePages = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrintZoomPage
|
||||
|
||||
private void PrintZoomPage(PrintPageEventArgs e)
|
||||
{
|
||||
Rectangle rd = _PrintBounds;
|
||||
|
||||
SizeF size = new SizeF(_ChartImage.Width / _ChartImage.HorizontalResolution,
|
||||
_ChartImage.Height / _ChartImage.VerticalResolution);
|
||||
|
||||
float scale = Math.Min(rd.Width / size.Width, rd.Height / size.Height);
|
||||
|
||||
size.Width *= scale;
|
||||
size.Height *= scale;
|
||||
|
||||
e.Graphics.DrawImage(_ChartImage, rd.X, rd.Y, size.Width, size.Height);
|
||||
|
||||
e.HasMorePages = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnEndPrint
|
||||
|
||||
protected override void OnEndPrint(PrintEventArgs e)
|
||||
{
|
||||
base.OnEndPrint(e);
|
||||
|
||||
if (_ChartImage != null)
|
||||
_ChartImage.Dispose();
|
||||
|
||||
_ChartImage = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region FitToPageScale
|
||||
|
||||
public enum FitToPageScale
|
||||
{
|
||||
Normal,
|
||||
|
||||
Stretch,
|
||||
Zoom,
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 326 B |
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.Charts.TextMarkup
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents block layout manager responsible for sizing the content blocks.
|
||||
/// </summary>
|
||||
public abstract class BlockLayoutManager
|
||||
{
|
||||
private Graphics _Graphics;
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the content block and sets it's Bounds property to reflect new size.
|
||||
/// </summary>
|
||||
/// <param name="block">Content block to resize.</param>
|
||||
/// <param name="availableSize">Content size available for the block in the given line.</param>
|
||||
public abstract void Layout(IBlock block, Size availableSize);
|
||||
|
||||
/// <summary>
|
||||
/// Performs layout finalization
|
||||
/// </summary>
|
||||
/// <param name="containerBounds"></param>
|
||||
/// <param name="blocksBounds"></param>
|
||||
/// <param name="lines"></param>
|
||||
/// <returns></returns>
|
||||
public abstract Rectangle FinalizeLayout(Rectangle containerBounds, Rectangle blocksBounds, ArrayList lines);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the graphics object used by layout manager.
|
||||
/// </summary>
|
||||
public Graphics Graphics
|
||||
{
|
||||
get {return _Graphics;}
|
||||
set {_Graphics = value;}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace DevComponents.Charts.TextMarkup
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies orientation of content.
|
||||
/// </summary>
|
||||
public enum eContentOrientation
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates Horizontal orientation of the content.
|
||||
/// </summary>
|
||||
Horizontal,
|
||||
/// <summary>
|
||||
/// Indicates Vertical orientation of the content.
|
||||
/// </summary>
|
||||
Vertical
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies content horizontal alignment.
|
||||
/// </summary>
|
||||
public enum eContentAlignment
|
||||
{
|
||||
/// <summary>
|
||||
/// Content is left aligned.UI
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// Content is right aligned.
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// Content is centered.
|
||||
/// </summary>
|
||||
Center
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies content vertical alignment.
|
||||
/// </summary>
|
||||
public enum eContentVerticalAlignment
|
||||
{
|
||||
/// <summary>
|
||||
/// Content is top aligned.
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// Content is bottom aligned.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
/// <summary>
|
||||
/// Content is in the middle.
|
||||
/// </summary>
|
||||
Middle
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.Charts.TextMarkup
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a content block interface.
|
||||
/// </summary>
|
||||
public interface IBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the bounds of the content block.
|
||||
/// </summary>
|
||||
Rectangle Bounds {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether content block is visible.
|
||||
/// </summary>
|
||||
bool Visible {get;set;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace DevComponents.Charts.TextMarkup
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a extended content block interface for advanced layout information.
|
||||
/// </summary>
|
||||
public interface IBlockExtended : IBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets whether element is block level element.
|
||||
/// </summary>
|
||||
bool IsBlockElement { get;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether new line is required after the element.
|
||||
/// </summary>
|
||||
bool IsNewLineAfterElement { get;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether element can be on new line.
|
||||
/// </summary>
|
||||
bool CanStartNewLine { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.Charts.TextMarkup
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents interface for block layout.
|
||||
/// </summary>
|
||||
public interface IContentLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs layout of the content block.
|
||||
/// </summary>
|
||||
/// <param name="containerBounds">Container bounds to layout content blocks in.</param>
|
||||
/// <param name="contentBlocks">Content blocks to layout.</param>
|
||||
/// <param name="blockLayout">Block layout manager that resizes the content blocks.</param>
|
||||
/// <returns>The bounds of the content blocks within the container bounds.</returns>
|
||||
Rectangle Layout(Rectangle containerBounds, IBlock[] contentBlocks, BlockLayoutManager blockLayout);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.Charts.TextMarkup
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the serial content layout manager that arranges content blocks in series next to each other.
|
||||
/// </summary>
|
||||
public class SerialContentLayoutManager:IContentLayout
|
||||
{
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when X, Y position of next block is calcualted.
|
||||
/// </summary>
|
||||
public event LayoutManagerPositionEventHandler NextPosition;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before new block is layed out.
|
||||
/// </summary>
|
||||
public event LayoutManagerLayoutEventHandler BeforeNewBlockLayout;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Variables
|
||||
|
||||
private int _BlockSpacing;
|
||||
private bool _FitContainerOversize;
|
||||
private bool _FitContainer;
|
||||
private bool _VerticalFitContainerWidth;
|
||||
private bool _HorizontalFitContainerHeight;
|
||||
private bool _EvenHeight;
|
||||
private bool _MultiLine;
|
||||
private bool _RightToLeft;
|
||||
private bool _OversizeDistribute;
|
||||
|
||||
private eContentAlignment _ContentAlignment = eContentAlignment.Left;
|
||||
private eContentOrientation _ContentOrientation = eContentOrientation.Horizontal;
|
||||
private eContentVerticalAlignment _ContentVerticalAlignment = eContentVerticalAlignment.Middle;
|
||||
private eContentVerticalAlignment _BlockLineAlignment = eContentVerticalAlignment.Middle;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IContentLayout Members
|
||||
|
||||
/// <summary>
|
||||
/// Performs layout of the content block.
|
||||
/// </summary>
|
||||
/// <param name="containerBounds">Container bounds to layout content blocks in.</param>
|
||||
/// <param name="contentBlocks">Content blocks to layout.</param>
|
||||
/// <param name="blockLayout">Block layout manager that resizes the content blocks.</param>
|
||||
/// <returns>The bounds of the content blocks within the container bounds.</returns>
|
||||
public virtual Rectangle Layout(Rectangle containerBounds, IBlock[] contentBlocks, BlockLayoutManager blockLayout)
|
||||
{
|
||||
Rectangle blocksBounds = Rectangle.Empty;
|
||||
Point position = containerBounds.Location;
|
||||
ArrayList lines = new ArrayList();
|
||||
lines.Add(new BlockLineInfo());
|
||||
BlockLineInfo currentLine = lines[0] as BlockLineInfo;
|
||||
bool switchToNewLine = false;
|
||||
int visibleIndex = 0;
|
||||
|
||||
foreach (IBlock block in contentBlocks)
|
||||
{
|
||||
if (!block.Visible)
|
||||
{
|
||||
block.Bounds = Rectangle.Empty;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (BeforeNewBlockLayout != null)
|
||||
{
|
||||
LayoutManagerLayoutEventArgs e = new
|
||||
LayoutManagerLayoutEventArgs(block, position, visibleIndex);
|
||||
|
||||
BeforeNewBlockLayout(this, e);
|
||||
|
||||
position = e.CurrentPosition;
|
||||
|
||||
if (e.CancelLayout)
|
||||
continue;
|
||||
}
|
||||
visibleIndex++;
|
||||
|
||||
Size availableSize = containerBounds.Size;
|
||||
bool isBlockElement = false;
|
||||
bool isNewLineTriggger = false;
|
||||
bool canStartOnNewLine;
|
||||
|
||||
if (block is IBlockExtended)
|
||||
{
|
||||
IBlockExtended ex = block as IBlockExtended;
|
||||
|
||||
isBlockElement = ex.IsBlockElement;
|
||||
isNewLineTriggger = ex.IsNewLineAfterElement;
|
||||
canStartOnNewLine = ex.CanStartNewLine;
|
||||
}
|
||||
else
|
||||
canStartOnNewLine = true;
|
||||
|
||||
if (!isBlockElement)
|
||||
{
|
||||
if (_ContentOrientation == eContentOrientation.Horizontal)
|
||||
availableSize.Width = (containerBounds.Right - position.X);
|
||||
else
|
||||
availableSize.Height = (containerBounds.Bottom - position.Y);
|
||||
}
|
||||
|
||||
// Resize the content block
|
||||
|
||||
blockLayout.Layout(block, availableSize);
|
||||
|
||||
if (_MultiLine && currentLine.Blocks.Count > 0)
|
||||
{
|
||||
if (_ContentOrientation == eContentOrientation.Horizontal &&
|
||||
position.X + block.Bounds.Width > containerBounds.Right && canStartOnNewLine || isBlockElement ||
|
||||
switchToNewLine)
|
||||
{
|
||||
position.X = containerBounds.X;
|
||||
position.Y += (currentLine.LineSize.Height + _BlockSpacing);
|
||||
|
||||
currentLine = new BlockLineInfo();
|
||||
|
||||
currentLine.Line = lines.Count;
|
||||
|
||||
lines.Add(currentLine);
|
||||
}
|
||||
else if (_ContentOrientation == eContentOrientation.Vertical &&
|
||||
position.Y + block.Bounds.Height > containerBounds.Bottom && canStartOnNewLine || isBlockElement ||
|
||||
switchToNewLine)
|
||||
{
|
||||
position.Y = containerBounds.Y;
|
||||
position.X += (currentLine.LineSize.Width + _BlockSpacing);
|
||||
|
||||
currentLine = new BlockLineInfo();
|
||||
|
||||
currentLine.Line = lines.Count;
|
||||
|
||||
lines.Add(currentLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (_ContentOrientation == eContentOrientation.Horizontal)
|
||||
{
|
||||
if (block.Bounds.Height > currentLine.LineSize.Height)
|
||||
currentLine.LineSize.Height = block.Bounds.Height;
|
||||
|
||||
currentLine.LineSize.Width = position.X + block.Bounds.Width - containerBounds.X;
|
||||
}
|
||||
else if (_ContentOrientation == eContentOrientation.Vertical)
|
||||
{
|
||||
if (block.Bounds.Width > currentLine.LineSize.Width)
|
||||
currentLine.LineSize.Width = block.Bounds.Width;
|
||||
|
||||
currentLine.LineSize.Height = position.Y + block.Bounds.Height - containerBounds.Y;
|
||||
}
|
||||
|
||||
currentLine.Blocks.Add(block);
|
||||
|
||||
if (block.Visible)
|
||||
currentLine.VisibleItemsCount++;
|
||||
|
||||
block.Bounds = new Rectangle(position, block.Bounds.Size);
|
||||
|
||||
if (blocksBounds.IsEmpty)
|
||||
blocksBounds = block.Bounds;
|
||||
else
|
||||
blocksBounds = Rectangle.Union(blocksBounds, block.Bounds);
|
||||
|
||||
switchToNewLine = isBlockElement | isNewLineTriggger;
|
||||
|
||||
position = GetNextPosition(block, position);
|
||||
}
|
||||
|
||||
blocksBounds = AlignResizeBlocks(containerBounds, blocksBounds, lines);
|
||||
|
||||
if (_RightToLeft)
|
||||
blocksBounds = MirrorContent(containerBounds, blocksBounds, contentBlocks);
|
||||
|
||||
blocksBounds = blockLayout.FinalizeLayout(containerBounds, blocksBounds, lines);
|
||||
|
||||
return blocksBounds;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internals
|
||||
|
||||
private struct SizeExtended
|
||||
{
|
||||
public int Width;
|
||||
public int Height;
|
||||
public float WidthReduction;
|
||||
public float HeightReduction;
|
||||
public bool UseAbsoluteWidth;
|
||||
}
|
||||
|
||||
private Rectangle AlignResizeBlocks(Rectangle containerBounds,Rectangle blocksBounds,ArrayList lines)
|
||||
{
|
||||
Rectangle newBounds=Rectangle.Empty;
|
||||
|
||||
if(containerBounds.IsEmpty || blocksBounds.IsEmpty || ((BlockLineInfo)lines[0]).Blocks.Count==0)
|
||||
return newBounds;
|
||||
|
||||
if (_ContentAlignment == eContentAlignment.Left && _ContentVerticalAlignment == eContentVerticalAlignment.Top &&
|
||||
!_FitContainer && !_FitContainerOversize && !_EvenHeight && _BlockLineAlignment == eContentVerticalAlignment.Top)
|
||||
return blocksBounds;
|
||||
|
||||
Point[] offset=new Point[lines.Count];
|
||||
SizeExtended[] sizeOffset = new SizeExtended[lines.Count];
|
||||
foreach(BlockLineInfo lineInfo in lines)
|
||||
{
|
||||
if (_ContentOrientation == eContentOrientation.Horizontal)
|
||||
{
|
||||
if (_FitContainer && containerBounds.Width > lineInfo.LineSize.Width ||
|
||||
_FitContainerOversize && lineInfo.LineSize.Width > containerBounds.Width)
|
||||
{
|
||||
if (_OversizeDistribute && containerBounds.Width < lineInfo.LineSize.Width * .75)
|
||||
{
|
||||
sizeOffset[lineInfo.Line].Width = (int)Math.Floor((float)(containerBounds.Width - lineInfo.VisibleItemsCount * _BlockSpacing) / (float)lineInfo.VisibleItemsCount);
|
||||
sizeOffset[lineInfo.Line].UseAbsoluteWidth = true;
|
||||
}
|
||||
else
|
||||
sizeOffset[lineInfo.Line].Width = ((containerBounds.Width - lineInfo.VisibleItemsCount * _BlockSpacing) - lineInfo.LineSize.Width) / lineInfo.VisibleItemsCount;
|
||||
sizeOffset[lineInfo.Line].WidthReduction = (float)(containerBounds.Width - lineInfo.VisibleItemsCount * _BlockSpacing) / (float)lineInfo.LineSize.Width;
|
||||
blocksBounds.Width = containerBounds.Width;
|
||||
}
|
||||
|
||||
if (_HorizontalFitContainerHeight && containerBounds.Height > blocksBounds.Height)
|
||||
sizeOffset[lineInfo.Line].Height = (containerBounds.Height - lineInfo.LineSize.Height) / lines.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_FitContainer && containerBounds.Height > lineInfo.LineSize.Height ||
|
||||
_FitContainerOversize && lineInfo.LineSize.Height > containerBounds.Height)
|
||||
{
|
||||
if (_OversizeDistribute && containerBounds.Width < lineInfo.LineSize.Width*.75)
|
||||
{
|
||||
sizeOffset[lineInfo.Line].Height = (int)
|
||||
Math.Floor((float) (containerBounds.Height - lineInfo.VisibleItemsCount*_BlockSpacing)/
|
||||
(float) lineInfo.VisibleItemsCount);
|
||||
|
||||
sizeOffset[lineInfo.Line].UseAbsoluteWidth = true;
|
||||
}
|
||||
else
|
||||
sizeOffset[lineInfo.Line].Height = ((containerBounds.Height -
|
||||
lineInfo.VisibleItemsCount*_BlockSpacing) -
|
||||
lineInfo.LineSize.Height)/lineInfo.VisibleItemsCount;
|
||||
sizeOffset[lineInfo.Line].HeightReduction =
|
||||
(float) (containerBounds.Height - lineInfo.VisibleItemsCount*_BlockSpacing)/
|
||||
(float) lineInfo.LineSize.Height;
|
||||
blocksBounds.Height = containerBounds.Height;
|
||||
}
|
||||
|
||||
if (_VerticalFitContainerWidth && containerBounds.Width > blocksBounds.Width)
|
||||
sizeOffset[lineInfo.Line].Width = (containerBounds.Width - lineInfo.LineSize.Width)/lines.Count;
|
||||
}
|
||||
|
||||
|
||||
if (_ContentOrientation == eContentOrientation.Horizontal && !_FitContainer)
|
||||
{
|
||||
if (containerBounds.Width > blocksBounds.Width && _FitContainerOversize || !_FitContainerOversize)
|
||||
{
|
||||
switch (_ContentAlignment)
|
||||
{
|
||||
case eContentAlignment.Right:
|
||||
if (containerBounds.Width > lineInfo.LineSize.Width)
|
||||
offset[lineInfo.Line].X = containerBounds.Width - lineInfo.LineSize.Width;
|
||||
break;
|
||||
|
||||
case eContentAlignment.Center:
|
||||
if (containerBounds.Width > lineInfo.LineSize.Width)
|
||||
offset[lineInfo.Line].X = (containerBounds.Width - lineInfo.LineSize.Width)/2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_ContentOrientation == eContentOrientation.Vertical && !_FitContainer)
|
||||
{
|
||||
if (containerBounds.Height > blocksBounds.Height && _FitContainerOversize || !_FitContainerOversize)
|
||||
{
|
||||
switch (_ContentVerticalAlignment)
|
||||
{
|
||||
case eContentVerticalAlignment.Bottom:
|
||||
if (containerBounds.Height > lineInfo.LineSize.Height)
|
||||
offset[lineInfo.Line].Y = containerBounds.Height - lineInfo.LineSize.Height;
|
||||
break;
|
||||
|
||||
case eContentVerticalAlignment.Middle:
|
||||
if (containerBounds.Height > lineInfo.LineSize.Height)
|
||||
offset[lineInfo.Line].Y = (containerBounds.Height - lineInfo.LineSize.Height)/2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_VerticalFitContainerWidth && containerBounds.Width > blocksBounds.Width && _ContentOrientation==eContentOrientation.Vertical)
|
||||
blocksBounds.Width = containerBounds.Width;
|
||||
|
||||
else if(_HorizontalFitContainerHeight && containerBounds.Height>blocksBounds.Height && _ContentOrientation==eContentOrientation.Horizontal)
|
||||
blocksBounds.Height = containerBounds.Height;
|
||||
|
||||
if(_ContentOrientation==eContentOrientation.Horizontal)
|
||||
{
|
||||
foreach(BlockLineInfo lineInfo in lines)
|
||||
{
|
||||
foreach (IBlock block in lineInfo.Blocks)
|
||||
{
|
||||
if (!block.Visible)
|
||||
continue;
|
||||
|
||||
Rectangle r = block.Bounds;
|
||||
|
||||
if (_EvenHeight && lineInfo.LineSize.Height > 0)
|
||||
r.Height = lineInfo.LineSize.Height;
|
||||
|
||||
r.Offset(offset[lineInfo.Line]);
|
||||
|
||||
if (_ContentVerticalAlignment == eContentVerticalAlignment.Middle)
|
||||
{
|
||||
// Takes care of offset rounding error when both content is vertically centered and blocks in line are centered
|
||||
|
||||
if (_BlockLineAlignment == eContentVerticalAlignment.Middle)
|
||||
r.Offset(0,
|
||||
((containerBounds.Height - blocksBounds.Height) +
|
||||
(lineInfo.LineSize.Height - r.Height))/2);
|
||||
else
|
||||
r.Offset(0, (containerBounds.Height - blocksBounds.Height)/2);
|
||||
|
||||
// Line alignment of the block
|
||||
|
||||
if (_BlockLineAlignment == eContentVerticalAlignment.Bottom)
|
||||
r.Offset(0, lineInfo.LineSize.Height - r.Height);
|
||||
}
|
||||
else if (_ContentVerticalAlignment == eContentVerticalAlignment.Bottom)
|
||||
r.Offset(0, containerBounds.Height - blocksBounds.Height);
|
||||
|
||||
// To avoid rounding offset errors when dividing this is split see upper part
|
||||
|
||||
if (_ContentVerticalAlignment != eContentVerticalAlignment.Middle)
|
||||
{
|
||||
// Line alignment of the block
|
||||
|
||||
if (_BlockLineAlignment == eContentVerticalAlignment.Middle)
|
||||
r.Offset(0, (lineInfo.LineSize.Height - r.Height)/2);
|
||||
|
||||
else if (_BlockLineAlignment == eContentVerticalAlignment.Bottom)
|
||||
r.Offset(0, lineInfo.LineSize.Height - r.Height);
|
||||
}
|
||||
|
||||
if (sizeOffset[lineInfo.Line].Width != 0)
|
||||
{
|
||||
if (_OversizeDistribute)
|
||||
{
|
||||
int nw = sizeOffset[lineInfo.Line].UseAbsoluteWidth
|
||||
? sizeOffset[lineInfo.Line].Width
|
||||
: (int) Math.Floor(r.Width*sizeOffset[lineInfo.Line].WidthReduction);
|
||||
|
||||
offset[lineInfo.Line].X += nw - r.Width;
|
||||
|
||||
r.Width = nw;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Width += sizeOffset[lineInfo.Line].Width;
|
||||
offset[lineInfo.Line].X += sizeOffset[lineInfo.Line].Width;
|
||||
}
|
||||
}
|
||||
|
||||
r.Height += sizeOffset[lineInfo.Line].Height;
|
||||
|
||||
block.Bounds = r;
|
||||
|
||||
if (newBounds.IsEmpty)
|
||||
newBounds = block.Bounds;
|
||||
else
|
||||
newBounds = Rectangle.Union(newBounds, block.Bounds);
|
||||
}
|
||||
|
||||
// Adjust for left-over size adjustment for odd difference
|
||||
// between container width and the total block width
|
||||
|
||||
if (!_OversizeDistribute && sizeOffset[lineInfo.Line].Width != 0 &&
|
||||
containerBounds.Width - (lineInfo.LineSize.Width + sizeOffset[lineInfo.Line].Width * lineInfo.Blocks.Count) != 0)
|
||||
{
|
||||
Rectangle r = ((IBlock) lineInfo.Blocks[lineInfo.Blocks.Count - 1]).Bounds;
|
||||
|
||||
r.Width += containerBounds.Width -
|
||||
(lineInfo.LineSize.Width + sizeOffset[lineInfo.Line].Width*lineInfo.Blocks.Count);
|
||||
|
||||
((IBlock) lineInfo.Blocks[lineInfo.Blocks.Count - 1]).Bounds = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(BlockLineInfo lineInfo in lines)
|
||||
{
|
||||
foreach(IBlock block in lineInfo.Blocks)
|
||||
{
|
||||
if(!block.Visible)
|
||||
continue;
|
||||
|
||||
Rectangle r=block.Bounds;
|
||||
|
||||
if(_EvenHeight && lineInfo.LineSize.Width>0)
|
||||
r.Width=lineInfo.LineSize.Width;
|
||||
|
||||
r.Offset(offset[lineInfo.Line]);
|
||||
|
||||
if(_ContentAlignment==eContentAlignment.Center)
|
||||
r.Offset(((containerBounds.Width-blocksBounds.Width)+(lineInfo.LineSize.Width-r.Width))/2,0); //r.Offset((containerBounds.Width-blocksBounds.Width)/2+(lineInfo.LineSize.Width-r.Width)/2,0);
|
||||
else if(_ContentAlignment==eContentAlignment.Right)
|
||||
|
||||
r.Offset((containerBounds.Width-blocksBounds.Width)+lineInfo.LineSize.Width-r.Width,0);
|
||||
r.Width+=sizeOffset[lineInfo.Line].Width;
|
||||
|
||||
if(sizeOffset[lineInfo.Line].Height!=0)
|
||||
{
|
||||
if (_OversizeDistribute)
|
||||
{
|
||||
int nw = sizeOffset[lineInfo.Line].UseAbsoluteWidth
|
||||
? sizeOffset[lineInfo.Line].Height : (int)Math.Floor(r.Height * sizeOffset[lineInfo.Line].HeightReduction);
|
||||
|
||||
offset[lineInfo.Line].Y += nw - r.Height;
|
||||
r.Height = nw;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Height += sizeOffset[lineInfo.Line].Height;
|
||||
offset[lineInfo.Line].Y += sizeOffset[lineInfo.Line].Height;
|
||||
}
|
||||
}
|
||||
|
||||
block.Bounds=r;
|
||||
|
||||
if(newBounds.IsEmpty)
|
||||
newBounds=block.Bounds;
|
||||
else
|
||||
newBounds=Rectangle.Union(newBounds,block.Bounds);
|
||||
}
|
||||
|
||||
if (!_OversizeDistribute && sizeOffset[lineInfo.Line].Height != 0 && containerBounds.Height - (lineInfo.LineSize.Height + sizeOffset[lineInfo.Line].Height * lineInfo.Blocks.Count) != 0)
|
||||
{
|
||||
Rectangle r=((IBlock)lineInfo.Blocks[lineInfo.Blocks.Count-1]).Bounds;
|
||||
r.Height+=containerBounds.Height-(lineInfo.LineSize.Height+sizeOffset[lineInfo.Line].Height*lineInfo.Blocks.Count);
|
||||
((IBlock)lineInfo.Blocks[lineInfo.Blocks.Count-1]).Bounds=r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return newBounds;
|
||||
}
|
||||
|
||||
private Point GetNextPosition(IBlock block, Point position)
|
||||
{
|
||||
if (NextPosition != null)
|
||||
{
|
||||
LayoutManagerPositionEventArgs e = new LayoutManagerPositionEventArgs();
|
||||
|
||||
e.Block = block;
|
||||
e.CurrentPosition = position;
|
||||
|
||||
NextPosition(this, e);
|
||||
|
||||
if (e.Cancel)
|
||||
return e.NextPosition;
|
||||
}
|
||||
|
||||
if(_ContentOrientation==eContentOrientation.Horizontal)
|
||||
position.X+=block.Bounds.Width+_BlockSpacing;
|
||||
else
|
||||
position.Y+=block.Bounds.Height+_BlockSpacing;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
internal class BlockLineInfo
|
||||
{
|
||||
public ArrayList Blocks=new ArrayList();
|
||||
public Size LineSize = Size.Empty;
|
||||
public int Line;
|
||||
public int VisibleItemsCount;
|
||||
}
|
||||
|
||||
private Rectangle MirrorContent(Rectangle containerBounds, Rectangle blockBounds, IBlock[] contentBlocks)
|
||||
{
|
||||
if (blockBounds.Width < containerBounds.Width)
|
||||
blockBounds.X = containerBounds.Right - ((blockBounds.X - containerBounds.X) + blockBounds.Width);
|
||||
|
||||
else if (blockBounds.Width > containerBounds.Width)
|
||||
containerBounds.Width = blockBounds.Width;
|
||||
|
||||
foreach (IBlock block in contentBlocks)
|
||||
{
|
||||
if (!block.Visible)
|
||||
continue;
|
||||
|
||||
Rectangle r = block.Bounds;
|
||||
|
||||
block.Bounds = new Rectangle(containerBounds.Right -
|
||||
((r.X - containerBounds.X) + r.Width), r.Y, r.Width, r.Height);
|
||||
}
|
||||
|
||||
return blockBounds;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the spacing in pixels between content blocks. Default value is 0.
|
||||
/// </summary>
|
||||
public virtual int BlockSpacing
|
||||
{
|
||||
get {return _BlockSpacing;}
|
||||
set {_BlockSpacing=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether content blocks are forced to fit the container bounds if they
|
||||
/// occupy more space than it is available by container. Default value is false.
|
||||
/// </summary>
|
||||
public virtual bool FitContainerOversize
|
||||
{
|
||||
get {return _FitContainerOversize;}
|
||||
set {_FitContainerOversize=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether content blocks are resized to fit the container bound if they
|
||||
/// occupy less space than it is available by container. Default value is false.
|
||||
/// </summary>
|
||||
public virtual bool FitContainer
|
||||
{
|
||||
get {return _FitContainer;}
|
||||
set {_FitContainer=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether content blocks are resized (Width) to fit container bounds if they
|
||||
/// occupy less space than the actual container width. Applies to the Vertical orientation only. Default value is false.
|
||||
/// </summary>
|
||||
public virtual bool VerticalFitContainerWidth
|
||||
{
|
||||
get { return _VerticalFitContainerWidth; }
|
||||
set { _VerticalFitContainerWidth = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether content blocks are resized (Height) to fit container bounds if they
|
||||
/// occupy less space than the actual container height. Applies to the Horizontal orientation only. Default value is false.
|
||||
/// </summary>
|
||||
public virtual bool HorizontalFitContainerHeight
|
||||
{
|
||||
get { return _HorizontalFitContainerHeight; }
|
||||
set { _HorizontalFitContainerHeight = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content orientation. Default value is Horizontal.
|
||||
/// </summary>
|
||||
public virtual eContentOrientation ContentOrientation
|
||||
{
|
||||
get {return _ContentOrientation;}
|
||||
set {_ContentOrientation=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content vertical alignment. Default value is Middle.
|
||||
/// </summary>
|
||||
public virtual eContentVerticalAlignment ContentVerticalAlignment
|
||||
{
|
||||
get {return _ContentVerticalAlignment;}
|
||||
set {_ContentVerticalAlignment=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the block line vertical alignment. Default value is Middle.
|
||||
/// </summary>
|
||||
public virtual eContentVerticalAlignment BlockLineAlignment
|
||||
{
|
||||
get { return _BlockLineAlignment; }
|
||||
set { _BlockLineAlignment = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content horizontal alignment. Default value is Left.
|
||||
/// </summary>
|
||||
public virtual eContentAlignment ContentAlignment
|
||||
{
|
||||
get {return _ContentAlignment;}
|
||||
set {_ContentAlignment=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether all content blocks are resized so they have same height which is height of the tallest content block. Default value is false.
|
||||
/// </summary>
|
||||
public virtual bool EvenHeight
|
||||
{
|
||||
get {return _EvenHeight;}
|
||||
set {_EvenHeight=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether oversized blocks are resized based on the percentage reduction instead of based on equal pixel distribution. Default value is false.
|
||||
/// </summary>
|
||||
public virtual bool OversizeDistribute
|
||||
{
|
||||
get { return _OversizeDistribute; }
|
||||
set { _OversizeDistribute = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether content is wrapped into new line if it exceeds the width of the container.
|
||||
/// </summary>
|
||||
public bool MultiLine
|
||||
{
|
||||
get {return _MultiLine;}
|
||||
set {_MultiLine=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether layout is right-to-left.
|
||||
/// </summary>
|
||||
public bool RightToLeft
|
||||
{
|
||||
get { return _RightToLeft; }
|
||||
set { _RightToLeft = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents event arguments for SerialContentLayoutManager.NextPosition event.
|
||||
/// </summary>
|
||||
public class LayoutManagerPositionEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the block that is layed out.
|
||||
/// </summary>
|
||||
public IBlock Block;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current block position.
|
||||
/// </summary>
|
||||
public Point CurrentPosition = Point.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the calculated next block position.
|
||||
/// </summary>
|
||||
public Point NextPosition = Point.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Cancels default position calculation.
|
||||
/// </summary>
|
||||
public bool Cancel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents event arguments for the SerialContentLayoutManager layout events.
|
||||
/// </summary>
|
||||
public class LayoutManagerLayoutEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the reference block object.
|
||||
/// </summary>
|
||||
public IBlock Block;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position block will assume.
|
||||
/// </summary>
|
||||
public Point CurrentPosition = Point.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the layout of the block, applies only to BeforeXXX layout event.
|
||||
/// </summary>
|
||||
public bool CancelLayout;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visibility index of the block.
|
||||
/// </summary>
|
||||
public int BlockVisibleIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initializes it with default values.
|
||||
/// </summary>
|
||||
public LayoutManagerLayoutEventArgs(IBlock block, Point currentPosition, int visibleIndex)
|
||||
{
|
||||
this.Block = block;
|
||||
this.CurrentPosition = currentPosition;
|
||||
this.BlockVisibleIndex = visibleIndex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for SerialContentLayoutManager.NextPosition event.
|
||||
/// </summary>
|
||||
public delegate void LayoutManagerPositionEventHandler(object sender, LayoutManagerPositionEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the SerialContentLayoutManager layout events.
|
||||
/// </summary>
|
||||
public delegate void LayoutManagerLayoutEventHandler(object sender, LayoutManagerLayoutEventArgs e);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
// Monotone Chain Convex Hull.
|
||||
// It takes O(NlogN) in sorting & O(N) in actual convex hull calc for N points.
|
||||
|
||||
public static class ConvexHull
|
||||
{
|
||||
#region GetConvexHull
|
||||
|
||||
public static Point[] GetConvexHull(Point[] points)
|
||||
{
|
||||
int n = points.Length;
|
||||
|
||||
Array.Sort(points, 0, n, new PointComparer());
|
||||
|
||||
Point[] ans = new Point[2 * n];
|
||||
|
||||
int k = 0;
|
||||
int start = 0;
|
||||
|
||||
// Bottom hull
|
||||
|
||||
Point lpt = Point.Empty;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
Point p = points[i];
|
||||
|
||||
if (PtCompare(p, lpt) == 0)
|
||||
continue;
|
||||
|
||||
lpt = p;
|
||||
|
||||
while (k - start >= 2)
|
||||
{
|
||||
Point sp1 = PtSub(p, ans[k - 1]);
|
||||
Point sp2 = PtSub(p, ans[k - 2]);
|
||||
|
||||
if (PtCross(sp1, sp2) <= 0)
|
||||
break;
|
||||
|
||||
k--;
|
||||
}
|
||||
|
||||
ans[k++] = p;
|
||||
}
|
||||
|
||||
k--;
|
||||
|
||||
// Top hull
|
||||
|
||||
start = k;
|
||||
lpt = Point.Empty;
|
||||
|
||||
for (int i = n - 1; i >= 0; i--)
|
||||
{
|
||||
Point p = points[i];
|
||||
|
||||
if (PtCompare(p, lpt) == 0)
|
||||
continue;
|
||||
|
||||
lpt = p;
|
||||
|
||||
while (k - start >= 2)
|
||||
{
|
||||
Point sp1 = PtSub(p, ans[k - 1]);
|
||||
Point sp2 = PtSub(p, ans[k - 2]);
|
||||
|
||||
if (PtCross(sp1, sp2) <= 0)
|
||||
break;
|
||||
|
||||
k--;
|
||||
}
|
||||
|
||||
ans[k++] = p;
|
||||
}
|
||||
|
||||
k--;
|
||||
|
||||
Point[] hullPoints = new Point[k + 1];
|
||||
Array.Copy(ans, hullPoints, k);
|
||||
|
||||
hullPoints[k] = hullPoints[0];
|
||||
|
||||
return (hullPoints);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PointComparer
|
||||
|
||||
private class PointComparer : IComparer<Point>
|
||||
{
|
||||
public int Compare(Point pt1, Point pt2)
|
||||
{
|
||||
return (ConvexHull.PtCompare(pt1, pt2));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PtCompare
|
||||
|
||||
private static int PtCompare(Point pt1, Point pt2)
|
||||
{
|
||||
if (pt1.X == pt2.X)
|
||||
return (pt1.Y - pt2.Y);
|
||||
|
||||
return (pt1.X - pt2.X);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PtCross
|
||||
|
||||
private static int PtCross(Point pt1, Point pt2)
|
||||
{
|
||||
return (pt1.X * pt2.Y - pt1.Y * pt2.X);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PtSub
|
||||
|
||||
private static Point PtSub(Point pt1, Point pt2)
|
||||
{
|
||||
return (new Point(pt1.X - pt2.X, pt1.Y - pt2.Y));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2AF9BA7A-2D05-419E-9F49-0CCEF791947E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DevComponents.DotNetBar.Charts</RootNamespace>
|
||||
<AssemblyName>DevComponents.DotNetBar.Charts</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;CHARTCONTROL</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\DevComponents.DotNetBar.Charts.XML</DocumentationFile>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>ChartControl.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChartControl\BaseChart.cs" />
|
||||
<Compile Include="ChartControl\BaseSeries.cs" />
|
||||
<Compile Include="ChartControl\ChartTitle.cs" />
|
||||
<Compile Include="ChartControl\ChartLegendItem.cs" />
|
||||
<Compile Include="ChartControl\ChartNote.cs" />
|
||||
<Compile Include="ChartControl\ChartContainer.cs" />
|
||||
<Compile Include="ChartControl\Annotation.cs" />
|
||||
<Compile Include="ChartControl\ChartPanel.cs" />
|
||||
<Compile Include="ChartControl\ChartIndicator.cs" />
|
||||
<Compile Include="ChartControl\RadialChart\PieLabel.cs" />
|
||||
<Compile Include="ChartControl\RadialChart\PieReferenceLine.cs" />
|
||||
<Compile Include="ChartControl\RadialChart\PieRing.cs" />
|
||||
<Compile Include="ChartControl\RadialChart\PieSeries.cs" />
|
||||
<Compile Include="ChartControl\RadialChart\RadialAlign.cs" />
|
||||
<Compile Include="ChartControl\TreeMap\TreeMap.cs" />
|
||||
<Compile Include="ChartControl\DataLabel.cs" />
|
||||
<Compile Include="ChartControl\ChartElement.cs" />
|
||||
<Compile Include="ChartControl\ChartMatrix.cs" />
|
||||
<Compile Include="ChartControl\SeriesPoints.cs" />
|
||||
<Compile Include="ChartControl\ChartLayoutInfo.cs" />
|
||||
<Compile Include="ChartControl\ChartRenderInfo.cs" />
|
||||
<Compile Include="ChartControl\ChartLegend.cs" />
|
||||
<Compile Include="ChartControl\ChartCrosshair.cs" />
|
||||
<Compile Include="ChartControl\DataBinder.cs" />
|
||||
<Compile Include="ChartControl\IOwnerLocalize.cs" />
|
||||
<Compile Include="ChartControl\RadialChart\PieChart.cs" />
|
||||
<Compile Include="ChartControl\TextDrawing.cs" />
|
||||
<Compile Include="ChartControl\XyChart\ChartAxes.cs" />
|
||||
<Compile Include="ChartControl\XyChart\ChartSeries.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ChartControl\XyChart\ChartTickmarks.cs" />
|
||||
<Compile Include="ChartControl\XyChart\FlockAlign.cs" />
|
||||
<Compile Include="ChartControl\XyChart\PointMarker.cs" />
|
||||
<Compile Include="ChartControl\XyChart\AxisStripe.cs" />
|
||||
<Compile Include="ChartControl\XyChart\ReferenceLine.cs" />
|
||||
<Compile Include="ChartControl\XyChart\ChartGridLines.cs" />
|
||||
<Compile Include="ChartControl\XyChart\ChartXy.cs" />
|
||||
<Compile Include="ChartControl\XyChart\PointLabel.cs" />
|
||||
<Compile Include="ChartEventArgs.cs" />
|
||||
<Compile Include="ChartControl\ChartLable.cs" />
|
||||
<Compile Include="ChartPrint.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ContentManager\BlockLayoutManager.cs" />
|
||||
<Compile Include="ContentManager\Enums.cs" />
|
||||
<Compile Include="ContentManager\IBlock.cs" />
|
||||
<Compile Include="ContentManager\IBlockExtended.cs" />
|
||||
<Compile Include="ContentManager\IContentLayoutManager.cs" />
|
||||
<Compile Include="ContentManager\SerialContentLayoutManager.cs" />
|
||||
<Compile Include="ConvexHull.cs" />
|
||||
<Compile Include="Helpers\MathHelper.cs" />
|
||||
<Compile Include="Helpers\PieSeriesConverter.cs" />
|
||||
<Compile Include="Helpers\PointFConverter.cs" />
|
||||
<Compile Include="Helpers\XmlHelpers.cs" />
|
||||
<Compile Include="Licensing.cs" />
|
||||
<Compile Include="Primitives\ColorFactory.cs" />
|
||||
<Compile Include="Primitives\SymbolDef.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ScrollBarLite\ScrollBarLite.cs" />
|
||||
<Compile Include="Style\ChartBarVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartHiLoBarVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartSliceVisualStyle.cs" />
|
||||
<Compile Include="Style\HiLoBarSegmentStyle.cs" />
|
||||
<Compile Include="Style\PieCenterVisualStyle.cs" />
|
||||
<Compile Include="Style\PieChartVisualStyle.cs" />
|
||||
<Compile Include="Style\PieGridLineVisualStyle .cs" />
|
||||
<Compile Include="Style\PieReferenceLineVisualStyle.cs" />
|
||||
<Compile Include="Style\PointMarkerVisualStyle.cs" />
|
||||
<Compile Include="Style\DropShadowVisualStyle.cs" />
|
||||
<Compile Include="Style\ConnectorLineVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartLineVisualStyle.cs" />
|
||||
<Compile Include="Style\AxisStripeVisualStyle .cs" />
|
||||
<Compile Include="Style\SliceCenterLineVisualStyle.cs" />
|
||||
<Compile Include="Style\SliceLabelVisualStyle.cs" />
|
||||
<Compile Include="Style\TrendLineVisualStyle.cs" />
|
||||
<Compile Include="Style\RegressionLineVisualStyle.cs" />
|
||||
<Compile Include="Style\CrosshairValuelVisualStyle.cs" />
|
||||
<Compile Include="Style\TickmarkLableVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartTickmarkVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartLegendItemVisualStyle.cs" />
|
||||
<Compile Include="Style\ReferenceLineVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartXyVisualStyle.cs" />
|
||||
<Compile Include="Style\ScrollBarVisualStyle.cs" />
|
||||
<Compile Include="Style\DividerLineVisualStyle.cs" />
|
||||
<Compile Include="Style\EffectiveStyles.cs" />
|
||||
<Compile Include="Helpers\TextHelpers.cs" />
|
||||
<Compile Include="Primitives\Converters.cs" />
|
||||
<Compile Include="Primitives\CustomCollection.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ChartControl.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Style\BackColorBlend.cs" />
|
||||
<Compile Include="Style\Background.cs" />
|
||||
<Compile Include="Style\BaseVisualStyle.cs" />
|
||||
<Compile Include="Style\BorderColor.cs" />
|
||||
<Compile Include="Style\BorderPattern.cs" />
|
||||
<Compile Include="Style\ChartAxisVisualStyle.cs" />
|
||||
<Compile Include="Style\AnnotationVisualStyle.cs" />
|
||||
<Compile Include="Style\SeriesLabelVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartSeriesVisualStyle.cs" />
|
||||
<Compile Include="Style\CrosshairVisualStyle.cs" />
|
||||
<Compile Include="Style\GridLineVisualStyle .cs" />
|
||||
<Compile Include="Style\DataLabelVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartTitleVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartLegendVisualStyle.cs" />
|
||||
<Compile Include="Style\ChartPanelVisualStyle.cs" />
|
||||
<Compile Include="Style\ContainerVisualStyle.cs" />
|
||||
<Compile Include="Style\DefaultVisualStyles.cs" />
|
||||
<Compile Include="Style\Padding.cs" />
|
||||
<Compile Include="Style\Thickness.cs" />
|
||||
<Compile Include="Style\VisualStyle.cs" />
|
||||
<Compile Include="Style\VisualStyles.cs" />
|
||||
<Compile Include="TextMarkup\BodyElement.cs" />
|
||||
<Compile Include="TextMarkup\ContainerElement.cs" />
|
||||
<Compile Include="TextMarkup\Div.cs" />
|
||||
<Compile Include="TextMarkup\EndMarkupElement.cs" />
|
||||
<Compile Include="TextMarkup\ExpandElement.cs" />
|
||||
<Compile Include="TextMarkup\FontChangeElement.cs" />
|
||||
<Compile Include="TextMarkup\FontElement.cs" />
|
||||
<Compile Include="TextMarkup\Heading.cs" />
|
||||
<Compile Include="TextMarkup\HyperLink.cs" />
|
||||
<Compile Include="TextMarkup\IActiveMarkupElement.cs" />
|
||||
<Compile Include="TextMarkup\ImageElement.cs" />
|
||||
<Compile Include="TextMarkup\Italic.cs" />
|
||||
<Compile Include="TextMarkup\MarkupDrawContext.cs" />
|
||||
<Compile Include="TextMarkup\MarkupElement.cs" />
|
||||
<Compile Include="TextMarkup\MarkupElementCollection.cs" />
|
||||
<Compile Include="TextMarkup\MarkupLayoutManager.cs" />
|
||||
<Compile Include="TextMarkup\MarkupParser.cs" />
|
||||
<Compile Include="TextMarkup\MarkupSettings.cs" />
|
||||
<Compile Include="TextMarkup\NewLine.cs" />
|
||||
<Compile Include="TextMarkup\Paragraph.cs" />
|
||||
<Compile Include="TextMarkup\Span.cs" />
|
||||
<Compile Include="TextMarkup\Strike.cs" />
|
||||
<Compile Include="TextMarkup\Strong.cs" />
|
||||
<Compile Include="TextMarkup\TextElement.cs" />
|
||||
<Compile Include="TextMarkup\Underline.cs" />
|
||||
<Compile Include="VisualStyles\MetroStyleFactory.cs" />
|
||||
<Compile Include="VisualStyles\Office2010BlackStyleFactory.cs" />
|
||||
<Compile Include="VisualStyles\Office2010BlueStyleFactory.cs" />
|
||||
<Compile Include="VisualStyles\Office2010SilverStyleFactory.cs" />
|
||||
<Compile Include="VisualStyles\VisualStyleFactory.cs" />
|
||||
<Compile Include="VisualStyles\VisualStylesTable.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DotNetBar.csproj">
|
||||
<Project>{36546ce3-335c-4ab6-a2f3-40f8c818bc66}</Project>
|
||||
<Name>DotNetBar</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ChartControl.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ClosedHand.cur" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="OpenHand.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ChartControl.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
internal static class MathHelper
|
||||
{
|
||||
#region ToDegrees
|
||||
|
||||
public static double ToDegrees(double radians)
|
||||
{
|
||||
return (radians * 180 / Math.PI);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToRadians
|
||||
|
||||
public static double ToRadians(double degrees)
|
||||
{
|
||||
return (degrees * Math.PI / 180);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPointAngle
|
||||
|
||||
public static int GetPointAngle(Point pt)
|
||||
{
|
||||
double theta = Math.Atan2(pt.X, -pt.Y);
|
||||
int angle = (int)(MathHelper.ToDegrees(theta) + 270) % 360;
|
||||
|
||||
return (angle);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPointRadius
|
||||
|
||||
public static int GetPointRadius(ref Point pt, Point cpt)
|
||||
{
|
||||
pt.X -= cpt.X;
|
||||
pt.Y -= cpt.Y;
|
||||
|
||||
return ((int)Math.Sqrt(pt.X * pt.X + pt.Y * pt.Y));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOffsetPoint
|
||||
|
||||
public static Point GetOffsetPoint(
|
||||
Point pt, Point cpt, out int radius, out int angle)
|
||||
{
|
||||
radius = MathHelper.GetPointRadius(ref pt, cpt);
|
||||
angle = MathHelper.GetPointAngle(pt);
|
||||
|
||||
return (pt);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clamp
|
||||
|
||||
public static T Clamp<T>(T value, T min, T max)
|
||||
where T : IComparable<T>
|
||||
{
|
||||
T result = value;
|
||||
|
||||
if (result.CompareTo(max) > 0)
|
||||
result = max;
|
||||
|
||||
if (result.CompareTo(min) < 0)
|
||||
result = min;
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToScalar
|
||||
|
||||
public static double ToScalar(double x)
|
||||
{
|
||||
return (MathHelper.Sqrt((float)(x / Math.PI)) * 2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sqrt
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
private struct FloatIntUnion
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float f;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public int tmp;
|
||||
}
|
||||
|
||||
public static float Sqrt(float x)
|
||||
{
|
||||
if (x != 0)
|
||||
{
|
||||
FloatIntUnion u;
|
||||
|
||||
u.tmp = 0;
|
||||
u.f = x;
|
||||
|
||||
u.tmp -= 1 << 23; // Subtract 2^m
|
||||
u.tmp >>= 1; // Divide by 2
|
||||
u.tmp += 1 << 29; // Add ((b + 1) / 2) * 2^m
|
||||
|
||||
return (u.f);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
public class PieSeriesConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override PropertyDescriptorCollection
|
||||
GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
PropertyDescriptorCollection pdc = base.GetProperties(context, value, attributes);
|
||||
|
||||
PropertyDescriptor[] newProps = new PropertyDescriptor[pdc.Count - 1];
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < pdc.Count; i++)
|
||||
{
|
||||
if (pdc[i].Name.Equals("SeriesType") == false)
|
||||
newProps[n++] = pdc[i];
|
||||
}
|
||||
|
||||
return new PropertyDescriptorCollection(newProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
public class PointFConverter : ExpandableObjectConverter
|
||||
{
|
||||
#region CanConvertTo
|
||||
|
||||
public override bool CanConvertTo(
|
||||
ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return (true);
|
||||
|
||||
return (base.CanConvertTo(context, destinationType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConvertTo
|
||||
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
PointF pf = (PointF)value;
|
||||
|
||||
return (String.Format("{0:f}, {1:f}", pf.X, pf.Y));
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CanConvertFrom
|
||||
|
||||
public override bool CanConvertFrom(
|
||||
ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(string))
|
||||
return (true);
|
||||
|
||||
return (base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConvertFrom
|
||||
|
||||
public override object ConvertFrom(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
if (value is string)
|
||||
{
|
||||
string[] values = ((string)value).Split(',');
|
||||
|
||||
if (values.Length != 2)
|
||||
throw new ArgumentException("Invalid value to convert.");
|
||||
|
||||
try
|
||||
{
|
||||
float x = float.Parse(values[0]);
|
||||
float y = float.Parse(values[1]);
|
||||
|
||||
PointF pf = new PointF(x, y);
|
||||
|
||||
return (pf);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException("Invalid value to convert.");
|
||||
}
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCreateInstanceSupported
|
||||
|
||||
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateInstance
|
||||
|
||||
public override object CreateInstance(
|
||||
ITypeDescriptorContext context, IDictionary propertyValues)
|
||||
{
|
||||
if (propertyValues != null)
|
||||
return (new PointF((float)propertyValues["X"], (float)propertyValues["Y"]));
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides helpers when working with text.
|
||||
/// </summary>
|
||||
internal static class TextHelper
|
||||
{
|
||||
private static int _textMarkupCultureSpecific = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the text-markup padding for text
|
||||
/// measurement when running on Japanese version of Windows.
|
||||
/// </summary>
|
||||
public static int TextMarkupCultureSpecificPadding
|
||||
{
|
||||
get { return _textMarkupCultureSpecific; }
|
||||
set { _textMarkupCultureSpecific = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MeasureText always adds about 1/2 em width of white space on the right,
|
||||
/// even when NoPadding is specified. It returns zero for an empty string.
|
||||
/// To get the precise string width, measure the width of a string containing a
|
||||
/// single period and subtract that from the width of our original string plus a period.
|
||||
/// </summary>
|
||||
public static Size MeasureText(Graphics g,
|
||||
string s, Font font, Size csize, eTextFormat tf)
|
||||
{
|
||||
return (TextDrawing.MeasureString(g, s, font, csize, tf));
|
||||
|
||||
if (font.Italic == true)
|
||||
return (TextDrawing.MeasureString(g, s, font, csize, tf));
|
||||
|
||||
Size sz1 = TextDrawing.MeasureString(g, ".", font, csize, tf);
|
||||
Size sz2 = TextDrawing.MeasureString(g, s + ".", font, csize, tf);
|
||||
|
||||
return (new Size(sz2.Width - sz1.Width, sz2.Height));
|
||||
}
|
||||
|
||||
public static Size MeasureText(Graphics g, string s, Font font)
|
||||
{
|
||||
return (TextDrawing.MeasureString(g, s, font));
|
||||
|
||||
if (font.Italic == true)
|
||||
return (TextDrawing.MeasureString(g, s, font));
|
||||
|
||||
Size sz1 = TextDrawing.MeasureString(g, ".", font);
|
||||
Size sz2 = TextDrawing.MeasureString(g, s + ".", font);
|
||||
|
||||
return (new Size(sz2.Width - sz1.Width, sz2.Height));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
internal class Licensing
|
||||
{
|
||||
#if !TRIAL
|
||||
internal static bool KeyValidated;
|
||||
internal static int KeyValidated2;
|
||||
|
||||
internal static bool ValidateLicenseKey(string key)
|
||||
{
|
||||
string[] parts = key.Split('-');
|
||||
int i = 10;
|
||||
|
||||
foreach (string s in parts)
|
||||
{
|
||||
if (s == "88405280")
|
||||
i++;
|
||||
else if (s == "D06E")
|
||||
i += 10;
|
||||
else if (s == "4617")
|
||||
i += 8;
|
||||
else if (s == "8810")
|
||||
i += 12;
|
||||
else if (s == "64462F60FA93")
|
||||
i += 3;
|
||||
}
|
||||
|
||||
if (i == 29)
|
||||
return true;
|
||||
|
||||
KeyValidated = true;
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
internal static bool CheckLicenseKey(string key)
|
||||
{
|
||||
// {F962CEC7-CD8F-4911-A9E9-CAB39962FC1F}, 114
|
||||
string[] parts = key.Split('-');
|
||||
int test = 0;
|
||||
|
||||
for (int i = parts.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (parts[i] == "CD8F")
|
||||
test += 12;
|
||||
else if (parts[i] == "CAB39962FC1F")
|
||||
test += 2;
|
||||
else if (parts[i] == "A9E9")
|
||||
test += 3;
|
||||
else if (parts[i] == "4911")
|
||||
test += 7;
|
||||
else if (parts[i] == "F962CEC7")
|
||||
test += 13;
|
||||
}
|
||||
|
||||
KeyValidated2 = test + 77;
|
||||
|
||||
if (test == 23)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TRIAL
|
||||
private static Color m_ColorExpFlag = Color.Empty;
|
||||
internal static int ColorCountExp;
|
||||
|
||||
internal static bool ColorExpAlt()
|
||||
{
|
||||
Color clr=SystemColors.Control;
|
||||
Color clr2;
|
||||
Color clr3;
|
||||
clr2=clr;
|
||||
|
||||
if(clr2.ToArgb()==clr.ToArgb())
|
||||
{
|
||||
clr3=clr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
clr3=clr;
|
||||
}
|
||||
|
||||
ColorCountExp=clr.A;
|
||||
|
||||
if(!m_ColorExpFlag.IsEmpty)
|
||||
{
|
||||
return (m_ColorExpFlag==Color.Black?false:true);
|
||||
}
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.ClassesRoot;
|
||||
key=key.CreateSubKey("CLSID\\{542FD3B2-2F65-4290-AB4F-EBFF0444C54C}\\InprocServer32");
|
||||
|
||||
try
|
||||
{
|
||||
if(key.GetValue("")==null || key.GetValue("").ToString()=="")
|
||||
{
|
||||
key.SetValue("",DateTime.Today.ToOADate().ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(key.GetValue("").ToString()=="windows3.dll")
|
||||
{
|
||||
m_ColorExpFlag=Color.White;
|
||||
key.Close();
|
||||
key=null;
|
||||
return true;
|
||||
}
|
||||
DateTime date=DateTime.FromOADate(double.Parse(key.GetValue("").ToString()));
|
||||
if(((TimeSpan)DateTime.Today.Subtract(date)).TotalDays>30)
|
||||
{
|
||||
m_ColorExpFlag=Color.White;
|
||||
key.SetValue("","windows3.dll");
|
||||
key.Close();
|
||||
key=null;
|
||||
return true;
|
||||
}
|
||||
if(((TimeSpan)DateTime.Today.Subtract(date)).TotalDays<0)
|
||||
{
|
||||
m_ColorExpFlag=Color.White;
|
||||
key.SetValue("","windows2.dll");
|
||||
key.Close();
|
||||
key=null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(key!=null)
|
||||
key.Close();
|
||||
}
|
||||
}
|
||||
catch{}
|
||||
|
||||
m_ColorExpFlag=Color.Black;
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 326 B |
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Primitives
|
||||
{
|
||||
public class ColorFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgbHex">Hexadecimal color representation.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(string rgbHex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(rgbHex) == false)
|
||||
{
|
||||
if (rgbHex.Length == 8)
|
||||
{
|
||||
return (Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(4, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(6, 2), 16)));
|
||||
}
|
||||
|
||||
return (Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(4, 2), 16)));
|
||||
}
|
||||
|
||||
return Color.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts int value to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgb">Color representation as 32-bit RGB value.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int rgb)
|
||||
{
|
||||
return ((rgb == -1) ? Color.Empty :
|
||||
Color.FromArgb((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts int values to Color type.
|
||||
/// </summary>
|
||||
/// <param name="alpha"></param>
|
||||
/// <param name="rgb">Color representation as 32-bit RGB value.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int alpha, int rgb)
|
||||
{
|
||||
return ((rgb == -1) ? Color.Empty :
|
||||
Color.FromArgb(alpha, (rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts int values to Color type.
|
||||
/// </summary>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int red, int green, int blue)
|
||||
{
|
||||
return (ColorFactory.GetColor(255, red, green, blue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts int values to Color type.
|
||||
/// </summary>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int alpha, int red, int green, int blue)
|
||||
{
|
||||
return (Color.FromArgb(alpha, red, green, blue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Primitives
|
||||
{
|
||||
#region BlankExpandableObjectConverter
|
||||
|
||||
///<summary>
|
||||
/// BlankExpandableObjectConverter
|
||||
///</summary>
|
||||
public class BlankExpandableObjectConverter : ExpandableObjectConverter
|
||||
{
|
||||
///<summary>
|
||||
/// ConvertTo
|
||||
///</summary>
|
||||
///<param name="context"></param>
|
||||
///<param name="culture"></param>
|
||||
///<param name="value"></param>
|
||||
///<param name="destinationType"></param>
|
||||
///<returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return (" ");
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,549 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Globalization;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
[TypeConverter(typeof(SymbolDefConvertor))]
|
||||
[Editor(typeof(SymbolDefEditor), typeof(UITypeEditor))]
|
||||
public class SymbolDef : INotifyPropertyChanged, IDisposable, IProcessSerialElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _Symbol = "";
|
||||
private string _SymbolRealized;
|
||||
|
||||
private float _SymbolSize = -1f;
|
||||
private Color _SymbolColor = Color.Empty;
|
||||
private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
|
||||
|
||||
private Font _SymbolFont;
|
||||
private Size _RealSymbolSize;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Symbol
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the displayed Symbol. Symbol setting takes precedence over Image setting.
|
||||
/// </summary>
|
||||
[DefaultValue(""), Category("Appearance"), Description("displayed Symbol. Symbol setting takes precedence over Image setting.")]
|
||||
[Editor("DevComponents.DotNetBar.Design.SymbolTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public string Symbol
|
||||
{
|
||||
get { return (_Symbol); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
value = "";
|
||||
|
||||
if (value != _Symbol)
|
||||
{
|
||||
_Symbol = value;
|
||||
_SymbolRealized = null;
|
||||
|
||||
OnPropertyChangedEx("Symbol");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the Symbol.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of the Symbol.")]
|
||||
public Color SymbolColor
|
||||
{
|
||||
get { return (_SymbolColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_SymbolColor != value)
|
||||
{
|
||||
_SymbolColor = value;
|
||||
|
||||
OnPropertyChangedEx("SymbolColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeSymbolColor()
|
||||
{
|
||||
return (_SymbolColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetSymbolColor()
|
||||
{
|
||||
SymbolColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolRealized
|
||||
|
||||
/// <summary>
|
||||
/// Gets the realized symbol string.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string SymbolRealized
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SymbolRealized == null)
|
||||
{
|
||||
if (_Symbol != null)
|
||||
_SymbolRealized = Symbols.GetSymbol(_Symbol);
|
||||
}
|
||||
|
||||
return (_SymbolRealized);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolSet
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the symbol set used to represent the Symbol.
|
||||
/// </summary>
|
||||
[DefaultValue(eSymbolSet.Awesome)]
|
||||
public eSymbolSet SymbolSet
|
||||
{
|
||||
get { return (_SymbolSet); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_SymbolSet != value)
|
||||
{
|
||||
_SymbolSet = value;
|
||||
|
||||
_SymbolRealized = null;
|
||||
_SymbolFont = null;
|
||||
_RealSymbolSize = Size.Empty;
|
||||
|
||||
OnPropertyChangedEx("SymbolSet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolSize
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the size of the symbol in points.
|
||||
/// </summary>
|
||||
[DefaultValue(-1f), Category("Appearance")]
|
||||
[Description("Indicates the size of the symbol in points.")]
|
||||
public float SymbolSize
|
||||
{
|
||||
get { return (_SymbolSize); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _SymbolSize)
|
||||
{
|
||||
_SymbolSize = value;
|
||||
_SymbolFont = null;
|
||||
_RealSymbolSize = Size.Empty;
|
||||
|
||||
OnPropertyChangedEx("SymbolSize");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether SymbolDef is Empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((string.IsNullOrEmpty(_Symbol) == true) &&
|
||||
(_SymbolColor.IsEmpty == true) &&
|
||||
(_SymbolSize == -1f));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region SymbolFont
|
||||
|
||||
internal Font SymbolFont
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SymbolFont == null)
|
||||
_SymbolFont = Symbols.GetFont(SymbolSize, SymbolSet);
|
||||
|
||||
return (_SymbolFont);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_SymbolFont = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsValidSymbol
|
||||
|
||||
internal bool IsValidSymbol
|
||||
{
|
||||
get { return (string.IsNullOrEmpty(SymbolRealized) == false); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSymbolSize
|
||||
|
||||
internal Size GetSymbolSize(Graphics g)
|
||||
{
|
||||
if (_RealSymbolSize == Size.Empty)
|
||||
{
|
||||
Font font = SymbolFont;
|
||||
|
||||
Size size = g.MeasureString(SymbolRealized, font).ToSize();
|
||||
|
||||
size.Width++;
|
||||
size.Height++;
|
||||
|
||||
_RealSymbolSize = size;
|
||||
}
|
||||
|
||||
return (_RealSymbolSize);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the SymbolDef.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the SymbolDef.</returns>
|
||||
public SymbolDef Copy()
|
||||
{
|
||||
SymbolDef style = new SymbolDef();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(SymbolDef style)
|
||||
{
|
||||
style.Symbol = _Symbol;
|
||||
|
||||
style.SymbolColor = _SymbolColor;
|
||||
style.SymbolSet = _SymbolSet;
|
||||
style.SymbolSize = _SymbolSize;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
if (IsEmpty == false)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "SymbolDef";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (IsValidSymbol == true)
|
||||
sec.AddValue("Symbol", Symbol);
|
||||
|
||||
sec.AddValue("SymbolColor", SymbolColor, Color.Empty);
|
||||
sec.AddValue("SymbolSet", SymbolSet, eSymbolSet.Awesome);
|
||||
sec.AddValue("SymbolSize", SymbolSize, -1f);
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessValue
|
||||
|
||||
void IProcessSerialElement.ProcessValue(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Symbol":
|
||||
Symbol = se.GetValueString();
|
||||
break;
|
||||
|
||||
case "SymbolColor":
|
||||
SymbolColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "SymbolSet":
|
||||
SymbolSet = (eSymbolSet)se.GetValueEnum(typeof(eSymbolSet));
|
||||
break;
|
||||
|
||||
case "SymbolSize":
|
||||
SymbolSize = float.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown Serial Value (" + se.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
void IProcessSerialElement.ProcessCollection(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
default:
|
||||
throw new Exception("Unknown Serial Collection (" + se.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(VisualPropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s, VisualChangeType changeType)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s, changeType);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateChangeHandler
|
||||
|
||||
private void UpdateChangeHandler(
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
oldValue.PropertyChanged -= StyleChanged;
|
||||
|
||||
if (newValue != null)
|
||||
newValue.PropertyChanged += StyleChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleChanged
|
||||
|
||||
/// <summary>
|
||||
/// StyleChanged
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected virtual void StyleChanged(
|
||||
object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged((VisualPropertyChangedEventArgs)e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
SymbolFont = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region SymbolDefConvertor
|
||||
|
||||
///<summary>
|
||||
/// SymbolDefConvertor
|
||||
///</summary>
|
||||
public class SymbolDefConvertor : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
SymbolDef sd = value as SymbolDef;
|
||||
|
||||
if (sd != null)
|
||||
return (sd.SymbolSet.ToString());
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolDefEditor
|
||||
|
||||
///<summary>
|
||||
/// SymbolDefEditor
|
||||
///</summary>
|
||||
public class SymbolDefEditor : UITypeEditor
|
||||
{
|
||||
#region GetPaintValueSupported
|
||||
|
||||
/// <summary>
|
||||
/// GetPaintValueSupported
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PaintValue
|
||||
|
||||
/// <summary>
|
||||
/// PaintValue
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void PaintValue(PaintValueEventArgs e)
|
||||
{
|
||||
SymbolDef sd = e.Value as SymbolDef;
|
||||
|
||||
if (sd != null)
|
||||
{
|
||||
Font font = Symbols.GetFont(10, sd.SymbolSet);
|
||||
|
||||
Color color = sd.SymbolColor;
|
||||
|
||||
if (sd.SymbolColor.IsEmpty || sd.SymbolColor == Color.White)
|
||||
color = Color.Brown;
|
||||
|
||||
using (Brush br = new SolidBrush(color))
|
||||
{
|
||||
using (StringFormat sf = new StringFormat())
|
||||
{
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
|
||||
e.Graphics.DrawString(sd.SymbolRealized, font, br, e.Bounds, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
63
PROMS/DotNetBar Source Code/DevComponents.DotNetBar.Charts/Properties/Resources.Designer.cs
generated
Normal file
63
PROMS/DotNetBar Source Code/DevComponents.DotNetBar.Charts/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34209
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevComponents.DotNetBar.Charts.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</root>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,206 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
///<summary>
|
||||
/// AnnotationVisualStyles
|
||||
///</summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class AnnotationVisualStyles : VisualStyles<AnnotationVisualStyle>
|
||||
{
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public AnnotationVisualStyles Copy()
|
||||
{
|
||||
AnnotationVisualStyles styles = new AnnotationVisualStyles();
|
||||
|
||||
for (int i = 0; i < Styles.Length; i++)
|
||||
{
|
||||
AnnotationVisualStyle vstyle = Styles[i];
|
||||
|
||||
if (vstyle != null)
|
||||
styles.Styles[i] = vstyle.Copy();
|
||||
}
|
||||
|
||||
return (styles);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Legend element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class AnnotationVisualStyle : ContainerVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private AnnotationShape _AnnotationShape = AnnotationShape.Ellipse;
|
||||
private ConnectorShape _ConnectorShape = ConnectorShape.NotSet;
|
||||
|
||||
private Alignment _TextAlignment = Alignment.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AnnotationShape
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the shape of the annotation container.
|
||||
/// </summary>
|
||||
[DefaultValue(AnnotationShape.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the shape of the annotation container.")]
|
||||
public AnnotationShape AnnotationShape
|
||||
{
|
||||
get { return (_AnnotationShape); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AnnotationShape != value)
|
||||
{
|
||||
_AnnotationShape = value;
|
||||
|
||||
OnPropertyChangedEx("AnnotationShape", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConnectorShape
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the shape of the annotation connector.
|
||||
/// </summary>
|
||||
[DefaultValue(ConnectorShape.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the shape of the annotation connector.")]
|
||||
public ConnectorShape ConnectorShape
|
||||
{
|
||||
get { return (_ConnectorShape); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ConnectorShape != value)
|
||||
{
|
||||
_ConnectorShape = value;
|
||||
|
||||
OnPropertyChangedEx("ConnectorShape", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextAlignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the content within the cell
|
||||
/// </summary>
|
||||
[DefaultValue(Alignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the alignment of the content within the cell.")]
|
||||
public Alignment TextAlignment
|
||||
{
|
||||
get { return (_TextAlignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextAlignment != value)
|
||||
{
|
||||
_TextAlignment = value;
|
||||
|
||||
OnPropertyChangedEx("TextAlignment", 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 ((_AnnotationShape == AnnotationShape.NotSet) &&
|
||||
(_ConnectorShape == ConnectorShape.NotSet) &&
|
||||
(_TextAlignment == Alignment.NotSet) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(AnnotationVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.AnnotationShape != AnnotationShape.NotSet)
|
||||
_AnnotationShape = style.AnnotationShape;
|
||||
|
||||
if (style.ConnectorShape != ConnectorShape.NotSet)
|
||||
_ConnectorShape = style.ConnectorShape;
|
||||
|
||||
if (style.TextAlignment != Alignment.NotSet)
|
||||
_TextAlignment = style.TextAlignment;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new AnnotationVisualStyle Copy()
|
||||
{
|
||||
AnnotationVisualStyle style = new AnnotationVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(AnnotationVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AnnotationShape = _AnnotationShape;
|
||||
style.ConnectorShape = _ConnectorShape;
|
||||
style.TextAlignment = _TextAlignment;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a AxisStripeVisualStyle.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class AxisStripeVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Background _Background;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Background
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style background.
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBackground()
|
||||
{
|
||||
return (_Background != null && _Background.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBackground()
|
||||
{
|
||||
Background = null;
|
||||
}
|
||||
|
||||
#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 ((_Background == null || _Background.IsEmpty == true) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(AxisStripeVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._Background != null && style._Background.IsEmpty == false)
|
||||
Background = style._Background.Copy();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new AxisStripeVisualStyle Copy()
|
||||
{
|
||||
AxisStripeVisualStyle style = new AxisStripeVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(AxisStripeVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.Background = (_Background != null) ? _Background.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "AxisStripeVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_Background != null && _Background.IsEmpty == false)
|
||||
sec.AddElement(_Background.GetSerialData("Background"));
|
||||
|
||||
sec.AddElement(base.GetSerialData(null));
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Background":
|
||||
sec.PutSerialData(Background);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
Background = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
///<summary>
|
||||
/// BackColorBlend
|
||||
///</summary>
|
||||
[TypeConverter(typeof(BackColorBlendConvertor))]
|
||||
public class BackColorBlend : INotifyPropertyChanged, IProcessSerialElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Color[] _Colors; // Color values
|
||||
private float[] _Positions; // Gradient color positions
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Colors
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ColorBlend Color array
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(null)]
|
||||
[Description("Indicates the ColorBlend Color array")]
|
||||
[TypeConverter(typeof(ArrayConverter))]
|
||||
public Color[] Colors
|
||||
{
|
||||
get { return (_Colors); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length == 0)
|
||||
value = null;
|
||||
|
||||
_Colors = value;
|
||||
|
||||
OnPropertyChangedEx("Colors");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Positions
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ColorBlend Color Positions
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(null)]
|
||||
[Description("Indicates the ColorBlend Color Positions")]
|
||||
[TypeConverter(typeof(ArrayConverter))]
|
||||
public float[] Positions
|
||||
{
|
||||
get { return (_Positions); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length == 0)
|
||||
value = null;
|
||||
|
||||
_Positions = value;
|
||||
|
||||
OnPropertyChangedEx("Positions");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return (_Colors == null || _Colors.Length == 1 && _Colors[0].IsEmpty); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the BackColorBlend.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the BackColorBlend.</returns>
|
||||
public BackColorBlend Copy()
|
||||
{
|
||||
BackColorBlend copy = new BackColorBlend();
|
||||
|
||||
if (_Colors != null)
|
||||
{
|
||||
copy.Colors = new Color[_Colors.Length];
|
||||
|
||||
_Colors.CopyTo(copy.Colors, 0);
|
||||
}
|
||||
|
||||
if (_Positions != null)
|
||||
{
|
||||
copy.Positions = new float[_Positions.Length];
|
||||
|
||||
_Positions.CopyTo(copy.Positions, 0);
|
||||
}
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal SerialElementCollection GetSerialData()
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
sec.AddStartElement("BackColorBlend");
|
||||
|
||||
if (_Colors != null && _Colors.Length > 0)
|
||||
{
|
||||
sec.AddStartElement("Colors count=\"" + _Colors.Length + "\"");
|
||||
|
||||
foreach (Color color in _Colors)
|
||||
sec.AddValue("Color", color);
|
||||
|
||||
sec.AddEndElement("Colors");
|
||||
}
|
||||
|
||||
if (_Positions != null && _Positions.Length > 0)
|
||||
{
|
||||
sec.AddStartElement("Positions count=\"" + _Positions.Length + "\"");
|
||||
|
||||
foreach (float pos in _Positions)
|
||||
sec.AddDataValue("Position", pos);
|
||||
|
||||
sec.AddEndElement("Positions");
|
||||
}
|
||||
|
||||
sec.AddEndElement("BackColorBlend");
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessValue
|
||||
|
||||
void IProcessSerialElement.ProcessValue(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Color":
|
||||
_Colors[se.ValueIndex] = se.ColorValue;
|
||||
break;
|
||||
|
||||
case "Position":
|
||||
_Positions[se.ValueIndex] = (float)se.DataValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown Serial Value (" + se.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
void IProcessSerialElement.ProcessCollection(SerialElement se)
|
||||
{
|
||||
int count = se.ArrayCount;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Colors":
|
||||
_Colors = new Color[count];
|
||||
break;
|
||||
|
||||
case "Positions":
|
||||
_Positions = new float[count];
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown Serial Collection (" + se.Name + ")");
|
||||
}
|
||||
|
||||
se.Sec.PutSerialData(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region BackColorBlendConvertor
|
||||
|
||||
/// <summary>
|
||||
/// BackColorBlendConvertor
|
||||
/// </summary>
|
||||
public class BackColorBlendConvertor : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
BackColorBlend cb = value as BackColorBlend;
|
||||
|
||||
if (cb != null)
|
||||
{
|
||||
ColorConverter cvt = new ColorConverter();
|
||||
|
||||
if (cb.Colors != null)
|
||||
{
|
||||
if (cb.Colors[0] != Color.Empty)
|
||||
return (cvt.ConvertToString(cb.Colors[0]));
|
||||
|
||||
if (cb.Colors.Length > 1 && cb.Colors[1] != Color.Empty)
|
||||
return (cvt.ConvertToString(cb.Colors[1]));
|
||||
}
|
||||
}
|
||||
|
||||
return (String.Empty);
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,622 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base visual style.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
public class BaseVisualStyle : INotifyPropertyChanged, IDisposable, IProcessSerialElement
|
||||
{
|
||||
#region Static data
|
||||
|
||||
static private List<BaseVisualStyle> _StyleList;
|
||||
private static StyleUpdateMode _StyleUpdateMode = StyleUpdateMode.Full;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private StyleType _StyleType;
|
||||
private BaseVisualStyle _Parent;
|
||||
|
||||
private ushort _StyleUpdateCount;
|
||||
|
||||
private string _Class = "";
|
||||
private object _Tag;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Class
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the class style belongs to.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public string Class
|
||||
{
|
||||
get { return (_Class); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Class != value)
|
||||
{
|
||||
_Class = value;
|
||||
|
||||
OnPropertyChangedEx("Class", 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 virtual bool IsEmpty
|
||||
{
|
||||
get { return (_Tag == null); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tag
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user defined reference Tag.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("User defined reference Tag.")]
|
||||
public object Tag
|
||||
{
|
||||
get { return (_Tag); }
|
||||
set { _Tag = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region StyleType
|
||||
|
||||
internal StyleType StyleType
|
||||
{
|
||||
get { return (_StyleType); }
|
||||
set { _StyleType = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleUpdateCount
|
||||
|
||||
internal ushort StyleUpdateCount
|
||||
{
|
||||
get { return (_StyleUpdateCount); }
|
||||
set { _StyleUpdateCount = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleUpdateMode
|
||||
|
||||
internal StyleUpdateMode StyleUpdateMode
|
||||
{
|
||||
get { return (_StyleUpdateMode); }
|
||||
set { _StyleUpdateMode = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Parent
|
||||
|
||||
internal BaseVisualStyle Parent
|
||||
{
|
||||
get { return (_Parent); }
|
||||
set { _Parent = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleList
|
||||
|
||||
internal List<BaseVisualStyle> StyleList
|
||||
{
|
||||
get { return (_StyleList); }
|
||||
set { _StyleList = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(BaseVisualStyle style)
|
||||
{
|
||||
if (StyleList != null)
|
||||
StyleList.Add(style ?? this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetApplyStyleTypes
|
||||
|
||||
internal StyleType[] GetApplyStyleTypes(StyleType e)
|
||||
{
|
||||
StyleType[] css = null;
|
||||
|
||||
switch (e)
|
||||
{
|
||||
case StyleType.Default:
|
||||
css = new StyleType[] { StyleType.Default};
|
||||
break;
|
||||
|
||||
case StyleType.MouseOver:
|
||||
css = new StyleType[] { StyleType.Default, e };
|
||||
break;
|
||||
|
||||
case StyleType.Selected:
|
||||
css = new StyleType[] { StyleType.Default, e };
|
||||
break;
|
||||
|
||||
case StyleType.SelectedMouseOver:
|
||||
css = new StyleType[] { StyleType.Default, StyleType.Selected, e };
|
||||
break;
|
||||
}
|
||||
|
||||
return (css);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public BaseVisualStyle Copy()
|
||||
{
|
||||
BaseVisualStyle style = new BaseVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(BaseVisualStyle copy)
|
||||
{
|
||||
copy.Class = _Class;
|
||||
copy.Tag = _Tag;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal virtual SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
if ((String.IsNullOrEmpty(Class) == false) || (Tag != null))
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "BaseVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("Class", Class, "");
|
||||
sec.AddValue("Tag", Tag, null);
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessValue
|
||||
|
||||
void IProcessSerialElement.ProcessValue(SerialElement se)
|
||||
{
|
||||
ProcessValue(se);
|
||||
}
|
||||
|
||||
internal virtual void ProcessValue(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Name":
|
||||
Class = se.StringValue;
|
||||
break;
|
||||
|
||||
case "Tag":
|
||||
Tag = se.DataValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown Serial Value (" + se.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
void IProcessSerialElement.ProcessCollection(SerialElement se)
|
||||
{
|
||||
ProcessCollection(se);
|
||||
}
|
||||
|
||||
internal virtual void ProcessCollection(SerialElement se)
|
||||
{
|
||||
throw new Exception("Unknown Serial Collection (" + se.Name + ")");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public virtual void ApplyDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
if ((StyleUpdateMode & StyleUpdateMode.UpdateCount) == StyleUpdateMode.UpdateCount)
|
||||
StyleUpdateCount++;
|
||||
|
||||
if ((StyleUpdateMode & StyleUpdateMode.Notify) == StyleUpdateMode.Notify)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnPropertyChanged(string s)
|
||||
{
|
||||
if ((StyleUpdateMode & StyleUpdateMode.UpdateCount) == StyleUpdateMode.UpdateCount)
|
||||
StyleUpdateCount++;
|
||||
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="changeType">invalidate</param>
|
||||
protected void OnPropertyChangedEx(string s, VisualChangeType changeType)
|
||||
{
|
||||
if ((StyleUpdateMode & StyleUpdateMode.UpdateCount) == StyleUpdateMode.UpdateCount)
|
||||
StyleUpdateCount++;
|
||||
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s, changeType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateChangeHandler
|
||||
|
||||
/// <summary>
|
||||
/// UpdateChangeHandler
|
||||
/// </summary>
|
||||
/// <param name="oldValue"></param>
|
||||
/// <param name="newValue"></param>
|
||||
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 OnStyleChanged
|
||||
|
||||
protected void OnStyleChanged(string property,
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
UpdateChangeHandler(oldValue, newValue);
|
||||
|
||||
OnPropertyChanged(property);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region StyleState
|
||||
|
||||
///<summary>
|
||||
/// StyleState
|
||||
///</summary>
|
||||
[Flags]
|
||||
public enum StyleState
|
||||
{
|
||||
///<summary>
|
||||
/// Default
|
||||
///</summary>
|
||||
Default = 0,
|
||||
|
||||
///<summary>
|
||||
/// MouseOver
|
||||
///</summary>
|
||||
MouseOver = (1 << 0),
|
||||
|
||||
///<summary>
|
||||
/// Selected
|
||||
///</summary>
|
||||
Selected = (1 << 1),
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleType
|
||||
|
||||
///<summary>
|
||||
/// StyleType
|
||||
///</summary>
|
||||
public enum StyleType
|
||||
{
|
||||
///<summary>
|
||||
/// CellStyle is Not Set
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// Default
|
||||
///</summary>
|
||||
Default = 0,
|
||||
|
||||
///<summary>
|
||||
/// MouseOver
|
||||
///</summary>
|
||||
MouseOver,
|
||||
|
||||
///<summary>
|
||||
/// Selected
|
||||
///</summary>
|
||||
Selected,
|
||||
|
||||
///<summary>
|
||||
/// SelectedMouseOver
|
||||
///</summary>
|
||||
SelectedMouseOver,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleUpdateMode
|
||||
|
||||
[Flags]
|
||||
internal enum StyleUpdateMode
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Notify = (1 << 0),
|
||||
UpdateCount = (1 << 1),
|
||||
|
||||
Full = (UpdateCount | Notify),
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tbool
|
||||
|
||||
///<summary>
|
||||
/// TBool - Three state boolean
|
||||
///</summary>
|
||||
public enum Tbool
|
||||
{
|
||||
///<summary>
|
||||
/// NotSet
|
||||
///</summary>
|
||||
NotSet,
|
||||
|
||||
///<summary>
|
||||
/// True
|
||||
///</summary>
|
||||
True,
|
||||
|
||||
///<summary>
|
||||
/// False
|
||||
///</summary>
|
||||
False
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VisualChangeType
|
||||
|
||||
/// <summary>
|
||||
/// Defines visual property change type.
|
||||
/// </summary>
|
||||
public enum VisualChangeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Visual style has changed so Recalc is needed
|
||||
/// </summary>
|
||||
Recalc,
|
||||
|
||||
/// <summary>
|
||||
/// Visual style has changed so layout is impacted, but not recalc
|
||||
/// </summary>
|
||||
Layout,
|
||||
|
||||
/// <summary>
|
||||
/// Visual style has changed so visuals are impacted, but not layout
|
||||
/// </summary>
|
||||
Render
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region VisualPropertyChangedEventArgs
|
||||
|
||||
/// <summary>
|
||||
/// Represents visual property changed event arguments.
|
||||
/// </summary>
|
||||
public class VisualPropertyChangedEventArgs : PropertyChangedEventArgs
|
||||
{
|
||||
#region Public data
|
||||
|
||||
/// <summary>
|
||||
/// Gets the change type.
|
||||
/// </summary>
|
||||
public readonly VisualChangeType ChangeType;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the VisualPropertyChangedEventArgs class.
|
||||
/// </summary>
|
||||
public VisualPropertyChangedEventArgs(string propertyName)
|
||||
: base(propertyName)
|
||||
{
|
||||
ChangeType = VisualChangeType.Layout;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the VisualPropertyChangedEventArgs class.
|
||||
/// </summary>
|
||||
public VisualPropertyChangedEventArgs(string propertyName, VisualChangeType changeType)
|
||||
: base(propertyName)
|
||||
{
|
||||
ChangeType = changeType;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VisualStylesConverter
|
||||
|
||||
///<summary>
|
||||
/// VisualStylesConverter
|
||||
///</summary>
|
||||
public class VisualStylesConverter : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return (" ");
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DefaultStyleConvertor
|
||||
|
||||
public class DefaultStyleConvertor : ExpandableObjectConverter
|
||||
{
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
BaseVisualStyle bvs = value as BaseVisualStyle;
|
||||
|
||||
if (bvs != null)
|
||||
{
|
||||
ColorConverter cvt = new ColorConverter();
|
||||
|
||||
return ((bvs.IsEmpty == true) ? " " : "(Set)");
|
||||
}
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,670 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Drawing.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents style border color.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BorderColorConverter))]
|
||||
public class BorderColor : IProcessSerialElement, INotifyPropertyChanged
|
||||
{
|
||||
#region Static data
|
||||
|
||||
///<summary>
|
||||
/// Empty
|
||||
///</summary>
|
||||
/// <summary>
|
||||
/// Returns Empty instance of BorderColor.
|
||||
/// </summary>
|
||||
public static BorderColor Empty
|
||||
{
|
||||
get { return (new BorderColor()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private Color _Top = Color.Empty;
|
||||
private Color _Left = Color.Empty;
|
||||
private Color _Bottom = Color.Empty;
|
||||
private Color _Right = Color.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the BorderColor object.
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="top"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <param name="bottom"></param>
|
||||
public BorderColor(Color left, Color top, Color right, Color bottom)
|
||||
{
|
||||
_Top = top;
|
||||
_Bottom = bottom;
|
||||
_Left = left;
|
||||
_Right = right;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the BorderColor object.
|
||||
/// </summary>
|
||||
public BorderColor(Color all)
|
||||
: this(all, all, all, all)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the BorderColor object.
|
||||
/// </summary>
|
||||
public BorderColor()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region All
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of all borders.
|
||||
/// </summary>
|
||||
//[Browsable(false)]
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Color All
|
||||
{
|
||||
set { _Top = _Left = _Bottom = _Right = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bottom
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the bottom border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the bottom border")]
|
||||
public Color Bottom
|
||||
{
|
||||
get { return (_Bottom); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Bottom != value)
|
||||
{
|
||||
_Bottom = value;
|
||||
|
||||
OnVisualPropertyChanged("Bottom");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeBottom()
|
||||
{
|
||||
return (_Bottom.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetBottom()
|
||||
{
|
||||
Bottom = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Left
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the left border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the left border")]
|
||||
public Color Left
|
||||
{
|
||||
get { return (_Left); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Left != value)
|
||||
{
|
||||
_Left = value;
|
||||
|
||||
OnVisualPropertyChanged("Left");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLeft()
|
||||
{
|
||||
return (_Left.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLeft()
|
||||
{
|
||||
Left = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Right
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the right border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the right border")]
|
||||
public Color Right
|
||||
{
|
||||
get { return (_Right); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Right != value)
|
||||
{
|
||||
_Right = value;
|
||||
|
||||
OnVisualPropertyChanged("Right");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeRight()
|
||||
{
|
||||
return (_Right.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetRight()
|
||||
{
|
||||
Right = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Top
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the top border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the top border")]
|
||||
public Color Top
|
||||
{
|
||||
get { return (_Top); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Top != value)
|
||||
{
|
||||
_Top = value;
|
||||
|
||||
OnVisualPropertyChanged("Top");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeTop()
|
||||
{
|
||||
return (_Top.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetTop()
|
||||
{
|
||||
Top = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
internal bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left.IsEmpty && _Top.IsEmpty &&
|
||||
_Right.IsEmpty && _Bottom.IsEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsUniform
|
||||
|
||||
internal bool IsUniform
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left == _Top &&
|
||||
_Left == _Right && _Left == _Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
#region '==' operator
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances.
|
||||
/// </summary>
|
||||
/// <param name="t1">Instance 1</param>
|
||||
/// <param name="t2">Instance 2</param>
|
||||
/// <returns>true if same</returns>
|
||||
public static bool operator ==(BorderColor t1, BorderColor t2)
|
||||
{
|
||||
// If both are null, or both are same instance, return true.
|
||||
|
||||
if (ReferenceEquals(t1, t2))
|
||||
return (true);
|
||||
|
||||
// If one is null, but not both, return false.
|
||||
|
||||
if (((object)t1 == null) || ((object)t2 == null))
|
||||
return (false);
|
||||
|
||||
return (t1._Left == t2._Left && t1._Right == t2._Right &&
|
||||
t1._Top == t2._Top && t1._Bottom == t2._Bottom);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "!=" operator
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances.
|
||||
/// </summary>
|
||||
/// <param name="t1">Instance 1</param>
|
||||
/// <param name="t2">Instance 2</param>
|
||||
/// <returns>true if different.</returns>
|
||||
public static bool operator !=(BorderColor t1, BorderColor t2)
|
||||
{
|
||||
return ((t1 == t2) == false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetHashCode
|
||||
|
||||
/// <summary>
|
||||
/// Returns hash-code for object.
|
||||
/// </summary>
|
||||
/// <returns>Hash-code value.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((_Left.GetHashCode() ^ _Top.GetHashCode()) ^
|
||||
_Right.GetHashCode()) ^ _Bottom.GetHashCode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Equals
|
||||
|
||||
/// <summary>
|
||||
/// Compares object to this instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to compare.</param>
|
||||
/// <returns>true if same.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is BorderColor)
|
||||
return ((BorderColor) obj == this);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares object to this instance.
|
||||
/// </summary>
|
||||
/// <param name="borderColor">Border color</param>
|
||||
/// <returns>true if same</returns>
|
||||
public bool Equals(BorderColor borderColor)
|
||||
{
|
||||
return (this == borderColor);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the BorderColor.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the BorderColor.</returns>
|
||||
public BorderColor Copy()
|
||||
{
|
||||
BorderColor copy = new BorderColor(_Left, _Top, _Right, _Bottom);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "BorderColor";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (IsUniform == true)
|
||||
{
|
||||
sec.AddValue("All", Left, Color.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
sec.AddValue("Left", Left, Color.Empty);
|
||||
sec.AddValue("Top", Top, Color.Empty);
|
||||
sec.AddValue("Right", Right, Color.Empty);
|
||||
sec.AddValue("Bottom", Bottom, Color.Empty);
|
||||
}
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessValue
|
||||
|
||||
void IProcessSerialElement.ProcessValue(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "All":
|
||||
All = (Color)se.ColorValue;
|
||||
break;
|
||||
|
||||
case "Left":
|
||||
Left = (Color)se.ColorValue;
|
||||
break;
|
||||
|
||||
case "Top":
|
||||
Top = (Color)se.ColorValue;
|
||||
break;
|
||||
|
||||
case "Right":
|
||||
Right = (Color)se.ColorValue;
|
||||
break;
|
||||
|
||||
case "Bottom":
|
||||
Bottom = (Color)se.ColorValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown Serial Value (" + se.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
void IProcessSerialElement.ProcessCollection(SerialElement se)
|
||||
{
|
||||
throw new Exception("Unknown Serial Collection (" + se.Name + ")");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnPropertyChanged(string s)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnVisualPropertyChanged(string s)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region BorderColorConverter
|
||||
|
||||
///<summary>
|
||||
/// BorderColorConverter
|
||||
///</summary>
|
||||
public class BorderColorConverter : ExpandableObjectConverter
|
||||
{
|
||||
#region CanConvertTo
|
||||
|
||||
/// <summary>
|
||||
/// CanConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override bool CanConvertTo(
|
||||
ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return (true);
|
||||
|
||||
return (base.CanConvertTo(context, destinationType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConvertTo
|
||||
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
BorderColor bc = value as BorderColor;
|
||||
|
||||
if (bc != null)
|
||||
{
|
||||
if (bc.IsUniform == true)
|
||||
return (bc.Left.ToString());
|
||||
|
||||
return (String.Format("{0}, {1}, {2}, {3}",
|
||||
bc.Bottom, bc.Left, bc.Right, bc.Top));
|
||||
}
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CanConvertFrom
|
||||
|
||||
/// <summary>
|
||||
/// CanConvertFrom
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="sourceType"></param>
|
||||
/// <returns></returns>
|
||||
public override bool CanConvertFrom(
|
||||
ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(string))
|
||||
return (true);
|
||||
|
||||
return (base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConvertFrom
|
||||
|
||||
/// <summary>
|
||||
/// ConvertFrom
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertFrom(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
if (value is string)
|
||||
{
|
||||
string[] values = ((string)value).Split(',');
|
||||
|
||||
if (values.Length != 1 && values.Length != 4)
|
||||
throw new ArgumentException("Invalid value to convert.");
|
||||
|
||||
ColorConverter cvt = new ColorConverter();
|
||||
|
||||
try
|
||||
{
|
||||
Color[] c = new Color[values.Length];
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
c[i] = (Color)cvt.ConvertFrom(values[i]);
|
||||
|
||||
BorderColor bc = (values.Length == 1)
|
||||
? new BorderColor(c[0])
|
||||
: new BorderColor(c[1], c[3], c[2], c[0]);
|
||||
|
||||
return (bc);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new ArgumentException("Invalid value to convert.");
|
||||
}
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCreateInstanceSupported
|
||||
|
||||
/// <summary>
|
||||
/// GetCreateInstanceSupported
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateInstance
|
||||
|
||||
/// <summary>
|
||||
/// CreateInstance
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="propertyValues"></param>
|
||||
/// <returns></returns>
|
||||
public override object CreateInstance(
|
||||
ITypeDescriptorContext context, IDictionary propertyValues)
|
||||
{
|
||||
return (new BorderColor((Color)propertyValues["Left"], (Color)propertyValues["Top"],
|
||||
(Color)propertyValues["Right"], (Color)propertyValues["Bottom"]));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
using DevComponents.DotNetBar.Charts.Primitives;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines Thickness class.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class BorderPattern : IEquatable<BorderPattern>, IProcessSerialElement, INotifyPropertyChanged
|
||||
{
|
||||
#region Static data
|
||||
|
||||
/// <summary>
|
||||
/// Returns Empty instance of BorderPattern.
|
||||
/// </summary>
|
||||
public static BorderPattern Empty
|
||||
{
|
||||
get { return (new BorderPattern()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private LinePattern _Bottom = LinePattern.NotSet;
|
||||
private LinePattern _Left = LinePattern.NotSet;
|
||||
private LinePattern _Right = LinePattern.NotSet;
|
||||
private LinePattern _Top = LinePattern.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="left">Left BorderPatternStyle.</param>
|
||||
/// <param name="top">Top BorderPatternStyle.</param>
|
||||
/// <param name="right">Right BorderPatternStyle.</param>
|
||||
/// <param name="bottom">Bottom BorderPatternStyle.</param>
|
||||
public BorderPattern(LinePattern left,
|
||||
LinePattern top, LinePattern right, LinePattern bottom)
|
||||
{
|
||||
_Left = left;
|
||||
_Top = top;
|
||||
_Right = right;
|
||||
_Bottom = bottom;
|
||||
|
||||
PropertyChanged = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="all">Specifies uniform Thickness.</param>
|
||||
public BorderPattern(LinePattern all)
|
||||
: this(all, all, all, all)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Creates new instance of the object.
|
||||
///</summary>
|
||||
public BorderPattern()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region All
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thickness of all sides.
|
||||
/// </summary>
|
||||
//[Browsable(false)]
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public LinePattern All
|
||||
{
|
||||
set { _Top = _Left = _Bottom = _Right = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bottom
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bottom Border Pattern
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the bottom Border Pattern")]
|
||||
public LinePattern Bottom
|
||||
{
|
||||
get { return (_Bottom); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Bottom != value)
|
||||
{
|
||||
_Bottom = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Bottom"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Left
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left Border Pattern
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the left Border Pattern")]
|
||||
public LinePattern Left
|
||||
{
|
||||
get { return (_Left); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Left != value)
|
||||
{
|
||||
_Left = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Left"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Right
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Right Border Pattern
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the Right Border Pattern")]
|
||||
public LinePattern Right
|
||||
{
|
||||
get { return (_Right); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Right != value)
|
||||
{
|
||||
_Right = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Right"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Top
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Top Border Pattern
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the Top Border Pattern")]
|
||||
public LinePattern Top
|
||||
{
|
||||
get { return (_Top); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Top != value)
|
||||
{
|
||||
_Top = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Top"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the item is empty
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left == LinePattern.NotSet &&
|
||||
_Right == LinePattern.NotSet &&
|
||||
_Top == LinePattern.NotSet &&
|
||||
_Bottom == LinePattern.NotSet);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsUniform
|
||||
|
||||
internal bool IsUniform
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left == _Top &&
|
||||
_Left == _Right && _Left == _Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Equals
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether two instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">Instance to compare to.</param>
|
||||
/// <returns>true if equal otherwise false.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is BorderPattern)
|
||||
return (this == (BorderPattern)obj);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether two instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="borderPattern">Instance to compare to</param>
|
||||
/// <returns>true if equal otherwise false</returns>
|
||||
public bool Equals(BorderPattern borderPattern)
|
||||
{
|
||||
return (this == borderPattern);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetHashCode
|
||||
|
||||
/// <summary>
|
||||
/// Returns hash-code.
|
||||
/// </summary>
|
||||
/// <returns>hash-code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((_Left.GetHashCode() ^ _Top.GetHashCode()) ^
|
||||
_Right.GetHashCode()) ^ _Bottom.GetHashCode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
#region "==" operator
|
||||
|
||||
/// <summary>
|
||||
/// Implements == operator.
|
||||
/// </summary>
|
||||
/// <param name="t1">Object 1</param>
|
||||
/// <param name="t2">Object 2</param>
|
||||
/// <returns>true if equals</returns>
|
||||
public static bool operator ==(BorderPattern t1, BorderPattern t2)
|
||||
{
|
||||
if (ReferenceEquals(t1, t2))
|
||||
return (true);
|
||||
|
||||
if (((object)t1 == null) || ((object)t2 == null))
|
||||
return (false);
|
||||
|
||||
return (t1._Left == t2._Left && t1._Right == t2._Right &&
|
||||
t1._Top == t2._Top && t1._Bottom == t2._Bottom);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "!=" operator
|
||||
|
||||
/// <summary>
|
||||
/// Implements != operator
|
||||
/// </summary>
|
||||
/// <param name="t1">Object 1</param>
|
||||
/// <param name="t2">Object 2</param>
|
||||
/// <returns>true if different</returns>
|
||||
public static bool operator !=(BorderPattern t1, BorderPattern t2)
|
||||
{
|
||||
return ((t1 == t2) == false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyPattern
|
||||
|
||||
/// <summary>
|
||||
/// Applies the pattern to instance of this pattern.
|
||||
/// </summary>
|
||||
/// <param name="pattern">Pattern to apply.</param>
|
||||
public void ApplyPattern(BorderPattern pattern)
|
||||
{
|
||||
if (pattern != null)
|
||||
{
|
||||
if (pattern.Top != LinePattern.NotSet)
|
||||
_Top = pattern.Top;
|
||||
|
||||
if (pattern.Left != LinePattern.NotSet)
|
||||
_Left = pattern.Left;
|
||||
|
||||
if (pattern.Bottom != LinePattern.NotSet)
|
||||
_Bottom = pattern.Bottom;
|
||||
|
||||
if (pattern.Right != LinePattern.NotSet)
|
||||
_Right = pattern.Right;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the BorderPattern.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the BorderPattern.</returns>
|
||||
public BorderPattern Copy()
|
||||
{
|
||||
BorderPattern copy = new BorderPattern(_Left, _Top, _Right, _Bottom);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "BorderPattern";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (IsUniform == true)
|
||||
{
|
||||
sec.AddValue("All", Left, LinePattern.NotSet);
|
||||
}
|
||||
else
|
||||
{
|
||||
sec.AddValue("Left", Left, LinePattern.NotSet);
|
||||
sec.AddValue("Top", Top, LinePattern.NotSet);
|
||||
sec.AddValue("Right", Right, LinePattern.NotSet);
|
||||
sec.AddValue("Bottom", Bottom, LinePattern.NotSet);
|
||||
}
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessValue
|
||||
|
||||
void IProcessSerialElement.ProcessValue(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "All":
|
||||
All = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
case "Left":
|
||||
Left = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
case "Top":
|
||||
Top = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
case "Right":
|
||||
Right = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
case "Bottom":
|
||||
Bottom = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown Serial Value (" + se.Name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
void IProcessSerialElement.ProcessCollection(SerialElement se)
|
||||
{
|
||||
throw new Exception("Unknown Serial Collection (" + se.Name + ")");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
void OnPropertyChanged(VisualPropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region LinePattern
|
||||
|
||||
///<summary>
|
||||
/// LinePattern
|
||||
///</summary>
|
||||
public enum LinePattern
|
||||
{
|
||||
///<summary>
|
||||
/// None
|
||||
///</summary>
|
||||
None = -2,
|
||||
|
||||
///<summary>
|
||||
/// NotSet
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// Solid
|
||||
///</summary>
|
||||
Solid = DashStyle.Solid,
|
||||
|
||||
///<summary>
|
||||
/// Dash
|
||||
///</summary>
|
||||
Dash = DashStyle.Dash,
|
||||
|
||||
///<summary>
|
||||
/// Dot
|
||||
///</summary>
|
||||
Dot = DashStyle.Dot,
|
||||
|
||||
///<summary>
|
||||
/// DashDot
|
||||
///</summary>
|
||||
DashDot = DashStyle.DashDot,
|
||||
|
||||
///<summary>
|
||||
/// DashDotDot
|
||||
///</summary>
|
||||
DashDotDot = DashStyle.DashDotDot,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChartLineCap
|
||||
|
||||
///<summary>
|
||||
/// ChartLineCap
|
||||
///</summary>
|
||||
public enum ChartLineCap
|
||||
{
|
||||
///<summary>
|
||||
/// NotSet
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
Flat = 0,
|
||||
Square = 1,
|
||||
Round = 2,
|
||||
Triangle = 3,
|
||||
NoAnchor = 16,
|
||||
SquareAnchor = 17,
|
||||
RoundAnchor = 18,
|
||||
DiamondAnchor = 19,
|
||||
ArrowAnchor = 20,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
///<summary>
|
||||
/// ChartAxisVisualStyles
|
||||
///</summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartAxisVisualStyles : VisualStyles<ChartAxisVisualStyle>
|
||||
{
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public ChartAxisVisualStyles Copy()
|
||||
{
|
||||
ChartAxisVisualStyles styles = new ChartAxisVisualStyles();
|
||||
|
||||
for (int i = 0; i < Styles.Length; i++)
|
||||
{
|
||||
ChartAxisVisualStyle vstyle = Styles[i];
|
||||
|
||||
if (vstyle != null)
|
||||
styles.Styles[i] = vstyle.Copy();
|
||||
}
|
||||
|
||||
return (styles);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the visual style of a ChartAxis element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartAxisVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Color _AxisColor = Color.Empty;
|
||||
private Background _AlternateBackground;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AlternateBackground
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alternate, or interlaced, background.
|
||||
/// </summary>
|
||||
[Description("Indicates the alternate, or interlaced, background")]
|
||||
public Background AlternateBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AlternateBackground == null)
|
||||
{
|
||||
_AlternateBackground = Background.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _AlternateBackground);
|
||||
}
|
||||
|
||||
return (_AlternateBackground);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AlternateBackground != value)
|
||||
{
|
||||
UpdateChangeHandler(_AlternateBackground, value);
|
||||
|
||||
_AlternateBackground = value;
|
||||
|
||||
OnPropertyChangedEx("AlternateBackground", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeAlternateBackground()
|
||||
{
|
||||
return (_AlternateBackground != null && _AlternateBackground.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetAlternateBackground()
|
||||
{
|
||||
AlternateBackground = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AxisColor
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the Axis line Color.
|
||||
///</summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the Axis line Color.")]
|
||||
public Color AxisColor
|
||||
{
|
||||
get { return (_AxisColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _AxisColor)
|
||||
{
|
||||
_AxisColor = value;
|
||||
|
||||
OnPropertyChangedEx("AxisColor", Style.VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeAxisColor()
|
||||
{
|
||||
return (_AxisColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetAxisColor()
|
||||
{
|
||||
_AxisColor = Color.Empty;
|
||||
}
|
||||
|
||||
#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 ((_AlternateBackground == null || _AlternateBackground.IsEmpty) &&
|
||||
(_AxisColor.IsEmpty == true) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartAxisVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._AlternateBackground != null && style.AlternateBackground.IsEmpty == false)
|
||||
AlternateBackground = style.AlternateBackground.Copy();
|
||||
|
||||
if (style.AxisColor.IsEmpty == false)
|
||||
AxisColor = style.AxisColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
if (AxisColor.IsEmpty == true)
|
||||
AxisColor = Color.Black;
|
||||
|
||||
if (AlternateBackground.IsEmpty == true)
|
||||
AlternateBackground = new Background(Color.Ivory);
|
||||
|
||||
base.ApplyDefaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartAxisVisualStyle Copy()
|
||||
{
|
||||
ChartAxisVisualStyle style = new ChartAxisVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartAxisVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AlternateBackground =
|
||||
(_AlternateBackground != null) ? _AlternateBackground.Copy() : null;
|
||||
|
||||
style.AxisColor = _AxisColor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartAxisVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_AlternateBackground != null && _AlternateBackground.IsEmpty == false)
|
||||
sec.AddElement(_AlternateBackground.GetSerialData("AlternateBackground"));
|
||||
|
||||
sec.AddValue("AxisColor", AxisColor, Color.Empty);
|
||||
|
||||
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 "AxisColor":
|
||||
AxisColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "AlternateBackground":
|
||||
sec.PutSerialData(AlternateBackground);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
AlternateBackground = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Bar Series
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartBarVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ChartLineVisualStyle _Border;
|
||||
private ChartLineVisualStyle _AlternateBorder;
|
||||
|
||||
private Background _Background;
|
||||
private Background _AlternateBackground;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AlternateBackground
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background for the bar, when it
|
||||
/// extends to the alternate side of the bar origin.
|
||||
/// </summary>
|
||||
[Description("Indicates the background for the bar, when it extends to the alternate side of the bar origin.")]
|
||||
public Background AlternateBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AlternateBackground == null)
|
||||
{
|
||||
_AlternateBackground = Background.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _AlternateBackground);
|
||||
}
|
||||
|
||||
return (_AlternateBackground);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AlternateBackground != value)
|
||||
{
|
||||
UpdateChangeHandler(_AlternateBackground, value);
|
||||
|
||||
_AlternateBackground = value;
|
||||
|
||||
OnPropertyChangedEx("AlternateBackground", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeAlternateBackground()
|
||||
{
|
||||
return (_AlternateBackground != null && _AlternateBackground.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetAlternateBackground()
|
||||
{
|
||||
AlternateBackground = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AlternateBorder
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the border style for the bar, when it
|
||||
/// extends to the alternate side of the bar origin.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the border style for the bar, when it extends to the alternate side of the bar origin.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle AlternateBorder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AlternateBorder == null)
|
||||
{
|
||||
_AlternateBorder = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _AlternateBorder);
|
||||
}
|
||||
|
||||
return (_AlternateBorder);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AlternateBorder != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _AlternateBorder;
|
||||
|
||||
_AlternateBorder = value;
|
||||
|
||||
OnStyleChanged("AlternateBorder", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Background
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background for the bar.
|
||||
/// </summary>
|
||||
[Description("Indicates the background for the bar.")]
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBackground()
|
||||
{
|
||||
return (_Background != null && _Background.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBackground()
|
||||
{
|
||||
Background = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Border
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the border style for the bar.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the border style for the bar.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle Border
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Border == null)
|
||||
{
|
||||
_Border = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _Border);
|
||||
}
|
||||
|
||||
return (_Border);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_Border != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _Border;
|
||||
|
||||
_Border = value;
|
||||
|
||||
OnStyleChanged("Border", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_AlternateBackground == null || _AlternateBackground.IsEmpty == true) &&
|
||||
(_AlternateBorder == null || _AlternateBorder.IsEmpty) &&
|
||||
(_Background == null || _Background.IsEmpty) &&
|
||||
(_Border == null || _Border.IsEmpty) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartBarVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._AlternateBackground != null && style._AlternateBackground.IsEmpty == false)
|
||||
AlternateBackground = style._AlternateBackground.Copy();
|
||||
|
||||
if (style._AlternateBorder != null && style._AlternateBorder.IsEmpty == false)
|
||||
AlternateBorder.ApplyStyle(style._AlternateBorder);
|
||||
|
||||
if (style._Background != null && style._Background.IsEmpty == false)
|
||||
Background = style._Background.Copy();
|
||||
|
||||
if (style._Border != null && style._Border.IsEmpty == false)
|
||||
Border.ApplyStyle(style._Border);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartBarVisualStyle Copy()
|
||||
{
|
||||
ChartBarVisualStyle style = new ChartBarVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartBarVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AlternateBackground = (_AlternateBackground != null) ? _AlternateBackground.Copy() : null;
|
||||
style.AlternateBorder = (_AlternateBorder != null) ? _AlternateBorder.Copy() : null;
|
||||
style.Background = (_Background != null) ? _Background.Copy() : null;
|
||||
style.Border = (_Border != null) ? _Border.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartBarVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_AlternateBackground != null && _AlternateBackground.IsEmpty == false)
|
||||
sec.AddElement(_AlternateBackground.GetSerialData("AlternateBackground"));
|
||||
|
||||
if (_AlternateBorder != null && _AlternateBorder.IsEmpty == false)
|
||||
sec.AddElement(_AlternateBorder.GetSerialData("AlternateBorder"));
|
||||
|
||||
if (_Background != null && _Background.IsEmpty == false)
|
||||
sec.AddElement(_Background.GetSerialData("Background"));
|
||||
|
||||
if (_Border != null && _Border.IsEmpty == false)
|
||||
sec.AddElement(_Border.GetSerialData("Border"));
|
||||
|
||||
sec.AddElement(base.GetSerialData(null));
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "AlternateBackground":
|
||||
sec.PutSerialData(AlternateBackground);
|
||||
break;
|
||||
|
||||
case "AlternateBorder":
|
||||
sec.PutSerialData(AlternateBorder);
|
||||
break;
|
||||
|
||||
case "Background":
|
||||
sec.PutSerialData(Background);
|
||||
break;
|
||||
|
||||
case "Border":
|
||||
sec.PutSerialData(Border);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
AlternateBackground = null;
|
||||
Background = null;
|
||||
Border = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of an Hilo Bar Series (OHLC)
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartHiLoBarVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private HiLoBarSegmentStyle _DefaultSegmentStyle;
|
||||
private HiLoBarSegmentStyle _AlternateSegmentStyle;
|
||||
|
||||
private Tbool _ShowWhiskerCaps = Tbool.NotSet;
|
||||
private Tbool _UseAlternateSegmentStyle = Tbool.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AlternateSegmentStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Alternate Style for the Ohlc bar.
|
||||
/// </summary>
|
||||
[Description("Indicates the Alternate Style for the Ohlc bar.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public HiLoBarSegmentStyle AlternateSegmentStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AlternateSegmentStyle == null)
|
||||
{
|
||||
_AlternateSegmentStyle = HiLoBarSegmentStyle.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _AlternateSegmentStyle);
|
||||
}
|
||||
|
||||
return (_AlternateSegmentStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AlternateSegmentStyle != value)
|
||||
{
|
||||
UpdateChangeHandler(_AlternateSegmentStyle, value);
|
||||
|
||||
_AlternateSegmentStyle = value;
|
||||
|
||||
OnPropertyChangedEx("AlternateSegmentStyle", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DefaultSegmentStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Default Style for the Ohlc bar.
|
||||
/// </summary>
|
||||
[Description("Indicates the Default Style for the Ohlc bar.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public HiLoBarSegmentStyle DefaultSegmentStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DefaultSegmentStyle == null)
|
||||
{
|
||||
_DefaultSegmentStyle = HiLoBarSegmentStyle.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _DefaultSegmentStyle);
|
||||
}
|
||||
|
||||
return (_DefaultSegmentStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_DefaultSegmentStyle != value)
|
||||
{
|
||||
UpdateChangeHandler(_DefaultSegmentStyle, value);
|
||||
|
||||
_DefaultSegmentStyle = value;
|
||||
|
||||
OnPropertyChangedEx("DefaultSegmentStyle", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowWhiskerCaps
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Box/Candle whisker caps are displayed.
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether Box/Candle whisker caps are displayed.")]
|
||||
public Tbool ShowWhiskerCaps
|
||||
{
|
||||
get { return (_ShowWhiskerCaps); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _ShowWhiskerCaps)
|
||||
{
|
||||
_ShowWhiskerCaps = value;
|
||||
|
||||
OnPropertyChangedEx("ShowWhiskerCaps", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UseAlternateSegmentStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Box/Candle whisker caps are displayed.
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether Box/Candle whisker caps are displayed.")]
|
||||
public Tbool UseAlternateSegmentStyle
|
||||
{
|
||||
get { return (_UseAlternateSegmentStyle); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _UseAlternateSegmentStyle)
|
||||
{
|
||||
_UseAlternateSegmentStyle = value;
|
||||
|
||||
OnPropertyChangedEx("UseAlternateSegmentStyle", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_AlternateSegmentStyle == null || _AlternateSegmentStyle.IsEmpty == true) &&
|
||||
(_DefaultSegmentStyle == null || _DefaultSegmentStyle.IsEmpty) &&
|
||||
(_ShowWhiskerCaps == Tbool.NotSet));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartHiLoBarVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._AlternateSegmentStyle != null && style._AlternateSegmentStyle.IsEmpty == false)
|
||||
AlternateSegmentStyle.ApplyStyle(style._AlternateSegmentStyle);
|
||||
|
||||
if (style._DefaultSegmentStyle != null && style._DefaultSegmentStyle.IsEmpty == false)
|
||||
DefaultSegmentStyle.ApplyStyle(style._DefaultSegmentStyle);
|
||||
|
||||
if (style.ShowWhiskerCaps != Tbool.NotSet)
|
||||
ShowWhiskerCaps = style.ShowWhiskerCaps;
|
||||
|
||||
if (style.UseAlternateSegmentStyle != Tbool.NotSet)
|
||||
UseAlternateSegmentStyle = style.UseAlternateSegmentStyle;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartHiLoBarVisualStyle Copy()
|
||||
{
|
||||
ChartHiLoBarVisualStyle style = new ChartHiLoBarVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartHiLoBarVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AlternateSegmentStyle = (_AlternateSegmentStyle != null) ? _AlternateSegmentStyle.Copy() : null;
|
||||
style.DefaultSegmentStyle = (_DefaultSegmentStyle != null) ? _DefaultSegmentStyle.Copy() : null;
|
||||
|
||||
style.ShowWhiskerCaps = _ShowWhiskerCaps;
|
||||
style.UseAlternateSegmentStyle = _UseAlternateSegmentStyle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartHiLoBarVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_DefaultSegmentStyle != null && _DefaultSegmentStyle.IsEmpty == false)
|
||||
sec.AddElement(_DefaultSegmentStyle.GetSerialData("DefaultSegmentStyle"));
|
||||
|
||||
if (_AlternateSegmentStyle != null && _AlternateSegmentStyle.IsEmpty == false)
|
||||
sec.AddElement(_AlternateSegmentStyle.GetSerialData("AlternateSegmentStyle"));
|
||||
|
||||
sec.AddValue("ShowWhiskerCaps", ShowWhiskerCaps, Tbool.NotSet);
|
||||
sec.AddValue("UseAlternateSegmentStyle", UseAlternateSegmentStyle, 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 "ShowWhiskerCaps":
|
||||
ShowWhiskerCaps = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
case "UseAlternateSegmentStyle":
|
||||
UseAlternateSegmentStyle = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "DefaultSegmentStyle":
|
||||
sec.PutSerialData(DefaultSegmentStyle);
|
||||
break;
|
||||
|
||||
case "AlternateSegmentStyle":
|
||||
sec.PutSerialData(AlternateSegmentStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
AlternateSegmentStyle = null;
|
||||
DefaultSegmentStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,847 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
///<summary>
|
||||
/// ChartLegendVisualStyles
|
||||
///</summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartLegendItemVisualStyles : VisualStyles<ChartLegendItemVisualStyle>
|
||||
{
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public ChartLegendItemVisualStyles Copy()
|
||||
{
|
||||
ChartLegendItemVisualStyles styles = new ChartLegendItemVisualStyles();
|
||||
|
||||
for (int i = 0; i < Styles.Length; i++)
|
||||
{
|
||||
ChartLegendItemVisualStyle vstyle = Styles[i];
|
||||
|
||||
if (vstyle != null)
|
||||
styles.Styles[i] = vstyle.Copy();
|
||||
}
|
||||
|
||||
return (styles);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Legend item element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartLegendItemVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Background _Background;
|
||||
private Color _TextColor = Color.Empty;
|
||||
private Font _Font;
|
||||
|
||||
private Tbool _AllowWrap = Tbool.NotSet;
|
||||
private Alignment _Alignment = Alignment.NotSet;
|
||||
private int _MaxLineCount;
|
||||
|
||||
private Background _CheckBoxBackground;
|
||||
private Color _CheckBoxBorderColor = Color.Empty;
|
||||
private Color _CheckBoxCheckColor = Color.Empty;
|
||||
|
||||
private PointMarkerVisualStyle _MarkerVisualStyle;
|
||||
|
||||
private Background _DisabledMarkerBackground;
|
||||
private Color _DisabledTextColor = Color.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Alignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the text
|
||||
/// </summary>
|
||||
[DefaultValue(Alignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the alignment of the text.")]
|
||||
public Alignment Alignment
|
||||
{
|
||||
get { return (_Alignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Alignment != value)
|
||||
{
|
||||
_Alignment = value;
|
||||
|
||||
OnPropertyChangedEx("Alignment", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#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 Background
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style background.
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBackground()
|
||||
{
|
||||
return (_Background != null && _Background.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBackground()
|
||||
{
|
||||
Background = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckBoxBackground
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CheckBox background.
|
||||
/// </summary>
|
||||
[Description("Indicates the CheckBox background")]
|
||||
public Background CheckBoxBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CheckBoxBackground == null)
|
||||
{
|
||||
_CheckBoxBackground = Background.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _CheckBoxBackground);
|
||||
}
|
||||
|
||||
return (_CheckBoxBackground);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_CheckBoxBackground != value)
|
||||
{
|
||||
UpdateChangeHandler(_CheckBoxBackground, value);
|
||||
|
||||
_CheckBoxBackground = value;
|
||||
|
||||
OnPropertyChangedEx("CheckBoxBackground", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeCheckBoxBackground()
|
||||
{
|
||||
return (_CheckBoxBackground != null && _CheckBoxBackground.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetCheckBoxBackground()
|
||||
{
|
||||
CheckBoxBackground = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckBoxBorderColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CheckBox border color.
|
||||
/// </summary>
|
||||
[Description("Indicates the CheckBox border color")]
|
||||
public Color CheckBoxBorderColor
|
||||
{
|
||||
get { return (_CheckBoxBorderColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_CheckBoxBorderColor != value)
|
||||
{
|
||||
_CheckBoxBorderColor = value;
|
||||
|
||||
OnPropertyChangedEx("CheckBoxBorderColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeCheckBoxBorderColor()
|
||||
{
|
||||
return (_CheckBoxBorderColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetCheckBoxBorderColor()
|
||||
{
|
||||
CheckBoxBorderColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckBoxCheckColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CheckBox check color.
|
||||
/// </summary>
|
||||
[Description("Indicates the CheckBox check color")]
|
||||
public Color CheckBoxCheckColor
|
||||
{
|
||||
get { return (_CheckBoxCheckColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_CheckBoxCheckColor != value)
|
||||
{
|
||||
_CheckBoxCheckColor = value;
|
||||
|
||||
OnPropertyChangedEx("CheckBoxCheckColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeCheckBoxCheckColor()
|
||||
{
|
||||
return (_CheckBoxCheckColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetCheckBoxCheckColor()
|
||||
{
|
||||
CheckBoxCheckColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DisabledMarkerBackground
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Disabled Marker Background style.
|
||||
/// </summary>
|
||||
[Description("Indicates the Disabled Marker Background style")]
|
||||
public Background DisabledMarkerBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DisabledMarkerBackground == null)
|
||||
{
|
||||
_DisabledMarkerBackground = Background.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _DisabledMarkerBackground);
|
||||
}
|
||||
|
||||
return (_DisabledMarkerBackground);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_DisabledMarkerBackground != value)
|
||||
{
|
||||
UpdateChangeHandler(_DisabledMarkerBackground, value);
|
||||
|
||||
_DisabledMarkerBackground = value;
|
||||
|
||||
OnPropertyChangedEx("DisabledMarkerBackground", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeDisabledMarkerBackground()
|
||||
{
|
||||
return (_DisabledMarkerBackground != null && _DisabledMarkerBackground.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetDisabledMarkerBackground()
|
||||
{
|
||||
DisabledMarkerBackground = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DisabledTextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Disabled TextColor
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates whether the items in the Legend are equally spaced.")]
|
||||
public Color DisabledTextColor
|
||||
{
|
||||
get { return (_DisabledTextColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _DisabledTextColor)
|
||||
{
|
||||
_DisabledTextColor = value;
|
||||
|
||||
OnPropertyChangedEx("DisabledTextColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeDisabledTextColor()
|
||||
{
|
||||
return (_DisabledTextColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetDisabledTextColor()
|
||||
{
|
||||
DisabledTextColor = Color.Empty;
|
||||
}
|
||||
|
||||
#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 MarkerVisualStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles for the Legend Marker.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual styles for the PointMarker.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public PointMarkerVisualStyle MarkerVisualStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MarkerVisualStyle == null)
|
||||
{
|
||||
_MarkerVisualStyle = new PointMarkerVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _MarkerVisualStyle);
|
||||
}
|
||||
|
||||
return (_MarkerVisualStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_MarkerVisualStyle != value)
|
||||
{
|
||||
PointMarkerVisualStyle oldValue = _MarkerVisualStyle;
|
||||
|
||||
_MarkerVisualStyle = value;
|
||||
|
||||
OnStyleChanged("MarkerVisualStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MaxLineCount
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of lines for the item text.
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the maximum number of lines for the item text.")]
|
||||
[DefaultValue(0)]
|
||||
public int MaxLineCount
|
||||
{
|
||||
get { return (_MaxLineCount); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MaxLineCount)
|
||||
{
|
||||
_MaxLineCount = value;
|
||||
|
||||
OnPropertyChangedEx("MaxLineCount", 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 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 ((_Alignment == Alignment.NotSet) &&
|
||||
(_AllowWrap == Tbool.NotSet) &&
|
||||
(_Background == null || _Background.IsEmpty == true) &&
|
||||
(_CheckBoxBackground == null || _CheckBoxBackground.IsEmpty == true) &&
|
||||
(_CheckBoxBorderColor.IsEmpty == true) &&
|
||||
(_CheckBoxCheckColor.IsEmpty == true) &&
|
||||
(_DisabledMarkerBackground == null || _DisabledMarkerBackground.IsEmpty == true) &&
|
||||
(_DisabledTextColor.IsEmpty == true) &&
|
||||
(_Font == null) &&
|
||||
(_MarkerVisualStyle == null || _MarkerVisualStyle.IsEmpty) &&
|
||||
(_MaxLineCount == 0) &&
|
||||
(_TextColor.IsEmpty == true) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetStringFormatFlags
|
||||
|
||||
internal void GetStringFormatFlags(StringFormat sf)
|
||||
{
|
||||
if (_AllowWrap == Tbool.False || _MaxLineCount <= 1)
|
||||
sf.FormatFlags |= StringFormatFlags.NoWrap;
|
||||
|
||||
sf.Trimming = StringTrimming.EllipsisCharacter;
|
||||
|
||||
switch (Alignment)
|
||||
{
|
||||
case Alignment.TopCenter:
|
||||
sf.LineAlignment = StringAlignment.Near;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
break;
|
||||
|
||||
case Alignment.TopRight:
|
||||
sf.LineAlignment = StringAlignment.Near;
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
break;
|
||||
|
||||
case Alignment.NotSet:
|
||||
case Alignment.MiddleLeft:
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Near;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleCenter:
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleRight:
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
break;
|
||||
|
||||
case Alignment.BottomLeft:
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
sf.Alignment = StringAlignment.Near;
|
||||
break;
|
||||
|
||||
case Alignment.BottomCenter:
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
break;
|
||||
|
||||
case Alignment.BottomRight:
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartLegendItemVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
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._CheckBoxBackground != null && style._CheckBoxBackground.IsEmpty == false)
|
||||
CheckBoxBackground = style._CheckBoxBackground.Copy();
|
||||
|
||||
if (style._CheckBoxBorderColor.IsEmpty == false)
|
||||
CheckBoxBorderColor = style._CheckBoxBorderColor;
|
||||
|
||||
if (style._CheckBoxCheckColor.IsEmpty == false)
|
||||
CheckBoxCheckColor = style._CheckBoxCheckColor;
|
||||
|
||||
if (style._DisabledMarkerBackground != null && style._DisabledMarkerBackground.IsEmpty == false)
|
||||
DisabledMarkerBackground = style.DisabledMarkerBackground.Copy();
|
||||
|
||||
if (style.DisabledTextColor.IsEmpty == false)
|
||||
DisabledTextColor = style.DisabledTextColor;
|
||||
|
||||
if (style.Font != null)
|
||||
Font = style.Font;
|
||||
|
||||
if (style._MarkerVisualStyle != null && style.MarkerVisualStyle.IsEmpty == false)
|
||||
MarkerVisualStyle.ApplyStyle(style.MarkerVisualStyle);
|
||||
|
||||
if (style.MaxLineCount != 0)
|
||||
MaxLineCount = style.MaxLineCount;
|
||||
|
||||
if (style._TextColor.IsEmpty == false)
|
||||
TextColor = style._TextColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartLegendItemVisualStyle Copy()
|
||||
{
|
||||
ChartLegendItemVisualStyle style = new ChartLegendItemVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartLegendItemVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.Alignment = _Alignment;
|
||||
style.AllowWrap = _AllowWrap;
|
||||
|
||||
style.Background = (_Background != null) ? _Background.Copy() : null;
|
||||
|
||||
style.CheckBoxBackground = (_CheckBoxBackground != null) ? _CheckBoxBackground.Copy() : null;
|
||||
style.CheckBoxBorderColor = _CheckBoxBorderColor;
|
||||
style.CheckBoxCheckColor = _CheckBoxCheckColor;
|
||||
|
||||
style.DisabledMarkerBackground = (_DisabledMarkerBackground != null ? _DisabledMarkerBackground.Copy() : null);
|
||||
style.DisabledTextColor = _DisabledTextColor;
|
||||
|
||||
style.Font = (_Font != null) ? (Font)_Font.Clone() : null;
|
||||
style.MarkerVisualStyle = (_MarkerVisualStyle != null) ? _MarkerVisualStyle.Copy() : null;
|
||||
|
||||
style.MaxLineCount = _MaxLineCount;
|
||||
style.TextColor = _TextColor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartLegendItemVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("Alignment", _Alignment, Alignment.NotSet);
|
||||
sec.AddValue("AllowWrap", _AllowWrap, Tbool.NotSet);
|
||||
|
||||
if (_Background != null && _Background.IsEmpty == false)
|
||||
sec.AddElement(_Background.GetSerialData("Background"));
|
||||
|
||||
if (_CheckBoxBackground != null && _CheckBoxBackground.IsEmpty == false)
|
||||
sec.AddElement(_CheckBoxBackground.GetSerialData("CheckBoxBackground"));
|
||||
|
||||
sec.AddValue("CheckBoxBorderColor", _CheckBoxBorderColor, Color.Empty);
|
||||
sec.AddValue("CheckBoxCheckColor", _CheckBoxCheckColor, Color.Empty);
|
||||
|
||||
if (_Font != null)
|
||||
sec.AddValue("Font", XmlSerializableFont.ConvertToString(Font));
|
||||
|
||||
if (_MarkerVisualStyle != null && _MarkerVisualStyle.IsEmpty == false)
|
||||
sec.AddElement(_MarkerVisualStyle.GetSerialData("MarkerVisualStyle"));
|
||||
|
||||
sec.AddValue("MaxLineCount", _MaxLineCount, 0);
|
||||
sec.AddValue("TextColor", _TextColor, Color.Empty);
|
||||
|
||||
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 "Alignment":
|
||||
Alignment = (Alignment)se.GetValueEnum(typeof(Alignment));
|
||||
break;
|
||||
|
||||
case "AllowWrap":
|
||||
AllowWrap = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
case "CheckBoxBorderColor":
|
||||
CheckBoxBorderColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "CheckBoxCheckColor":
|
||||
CheckBoxCheckColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "Font":
|
||||
Font = XmlSerializableFont.ConvertFromString(se.StringValue);
|
||||
break;
|
||||
|
||||
case "MaxLineCount":
|
||||
MaxLineCount = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "TextColor":
|
||||
TextColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Background":
|
||||
sec.PutSerialData(Background);
|
||||
break;
|
||||
|
||||
case "CheckBoxBackground":
|
||||
sec.PutSerialData(CheckBoxBackground);
|
||||
break;
|
||||
|
||||
case "MarkerVisualStyle":
|
||||
sec.PutSerialData(MarkerVisualStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Background = null;
|
||||
CheckBoxBackground = null;
|
||||
MarkerVisualStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
///<summary>
|
||||
/// ChartLegendVisualStyles
|
||||
///</summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartLegendVisualStyles : VisualStyles<ChartLegendVisualStyle>
|
||||
{
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public ChartLegendVisualStyles Copy()
|
||||
{
|
||||
ChartLegendVisualStyles styles = new ChartLegendVisualStyles();
|
||||
|
||||
for (int i = 0; i < Styles.Length; i++)
|
||||
{
|
||||
ChartLegendVisualStyle vstyle = Styles[i];
|
||||
|
||||
if (vstyle != null)
|
||||
styles.Styles[i] = vstyle.Copy();
|
||||
}
|
||||
|
||||
return (styles);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Legend element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class ChartLegendVisualStyle : ContainerVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Tbool _EquallySpacedItems = Tbool.NotSet;
|
||||
|
||||
private int _HorizontalSpacing = -1;
|
||||
private int _VerticalSpacing = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region EquallySpacedItems
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the items in the Legend are equally spaced.
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether the items in the Legend are equally spaced.")]
|
||||
public Tbool EquallySpacedItems
|
||||
{
|
||||
get { return (_EquallySpacedItems); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _EquallySpacedItems)
|
||||
{
|
||||
_EquallySpacedItems = value;
|
||||
|
||||
OnPropertyChangedEx("EquallySpacedItems", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HorizontalSpacing
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the horizontal spacing of the legend items.
|
||||
/// </summary>
|
||||
[DefaultValue(-1), Category("Appearance")]
|
||||
[Description("Indicates the horizontal spacing of the legend items.")]
|
||||
public int HorizontalSpacing
|
||||
{
|
||||
get { return (_HorizontalSpacing); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _HorizontalSpacing)
|
||||
{
|
||||
_HorizontalSpacing = value;
|
||||
|
||||
OnPropertyChangedEx("HorizontalSpacing", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VerticalSpacing
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertical spacing of the legend items.
|
||||
/// </summary>
|
||||
[DefaultValue(-1), Category("Appearance")]
|
||||
[Description("Indicates the vertical spacing of the legend items.")]
|
||||
public int VerticalSpacing
|
||||
{
|
||||
get { return (_VerticalSpacing); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _VerticalSpacing)
|
||||
{
|
||||
_VerticalSpacing = value;
|
||||
|
||||
OnPropertyChangedEx("VerticalSpacing", 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 ((_EquallySpacedItems == Tbool.NotSet) &&
|
||||
(_HorizontalSpacing == -1) &&
|
||||
(_VerticalSpacing == -1) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hidden properties
|
||||
|
||||
#region Alignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the text
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Alignment Alignment
|
||||
{
|
||||
get { return (base.Alignment); }
|
||||
set { base.Alignment = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AllowWrap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether text wrapping is permitted
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Tbool AllowWrap
|
||||
{
|
||||
get { return (base.AllowWrap); }
|
||||
set { base.AllowWrap = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style Font
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Font Font
|
||||
{
|
||||
get { return (base.Font); }
|
||||
set { base.Font = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Text color
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Color TextColor
|
||||
{
|
||||
get { return (base.TextColor); }
|
||||
set { base.TextColor = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartLegendVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.EquallySpacedItems != Tbool.NotSet)
|
||||
EquallySpacedItems = style.EquallySpacedItems;
|
||||
|
||||
if (style.HorizontalSpacing != -1)
|
||||
HorizontalSpacing = style.HorizontalSpacing;
|
||||
|
||||
if (style.VerticalSpacing != -1)
|
||||
VerticalSpacing = style.VerticalSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
base.ApplyDefaults();
|
||||
|
||||
if (VerticalSpacing < 0)
|
||||
VerticalSpacing = 2;
|
||||
|
||||
if (HorizontalSpacing < 0)
|
||||
HorizontalSpacing = 2;
|
||||
|
||||
if (BorderPattern == null)
|
||||
BorderPattern = new BorderPattern(LinePattern.Solid);
|
||||
|
||||
if (DropShadow.Enabled == Tbool.NotSet)
|
||||
DropShadow.Enabled = Tbool.False;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartLegendVisualStyle Copy()
|
||||
{
|
||||
ChartLegendVisualStyle style = new ChartLegendVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartLegendVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.HorizontalSpacing = _HorizontalSpacing;
|
||||
style.EquallySpacedItems = _EquallySpacedItems;
|
||||
|
||||
style.VerticalSpacing = _VerticalSpacing;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartLegendVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("HorizontalSpacing", HorizontalSpacing, -1);
|
||||
sec.AddValue("EquallySpacedItems", EquallySpacedItems, Tbool.NotSet);
|
||||
sec.AddValue("VerticalSpacing", VerticalSpacing, -1);
|
||||
|
||||
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 "HorizontalSpacing":
|
||||
HorizontalSpacing = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "EquallySpacedItems":
|
||||
EquallySpacedItems = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
case "VerticalSpacing":
|
||||
VerticalSpacing = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Chart Line
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class ChartLineVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Color _LineColor = Color.Empty;
|
||||
private LinePattern _LinePattern = LinePattern.NotSet;
|
||||
private int _LineWidth = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region LineColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Line color.
|
||||
/// </summary>
|
||||
[Description("Indicates the Line color.")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return (_LineColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_LineColor != value)
|
||||
{
|
||||
_LineColor = value;
|
||||
|
||||
OnPropertyChangedEx("LineColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeLineColor()
|
||||
{
|
||||
return (_LineColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetLineColor()
|
||||
{
|
||||
LineColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LinePattern
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the LinePattern.
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the LinePattern.")]
|
||||
public LinePattern LinePattern
|
||||
{
|
||||
get { return (_LinePattern); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_LinePattern != value)
|
||||
{
|
||||
_LinePattern = value;
|
||||
|
||||
OnPropertyChangedEx("LinePattern", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LineWidth
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the line width.
|
||||
/// </summary>
|
||||
[DefaultValue(-1)]
|
||||
[Description("Indicates the line width")]
|
||||
public int LineWidth
|
||||
{
|
||||
get { return (_LineWidth); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_LineWidth != value)
|
||||
{
|
||||
_LineWidth = value;
|
||||
|
||||
OnPropertyChangedEx("LineWidth", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_LineColor.IsEmpty) &&
|
||||
(_LinePattern == LinePattern.NotSet) &&
|
||||
(_LineWidth < 0) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
internal bool IsDisplayable
|
||||
{
|
||||
get
|
||||
{
|
||||
return (LineColor.IsEmpty == false &&
|
||||
LinePattern != LinePattern.None &&
|
||||
LineWidth > 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartLineVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.LineColor.IsEmpty == false)
|
||||
LineColor = style.LineColor;
|
||||
|
||||
if (style.LinePattern != LinePattern.NotSet)
|
||||
LinePattern = style.LinePattern;
|
||||
|
||||
if (style.LineWidth >= 0)
|
||||
LineWidth = style.LineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
if (LinePattern == LinePattern.NotSet)
|
||||
LinePattern = LinePattern.Solid;
|
||||
|
||||
if (LineWidth < 0)
|
||||
LineWidth = 1;
|
||||
|
||||
base.ApplyDefaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartLineVisualStyle Copy()
|
||||
{
|
||||
ChartLineVisualStyle style = new ChartLineVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartLineVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.LineColor = _LineColor;
|
||||
style.LinePattern = _LinePattern;
|
||||
style.LineWidth = _LineWidth;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartLineVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("LineColor", LineColor, Color.Empty);
|
||||
sec.AddValue("LinePattern", LinePattern, LinePattern.NotSet);
|
||||
sec.AddValue("LineWidth", LineWidth, -1);
|
||||
|
||||
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 "LineColor":
|
||||
LineColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "LinePattern":
|
||||
LinePattern = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
case "LineWidth":
|
||||
LineWidth = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Chart CapLine
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class ChartCapLineVisualStyle : ChartLineVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ChartLineCap _EndCap = ChartLineCap.NotSet;
|
||||
private ChartLineCap _StartCap = ChartLineCap.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region EndCap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the line EndCap.
|
||||
/// </summary>
|
||||
[DefaultValue(ChartLineCap.NotSet)]
|
||||
[Description("Indicates the line End Cap.")]
|
||||
public ChartLineCap EndCap
|
||||
{
|
||||
get { return (_EndCap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_EndCap != value)
|
||||
{
|
||||
_EndCap = value;
|
||||
|
||||
OnPropertyChangedEx("EndCap", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StartCap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the line StartCap.
|
||||
/// </summary>
|
||||
[DefaultValue(ChartLineCap.NotSet)]
|
||||
[Description("Indicates the line Start Cap.")]
|
||||
public ChartLineCap StartCap
|
||||
{
|
||||
get { return (_StartCap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_StartCap != value)
|
||||
{
|
||||
_StartCap = value;
|
||||
|
||||
OnPropertyChangedEx("StartCap", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_EndCap == ChartLineCap.NotSet) &&
|
||||
(_StartCap == ChartLineCap.NotSet) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartCapLineVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.EndCap != ChartLineCap.NotSet)
|
||||
_EndCap = style.EndCap;
|
||||
|
||||
if (style.StartCap != ChartLineCap.NotSet)
|
||||
_StartCap = style.StartCap;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
if (EndCap == ChartLineCap.NotSet)
|
||||
EndCap = ChartLineCap.NoAnchor;
|
||||
|
||||
if (StartCap == ChartLineCap.NotSet)
|
||||
StartCap = ChartLineCap.NoAnchor;
|
||||
|
||||
base.ApplyDefaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartCapLineVisualStyle Copy()
|
||||
{
|
||||
ChartCapLineVisualStyle style = new ChartCapLineVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartCapLineVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.EndCap = _EndCap;
|
||||
style.StartCap = _StartCap;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartCapLineVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("EndCap", EndCap, ChartLineCap.NotSet);
|
||||
sec.AddValue("StartCap", StartCap, ChartLineCap.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 "EndCap":
|
||||
EndCap = (ChartLineCap)se.GetValueEnum(typeof(ChartLineCap));
|
||||
break;
|
||||
|
||||
case "StartCap":
|
||||
StartCap = (ChartLineCap)se.GetValueEnum(typeof(ChartLineCap));
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a ChartPanel
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class ChartPanelVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private DividerLineVisualStyle _DividerLineX;
|
||||
private DividerLineVisualStyle _DividerLineY;
|
||||
|
||||
private ScrollBarVisualStyles _HScrollBarVisualStyles;
|
||||
private ScrollBarVisualStyles _VScrollBarVisualStyles;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region DividerLineX
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style of the horizontal DividerLine (when ChartMatrix.DividerLines is enabled).
|
||||
/// </summary>
|
||||
[Description("Indicates the visual style of the horizontal DividerLine (when ChartMatrix.DividerLines is enabled).")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public DividerLineVisualStyle DividerLineX
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DividerLineX == null)
|
||||
{
|
||||
_DividerLineX = new DividerLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _DividerLineX);
|
||||
}
|
||||
|
||||
return (_DividerLineX);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_DividerLineX != value)
|
||||
{
|
||||
UpdateChangeHandler(_DividerLineX, value);
|
||||
|
||||
_DividerLineX = value;
|
||||
|
||||
OnPropertyChangedEx("DividerLineX", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DividerLineY
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style of the vertical DividerLine (when ChartMatrix.DividerLines is enabled).
|
||||
/// </summary>
|
||||
[Description("Indicates the visual style of the vertical DividerLine. (when ChartMatrix.DividerLines is enabled)")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public DividerLineVisualStyle DividerLineY
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DividerLineY == null)
|
||||
{
|
||||
_DividerLineY = new DividerLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _DividerLineY);
|
||||
}
|
||||
|
||||
return (_DividerLineY);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_DividerLineY != value)
|
||||
{
|
||||
UpdateChangeHandler(_DividerLineY, value);
|
||||
|
||||
_DividerLineY = value;
|
||||
|
||||
OnPropertyChangedEx("DividerLineY", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HScrollBarVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles to be used for Horizontal ScrollBar elements
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates visual styles to be used for Horizontal ScrollBar elements ")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ScrollBarVisualStyles HScrollBarVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_HScrollBarVisualStyles == null)
|
||||
{
|
||||
_HScrollBarVisualStyles = new ScrollBarVisualStyles();
|
||||
|
||||
UpdateChangeHandler(null, _HScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
return (_HScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_HScrollBarVisualStyles != value)
|
||||
{
|
||||
ScrollBarVisualStyles oldValue = _HScrollBarVisualStyles;
|
||||
_HScrollBarVisualStyles = value;
|
||||
|
||||
OnStyleChanged("HScrollBarVisualStyles", oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VScrollBarVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles to be used for Vertical ScrollBar elements
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates visual styles to be used for Vertical ScrollBar elements ")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ScrollBarVisualStyles VScrollBarVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_VScrollBarVisualStyles == null)
|
||||
{
|
||||
_VScrollBarVisualStyles = new ScrollBarVisualStyles();
|
||||
|
||||
UpdateChangeHandler(null, _VScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
return (_VScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_VScrollBarVisualStyles != value)
|
||||
{
|
||||
ScrollBarVisualStyles oldValue = _VScrollBarVisualStyles;
|
||||
_VScrollBarVisualStyles = value;
|
||||
|
||||
OnStyleChanged("VScrollBarVisualStyles", oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_DividerLineX == null || _DividerLineX.IsEmpty == true) &&
|
||||
(_DividerLineY == null || _DividerLineY.IsEmpty == true) &&
|
||||
(_HScrollBarVisualStyles == null) &&
|
||||
(_VScrollBarVisualStyles == null) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartPanelVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.DividerLineX != null)
|
||||
DividerLineX.ApplyStyle(style.DividerLineX);
|
||||
|
||||
if (style.DividerLineY != null)
|
||||
DividerLineY.ApplyStyle(style.DividerLineY);
|
||||
|
||||
if (style.HScrollBarVisualStyles != null)
|
||||
{
|
||||
for (int i = 0; i < style.HScrollBarVisualStyles.Styles.Length; i++)
|
||||
{
|
||||
if (style.HScrollBarVisualStyles.Styles[i] != null)
|
||||
HScrollBarVisualStyles.GetStyle(i).ApplyStyle(style.HScrollBarVisualStyles.Styles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (style.VScrollBarVisualStyles != null)
|
||||
{
|
||||
for (int i = 0; i < style.VScrollBarVisualStyles.Styles.Length; i++)
|
||||
{
|
||||
if (style.VScrollBarVisualStyles.Styles[i] != null)
|
||||
VScrollBarVisualStyles.GetStyle(i).ApplyStyle(style.VScrollBarVisualStyles.Styles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartPanelVisualStyle Copy()
|
||||
{
|
||||
ChartPanelVisualStyle style = new ChartPanelVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartPanelVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.DividerLineX = (_DividerLineX != null) ? _DividerLineX.Copy() : null;
|
||||
style.DividerLineY = (_DividerLineY != null) ? _DividerLineY.Copy() : null;
|
||||
|
||||
style.HScrollBarVisualStyles = (_HScrollBarVisualStyles != null) ? _HScrollBarVisualStyles.Copy() : null;
|
||||
style.VScrollBarVisualStyles = (_VScrollBarVisualStyles != null) ? _VScrollBarVisualStyles.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartPanelVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_DividerLineX != null && _DividerLineX.IsEmpty == false)
|
||||
sec.AddElement(_DividerLineX.GetSerialData("DividerLineX"));
|
||||
|
||||
if (_DividerLineY != null && _DividerLineY.IsEmpty == false)
|
||||
sec.AddElement(_DividerLineY.GetSerialData("DividerLineY"));
|
||||
|
||||
if (_HScrollBarVisualStyles != null && _HScrollBarVisualStyles.IsEmpty == false)
|
||||
sec.AddElement(_HScrollBarVisualStyles.GetSerialData("HScrollBarVisualStyles"));
|
||||
|
||||
if (_VScrollBarVisualStyles != null && _VScrollBarVisualStyles.IsEmpty == false)
|
||||
sec.AddElement(_VScrollBarVisualStyles.GetSerialData("VScrollBarVisualStyles"));
|
||||
|
||||
sec.AddElement(base.GetSerialData(null));
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "DividerLineX":
|
||||
sec.PutSerialData(DividerLineX);
|
||||
break;
|
||||
|
||||
case "DividerLineY":
|
||||
sec.PutSerialData(DividerLineY);
|
||||
break;
|
||||
|
||||
case "HScrollBarVisualStyles":
|
||||
sec.PutSerialData(HScrollBarVisualStyles);
|
||||
break;
|
||||
|
||||
case "VScrollBarVisualStyles":
|
||||
sec.PutSerialData(VScrollBarVisualStyles);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
DividerLineX = null;
|
||||
DividerLineY = null;
|
||||
HScrollBarVisualStyles = null;
|
||||
VScrollBarVisualStyles = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,300 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Chart Ticmark element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class ChartTickmarkVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _TickmarkLength = -1;
|
||||
private int _TickmarkThickness = -1;
|
||||
private Color _TickmarkColor = Color.Empty;
|
||||
|
||||
private LineAlignment _TickmarkAlignment = LineAlignment.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region TickmarkAlignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Tickmark alignment.
|
||||
/// </summary>
|
||||
[DefaultValue(LineAlignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the Tickmark alignment.")]
|
||||
public LineAlignment TickmarkAlignment
|
||||
{
|
||||
get { return (_TickmarkAlignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _TickmarkAlignment)
|
||||
{
|
||||
_TickmarkAlignment = value;
|
||||
|
||||
OnPropertyChangedEx("TickMarkAlignment", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TickmarkColor
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the Tickmark Color.
|
||||
///</summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the Tickmark Color.")]
|
||||
public Color TickmarkColor
|
||||
{
|
||||
get { return (_TickmarkColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _TickmarkColor)
|
||||
{
|
||||
_TickmarkColor = value;
|
||||
|
||||
OnPropertyChangedEx("TickmarkColor", Style.VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeTickmarkColor()
|
||||
{
|
||||
return (_TickmarkColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetTickmarkColor()
|
||||
{
|
||||
TickmarkColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TickmarkLength
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Tickmark length.
|
||||
/// </summary>
|
||||
[DefaultValue(-1), Category("Appearance")]
|
||||
[Description("Indicates the Tickmark length.")]
|
||||
public int TickmarkLength
|
||||
{
|
||||
get { return (_TickmarkLength); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _TickmarkLength)
|
||||
{
|
||||
_TickmarkLength = value;
|
||||
|
||||
OnPropertyChangedEx("TickmarkLength", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TickmarkThickness
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Tickmark Thickness.
|
||||
/// </summary>
|
||||
[DefaultValue(-1), Category("Appearance")]
|
||||
[Description("Indicates the Tickmark Thickness.")]
|
||||
public int TickmarkThickness
|
||||
{
|
||||
get { return (_TickmarkThickness); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _TickmarkThickness)
|
||||
{
|
||||
_TickmarkThickness = value;
|
||||
|
||||
OnPropertyChangedEx("TickmarkThickness", 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 ((_TickmarkAlignment == LineAlignment.NotSet) &&
|
||||
(_TickmarkColor.IsEmpty == true) &&
|
||||
(_TickmarkLength < 0) &&
|
||||
(_TickmarkThickness < 0) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartTickmarkVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.TickmarkAlignment != LineAlignment.NotSet)
|
||||
TickmarkAlignment = style.TickmarkAlignment;
|
||||
|
||||
if (style.TickmarkColor.IsEmpty == false)
|
||||
TickmarkColor = style.TickmarkColor;
|
||||
|
||||
if (style.TickmarkLength >= 0)
|
||||
TickmarkLength = style.TickmarkLength;
|
||||
|
||||
if (style.TickmarkThickness >= 0)
|
||||
TickmarkThickness = style.TickmarkThickness;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartTickmarkVisualStyle Copy()
|
||||
{
|
||||
ChartTickmarkVisualStyle style = new ChartTickmarkVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartTickmarkVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.TickmarkAlignment = _TickmarkAlignment;
|
||||
style.TickmarkColor = _TickmarkColor;
|
||||
style.TickmarkLength = _TickmarkLength;
|
||||
style.TickmarkThickness = _TickmarkThickness;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartTickmarkVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("TickmarkAlignment", TickmarkAlignment, LineAlignment.NotSet);
|
||||
sec.AddValue("TickmarkColor", TickmarkColor, Color.Empty);
|
||||
sec.AddValue("TickmarkLength", TickmarkLength, -1);
|
||||
sec.AddValue("TickmarkThickness", TickmarkThickness, -1);
|
||||
|
||||
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 "TickmarkAlignment":
|
||||
TickmarkAlignment = (LineAlignment)se.GetValueEnum(typeof(LineAlignment));
|
||||
break;
|
||||
|
||||
case "TickmarkColor":
|
||||
TickmarkColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "TickmarkLength":
|
||||
TickmarkLength = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "TickmarkThickness":
|
||||
TickmarkThickness = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of an element.
|
||||
/// </summary>
|
||||
[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
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of Text lines.
|
||||
/// </summary>
|
||||
[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
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether text is 'stretched' to consume entire XyAlignment area.
|
||||
/// </summary>
|
||||
[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
|
||||
|
||||
/// <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 ((_MaxLineCount < 0) &&
|
||||
(_Stretch == Tbool.NotSet) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartTitleVisualStyle Copy()
|
||||
{
|
||||
ChartTitleVisualStyle style = new ChartTitleVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region RotateDegrees
|
||||
|
||||
///<summary>
|
||||
/// Specifies the degrees to rotate the element.
|
||||
///</summary>
|
||||
public enum RotateDegrees
|
||||
{
|
||||
///<summary>
|
||||
/// Not set
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// None
|
||||
///</summary>
|
||||
None,
|
||||
|
||||
///<summary>
|
||||
/// Rotate as needed
|
||||
///</summary>
|
||||
Auto,
|
||||
|
||||
///<summary>
|
||||
/// Rotate 90 degrees
|
||||
///</summary>
|
||||
Rotate90,
|
||||
|
||||
///<summary>
|
||||
/// Rotate 180 degrees
|
||||
///</summary>
|
||||
Rotate180,
|
||||
|
||||
///<summary>
|
||||
/// Rotate 270 degrees
|
||||
///</summary>
|
||||
Rotate270,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of an XY Chart element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class ChartXyVisualStyle : ContainerVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ScrollBarVisualStyles _HScrollBarVisualStyles;
|
||||
private ScrollBarVisualStyles _VScrollBarVisualStyles;
|
||||
|
||||
private int _InterSeriesGap = -1;
|
||||
private int _IntraSeriesGap = -1;
|
||||
|
||||
private Tbool _AutoExpandIntraSeriesGap = Tbool.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AutoExpandIntraSeriesGap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to auto adjust the IntraSeriesGap when space permits.
|
||||
/// </summary>
|
||||
[Description("Indicates whether to auto adjust the IntraSeriesGap when space permits.")]
|
||||
[DefaultValue(Tbool.NotSet)]
|
||||
public Tbool AutoExpandIntraSeriesGap
|
||||
{
|
||||
get { return (_AutoExpandIntraSeriesGap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _AutoExpandIntraSeriesGap)
|
||||
{
|
||||
_AutoExpandIntraSeriesGap = value;
|
||||
|
||||
OnPropertyChangedEx("AutoExpandIntraSeriesGap", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HScrollBarVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles to be used for Horizontal ScrollBar elements
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates visual styles to be used for Horizontal ScrollBar elements ")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ScrollBarVisualStyles HScrollBarVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_HScrollBarVisualStyles == null)
|
||||
{
|
||||
_HScrollBarVisualStyles = new ScrollBarVisualStyles();
|
||||
|
||||
UpdateChangeHandler(null, _HScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
return (_HScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_HScrollBarVisualStyles != value)
|
||||
{
|
||||
ScrollBarVisualStyles oldValue = _HScrollBarVisualStyles;
|
||||
_HScrollBarVisualStyles = value;
|
||||
|
||||
OnStyleChanged("HScrollBarVisualStyles", oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InterSeriesGap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pixel gap between grouped, qualitative series.
|
||||
/// </summary>
|
||||
[Description("Indicates the pixel gap between grouped, qualitative series.")]
|
||||
[DefaultValue(-1)]
|
||||
public int InterSeriesGap
|
||||
{
|
||||
get { return (_InterSeriesGap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _InterSeriesGap)
|
||||
{
|
||||
_InterSeriesGap = value;
|
||||
|
||||
OnPropertyChangedEx("InterSeriesGap", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IntraSeriesGap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pixel gap between each series in a set of grouped, qualitative series.
|
||||
/// </summary>
|
||||
[Description("Indicates the pixel gap between each series in a set of grouped, qualitative series.")]
|
||||
[DefaultValue(-1)]
|
||||
public int IntraSeriesGap
|
||||
{
|
||||
get { return (_IntraSeriesGap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _IntraSeriesGap)
|
||||
{
|
||||
_IntraSeriesGap = value;
|
||||
|
||||
OnPropertyChangedEx("IntraSeriesGap", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VScrollBarVisualStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles to be used for Vertical ScrollBar elements
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates visual styles to be used for Vertical ScrollBar elements ")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ScrollBarVisualStyles VScrollBarVisualStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_VScrollBarVisualStyles == null)
|
||||
{
|
||||
_VScrollBarVisualStyles = new ScrollBarVisualStyles();
|
||||
|
||||
UpdateChangeHandler(null, _VScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
return (_VScrollBarVisualStyles);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_VScrollBarVisualStyles != value)
|
||||
{
|
||||
ScrollBarVisualStyles oldValue = _VScrollBarVisualStyles;
|
||||
_VScrollBarVisualStyles = value;
|
||||
|
||||
OnStyleChanged("VScrollBarVisualStyles", oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_InterSeriesGap < 0) &&
|
||||
(_IntraSeriesGap < 0) &&
|
||||
(_VScrollBarVisualStyles == null) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ChartXyVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.AutoExpandIntraSeriesGap != Tbool.NotSet)
|
||||
_AutoExpandIntraSeriesGap = style.AutoExpandIntraSeriesGap;
|
||||
|
||||
if (style.InterSeriesGap >= 0)
|
||||
_InterSeriesGap = style.InterSeriesGap;
|
||||
|
||||
if (style.IntraSeriesGap >= 0)
|
||||
_IntraSeriesGap = style.IntraSeriesGap;
|
||||
|
||||
if (style.HScrollBarVisualStyles != null)
|
||||
{
|
||||
for (int i = 0; i < style.HScrollBarVisualStyles.Styles.Length; i++)
|
||||
{
|
||||
if (style.HScrollBarVisualStyles.Styles[i] != null)
|
||||
HScrollBarVisualStyles.GetStyle(i).ApplyStyle(style.HScrollBarVisualStyles.Styles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (style.VScrollBarVisualStyles != null)
|
||||
{
|
||||
for (int i = 0; i < style.VScrollBarVisualStyles.Styles.Length; i++)
|
||||
{
|
||||
if (style.VScrollBarVisualStyles.Styles[i] != null)
|
||||
VScrollBarVisualStyles.GetStyle(i).ApplyStyle(style.VScrollBarVisualStyles.Styles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
if (BorderPattern == null)
|
||||
BorderPattern = new BorderPattern(LinePattern.Solid);
|
||||
|
||||
if (InterSeriesGap < 0)
|
||||
InterSeriesGap = 2;
|
||||
|
||||
if (IntraSeriesGap < 0)
|
||||
IntraSeriesGap = 2;
|
||||
|
||||
if (AutoExpandIntraSeriesGap == Tbool.NotSet)
|
||||
AutoExpandIntraSeriesGap = Tbool.True;
|
||||
|
||||
if (DropShadow.Enabled == Tbool.NotSet)
|
||||
DropShadow.Enabled = Tbool.False;
|
||||
|
||||
base.ApplyDefaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ChartXyVisualStyle Copy()
|
||||
{
|
||||
ChartXyVisualStyle style = new ChartXyVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ChartXyVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AutoExpandIntraSeriesGap = _AutoExpandIntraSeriesGap;
|
||||
style.InterSeriesGap = _InterSeriesGap;
|
||||
style.IntraSeriesGap = _IntraSeriesGap;
|
||||
|
||||
style.HScrollBarVisualStyles = (_HScrollBarVisualStyles != null) ? _HScrollBarVisualStyles.Copy() : null;
|
||||
style.VScrollBarVisualStyles = (_VScrollBarVisualStyles != null) ? _VScrollBarVisualStyles.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ChartXyVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("AutoExpandIntraSeriesGap", AutoExpandIntraSeriesGap, Tbool.NotSet);
|
||||
sec.AddValue("InterSeriesGap", InterSeriesGap, -1);
|
||||
sec.AddValue("IntraSeriesGap", IntraSeriesGap, -1);
|
||||
|
||||
if (_HScrollBarVisualStyles != null && _HScrollBarVisualStyles.IsEmpty == false)
|
||||
sec.AddElement(_HScrollBarVisualStyles.GetSerialData("HScrollBarVisualStyles"));
|
||||
|
||||
if (_VScrollBarVisualStyles != null && _VScrollBarVisualStyles.IsEmpty == false)
|
||||
sec.AddElement(_VScrollBarVisualStyles.GetSerialData("VScrollBarVisualStyles"));
|
||||
|
||||
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 "AutoExpandIntraSeriesGap":
|
||||
AutoExpandIntraSeriesGap = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
case "InterSeriesGap":
|
||||
InterSeriesGap = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "IntraSeriesGap":
|
||||
IntraSeriesGap = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "HScrollBarVisualStyles":
|
||||
sec.PutSerialData(HScrollBarVisualStyles);
|
||||
break;
|
||||
|
||||
case "VScrollBarVisualStyles":
|
||||
sec.PutSerialData(HScrollBarVisualStyles);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
HScrollBarVisualStyles = null;
|
||||
VScrollBarVisualStyles = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Chart Line
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(DefaultStyleConvertor))]
|
||||
public class ConnectorLineVisualStyle : ChartLineVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _MaxLength = -1;
|
||||
private int _MinLength = -1;
|
||||
private int _LengthStep = -1;
|
||||
|
||||
private int _DefaultAngle = -1;
|
||||
private int _AngleStep = -1;
|
||||
|
||||
private ConnectorOrigin _Origin = ConnectorOrigin.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AngleStep
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the angle step value when rotating conflicting labels.
|
||||
///</summary>
|
||||
[DefaultValue(-1), Category("DataLabel")]
|
||||
[Description("Indicates the angle step value when rotating conflicting labels.")]
|
||||
public int AngleStep
|
||||
{
|
||||
get { return (_AngleStep); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _AngleStep)
|
||||
{
|
||||
_AngleStep = value;
|
||||
|
||||
OnPropertyChangedEx("AngleStep", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DefaultAngle
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the default line angle (-1 denotes 'auto').
|
||||
///</summary>
|
||||
[DefaultValue(-1), Category("DataLabel")]
|
||||
[Description("Indicates the default line angle (-1 denotes 'auto').")]
|
||||
public int DefaultAngle
|
||||
{
|
||||
get { return (_DefaultAngle); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _DefaultAngle)
|
||||
{
|
||||
_DefaultAngle = value;
|
||||
|
||||
OnPropertyChangedEx("DefaultAngle", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LengthStep
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the angle step value when rotating conflicting labels.
|
||||
///</summary>
|
||||
[DefaultValue(-1), Category("DataLabel")]
|
||||
[Description("Indicates the angle step value when rotating conflicting labels.")]
|
||||
public int LengthStep
|
||||
{
|
||||
get { return (_LengthStep); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _LengthStep)
|
||||
{
|
||||
_LengthStep = value;
|
||||
|
||||
OnPropertyChangedEx("LengthStep", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MaxLength
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the maximum connector line length.
|
||||
///</summary>
|
||||
[DefaultValue(-1), Category("DataLabel")]
|
||||
[Description("Indicates the maximum connector line length.")]
|
||||
public int MaxLength
|
||||
{
|
||||
get { return (_MaxLength); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MaxLength)
|
||||
{
|
||||
_MaxLength = value;
|
||||
|
||||
OnPropertyChangedEx("MaxLength", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MinLength
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the minimum connector line length.
|
||||
///</summary>
|
||||
[DefaultValue(-1), Category("DataLabel")]
|
||||
[Description("Indicates the minimum connector line length.")]
|
||||
public int MinLength
|
||||
{
|
||||
get { return (_MinLength); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _MinLength)
|
||||
{
|
||||
_MinLength = value;
|
||||
|
||||
OnPropertyChangedEx("MinLength", Style.VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Origin
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the line connector origin.
|
||||
/// </summary>
|
||||
[DefaultValue(ConnectorOrigin.NotSet)]
|
||||
[Description("Indicates the line connector origin")]
|
||||
public ConnectorOrigin Origin
|
||||
{
|
||||
get { return (_Origin); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _Origin)
|
||||
{
|
||||
_Origin = value;
|
||||
|
||||
OnPropertyChangedEx("Origin", 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 ((_AngleStep < 0) &&
|
||||
(_DefaultAngle < 0) &&
|
||||
(_Origin == ConnectorOrigin.NotSet) &&
|
||||
(_LengthStep < 0) &&
|
||||
(_MaxLength < 0) &&
|
||||
(_MinLength < 0) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(ConnectorLineVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.AngleStep >= 0)
|
||||
_AngleStep = style.AngleStep;
|
||||
|
||||
if (style.DefaultAngle >= 0)
|
||||
_DefaultAngle = style.DefaultAngle;
|
||||
|
||||
if (style.LengthStep >= 0)
|
||||
_LengthStep = style.LengthStep;
|
||||
|
||||
if (style.MaxLength >= 0)
|
||||
_MaxLength = style.MaxLength;
|
||||
|
||||
if (style.MinLength >= 0)
|
||||
_MinLength = style.MinLength;
|
||||
|
||||
if (style.Origin != ConnectorOrigin.NotSet)
|
||||
_Origin = style.Origin;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
if (MinLength > MaxLength)
|
||||
MaxLength = MinLength;
|
||||
|
||||
if (MinLength < 0)
|
||||
MinLength = 10;
|
||||
|
||||
if (MaxLength < 0)
|
||||
MaxLength = 200;
|
||||
|
||||
if (MaxLength <= MinLength)
|
||||
MaxLength = MinLength + 200;
|
||||
|
||||
if (AngleStep < 0)
|
||||
AngleStep = 15;
|
||||
|
||||
if (LengthStep < 0)
|
||||
LengthStep = 10;
|
||||
|
||||
if (LinePattern == LinePattern.NotSet)
|
||||
LinePattern = LinePattern.Solid;
|
||||
|
||||
if (LineColor.IsEmpty == true)
|
||||
LineColor = Color.Black;
|
||||
|
||||
if (LineWidth < 0)
|
||||
LineWidth = 1;
|
||||
|
||||
base.ApplyDefaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new ConnectorLineVisualStyle Copy()
|
||||
{
|
||||
ConnectorLineVisualStyle style = new ConnectorLineVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(ConnectorLineVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.AngleStep = _AngleStep;
|
||||
style.DefaultAngle = _DefaultAngle;
|
||||
|
||||
style.LengthStep = _LengthStep;
|
||||
style.MaxLength = _MaxLength;
|
||||
style.MinLength = _MinLength;
|
||||
|
||||
style.Origin = _Origin;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "ConnectorLineVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("AngleStep", AngleStep, -1);
|
||||
sec.AddValue("DefaultAngle", DefaultAngle, -1);
|
||||
|
||||
sec.AddValue("LengthStep", LengthStep, -1);
|
||||
sec.AddValue("MaxLength", MaxLength, -1);
|
||||
sec.AddValue("MinLength", MinLength, -1);
|
||||
|
||||
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 "AngleStep":
|
||||
AngleStep = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "DefaultAngle":
|
||||
DefaultAngle = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "LengthStep":
|
||||
LengthStep = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "MaxLength":
|
||||
MaxLength = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "MinLength":
|
||||
MinLength = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Enums
|
||||
|
||||
#region ConnectorOrigin
|
||||
|
||||
public enum ConnectorOrigin
|
||||
{
|
||||
NotSet = -1,
|
||||
|
||||
Center,
|
||||
|
||||
Edge,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of an element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class CrosshairValueVisualStyle : VisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _TextFormat;
|
||||
private DropShadowVisualStyle _DropShadow;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region DropShadow
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the DropShadow.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the DropShadow.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public DropShadowVisualStyle DropShadow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DropShadow == null)
|
||||
{
|
||||
_DropShadow = new DropShadowVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _DropShadow);
|
||||
}
|
||||
|
||||
return (_DropShadow);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_DropShadow != value)
|
||||
{
|
||||
DropShadowVisualStyle oldValue = _DropShadow;
|
||||
|
||||
_DropShadow = value;
|
||||
|
||||
OnStyleChanged("DropShadow", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_DropShadow == null || _DropShadow.IsEmpty) &&
|
||||
(string.IsNullOrEmpty(_TextFormat) == true) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(CrosshairValueVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._DropShadow != null && style.DropShadow.IsEmpty == false)
|
||||
DropShadow.ApplyStyle(style.DropShadow);
|
||||
|
||||
if (string.IsNullOrEmpty(style.TextFormat) == false)
|
||||
_TextFormat = style.TextFormat;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
public override void ApplyDefaults()
|
||||
{
|
||||
if (Background.IsEmpty == true)
|
||||
Background = new Background(ControlPaint.LightLight(Color.Fuchsia));
|
||||
|
||||
if (BorderColor.IsEmpty == true)
|
||||
BorderColor = new BorderColor(Color.Black);
|
||||
|
||||
if (BorderPattern.IsEmpty == true)
|
||||
BorderPattern = new BorderPattern(LinePattern.Solid);
|
||||
|
||||
if (BorderThickness.IsEmpty == true)
|
||||
BorderThickness = new Thickness(1);
|
||||
|
||||
base.ApplyDefaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new CrosshairValueVisualStyle Copy()
|
||||
{
|
||||
CrosshairValueVisualStyle style = new CrosshairValueVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(CrosshairValueVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.DropShadow = (_DropShadow != null) ? DropShadow.Copy() : null;
|
||||
style.TextFormat = _TextFormat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "CrosshairValueVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_DropShadow != null && _DropShadow.IsEmpty == false)
|
||||
sec.AddElement(_DropShadow.GetSerialData("DropShadow"));
|
||||
|
||||
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 "TextFormat":
|
||||
TextFormat = se.StringValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "DropShadow":
|
||||
sec.PutSerialData(DropShadow);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
DropShadow = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,778 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of an element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class CrosshairVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Background _Background;
|
||||
private Color _BorderColor = Color.Empty;
|
||||
private LinePattern _BorderPattern = LinePattern.NotSet;
|
||||
private int _BorderThickness;
|
||||
|
||||
private Color _TextColor = Color.Empty;
|
||||
|
||||
private ChartLineVisualStyle _ValueXLineStyle;
|
||||
private ChartLineVisualStyle _ValueYLineStyle;
|
||||
|
||||
private Font _GroupHeaderFont;
|
||||
private Color _GroupHeaderTextColor = Color.Empty;
|
||||
|
||||
private Font _Font;
|
||||
private Padding _Margin;
|
||||
private Padding _Padding;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Background
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style background.
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBackground()
|
||||
{
|
||||
return (_Background != null && _Background.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBackground()
|
||||
{
|
||||
Background = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style border color.
|
||||
/// </summary>
|
||||
[Description("Indicates the style Border Color")]
|
||||
public Color BorderColor
|
||||
{
|
||||
get { return (_BorderColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_BorderColor != value)
|
||||
{
|
||||
_BorderColor = value;
|
||||
|
||||
OnPropertyChangedEx("BorderColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBorderColor()
|
||||
{
|
||||
return (_BorderColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBorderColor()
|
||||
{
|
||||
BorderColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderPattern
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style border pattern (Solid, Dash, ...)
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the style border pattern (Solid, Dash, ...)")]
|
||||
public LinePattern BorderPattern
|
||||
{
|
||||
get { return (_BorderPattern); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_BorderPattern != value)
|
||||
{
|
||||
_BorderPattern = value;
|
||||
|
||||
OnPropertyChangedEx("BorderPattern", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderThickness
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style border thickness.
|
||||
/// </summary>
|
||||
[DefaultValue(0)]
|
||||
[Description("Indicates the style border thickness")]
|
||||
public int BorderThickness
|
||||
{
|
||||
get { return (_BorderThickness); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_BorderThickness != value)
|
||||
{
|
||||
_BorderThickness = value;
|
||||
|
||||
OnPropertyChangedEx("BorderThickness", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GroupHeaderFont
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the GroupHeader Font
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
[Description("Indicates the GroupHeader Font")]
|
||||
public Font GroupHeaderFont
|
||||
{
|
||||
get { return (_GroupHeaderFont); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_GroupHeaderFont != value)
|
||||
{
|
||||
_GroupHeaderFont = value;
|
||||
|
||||
OnPropertyChangedEx("GroupHeaderFont", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GroupHeaderTextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Color of the GroupHeaderText.
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the Color of the GroupHeaderText.")]
|
||||
public Color GroupHeaderTextColor
|
||||
{
|
||||
get { return (_GroupHeaderTextColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_GroupHeaderTextColor != value)
|
||||
{
|
||||
_GroupHeaderTextColor = value;
|
||||
|
||||
OnPropertyChangedEx("GroupHeaderTextColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeGroupHeaderTextColor()
|
||||
{
|
||||
return (_GroupHeaderTextColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetGroupHeaderTextColor()
|
||||
{
|
||||
GroupHeaderTextColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Font
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
[Description("Indicates the Font")]
|
||||
public Font Font
|
||||
{
|
||||
get { return (_Font); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Font != value)
|
||||
{
|
||||
_Font = value;
|
||||
|
||||
OnPropertyChangedEx("Font", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Margin
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the spacing between the border and outside content.
|
||||
/// </summary>
|
||||
[Description("Indicates the spacing between the border and outside content")]
|
||||
public Padding Margin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Margin == null)
|
||||
{
|
||||
_Margin = Padding.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _Margin);
|
||||
}
|
||||
|
||||
return (_Margin);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_Margin != value)
|
||||
{
|
||||
UpdateChangeHandler(_Margin, value);
|
||||
|
||||
_Margin = value;
|
||||
|
||||
OnPropertyChangedEx("Margin", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeMargin()
|
||||
{
|
||||
return (_Margin != null && _Margin.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetMargin()
|
||||
{
|
||||
Margin = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Padding
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets spacing between the content and edges of the element.
|
||||
/// </summary>
|
||||
[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.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializePadding()
|
||||
{
|
||||
return (_Padding != null && _Padding.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetPadding()
|
||||
{
|
||||
Padding = null;
|
||||
}
|
||||
|
||||
#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 ValueXLineStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the X Value Line.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the X Value Line.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle ValueXLineStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ValueXLineStyle == null)
|
||||
{
|
||||
_ValueXLineStyle = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _ValueXLineStyle);
|
||||
}
|
||||
|
||||
return (_ValueXLineStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_ValueXLineStyle != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _ValueXLineStyle;
|
||||
|
||||
_ValueXLineStyle = value;
|
||||
|
||||
OnStyleChanged("ValueXLineStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ValueYLineStyle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Y Value Line.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Y Value Line.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle ValueYLineStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ValueYLineStyle == null)
|
||||
{
|
||||
_ValueYLineStyle = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _ValueYLineStyle);
|
||||
}
|
||||
|
||||
return (_ValueYLineStyle);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_ValueYLineStyle != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _ValueYLineStyle;
|
||||
|
||||
_ValueYLineStyle = value;
|
||||
|
||||
OnStyleChanged("ValueYLineStyle", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 ((_Background == null || _Background.IsEmpty == true) &&
|
||||
(_BorderColor.IsEmpty == true) &&
|
||||
(_BorderPattern == LinePattern.NotSet) &&
|
||||
(_BorderThickness <= 0) &&
|
||||
(_GroupHeaderFont == null) &&
|
||||
(_Font == null) &&
|
||||
(_GroupHeaderTextColor.IsEmpty == true) &&
|
||||
(_Margin == null || _Margin.IsEmpty == true) &&
|
||||
(_Padding == null || _Padding.IsEmpty == true) &&
|
||||
(_TextColor.IsEmpty == true) &&
|
||||
(_ValueXLineStyle == null || _ValueXLineStyle.IsEmpty) &&
|
||||
(_ValueYLineStyle == null || _ValueYLineStyle.IsEmpty) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(CrosshairVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._Background != null && style._Background.IsEmpty == false)
|
||||
Background = style._Background.Copy();
|
||||
|
||||
if (style._BorderColor.IsEmpty == false)
|
||||
BorderColor = style._BorderColor;
|
||||
|
||||
if (style._BorderPattern != LinePattern.NotSet)
|
||||
BorderPattern = style._BorderPattern;
|
||||
|
||||
if (style._BorderThickness > 0)
|
||||
BorderThickness = style._BorderThickness;
|
||||
|
||||
if (style.GroupHeaderFont != null)
|
||||
GroupHeaderFont = style.GroupHeaderFont;
|
||||
|
||||
if (style._Font != null)
|
||||
Font = style.Font;
|
||||
|
||||
if (style.GroupHeaderTextColor.IsEmpty == false)
|
||||
GroupHeaderTextColor = style.GroupHeaderTextColor;
|
||||
|
||||
if (style._Margin != null && style._Margin.IsEmpty == false)
|
||||
Margin = style.Margin.Copy();
|
||||
|
||||
if (style._Padding != null && style._Padding.IsEmpty == false)
|
||||
Padding = style.Padding.Copy();
|
||||
|
||||
if (style._TextColor.IsEmpty == false)
|
||||
TextColor = style._TextColor;
|
||||
|
||||
if (style._ValueXLineStyle != null && style.ValueXLineStyle.IsEmpty == false)
|
||||
ValueXLineStyle.ApplyStyle(style.ValueXLineStyle);
|
||||
|
||||
if (style._ValueYLineStyle != null && style.ValueYLineStyle.IsEmpty == false)
|
||||
ValueYLineStyle.ApplyStyle(style.ValueYLineStyle);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new CrosshairVisualStyle Copy()
|
||||
{
|
||||
CrosshairVisualStyle style = new CrosshairVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(CrosshairVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.Background = (_Background != null) ? _Background.Copy() : null;
|
||||
|
||||
style.BorderColor = _BorderColor;
|
||||
style.BorderPattern = _BorderPattern;
|
||||
style.BorderThickness = _BorderThickness;
|
||||
|
||||
style.GroupHeaderFont = (_GroupHeaderFont != null) ? (Font)_GroupHeaderFont.Clone() : null;
|
||||
style.GroupHeaderTextColor = _GroupHeaderTextColor;
|
||||
|
||||
style.Font = (_Font != null) ? (Font)_Font.Clone() : null;
|
||||
style.Margin = (_Margin != null) ? _Margin.Copy() : null;
|
||||
style.Padding = (_Padding != null) ? _Padding.Copy() : null;
|
||||
|
||||
style.TextColor = _TextColor;
|
||||
|
||||
style.ValueXLineStyle = (_ValueXLineStyle != null) ? _ValueXLineStyle.Copy() : null;
|
||||
style.ValueYLineStyle = (_ValueYLineStyle != null) ? _ValueYLineStyle.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "CrosshairVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_Background != null && _Background.IsEmpty == false)
|
||||
sec.AddElement(_Background.GetSerialData("Background"));
|
||||
|
||||
sec.AddValue("BorderColor", BorderColor, Color.Empty);
|
||||
sec.AddValue("BorderPattern", BorderPattern, LinePattern.NotSet);
|
||||
sec.AddValue("BorderThickness", BorderThickness, 0);
|
||||
|
||||
if (_GroupHeaderFont != null)
|
||||
sec.AddValue("GroupHeaderFont", XmlSerializableFont.ConvertToString(GroupHeaderFont));
|
||||
|
||||
sec.AddValue("GroupHeaderTextColor", GroupHeaderTextColor, Color.Empty);
|
||||
|
||||
if (_Font != null)
|
||||
sec.AddValue("Font", XmlSerializableFont.ConvertToString(Font));
|
||||
|
||||
if (_Margin != null && _Margin.IsEmpty == false)
|
||||
sec.AddElement(_Margin.GetSerialData("Margin"));
|
||||
|
||||
if (_Padding != null && _Padding.IsEmpty == false)
|
||||
sec.AddElement(_Padding.GetSerialData("Padding"));
|
||||
|
||||
sec.AddValue("TextColor", TextColor, Color.Empty);
|
||||
|
||||
if (_ValueXLineStyle != null && _ValueXLineStyle.IsEmpty == false)
|
||||
sec.AddElement(_ValueXLineStyle.GetSerialData("ValueXLineStyle"));
|
||||
|
||||
if (_ValueYLineStyle != null && _ValueYLineStyle.IsEmpty == false)
|
||||
sec.AddElement(_ValueYLineStyle.GetSerialData("ValueYLineStyle"));
|
||||
|
||||
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 "BorderColor":
|
||||
BorderColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "BorderPattern":
|
||||
BorderPattern = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
||||
break;
|
||||
|
||||
case "BorderThickness":
|
||||
BorderThickness = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "GroupHeaderFont":
|
||||
GroupHeaderFont = XmlSerializableFont.ConvertFromString(se.StringValue);
|
||||
break;
|
||||
|
||||
case "GroupHeaderTextColor":
|
||||
GroupHeaderTextColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
case "Font":
|
||||
Font = XmlSerializableFont.ConvertFromString(se.StringValue);
|
||||
break;
|
||||
|
||||
case "TextColor":
|
||||
TextColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "Background":
|
||||
sec.PutSerialData(Background);
|
||||
break;
|
||||
|
||||
case "Margin":
|
||||
sec.PutSerialData(Margin);
|
||||
break;
|
||||
|
||||
case "Padding":
|
||||
sec.PutSerialData(Padding);
|
||||
break;
|
||||
|
||||
case "ValueXLineStyle":
|
||||
sec.PutSerialData(ValueXLineStyle);
|
||||
break;
|
||||
|
||||
case "ValueYLineStyle":
|
||||
sec.PutSerialData(ValueYLineStyle);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
Margin = null;
|
||||
Padding = null;
|
||||
ValueXLineStyle = null;
|
||||
ValueYLineStyle = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Legend element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class DividerLineVisualStyle : ChartLineVisualStyle
|
||||
{
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to the instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(DividerLineVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
base.ApplyStyle(style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new DividerLineVisualStyle Copy()
|
||||
{
|
||||
DividerLineVisualStyle style = new DividerLineVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(DividerLineVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a DropShadow
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(DropShadowStyleConvertor))]
|
||||
public class DropShadowVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Tbool _Enabled = Tbool.NotSet;
|
||||
private Color _ShadowColor = Color.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region ShadowColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DropShadow color
|
||||
/// </summary>
|
||||
[Description("Indicates the DropShadow color")]
|
||||
public Color ShadowColor
|
||||
{
|
||||
get { return (_ShadowColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _ShadowColor)
|
||||
{
|
||||
_ShadowColor = value;
|
||||
|
||||
OnPropertyChangedEx("ShadowColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeShadowColor()
|
||||
{
|
||||
return (_ShadowColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetShadowColor()
|
||||
{
|
||||
_ShadowColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enabled
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether drop shadow is displayed.
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether drop shadow is displayed.")]
|
||||
public Tbool Enabled
|
||||
{
|
||||
get { return (_Enabled); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _Enabled)
|
||||
{
|
||||
_Enabled = value;
|
||||
|
||||
OnPropertyChangedEx("Enabled", 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 ((_ShadowColor.IsEmpty == true) &&
|
||||
(_Enabled == Tbool.NotSet) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderDropShadow
|
||||
|
||||
internal virtual void RenderDropShadow(
|
||||
Graphics g, Rectangle r, bool drawBot, bool drawRight)
|
||||
{
|
||||
Color color = (_ShadowColor.IsEmpty == false) ? _ShadowColor : Color.Black;
|
||||
|
||||
Point[] pts = new Point[]
|
||||
{
|
||||
new Point(r.X + 3, r.Bottom),
|
||||
new Point(r.Right, r.Bottom),
|
||||
new Point(r.Right, r.Y + 3)
|
||||
};
|
||||
|
||||
using (Pen pen1 = new Pen(Color.FromArgb(100, color)))
|
||||
g.DrawLines(pen1, pts);
|
||||
|
||||
IncShadowPts(pts);
|
||||
|
||||
using (Pen pen2 = new Pen(Color.FromArgb(64, color)))
|
||||
g.DrawLines(pen2, pts);
|
||||
|
||||
IncShadowPts(pts);
|
||||
|
||||
using (Pen pen3 = new Pen(Color.FromArgb(32, color)))
|
||||
g.DrawLines(pen3, pts);
|
||||
|
||||
IncShadowPts(pts);
|
||||
}
|
||||
|
||||
#region IncShadowPts
|
||||
|
||||
private void IncShadowPts(Point[] pts)
|
||||
{
|
||||
pts[0].X++;
|
||||
pts[0].Y++;
|
||||
|
||||
pts[1].X++;
|
||||
pts[1].Y++;
|
||||
|
||||
pts[2].X++;
|
||||
pts[2].Y++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(DropShadowVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.ShadowColor.IsEmpty == false)
|
||||
ShadowColor = style.ShadowColor;
|
||||
|
||||
if (style.Enabled != Tbool.NotSet)
|
||||
Enabled = style.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new DropShadowVisualStyle Copy()
|
||||
{
|
||||
DropShadowVisualStyle style = new DropShadowVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(DropShadowVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.Enabled = _Enabled;
|
||||
style.ShadowColor = _ShadowColor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "DropShadowVisualStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
sec.AddValue("Enabled", Enabled, Tbool.NotSet);
|
||||
sec.AddValue("ShadowColor", ShadowColor, Color.Empty);
|
||||
|
||||
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 "Enabled":
|
||||
Enabled = (Tbool)se.GetValueEnum(typeof(Tbool));
|
||||
break;
|
||||
|
||||
case "ShadowColor":
|
||||
ShadowColor = se.GetValueColor();
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region DropShadowStyleConvertor
|
||||
|
||||
public class DropShadowStyleConvertor : ExpandableObjectConverter
|
||||
{
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
DropShadowVisualStyle dsc = value as DropShadowVisualStyle;
|
||||
|
||||
if (dsc != null)
|
||||
{
|
||||
ColorConverter cvt = new ColorConverter();
|
||||
|
||||
if (dsc.Enabled == Tbool.NotSet)
|
||||
return (" ");
|
||||
|
||||
return ((dsc.Enabled == Tbool.True) ? "Enabled" : "Disabled");
|
||||
}
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Charts.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides helpers when working with EffectiveStyles.
|
||||
/// </summary>
|
||||
public class EffectiveStyles<T> where T : BaseVisualStyle, new()
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private IEffectiveStyle _ChartElement;
|
||||
private VisualStyles<T> _Styles = new VisualStyles<T>();
|
||||
|
||||
private ushort[] _StyleUpdateCount;
|
||||
private ushort[] _GlobalStyleUpdateCount;
|
||||
|
||||
private List<BaseVisualStyle>[] _StyleList;
|
||||
|
||||
#endregion
|
||||
|
||||
public EffectiveStyles(IEffectiveStyle chartElement)
|
||||
{
|
||||
_ChartElement = chartElement;
|
||||
|
||||
int len = Enum.GetValues(typeof(StyleType)).Length - 1;
|
||||
|
||||
_StyleUpdateCount = new ushort[len];
|
||||
_GlobalStyleUpdateCount = new ushort[len];
|
||||
|
||||
_StyleList = new List<BaseVisualStyle>[len];
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
_StyleUpdateCount[i] = ushort.MaxValue;
|
||||
_GlobalStyleUpdateCount[i] = ushort.MaxValue;
|
||||
}
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region StyleType Indexer
|
||||
|
||||
public T this[StyleType type]
|
||||
{
|
||||
get { return (GetEffectiveStyle(type)); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleState Indexer
|
||||
|
||||
public T this[StyleState state]
|
||||
{
|
||||
get { return (GetEffectiveStyle(state)); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetEffectiveStyle
|
||||
|
||||
internal T GetEffectiveStyle(StyleType type)
|
||||
{
|
||||
return (GetStyle(type));
|
||||
}
|
||||
|
||||
internal T GetEffectiveStyle(StyleState state)
|
||||
{
|
||||
if (_ChartElement.ChartControl.DesignerHosted == true)
|
||||
state &= ~(StyleState.MouseOver | StyleState.Selected);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case StyleState.MouseOver:
|
||||
return (GetStyle(StyleType.MouseOver));
|
||||
|
||||
case StyleState.Selected:
|
||||
return (GetStyle(StyleType.Selected));
|
||||
|
||||
case StyleState.Selected | StyleState.MouseOver:
|
||||
return (GetStyle(StyleType.SelectedMouseOver));
|
||||
|
||||
default:
|
||||
return (GetStyle(StyleType.Default));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetStyle
|
||||
|
||||
internal T GetStyle(StyleType e)
|
||||
{
|
||||
VisualStyles<T> cvs = _Styles;
|
||||
|
||||
if (cvs == null)
|
||||
cvs = new VisualStyles<T>();
|
||||
|
||||
int styleIndex = cvs.StyleIndex(e);
|
||||
|
||||
ushort styleUpdateCount = _StyleUpdateCount[styleIndex];
|
||||
ushort globalUpdateCount = _ChartElement.ChartControl.GlobalUpdateCount;
|
||||
|
||||
T style = cvs.Style(e);
|
||||
|
||||
if (_GlobalStyleUpdateCount[styleIndex] != globalUpdateCount)
|
||||
{
|
||||
if (style != null)
|
||||
styleUpdateCount = GetStyleUpdateCount(styleIndex);
|
||||
}
|
||||
|
||||
if (style == null || _StyleUpdateCount[styleIndex] != styleUpdateCount)
|
||||
{
|
||||
style = new T();
|
||||
|
||||
if (_StyleList[styleIndex] == null)
|
||||
_StyleList[styleIndex] = new List<BaseVisualStyle>();
|
||||
|
||||
_StyleList[styleIndex].Clear();
|
||||
|
||||
style.StyleType = e;
|
||||
style.StyleList = _StyleList[styleIndex];
|
||||
style.StyleUpdateMode = StyleUpdateMode.UpdateCount;
|
||||
|
||||
StyleType[] css = style.GetApplyStyleTypes(e);
|
||||
|
||||
if (css != null)
|
||||
{
|
||||
foreach (StyleType cs in css)
|
||||
_ChartElement.ApplyStyles(style, cs);
|
||||
}
|
||||
|
||||
style.StyleUpdateMode = StyleUpdateMode.None;
|
||||
|
||||
_ChartElement.ApplyDefaults(style, e);
|
||||
|
||||
style.StyleUpdateMode = (StyleUpdateMode.UpdateCount | StyleUpdateMode.Notify);
|
||||
|
||||
BaseVisualStyle vstyle = (BaseVisualStyle)style;
|
||||
_ChartElement.GetElementStyle(_ChartElement, e, ref vstyle);
|
||||
|
||||
_StyleUpdateCount[styleIndex] = GetStyleUpdateCount(styleIndex);
|
||||
|
||||
style.StyleList = null;
|
||||
|
||||
cvs[e] = style;
|
||||
|
||||
_Styles = cvs;
|
||||
}
|
||||
|
||||
_GlobalStyleUpdateCount[styleIndex] = globalUpdateCount;
|
||||
|
||||
return (cvs[e]);
|
||||
}
|
||||
|
||||
#region GetStyleUpdateCount
|
||||
|
||||
private ushort GetStyleUpdateCount(int styleIndex)
|
||||
{
|
||||
ushort styleCount = 0;
|
||||
|
||||
List<BaseVisualStyle> slist = _StyleList[styleIndex];
|
||||
|
||||
if (slist != null)
|
||||
{
|
||||
foreach (BaseVisualStyle style in slist)
|
||||
styleCount += style.StyleUpdateCount;
|
||||
}
|
||||
|
||||
return (styleCount);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
public bool InvalidateStyle(StyleType type)
|
||||
{
|
||||
if (_Styles != null)
|
||||
{
|
||||
if (_Styles[type] != null)
|
||||
{
|
||||
_Styles[type].Dispose();
|
||||
_Styles[type] = null;
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyles
|
||||
|
||||
public void InvalidateStyles()
|
||||
{
|
||||
if (_Styles != null)
|
||||
{
|
||||
_Styles.Dispose();
|
||||
_Styles = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides helpers when working with EffectiveStyle.
|
||||
/// </summary>
|
||||
public class EffectiveStyle<T> where T : BaseVisualStyle, new()
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private IEffectiveStyle _ChartElement;
|
||||
private T _Style;
|
||||
|
||||
private ushort _StyleUpdateCount = ushort.MaxValue;
|
||||
private ushort _GlobalStyleUpdateCount = ushort.MaxValue;
|
||||
|
||||
private List<BaseVisualStyle> _StyleList = new List<BaseVisualStyle>();
|
||||
|
||||
#endregion
|
||||
|
||||
public EffectiveStyle(IEffectiveStyle chartElement)
|
||||
{
|
||||
_ChartElement = chartElement;
|
||||
}
|
||||
|
||||
#region Style
|
||||
|
||||
internal T Style
|
||||
{
|
||||
get
|
||||
{
|
||||
ushort styleUpdateCount = _StyleUpdateCount;
|
||||
ushort globalUpdateCount = _ChartElement.ChartControl.GlobalUpdateCount;
|
||||
|
||||
if (_GlobalStyleUpdateCount != globalUpdateCount)
|
||||
{
|
||||
if (_Style != null)
|
||||
styleUpdateCount = GetStyleUpdateCount();
|
||||
}
|
||||
|
||||
if (_Style == null || _StyleUpdateCount != styleUpdateCount)
|
||||
{
|
||||
T style = new T();
|
||||
|
||||
_StyleList.Clear();
|
||||
|
||||
style.StyleList = _StyleList;
|
||||
style.StyleType = StyleType.Default;
|
||||
|
||||
_ChartElement.ApplyStyles(style);
|
||||
_ChartElement.ApplyDefaults(style, StyleType.Default);
|
||||
|
||||
BaseVisualStyle vstyle = (BaseVisualStyle)style;
|
||||
_ChartElement.GetElementStyle(_ChartElement, StyleType.Default, ref vstyle);
|
||||
|
||||
_StyleUpdateCount = GetStyleUpdateCount();
|
||||
|
||||
style.StyleList = null;
|
||||
|
||||
_Style = style;
|
||||
}
|
||||
|
||||
_GlobalStyleUpdateCount = globalUpdateCount;
|
||||
|
||||
return (_Style);
|
||||
}
|
||||
}
|
||||
|
||||
#region GetStyleUpdateCount
|
||||
|
||||
private ushort GetStyleUpdateCount()
|
||||
{
|
||||
ushort styleCount = 0;
|
||||
|
||||
List<BaseVisualStyle> slist = _StyleList;
|
||||
|
||||
if (slist != null)
|
||||
{
|
||||
foreach (BaseVisualStyle style in slist)
|
||||
styleCount += style.StyleUpdateCount;
|
||||
}
|
||||
|
||||
return (styleCount);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
public bool InvalidateStyle()
|
||||
{
|
||||
if (_Style != null)
|
||||
{
|
||||
_Style.Dispose();
|
||||
_Style = null;
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region IEffectiveStyle
|
||||
|
||||
public interface IEffectiveStyle
|
||||
{
|
||||
void ApplyStyles(BaseVisualStyle style);
|
||||
void ApplyStyles(BaseVisualStyle style, StyleType styleType);
|
||||
|
||||
void ApplyDefaults(BaseVisualStyle style, StyleType styleType);
|
||||
|
||||
void GetElementStyle(IEffectiveStyle chartElement, StyleType styleType, ref BaseVisualStyle style);
|
||||
|
||||
ChartControl ChartControl
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a GridLineVisualStyle.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class GridLineVisualStyle : ChartLineVisualStyle
|
||||
{
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new GridLineVisualStyle Copy()
|
||||
{
|
||||
GridLineVisualStyle style = new GridLineVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(GridLineVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,763 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents HiLoBarSegment visual style.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class HiLoBarSegmentStyle : BaseVisualStyle
|
||||
{
|
||||
#region Static data
|
||||
|
||||
/// <summary>
|
||||
/// Returns Empty instance of HiLoBarSegmentStyle.
|
||||
/// </summary>
|
||||
public static HiLoBarSegmentStyle Empty
|
||||
{
|
||||
get { return (new HiLoBarSegmentStyle()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private ChartLineVisualStyle _Default;
|
||||
|
||||
private ChartLineVisualStyle _OpenWhisker;
|
||||
private ChartLineVisualStyle _CloseWhisker;
|
||||
|
||||
private ChartLineVisualStyle _CenterLine;
|
||||
private ChartLineVisualStyle _MedianLine;
|
||||
|
||||
private ChartLineVisualStyle _HighWhisker;
|
||||
private ChartLineVisualStyle _LowWhisker;
|
||||
|
||||
private ChartLineVisualStyle _HighWhiskerCap;
|
||||
private ChartLineVisualStyle _LowWhiskerCap;
|
||||
|
||||
private Background _BoxBackground;
|
||||
private ChartLineVisualStyle _BoxBorder;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region BoxBackground
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Box Background (Box, Candle only).
|
||||
/// </summary>
|
||||
[Description("Indicates the the visual style for Box Background (Box, Candle only).")]
|
||||
public Background BoxBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BoxBackground == null)
|
||||
{
|
||||
_BoxBackground = Background.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _BoxBackground);
|
||||
}
|
||||
|
||||
return (_BoxBackground);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BoxBackground != value)
|
||||
{
|
||||
Background oldValue = _BoxBackground;
|
||||
|
||||
_BoxBackground = value;
|
||||
|
||||
OnStyleChanged("BoxBackground", oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBoxBackground()
|
||||
{
|
||||
return (_BoxBackground != null && _BoxBackground.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBoxBackground()
|
||||
{
|
||||
BoxBackground = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BoxBorder
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Box Border (Box, Candle only).
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Box Border (Box, Candle only).")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle BoxBorder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BoxBorder == null)
|
||||
{
|
||||
_BoxBorder = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _BoxBorder);
|
||||
}
|
||||
|
||||
return (_BoxBorder);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BoxBorder != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _BoxBorder;
|
||||
|
||||
_BoxBorder = value;
|
||||
|
||||
OnStyleChanged("BoxBorder", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CenterLine
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Center Line segment. This is the
|
||||
/// style used for the center Hilo segment and the Box/Candle segment when
|
||||
/// no Open or Close values are specified.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Center Line segment. This is the style used for the center Hilo segment and the Box/Candle segment when no Open or Close values are specified.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle CenterLine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CenterLine == null)
|
||||
{
|
||||
_CenterLine = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _CenterLine);
|
||||
}
|
||||
|
||||
return (_CenterLine);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_CenterLine != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _CenterLine;
|
||||
|
||||
_CenterLine = value;
|
||||
|
||||
OnStyleChanged("CenterLine", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CloseWhisker
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Close Whisker (Hilo only).
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Close Whisker (Hilo only).")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle CloseWhisker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CloseWhisker == null)
|
||||
{
|
||||
_CloseWhisker = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _CloseWhisker);
|
||||
}
|
||||
|
||||
return (_CloseWhisker);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_CloseWhisker != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _CloseWhisker;
|
||||
|
||||
_CloseWhisker = value;
|
||||
|
||||
OnStyleChanged("CloseWhisker", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Default
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style used as the Default when
|
||||
/// a segment style is not specified (ie BoxBorder, HighWhisker, etc).
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style used as the Default when a segment style is not specified (ie BoxBorder, HighWhisker, etc).")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle Default
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Default == null)
|
||||
{
|
||||
_Default = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _Default);
|
||||
}
|
||||
|
||||
return (_Default);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_Default != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _Default;
|
||||
|
||||
_Default = value;
|
||||
|
||||
OnStyleChanged("Default", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HighWhisker
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the High Whisker.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the High Whisker.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle HighWhisker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_HighWhisker == null)
|
||||
{
|
||||
_HighWhisker = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _HighWhisker);
|
||||
}
|
||||
|
||||
return (_HighWhisker);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_HighWhisker != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _HighWhisker;
|
||||
|
||||
_HighWhisker = value;
|
||||
|
||||
OnStyleChanged("HighWhisker", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HighWhiskerCap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the High Whisker Cap.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the High Whisker Cap.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle HighWhiskerCap
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_HighWhiskerCap == null)
|
||||
{
|
||||
_HighWhiskerCap = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _HighWhiskerCap);
|
||||
}
|
||||
|
||||
return (_HighWhiskerCap);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_HighWhiskerCap != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _HighWhiskerCap;
|
||||
|
||||
_HighWhiskerCap = value;
|
||||
|
||||
OnStyleChanged("HighWhiskerCap", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LowWhisker
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Low Whisker.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Low Whisker.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle LowWhisker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LowWhisker == null)
|
||||
{
|
||||
_LowWhisker = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _LowWhisker);
|
||||
}
|
||||
|
||||
return (_LowWhisker);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_LowWhisker != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _LowWhisker;
|
||||
|
||||
_LowWhisker = value;
|
||||
|
||||
OnStyleChanged("LowWhisker", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LowWhiskerCap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Low Whisker Cap.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Low Whisker Cap.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle LowWhiskerCap
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LowWhiskerCap == null)
|
||||
{
|
||||
_LowWhiskerCap = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _LowWhiskerCap);
|
||||
}
|
||||
|
||||
return (_LowWhiskerCap);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_LowWhiskerCap != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _LowWhiskerCap;
|
||||
|
||||
_LowWhiskerCap = value;
|
||||
|
||||
OnStyleChanged("LowWhiskerCap", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MedianLine
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Median Line.
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Median Line.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle MedianLine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MedianLine == null)
|
||||
{
|
||||
_MedianLine = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _MedianLine);
|
||||
}
|
||||
|
||||
return (_MedianLine);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_MedianLine != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _MedianLine;
|
||||
|
||||
_MedianLine = value;
|
||||
|
||||
OnStyleChanged("MedianLine", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenWhisker
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style for the Open Whisker (Hilo only).
|
||||
/// </summary>
|
||||
[Category("Style")]
|
||||
[Description("Indicates the visual style for the Open Whisker (Hilo only).")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public ChartLineVisualStyle OpenWhisker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_OpenWhisker == null)
|
||||
{
|
||||
_OpenWhisker = new ChartLineVisualStyle();
|
||||
|
||||
UpdateChangeHandler(null, _OpenWhisker);
|
||||
}
|
||||
|
||||
return (_OpenWhisker);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_OpenWhisker != value)
|
||||
{
|
||||
ChartLineVisualStyle oldValue = _OpenWhisker;
|
||||
|
||||
_OpenWhisker = value;
|
||||
|
||||
OnStyleChanged("OpenWhisker", oldValue, value);
|
||||
|
||||
if (oldValue != null)
|
||||
oldValue.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether both colors assigned are empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((_BoxBackground == null || _BoxBackground.IsEmpty) &&
|
||||
(_BoxBorder == null || _BoxBorder.IsEmpty) &&
|
||||
(_CenterLine == null || _CenterLine.IsEmpty) &&
|
||||
(_CloseWhisker == null || _CloseWhisker.IsEmpty) &&
|
||||
(_Default == null || _Default.IsEmpty) &&
|
||||
(_HighWhisker == null || _HighWhisker.IsEmpty) &&
|
||||
(_HighWhiskerCap == null || _HighWhiskerCap.IsEmpty) &&
|
||||
(_LowWhisker == null || _LowWhisker.IsEmpty) &&
|
||||
(_LowWhiskerCap == null || _LowWhiskerCap.IsEmpty) &&
|
||||
(_OpenWhisker == null || _OpenWhisker.IsEmpty) &&
|
||||
(_MedianLine == null || _MedianLine.IsEmpty) &&
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(HiLoBarSegmentStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style._BoxBackground != null && style._BoxBackground.IsEmpty == false)
|
||||
BoxBackground = style._BoxBackground.Copy();
|
||||
|
||||
if (style._BoxBorder != null && style._BoxBorder.IsEmpty == false)
|
||||
BoxBorder.ApplyStyle(style._BoxBorder);
|
||||
|
||||
if (style._CenterLine != null && style._CenterLine.IsEmpty == false)
|
||||
CenterLine.ApplyStyle(style._CenterLine);
|
||||
|
||||
if (style._CloseWhisker != null && style._CloseWhisker.IsEmpty == false)
|
||||
CloseWhisker.ApplyStyle(style._CloseWhisker);
|
||||
|
||||
if (style._Default != null && style._Default.IsEmpty == false)
|
||||
Default.ApplyStyle(style._Default);
|
||||
|
||||
if (style._HighWhisker != null && style._HighWhisker.IsEmpty == false)
|
||||
HighWhisker.ApplyStyle(style._HighWhisker);
|
||||
|
||||
if (style._HighWhiskerCap != null && style._HighWhiskerCap.IsEmpty == false)
|
||||
HighWhiskerCap.ApplyStyle(style._HighWhiskerCap);
|
||||
|
||||
if (style._LowWhisker != null && style._LowWhisker.IsEmpty == false)
|
||||
LowWhisker.ApplyStyle(style._LowWhisker);
|
||||
|
||||
if (style._LowWhiskerCap != null && style._LowWhiskerCap.IsEmpty == false)
|
||||
LowWhiskerCap.ApplyStyle(style._LowWhiskerCap);
|
||||
|
||||
if (style._MedianLine != null && style._MedianLine.IsEmpty == false)
|
||||
MedianLine.ApplyStyle(style._MedianLine);
|
||||
|
||||
if (style._OpenWhisker != null && style._OpenWhisker.IsEmpty == false)
|
||||
OpenWhisker.ApplyStyle(style._OpenWhisker);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the OhlcBarSegmentStyle.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the OhlcBarSegmentStyle.</returns>
|
||||
public new HiLoBarSegmentStyle Copy()
|
||||
{
|
||||
HiLoBarSegmentStyle style = new HiLoBarSegmentStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(HiLoBarSegmentStyle style)
|
||||
{
|
||||
style.BoxBackground = (_BoxBackground != null) ? _BoxBackground.Copy() : null;
|
||||
style.BoxBorder = (_BoxBorder != null) ? _BoxBorder.Copy() : null;
|
||||
style.CenterLine = (_CenterLine != null) ? _CenterLine.Copy() : null;
|
||||
style.CloseWhisker = (_CloseWhisker != null) ? _CloseWhisker.Copy() : null;
|
||||
style.Default = (_Default != null) ? _Default.Copy() : null;
|
||||
style.HighWhisker = (_HighWhisker != null) ? _HighWhisker.Copy() : null;
|
||||
style.HighWhiskerCap = (_HighWhiskerCap != null) ? _HighWhiskerCap.Copy() : null;
|
||||
style.LowWhisker = (_LowWhisker != null) ? _LowWhisker.Copy() : null;
|
||||
style.LowWhiskerCap = (_LowWhiskerCap != null) ? _LowWhiskerCap.Copy() : null;
|
||||
style.MedianLine = (_MedianLine != null) ? _MedianLine.Copy() : null;
|
||||
style.OpenWhisker = (_OpenWhisker != null) ? _OpenWhisker.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string serialName)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
if (serialName != null)
|
||||
{
|
||||
if (serialName.Equals("") == true)
|
||||
serialName = "HiLoBarSegmentStyle";
|
||||
|
||||
sec.AddStartElement(serialName);
|
||||
}
|
||||
|
||||
if (_BoxBackground != null && _BoxBackground.IsEmpty == false)
|
||||
sec.AddElement(_BoxBackground.GetSerialData("BoxBackground"));
|
||||
|
||||
if (_BoxBorder != null && _BoxBorder.IsEmpty == false)
|
||||
sec.AddElement(_BoxBorder.GetSerialData("BoxBorder"));
|
||||
|
||||
if (_CenterLine != null && _CenterLine.IsEmpty == false)
|
||||
sec.AddElement(_CenterLine.GetSerialData("CenterLine"));
|
||||
|
||||
if (_CloseWhisker != null && _CloseWhisker.IsEmpty == false)
|
||||
sec.AddElement(_CloseWhisker.GetSerialData("CloseWhisker"));
|
||||
|
||||
if (_Default != null && _Default.IsEmpty == false)
|
||||
sec.AddElement(_Default.GetSerialData("Default"));
|
||||
|
||||
if (_HighWhisker != null && _HighWhisker.IsEmpty == false)
|
||||
sec.AddElement(_HighWhisker.GetSerialData("HighWhisker"));
|
||||
|
||||
if (_HighWhiskerCap != null && _HighWhiskerCap.IsEmpty == false)
|
||||
sec.AddElement(_HighWhiskerCap.GetSerialData("HighWhiskerCap"));
|
||||
|
||||
if (_LowWhisker != null && _LowWhisker.IsEmpty == false)
|
||||
sec.AddElement(_LowWhisker.GetSerialData("LowWhisker"));
|
||||
|
||||
if (_LowWhiskerCap != null && _LowWhiskerCap.IsEmpty == false)
|
||||
sec.AddElement(_LowWhiskerCap.GetSerialData("LowWhiskerCap"));
|
||||
|
||||
if (_MedianLine != null && _MedianLine.IsEmpty == false)
|
||||
sec.AddElement(_MedianLine.GetSerialData("MedianLine"));
|
||||
|
||||
if (_OpenWhisker != null && _OpenWhisker.IsEmpty == false)
|
||||
sec.AddElement(_OpenWhisker.GetSerialData("OpenWhisker"));
|
||||
|
||||
sec.AddElement(base.GetSerialData(null));
|
||||
|
||||
if (serialName != null)
|
||||
sec.AddEndElement(serialName);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessCollection
|
||||
|
||||
internal override void ProcessCollection(SerialElement se)
|
||||
{
|
||||
SerialElementCollection sec = se.Sec;
|
||||
|
||||
switch (se.Name)
|
||||
{
|
||||
case "BoxBackground":
|
||||
sec.PutSerialData(BoxBackground);
|
||||
break;
|
||||
|
||||
case "BoxBorder":
|
||||
sec.PutSerialData(BoxBorder);
|
||||
break;
|
||||
|
||||
case "CenterLine":
|
||||
sec.PutSerialData(CenterLine);
|
||||
break;
|
||||
|
||||
case "CloseWhisker":
|
||||
sec.PutSerialData(CloseWhisker);
|
||||
break;
|
||||
|
||||
case "Default":
|
||||
sec.PutSerialData(Default);
|
||||
break;
|
||||
|
||||
case "HighWhisker":
|
||||
sec.PutSerialData(HighWhisker);
|
||||
break;
|
||||
|
||||
case "HighWhiskerCap":
|
||||
sec.PutSerialData(HighWhiskerCap);
|
||||
break;
|
||||
|
||||
case "LowWhisker":
|
||||
sec.PutSerialData(LowWhisker);
|
||||
break;
|
||||
|
||||
case "LowWhiskerCap":
|
||||
sec.PutSerialData(LowWhiskerCap);
|
||||
break;
|
||||
|
||||
case "MedianLine":
|
||||
sec.PutSerialData(MedianLine);
|
||||
break;
|
||||
|
||||
case "OpenWhisker":
|
||||
sec.PutSerialData(OpenWhisker);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessCollection(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
BoxBorder = null;
|
||||
CenterLine = null;
|
||||
CloseWhisker = null;
|
||||
Default = null;
|
||||
HighWhisker = null;
|
||||
HighWhiskerCap = null;
|
||||
LowWhisker = null;
|
||||
LowWhiskerCap = null;
|
||||
MedianLine = null;
|
||||
OpenWhisker = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.Charts.Style
|
||||
{
|
||||
///<summary>
|
||||
/// Padding
|
||||
///</summary>
|
||||
[TypeConverter(typeof(PaddingTypeConverter))]
|
||||
public class Padding : Thickness
|
||||
{
|
||||
#region Static data
|
||||
|
||||
/// <summary>
|
||||
/// Returns Empty instance of Thickness.
|
||||
/// </summary>
|
||||
public new static Padding Empty
|
||||
{
|
||||
get { return (new Padding()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initializes it.
|
||||
/// </summary>
|
||||
/// <param name="left">Left padding</param>
|
||||
/// <param name="right">Right padding</param>
|
||||
/// <param name="top">Top padding</param>
|
||||
/// <param name="bottom">Bottom padding</param>
|
||||
public Padding(int left, int top, int right, int bottom)
|
||||
: base(left, top, right, bottom)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Padding class.
|
||||
/// </summary>
|
||||
/// <param name="all">Uniform padding.</param>
|
||||
public Padding(int all)
|
||||
: base(all)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Padding class.
|
||||
/// </summary>
|
||||
public Padding()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the Padding.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the Padding.</returns>
|
||||
public new Padding Copy()
|
||||
{
|
||||
Padding copy = new Padding(Left, Top, Right, Bottom);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSerialData
|
||||
|
||||
internal override SerialElementCollection GetSerialData(string name)
|
||||
{
|
||||
SerialElementCollection sec = new SerialElementCollection();
|
||||
|
||||
sec.AddStartElement(name);
|
||||
|
||||
if (IsUniform == true)
|
||||
{
|
||||
sec.AddValue("All", Left, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
sec.AddValue("Left", Left, 0);
|
||||
sec.AddValue("Top", Top, 0);
|
||||
sec.AddValue("Right", Right, 0);
|
||||
sec.AddValue("Bottom", Bottom, 0);
|
||||
}
|
||||
|
||||
sec.AddEndElement(name);
|
||||
|
||||
return (sec);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutSerialData
|
||||
|
||||
#region ProcessValue
|
||||
|
||||
internal override void ProcessValue(SerialElement se)
|
||||
{
|
||||
switch (se.Name)
|
||||
{
|
||||
case "All":
|
||||
All = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "Left":
|
||||
Left = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "Top":
|
||||
Top = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "Right":
|
||||
Right = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
case "Bottom":
|
||||
Bottom = int.Parse(se.StringValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.ProcessValue(se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region PaddingTypeConverter
|
||||
|
||||
///<summary>
|
||||
/// PaddingTypeConverter
|
||||
///</summary>
|
||||
public class PaddingTypeConverter : ExpandableObjectConverter
|
||||
{
|
||||
#region CanConvertTo
|
||||
|
||||
/// <summary>
|
||||
/// CanConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override bool CanConvertTo(
|
||||
ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return (true);
|
||||
|
||||
return (base.CanConvertTo(context, destinationType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConvertTo
|
||||
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
Padding p = value as Padding;
|
||||
|
||||
if (p != null)
|
||||
{
|
||||
if (p.IsUniform == true)
|
||||
return (p.Left.ToString());
|
||||
|
||||
return (String.Format("{0:d}, {1:d}, {2:d}, {3:d}",
|
||||
p.Bottom, p.Left, p.Right, p.Top));
|
||||
}
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CanConvertFrom
|
||||
|
||||
/// <summary>
|
||||
/// CanConvertFrom
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="sourceType"></param>
|
||||
/// <returns></returns>
|
||||
public override bool CanConvertFrom(
|
||||
ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(string))
|
||||
return (true);
|
||||
|
||||
return (base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConvertFrom
|
||||
|
||||
/// <summary>
|
||||
/// ConvertFrom
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertFrom(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
if (value is string)
|
||||
{
|
||||
string[] values = ((string)value).Split(',');
|
||||
|
||||
if (values.Length != 1 && values.Length != 4)
|
||||
throw new ArgumentException("Invalid value to convert.");
|
||||
|
||||
try
|
||||
{
|
||||
int[] v = new int[values.Length];
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
v[i] = int.Parse(values[i]);
|
||||
|
||||
Padding p = (values.Length == 1)
|
||||
? new Padding(v[0])
|
||||
: new Padding(v[1], v[3], v[2], v[0]);
|
||||
|
||||
return (p);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new ArgumentException("Invalid value to convert.");
|
||||
}
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCreateInstanceSupported
|
||||
|
||||
/// <summary>
|
||||
/// GetCreateInstanceSupported
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateInstance
|
||||
|
||||
/// <summary>
|
||||
/// CreateInstance
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="propertyValues"></param>
|
||||
/// <returns></returns>
|
||||
public override object CreateInstance(
|
||||
ITypeDescriptorContext context, IDictionary propertyValues)
|
||||
{
|
||||
return (new Padding((int)propertyValues["Left"], (int)propertyValues["Top"],
|
||||
(int)propertyValues["Right"], (int)propertyValues["Bottom"]));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user