Commit 44b6ae61 HZH

折线图

1 个父辈 b59938b4
正在显示 35 个修改的文件 包含 584 行增加2166 行删除
using System.Drawing;
namespace HZH_Controls.Controls
{
public class AuxiliaryLable
{
public string Text
{
get;
set;
}
public Brush TextBrush
{
get;
set;
}
public Brush TextBack
{
get;
set;
}
public float LocationX
{
get;
set;
}
public AuxiliaryLable()
{
TextBrush = Brushes.Black;
TextBack = Brushes.Transparent;
LocationX = 0.5f;
}
}
}
...@@ -25,110 +25,64 @@ namespace HZH_Controls.Controls ...@@ -25,110 +25,64 @@ namespace HZH_Controls.Controls
/// <seealso cref="System.IDisposable" /> /// <seealso cref="System.IDisposable" />
internal class AuxiliaryLine : IDisposable internal class AuxiliaryLine : IDisposable
{ {
private string tip;
/// <summary>
/// Gets or sets the tip.
/// </summary>
/// <value>The tip.</value>
public string Tip
{
get { return tip; }
set { tip = value; }
}
/// <summary>
/// The disposed value
/// </summary>
private bool disposedValue = false; private bool disposedValue = false;
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>The value.</value>
public float Value public float Value
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the paint value.
/// </summary>
/// <value>The paint value.</value>
public float PaintValue public float PaintValue
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the paint value back up.
/// </summary>
/// <value>The paint value back up.</value>
public float PaintValueBackUp public float PaintValueBackUp
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the color of the line.
/// </summary>
/// <value>The color of the line.</value>
public Color LineColor public Color LineColor
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the pen dash.
/// </summary>
/// <value>The pen dash.</value>
public Pen PenDash public Pen PenDash
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the pen solid.
/// </summary>
/// <value>The pen solid.</value>
public Pen PenSolid public Pen PenSolid
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the line thickness.
/// </summary>
/// <value>The line thickness.</value>
public float LineThickness public float LineThickness
{ {
get; get;
set; set;
} }
/// <summary>
/// Gets or sets the line text brush.
/// </summary>
/// <value>The line text brush.</value>
public Brush LineTextBrush public Brush LineTextBrush
{ {
get; get;
set; set;
} }
/// <summary> public bool IsLeftFrame
/// The is dash style {
/// </summary> get;
set;
}
private bool isDashStyle = true; private bool isDashStyle = true;
/// <summary>
/// Gets or sets a value indicating whether this instance is dash style.
/// </summary>
/// <value><c>true</c> if this instance is dash style; otherwise, <c>false</c>.</value>
public bool IsDashStyle public bool IsDashStyle
{ {
get { return isDashStyle; } get { return isDashStyle; }
...@@ -136,40 +90,30 @@ namespace HZH_Controls.Controls ...@@ -136,40 +90,30 @@ namespace HZH_Controls.Controls
} }
/// <summary>
/// Gets the pen.
/// </summary>
/// <returns>Pen.</returns>
public Pen GetPen() public Pen GetPen()
{ {
return IsDashStyle ? PenDash : PenSolid; return IsDashStyle ? PenDash : PenSolid;
} }
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (!disposedValue) if (!disposedValue)
{ {
if (disposing) if (disposing)
{ {
if(PenDash!=null) if(PenDash==null)
PenDash.Dispose(); PenDash.Dispose();
if(PenSolid!=null) if(PenSolid==null)
PenSolid.Dispose(); PenSolid.Dispose();
if(LineTextBrush!=null) if(LineTextBrush==null)
LineTextBrush.Dispose(); LineTextBrush.Dispose();
} }
disposedValue = true; disposedValue = true;
} }
} }
/// <summary> public string Tip { get; set; }
/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
/// </summary>
public void Dispose() public void Dispose()
{ {
Dispose(true); Dispose(true);
......
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisCollection.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.Collections.ObjectModel;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class AxisCollection.
/// Implements the <see cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.Axis}" />
/// </summary>
/// <seealso cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.Axis}" />
public class AxisCollection : Collection<Axis>
{
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
public UCChart Chart
{
get;
internal set;
}
/// <summary>
/// Gets the type.
/// </summary>
/// <value>The type.</value>
public AxisType Type
{
get;
internal set;
}
/// <summary>
/// Inserts the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected override void InsertItem(int index, Axis item)
{
base.InsertItem(index, item);
item.Chart = Chart;
item.Type = Type;
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Sets the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected override void SetItem(int index, Axis item)
{
base.SetItem(index, item);
item.Chart = Chart;
item.Type = Type;
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Clears the items.
/// </summary>
protected override void ClearItems()
{
base.ClearItems();
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Removes the item.
/// </summary>
/// <param name="index">The index.</param>
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
if(Chart!=null)Chart.Invalidate();
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisFormat.cs">
// Copyright by Huang Zhenghui(»ÆÕý»Ô) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub£ºhttps://github.com/kwwwvagaa/NetWinformControl
// gitee£ºhttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.Drawing;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class AxisFormat.
/// </summary>
public class AxisFormat
{
/// <summary>
/// The title angle axis y
/// </summary>
public const int TitleAngleAxisY = -90;
/// <summary>
/// The title format right axis y
/// </summary>
static StringFormat titleFormatRightAxisY = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Far
};
/// <summary>
/// Gets or sets the title format right axis y.
/// </summary>
/// <value>The title format right axis y.</value>
public static StringFormat TitleFormatRightAxisY
{
get { return titleFormatRightAxisY; }
set { titleFormatRightAxisY = value; }
}
/// <summary>
/// The title format left axis y
/// </summary>
static StringFormat titleFormatLeftAxisY = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Near
};
/// <summary>
/// Gets or sets the title format left axis y.
/// </summary>
/// <value>The title format left axis y.</value>
public static StringFormat TitleFormatLeftAxisY
{
get { return titleFormatLeftAxisY; }
set { titleFormatLeftAxisY = value; }
}
/// <summary>
/// The label format left axis y
/// </summary>
static StringFormat labelFormatLeftAxisY = new StringFormat
{
Alignment = StringAlignment.Far,
LineAlignment = StringAlignment.Center
};
/// <summary>
/// Gets or sets the label format left axis y.
/// </summary>
/// <value>The label format left axis y.</value>
public static StringFormat LabelFormatLeftAxisY
{
get { return labelFormatLeftAxisY; }
set { labelFormatLeftAxisY = value; }
}
/// <summary>
/// The label format right axis y
/// </summary>
static StringFormat labelFormatRightAxisY = new StringFormat
{
Alignment = StringAlignment.Near,
LineAlignment = StringAlignment.Center
};
/// <summary>
/// Gets or sets the label format right axis y.
/// </summary>
/// <value>The label format right axis y.</value>
public static StringFormat LabelFormatRightAxisY
{
get { return AxisFormat.labelFormatRightAxisY; }
set { AxisFormat.labelFormatRightAxisY = value; }
}
/// <summary>
/// The title format top axis x
/// </summary>
static StringFormat titleFormatTopAxisX = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Near
};
/// <summary>
/// Gets or sets the title format top axis x.
/// </summary>
/// <value>The title format top axis x.</value>
public static StringFormat TitleFormatTopAxisX
{
get { return AxisFormat.titleFormatTopAxisX; }
set { AxisFormat.titleFormatTopAxisX = value; }
}
/// <summary>
/// The title format bottom axis x
/// </summary>
static StringFormat titleFormatBottomAxisX = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Far
};
/// <summary>
/// Gets or sets the title format bottom axis x.
/// </summary>
/// <value>The title format bottom axis x.</value>
public static StringFormat TitleFormatBottomAxisX
{
get { return AxisFormat.titleFormatBottomAxisX; }
set { AxisFormat.titleFormatBottomAxisX = value; }
}
/// <summary>
/// The label format top axis x
/// </summary>
static StringFormat labelFormatTopAxisX = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Far
};
/// <summary>
/// Gets or sets the label format top axis x.
/// </summary>
/// <value>The label format top axis x.</value>
public static StringFormat LabelFormatTopAxisX
{
get { return AxisFormat.labelFormatTopAxisX; }
set { AxisFormat.labelFormatTopAxisX = value; }
}
/// <summary>
/// The label format bottom axis x
/// </summary>
static StringFormat labelFormatBottomAxisX = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Near
};
/// <summary>
/// Gets or sets the label format bottom axis x.
/// </summary>
/// <value>The label format bottom axis x.</value>
public static StringFormat LabelFormatBottomAxisX
{
get { return AxisFormat.labelFormatBottomAxisX; }
set { AxisFormat.labelFormatBottomAxisX = value; }
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisPosition.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace HZH_Controls.Controls
{
/// <summary>
/// Enum AxisPosition
/// </summary>
public enum AxisPosition
{
/// <summary>
/// The left bottom
/// </summary>
LeftBottom,
/// <summary>
/// The right top
/// </summary>
RightTop
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisType.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace HZH_Controls.Controls
{
/// <summary>
/// Enum AxisType
/// </summary>
public enum AxisType
{
/// <summary>
/// The x
/// </summary>
X,
/// <summary>
/// The y
/// </summary>
Y
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPoint.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.ComponentModel;
using System.Drawing;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class ChartPoint.
/// </summary>
[TypeConverter(typeof(ExpandableObjectConverter))]
public class ChartPoint
{
/// <summary>
/// The chart
/// </summary>
private UCChart _chart;
/// <summary>
/// The series
/// </summary>
private SeriesBase _series;
/// <summary>
/// The x
/// </summary>
private double _x;
/// <summary>
/// The y
/// </summary>
private double _y;
/// <summary>
/// The label
/// </summary>
private string _label;
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
[Browsable(false)]
public UCChart Chart
{
get
{
return _chart;
}
internal set
{
_chart = value;
}
}
/// <summary>
/// Gets the series.
/// </summary>
/// <value>The series.</value>
[Browsable(false)]
public SeriesBase Series
{
get
{
return _series;
}
internal set
{
_series = value;
}
}
/// <summary>
/// Gets the parent axis x.
/// </summary>
/// <value>The parent axis x.</value>
[Browsable(false)]
public Axis ParentAxisX
{
get
{
if (_series != null)
{
return _series.ParentAxisX;
}
return null;
}
}
/// <summary>
/// Gets the parent axis y.
/// </summary>
/// <value>The parent axis y.</value>
[Browsable(false)]
public Axis ParentAxisY
{
get
{
if (_series != null)
{
return _series.ParentAxisY;
}
return null;
}
}
/// <summary>
/// Gets or sets the x.
/// </summary>
/// <value>The x.</value>
public double X
{
get
{
return _x;
}
set
{
if (_x != value)
{
_x = value;
if(_chart!=null)
_chart.Invalidate();
OnValueChanged(new EventArgs());
}
}
}
/// <summary>
/// Gets or sets the y.
/// </summary>
/// <value>The y.</value>
public double Y
{
get
{
return _y;
}
set
{
if (_y != value)
{
_y = value;
if(_chart!=null)
_chart.Invalidate();
OnValueChanged(new EventArgs());
}
}
}
/// <summary>
/// Gets or sets the label.
/// </summary>
/// <value>The label.</value>
public string Label
{
get
{
return _label;
}
set
{
if (_label != value)
{
_label = value;
if(_chart!=null)
_chart.Invalidate();
OnLabelChanged(new EventArgs());
}
}
}
/// <summary>
/// Gets the left.
/// </summary>
/// <value>The left.</value>
[Browsable(false)]
public int Left
{
get
{
int num = (_chart != null) ? _chart.OffsetX : 0;
return (int)(Series.CountLeft(X) + (float)num);
}
}
/// <summary>
/// Gets the top.
/// </summary>
/// <value>The top.</value>
[Browsable(false)]
public int Top
{
get
{
int num = (_chart != null) ? _chart.OffsetY : 0;
return (int)(Series.CountTop(Y) + (float)num);
}
}
/// <summary>
/// Gets the location.
/// </summary>
/// <value>The location.</value>
[Browsable(false)]
public Point Location { get { return new Point(Left, Top); } }
/// <summary>
/// Occurs when [value changed].
/// </summary>
public event EventHandler ValueChanged;
/// <summary>
/// Occurs when [label changed].
/// </summary>
public event EventHandler LabelChanged;
/// <summary>
/// Initializes a new instance of the <see cref="ChartPoint"/> class.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
public ChartPoint(double x, double y)
{
_x = x;
_y = y;
}
/// <summary>
/// Initializes a new instance of the <see cref="ChartPoint"/> class.
/// </summary>
public ChartPoint()
: this(0.0, 0.0)
{
}
/// <summary>
/// Handles the <see cref="E:ValueChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void OnValueChanged(EventArgs e)
{
if(this.ValueChanged!=null)
this.ValueChanged.Invoke(this, e);
}
/// <summary>
/// Handles the <see cref="E:LabelChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void OnLabelChanged(EventArgs e)
{
if(this.LabelChanged!=null)
this.LabelChanged.Invoke(this, e);
}
/// <summary>
/// Gets the label from axis x.
/// </summary>
/// <returns>System.String.</returns>
public string GetLabelFromAxisX()
{
if (ParentAxisX != null)
{
return ParentAxisX.GetLabel(_x);
}
return null;
}
/// <summary>
/// Gets the label from axis y.
/// </summary>
/// <returns>System.String.</returns>
public string GetLabelFromAxisY()
{
if (ParentAxisY != null)
{
return ParentAxisY.GetLabel(_y);
}
return null;
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPointCollection.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.Collections.ObjectModel;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class ChartPointCollection.
/// Implements the <see cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.ChartPoint}" />
/// </summary>
/// <seealso cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.ChartPoint}" />
public class ChartPointCollection : Collection<ChartPoint>
{
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
public UCChart Chart
{
get;
internal set;
}
/// <summary>
/// Gets the series.
/// </summary>
/// <value>The series.</value>
public SeriesBase Series
{
get;
internal set;
}
/// <summary>
/// Inserts the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected override void InsertItem(int index, ChartPoint item)
{
base.InsertItem(index, item);
item.Chart = Chart;
item.Series = Series;
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Sets the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected override void SetItem(int index, ChartPoint item)
{
base.SetItem(index, item);
item.Chart = Chart;
item.Series = Series;
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Clears the items.
/// </summary>
protected override void ClearItems()
{
base.ClearItems();
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Removes the item.
/// </summary>
/// <param name="index">The index.</param>
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
if(Chart!=null)Chart.Invalidate();
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPointEventArgs.cs">
// Copyright by Huang Zhenghui(»ÆÕý»Ô) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub£ºhttps://github.com/kwwwvagaa/NetWinformControl
// gitee£ºhttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class ChartPointEventArgs.
/// Implements the <see cref="System.EventArgs" />
/// </summary>
/// <seealso cref="System.EventArgs" />
public class ChartPointEventArgs : EventArgs
{
/// <summary>
/// Gets the point.
/// </summary>
/// <value>The point.</value>
public ChartPoint[] Point
{
get;
private set;
}
/// <summary>
/// Gets or sets the content.
/// </summary>
/// <value>The content.</value>
public string Content
{
get;
set;
}
/// <summary>
/// Initializes a new instance of the <see cref="ChartPointEventArgs"/> class.
/// </summary>
/// <param name="point">The point.</param>
/// <param name="content">The content.</param>
public ChartPointEventArgs(ChartPoint[] point = null, string content = null)
{
Point = point;
Content = content;
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPointEventHandler.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace HZH_Controls.Controls
{
/// <summary>
/// Delegate ChartPointEventHandler
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="ChartPointEventArgs"/> instance containing the event data.</param>
public delegate void ChartPointEventHandler(object sender, ChartPointEventArgs e);
}
using System.Drawing;
namespace HZH_Controls.Controls
{
public class CurveItem
{
public float[] Data = null;
public string[] MarkText = null;
public float LineThickness
{
get;
set;
}
public bool IsSmoothCurve
{
get;
set;
}
public Color LineColor
{
get;
set;
}
public bool IsLeftFrame
{
get;
set;
}
public bool Visible
{
get;
set;
}
public bool LineRenderVisiable
{
get;
set;
}
public RectangleF TitleRegion
{
get;
set;
}
private string renderFormat = "{0}";
public string RenderFormat
{
get { return renderFormat; }
set { renderFormat = value; }
}
public CurveItem()
{
LineThickness = 1f;
IsLeftFrame = true;
Visible = true;
LineRenderVisiable = true;
TitleRegion = new RectangleF(0f, 0f, 0f, 0f);
}
}
}
// *********************************************************************** // ***********************************************************************
// Assembly : HZH_Controls // Assembly : HZH_Controls
// Created : 2019-09-17 // Created : 2019-09-23
// //
// *********************************************************************** // ***********************************************************************
// <copyright file="AxisLabel.cs"> // <copyright file="MarkText.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright> // </copyright>
// //
...@@ -13,74 +13,101 @@ ...@@ -13,74 +13,101 @@
// //
// If you use this code, please keep this note. // If you use this code, please keep this note.
// *********************************************************************** // ***********************************************************************
using System.ComponentModel; using System.Drawing;
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
/// <summary> /// <summary>
/// Class AxisLabel. /// Class MarkText.
/// </summary> /// </summary>
[TypeConverter(typeof(ExpandableObjectConverter))] public class MarkText
public class AxisLabel
{ {
/// <summary> /// <summary>
/// The content /// The mark text offect
/// </summary> /// </summary>
private string _content; public static readonly int MarkTextOffect = 5;
/// <summary> /// <summary>
/// The value /// Gets or sets the curve key.
/// </summary> /// </summary>
private double _value; /// <value>The curve key.</value>
public string CurveKey
{
get;
set;
}
/// <summary> /// <summary>
/// Gets or sets the content. /// Gets or sets the index.
/// </summary> /// </summary>
/// <value>The content.</value> /// <value>The index.</value>
public string Content public int Index
{
get
{ {
return _content; get;
} set;
set
{
_content = value;
}
} }
/// <summary> /// <summary>
/// Gets or sets the value. /// Gets or sets the mark text.
/// </summary> /// </summary>
/// <value>The value.</value> /// <value>The mark text.</value>
public double Value public string Text
{ {
get get;
{ set;
return _value;
} }
set
private Color? textColor = null;
public Color? TextColor
{ {
_value = value; get { return textColor; }
} set { textColor = value; }
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AxisLabel"/> class. /// The position style
/// </summary> /// </summary>
/// <param name="value">The value.</param> private MarkTextPositionStyle positionStyle = MarkTextPositionStyle.Auto;
public AxisLabel(double value)
/// <summary>
/// Gets or sets the position style.
/// </summary>
/// <value>The position style.</value>
public MarkTextPositionStyle PositionStyle
{ {
_value = value; get { return positionStyle; }
_content = _value.ToString(); set { positionStyle = value; }
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AxisLabel"/> class. /// Calculates the index of the direction from data.
/// </summary> /// </summary>
public AxisLabel() /// <param name="data">The data.</param>
: this(0.0) /// <param name="Index">The index.</param>
/// <returns>MarkTextPositionStyle.</returns>
public static MarkTextPositionStyle CalculateDirectionFromDataIndex(float[] data, int Index)
{
float num = (Index == 0) ? data[Index] : data[Index - 1];
float num2 = (Index == data.Length - 1) ? data[Index] : data[Index + 1];
if (num < data[Index] && data[Index] < num2)
{
return MarkTextPositionStyle.Left;
}
if (num > data[Index] && data[Index] > num2)
{ {
return MarkTextPositionStyle.Right;
}
if (num <= data[Index] && data[Index] >= num2)
{
return MarkTextPositionStyle.Up;
}
if (num >= data[Index] && data[Index] <= num2)
{
return MarkTextPositionStyle.Down;
}
return MarkTextPositionStyle.Up;
} }
} }
} }
namespace HZH_Controls.Controls
{
public enum MarkTextPositionStyle
{
Up = 1,
Right = 2,
Down = 4,
Left = 8,
Auto = 16
}
}
...@@ -32,11 +32,6 @@ namespace HZH_Controls.Controls ...@@ -32,11 +32,6 @@ namespace HZH_Controls.Controls
public class UCPieChart : UserControl public class UCPieChart : UserControl
{ {
/// <summary> /// <summary>
/// The percent color
/// </summary>
private Color percentColor = Color.DodgerBlue;
/// <summary>
/// The pie items /// The pie items
/// </summary> /// </summary>
private PieItem[] pieItems = new PieItem[0]; private PieItem[] pieItems = new PieItem[0];
...@@ -312,25 +307,7 @@ namespace HZH_Controls.Controls ...@@ -312,25 +307,7 @@ namespace HZH_Controls.Controls
} }
} }
/// <summary>
/// Sets the margin paint.
/// </summary>
/// <param name="value">The value.</param>
private void SetMarginPaint(int value)
{
if (value > 500)
{
margin = 80;
}
else if (value > 300)
{
margin = 60;
}
else
{
margin = 40;
}
}
/// <summary> /// <summary>
/// Gets the center point. /// Gets the center point.
...@@ -343,17 +320,6 @@ namespace HZH_Controls.Controls ...@@ -343,17 +320,6 @@ namespace HZH_Controls.Controls
return new Point(base.Width / 2 - 1, base.Height / 2 + (titleSize != SizeF.Empty ? ((int)titleSize.Height) : 0) - 1); return new Point(base.Width / 2 - 1, base.Height / 2 + (titleSize != SizeF.Empty ? ((int)titleSize.Height) : 0) - 1);
} }
/// <summary>
/// Gets the random color.
/// </summary>
/// <returns>Color.</returns>
private Color GetRandomColor()
{
int num = random.Next(256);
int num2 = random.Next(256);
int blue = (num + num2 > 430) ? random.Next(100) : random.Next(200);
return Color.FromArgb(num, num2, blue);
}
/// <summary> /// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。 /// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
...@@ -370,12 +336,9 @@ namespace HZH_Controls.Controls ...@@ -370,12 +336,9 @@ namespace HZH_Controls.Controls
{ {
if (!string.IsNullOrEmpty(title)) if (!string.IsNullOrEmpty(title))
e.Graphics.DrawString(title, titleFont, new SolidBrush(titleFroeColor), new PointF((this.Width - titleSize.Width) / 2, 5)); e.Graphics.DrawString(title, titleFont, new SolidBrush(titleFroeColor), new PointF((this.Width - titleSize.Width) / 2, 5));
//e.Graphics.FillEllipse(Brushes.AliceBlue, rectangle);
//e.Graphics.DrawEllipse(Pens.DodgerBlue, rectangle);
Rectangle rect = new Rectangle(rectangle.X - centerPoint.X, rectangle.Y - centerPoint.Y, rectangle.Width, rectangle.Height); Rectangle rect = new Rectangle(rectangle.X - centerPoint.X, rectangle.Y - centerPoint.Y, rectangle.Width, rectangle.Height);
e.Graphics.TranslateTransform(centerPoint.X, centerPoint.Y); e.Graphics.TranslateTransform(centerPoint.X, centerPoint.Y);
e.Graphics.RotateTransform(90f); e.Graphics.RotateTransform(90f);
e.Graphics.DrawLine(Pens.DimGray, 0, 0, width, 0);
int num = pieItems.Sum((PieItem item) => item.Value); int num = pieItems.Sum((PieItem item) => item.Value);
float num2 = 0f; float num2 = 0f;
float num3 = -90f; float num3 = -90f;
...@@ -460,7 +423,7 @@ namespace HZH_Controls.Controls ...@@ -460,7 +423,7 @@ namespace HZH_Controls.Controls
{ {
e.Graphics.FillEllipse(Brushes.AliceBlue, rectangle); e.Graphics.FillEllipse(Brushes.AliceBlue, rectangle);
e.Graphics.DrawEllipse(Pens.DodgerBlue, rectangle); e.Graphics.DrawEllipse(Pens.DodgerBlue, rectangle);
e.Graphics.DrawString("", Font, Brushes.DimGray, rectangle, formatCenter); e.Graphics.DrawString("无数据", Font, Brushes.DimGray, rectangle, formatCenter);
} }
base.OnPaint(e); base.OnPaint(e);
} }
......
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SelectMode.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace HZH_Controls.Controls
{
/// <summary>
/// Enum SelectMode
/// </summary>
public enum SelectMode
{
/// <summary>
/// The both
/// </summary>
Both,
/// <summary>
/// The x
/// </summary>
X,
/// <summary>
/// The y
/// </summary>
Y
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="BezierSeries.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class BezierSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public class BezierSeries : SeriesBase
{
/// <summary>
/// The thickness
/// </summary>
private float _thickness = 1.8f;
/// <summary>
/// Gets or sets the thickness.
/// </summary>
/// <value>The thickness.</value>
[Category("自定义")]
[Description("图形宽度。")]
[DefaultValue(1.8f)]
public float Thickness
{
get
{
return _thickness;
}
set
{
_thickness = value;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal override void Draw(Graphics g)
{
PointF[] locationArray = GetLocationArray();
if (locationArray != null && locationArray.Length > 3)
{
int num = locationArray.Length % 3;
int num2 = locationArray.Length / 3;
int num3 = (num != 0) ? 1 : (-2);
PointF[] points = locationArray.Take(3 * num2 + num3).ToArray();
using (Pen pen = new Pen(base.Color, Thickness))
{
g.DrawBeziers(pen, points);
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected override void PaintLegend(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
PointF[] points = new PointF[4]
{
new PointF(0f, (float)base.Legend.Height / 2f),
new PointF(3f, 0f),
new PointF(9f, base.Legend.Height),
new PointF(12f, (float)base.Legend.Height / 2f)
};
using (Pen pen = new Pen(base.Color, _thickness))
{
e.Graphics.DrawBeziers(pen, points);
}
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ColumnSeries.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class ColumnSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public class ColumnSeries : SeriesBase
{
/// <summary>
/// The width
/// </summary>
private int _width = 24;
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[Category("自定义")]
[Description("图形宽度。")]
[DefaultValue(24)]
public int Width
{
get
{
return _width;
}
set
{
_width = value;
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected override void PaintLegend(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
using (SolidBrush brush = new SolidBrush(base.Color))
{
e.Graphics.FillRectangle(brush, 2f, ((float)base.Legend.Height - 16f) / 2f, 12f, 16f);
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="border">The border.</param>
/// <param name="sum">The sum.</param>
/// <param name="series">The series.</param>
internal static void Draw(Graphics g, Rectangle border, int sum, ColumnSeries[] series)
{
int num = series.Count();
float num2 = 0f;
for (int i = 0; i < num; i++)
{
num2 += (float)series[i].Width;
}
if (!(num2 > 0f))
{
return;
}
num2 += (float)(num - 1) * 3f;
float num3 = border.Width;
float num4 = num3 / (float)sum;
float num5 = (float)border.Left + num4 - num2 / 2f;
for (int j = 0; j < num; j++)
{
if (series[j].Visible)
{
PointF[] locationArray = series[j].GetLocationArray();
if (locationArray != null && locationArray.Length != 0)
{
using (SolidBrush brush = new SolidBrush(series[j].Color))
{
for (int k = 0; k < locationArray.Length; k++)
{
float x = num5 + num4 * (float)k;
float y = locationArray[k].Y;
float width = series[j].Width;
float height = (float)border.Bottom - locationArray[k].Y - 1f;
RectangleF rect = new RectangleF(x, y, width, height);
g.FillRectangle(brush, rect);
}
}
}
num5 += (float)series[j].Width + 3f;
}
}
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="LabelSeries.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class LabelSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public class LabelSeries : SeriesBase
{
/// <summary>
/// The width
/// </summary>
private int _width = 12;
/// <summary>
/// The height
/// </summary>
private int _height = 12;
/// <summary>
/// The font
/// </summary>
private Font _font = new Font("微软雅黑", 10f);
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[Category("自定义")]
[Description("图形宽度。")]
[DefaultValue(12)]
public int Width
{
get
{
return _width;
}
set
{
_width = value;
}
}
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>The height.</value>
[Category("自定义")]
[Description("图形高度。")]
[DefaultValue(12)]
public int Height
{
get
{
return _height;
}
set
{
_height = value;
}
}
/// <summary>
/// Gets or sets the font.
/// </summary>
/// <value>The font.</value>
[Category("自定义")]
[Description("字体。")]
public Font Font
{
get
{
return _font;
}
set
{
_font = value;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal override void Draw(Graphics g)
{
if (base.Points.Count > 0)
{
using (SolidBrush brush = new SolidBrush(base.Color))
{
foreach (ChartPoint point2 in base.Points)
{
int left = point2.Left;
int top = point2.Top;
Point[] points = new Point[3]
{
new Point(left, top),
new Point(left - _width / 2, top - _height),
new Point(left + _width / 2, top - _height)
};
g.FillPolygon(brush, points);
if (!string.IsNullOrEmpty(point2.Label))
{
g.DrawString(point: new Point(left, top - _height), s: point2.Label, font: _font, brush: brush, format: SeriesFormat.LabelFormat);
}
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected override void PaintLegend(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
float num = ((float)base.Legend.Height - 12f) / 2f;
PointF[] points = new PointF[3]
{
new PointF(0f, num),
new PointF(12f, num),
new PointF(6f, num + 12f)
};
using (SolidBrush brush = new SolidBrush(base.Color))
{
e.Graphics.FillPolygon(brush, points);
}
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="LineSeries.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class LineSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public class LineSeries : SeriesBase
{
/// <summary>
/// The thickness
/// </summary>
private float _thickness = 1.8f;
/// <summary>
/// The curve tension
/// </summary>
private float _curveTension = 0f;
/// <summary>
/// The fill graph
/// </summary>
private bool _fillGraph = true;
/// <summary>
/// The point visible
/// </summary>
private bool _pointVisible = false;
/// <summary>
/// The value visible
/// </summary>
private bool _valueVisible = false;
/// <summary>
/// The font
/// </summary>
private Font _font = new Font("微软雅黑", 10f);
/// <summary>
/// Gets or sets the thickness.
/// </summary>
/// <value>The thickness.</value>
[Category("自定义")]
[Description("图形宽度。")]
[DefaultValue(1.8f)]
public float Thickness
{
get
{
return _thickness;
}
set
{
_thickness = value;
}
}
/// <summary>
/// Gets or sets the curve tension.
/// </summary>
/// <value>The curve tension.</value>
[Category("自定义")]
[Description("曲线张力。")]
[DefaultValue(0f)]
public float CurveTension
{
get
{
return _curveTension;
}
set
{
_curveTension = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether [fill graph].
/// </summary>
/// <value><c>true</c> if [fill graph]; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("是否填充图形。")]
[DefaultValue(true)]
public bool FillGraph
{
get
{
return _fillGraph;
}
set
{
_fillGraph = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether [point visible].
/// </summary>
/// <value><c>true</c> if [point visible]; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("显示/隐藏点状图形。")]
[DefaultValue(false)]
public bool PointVisible
{
get
{
return _pointVisible;
}
set
{
_pointVisible = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether [value visible].
/// </summary>
/// <value><c>true</c> if [value visible]; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("显示/隐藏当前值。")]
[DefaultValue(false)]
public bool ValueVisible
{
get
{
return _valueVisible;
}
set
{
_valueVisible = value;
}
}
/// <summary>
/// Gets or sets the font.
/// </summary>
/// <value>The font.</value>
[Category("自定义")]
[Description("字体。")]
public Font Font
{
get
{
return _font;
}
set
{
_font = value;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal override void Draw(Graphics g)
{
PointF[] locationArray = GetLocationArray();
if (locationArray != null && locationArray.Length > 1)
{
using (Pen pen = new Pen(base.Color, Thickness))
{
if (CurveTension > 0f)
{
g.DrawCurve(pen, locationArray, CurveTension);
}
else
{
g.DrawLines(pen, locationArray);
}
}
if (FillGraph && base.ParentAxisY != null)
{
double yValue = base.ParentAxisY.IsReverse ? base.ParentAxisY.MaxValue : base.ParentAxisY.MinValue;
int num = (int)Math.Round(CountTop(yValue));
PointF[] array = new PointF[locationArray.Length + 2];
locationArray.CopyTo(array, 0);
array[array.Length - 1] = new PointF(locationArray[0].X, num);
array[array.Length - 2] = new PointF(locationArray[locationArray.Length - 1].X, num);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(50, base.Color)))
{
g.FillPolygon(brush, array);
}
}
}
if (base.Points.Count > 0 && (_pointVisible || _valueVisible))
{
using (SolidBrush brush2 = new SolidBrush(base.Color))
{
if (_pointVisible)
{
float num2 = 4f * _thickness;
foreach (ChartPoint point in base.Points)
{
int num3 = (int)Math.Round((float)point.Left - 2f * _thickness);
int num4 = (int)Math.Round((float)point.Top - 2f * _thickness);
g.FillEllipse(brush2, num3, num4, num2, num2);
}
}
if (_valueVisible)
{
ChartPoint chartPoint = base.Points.Last();
string text = chartPoint.Y.ToString();
if (!string.IsNullOrEmpty(text))
{
g.DrawString(text, _font, brush2, new Point(chartPoint.Left, chartPoint.Top), SeriesFormat.LabelFormat);
}
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected override void PaintLegend(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
float num = ((float)base.Legend.Height - _thickness) / 2f;
using (Pen pen = new Pen(base.Color, _thickness))
{
e.Graphics.DrawLine(pen, 0f, num, 12f, num);
}
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="PointSeries.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class PointSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public class PointSeries : SeriesBase
{
/// <summary>
/// The width
/// </summary>
private int _width = 8;
/// <summary>
/// The height
/// </summary>
private int _height = 8;
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[Category("自定义")]
[Description("图形宽度。")]
[DefaultValue(8)]
public int Width
{
get
{
return _width;
}
set
{
_width = value;
}
}
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>The height.</value>
[Category("自定义")]
[Description("图形高度。")]
[DefaultValue(8)]
public int Height
{
get
{
return _height;
}
set
{
_height = value;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal override void Draw(Graphics g)
{
if (base.Points.Count > 0)
{
using (SolidBrush brush = new SolidBrush(base.Color))
{
foreach (ChartPoint point in base.Points)
{
float x = (float)point.Left - (float)_width / 2f;
float y = (float)point.Top - (float)_height / 2f;
g.FillEllipse(brush, x, y, _width, _height);
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected override void PaintLegend(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
using (SolidBrush brush = new SolidBrush(base.Color))
{
e.Graphics.FillEllipse(brush, 2f, (float)(base.Legend.Height - 8) / 2f, 8f, 8f);
}
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="StandardLineSeries.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class StandardLineSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public class StandardLineSeries : SeriesBase
{
/// <summary>
/// The thickness
/// </summary>
private float _thickness = 1f;
/// <summary>
/// The horizontat line visible
/// </summary>
private bool _horizontatLineVisible = true;
/// <summary>
/// The vertical line visible
/// </summary>
private bool _verticalLineVisible = true;
/// <summary>
/// Gets or sets the thickness.
/// </summary>
/// <value>The thickness.</value>
[Category("自定义")]
[Description("图形宽度。")]
[DefaultValue(1f)]
public float Thickness
{
get
{
return _thickness;
}
set
{
_thickness = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether [horizontat line visible].
/// </summary>
/// <value><c>true</c> if [horizontat line visible]; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("显示/隐藏横向基准线。")]
[DefaultValue(true)]
public bool HorizontatLineVisible
{
get
{
return _horizontatLineVisible;
}
set
{
_horizontatLineVisible = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether [vertical line visible].
/// </summary>
/// <value><c>true</c> if [vertical line visible]; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("显示/隐藏纵向基准线。")]
[DefaultValue(true)]
public bool VerticalLineVisible
{
get
{
return _verticalLineVisible;
}
set
{
_verticalLineVisible = value;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal override void Draw(Graphics g)
{
PointF[] locationArray = GetLocationArray();
if (locationArray != null && locationArray.Length != 0)
{
using (Pen pen = new Pen(base.Color, Thickness))
{
if (_horizontatLineVisible && base.ParentAxisX != null)
{
float x = CountLeft(base.ParentAxisX.MinValue);
float x2 = CountLeft(base.ParentAxisX.MaxValue);
PointF[] array = locationArray;
for (int i = 0; i < array.Length; i++)
{
PointF pointF = array[i];
g.DrawLine(pen, x, pointF.Y, x2, pointF.Y);
}
}
if (_verticalLineVisible && base.ParentAxisY != null)
{
float y = CountTop(base.ParentAxisY.MinValue);
float y2 = CountTop(base.ParentAxisY.MaxValue);
PointF[] array2 = locationArray;
for (int j = 0; j < array2.Length; j++)
{
PointF pointF2 = array2[j];
g.DrawLine(pen, pointF2.X, y, pointF2.X, y2);
}
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected override void PaintLegend(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
float num = ((float)base.Legend.Height - _thickness) / 2f;
using (Pen pen = new Pen(base.Color, _thickness))
{
e.Graphics.DrawLine(pen, 0f, num, 12f, num);
}
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesCollection.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing.Design;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class SeriesCollection.
/// Implements the <see cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.SeriesBase}" />
/// </summary>
/// <seealso cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.SeriesBase}" />
[Editor(typeof(SeriesCollectionEditor), typeof(UITypeEditor))]
public class SeriesCollection : Collection<SeriesBase>
{
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
public UCChart Chart
{
get;
internal set;
}
/// <summary>
/// Inserts the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected override void InsertItem(int index, SeriesBase item)
{
base.InsertItem(index, item);
item.Chart = Chart;
item.Points.Chart = Chart;
item.Points.Series = item;
if (Chart != null)
{
Chart.LegendPanel.Controls.Add(item.Legend);
}
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Sets the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected override void SetItem(int index, SeriesBase item)
{
if (Chart != null)
{
Chart.LegendPanel.Controls.Remove(base[index].Legend);
}
base.SetItem(index, item);
item.Chart = Chart;
item.Points.Chart = Chart;
item.Points.Series = item;
if (Chart != null)
{
Chart.LegendPanel.Controls.Add(item.Legend);
}
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Clears the items.
/// </summary>
protected override void ClearItems()
{
if (Chart != null)
{
Chart.LegendPanel.Controls.Clear();
}
base.ClearItems();
if(Chart!=null)Chart.Invalidate();
}
/// <summary>
/// Removes the item.
/// </summary>
/// <param name="index">The index.</param>
protected override void RemoveItem(int index)
{
if (Chart != null)
{
Chart.LegendPanel.Controls.Remove(base[index].Legend);
}
base.RemoveItem(index);
if(Chart!=null)Chart.Invalidate();
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesCollectionEditor.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.ComponentModel.Design;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class SeriesCollectionEditor.
/// Implements the <see cref="System.ComponentModel.Design.CollectionEditor" />
/// </summary>
/// <seealso cref="System.ComponentModel.Design.CollectionEditor" />
public class SeriesCollectionEditor : CollectionEditor
{
/// <summary>
/// Initializes a new instance of the <see cref="SeriesCollectionEditor"/> class.
/// </summary>
/// <param name="type">此编辑器要编辑的集合的类型。</param>
public SeriesCollectionEditor(Type type)
: base(type)
{
}
/// <summary>
/// 指示是否可一次选择多个集合项。
/// </summary>
/// <returns>如果可以同时选择多个集合成员,则为 true;否则,为 false。默认情况下,它将返回 true。</returns>
protected override bool CanSelectMultipleInstances()
{
return true;
}
/// <summary>
/// 获取此集合编辑器可包含的数据类型。
/// </summary>
/// <returns>此集合可包含的数据类型数组。</returns>
protected override Type[] CreateNewItemTypes()
{
return new Type[6]
{
typeof(BezierSeries),
typeof(ColumnSeries),
typeof(LabelSeries),
typeof(LineSeries),
typeof(PointSeries),
typeof(StandardLineSeries)
};
}
/// <summary>
/// 创建指定的集合项类型的新实例。
/// </summary>
/// <param name="itemType">要创建的项类型。</param>
/// <returns>指定对象的新实例。</returns>
protected override object CreateInstance(Type itemType)
{
if (itemType == typeof(BezierSeries))
{
return new BezierSeries();
}
if (itemType == typeof(ColumnSeries))
{
return new ColumnSeries();
}
if (itemType == typeof(LabelSeries))
{
return new LabelSeries();
}
if (itemType == typeof(LineSeries))
{
return new LineSeries();
}
if (itemType == typeof(PointSeries))
{
return new PointSeries();
}
if (itemType == typeof(StandardLineSeries))
{
return new StandardLineSeries();
}
return null;
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesFormat.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System.Drawing;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class SeriesFormat.
/// </summary>
public class SeriesFormat
{
/// <summary>
/// The label format
/// </summary>
static StringFormat labelFormat=new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Far
};
/// <summary>
/// Gets or sets the label format.
/// </summary>
/// <value>The label format.</value>
public static StringFormat LabelFormat
{
get { return labelFormat; }
set { labelFormat = value; }
}
}
}
...@@ -46,18 +46,15 @@ ...@@ -46,18 +46,15 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\Charts\BarChart\AuxiliaryLine.cs" /> <Compile Include="Controls\Charts\AuxiliaryLable.cs" />
<Compile Include="Controls\Charts\Axis.cs" /> <Compile Include="Controls\Charts\AuxiliaryLine.cs" />
<Compile Include="Controls\Charts\AxisCollection.cs" />
<Compile Include="Controls\Charts\AxisFormat.cs" />
<Compile Include="Controls\Charts\AxisLabel.cs" />
<Compile Include="Controls\Charts\AxisPosition.cs" />
<Compile Include="Controls\Charts\AxisType.cs" />
<Compile Include="Controls\Charts\BarChart\BarChartItem.cs" /> <Compile Include="Controls\Charts\BarChart\BarChartItem.cs" />
<Compile Include="Controls\Charts\ChartPoint.cs" /> <Compile Include="Controls\Charts\CurveChart\UCCurve.cs">
<Compile Include="Controls\Charts\ChartPointCollection.cs" /> <SubType>UserControl</SubType>
<Compile Include="Controls\Charts\ChartPointEventArgs.cs" /> </Compile>
<Compile Include="Controls\Charts\ChartPointEventHandler.cs" /> <Compile Include="Controls\Charts\CurveChart\CurveItem.cs" />
<Compile Include="Controls\Charts\MarkText.cs" />
<Compile Include="Controls\Charts\MarkTextPositionStyle.cs" />
<Compile Include="Controls\Charts\PieChart\UCPieChart.cs"> <Compile Include="Controls\Charts\PieChart\UCPieChart.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -73,20 +70,6 @@ ...@@ -73,20 +70,6 @@
<Compile Include="Controls\Charts\BarChart\UCBarChart.cs"> <Compile Include="Controls\Charts\BarChart\UCBarChart.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\Charts\UCChart.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Charts\SelectMode.cs" />
<Compile Include="Controls\Charts\SeriesBase.cs" />
<Compile Include="Controls\Charts\SeriesCollection.cs" />
<Compile Include="Controls\Charts\SeriesCollectionEditor.cs" />
<Compile Include="Controls\Charts\SeriesFormat.cs" />
<Compile Include="Controls\Charts\Series\BezierSeries.cs" />
<Compile Include="Controls\Charts\Series\ColumnSeries.cs" />
<Compile Include="Controls\Charts\Series\LabelSeries.cs" />
<Compile Include="Controls\Charts\Series\LineSeries.cs" />
<Compile Include="Controls\Charts\Series\PointSeries.cs" />
<Compile Include="Controls\Charts\Series\StandardLineSeries.cs" />
<Compile Include="Controls\Charts\ZoomType.cs" /> <Compile Include="Controls\Charts\ZoomType.cs" />
<Compile Include="Controls\FactoryControls\Arrow\UCArrow.cs"> <Compile Include="Controls\FactoryControls\Arrow\UCArrow.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
...@@ -936,27 +919,7 @@ ...@@ -936,27 +919,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<None Include="Resources\ThumbBottom.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbMiddle.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbSpanBottom.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbSpanTop.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbTop.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\uparrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\downarrow.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PreBuildEvent> <PreBuildEvent>
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
this.panControl.Name = "panControl"; this.panControl.Name = "panControl";
this.panControl.Size = new System.Drawing.Size(815, 707); this.panControl.Size = new System.Drawing.Size(815, 707);
this.panControl.TabIndex = 9; this.panControl.TabIndex = 9;
this.scrollbarComponent1.SetUserCustomScrollbar(this.panControl, true); this.scrollbarComponent1.SetUserCustomScrollbar(this.panControl, false);
// //
// FrmMain // FrmMain
// //
......
...@@ -65,6 +65,7 @@ namespace Test ...@@ -65,6 +65,7 @@ namespace Test
tnCharts.Nodes.Add("滚动图表"); tnCharts.Nodes.Add("滚动图表");
tnCharts.Nodes.Add("柱状图"); tnCharts.Nodes.Add("柱状图");
tnCharts.Nodes.Add("饼状图"); tnCharts.Nodes.Add("饼状图");
tnCharts.Nodes.Add("曲线图");
this.tvMenu.Nodes.Add(tnCharts); this.tvMenu.Nodes.Add(tnCharts);
TreeNode tnFactory = new TreeNode(" 工业控件"); TreeNode tnFactory = new TreeNode(" 工业控件");
...@@ -215,6 +216,9 @@ namespace Test ...@@ -215,6 +216,9 @@ namespace Test
case "饼状图": case "饼状图":
AddControl(new UC.UCTestPieCharts()); AddControl(new UC.UCTestPieCharts());
break; break;
case "曲线图":
AddControl(new UC.UCTestCurveChart());
break;
case "滚动图表": case "滚动图表":
AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill }); AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill });
break; break;
......
...@@ -110,6 +110,12 @@ ...@@ -110,6 +110,12 @@
<Compile Include="UC\UCTestConveyor.Designer.cs"> <Compile Include="UC\UCTestConveyor.Designer.cs">
<DependentUpon>UCTestConveyor.cs</DependentUpon> <DependentUpon>UCTestConveyor.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UC\UCTestCurveChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestCurveChart.Designer.cs">
<DependentUpon>UCTestCurveChart.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestIcon.cs"> <Compile Include="UC\UCTestIcon.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -326,6 +332,9 @@ ...@@ -326,6 +332,9 @@
<EmbeddedResource Include="UC\UCTestConveyor.resx"> <EmbeddedResource Include="UC\UCTestConveyor.resx">
<DependentUpon>UCTestConveyor.cs</DependentUpon> <DependentUpon>UCTestConveyor.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UC\UCTestCurveChart.resx">
<DependentUpon>UCTestCurveChart.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestForms.resx"> <EmbeddedResource Include="UC\UCTestForms.resx">
<DependentUpon>UCTestForms.cs</DependentUpon> <DependentUpon>UCTestForms.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
namespace Test.UC
{
partial class UCTestCurveChart
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.ucCurve2 = new HZH_Controls.Controls.UCCurve();
this.ucCurve1 = new HZH_Controls.Controls.UCCurve();
this.ucCurve3 = new HZH_Controls.Controls.UCCurve();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 200;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucCurve2
//
this.ucCurve2.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucCurve2.CurveNameWidth = 50;
this.ucCurve2.IntervalAbscissaText = 20;
this.ucCurve2.IsAbscissaStrech = true;
this.ucCurve2.IsRenderRightCoordinate = false;
this.ucCurve2.Location = new System.Drawing.Point(40, 327);
this.ucCurve2.Name = "ucCurve2";
this.ucCurve2.Size = new System.Drawing.Size(963, 318);
this.ucCurve2.StrechDataCountMax = 100;
this.ucCurve2.TabIndex = 1;
this.ucCurve2.Title = "动态数据";
//
// ucCurve1
//
this.ucCurve1.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucCurve1.IntervalAbscissaText = -1;
this.ucCurve1.IsAbscissaStrech = true;
this.ucCurve1.Location = new System.Drawing.Point(40, 22);
this.ucCurve1.Name = "ucCurve1";
this.ucCurve1.Size = new System.Drawing.Size(963, 299);
this.ucCurve1.StrechDataCountMax = 7;
this.ucCurve1.TabIndex = 0;
this.ucCurve1.Title = "一周生产";
//
// ucCurve3
//
this.ucCurve3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucCurve3.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucCurve3.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucCurve3.CurveNameWidth = 50;
this.ucCurve3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucCurve3.IntervalAbscissaText = -1;
this.ucCurve3.IsAbscissaStrech = true;
this.ucCurve3.IsRenderRightCoordinate = false;
this.ucCurve3.Location = new System.Drawing.Point(40, 651);
this.ucCurve3.Name = "ucCurve3";
this.ucCurve3.Size = new System.Drawing.Size(963, 534);
this.ucCurve3.StrechDataCountMax = 6;
this.ucCurve3.TabIndex = 1;
this.ucCurve3.Title = "小明模拟考试成绩走势";
this.ucCurve3.ValueSegment = 10;
//
// UCTestCurveChart
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.ucCurve3);
this.Controls.Add(this.ucCurve2);
this.Controls.Add(this.ucCurve1);
this.Name = "UCTestCurveChart";
this.Size = new System.Drawing.Size(1041, 1239);
this.Load += new System.EventHandler(this.UCTestCurveChart_Load);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCCurve ucCurve1;
private HZH_Controls.Controls.UCCurve ucCurve2;
private System.Windows.Forms.Timer timer1;
private HZH_Controls.Controls.UCCurve ucCurve3;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test.UC
{
public partial class UCTestCurveChart : UserControl
{
public UCTestCurveChart()
{
InitializeComponent();
}
private void UCTestCurveChart_Load(object sender, EventArgs e)
{
Random r = new Random();
this.ucCurve1.SetCurveText(new string[] { "周一", "周二", "周三", "周四", "周五", "周六", "周日" });
float[] data1 = new float[7];
float[] data2 = new float[7];
float[] data3 = new float[7];
for (int i = 0; i < data1.Length; i++)
{
data1[i] = r.Next(0, 100);
data2[i] = r.Next(0, 100);
data3[i] = r.Next(0, 100);
}
ucCurve1.SetLeftCurve("A", data1);
ucCurve1.SetLeftCurve("B", data2);
ucCurve1.SetLeftCurve("C", data3);
//辅助文字
ucCurve1.AddMarkText("A", 0, "周一数据", Color.Red);
ucCurve1.AddMarkText("A", 1, "周二数据");
ucCurve1.AddMarkText("B", 0, "周一数据");
ucCurve1.AddMarkText("B", 1, "周二数据");
ucCurve1.AddAuxiliaryLabel(new HZH_Controls.Controls.AuxiliaryLable()
{
LocationX = 0.8f,
Text = "不合格数:5",
TextBack = Brushes.Red,
TextBrush = Brushes.White
});
ucCurve1.AddLeftAuxiliary(20, Color.Red);
ucCurve2.SetLeftCurve("A", null, Color.Red);
ucCurve2.SetLeftCurve("B", null, Color.Orange);
ucCurve2.SetLeftCurve("C", null, Color.Blue);
ucCurve2.SetLeftCurve("D", null, Color.Green);
this.ucCurve3.SetCurveText(new string[] { "第一次模拟", "第二次模拟", "第三次模拟", "第四次模拟", "第五次模拟", "第六次模拟", "第七次模拟" });
float[] data31 = new float[6];
float[] data32 = new float[6];
float[] data33 = new float[6];
float[] data34 = new float[6];
float[] data35 = new float[6];
float[] data36 = new float[6];
for (int i = 0; i < data31.Length; i++)
{
data31[i] = r.Next(10 + i * 10, 40+i*10);
data32[i] = r.Next(10 + i * 10, 40+i*10);
data33[i] = r.Next(10 + i * 10, 40+i*10);
data34[i] = r.Next(10 + i * 10, 40+i*10);
data35[i] = r.Next(10 + i * 10, 40+i*10);
data36[i] = r.Next(10 + i * 10, 40+i*10);
}
ucCurve3.SetLeftCurve("语文", data31);
ucCurve3.SetLeftCurve("数学", data32);
ucCurve3.SetLeftCurve("英语", data33);
ucCurve3.SetLeftCurve("化学", data34);
ucCurve3.SetLeftCurve("生物", data35);
ucCurve3.SetLeftCurve("物理", data36);
for (int i = 0; i < data31.Length; i++)
{
ucCurve3.AddMarkText("语文", i, data31[i].ToString());
ucCurve3.AddMarkText("数学", i, data32[i].ToString());
ucCurve3.AddMarkText("英语", i, data33[i].ToString());
ucCurve3.AddMarkText("化学", i, data34[i].ToString());
ucCurve3.AddMarkText("生物", i, data35[i].ToString());
ucCurve3.AddMarkText("物理", i, data36[i].ToString());
}
}
int count_tick = 0;
private void timer1_Tick(object sender, EventArgs e)
{
count_tick++;
float random1 = (float)(Math.Sin(2 * Math.PI * count_tick / 30) * 0.5d + 0.5);
float random2 = (float)(Math.Sin(2 * Math.PI * count_tick / 50) * 0.5d + 0.5);
float random3 = (float)(Math.Cos(2 * Math.PI * count_tick / 80) * 0.5d + 0.5);
float random4 = (float)(Math.Cos(2 * Math.PI * count_tick / 10) * 0.5d + 0.5);
if (count_tick % 50 == 0)
{
ucCurve2.AddCurveData(
new string[] { "A", "B", "C", "D" },
new float[]
{
random1*10 + 80,
random2*20+50,
random3*20+30,
random4*10+20,
}, new string[] { "标签1", "标签2", "标签3", "标签4" }
);
}
else
{
ucCurve2.AddCurveData(
new string[] { "A", "B", "C", "D" },
new float[]
{
random1*10 + 80,
random2*20+50,
random3*20+30,
random4*10+20,
}
);
}
if (count_tick > 10000)
count_tick = 0;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!