DotNet 4.8.1 build of DotNetBar

This commit is contained in:
2025-02-07 10:35:23 -05:00
parent 33439b63a0
commit 6b0a5d60f4
2609 changed files with 989814 additions and 7 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}
}

View File

@@ -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;
}
}
}

View File

@@ -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
}
}

View File

@@ -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;
}
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DevComponents.DotNetBar.Charts
{
public class TreeMap : BaseChart
{
}
}

View File

@@ -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
}
}

View File

@@ -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
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}