编译自定义控件的运行时版本
1. 在解决方案资源管理器中,右击 Class1.cs 并单击"重命名"。
2. 重命名文件 PDAChartControlControl.cs。
注意 如果没有打开解决方案资源管理器,请单击"视图"菜单上的"解决方案资源管理器"。
用下列代码替换 PDAChartControlControl.cs 中的代码:
//*****************************************************************************
// PDAChartControlControl
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
#if NETCFDESIGNTIME
[assembly: System.CF.Design.RuntimeAssemblyAttribute("PDAChartControl, Version=1.10.0.0, _
Culture=neutral, PublicKeyToken=null")]
namespace PDAChartControl
{
///
/// Summary description for UserControl1.
///
public class PDAChart : System.Windows.Forms.Control
{
public System.Windows.Forms.HScrollBar hScrollBar1;
///
/// Required designer variable.
///
// Delegate declaration.
// public delegate void EventHandler(string text,Color BackColor,int Height);
//
// //声明事件的委托:
// //public delegate void MyEventHandler(string text,Color BackColor,int Height);
// //定义一个公共事件成员
// public event EventHandler AddCube;
// protected virtual void OnAddCube(EventArgs e)
// {
//
// }
//
private PDAChartControl.MyGraph objGraph=new MyGraph();
private Point mBeginPoint=new Point(0,0) ;
private System.ComponentModel.Container components = null;
public PDAChart()
{
InitializeComponent();
}
public enum ChartTypeEnum { PillarChart, CakeChart ,BreakLinkChart};
#region Windows 属性定义
private bool mhScrollBarVisible=true;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute(0)]
[System.ComponentModel.Description("设置/读取滚动条是否可见")]
#endif
public bool hScrollBarVisible
{
get
{
return mhScrollBarVisible;
}
set
{
mhScrollBarVisible =value;
this.Invalidate();
}
}
private ChartTypeEnum mChartType=ChartTypeEnum.PillarChart;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute(0)]
[System.ComponentModel.Description("设置/读取图形类型")]
#endif
public ChartTypeEnum ChartType
{
get
{
return mChartType;
}
set
{
mChartType =value;
this.Invalidate();
}
}
private int mPicHeight=20;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute(0)]
[System.ComponentModel.Description("设置/读取饼图高")]
#endif
public int PicHeight
{
get
{
return mPicHeight;
}
set
{
mPicHeight =value;
this.Invalidate();
}
}
private Font mTitleFont =new Font("Arial", 9, FontStyle.Regular);
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.Description("设置/读取文本字体")]
#endif
public Font TitleFont
{
get
{
return mTitleFont;
}
set
{
mTitleFont=value;
this.Invalidate();
}
}
private Font mTextFont =new Font("Arial", 8, FontStyle.Regular);
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.Description("设置/读取文本字体")]
#endif
public Font TextFont
{
get
{
return mTextFont;
}
set
{
mTextFont=value;
this.Invalidate();
}
}
private static DataTable mDataTable=new DataTable() ;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.Description("设置/读取数据表")]
#endif
public DataTable dataTable
{
get
{
return mDataTable;
}
set
{
mDataTable=(DataTable)value;
this.Invalidate();
}
}
private string mShowColumnName;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.Description("设置/读取显示列")]
#endif
public string ShowColumnName
{
get
{
return mShowColumnName;
}
set
{
mShowColumnName=value;
this.Invalidate();
}
}
private string mDataColumnName;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.Description("设置/读取数据列")]
#endif
public string DataColumnName
{
get
{
return mDataColumnName;
}
set
{
mDataColumnName=value;
this.Invalidate();
}
}
private string mTitle="统计图";
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute("图表")]
[System.ComponentModel.Description("设置/读取标题")]
#endif
public string Title
{
get
{
return mTitle;
}
set
{
mTitle=value;
this.Invalidate();
}
}
private ArrayList mCubeData;
#if !NETCFDESIGNTIME
//The actual Data used to draw the line on the graph
public ICollection CubeData
{
get
{
return mCubeData;
}
set
{
mCubeData = new ArrayList(value);
Rectangle rcClient = this.ClientRectangle;
Rectangle rcGraphClient = new Rectangle(rcClient.X + 21, rcClient.Y + 5, rcClient.Width - 21, rcClient.Height - 21);
this.Invalidate(rcGraphClient);
}
}
#endif
private Color mBackColor=System.Drawing.SystemColors.ControlLight;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute(0)]
[System.ComponentModel.Description("设置/读取背景颜色")]
#endif
public override Color BackColor
{
get
{
return mBackColor;
}
set
{
mBackColor =value;
this.Invalidate();
}
}
private Color mAxesXColor=System.Drawing.SystemColors.HighlightText;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute(0)]
[System.ComponentModel.Description("设置/读取X轴颜色")]
#endif
public Color AxesXColor
{
get
{
return mAxesXColor;
}
set
{
mAxesXColor =value;
this.Invalidate();
}
}
private Color mAxesYColor=System.Drawing.SystemColors.Info;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.DefaultValueAttribute(0)]
[System.ComponentModel.Description("设置/读取Y轴颜色")]
#endif
public Color AxesYColor
{
get
{
return mAxesYColor;
}
set
{
mAxesYColor =value;
this.Invalidate();
}
}
private int mLenght = 4;
#if NETCFDESIGNTIME
// These design time attributes affect appearance of this property in the property grid.
[System.ComponentModel.DefaultValueAttribute(5)]
[System.ComponentModel.Description("立体长")]
#endif
//The lower Y bound of the PDAChart
public int Lenght
{
get
{
return mLenght;
}
set
{
mLenght = value;
this.Invalidate();
}
}
private int mMaxYValue ;//图表Y轴最大值
private int mMaxXValue ;//图表X轴最大值
private Color mGridLineColor=System.Drawing.Color.Cyan;
#if NETCFDESIGNTIME
[System.ComponentModel.Category("PDAChart")]
[System.ComponentModel.Description("网格线的颜色.")]
#endif
//The color of the line of the PDAChart.
public Color GridLineColor
{
get
{
return mGridLineColor;
}
set
{
mGridLineColor =value;
this.Invalidate();
}
}
private bool mShowXText = true;
#if NETCFDESIGNTIME
// These design time attributes affect appearance of this property in the property grid.
[System.ComponentModel.Category("Chart")]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.Description("是否显示X轴的文本")]
#endif
// If true, shows the Y-Values on the left of the PDAChart
public bool IsShowXText
{
get
{
return mShowXText;
}
set
{
mShowXText = value;
this.Invalidate();
}
}
private bool mShowYText = true;
#if NETCFDESIGNTIME
// These design time attributes affect appearance of this property in the property grid.
[System.ComponentModel.Category("Chart")]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.Description("是否显示Y轴的数字")]
#endif
// If true, shows the Y-Values on the left of the PDAChart
public bool IsShowYText
{
get
{
return mShowYText;
}
set
{
mShowYText = value;
this.Invalidate();
}
}
private bool mShowXScale = true;
#if NETCFDESIGNTIME
// These design time attributes affect appearance of this property in the property grid.
[System.ComponentModel.Category("Chart")]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.Description("是否显示X轴的刻度.")]
#endif
// If true, shows the X-Values on the bottom of the PDAChart
public bool IsShowXScale
{
get
{
return mShowXScale;
}
set
{
mShowXScale = value;
this.Invalidate();
}
}
private bool mShowYScale = true;
#if NETCFDESIGNTIME
// These design time attributes affect appearance of this property in the property grid.
[System.ComponentModel.Category("Chart")]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.Description("是否显示Y轴的刻度")]
#endif
// If true, shows the Y-Values on the left of the PDAChart
public bool IsShowYScale
{
get
{
return mShowYScale;
}
set
{
mShowYScale = value;
this.Invalidate();
}
}
private bool mShowGrid = true;
#if NETCFDESIGNTIME
// These design time attributes affect appearance of this property in the property grid.
[System.ComponentModel.Category("Chart")]
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.Description("是否显示网格线")]
#endif
// If true, shows horiztonal grid lines on the PDAChart.
public bool IsShowGrid
{
get
{
return mShowGrid;
}
set
{
mShowGrid = value;
this.Invalidate();
}
}
#endregion
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
