Commit d95b8fb9 HZH

移除部分内容

1 个父辈 e98ddec5
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="BarChartItem.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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class BarChartItem.
/// </summary>
public class BarChartItem
{
public BarChartItem()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BarChartItem"/> class.
/// </summary>
/// <param name="_barBackColor">Color of the bar back.</param>
/// <param name="_itemName">Name of the item.</param>
/// <param name="_barPercentWidth">柱状图占平均宽度的百分比,默认0.8,即80%.</param>
public BarChartItem(
string _itemName = "",
Color? _barBackColor = null,
float _barPercentWidth = 0.9f)
{
barBackColor = _barBackColor;
itemName = _itemName;
barPercentWidth = _barPercentWidth;
}
/// <summary>
/// The bar back color
/// </summary>
private Color? barBackColor ;
/// <summary>
/// Gets or sets the color of the bar back.
/// </summary>
/// <value>The color of the bar back.</value>
public Color? BarBackColor
{
get { return barBackColor; }
set { barBackColor = value; }
}
/// <summary>
/// The bar percent width
/// </summary>
private float barPercentWidth = 0.9f;
/// <summary>
/// 获取或设置柱状图占平均宽度的百分比,默认0.9,即90%
/// </summary>
/// <value>The width of the bar percent.</value>
public float BarPercentWidth
{
get { return barPercentWidth; }
set { barPercentWidth = value; }
}
/// <summary>
/// The item name
/// </summary>
private string itemName;
/// <summary>
/// Gets or sets the name of the item.
/// </summary>
/// <value>The name of the item.</value>
public string ItemName
{
get { return itemName; }
set { itemName = value; }
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="UCBarChart.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.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
using System.Linq;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCBarChart.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public class UCBarChart : UCControlBase
{
/// <summary>
/// The auxiliary lines
/// </summary>
private List<AuxiliaryLine> auxiliary_lines;
/// <summary>
/// The value maximum left
/// </summary>
private int value_max_left = -1;
/// <summary>
/// The value minimum left
/// </summary>
private int value_min_left = 0;
/// <summary>
/// The value segment
/// </summary>
private int value_Segment = 5;
/// <summary>
/// The data values
/// </summary>
private double[][] data_values = null;
/// <summary>
/// The data texts
/// </summary>
private string[] data_texts = null;
///// <summary>
///// The data colors
///// </summary>
//private Color[] data_colors = null;
/// <summary>
/// The brush deep
/// </summary>
private Brush brush_deep = null;
/// <summary>
/// The pen normal
/// </summary>
private Pen pen_normal = null;
/// <summary>
/// The pen dash
/// </summary>
private Pen pen_dash = null;
/// <summary>
/// The bar back color
/// </summary>
//private Color barBackColor = Color.FromArgb(255, 77, 59);
/// <summary>
/// The use gradient
/// </summary>
private bool useGradient = false;
/// <summary>
/// The color deep
/// </summary>
private Color color_deep = Color.FromArgb(150, 255, 77, 59);
/// <summary>
/// The color dash
/// </summary>
private Color color_dash = Color.FromArgb(50, 255, 77, 59);
/// <summary>
/// The format left
/// </summary>
private StringFormat format_left = null;
/// <summary>
/// The format right
/// </summary>
private StringFormat format_right = null;
/// <summary>
/// The format center
/// </summary>
private StringFormat format_center = null;
/// <summary>
/// The value is render dash line
/// </summary>
private bool value_IsRenderDashLine = true;
/// <summary>
/// The is show bar value
/// </summary>
private bool isShowBarValue = true;
/// <summary>
/// The show bar value format
/// </summary>
private string showBarValueFormat = "{0}";
/// <summary>
/// The value title
/// </summary>
private string value_title = "";
/// <summary>
/// The bar percent width
/// </summary>
private float barPercentWidth = 0.9f;
/// <summary>
/// The components
/// </summary>
private IContainer components = null;
/// <summary>
/// 获取或设置控件的背景色。
/// </summary>
/// <value>The color of the back.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[Browsable(true)]
[Description("获取或设置控件的背景色")]
[Category("自定义")]
[DefaultValue(typeof(Color), "Transparent")]
[EditorBrowsable(EditorBrowsableState.Always)]
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>The text.</value>
[Browsable(true)]
[Description("获取或设置当前控件的文本")]
[Category("自定义")]
[EditorBrowsable(EditorBrowsableState.Always)]
[Bindable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
Invalidate();
}
}
/// <summary>
/// 获取或设置控件的前景色。
/// </summary>
/// <value>The color of the fore.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[Browsable(true)]
[Description("获取或设置控件的前景色")]
[Category("自定义")]
[EditorBrowsable(EditorBrowsableState.Always)]
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
/// <summary>
/// Gets or sets the color lines and text.
/// </summary>
/// <value>The color lines and text.</value>
[Category("自定义")]
[Description("获取或设置坐标轴及相关信息文本的颜色")]
[Browsable(true)]
[DefaultValue(typeof(Color), "DimGray")]
public Color ColorLinesAndText
{
get
{
return color_deep;
}
set
{
color_deep = value;
InitializationColor();
Invalidate();
}
}
/// <summary>
/// Gets or sets a value indicating whether [use gradient].
/// </summary>
/// <value><c>true</c> if [use gradient]; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("获取或设置本条形图控件是否使用渐进色")]
[Browsable(true)]
[DefaultValue(false)]
public bool UseGradient
{
get
{
return useGradient;
}
set
{
useGradient = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the color dash lines.
/// </summary>
/// <value>The color dash lines.</value>
[Category("自定义")]
[Description("获取或设置虚线的颜色")]
[Browsable(true)]
[DefaultValue(typeof(Color), "LightGray")]
public Color ColorDashLines
{
get
{
return color_dash;
}
set
{
color_dash = value;
if (pen_dash != null)
pen_dash.Dispose();
pen_dash = new Pen(color_dash);
Invalidate();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is render dash line.
/// </summary>
/// <value><c>true</c> if this instance is render dash line; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("获取或设置虚线是否进行显示")]
[Browsable(true)]
[DefaultValue(true)]
public bool IsRenderDashLine
{
get
{
return value_IsRenderDashLine;
}
set
{
value_IsRenderDashLine = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value segment.
/// </summary>
/// <value>The value segment.</value>
[Category("自定义")]
[Description("获取或设置图形的纵轴分段数")]
[Browsable(true)]
[DefaultValue(5)]
public int ValueSegment
{
get
{
return value_Segment;
}
set
{
value_Segment = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value maximum left.
/// </summary>
/// <value>The value maximum left.</value>
[Category("自定义")]
[Description("获取或设置图形的左纵坐标的最大值,该值必须大于最小值,该值为负数,最大值即为自动适配。")]
[Browsable(true)]
[DefaultValue(-1)]
public int ValueMaxLeft
{
get
{
return value_max_left;
}
set
{
value_max_left = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value minimum left.
/// </summary>
/// <value>The value minimum left.</value>
[Category("自定义")]
[Description("获取或设置图形的左纵坐标的最小值,该值必须小于最大值")]
[Browsable(true)]
[DefaultValue(0)]
public int ValueMinLeft
{
get
{
return value_min_left;
}
set
{
if (value < value_max_left)
{
value_min_left = value;
Invalidate();
}
}
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
[Category("自定义")]
[Description("获取或设置图标的标题信息")]
[Browsable(true)]
[DefaultValue("")]
public string Title
{
get
{
return value_title;
}
set
{
value_title = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is show bar value.
/// </summary>
/// <value><c>true</c> if this instance is show bar value; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("获取或设置是否显示柱状图的值文本")]
[Browsable(true)]
[DefaultValue(true)]
public bool IsShowBarValue
{
get
{
return isShowBarValue;
}
set
{
isShowBarValue = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the show bar value format.
/// </summary>
/// <value>The show bar value format.</value>
[Category("自定义")]
[Description("获取或设置柱状图显示值的格式化信息,可以带单位")]
[Browsable(true)]
[DefaultValue("")]
public string ShowBarValueFormat
{
get
{
return showBarValueFormat;
}
set
{
showBarValueFormat = value;
Invalidate();
}
}
private BarChartItem[] barChartItems = new BarChartItem[] { new BarChartItem() };
[Category("自定义")]
[Description("获取或设置柱状图的项目")]
[Browsable(true)]
public BarChartItem[] BarChartItems
{
get { return barChartItems; }
set { barChartItems = value; }
}
[Category("自定义")]
[Description("获取或设置是否显示柱状图的项目名称")]
[Browsable(true)]
public bool ShowChartItemName { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="UCBarChart"/> class.
/// </summary>
public UCBarChart()
{
InitializeComponent();
ConerRadius = 10;
ForeColor = Color.FromArgb(150, 255, 77, 59);
FillColor = Color.FromArgb(243, 220, 219);
format_left = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Near
};
format_right = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Far
};
format_center = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Center
};
auxiliary_lines = new List<AuxiliaryLine>();
pen_dash = new Pen(color_dash);
pen_dash.DashStyle = DashStyle.Custom;
pen_dash.DashPattern = new float[2]
{
5f,
5f
};
InitializationColor();
SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
if (DesignMode)
{
barChartItems = new BarChartItem[] { new BarChartItem() };
data_values = new double[5][];
for (int i = 0; i < data_values.Length; i++)
{
data_values[i] = new double[] { i + 1 };
}
}
}
/// <summary>
/// Initializations the color.
/// </summary>
private void InitializationColor()
{
if (pen_normal != null)
pen_normal.Dispose();
if (brush_deep != null)
brush_deep.Dispose();
pen_normal = new Pen(color_deep);
brush_deep = new SolidBrush(color_deep);
}
/// <summary>
/// Sets the data source.
/// </summary>
/// <param name="data">The data.</param>
public void SetDataSource(double[] data)
{
SetDataSource(data, null);
}
public void SetDataSource(double[][] data)
{
SetDataSource(data, null);
}
/// <summary>
/// Sets the data source.
/// </summary>
/// <param name="data">The data.</param>
/// <param name="texts">X texts</param>
public void SetDataSource(double[] data, string[] texts)
{
data_values = new double[data.Length][];
for (int i = 0; i < data.Length; i++)
{
data_values[i] = new double[] { data[i] };
}
if (barChartItems == null || barChartItems.Length <= 0)
barChartItems = new BarChartItem[] { new BarChartItem() };
data_texts = texts;
Invalidate();
}
public void SetDataSource(double[][] data, string[] texts)
{
data_values = data;
if (barChartItems == null || barChartItems.Length <= 0)
barChartItems = new BarChartItem[] { new BarChartItem() };
data_texts = texts;
Invalidate();
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics graphics = e.Graphics;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
PaintMain(graphics, base.Width, base.Height);
}
/// <summary>
/// Paints the main.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
private void PaintMain(Graphics g, int width, int height)
{
if (barChartItems == null || barChartItems.Length <= 0)
{
if (DesignMode)
{
barChartItems = new BarChartItem[] { new BarChartItem() };
}
else
{
return;
}
}
if (data_values == null && DesignMode)
{
data_values = new double[5][];
for (int i = 0; i < data_values.Length; i++)
{
data_values[i] = new double[] { i + 1 };
}
}
double num = (data_values != null && data_values.Length != 0) ? ControlHelper.CalculateMaxSectionFrom(data_values) : 5;
if (value_max_left > 0)
{
num = value_max_left;
}
int intLeftX = (int)g.MeasureString(num.ToString(), Font).Width + 3;
if (intLeftX < 50)
{
intLeftX = 50;
}
//处理辅助线左侧间距
if (auxiliary_lines != null && auxiliary_lines.Count > 0)
{
var maxAuxiliaryWidth = auxiliary_lines.Max(p => g.MeasureString((p.Tip + "" + p.Value), Font).Width);
if (intLeftX < maxAuxiliaryWidth)
{
intLeftX = (int)maxAuxiliaryWidth + 5;
}
}
int intRightX = 20;
//顶部距离
int intTopY = 25;
if (!string.IsNullOrEmpty(value_title))
{
intTopY += 20;
}
//写标题
if (!string.IsNullOrEmpty(value_title))
{
g.DrawString(value_title, Font, brush_deep, new Rectangle(0, 0, width - 1, intTopY - 10), format_center);
}
//画项目名称颜色
if (ShowChartItemName && !(barChartItems.Length == 1 && string.IsNullOrEmpty(barChartItems[0].ItemName)))
{
int intItemNameRowCount = 0;
int intItemNameWidth = 0;
int intItemNameComCount = 0;
intItemNameWidth = (int)barChartItems.Max(p => g.MeasureString(p.ItemName, Font).Width) + 40;
intItemNameComCount = this.Width / intItemNameWidth;
intItemNameRowCount = barChartItems.Length / intItemNameComCount + (barChartItems.Length % intItemNameComCount != 0 ? 1 : 0);
int intItemNameHeight = (int)g.MeasureString("A", Font).Height;
for (int i = 0; i < intItemNameRowCount; i++)
{
int intLeft = (this.Width - (intItemNameWidth * ((i == intItemNameRowCount - 1) ? (barChartItems.Length % intItemNameComCount) : intItemNameComCount))) / 2;
int intTop = intTopY - 15 + intItemNameHeight * i + 10;
for (int j = i * intItemNameComCount; j < barChartItems.Length && j < (i + 1) * intItemNameComCount; j++)
{
Rectangle rectColor = new Rectangle(intLeft + (j % intItemNameComCount) * intItemNameWidth, intTop, 20, intItemNameHeight);
g.FillRectangle(new SolidBrush(barChartItems[j].BarBackColor??ControlHelper.Colors[j]), rectColor);
g.DrawString(barChartItems[j].ItemName, Font, new SolidBrush(ForeColor), new Point(rectColor.Right + 2, rectColor.Top));
}
}
intTopY += intItemNameRowCount * (intItemNameHeight + 20);
}
int intBottomY = 25;
//处理x坐标文字高度
if (data_texts != null && data_texts.Length > 0)
{
var maxTextsHeight = data_texts.Max(p => g.MeasureString(p, Font).Height);
if (intBottomY < maxTextsHeight)
intBottomY = (int)maxTextsHeight + 5;
}
//画xy轴
Point[] array2 = new Point[3]
{
new Point(intLeftX, intTopY - 8),
new Point(intLeftX, height - intBottomY),
new Point(width - intRightX+5, height - intBottomY)
};
g.DrawLine(pen_normal, array2[0], array2[1]);
g.DrawLine(pen_normal, array2[1], array2[2]);
ControlHelper.PaintTriangle(g, brush_deep, new Point(intLeftX, intTopY - 8), 4, GraphDirection.Upward);
ControlHelper.PaintTriangle(g, brush_deep, new Point(width - intRightX + 5, height - intBottomY), 4, GraphDirection.Rightward);
//画横向分割线
for (int j = 0; j <= value_Segment; j++)
{
float value = (float)((double)j * (double)(num - value_min_left) / (double)value_Segment + (double)value_min_left);
float num6 = ControlHelper.ComputePaintLocationY((float)num, value_min_left, height - intTopY - intBottomY, value) + (float)intTopY;
if (IsNeedPaintDash(num6))
{
g.DrawLine(pen_normal, intLeftX - 4, num6, intLeftX - 1, num6);
g.DrawString(layoutRectangle: new RectangleF(0f, num6 - 19f, intLeftX - 4, 40f), s: value.ToString(), font: Font, brush: brush_deep, format: format_right);
if (j > 0 && value_IsRenderDashLine)
{
g.DrawLine(pen_dash, intLeftX, num6, width - intRightX, num6);
}
}
}
//计算辅助线y坐标
for (int i = 0; i < auxiliary_lines.Count; i++)
{
auxiliary_lines[i].PaintValue = ControlHelper.ComputePaintLocationY((float)num, value_min_left, height - intTopY - intBottomY, auxiliary_lines[i].Value) + (float)intTopY;
}
//画辅助线
for (int k = 0; k < auxiliary_lines.Count; k++)
{
g.DrawLine(auxiliary_lines[k].GetPen(), intLeftX - 4, auxiliary_lines[k].PaintValue, intLeftX - 1, auxiliary_lines[k].PaintValue);
g.DrawString(layoutRectangle: new RectangleF(0f, auxiliary_lines[k].PaintValue - 9f, intLeftX - 4, 20f), s: auxiliary_lines[k].Tip + "" + auxiliary_lines[k].Value.ToString(), font: Font, brush: auxiliary_lines[k].LineTextBrush, format: format_right);
g.DrawLine(auxiliary_lines[k].GetPen(), intLeftX, auxiliary_lines[k].PaintValue, width - intRightX, auxiliary_lines[k].PaintValue);
}
if (data_values == null || data_values.Length == 0 || data_values.Max(p => p.Length) <= 0)
{
return;
}
//x轴分隔宽度
float fltSplitWidth = (float)(width - intLeftX - 1 - intRightX) * 1f / (float)data_values.Length;
for (int i = 0; i < data_values.Length; i++)
{
int intItemSplitCount = barChartItems.Length;
float _fltSplitWidth = fltSplitWidth * barPercentWidth / intItemSplitCount;
float _fltLeft = (float)i * fltSplitWidth + (1f - barPercentWidth) / 2f * fltSplitWidth + (float)intLeftX;
for (int j = 0; j < data_values[i].Length; j++)
{
if (j >= intItemSplitCount)
{
break;
}
float fltValueY = ControlHelper.ComputePaintLocationY((float)num, value_min_left, height - intTopY - intBottomY, (float)data_values[i][j]) + (float)intTopY;
RectangleF rect = new RectangleF(_fltLeft + _fltSplitWidth * j + (1F - barChartItems[j].BarPercentWidth) * _fltSplitWidth / 2f, fltValueY,
_fltSplitWidth * barChartItems[j].BarPercentWidth, (float)(height - intBottomY) - fltValueY);
Color color = barChartItems[j].BarBackColor ?? ControlHelper.Colors[j];
//画柱状
if (useGradient)
{
if (rect.Height > 0f)
{
using (LinearGradientBrush brush = new LinearGradientBrush(new PointF(rect.X, rect.Y + rect.Height), new PointF(rect.X, rect.Y), ControlHelper.GetColorLight(color), color))
{
g.FillRectangle(brush, rect);
}
}
}
else
{
using (Brush brush2 = new SolidBrush(color))
{
g.FillRectangle(brush2, rect);
}
}
//写值文字
if (isShowBarValue)
{
using (Brush brush3 = new SolidBrush(ForeColor))
{
g.DrawString(layoutRectangle: new RectangleF(rect.Left - 50f, fltValueY - (float)Font.Height - 2f, _fltSplitWidth + 100f, Font.Height + 2), s: string.Format(showBarValueFormat, data_values[i][j]), font: Font, brush: brush3, format: format_center);
}
}
}
//写x轴文字
if (data_texts != null && i < data_texts.Length)
{
g.DrawString(layoutRectangle: new RectangleF((float)i * fltSplitWidth + (float)intLeftX - 50f, height - intBottomY - 1, fltSplitWidth + 100f, intBottomY + 1), s: data_texts[i], font: Font, brush: brush_deep, format: format_center);
}
}
}
/// <summary>
/// Determines whether [is need paint dash] [the specified paint value].
/// </summary>
/// <param name="paintValue">The paint value.</param>
/// <returns><c>true</c> if [is need paint dash] [the specified paint value]; otherwise, <c>false</c>.</returns>
private bool IsNeedPaintDash(float paintValue)
{
if (data_values == null)
{
return true;
}
for (int i = 0; i < auxiliary_lines.Count; i++)
{
if (Math.Abs(auxiliary_lines[i].PaintValue - paintValue) < (float)Font.Height)
{
return false;
}
}
return true;
}
/// <summary>
/// Calculats the maximum width of the text.
/// </summary>
/// <param name="g">The g.</param>
/// <returns>System.Single.</returns>
private float calculatMaxTextWidth(Graphics g)
{
string[] array = data_texts;
if (array != null && array.Length != 0)
{
float num = 0f;
for (int i = 0; i < data_texts.Length; i++)
{
float width = g.MeasureString(data_texts[i], Font).Width;
if (num < width)
{
num = width;
}
}
return num;
}
return 1f;
}
#region 辅助线 English:Guide
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public void AddAuxiliaryLine(float value, string strTip = "")
{
AddAuxiliaryLine(value, ColorLinesAndText, strTip);
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
public void AddAuxiliaryLine(float value, Color lineColor, string strTip = "")
{
AddAuxiliaryLine(value, lineColor, 1f, true, strTip);
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
public void AddAuxiliaryLine(float value, Color lineColor, float lineThickness, bool isDashLine, string strTip = "")
{
AddAuxiliary(value, lineColor, lineThickness, isDashLine, strTip);
}
/// <summary>
/// Adds the auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
/// <param name="isLeft">if set to <c>true</c> [is left].</param>
private void AddAuxiliary(float value, Color lineColor, float lineThickness, bool isDashLine, string strTip = "")
{
auxiliary_lines.Add(new AuxiliaryLine
{
Value = value,
LineColor = lineColor,
PenDash = new Pen(lineColor)
{
DashStyle = DashStyle.Custom,
DashPattern = new float[2]
{
5f,
5f
}
},
PenSolid = new Pen(lineColor),
IsDashStyle = isDashLine,
LineThickness = lineThickness,
LineTextBrush = new SolidBrush(lineColor),
Tip = strTip
});
Invalidate();
}
/// <summary>
/// Removes the auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public void RemoveAuxiliary(float value)
{
int num = 0;
for (int num2 = auxiliary_lines.Count - 1; num2 >= 0; num2--)
{
if (auxiliary_lines[num2].Value == value)
{
auxiliary_lines[num2].Dispose();
auxiliary_lines.RemoveAt(num2);
num++;
}
}
if (num > 0)
{
Invalidate();
}
}
/// <summary>
/// Removes all auxiliary.
/// </summary>
public void RemoveAllAuxiliary()
{
int count = auxiliary_lines.Count;
auxiliary_lines.Clear();
if (count > 0)
{
Invalidate();
}
}
#endregion
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing">为 true 则释放托管资源和非托管资源;为 false 则仅释放非托管资源。</param>
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Initializes the component.
/// </summary>
private void InitializeComponent()
{
SuspendLayout();
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
BackColor = System.Drawing.Color.Transparent;
ForeColor = System.Drawing.Color.Black;
base.Name = "UCBarChart";
base.Size = new System.Drawing.Size(440, 264);
ResumeLayout(false);
}
}
}
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
// Created : 2019-09-23
//
// ***********************************************************************
// <copyright file="UCCurve.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.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCCurve.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public class UCCurve : UserControl
{
/// <summary>
/// The value count maximum
/// </summary>
private const int value_count_max = 4096;
/// <summary>
/// The value maximum left
/// </summary>
private float value_max_left = 100f;
/// <summary>
/// The value minimum left
/// </summary>
private float value_min_left = 0f;
/// <summary>
/// The value maximum right
/// </summary>
private float value_max_right = 100f;
/// <summary>
/// The value minimum right
/// </summary>
private float value_min_right = 0f;
/// <summary>
/// The value segment
/// </summary>
private int value_Segment = 5;
/// <summary>
/// The value is abscissa strech
/// </summary>
private bool value_IsAbscissaStrech = false;
/// <summary>
/// The value strech data count maximum
/// </summary>
private int value_StrechDataCountMax = 300;
/// <summary>
/// The value is render dash line
/// </summary>
private bool value_IsRenderDashLine = true;
/// <summary>
/// The text format
/// </summary>
private string textFormat = "HH:mm";
/// <summary>
/// The value interval abscissa text
/// </summary>
private int value_IntervalAbscissaText = 100;
/// <summary>
/// The random
/// </summary>
private Random random = null;
/// <summary>
/// The value title
/// </summary>
private string value_title = "";
/// <summary>
/// The left right
/// </summary>
private int leftRight = 50;
/// <summary>
/// Up dowm
/// </summary>
private int upDowm = 50;
/// <summary>
/// The data list
/// </summary>
private Dictionary<string, CurveItem> data_list = null;
/// <summary>
/// The data text
/// </summary>
private string[] data_text = null;
/// <summary>
/// The auxiliary lines
/// </summary>
private List<AuxiliaryLine> auxiliary_lines;
/// <summary>
/// The auxiliary labels
/// </summary>
private List<AuxiliaryLable> auxiliary_Labels;
/// <summary>
/// The mark texts
/// </summary>
private List<MarkText> MarkTexts;
/// <summary>
/// The font size9
/// </summary>
private Font font_size9 = null;
/// <summary>
/// The font size12
/// </summary>
private Font font_size12 = null;
/// <summary>
/// The brush deep
/// </summary>
private Brush brush_deep = null;
/// <summary>
/// The pen normal
/// </summary>
private Pen pen_normal = null;
/// <summary>
/// The pen dash
/// </summary>
private Pen pen_dash = null;
/// <summary>
/// The color normal
/// </summary>
private Color color_normal = Color.DeepPink;
/// <summary>
/// The color deep
/// </summary>
private Color color_deep = Color.DimGray;
/// <summary>
/// The color dash
/// </summary>
private Color color_dash = Color.FromArgb(232, 232, 232);
/// <summary>
/// The color mark font
/// </summary>
private Color color_mark_font = Color.DodgerBlue;
/// <summary>
/// The brush mark font
/// </summary>
private Brush brush_mark_font = Brushes.DodgerBlue;
/// <summary>
/// The format left
/// </summary>
private StringFormat format_left = null;
/// <summary>
/// The format right
/// </summary>
private StringFormat format_right = null;
/// <summary>
/// The format center
/// </summary>
private StringFormat format_center = null;
/// <summary>
/// The is render right coordinate
/// </summary>
private bool isRenderRightCoordinate = true;
/// <summary>
/// The curve name width
/// </summary>
private int curveNameWidth = 100;
/// <summary>
/// The components
/// </summary>
private IContainer components = null;
/// <summary>
/// 获取或设置控件的背景色。
/// </summary>
/// <value>The color of the back.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[Browsable(true)]
[Description("获取或设置控件的背景色")]
[Category("自定义")]
[DefaultValue(typeof(Color), "Transparent")]
[EditorBrowsable(EditorBrowsableState.Always)]
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
/// <summary>
/// Gets or sets the value maximum left.
/// </summary>
/// <value>The value maximum left.</value>
[Category("自定义")]
[Description("获取或设置图形的左纵坐标的最大值,该值必须大于最小值")]
[Browsable(true)]
[DefaultValue(100f)]
public float ValueMaxLeft
{
get
{
return value_max_left;
}
set
{
value_max_left = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value minimum left.
/// </summary>
/// <value>The value minimum left.</value>
[Category("自定义")]
[Description("获取或设置图形的左纵坐标的最小值,该值必须小于最大值")]
[Browsable(true)]
[DefaultValue(0f)]
public float ValueMinLeft
{
get
{
return value_min_left;
}
set
{
value_min_left = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value maximum right.
/// </summary>
/// <value>The value maximum right.</value>
[Category("自定义")]
[Description("获取或设置图形的右纵坐标的最大值,该值必须大于最小值")]
[Browsable(true)]
[DefaultValue(100f)]
public float ValueMaxRight
{
get
{
return value_max_right;
}
set
{
value_max_right = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value minimum right.
/// </summary>
/// <value>The value minimum right.</value>
[Category("自定义")]
[Description("获取或设置图形的右纵坐标的最小值,该值必须小于最大值")]
[Browsable(true)]
[DefaultValue(0f)]
public float ValueMinRight
{
get
{
return value_min_right;
}
set
{
value_min_right = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the value segment.
/// </summary>
/// <value>The value segment.</value>
[Category("自定义")]
[Description("获取或设置图形的纵轴分段数")]
[Browsable(true)]
[DefaultValue(5)]
public int ValueSegment
{
get
{
return value_Segment;
}
set
{
value_Segment = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is abscissa strech.
/// </summary>
/// <value><c>true</c> if this instance is abscissa strech; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("获取或设置所有的数据是否强制在一个界面里显示")]
[Browsable(true)]
[DefaultValue(false)]
public bool IsAbscissaStrech
{
get
{
return value_IsAbscissaStrech;
}
set
{
value_IsAbscissaStrech = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the strech data count maximum.
/// </summary>
/// <value>The strech data count maximum.</value>
[Category("自定义")]
[Description("获取或设置拉伸模式下的最大数据量")]
[Browsable(true)]
[DefaultValue(300)]
public int StrechDataCountMax
{
get
{
return value_StrechDataCountMax;
}
set
{
value_StrechDataCountMax = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is render dash line.
/// </summary>
/// <value><c>true</c> if this instance is render dash line; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("获取或设置虚线是否进行显示")]
[Browsable(true)]
[DefaultValue(true)]
public bool IsRenderDashLine
{
get
{
return value_IsRenderDashLine;
}
set
{
value_IsRenderDashLine = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the color lines and text.
/// </summary>
/// <value>The color lines and text.</value>
[Category("自定义")]
[Description("获取或设置坐标轴及相关信息文本的颜色")]
[Browsable(true)]
[DefaultValue(typeof(Color), "DimGray")]
public Color ColorLinesAndText
{
get
{
return color_deep;
}
set
{
color_deep = value;
InitializationColor();
Invalidate();
}
}
/// <summary>
/// Gets or sets the color dash lines.
/// </summary>
/// <value>The color dash lines.</value>
[Category("自定义")]
[Description("获取或设置虚线的颜色")]
[Browsable(true)]
public Color ColorDashLines
{
get
{
return color_dash;
}
set
{
color_dash = value;
if (pen_dash != null)
pen_dash.Dispose();
pen_dash = new Pen(color_dash);
pen_dash.DashStyle = DashStyle.Custom;
pen_dash.DashPattern = new float[2]
{
5f,
5f
};
Invalidate();
}
}
/// <summary>
/// Gets or sets the interval abscissa text.
/// </summary>
/// <value>The interval abscissa text.</value>
[Category("自定义")]
[Description("获取或设置纵向虚线的分隔情况,单位为多少个数据")]
[Browsable(true)]
[DefaultValue(100)]
public int IntervalAbscissaText
{
get
{
return value_IntervalAbscissaText;
}
set
{
value_IntervalAbscissaText = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the text add format.
/// </summary>
/// <value>The text add format.</value>
[Category("自定义")]
[Description("获取或设置实时数据新增时文本相对应于时间的格式化字符串,默认HH:mm")]
[Browsable(true)]
[DefaultValue("HH:mm")]
public string TextAddFormat
{
get
{
return textFormat;
}
set
{
textFormat = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
[Category("自定义")]
[Description("获取或设置图标的标题信息")]
[Browsable(true)]
[DefaultValue("")]
public string Title
{
get
{
return value_title;
}
set
{
value_title = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is render right coordinate.
/// </summary>
/// <value><c>true</c> if this instance is render right coordinate; otherwise, <c>false</c>.</value>
[Category("自定义")]
[Description("获取或设置是否显示右侧的坐标系信息")]
[Browsable(true)]
[DefaultValue(true)]
public bool IsRenderRightCoordinate
{
get
{
return isRenderRightCoordinate;
}
set
{
isRenderRightCoordinate = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the width of the curve name.
/// </summary>
/// <value>The width of the curve name.</value>
[Browsable(true)]
[Description("获取或设置曲线名称的布局宽度")]
[Category("自定义")]
[DefaultValue(100)]
public int CurveNameWidth
{
get
{
return curveNameWidth;
}
set
{
if (value > 10)
{
curveNameWidth = value;
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="UCCurve" /> class.
/// </summary>
public UCCurve()
{
InitializeComponent();
random = new Random();
data_list = new Dictionary<string, CurveItem>();
auxiliary_lines = new List<AuxiliaryLine>();
MarkTexts = new List<MarkText>();
auxiliary_Labels = new List<AuxiliaryLable>();
format_left = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Near
};
format_right = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Far
};
format_center = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Center
};
font_size9 = new Font("微软雅黑", 9f);
font_size12 = new Font("微软雅黑", 12f);
InitializationColor();
pen_dash = new Pen(color_deep);
pen_dash.DashStyle = DashStyle.Custom;
pen_dash.DashPattern = new float[2]
{
5f,
5f
};
SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
/// <summary>
/// Initializations the color.
/// </summary>
private void InitializationColor()
{
if (pen_normal != null)
pen_normal.Dispose();
if (brush_deep != null)
brush_deep.Dispose();
pen_normal = new Pen(color_deep);
brush_deep = new SolidBrush(color_deep);
}
/// <summary>
/// Sets the curve text.
/// </summary>
/// <param name="descriptions">The descriptions.</param>
public void SetCurveText(string[] descriptions)
{
data_text = descriptions;
Invalidate();
}
/// <summary>
/// Sets the left curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
public void SetLeftCurve(string key, float[] data, Color? lineColor = null)
{
SetCurve(key, true, data, lineColor, 1f, false);
}
/// <summary>
/// Sets the left curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="isSmooth">if set to <c>true</c> [is smooth].</param>
public void SetLeftCurve(string key, float[] data, Color? lineColor, bool isSmooth = false)
{
SetCurve(key, true, data, lineColor, 1f, isSmooth);
}
/// <summary>
/// Sets the right curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
public void SetRightCurve(string key, float[] data, Color? lineColor = null)
{
SetCurve(key, false, data, lineColor, 1f, false);
}
/// <summary>
/// Sets the right curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="isSmooth">if set to <c>true</c> [is smooth].</param>
public void SetRightCurve(string key, float[] data, Color? lineColor, bool isSmooth = false)
{
SetCurve(key, false, data, lineColor, 1f, isSmooth);
}
/// <summary>
/// Sets the curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="isLeft">if set to <c>true</c> [is left].</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="isSmooth">if set to <c>true</c> [is smooth].</param>
public void SetCurve(string key, bool isLeft, float[] data, Color? lineColor, float thickness, bool isSmooth)
{
if (data_list.ContainsKey(key))
{
if (data == null)
{
data = new float[0];
}
data_list[key].Data = data;
}
else
{
if (data == null)
{
data = new float[0];
}
data_list.Add(key, new CurveItem
{
Data = data,
MarkText = new string[data.Length],
LineThickness = thickness,
LineColor = lineColor ?? ControlHelper.Colors[data_list.Count + 13],
IsLeftFrame = isLeft,
IsSmoothCurve = isSmooth
});
if (data_text == null)
{
data_text = new string[data.Length];
}
}
Invalidate();
}
/// <summary>
/// Removes the curve.
/// </summary>
/// <param name="key">The key.</param>
public void RemoveCurve(string key)
{
if (data_list.ContainsKey(key))
{
data_list.Remove(key);
}
if (data_list.Count == 0)
{
data_text = new string[0];
}
Invalidate();
}
/// <summary>
/// Removes all curve.
/// </summary>
public void RemoveAllCurve()
{
int count = data_list.Count;
data_list.Clear();
if (data_list.Count == 0)
{
data_text = new string[0];
}
if (count > 0)
{
Invalidate();
}
}
/// <summary>
/// Removes all curve data.
/// </summary>
public void RemoveAllCurveData()
{
int count = data_list.Count;
foreach (KeyValuePair<string, CurveItem> item in data_list)
{
item.Value.Data = new float[0];
item.Value.MarkText = new string[0];
}
data_text = new string[0];
if (count > 0)
{
Invalidate();
}
}
/// <summary>
/// Gets the curve item.
/// </summary>
/// <param name="key">The key.</param>
/// <returns>CurveItem.</returns>
public CurveItem GetCurveItem(string key)
{
if (data_list.ContainsKey(key))
{
return data_list[key];
}
return null;
}
/// <summary>
/// Saves to bitmap.
/// </summary>
/// <returns>Bitmap.</returns>
public Bitmap SaveToBitmap()
{
return SaveToBitmap(base.Width, base.Height);
}
/// <summary>
/// Saves to bitmap.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <returns>Bitmap.</returns>
public Bitmap SaveToBitmap(int width, int height)
{
Bitmap bitmap = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(bitmap);
OnPaint(new PaintEventArgs(graphics, new Rectangle(0, 0, width, height)));
return bitmap;
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
/// <param name="isUpdateUI">if set to <c>true</c> [is update UI].</param>
private void AddCurveData(string key, float[] values, string[] markTexts, bool isUpdateUI)
{
if ((values != null && values.Length < 1) || !data_list.ContainsKey(key))
{
return;
}
CurveItem CurveItem = data_list[key];
if (CurveItem.Data != null)
{
if (value_IsAbscissaStrech)
{
ControlHelper.AddArrayData(ref CurveItem.Data, values, value_StrechDataCountMax);
ControlHelper.AddArrayData(ref CurveItem.MarkText, markTexts, value_StrechDataCountMax);
}
else
{
ControlHelper.AddArrayData(ref CurveItem.Data, values, 4096);
ControlHelper.AddArrayData(ref CurveItem.MarkText, markTexts, 4096);
}
if (isUpdateUI)
{
Invalidate();
}
}
}
/// <summary>
/// Adds the curve time.
/// </summary>
/// <param name="count">The count.</param>
private void AddCurveTime(int count)
{
AddCurveTime(count, DateTime.Now.ToString(textFormat));
}
/// <summary>
/// Adds the curve time.
/// </summary>
/// <param name="count">The count.</param>
/// <param name="text">The text.</param>
private void AddCurveTime(int count, string text)
{
if (data_text != null)
{
string[] array = new string[count];
for (int i = 0; i < array.Length; i++)
{
array[i] = text;
}
if (value_IsAbscissaStrech)
{
ControlHelper.AddArrayData(ref data_text, array, value_StrechDataCountMax);
}
else
{
ControlHelper.AddArrayData(ref data_text, array, 4096);
}
}
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public void AddCurveData(string key, float value)
{
AddCurveData(key, new float[1]
{
value
});
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
/// <param name="markText">The mark text.</param>
public void AddCurveData(string key, float value, string markText)
{
AddCurveData(key, new float[1]
{
value
}, new string[1]
{
markText
});
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="values">The values.</param>
public void AddCurveData(string key, float[] values)
{
AddCurveData(key, values, null);
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
public void AddCurveData(string key, float[] values, string[] markTexts)
{
if (markTexts == null)
{
markTexts = new string[values.Length];
}
AddCurveData(key, values, markTexts, false);
if (values != null && values.Length != 0)
{
AddCurveTime(values.Length);
}
Invalidate();
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
public void AddCurveData(string[] keys, float[] values)
{
AddCurveData(keys, values, null);
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="axisText">The axis text.</param>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
public void AddCurveData(string axisText, string[] keys, float[] values)
{
AddCurveData(axisText, keys, values, null);
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
/// <exception cref="ArgumentNullException">keys
/// or
/// values</exception>
/// <exception cref="Exception">两个参数的数组长度不一致。
/// or
/// 两个参数的数组长度不一致。</exception>
public void AddCurveData(string[] keys, float[] values, string[] markTexts)
{
if (keys == null)
{
throw new ArgumentNullException("keys");
}
if (values == null)
{
throw new ArgumentNullException("values");
}
if (markTexts == null)
{
markTexts = new string[keys.Length];
}
if (keys.Length != values.Length)
{
throw new Exception("两个参数的数组长度不一致。");
}
if (keys.Length != markTexts.Length)
{
throw new Exception("两个参数的数组长度不一致。");
}
for (int i = 0; i < keys.Length; i++)
{
AddCurveData(keys[i], new float[1]
{
values[i]
}, new string[1]
{
markTexts[i]
}, false);
}
AddCurveTime(1);
Invalidate();
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="axisText">The axis text.</param>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
/// <exception cref="ArgumentNullException">keys
/// or
/// values</exception>
/// <exception cref="Exception">两个参数的数组长度不一致。
/// or
/// 两个参数的数组长度不一致。</exception>
public void AddCurveData(string axisText, string[] keys, float[] values, string[] markTexts)
{
if (keys == null)
{
throw new ArgumentNullException("keys");
}
if (values == null)
{
throw new ArgumentNullException("values");
}
if (markTexts == null)
{
markTexts = new string[keys.Length];
}
if (keys.Length != values.Length)
{
throw new Exception("两个参数的数组长度不一致。");
}
if (keys.Length != markTexts.Length)
{
throw new Exception("两个参数的数组长度不一致。");
}
for (int i = 0; i < keys.Length; i++)
{
AddCurveData(keys[i], new float[1]
{
values[i]
}, new string[1]
{
markTexts[i]
}, false);
}
AddCurveTime(1, axisText);
Invalidate();
}
/// <summary>
/// Sets the curve visible.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="visible">if set to <c>true</c> [visible].</param>
public void SetCurveVisible(string key, bool visible)
{
if (data_list.ContainsKey(key))
{
CurveItem CurveItem = data_list[key];
CurveItem.Visible = visible;
Invalidate();
}
}
/// <summary>
/// Sets the curve visible.
/// </summary>
/// <param name="keys">The keys.</param>
/// <param name="visible">if set to <c>true</c> [visible].</param>
public void SetCurveVisible(string[] keys, bool visible)
{
foreach (string key in keys)
{
if (data_list.ContainsKey(key))
{
CurveItem CurveItem = data_list[key];
CurveItem.Visible = visible;
}
}
Invalidate();
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public void AddLeftAuxiliary(float value)
{
AddLeftAuxiliary(value, ColorLinesAndText);
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
public void AddLeftAuxiliary(float value, Color lineColor)
{
AddLeftAuxiliary(value, lineColor, 1f, true);
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
public void AddLeftAuxiliary(float value, Color lineColor, float lineThickness, bool isDashLine)
{
AddAuxiliary(value, lineColor, lineThickness, isDashLine, true);
}
/// <summary>
/// Adds the right auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public void AddRightAuxiliary(float value)
{
AddRightAuxiliary(value, ColorLinesAndText);
}
/// <summary>
/// Adds the right auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
public void AddRightAuxiliary(float value, Color lineColor)
{
AddRightAuxiliary(value, lineColor, 1f, true);
}
/// <summary>
/// Adds the right auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
public void AddRightAuxiliary(float value, Color lineColor, float lineThickness, bool isDashLine)
{
AddAuxiliary(value, lineColor, lineThickness, isDashLine, false);
}
/// <summary>
/// Adds the auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
/// <param name="isLeft">if set to <c>true</c> [is left].</param>
private void AddAuxiliary(float value, Color lineColor, float lineThickness, bool isDashLine, bool isLeft)
{
auxiliary_lines.Add(new AuxiliaryLine
{
Value = value,
LineColor = lineColor,
PenDash = new Pen(lineColor)
{
DashStyle = DashStyle.Custom,
DashPattern = new float[2]
{
5f,
5f
}
},
PenSolid = new Pen(lineColor),
IsDashStyle = isDashLine,
IsLeftFrame = isLeft,
LineThickness = lineThickness,
LineTextBrush = new SolidBrush(lineColor)
});
Invalidate();
}
/// <summary>
/// Removes the auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public void RemoveAuxiliary(float value)
{
int num = 0;
for (int num2 = auxiliary_lines.Count - 1; num2 >= 0; num2--)
{
if (auxiliary_lines[num2].Value == value)
{
auxiliary_lines[num2].Dispose();
auxiliary_lines.RemoveAt(num2);
num++;
}
}
if (num > 0)
{
Invalidate();
}
}
/// <summary>
/// Removes all auxiliary.
/// </summary>
public void RemoveAllAuxiliary()
{
int count = auxiliary_lines.Count;
auxiliary_lines.Clear();
if (count > 0)
{
Invalidate();
}
}
/// <summary>
/// Adds the auxiliary label.
/// </summary>
/// <param name="auxiliaryLable">The auxiliary lable.</param>
public void AddAuxiliaryLabel(AuxiliaryLable auxiliaryLable)
{
auxiliary_Labels.Add(auxiliaryLable);
}
/// <summary>
/// Removes the auxiliary lable.
/// </summary>
/// <param name="auxiliaryLable">The auxiliary lable.</param>
public void RemoveAuxiliaryLable(AuxiliaryLable auxiliaryLable)
{
if (auxiliary_Labels.Remove(auxiliaryLable))
{
Invalidate();
}
}
/// <summary>
/// Removes all auxiliary lable.
/// </summary>
public void RemoveAllAuxiliaryLable()
{
int count = auxiliary_Labels.Count;
auxiliary_Labels.Clear();
if (count > 0)
{
Invalidate();
}
}
/// <summary>
/// Adds the mark text.
/// </summary>
/// <param name="markText">The mark text.</param>
public void AddMarkText(MarkText markText)
{
MarkTexts.Add(markText);
if (data_list.Count > 0)
{
Invalidate();
}
}
/// <summary>
/// Adds the mark text.
/// </summary>
/// <param name="strCurveKey">The string curve key.</param>
/// <param name="intValueIndex">Index of the int value.</param>
/// <param name="strText">The string text.</param>
/// <param name="textColor">Color of the text.</param>
public void AddMarkText(string strCurveKey, int intValueIndex, string strText, Color? textColor = null)
{
AddMarkText(new MarkText() { CurveKey = strCurveKey, PositionStyle = MarkTextPositionStyle.Auto, Text = strText, TextColor = textColor, Index = intValueIndex });
}
/// <summary>
/// Removes the mark text.
/// </summary>
/// <param name="markText">The mark text.</param>
public void RemoveMarkText(MarkText markText)
{
MarkTexts.Remove(markText);
if (data_list.Count > 0)
{
Invalidate();
}
}
/// <summary>
/// Removes all mark text.
/// </summary>
public void RemoveAllMarkText()
{
MarkTexts.Clear();
if (data_list.Count > 0)
{
Invalidate();
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseMove" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
bool flag = false;
foreach (KeyValuePair<string, CurveItem> item in data_list)
{
if (item.Value.TitleRegion.Contains(e.Location))
{
flag = true;
break;
}
}
Cursor = (flag ? Cursors.Hand : Cursors.Arrow);
}
/// <summary>
/// Handles the <see cref="E:MouseDown" /> event.
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
foreach (KeyValuePair<string, CurveItem> item in data_list)
{
if (item.Value.TitleRegion.Contains(e.Location))
{
item.Value.LineRenderVisiable = !item.Value.LineRenderVisiable;
Invalidate();
break;
}
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
protected override void OnPaint(PaintEventArgs e)
{
try
{
Graphics graphics = e.Graphics;
graphics.SetGDIHigh();
if (BackColor != Color.Transparent)
{
graphics.Clear(BackColor);
}
int width = base.Width;
int height = base.Height;
if (width < 120 || height < 60)
{
return;
}
Point[] array = new Point[4]
{
new Point(leftRight - 1, upDowm - 8),
new Point(leftRight - 1, height - upDowm),
new Point(width - leftRight, height - upDowm),
new Point(width - leftRight, upDowm - 8)
};
graphics.DrawLine(pen_normal, array[0], array[1]);
graphics.DrawLine(pen_normal, array[1], array[2]);
if (isRenderRightCoordinate)
{
graphics.DrawLine(pen_normal, array[2], array[3]);
}
if (!string.IsNullOrEmpty(value_title))
{
graphics.DrawString(value_title, font_size9, brush_deep, new Rectangle(0, 0, width - 1, 20), format_center);
}
if (data_list.Count > 0)
{
float num = leftRight + 10;
foreach (KeyValuePair<string, CurveItem> item in data_list)
{
if (item.Value.Visible)
{
var titleSize=graphics.MeasureString(item.Key, Font);
SolidBrush solidBrush = item.Value.LineRenderVisiable ? new SolidBrush(item.Value.LineColor) : new SolidBrush(Color.FromArgb(80, item.Value.LineColor));
graphics.FillRectangle(solidBrush, num + 8f, 24f, 20f, 14f);
graphics.DrawString(item.Key, Font, solidBrush, new PointF(num + 30f, 24f+(14 - titleSize.Height) / 2));
item.Value.TitleRegion = new RectangleF(num, 24f, 60f, 18f);
solidBrush.Dispose();
num += titleSize.Width + 30;
}
}
}
for (int i = 0; i < auxiliary_Labels.Count; i++)
{
if (!string.IsNullOrEmpty(auxiliary_Labels[i].Text))
{
int num2 = (auxiliary_Labels[i].LocationX > 1f) ? ((int)auxiliary_Labels[i].LocationX) : ((int)(auxiliary_Labels[i].LocationX * (float)width));
int num3 = (int)graphics.MeasureString(auxiliary_Labels[i].Text, Font).Width + 3;
Point[] points = new Point[6]
{
new Point(num2, 11),
new Point(num2 + 10, 20),
new Point(num2 + num3 + 10, 20),
new Point(num2 + num3 + 10, 0),
new Point(num2 + 10, 0),
new Point(num2, 11)
};
graphics.FillPolygon(auxiliary_Labels[i].TextBack, points);
graphics.DrawString(auxiliary_Labels[i].Text, Font, auxiliary_Labels[i].TextBrush, new Rectangle(num2 + 7, 0, num3 + 3, 20), format_center);
}
}
ControlHelper.PaintTriangle(graphics, brush_deep, new Point(leftRight - 1, upDowm - 8), 4, GraphDirection.Upward);
if (isRenderRightCoordinate)
{
ControlHelper.PaintTriangle(graphics, brush_deep, new Point(width - leftRight, upDowm - 8), 4, GraphDirection.Upward);
}
for (int j = 0; j < auxiliary_lines.Count; j++)
{
if (auxiliary_lines[j].IsLeftFrame)
{
auxiliary_lines[j].PaintValue = ControlHelper.ComputePaintLocationY(value_max_left, value_min_left, height - upDowm - upDowm, auxiliary_lines[j].Value) + (float)upDowm;
}
else
{
auxiliary_lines[j].PaintValue = ControlHelper.ComputePaintLocationY(value_max_right, value_min_right, height - upDowm - upDowm, auxiliary_lines[j].Value) + (float)upDowm;
}
}
for (int k = 0; k <= value_Segment; k++)
{
float value = (float)((double)k * (double)(value_max_left - value_min_left) / (double)value_Segment + (double)value_min_left);
float num4 = ControlHelper.ComputePaintLocationY(value_max_left, value_min_left, height - upDowm - upDowm, value) + (float)upDowm;
if (IsNeedPaintDash(num4))
{
graphics.DrawLine(pen_normal, leftRight - 4, num4, leftRight - 1, num4);
RectangleF layoutRectangle = new RectangleF(0f, num4 - 9f, leftRight - 4, 20f);
graphics.DrawString(value.ToString(), font_size9, brush_deep, layoutRectangle, format_right);
if (isRenderRightCoordinate)
{
float num5 = (float)k * (value_max_right - value_min_right) / (float)value_Segment + value_min_right;
graphics.DrawLine(pen_normal, width - leftRight + 1, num4, width - leftRight + 4, num4);
layoutRectangle.Location = new PointF(width - leftRight + 4, num4 - 9f);
graphics.DrawString(num5.ToString(), font_size9, brush_deep, layoutRectangle, format_left);
}
if (k > 0 && value_IsRenderDashLine)
{
graphics.DrawLine(pen_dash, leftRight, num4, width - leftRight, num4);
}
}
}
if (value_IsRenderDashLine)
{
if (value_IsAbscissaStrech)
{
float num6 = (float)(width - leftRight * 2) * 1f / (float)(value_StrechDataCountMax - 1);
int num7 = CalculateDataCountByOffect(num6);
for (int l = 0; l < value_StrechDataCountMax; l += num7)
{
if (l > 0 && l < value_StrechDataCountMax - 1)
{
graphics.DrawLine(pen_dash, (float)l * num6 + (float)leftRight, upDowm, (float)l * num6 + (float)leftRight, height - upDowm - 1);
}
if (data_text != null && l < data_text.Length && (float)l * num6 + (float)leftRight < (float)(data_text.Length - 1) * num6 + (float)leftRight - 40f)
{
graphics.DrawString(layoutRectangle: new Rectangle((int)((float)l * num6), height - upDowm + 1, leftRight * 2, upDowm), s: data_text[l], font: font_size9, brush: brush_deep, format: format_center);
}
}
string[] array2 = data_text;
if (array2 != null && array2.Length > 1)
{
if (data_text.Length < value_StrechDataCountMax)
{
graphics.DrawLine(pen_dash, (float)(data_text.Length - 1) * num6 + (float)leftRight, upDowm, (float)(data_text.Length - 1) * num6 + (float)leftRight, height - upDowm - 1);
}
graphics.DrawString(layoutRectangle: new Rectangle((int)((float)(data_text.Length - 1) * num6 + (float)leftRight) - leftRight, height - upDowm + 1, leftRight * 2, upDowm), s: data_text[data_text.Length - 1], font: font_size9, brush: brush_deep, format: format_center);
}
}
else if (value_IntervalAbscissaText > 0)
{
int num8 = width - 2 * leftRight + 1;
for (int m = leftRight; m < width - leftRight; m += value_IntervalAbscissaText)
{
if (m != leftRight)
{
graphics.DrawLine(pen_dash, m, upDowm, m, height - upDowm - 1);
}
if (data_text == null)
{
continue;
}
int num9 = (num8 > data_text.Length) ? data_text.Length : num8;
if (m - leftRight < data_text.Length && num9 - (m - leftRight) > 40)
{
if (data_text.Length <= num8)
{
graphics.DrawString(layoutRectangle: new Rectangle(m - leftRight, height - upDowm + 1, leftRight * 2, upDowm), s: data_text[m - leftRight], font: font_size9, brush: brush_deep, format: format_center);
}
else
{
graphics.DrawString(layoutRectangle: new Rectangle(m - leftRight, height - upDowm + 1, leftRight * 2, upDowm), s: data_text[m - leftRight + data_text.Length - num8], font: font_size9, brush: brush_deep, format: format_center);
}
}
}
string[] array3 = data_text;
if (array3 != null && array3.Length > 1)
{
if (data_text.Length >= num8)
{
graphics.DrawString(layoutRectangle: new Rectangle(width - leftRight - leftRight, height - upDowm + 1, leftRight * 2, upDowm), s: data_text[data_text.Length - 1], font: font_size9, brush: brush_deep, format: format_center);
}
else
{
graphics.DrawLine(pen_dash, data_text.Length + leftRight - 1, upDowm, data_text.Length + leftRight - 1, height - upDowm - 1);
graphics.DrawString(layoutRectangle: new Rectangle(data_text.Length + leftRight - 1 - leftRight, height - upDowm + 1, leftRight * 2, upDowm), s: data_text[data_text.Length - 1], font: font_size9, brush: brush_deep, format: format_center);
}
}
}
}
for (int n = 0; n < auxiliary_lines.Count; n++)
{
if (auxiliary_lines[n].IsLeftFrame)
{
graphics.DrawLine(auxiliary_lines[n].GetPen(), leftRight - 4, auxiliary_lines[n].PaintValue, leftRight - 1, auxiliary_lines[n].PaintValue);
graphics.DrawString(layoutRectangle: new RectangleF(0f, auxiliary_lines[n].PaintValue - 9f, leftRight - 4, 20f), s: auxiliary_lines[n].Value.ToString(), font: font_size9, brush: auxiliary_lines[n].LineTextBrush, format: format_right);
}
else
{
graphics.DrawLine(auxiliary_lines[n].GetPen(), width - leftRight + 1, auxiliary_lines[n].PaintValue, width - leftRight + 4, auxiliary_lines[n].PaintValue);
graphics.DrawString(layoutRectangle: new RectangleF(width - leftRight + 4, auxiliary_lines[n].PaintValue - 9f, leftRight - 4, 20f), s: auxiliary_lines[n].Value.ToString(), font: font_size9, brush: auxiliary_lines[n].LineTextBrush, format: format_left);
}
graphics.DrawLine(auxiliary_lines[n].GetPen(), leftRight, auxiliary_lines[n].PaintValue, width - leftRight, auxiliary_lines[n].PaintValue);
}
if (value_IsAbscissaStrech)
{
foreach (MarkText MarkText in MarkTexts)
{
foreach (KeyValuePair<string, CurveItem> item2 in data_list)
{
if (item2.Value.Visible && item2.Value.LineRenderVisiable && !(item2.Key != MarkText.CurveKey))
{
float[] data = item2.Value.Data;
if (data != null && data.Length > 1)
{
float num10 = (float)(width - leftRight * 2) * 1f / (float)(value_StrechDataCountMax - 1);
if (MarkText.Index >= 0 && MarkText.Index < item2.Value.Data.Length)
{
PointF pointF = new PointF((float)leftRight + (float)MarkText.Index * num10, ControlHelper.ComputePaintLocationY(item2.Value.IsLeftFrame ? value_max_left : value_max_right, item2.Value.IsLeftFrame ? value_min_left : value_min_right, height - upDowm - upDowm, item2.Value.Data[MarkText.Index]) + (float)upDowm);
graphics.FillEllipse(new SolidBrush(MarkText.TextColor ?? item2.Value.LineColor), new RectangleF(pointF.X - 3f, pointF.Y - 3f, 6f, 6f));
switch ((MarkText.PositionStyle == MarkTextPositionStyle.Auto) ? MarkText.CalculateDirectionFromDataIndex(item2.Value.Data, MarkText.Index) : MarkText.PositionStyle)
{
case MarkTextPositionStyle.Left:
graphics.DrawString(MarkText.Text, Font, new SolidBrush(MarkText.TextColor ?? item2.Value.LineColor), new RectangleF(pointF.X - 100f, pointF.Y - (float)Font.Height, 100 - MarkText.MarkTextOffect, Font.Height * 2), format_right);
break;
case MarkTextPositionStyle.Up:
graphics.DrawString(MarkText.Text, Font, new SolidBrush(MarkText.TextColor ?? item2.Value.LineColor), new RectangleF(pointF.X - 100f, pointF.Y - (float)Font.Height - (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
case MarkTextPositionStyle.Right:
graphics.DrawString(MarkText.Text, Font, new SolidBrush(MarkText.TextColor ?? item2.Value.LineColor), new RectangleF(pointF.X + (float)MarkText.MarkTextOffect, pointF.Y - (float)Font.Height, 100f, Font.Height * 2), format_left);
break;
case MarkTextPositionStyle.Down:
graphics.DrawString(MarkText.Text, Font, new SolidBrush(MarkText.TextColor ?? item2.Value.LineColor), new RectangleF(pointF.X - 100f, pointF.Y + (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
}
}
}
}
}
}
foreach (CurveItem value2 in data_list.Values)
{
if (value2.Visible && value2.LineRenderVisiable)
{
float[] data2 = value2.Data;
if (data2 != null && data2.Length > 1)
{
float num11 = (float)(width - leftRight * 2) * 1f / (float)(value_StrechDataCountMax - 1);
PointF[] array4 = new PointF[value2.Data.Length];
for (int num12 = 0; num12 < value2.Data.Length; num12++)
{
array4[num12].X = (float)leftRight + (float)num12 * num11;
array4[num12].Y = ControlHelper.ComputePaintLocationY(value2.IsLeftFrame ? value_max_left : value_max_right, value2.IsLeftFrame ? value_min_left : value_min_right, height - upDowm - upDowm, value2.Data[num12]) + (float)upDowm;
if (!string.IsNullOrEmpty(value2.MarkText[num12]))
{
using (Brush brush = new SolidBrush(value2.LineColor))
{
graphics.FillEllipse(brush, new RectangleF(array4[num12].X - 3f, array4[num12].Y - 3f, 6f, 6f));
switch (MarkText.CalculateDirectionFromDataIndex(value2.Data, num12))
{
case MarkTextPositionStyle.Left:
graphics.DrawString(value2.MarkText[num12], Font, brush, new RectangleF(array4[num12].X - 100f, array4[num12].Y - (float)Font.Height, 100 - MarkText.MarkTextOffect, Font.Height * 2), format_right);
break;
case MarkTextPositionStyle.Up:
graphics.DrawString(value2.MarkText[num12], Font, brush, new RectangleF(array4[num12].X - 100f, array4[num12].Y - (float)Font.Height - (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
case MarkTextPositionStyle.Right:
graphics.DrawString(value2.MarkText[num12], Font, brush, new RectangleF(array4[num12].X + (float)MarkText.MarkTextOffect, array4[num12].Y - (float)Font.Height, 100f, Font.Height * 2), format_left);
break;
case MarkTextPositionStyle.Down:
graphics.DrawString(value2.MarkText[num12], Font, brush, new RectangleF(array4[num12].X - 100f, array4[num12].Y + (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
}
}
}
}
using (Pen pen2 = new Pen(value2.LineColor, value2.LineThickness))
{
if (value2.IsSmoothCurve)
{
graphics.DrawCurve(pen2, array4);
}
else
{
graphics.DrawLines(pen2, array4);
}
}
}
}
}
}
else
{
foreach (MarkText MarkText2 in MarkTexts)
{
foreach (KeyValuePair<string, CurveItem> item3 in data_list)
{
if (item3.Value.Visible && item3.Value.LineRenderVisiable && !(item3.Key != MarkText2.CurveKey))
{
float[] data3 = item3.Value.Data;
if (data3 != null && data3.Length > 1 && MarkText2.Index >= 0 && MarkText2.Index < item3.Value.Data.Length)
{
PointF pointF2 = new PointF(leftRight + MarkText2.Index, ControlHelper.ComputePaintLocationY(item3.Value.IsLeftFrame ? value_max_left : value_max_right, item3.Value.IsLeftFrame ? value_min_left : value_min_right, height - upDowm - upDowm, item3.Value.Data[MarkText2.Index]) + (float)upDowm);
graphics.FillEllipse(new SolidBrush(MarkText2.TextColor ?? item3.Value.LineColor), new RectangleF(pointF2.X - 3f, pointF2.Y - 3f, 6f, 6f));
switch ((MarkText2.PositionStyle == MarkTextPositionStyle.Auto) ? MarkText.CalculateDirectionFromDataIndex(item3.Value.Data, MarkText2.Index) : MarkText2.PositionStyle)
{
case MarkTextPositionStyle.Left:
graphics.DrawString(MarkText2.Text, Font, new SolidBrush(MarkText2.TextColor ?? item3.Value.LineColor), new RectangleF(pointF2.X - 100f, pointF2.Y - (float)Font.Height, 100 - MarkText.MarkTextOffect, Font.Height * 2), format_right);
break;
case MarkTextPositionStyle.Up:
graphics.DrawString(MarkText2.Text, Font, new SolidBrush(MarkText2.TextColor ?? item3.Value.LineColor), new RectangleF(pointF2.X - 100f, pointF2.Y - (float)Font.Height - (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
case MarkTextPositionStyle.Right:
graphics.DrawString(MarkText2.Text, Font, new SolidBrush(MarkText2.TextColor ?? item3.Value.LineColor), new RectangleF(pointF2.X + (float)MarkText.MarkTextOffect, pointF2.Y - (float)Font.Height, 100f, Font.Height * 2), format_left);
break;
case MarkTextPositionStyle.Down:
graphics.DrawString(MarkText2.Text, Font, new SolidBrush(MarkText2.TextColor ?? item3.Value.LineColor), new RectangleF(pointF2.X - 100f, pointF2.Y + (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
}
}
}
}
}
foreach (CurveItem value3 in data_list.Values)
{
if (value3.Visible && value3.LineRenderVisiable)
{
float[] data4 = value3.Data;
if (data4 != null && data4.Length > 1)
{
int num13 = width - 2 * leftRight + 1;
PointF[] array5;
if (value3.Data.Length <= num13)
{
array5 = new PointF[value3.Data.Length];
for (int num14 = 0; num14 < value3.Data.Length; num14++)
{
array5[num14].X = leftRight + num14;
array5[num14].Y = ControlHelper.ComputePaintLocationY(value3.IsLeftFrame ? value_max_left : value_max_right, value3.IsLeftFrame ? value_min_left : value_min_right, height - upDowm - upDowm, value3.Data[num14]) + (float)upDowm;
DrawMarkPoint(graphics, value3.MarkText[num14], array5[num14], value3.LineColor, MarkText.CalculateDirectionFromDataIndex(value3.Data, num14));
}
}
else
{
array5 = new PointF[num13];
for (int num15 = 0; num15 < array5.Length; num15++)
{
int num16 = num15 + value3.Data.Length - num13;
array5[num15].X = leftRight + num15;
array5[num15].Y = ControlHelper.ComputePaintLocationY(value3.IsLeftFrame ? value_max_left : value_max_right, value3.IsLeftFrame ? value_min_left : value_min_right, height - upDowm - upDowm, value3.Data[num16]) + (float)upDowm;
DrawMarkPoint(graphics, value3.MarkText[num16], array5[num15], value3.LineColor, MarkText.CalculateDirectionFromDataIndex(value3.Data, num16));
}
}
using (Pen pen3 = new Pen(value3.LineColor, value3.LineThickness))
{
if (value3.IsSmoothCurve)
{
graphics.DrawCurve(pen3, array5);
}
else
{
graphics.DrawLines(pen3, array5);
}
}
}
}
}
}
base.OnPaint(e);
}
catch (Exception exc)
{
e.Graphics.DrawString(exc.Message, this.Font, Brushes.Black, 10, 10);
}
}
/// <summary>
/// Draws the mark point.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="markText">The mark text.</param>
/// <param name="center">The center.</param>
/// <param name="color">The color.</param>
/// <param name="markTextPosition">The mark text position.</param>
private void DrawMarkPoint(Graphics g, string markText, PointF center, Color color, MarkTextPositionStyle markTextPosition)
{
if (!string.IsNullOrEmpty(markText))
{
using (Brush brush = new SolidBrush(color))
{
DrawMarkPoint(g, markText, center, brush, markTextPosition);
}
}
}
/// <summary>
/// Draws the mark point.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="markText">The mark text.</param>
/// <param name="center">The center.</param>
/// <param name="brush">The brush.</param>
/// <param name="markTextPosition">The mark text position.</param>
private void DrawMarkPoint(Graphics g, string markText, PointF center, Brush brush, MarkTextPositionStyle markTextPosition)
{
if (!string.IsNullOrEmpty(markText))
{
g.FillEllipse(brush, new RectangleF(center.X - 3f, center.Y - 3f, 6f, 6f));
switch (markTextPosition)
{
case MarkTextPositionStyle.Left:
g.DrawString(markText, Font, brush, new RectangleF(center.X - 100f, center.Y - (float)Font.Height, 100 - MarkText.MarkTextOffect, Font.Height * 2), format_right);
break;
case MarkTextPositionStyle.Up:
g.DrawString(markText, Font, brush, new RectangleF(center.X - 100f, center.Y - (float)Font.Height - (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
case MarkTextPositionStyle.Right:
g.DrawString(markText, Font, brush, new RectangleF(center.X + (float)MarkText.MarkTextOffect, center.Y - (float)Font.Height, 100f, Font.Height * 2), format_left);
break;
case MarkTextPositionStyle.Down:
g.DrawString(markText, Font, brush, new RectangleF(center.X - 100f, center.Y + (float)MarkText.MarkTextOffect, 200f, Font.Height + 2), format_center);
break;
}
}
}
/// <summary>
/// Determines whether [is need paint dash] [the specified paint value].
/// </summary>
/// <param name="paintValue">The paint value.</param>
/// <returns><c>true</c> if [is need paint dash] [the specified paint value]; otherwise, <c>false</c>.</returns>
private bool IsNeedPaintDash(float paintValue)
{
for (int i = 0; i < auxiliary_lines.Count; i++)
{
if (Math.Abs(auxiliary_lines[i].PaintValue - paintValue) < (float)font_size9.Height)
{
return false;
}
}
return true;
}
/// <summary>
/// Calculates the data count by offect.
/// </summary>
/// <param name="offect">The offect.</param>
/// <returns>System.Int32.</returns>
private int CalculateDataCountByOffect(float offect)
{
if (value_IntervalAbscissaText > 0)
{
return value_IntervalAbscissaText;
}
if (offect > 40f)
{
return 1;
}
offect = 40f / offect;
return (int)Math.Ceiling(offect);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing">为 true 则释放托管资源和非托管资源;为 false 则仅释放非托管资源。</param>
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Initializes the component.
/// </summary>
private void InitializeComponent()
{
SuspendLayout();
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
BackColor = System.Drawing.Color.Transparent;
base.Name = "HslCurve";
base.Size = new System.Drawing.Size(417, 205);
ResumeLayout(false);
}
}
}
using System.Drawing;
namespace HZH_Controls.Controls
{
public class PieItem
{
public string Name
{
get;
set;
}
public int Value
{
get;
set;
}
/// <summary>
/// Gets or sets the color of the pie.如果为空则使用默认颜色
/// </summary>
/// <value>The color of the pie.</value>
public Color? PieColor
{
get;
set;
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-23
//
// ***********************************************************************
// <copyright file="UCPieChart.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.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Linq;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPieChart.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public class UCPieChart : UserControl
{
/// <summary>
/// The pie items
/// </summary>
private PieItem[] pieItems = new PieItem[0];
/// <summary>
/// The random
/// </summary>
private Random random = null;
/// <summary>
/// The format center
/// </summary>
private StringFormat formatCenter = null;
/// <summary>
/// The margin
/// </summary>
private int margin = 50;
/// <summary>
/// The m is render percent
/// </summary>
private bool m_IsRenderPercent = false;
/// <summary>
/// The percen format
/// </summary>
private string percenFormat = "{0:F2}%";
/// <summary>
/// The components
/// </summary>
private IContainer components = null;
/// <summary>
/// Gets or sets a value indicating whether this instance is render percent.
/// </summary>
/// <value><c>true</c> if this instance is render percent; otherwise, <c>false</c>.</value>
[Browsable(true)]
[Category("自定义")]
[DefaultValue(false)]
[Description("获取或设置是否显示百分比占用")]
public bool IsRenderPercent
{
get
{
return m_IsRenderPercent;
}
set
{
m_IsRenderPercent = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the text margin.
/// </summary>
/// <value>The text margin.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置文本距离,单位为像素,默认50")]
[DefaultValue(50)]
public int TextMargin
{
get
{
return margin;
}
set
{
margin = value;
Invalidate();
}
}
/// <summary>
/// Gets or sets the percent format.
/// </summary>
/// <value>The percent format.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置文百分比文字的格式化信息")]
[DefaultValue("{0:F2}%")]
public string PercentFormat
{
get
{
return percenFormat;
}
set
{
percenFormat = value;
Invalidate();
}
}
/// <summary>
/// The center of circle color
/// </summary>
private Color centerOfCircleColor = Color.White;
/// <summary>
/// Gets or sets the color of the center of circle.
/// </summary>
/// <value>The color of the center of circle.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置圆心颜色")]
public Color CenterOfCircleColor
{
get { return centerOfCircleColor; }
set
{
centerOfCircleColor = value;
Invalidate();
}
}
/// <summary>
/// The center of circle width
/// </summary>
private int centerOfCircleWidth = 0;
/// <summary>
/// Gets or sets the width of the center of circle.
/// </summary>
/// <value>The width of the center of circle.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置圆心宽度")]
public int CenterOfCircleWidth
{
get { return centerOfCircleWidth; }
set
{
if (value < 0)
return;
centerOfCircleWidth = value;
Invalidate();
}
}
/// <summary>
/// The title
/// </summary>
private string title;
/// <summary>
/// Gets or sets the ti tle.
/// </summary>
/// <value>The ti tle.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置标题")]
public string TiTle
{
get { return title; }
set
{
title = value;
ResetTitleHeight();
Invalidate();
}
}
/// <summary>
/// The title font
/// </summary>
private Font titleFont = new Font("微软雅黑", 12);
/// <summary>
/// Gets or sets the title font.
/// </summary>
/// <value>The title font.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置标题字体")]
public Font TitleFont
{
get { return titleFont; }
set
{
titleFont = value;
ResetTitleHeight();
Invalidate();
}
}
/// <summary>
/// The title froe color
/// </summary>
private Color titleFroeColor = Color.Black;
/// <summary>
/// Gets or sets the color of the title froe.
/// </summary>
/// <value>The color of the title froe.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置标题颜色")]
public Color TitleFroeColor
{
get { return titleFroeColor; }
set
{
titleFroeColor = value;
Invalidate();
}
}
/// <summary>
/// The title size
/// </summary>
private SizeF titleSize = SizeF.Empty;
/// <summary>
/// Resets the height of the title.
/// </summary>
private void ResetTitleHeight()
{
if (string.IsNullOrEmpty(title))
titleSize = SizeF.Empty;
else
{
using (var g = this.CreateGraphics())
{
titleSize = g.MeasureString(title, titleFont);
}
}
}
/// <summary>
/// Gets or sets the data source.
/// </summary>
/// <value>The data source.</value>
[Browsable(true)]
[Category("自定义")]
[Description("获取或设置标题颜色")]
[Localizable(true)]
public PieItem[] DataSource
{
get { return pieItems; }
set
{
pieItems = value;
Invalidate();
}
}
/// <summary>
/// Initializes a new instance of the <see cref="UCPieChart"/> class.
/// </summary>
public UCPieChart()
{
InitializeComponent();
random = new Random();
formatCenter = new StringFormat();
formatCenter.Alignment = StringAlignment.Center;
formatCenter.LineAlignment = StringAlignment.Center;
SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
pieItems = new PieItem[0];
if (GetService(typeof(IDesignerHost)) != null || LicenseManager.UsageMode == LicenseUsageMode.Designtime)
{
pieItems = new PieItem[5];
for (int i = 0; i < 5; i++)
{
pieItems[i] = new PieItem
{
Name = "Source" + (i + 1),
Value = random.Next(10, 100)
};
}
}
}
/// <summary>
/// Gets the center point.
/// </summary>
/// <param name="width">The width.</param>
/// <returns>Point.</returns>
private Point GetCenterPoint(out int width)
{
width = Math.Min(base.Width, base.Height - (titleSize != SizeF.Empty ? ((int)titleSize.Height) : 0)) / 2 - margin - 8;
return new Point(base.Width / 2 - 1, base.Height / 2 + (titleSize != SizeF.Empty ? ((int)titleSize.Height) : 0) - 1);
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SetGDIHigh();
int width;
Point centerPoint = GetCenterPoint(out width);
Rectangle rectangle = new Rectangle(centerPoint.X - width, centerPoint.Y - width, width * 2, width * 2);
if (width > 0 && pieItems.Length != 0)
{
if (!string.IsNullOrEmpty(title))
e.Graphics.DrawString(title, titleFont, new SolidBrush(titleFroeColor), new PointF((this.Width - titleSize.Width) / 2, 5));
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.RotateTransform(90f);
int num = pieItems.Sum((PieItem item) => item.Value);
float num2 = 0f;
float num3 = -90f;
for (int i = 0; i < pieItems.Length; i++)
{
Color cItem = pieItems[i].PieColor ?? ControlHelper.Colors[i];
Pen pen = new Pen(cItem, 1f);
SolidBrush solidBrush = new SolidBrush(cItem);
SolidBrush solidBrush2 = new SolidBrush(cItem);
Brush percentBrush = new SolidBrush(cItem);
float num4 = e.Graphics.MeasureString(pieItems[i].Name, Font).Width + 3f;
float num5 = (num != 0) ? Convert.ToSingle((double)pieItems[i].Value * 1.0 / (double)num * 360.0) : ((float)(360 / pieItems.Length));
e.Graphics.FillPie(solidBrush, rect, 0f, 0f - num5);
e.Graphics.DrawPie(new Pen(solidBrush), rect, 0f, 0f - num5);
e.Graphics.RotateTransform(0f - num5 / 2f);
if (num5 < 2f)
{
num2 += num5;
}
else
{
num2 += num5 / 2f;
int num6 = 15;
if (num2 < 45f || num2 > 315f)
{
num6 = 20;
}
if (num2 > 135f && num2 < 225f)
{
num6 = 20;
}
e.Graphics.DrawLine(pen, width * 2 / 3, 0, width + num6, 0);
e.Graphics.TranslateTransform(width + num6, 0f);
if (num2 - num3 < 5f)
{
}
num3 = num2;
if (num2 < 180f)
{
e.Graphics.RotateTransform(num2 - 90f);
e.Graphics.DrawLine(pen, 0f, 0f, num4, 0f);
e.Graphics.DrawString(pieItems[i].Name, Font, solidBrush2, new Point(0, -Font.Height));
if (IsRenderPercent)
{
e.Graphics.DrawString(string.Format(percenFormat, num5 * 100f / 360f), Font, percentBrush, new Point(0, 1));
}
e.Graphics.RotateTransform(90f - num2);
}
else
{
e.Graphics.RotateTransform(num2 - 270f);
e.Graphics.DrawLine(pen, 0f, 0f, num4, 0f);
e.Graphics.TranslateTransform(num4 - 3f, 0f);
e.Graphics.RotateTransform(180f);
e.Graphics.DrawString(pieItems[i].Name, Font, solidBrush2, new Point(0, -Font.Height));
if (IsRenderPercent)
{
e.Graphics.DrawString(string.Format(percenFormat, num5 * 100f / 360f), Font, percentBrush, new Point(0, 1));
}
e.Graphics.RotateTransform(-180f);
e.Graphics.TranslateTransform(0f - num4 + 3f, 0f);
e.Graphics.RotateTransform(270f - num2);
}
e.Graphics.TranslateTransform(-width - num6, 0f);
e.Graphics.RotateTransform(0f - num5 / 2f);
num2 += num5 / 2f;
}
solidBrush.Dispose();
pen.Dispose();
solidBrush2.Dispose();
percentBrush.Dispose();
}
e.Graphics.ResetTransform();
if (centerOfCircleWidth > 0)
{
Rectangle rectCenter = new Rectangle(rectangle.Left + rectangle.Width / 2 - centerOfCircleWidth / 2, rectangle.Top + rectangle.Height / 2 - centerOfCircleWidth / 2, centerOfCircleWidth, centerOfCircleWidth);
e.Graphics.FillEllipse(new SolidBrush(centerOfCircleColor), rectCenter);
}
}
else
{
e.Graphics.FillEllipse(Brushes.AliceBlue, rectangle);
e.Graphics.DrawEllipse(Pens.DodgerBlue, rectangle);
e.Graphics.DrawString("无数据", Font, Brushes.DimGray, rectangle, formatCenter);
}
base.OnPaint(e);
}
/// <summary>
/// Sets the data source.
/// </summary>
/// <param name="source">The source.</param>
public void SetDataSource(PieItem[] source)
{
if (source != null)
{
DataSource = source;
}
}
/// <summary>
/// Sets the data source.
/// </summary>
/// <param name="names">The names.</param>
/// <param name="values">The values.</param>
/// <exception cref="System.ArgumentNullException">
/// names
/// or
/// values
/// </exception>
/// <exception cref="System.Exception">两个数组的长度不一致!</exception>
public void SetDataSource(string[] names, int[] values)
{
if (names == null)
{
throw new ArgumentNullException("names");
}
if (values == null)
{
throw new ArgumentNullException("values");
}
if (names.Length != values.Length)
{
throw new Exception("两个数组的长度不一致!");
}
pieItems = new PieItem[names.Length];
for (int i = 0; i < names.Length; i++)
{
pieItems[i] = new PieItem
{
Name = names[i],
Value = values[i]
};
}
Invalidate();
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing">为 true 则释放托管资源和非托管资源;为 false 则仅释放非托管资源。</param>
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Initializes the component.
/// </summary>
private void InitializeComponent()
{
SuspendLayout();
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
BackColor = System.Drawing.Color.Transparent;
base.Name = "UCPieChart";
ResumeLayout(false);
}
}
}
......@@ -54,11 +54,6 @@
<Compile Include="Colors\StatusColors.cs" />
<Compile Include="Controls\Charts\AuxiliaryLable.cs" />
<Compile Include="Controls\Charts\AuxiliaryLine.cs" />
<Compile Include="Controls\Charts\BarChart\BarChartItem.cs" />
<Compile Include="Controls\Charts\CurveChart\UCCurve.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Charts\CurveChart\CurveItem.cs" />
<Compile Include="Controls\Charts\FunnelChart\FunelChartAlignment.cs" />
<Compile Include="Controls\Charts\FunnelChart\FunelChartDirection.cs" />
<Compile Include="Controls\Charts\FunnelChart\FunelChartItem.cs" />
......@@ -67,10 +62,6 @@
</Compile>
<Compile Include="Controls\Charts\MarkText.cs" />
<Compile Include="Controls\Charts\MarkTextPositionStyle.cs" />
<Compile Include="Controls\Charts\PieChart\UCPieChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Charts\PieChart\PieItem.cs" />
<Compile Include="Controls\Charts\RadarChart\RadarLine.cs" />
<Compile Include="Controls\Charts\RadarChart\RadarPosition.cs" />
<Compile Include="Controls\Charts\RadarChart\UCRadarChart.cs">
......@@ -150,9 +141,6 @@
<DependentUpon>FrmLoading.cs</DependentUpon>
</Compile>
<Compile Include="Helpers\GraphDirection.cs" />
<Compile Include="Controls\Charts\BarChart\UCBarChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Charts\ZoomType.cs" />
<Compile Include="Controls\FactoryControls\Arrow\UCArrow.cs">
<SubType>UserControl</SubType>
......
......@@ -76,9 +76,6 @@ namespace Test
TreeNode tnCharts = new TreeNode(" 图表");
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);
......@@ -297,15 +294,6 @@ namespace Test
case "组织结构图":
AddControl(new UC.UCTestMindMapping() { Dock = DockStyle.Fill });
break;
case "柱状图":
AddControl(new UC.UCTestBarcharts());
break;
case "饼状图":
AddControl(new UC.UCTestPieCharts());
break;
case "曲线图":
AddControl(new UC.UCTestCurveChart());
break;
case "滚动图表":
AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill });
break;
......
......@@ -92,12 +92,6 @@
<Compile Include="UC\UCTestArrow.Designer.cs">
<DependentUpon>UCTestArrow.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestBarcharts.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestBarcharts.Designer.cs">
<DependentUpon>UCTestBarcharts.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestBlower.cs">
<SubType>UserControl</SubType>
</Compile>
......@@ -122,12 +116,6 @@
<Compile Include="UC\UCTestConveyor.Designer.cs">
<DependentUpon>UCTestConveyor.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestCurveChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestCurveChart.Designer.cs">
<DependentUpon>UCTestCurveChart.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestFunnelChart.cs">
<SubType>UserControl</SubType>
</Compile>
......@@ -254,12 +242,6 @@
<Compile Include="UC\UCTestPanelTitle.Designer.cs">
<DependentUpon>UCTestPanelTitle.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestPieCharts.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestPieCharts.Designer.cs">
<DependentUpon>UCTestPieCharts.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestProcess.cs">
<SubType>UserControl</SubType>
</Compile>
......@@ -416,9 +398,6 @@
<EmbeddedResource Include="UC\UCTestArrow.resx">
<DependentUpon>UCTestArrow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestBarcharts.resx">
<DependentUpon>UCTestBarcharts.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestBlower.resx">
<DependentUpon>UCTestBlower.cs</DependentUpon>
</EmbeddedResource>
......@@ -434,9 +413,6 @@
<EmbeddedResource Include="UC\UCTestConveyor.resx">
<DependentUpon>UCTestConveyor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestCurveChart.resx">
<DependentUpon>UCTestCurveChart.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestForms.resx">
<DependentUpon>UCTestForms.cs</DependentUpon>
</EmbeddedResource>
......@@ -497,9 +473,6 @@
<EmbeddedResource Include="UC\UCTestPanelTitle.resx">
<DependentUpon>UCTestPanelTitle.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestPieCharts.resx">
<DependentUpon>UCTestPieCharts.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestProcess.resx">
<DependentUpon>UCTestProcess.cs</DependentUpon>
</EmbeddedResource>
......
namespace Test.UC
{
partial class UCTestBarcharts
{
/// <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()
{
HZH_Controls.Controls.BarChartItem barChartItem8 = new HZH_Controls.Controls.BarChartItem();
HZH_Controls.Controls.BarChartItem barChartItem9 = new HZH_Controls.Controls.BarChartItem();
HZH_Controls.Controls.BarChartItem barChartItem10 = new HZH_Controls.Controls.BarChartItem();
HZH_Controls.Controls.BarChartItem barChartItem11 = new HZH_Controls.Controls.BarChartItem();
HZH_Controls.Controls.BarChartItem barChartItem12 = new HZH_Controls.Controls.BarChartItem();
HZH_Controls.Controls.BarChartItem barChartItem13 = new HZH_Controls.Controls.BarChartItem();
HZH_Controls.Controls.BarChartItem barChartItem14 = new HZH_Controls.Controls.BarChartItem();
this.ucBarChart6 = new HZH_Controls.Controls.UCBarChart();
this.ucBarChart5 = new HZH_Controls.Controls.UCBarChart();
this.ucBarChart7 = new HZH_Controls.Controls.UCBarChart();
this.ucBarChart4 = new HZH_Controls.Controls.UCBarChart();
this.ucBarChart3 = new HZH_Controls.Controls.UCBarChart();
this.ucBarChart2 = new HZH_Controls.Controls.UCBarChart();
this.ucBarChart1 = new HZH_Controls.Controls.UCBarChart();
this.SuspendLayout();
//
// ucBarChart6
//
barChartItem8.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem8.BarPercentWidth = 0.8F;
barChartItem8.ItemName = null;
this.ucBarChart6.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem8};
this.ucBarChart6.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart6.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart6.ConerRadius = 10;
this.ucBarChart6.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart6.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart6.IsRadius = false;
this.ucBarChart6.IsShowRect = false;
this.ucBarChart6.Location = new System.Drawing.Point(851, 254);
this.ucBarChart6.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart6.Name = "ucBarChart6";
this.ucBarChart6.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart6.RectWidth = 1;
this.ucBarChart6.ShowBarValueFormat = "{0}";
this.ucBarChart6.ShowChartItemName = true;
this.ucBarChart6.Size = new System.Drawing.Size(399, 244);
this.ucBarChart6.TabIndex = 2;
this.ucBarChart6.Text = "ucBarChart1";
this.ucBarChart6.Title = "成绩";
this.ucBarChart6.UseGradient = true;
//
// ucBarChart5
//
barChartItem9.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem9.BarPercentWidth = 0.8F;
barChartItem9.ItemName = null;
this.ucBarChart5.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem9};
this.ucBarChart5.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart5.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart5.ConerRadius = 10;
this.ucBarChart5.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart5.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart5.IsRadius = false;
this.ucBarChart5.IsShowRect = false;
this.ucBarChart5.Location = new System.Drawing.Point(446, 254);
this.ucBarChart5.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart5.Name = "ucBarChart5";
this.ucBarChart5.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart5.RectWidth = 1;
this.ucBarChart5.ShowBarValueFormat = "{0}";
this.ucBarChart5.ShowChartItemName = false;
this.ucBarChart5.Size = new System.Drawing.Size(399, 244);
this.ucBarChart5.TabIndex = 2;
this.ucBarChart5.Text = "ucBarChart1";
this.ucBarChart5.Title = "英语分数(渐变色)";
this.ucBarChart5.UseGradient = true;
//
// ucBarChart7
//
barChartItem10.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem10.BarPercentWidth = 0.8F;
barChartItem10.ItemName = null;
this.ucBarChart7.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem10};
this.ucBarChart7.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart7.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart7.ConerRadius = 10;
this.ucBarChart7.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart7.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart7.IsRadius = false;
this.ucBarChart7.IsShowRect = false;
this.ucBarChart7.Location = new System.Drawing.Point(41, 510);
this.ucBarChart7.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart7.Name = "ucBarChart7";
this.ucBarChart7.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart7.RectWidth = 1;
this.ucBarChart7.ShowBarValueFormat = "{0}";
this.ucBarChart7.ShowChartItemName = true;
this.ucBarChart7.Size = new System.Drawing.Size(1209, 244);
this.ucBarChart7.TabIndex = 2;
this.ucBarChart7.Text = "ucBarChart1";
this.ucBarChart7.Title = "今日生产量";
//
// ucBarChart4
//
barChartItem11.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem11.BarPercentWidth = 0.8F;
barChartItem11.ItemName = null;
this.ucBarChart4.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem11};
this.ucBarChart4.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart4.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart4.ConerRadius = 10;
this.ucBarChart4.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart4.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart4.IsRadius = false;
this.ucBarChart4.IsShowRect = false;
this.ucBarChart4.Location = new System.Drawing.Point(41, 254);
this.ucBarChart4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart4.Name = "ucBarChart4";
this.ucBarChart4.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart4.RectWidth = 1;
this.ucBarChart4.ShowBarValueFormat = "{0}";
this.ucBarChart4.ShowChartItemName = false;
this.ucBarChart4.Size = new System.Drawing.Size(399, 244);
this.ucBarChart4.TabIndex = 2;
this.ucBarChart4.Text = "ucBarChart1";
this.ucBarChart4.Title = "英语分数(及格线)";
//
// ucBarChart3
//
barChartItem12.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem12.BarPercentWidth = 0.8F;
barChartItem12.ItemName = null;
this.ucBarChart3.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem12};
this.ucBarChart3.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart3.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart3.ConerRadius = 10;
this.ucBarChart3.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart3.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart3.IsRadius = false;
this.ucBarChart3.IsShowRect = false;
this.ucBarChart3.Location = new System.Drawing.Point(851, 12);
this.ucBarChart3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart3.Name = "ucBarChart3";
this.ucBarChart3.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart3.RectWidth = 1;
this.ucBarChart3.ShowBarValueFormat = "{0}";
this.ucBarChart3.ShowChartItemName = false;
this.ucBarChart3.Size = new System.Drawing.Size(399, 219);
this.ucBarChart3.TabIndex = 2;
this.ucBarChart3.Text = "ucBarChart1";
this.ucBarChart3.Title = "数学分数";
//
// ucBarChart2
//
barChartItem13.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem13.BarPercentWidth = 0.8F;
barChartItem13.ItemName = null;
this.ucBarChart2.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem13};
this.ucBarChart2.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart2.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart2.ConerRadius = 10;
this.ucBarChart2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart2.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart2.IsRadius = false;
this.ucBarChart2.IsShowRect = false;
this.ucBarChart2.Location = new System.Drawing.Point(446, 12);
this.ucBarChart2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart2.Name = "ucBarChart2";
this.ucBarChart2.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart2.RectWidth = 1;
this.ucBarChart2.ShowBarValueFormat = "{0}";
this.ucBarChart2.ShowChartItemName = false;
this.ucBarChart2.Size = new System.Drawing.Size(399, 219);
this.ucBarChart2.TabIndex = 2;
this.ucBarChart2.Text = "ucBarChart1";
//
// ucBarChart1
//
barChartItem14.BarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
barChartItem14.BarPercentWidth = 0.8F;
barChartItem14.ItemName = null;
this.ucBarChart1.BarChartItems = new HZH_Controls.Controls.BarChartItem[] {
barChartItem14};
this.ucBarChart1.ColorDashLines = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart1.ColorLinesAndText = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart1.ConerRadius = 10;
this.ucBarChart1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(220)))), ((int)(((byte)(219)))));
this.ucBarChart1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBarChart1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBarChart1.IsRadius = false;
this.ucBarChart1.IsShowRect = false;
this.ucBarChart1.Location = new System.Drawing.Point(41, 12);
this.ucBarChart1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucBarChart1.Name = "ucBarChart1";
this.ucBarChart1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucBarChart1.RectWidth = 1;
this.ucBarChart1.ShowBarValueFormat = "{0}";
this.ucBarChart1.ShowChartItemName = false;
this.ucBarChart1.Size = new System.Drawing.Size(399, 219);
this.ucBarChart1.TabIndex = 2;
this.ucBarChart1.Text = "ucBarChart1";
//
// UCTestBarcharts
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.ucBarChart6);
this.Controls.Add(this.ucBarChart5);
this.Controls.Add(this.ucBarChart7);
this.Controls.Add(this.ucBarChart4);
this.Controls.Add(this.ucBarChart3);
this.Controls.Add(this.ucBarChart2);
this.Controls.Add(this.ucBarChart1);
this.Name = "UCTestBarcharts";
this.Size = new System.Drawing.Size(1272, 779);
this.Load += new System.EventHandler(this.UCTestBarcharts_Load);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCBarChart ucBarChart1;
private HZH_Controls.Controls.UCBarChart ucBarChart2;
private HZH_Controls.Controls.UCBarChart ucBarChart3;
private HZH_Controls.Controls.UCBarChart ucBarChart4;
private HZH_Controls.Controls.UCBarChart ucBarChart5;
private HZH_Controls.Controls.UCBarChart ucBarChart6;
private HZH_Controls.Controls.UCBarChart ucBarChart7;
}
}
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
{
[ToolboxItem(false)]
public partial class UCTestBarcharts : UserControl
{
public UCTestBarcharts()
{
InitializeComponent();
}
private Random random = new Random();
private void UCTestBarcharts_Load(object sender, EventArgs e)
{
this.ucBarChart1.SetDataSource(new double[] { random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100) });
this.ucBarChart2.SetDataSource(new double[] { random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100) }, new string[] { "张三", "李四", "王五", "赵六", "田七" });
this.ucBarChart3.SetDataSource(new double[] { random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100) }, new string[] { "张三", "李四", "王五", "赵六", "田七" });
this.ucBarChart4.SetDataSource(new double[] { random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100) }, new string[] { "张三", "李四", "王五", "赵六", "田七" });
this.ucBarChart4.AddAuxiliaryLine(60, Color.Red, "及格线超长占位符");
this.ucBarChart5.SetDataSource(new double[] { random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100), random.Next(50, 100) }, new string[] { "张三", "李四", "王五", "赵六", "田七" });
this.ucBarChart5.AddAuxiliaryLine(50, Color.Black, "及格线");
var ds = new double[5][];
for (int i = 0; i < ds.Length; i++)
{
ds[i] = new double[] { random.Next(50, 100), random.Next(50, 100), random.Next(50, 100) };
}
this.ucBarChart6.BarChartItems = new HZH_Controls.Controls.BarChartItem[] { new HZH_Controls.Controls.BarChartItem("语文"), new HZH_Controls.Controls.BarChartItem("英语"), new HZH_Controls.Controls.BarChartItem("数学") };
this.ucBarChart6.SetDataSource(ds, new string[] { "张三", "李四", "王五", "赵六", "田七" });
this.ucBarChart6.AddAuxiliaryLine(60, Color.Black);
var ds2 = new List<double[]>();
for (int i = 0; i < 20; i++)
{
ds2.Add(new double[] { random.Next(800, 2000), random.Next(100, 200) });
}
var titles = new List<string>();
double dblSum = ds2.Sum(p => p[0]);
for (int i = 0; i < ds2.Count; i++)
{
titles.Add("员工" + (i + 1) + "\n" + (ds2[i][0] / dblSum).ToString("0.0%"));
}
this.ucBarChart7.BarChartItems = new HZH_Controls.Controls.BarChartItem[] { new HZH_Controls.Controls.BarChartItem("合格"), new HZH_Controls.Controls.BarChartItem("次品") };
this.ucBarChart7.SetDataSource(ds2.ToArray(), titles.ToArray());
this.ucBarChart7.AddAuxiliaryLine(1000, Color.Black, "标准线");
}
}
}
<?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>
</root>
\ No newline at end of file
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
{
[ToolboxItem(false)]
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
namespace Test.UC
{
partial class UCTestPieCharts
{
/// <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()
{
HZH_Controls.Controls.PieItem pieItem1 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem2 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem3 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem4 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem5 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem6 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem7 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem8 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem9 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem10 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem11 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem12 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem13 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem14 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem15 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem16 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem17 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem18 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem19 = new HZH_Controls.Controls.PieItem();
HZH_Controls.Controls.PieItem pieItem20 = new HZH_Controls.Controls.PieItem();
this.ucPieChart1 = new HZH_Controls.Controls.UCPieChart();
this.ucPieChart2 = new HZH_Controls.Controls.UCPieChart();
this.ucPieChart3 = new HZH_Controls.Controls.UCPieChart();
this.ucPieChart4 = new HZH_Controls.Controls.UCPieChart();
this.SuspendLayout();
//
// ucPieChart1
//
this.ucPieChart1.BackColor = System.Drawing.Color.Transparent;
this.ucPieChart1.CenterOfCircleColor = System.Drawing.Color.White;
this.ucPieChart1.CenterOfCircleWidth = 0;
pieItem1.Name = "Source1";
pieItem1.PieColor = null;
pieItem1.Value = 27;
pieItem2.Name = "Source2";
pieItem2.PieColor = null;
pieItem2.Value = 20;
pieItem3.Name = "Source3";
pieItem3.PieColor = null;
pieItem3.Value = 94;
pieItem4.Name = "Source4";
pieItem4.PieColor = null;
pieItem4.Value = 28;
pieItem5.Name = "Source5";
pieItem5.PieColor = null;
pieItem5.Value = 84;
this.ucPieChart1.DataSource = new HZH_Controls.Controls.PieItem[] {
pieItem1,
pieItem2,
pieItem3,
pieItem4,
pieItem5};
this.ucPieChart1.IsRenderPercent = true;
this.ucPieChart1.Location = new System.Drawing.Point(50, 71);
this.ucPieChart1.Name = "ucPieChart1";
this.ucPieChart1.Size = new System.Drawing.Size(342, 298);
this.ucPieChart1.TabIndex = 1;
this.ucPieChart1.TiTle = null;
this.ucPieChart1.TitleFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucPieChart1.TitleFroeColor = System.Drawing.Color.Black;
//
// ucPieChart2
//
this.ucPieChart2.BackColor = System.Drawing.Color.Transparent;
this.ucPieChart2.CenterOfCircleColor = System.Drawing.Color.White;
this.ucPieChart2.CenterOfCircleWidth = 0;
pieItem6.Name = "Source1";
pieItem6.PieColor = null;
pieItem6.Value = 27;
pieItem7.Name = "Source2";
pieItem7.PieColor = null;
pieItem7.Value = 20;
pieItem8.Name = "Source3";
pieItem8.PieColor = null;
pieItem8.Value = 94;
pieItem9.Name = "Source4";
pieItem9.PieColor = null;
pieItem9.Value = 28;
pieItem10.Name = "Source5";
pieItem10.PieColor = null;
pieItem10.Value = 84;
this.ucPieChart2.DataSource = new HZH_Controls.Controls.PieItem[] {
pieItem6,
pieItem7,
pieItem8,
pieItem9,
pieItem10};
this.ucPieChart2.Location = new System.Drawing.Point(415, 18);
this.ucPieChart2.Name = "ucPieChart2";
this.ucPieChart2.Size = new System.Drawing.Size(342, 351);
this.ucPieChart2.TabIndex = 0;
this.ucPieChart2.TiTle = "有标题的饼状图";
this.ucPieChart2.TitleFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucPieChart2.TitleFroeColor = System.Drawing.Color.Black;
//
// ucPieChart3
//
this.ucPieChart3.BackColor = System.Drawing.Color.Transparent;
this.ucPieChart3.CenterOfCircleColor = System.Drawing.Color.White;
this.ucPieChart3.CenterOfCircleWidth = 150;
pieItem11.Name = "Source1";
pieItem11.PieColor = null;
pieItem11.Value = 27;
pieItem12.Name = "Source2";
pieItem12.PieColor = null;
pieItem12.Value = 20;
pieItem13.Name = "Source3";
pieItem13.PieColor = null;
pieItem13.Value = 94;
pieItem14.Name = "Source4";
pieItem14.PieColor = null;
pieItem14.Value = 28;
pieItem15.Name = "Source5";
pieItem15.PieColor = null;
pieItem15.Value = 84;
this.ucPieChart3.DataSource = new HZH_Controls.Controls.PieItem[] {
pieItem11,
pieItem12,
pieItem13,
pieItem14,
pieItem15};
this.ucPieChart3.Location = new System.Drawing.Point(415, 393);
this.ucPieChart3.Name = "ucPieChart3";
this.ucPieChart3.Size = new System.Drawing.Size(342, 351);
this.ucPieChart3.TabIndex = 0;
this.ucPieChart3.TiTle = "有标题的饼状图";
this.ucPieChart3.TitleFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucPieChart3.TitleFroeColor = System.Drawing.Color.Black;
//
// ucPieChart4
//
this.ucPieChart4.BackColor = System.Drawing.Color.Transparent;
this.ucPieChart4.CenterOfCircleColor = System.Drawing.Color.White;
this.ucPieChart4.CenterOfCircleWidth = 150;
pieItem16.Name = "Source1";
pieItem16.PieColor = null;
pieItem16.Value = 27;
pieItem17.Name = "Source2";
pieItem17.PieColor = null;
pieItem17.Value = 20;
pieItem18.Name = "Source3";
pieItem18.PieColor = null;
pieItem18.Value = 94;
pieItem19.Name = "Source4";
pieItem19.PieColor = null;
pieItem19.Value = 28;
pieItem20.Name = "Source5";
pieItem20.PieColor = null;
pieItem20.Value = 84;
this.ucPieChart4.DataSource = new HZH_Controls.Controls.PieItem[] {
pieItem16,
pieItem17,
pieItem18,
pieItem19,
pieItem20};
this.ucPieChart4.IsRenderPercent = true;
this.ucPieChart4.Location = new System.Drawing.Point(50, 424);
this.ucPieChart4.Name = "ucPieChart4";
this.ucPieChart4.Size = new System.Drawing.Size(342, 320);
this.ucPieChart4.TabIndex = 1;
this.ucPieChart4.TiTle = null;
this.ucPieChart4.TitleFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucPieChart4.TitleFroeColor = System.Drawing.Color.Black;
//
// UCTestPieCharts
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.ucPieChart4);
this.Controls.Add(this.ucPieChart1);
this.Controls.Add(this.ucPieChart3);
this.Controls.Add(this.ucPieChart2);
this.Name = "UCTestPieCharts";
this.Size = new System.Drawing.Size(813, 766);
this.Load += new System.EventHandler(this.UCTestPieCharts_Load);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCPieChart ucPieChart2;
private HZH_Controls.Controls.UCPieChart ucPieChart1;
private HZH_Controls.Controls.UCPieChart ucPieChart3;
private HZH_Controls.Controls.UCPieChart ucPieChart4;
}
}
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;
using HZH_Controls.Controls;
namespace Test.UC
{
[ToolboxItem(false)]
public partial class UCTestPieCharts : UserControl
{
public UCTestPieCharts()
{
InitializeComponent();
}
private void UCTestPieCharts_Load(object sender, EventArgs e)
{
Random r = new Random();
var pieItems = new PieItem[5];
for (int i = 0; i < 5; i++)
{
pieItems[i] = new PieItem
{
Name = "Source" + (i + 1),
Value = r.Next(10, 100)
};
}
this.ucPieChart1.SetDataSource(pieItems);
this.ucPieChart2.SetDataSource(pieItems);
}
}
}
<?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>
</root>
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!