时间:2021-05-20
当执行长时间后台处理时,你是否希望软件给你一个反馈,让你了解程序执行进度。进度轴帮你忙,轻松掌握全局动态。你的进度你做主!进度轴分为横版和纵版总有一版适合你!
应用了事件机制假如有更好的方法欢迎交流,假如对您有用请顶一下。
载入时间轴控件
/// <summary> /// 载入时间轴控件 /// 2015-04-16 /// 吴海龙 /// </summary> public void LoadTimeAxis() { SortedDictionary<string, string> sdict = new SortedDictionary<string, string>(); sdict.Add("1", "读取配置"); sdict.Add("2", "选择模板"); sdict.Add("3", "确认数据"); sdict.Add("4", "生成代码"); uta = new uctlTimeAxis(sdict,1); uta.lc = new ToolFunction.uctlTimeAxis.TimeAxisClick(SayHello); CommonFunction.AddForm3(splitContainer4.Panel2, uta); }panel容器中添加控件
/// <summary> /// 项panel容器中添加控件 /// </summary> /// <param name="p">容器panel</param> /// <param name="uc">显示的usercontrol</param> public static void AddForm3(Panel p, UserControl uc) { p.Controls.Clear(); p.Controls.Add(uc); uc.Dock = DockStyle.Fill; }初始化纵版界面
/// <summary> /// 初始化垂直进度轴 /// 2015-04-15 /// 吴海龙 /// </summary> public void InitVerticalTimeAxis() { try { int TempCenterOfThePieY = CenterOfTheCircleY; using (Graphics g = this.CreateGraphics()) { g.SmoothingMode = SmoothingMode.HighQuality; //使绘图质量最高,即消除锯齿 g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality; g.DrawString("正在执行:", f1, Brushes.Black, new PointF(CenterOfTheCircleX, 5)); g.DrawLine(p3, new Point(LineStartX, TempCenterOfThePieY), new Point(LineStartX, (sdict.Keys.Count - 1) * CircleSpace + TempCenterOfThePieY)); foreach (var item in sdict.Keys) { g.FillEllipse(Brushes.Gray, CenterOfTheCircleX - CircleRadius, TempCenterOfThePieY - CircleRadius, CircleRadius * 2, CircleRadius * 2); g.FillEllipse(Brushes.White, CenterOfTheCircleX - PieRadius2, TempCenterOfThePieY - PieRadius2, PieRadius2 * 2, PieRadius2 * 2); g.DrawString(sdict[item], f1, Brushes.DarkGray, new PointF(ItemStartX, TempCenterOfThePieY - ItemFixY)); Label l = new Label(); l.Name = item; l.Location = new Point(ItemStartX,TempCenterOfThePieY - ItemFixY); l.Text = sdict[item]; l.Click +=new EventHandler(l_Click); //l.Click += new EventHandler(l_Click2); this.Controls.Add(l); TempCenterOfThePieY = TempCenterOfThePieY + CircleSpace; } } } catch (Exception exp) { CommonFunction.WriteLog(exp, "绘制失败"); }}纵版进度轴步进方法
/// <summary> /// 垂直步进方法 /// /// 2015-04-16 /// 吴海龙 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void SetVerticalStep(object sender, KeyValueEventArgs e) { int TempCenterOfThePieY = CenterOfTheCircleY; if ("" == KeyValueEventArgs.Key) { return; } using (Graphics g = this.CreateGraphics()) { g.SmoothingMode = SmoothingMode.HighQuality; //使绘图质量最高,即消除锯齿 g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality; foreach (var item in sdict.Keys) { g.DrawString(sdict[item], f1, Brushes.Green, ItemStartX, TempCenterOfThePieY - ItemFixY); g.DrawEllipse(Pens.Green, CenterOfTheCircleX - CircleRadius, TempCenterOfThePieY - CircleRadius, CircleRadius * 2, CircleRadius * 2); g.DrawLine(p2, new Point(LineStartX, LineStartY), new Point(LineStartX, TempCenterOfThePieY)); g.FillEllipse(Brushes.Green, CenterOfTheCircleX - PieRadius, TempCenterOfThePieY - PieRadius, PieRadius * 2, PieRadius * 2); if (item == KeyValueEventArgs.Key) { break; } TempCenterOfThePieY = TempCenterOfThePieY + CircleSpace; } }}画图属性字段
/// <summary> /// 蓝色宽2 /// </summary> static Pen p1 = new Pen(Color.Blue, 2); /// <summary> /// 绿色宽3 /// </summary> static Pen p2 = new Pen(Color.Green, 3); /// <summary> /// 灰色宽1 /// </summary> static Pen p3 = new Pen(Color.Gray, 1); /// <summary> /// 微软雅黑 /// </summary> static Font f1 = new Font("微软雅黑", 9, FontStyle.Regular); /// <summary> /// 圆心X坐标 /// </summary> public static int CenterOfTheCircleX = 31; /// <summary> /// 圆心Y坐标 /// </summary> public static int CenterOfTheCircleY = 46; /// <summary> /// 说明条目X坐标 /// </summary> public static int ItemStartX = 45; /// <summary> /// 条目X修正量 /// </summary> public static int ItemFixX = -20; /// <summary> /// 条目Y修正量 /// </summary> public static int ItemFixY = 10; public static Point CenterOfThePie = new Point(CenterOfTheCircleX, CenterOfTheCircleY); /// <summary> /// 命中Pie半径 /// </summary> public static int PieRadius = 6; /// <summary> /// 白点Pie半径 /// </summary> public static int PieRadius2 = 8; /// <summary> /// 圆半径 /// </summary> public static int CircleRadius = 9; /// <summary> /// 圆心距 /// </summary> public static int CircleSpace = 80; /// <summary> /// 轴X起点 /// </summary> public static int LineStartX = CenterOfTheCircleX; /// <summary> /// 轴Y起点 /// </summary> public static int LineStartY = CenterOfTheCircleY; /// <summary> /// 内部Key定义 /// </summary> public static string Key = ""; /// <summary> /// 绘图事件 /// </summary> public event EventHandler<KeyValueEventArgs> KeyValueChangeEventHandler; public delegate void LabelClickEventHandler(object sender, LabelClickEventArgs e); //public event LabelClickEventHandler<LabelClickEventArgs> ; public delegate void TimeAxisClick(); public TimeAxisClick lc = null; public delegate void TimeAxisClick2(string labelName); public TimeAxisClick2 lc2 = null; /// <summary> /// 流程字典 /// </summary> public static SortedDictionary<string, string> sdict = new SortedDictionary<string, string>(); /// <summary> /// 水平标示 /// </summary> private static readonly int HorizontalTimeAxis = 0; /// <summary> /// 垂直标志 /// </summary> private static readonly int VerticalTimeAxis = 1; /// <summary> /// 绘制标志,0为水平;1为垂直。 /// </summary> public static int TimeAxisModle = 0;构造方法
#region 构造方法 public uctlTimeAxis() { InitializeComponent(); } public uctlTimeAxis(SortedDictionary<string, string> s) { InitializeComponent(); if (sdict != null) { sdict = s; } } public uctlTimeAxis(SortedDictionary<string, string> s, int model) { InitializeComponent(); if (sdict != null) { sdict = s; TimeAxisModle = model; if (HorizontalTimeAxis==TimeAxisModle) { KeyValueChangeEventHandler += new EventHandler<KeyValueEventArgs>(SetHorizontalStep); } else if (VerticalTimeAxis==TimeAxisModle) { KeyValueChangeEventHandler += new EventHandler<KeyValueEventArgs>(SetVerticalStep); } } }#endregionKey值转变
/// <summary> /// Key值转变 /// </summary> public class KeyValueEventArgs : EventArgs { public static string Key = ""; public KeyValueEventArgs(string s) { Key = s; } }以上所述就是本文的全部内容了,希望大家能够喜欢。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了WinForm遍历窗体所有子控件的方法。分享给大家供大家参考,具体如下://////C#只遍历控件子控件,不遍历孙控件///当控件有子控件时,需要
本文所述为C#实现根据指定容器和控件名字获得控件的方法,在进行C#应用程序设计时有一定的借鉴价值。分享给大家供大家参考借鉴。具体实现方法如下:功能代码如下://
最近弄了一个在Qt中使用C#控件的功能,使用的方法是通过C#生产ActiveX控件,在Qt中使用该ActiveX控件。本文这里简单的介绍一下如何用C#生成Act
本文实例讲述了C#使用listView增删操作的方法。分享给大家供大家参考。具体分析如下:应用场景:C#中使用listView控件,实现动态添加,选中删除等操作
在应用C#进行Winform窗体程序编写的时候,经常需要编写工具栏。下面小编给大家分享一下C#如何应用ToolSctrip控件编写工具栏。1、首先打开visua