C#進度軸控件分享。本站提示廣大學習愛好者:(C#進度軸控件分享)文章只能為提供參考,不一定能成為您想要的結果。以下是C#進度軸控件分享正文
當履行長時光後台處置時,你能否願望軟件給你一個反應,讓你懂得法式履行進度。進度軸幫你忙,輕松控制全局靜態。你的進度你做主!進度軸分為橫版和縱版總有一版合適你!
運用了事宜機制假設有更好的辦法迎接交換,假設對您有效請頂一下。
載入時光軸控件
/// <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); } } } #endregion
Key值改變
/// <summary> /// Key值改變 /// </summary> public class KeyValueEventArgs : EventArgs { public static string Key = ""; public KeyValueEventArgs(string s) { Key = s; } }
以上所述就是本文的全體內容了,願望年夜家可以或許愛好。