玩轉(zhuǎn)控件:Fucking ERP之流程圖
前言
首先,跟守護(hù)在作者公眾號(hào)和私信作者催更的朋友們道個(gè)歉。疫情的原因,公司從年初到現(xiàn)在一直處于996+的高壓模式,導(dǎo)致公眾號(hào)更新頻率較低。而且作者每更新一篇原創(chuàng)公眾號(hào),既要對(duì)自己沉淀知識(shí)負(fù)責(zé),也要對(duì)愿意和作者一起探討一起學(xué)習(xí)一起進(jìn)步的小伙伴兒們負(fù)責(zé),防止誤人子弟。所以作者的每一篇原創(chuàng),都是作者在有限時(shí)間內(nèi)仔細(xì)推敲后的產(chǎn)物,希望大家可以理解。
Talk is Cheap!
前面分享的幾個(gè)章節(jié),差不多把實(shí)際用到的控件和容器的封裝、擴(kuò)展、重繪都舉例到了(后續(xù)如果還有其他特例,作者也會(huì)更新進(jìn)來)。今天要分享的依然是“Fucking ERP”系列中比較重要的環(huán)節(jié)——流程圖。
本章的流程圖并非工作流,winform在市面上有很多經(jīng)典的工作流組件比如微軟的WWF,還有很多開源自主研發(fā)的工作流組件等等,后續(xù)作者實(shí)際用到的話也會(huì)分享出來和大家一起探討。此處分享的流程圖,主要是"標(biāo)識(shí)"的作用,主要用來表示業(yè)務(wù)數(shù)據(jù)的流轉(zhuǎn),具體數(shù)據(jù)如何流轉(zhuǎn),都需要各位后臺(tái)自行處理(說白了,就是從A表查出數(shù)據(jù),插入到B表,然后更新A表標(biāo)識(shí)罷了。)
Show me the Code!
首先,界面加載的時(shí)候,初始化控件可用性,以及所有模塊列表
private void frmWorkFlow_Load(object sender, EventArgs e) { //創(chuàng)建大模塊 CreateModule(); this.TabPage1.PageVisible = false; this.TabPage2.PageVisible = false; this.TabPage3.PageVisible = false; this.kzxsBtnAddButton.Enabled = false; this.kzxsBtnAddLabel.Enabled = false; this.kzxsBtnAddLine.Enabled = false; this.Btn_SaveButton.Enabled = false; this.Btn_SaveLabel.Enabled = false; this.Btn_SaveLine.Enabled = false;
為了滿足演示效果,本位都用DataTable來模擬數(shù)據(jù)庫(kù)操作。初始化模塊菜單方法如下:
//創(chuàng)建主目錄 public void CreateModule() { //此處拿DataTable來存儲(chǔ)數(shù)據(jù)庫(kù)的所有菜單節(jié)點(diǎn),此處用銷售模塊來舉例 DataTable dtSalesOrder = new DataTable(); dtSalesOrder.Columns.Add("sID", typeof(Guid)); dtSalesOrder.Columns.Add("sModel", typeof(string)); dtSalesOrder.Columns.Add("iOrder", typeof(int)); dtSalesOrder.Rows.Add(new object[] { Guid.NewGuid(), "銷售模塊", 1 }); DataRow[] dr = dtSalesOrder.Select("", "iOrder"); //存在子菜單生產(chǎn)樹結(jié)構(gòu) if (dr.Length > 0) { foreach (DataRow row in dr) { DevExpress.XtraEditors.SimpleButton sb = new DevExpress.XtraEditors.SimpleButton(); sb.Name = row["sID"].ToString(); sb.Text = row["sModel"].ToString(); sb.Tag = row["sModel"].ToString(); sb.TabIndex = int.Parse(row["iOrder"].ToString()); sb.Dock = DockStyle.Top; sb.Height = 25; sb.Click += onBtnClick; panelControl1.Controls.Add(sb); } } }
模塊按鈕綁定了點(diǎn)擊事件,用于觸發(fā)當(dāng)前選擇的菜單的流程圖(代碼邏輯已經(jīng)添加,時(shí)間有限,本文不做處理,如有疑問,可公眾號(hào)私信作者一起探討)
private void onBtnClick(object sender, EventArgs e) { sModel = ((DevExpress.XtraEditors.SimpleButton)sender).Name.ToString().Trim(); sModelName = ((DevExpress.XtraEditors.SimpleButton)sender).Text.ToString().Trim(); //根據(jù)選擇的菜單模塊,加載當(dāng)前菜單的流程圖 CreateFlowMap(((DevExpress.XtraEditors.SimpleButton)sender).Name.ToString().Trim(), ((DevExpress.XtraEditors.SimpleButton)sender).Text.ToString().Trim()); }
創(chuàng)建流程圖部分方法如下(有需要源碼可關(guān)注作者公眾號(hào),私信作者免費(fèi)獲取):
//創(chuàng)建流程圖 public void CreateFlowMap(string sModelID, string sModelName) { //查找是否存在流程圖 string sFilter = "sModelCode = '" + sModelID + "'"; TabControl2.Visible = true; Boolean bExists = false; //查找模塊流程圖是否存在 foreach (DevExpress.XtraTab.XtraTabPage tabPage in TabControl2.TabPages) { if (tabPage.Name == sModelID) { tabPage.PageVisible = true; TabControl2.SelectedTabPage = tabPage; bExists = true; } else { tabPage.PageVisible = false; } } //不存在需要增加頁(yè)面 if (!bExists) { .....
You say a JB without pictures !無圖言X,先給大家看看設(shè)計(jì)圖

圖片展示解析:
1.左側(cè)欄初始化動(dòng)作,加載所有系統(tǒng)模塊
2.右側(cè)上部分為操作欄,設(shè)計(jì)按鈕處理當(dāng)前選中的菜單模塊,用于加載/新增/刪除當(dāng)前模塊的流程圖
3.右側(cè)左邊部分為繪制工具欄,此處只拿繪制直線(或帶箭頭的直線),Label(流程注釋),按鈕來舉例子。
4.右側(cè)下部分為繪制工具欄的屬性配置,點(diǎn)擊保存,呈現(xiàn)繪制結(jié)果如圖右側(cè)中間部分
5.流程圖展示區(qū),用于加載或繪制流程圖
(以上因篇幅和時(shí)間限制未做詳細(xì)測(cè)試,主要實(shí)現(xiàn)功能為主舉個(gè)例子,作者繪制期間也有遇到不完善的地方,后續(xù)有時(shí)間在優(yōu)化)
代碼沒有太大難度(需要源碼研究可關(guān)注作者公眾號(hào),私信作者免費(fèi)獲取),主要跟大家分享下繪制流程模塊吧。
(帶箭頭的)直線的繪制
Talk is Cheap,直接上代碼:
KzxLine line = new KzxLine(); bAddLine = true; line.Name = "Line"; line.Tag = ""; line.lineWidth = int.Parse(this.cmb_LineWidth.Text.ToString()); string sColor = this.cmb_ColorLine.Text.ToString().Trim(); switch (sColor) { case "Black": line.LineColor = KzxLine.ColorType.Black; break; case "Blue": line.LineColor = KzxLine.ColorType.Blue; break; case "Green": line.LineColor = KzxLine.ColorType.Green; break; case "Lime": line.LineColor = KzxLine.ColorType.Lime; break; case "Red": line.LineColor = KzxLine.ColorType.Red; break; case "Yellow": line.LineColor = KzxLine.ColorType.Yellow; break; default: line.LineColor = KzxLine.ColorType.Black; break; } line.IsSolid = !this.chk_Solid.Checked; switch (this.cmb_ArrowType.Text.ToString().Trim()) { case "Start": line.ArrowPosition = KzxLine.ArrowType.Start; break; case "End": line.ArrowPosition = KzxLine.ArrowType.End; break; case "All": line.ArrowPosition = KzxLine.ArrowType.All; break; case "None": line.ArrowPosition = KzxLine.ArrowType.None; break; } if (this.chk_Horizon.Checked) { line.LineStyle = KzxLine.LineType.Horizontal; line.Left = int.Parse(this.edt_LeftLine.Text.ToString()); line.Top = int.Parse(this.edt_TopLine.Text.ToString()); line.Width = int.Parse(this.edt_WidthLine.Text.ToString()); line.Height = int.Parse(this.cmb_LineWidth.Text.ToString()) * 2 + 10; } else { line.LineStyle = KzxLine.LineType.Vertical; line.Left = int.Parse(this.edt_LeftLine.Text.ToString()); line.Top = int.Parse(this.edt_TopLine.Text.ToString()); line.Width = int.Parse(this.cmb_LineWidth.Text.ToString()) * 2 + 10; line.Height = int.Parse(this.edt_HeightLine.Text.ToString()); } line.Visible = true; line.Click += onClick; MoveClass.BarcodeControl(line); if (bFirstControl) { MoveClass.BarcodeCreate(); bFirstControl = false; } this.TabControl2.Enabled = true; this.TabControl1.SelectedTabPage = TabPage3; this.TabPage3.PageVisible = true; this.kzxsBtnAddButton.Enabled = true; this.kzxsBtnAddLabel.Enabled = true; this.kzxsBtnAddLine.Enabled = true;
其中KzxLine是作者封裝的用戶控件,(如有需要,請(qǐng)關(guān)注公眾號(hào)私信作者,源碼免費(fèi)贈(zèng)送)部分代碼如下:
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //e.Graphics.DrawLine(new Pen(lineColor, lineHeight), 1, 1, this.Width, lineHeight); AdjustableArrowCap lineCap = new AdjustableArrowCap(5, 5, true); Pen p = new Pen(lineColor, 1); string sColor = ""; if ((int)color == 0) { sColor = "Black"; } if ((int)color == 1) { sColor = "Red"; } if ((int)color == 2) { sColor = "Yellow"; } if ((int)color == 3) { sColor = "Blue"; } if ((int)color == 4) { sColor = "Green"; } if ((int)color == 5) { sColor = "Lime"; } p.Color = Color.FromName(sColor); p.Width = LWidth; if ((int)ArrowP == 1) { p.CustomStartCap = lineCap; } else if ((int)ArrowP == 2) { p.CustomEndCap = lineCap; } else if ((int)ArrowP == 3) { p.CustomStartCap = lineCap; p.CustomEndCap = lineCap; } if (!Solid) { float[] dashValues = { 5, 2, 5, 2 }; p.DashPattern = dashValues; } int iLeft = 1; int iTop = 1; int iWidth = 1; int iHeight = 1; if ((int)sTyle == 0) { iLeft = 1; iTop = LWidth * 2 + 5; iWidth = this.Width; iHeight = LWidth * 2 + 5; } else { iLeft = LWidth * 2 + 5; iTop = 1; iWidth = LWidth * 2 + 5; iHeight = this.Height; } e.Graphics.DrawLine(p, iLeft, iTop, iWidth, iHeight); p.Dispose(); }
點(diǎn)擊如圖"箭頭/直線"按鈕后,下面會(huì)顯示控件的屬性配置區(qū)域,設(shè)置好后點(diǎn)擊保存,就會(huì)把繪制好的控件添加到流程圖展示區(qū)。保存事件如下:
private void Btn_SaveLine_Click(object sender, EventArgs e) { if (bAddLine) { KzxLine line = new KzxLine(); line.Name = "Line"; line.Tag = ""; line.lineWidth = int.Parse(this.cmb_LineWidth.Text.ToString()); string sColor = this.cmb_ColorLine.Text.ToString().Trim(); switch (sColor) { case "Black": line.LineColor = KzxLine.ColorType.Black; break; case "Blue": line.LineColor = KzxLine.ColorType.Blue; break; case "Green": line.LineColor = KzxLine.ColorType.Green; break; case "Lime": line.LineColor = KzxLine.ColorType.Lime; break; case "Red": line.LineColor = KzxLine.ColorType.Red; break; case "Yellow": line.LineColor = KzxLine.ColorType.Yellow; break; default: line.LineColor = KzxLine.ColorType.Black; break; } line.IsSolid = !this.chk_Solid.Checked; switch (this.cmb_ArrowType.Text.ToString().Trim()) { case "Start": line.ArrowPosition = KzxLine.ArrowType.Start; break; case "End": line.ArrowPosition = KzxLine.ArrowType.End; break; case "All": line.ArrowPosition = KzxLine.ArrowType.All; break; case "None": line.ArrowPosition = KzxLine.ArrowType.None; break; } if (this.chk_Horizon.Checked) { line.LineStyle = KzxLine.LineType.Horizontal; line.Left = int.Parse(this.edt_LeftLine.Text.ToString()); line.Top = int.Parse(this.edt_TopLine.Text.ToString()); line.Width = int.Parse(this.edt_WidthLine.Text.ToString()); line.Height = int.Parse(this.cmb_LineWidth.Text.ToString()) * 2 + 10; } else { line.LineStyle = KzxLine.LineType.Vertical; line.Left = int.Parse(this.edt_LeftLine.Text.ToString()); line.Top = int.Parse(this.edt_TopLine.Text.ToString()); line.Width = int.Parse(this.cmb_LineWidth.Text.ToString()) * 2 + 10; line.Height = int.Parse(this.edt_HeightLine.Text.ToString()); } line.Visible = true; line.Click += onClick; MoveClass.BarcodeControl(line); if (bFirstControl) { MoveClass.BarcodeCreate(); bFirstControl = false; } this.TabControl2.Enabled = true; bAddLine = false; TabControl2.SelectedTabPage.Controls.Add(line); this.kzxsBtnAddButton.Enabled = true; this.kzxsBtnAddLabel.Enabled = true; this.kzxsBtnAddLine.Enabled = true; this.sBtnDelete.Enabled = true; } else if ((selectControl is KzxLine) && (KzxLine)selectControl != null) { ((KzxLine)selectControl).lineWidth = int.Parse(this.cmb_LineWidth.Text.ToString()); string sColor = this.cmb_ColorLine.Text.ToString().Trim(); switch (sColor) { case "Black": ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Black; break; case "Blue": ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Blue; break; case "Green": ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Green; break; case "Lime": ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Lime; break; case "Red": ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Red; break; case "Yellow": ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Yellow; break; default: ((KzxLine)selectControl).LineColor = KzxLine.ColorType.Black; break; } ((KzxLine)selectControl).IsSolid = !this.chk_Solid.Checked; switch (this.cmb_ArrowType.Text.ToString().Trim()) { case "Start": ((KzxLine)selectControl).ArrowPosition = KzxLine.ArrowType.Start; break; case "End": ((KzxLine)selectControl).ArrowPosition = KzxLine.ArrowType.End; break; case "All": ((KzxLine)selectControl).ArrowPosition = KzxLine.ArrowType.All; break; case "None": ((KzxLine)selectControl).ArrowPosition = KzxLine.ArrowType.None; break; } if (this.chk_Horizon.Checked) { ((KzxLine)selectControl).LineStyle = KzxLine.LineType.Horizontal; ((KzxLine)selectControl).Left = int.Parse(this.edt_LeftLine.Text.ToString()); ((KzxLine)selectControl).Top = int.Parse(this.edt_TopLine.Text.ToString()); ((KzxLine)selectControl).Width = int.Parse(this.edt_WidthLine.Text.ToString()); ((KzxLine)selectControl).Height = int.Parse(this.cmb_LineWidth.Text.ToString()) * 2 + 10; } else { ((KzxLine)selectControl).LineStyle = KzxLine.LineType.Vertical; ((KzxLine)selectControl).Left = int.Parse(this.edt_LeftLine.Text.ToString()); ((KzxLine)selectControl).Top = int.Parse(this.edt_TopLine.Text.ToString()); ((KzxLine)selectControl).Width = int.Parse(this.cmb_LineWidth.Text.ToString()) * 2 + 10; ((KzxLine)selectControl).Height = int.Parse(this.edt_HeightLine.Text.ToString()); } } }
因所有繪制控件都綁定了拖拽事件,所以可以在流程圖展示區(qū)隨意拖拽部署顯示控件(效果見下圖)。
Label(注釋)控件封裝
/// <summary> /// 標(biāo)簽驗(yàn)證 /// </summary> public partial class KzxLabel : KzxBaseControl
Label無需重繪只需封裝,初始化綁定多語(yǔ)言即可。
public void LayoutControl() { BindingEvent(this, PluginInfoTable); if (this.DesignMode == true) { this.DesigeCaption = GetLanguage(this.MessageCode, this.DesigeCaption); } } /// <summary> /// 綁定事件 /// </summary> /// <param name="eventInfoTable">事件信息表</param> public override void BindingEvent(DataTable eventInfoTable) { BindingEvent(this, eventInfoTable); } private void KzxLabel_Load(object sender, EventArgs e) { LayoutControl(); //UpdateDelegate d = LayoutControl; //this.BeginInvoke(d); }
按鈕控件封裝
按鈕的封裝同上Label一樣,具體請(qǐng)移步《玩轉(zhuǎn)控件:擴(kuò)展Dev中SimpleButton》.或者直接用Dev原生的SimpleButton亦可,此處不做過多廢話。只需在屬性配置區(qū)域的保存事件中,添加到流程圖展示區(qū)即可,配置區(qū)的按鈕保存代碼如下:
BillInfo info = new BillInfo(); //info.sID = Edt_FrmBtn.EditValue.ToString(); info.sFrmName = Edt_FrmBtn.Text.ToString(); info.sFrmCaption = Edt_CaptionBtn.Text.Trim(); info.sMsgID = Edt_MsgBtn.Text.ToString().Trim(); if (bAddBtn) { DevExpress.XtraEditors.SimpleButton sb = new DevExpress.XtraEditors.SimpleButton(); sb.Left = int.Parse(Edt_LeftBtn.Text.Trim()); sb.Top = int.Parse(Edt_TopBtn.Text.Trim()); sb.Width = int.Parse(Edt_WidthBtn.Text.Trim()); sb.Height = int.Parse(Edt_HightBtn.Text.Trim()); sb.Name = Edt_FrmBtn.Text.Trim(); sb.Text = Edt_CaptionBtn.Text.Trim(); sb.Tag = info; sb.Image = picture1.Image; sb.ImageLocation = DevExpress.XtraEditors.ImageLocation.TopCenter; sb.Cursor = Cursors.Hand; sb.Visible = true; TabControl2.SelectedTabPage.Controls.Add(sb); sb.Click += onClick; MoveClass.BarcodeControl(sb); if (bFirstControl) { MoveClass.BarcodeCreate(); bFirstControl = false; } this.TabControl2.Enabled = true; bAddBtn = false; this.kzxsBtnAddButton.Enabled = true; this.kzxsBtnAddLabel.Enabled = true; this.kzxsBtnAddLine.Enabled = true; } else if ((selectControl is DevExpress.XtraEditors.SimpleButton) && (DevExpress.XtraEditors.SimpleButton)selectControl != null) { ((DevExpress.XtraEditors.SimpleButton)selectControl).Left = int.Parse(Edt_LeftBtn.Text.Trim()); ((DevExpress.XtraEditors.SimpleButton)selectControl).Top = int.Parse(Edt_TopBtn.Text.Trim()); ((DevExpress.XtraEditors.SimpleButton)selectControl).Width = int.Parse(Edt_WidthBtn.Text.Trim()); ((DevExpress.XtraEditors.SimpleButton)selectControl).Height = int.Parse(Edt_HightBtn.Text.Trim()); ((DevExpress.XtraEditors.SimpleButton)selectControl).Name = Edt_FrmBtn.Text.Trim(); ((DevExpress.XtraEditors.SimpleButton)selectControl).Text = Edt_CaptionBtn.Text.Trim(); ((DevExpress.XtraEditors.SimpleButton)selectControl).Tag = info; ((DevExpress.XtraEditors.SimpleButton)selectControl).Image = picture1.Image; ((DevExpress.XtraEditors.SimpleButton)selectControl).ImageLocation = DevExpress.XtraEditors.ImageLocation.TopCenter; ((DevExpress.XtraEditors.SimpleButton)selectControl).Cursor = Cursors.Hand; }
以上便是"箭頭/直線","Label注釋","按鈕"等功能的準(zhǔn)備工作,具體效果如圖:

再次強(qiáng)調(diào),因時(shí)間和篇幅問題,作者沒有對(duì)代碼做嚴(yán)格的校驗(yàn),主要以實(shí)現(xiàn)功能為主。所以當(dāng)您拿到源碼時(shí)需要根據(jù)實(shí)際情況自行完善,或者后續(xù)作者有時(shí)間也會(huì)繼續(xù)完善(工作996+的我太難了!)
各個(gè)模塊功能實(shí)現(xiàn)后,就是保存當(dāng)前繪制的流程圖環(huán)節(jié)了,為了演示效果,作者沒有處理數(shù)據(jù)庫(kù)相關(guān)的工作,主要以DataTable來存儲(chǔ)相關(guān)繪制數(shù)據(jù)的。至于圖片,作者是用流的方式來存儲(chǔ)的,展示時(shí)解析即可。
#region 圖片處理 /// <summary> /// 點(diǎn)擊上傳圖片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picture1_Click(object sender, EventArgs e) { if (this.openDialog1.ShowDialog() == DialogResult.OK) { picture1.Image = Image.FromFile(this.openDialog1.FileName); } } /// <summary> /// 用流的方式來存儲(chǔ)圖片 /// </summary> /// <param name="img"></param> /// <returns></returns> private byte[] convertByte(Image img) { MemoryStream ms = new MemoryStream(); img.Save(ms, img.RawFormat); byte[] bytes = ms.ToArray(); ms.Close(); return bytes; } private Image convertImg(byte[] datas) { MemoryStream ms = new MemoryStream(datas); Image img = Image.FromStream(ms, true); ms.Close(); return img; } #endregion
DataTable數(shù)據(jù)存儲(chǔ)如下圖:

大家可以根據(jù)自己實(shí)際情況,存儲(chǔ)到數(shù)據(jù)庫(kù)或者配置文件中,具體保存代碼如下:
int iOrder = 0; foreach (Control c in TabControl2.SelectedTabPage.Controls) { //string sID = ""; string sFrmName = ""; string sCaption = ""; string sType = ""; string sBtnPositon = ""; string sArrowType = ""; string sFrmType = ""; string sMsgID = ""; string sColor = ""; Boolean bSolid = true; Boolean bUnderLine = false; Boolean bHorzion = true; int iLeft = 0; int iTop = 0; int iWidth = 0; int iHeight = 0; int iLineWidth = 0; float iFontSize = 0; BillInfo info = c.Tag as BillInfo; if (c is DevExpress.XtraEditors.SimpleButton) { //Button按鈕 //sID = info.sID; sFrmName = c.Name.ToString().Trim(); sCaption = c.Text.ToString().Trim(); sFrmType = info.sFrmType; sMsgID = info.sMsgID; sType = "Btn"; iLeft = c.Left; iTop = c.Top; iWidth = c.Width; iHeight = c.Height; sBtnPositon = "TopCenter"; } else if (c is DevExpress.XtraEditors.LabelControl) { //Label控件 //sID = info.sID; sFrmName = c.Name.ToString().Trim(); sCaption = c.Text.ToString().Trim(); sFrmType = info.sFrmType; sMsgID = info.sMsgID; sType = "Label"; iLeft = c.Left; iTop = c.Top; iWidth = c.Width; iHeight = c.Height; if (c.Font.Underline) //下劃線 { bUnderLine = true; } iFontSize = ((DevExpress.XtraEditors.LabelControl)c).Font.Size; //字體大小 sColor = ((DevExpress.XtraEditors.LabelControl)c).ForeColor.Name.ToString(); //字體顏色 } else if (c is KzxLine) { sCaption = "Line"; sType = "Line"; if (((KzxLine)c).ArrowPosition == KzxLine.ArrowType.Start) { sArrowType = "Start"; } else if (((KzxLine)c).ArrowPosition == KzxLine.ArrowType.End) { sArrowType = "End"; } else if (((KzxLine)c).ArrowPosition == KzxLine.ArrowType.All) { sArrowType = "All"; } else if (((KzxLine)c).ArrowPosition == KzxLine.ArrowType.None) { sArrowType = "None"; } //顏色 if (((KzxLine)c).LineColor == KzxLine.ColorType.Black) { sColor = "Black"; } else if (((KzxLine)c).LineColor == KzxLine.ColorType.Blue) { sColor = "Blue"; } else if (((KzxLine)c).LineColor == KzxLine.ColorType.Green) { sColor = "Green"; } else if (((KzxLine)c).LineColor == KzxLine.ColorType.Lime) { sColor = "Lime"; } else if (((KzxLine)c).LineColor == KzxLine.ColorType.Red) { sColor = "Red"; } else if (((KzxLine)c).LineColor == KzxLine.ColorType.Yellow) { sColor = "Yellow"; } else if (((KzxLine)c).LineColor == KzxLine.ColorType.Black) { sColor = "Black"; } iLineWidth = ((KzxLine)c).lineWidth; if (!((KzxLine)c).IsSolid) { bSolid = false; } if (((KzxLine)c).LineStyle == KzxLine.LineType.Horizontal) { bHorzion = true; iLeft = ((KzxLine)c).Left; iTop = ((KzxLine)c).Top + ((KzxLine)c).lineWidth * 2 + 5; iWidth = ((KzxLine)c).Width + ((KzxLine)c).Left; iHeight = ((KzxLine)c).Top + ((KzxLine)c).lineWidth * 2 + 5; } else { bHorzion = false; iLeft = ((KzxLine)c).Left + ((KzxLine)c).lineWidth * 2 + 5; iTop = ((KzxLine)c).Top; iWidth = ((KzxLine)c).Left + ((KzxLine)c).lineWidth * 2 + 5; iHeight = ((KzxLine)c).Top + ((KzxLine)c).Height; } //gc[i] = c; } if ((c is DevExpress.XtraEditors.SimpleButton) || (c is DevExpress.XtraEditors.LabelControl) || (c is KzxLine)) { DataRow newRow = dtDesign.NewRow(); newRow["uGuid"] = Guid.NewGuid().ToString("D"); newRow["sModelCode"] = sModel; //newRow["sID"] = sID; newRow["sFrmName"] = sFrmName; newRow["sCaption"] = sCaption; newRow["sType"] = sType; newRow["iLeft"] = iLeft; newRow["iTop"] = iTop; newRow["iWidth"] = iWidth; newRow["iHeight"] = iHeight; newRow["sBtnPositon"] = sBtnPositon; newRow["sArrowType"] = sArrowType; if (c is DevExpress.XtraEditors.SimpleButton) { if (((DevExpress.XtraEditors.SimpleButton)c).Image != null) newRow["mImage"] = convertByte(((DevExpress.XtraEditors.SimpleButton)c).Image); } else { newRow["mImage"] = null; } //newRow["mImage"] = sModel; newRow["iOrder"] = iOrder; newRow["bActive"] = 1; newRow["sFrmType"] = sFrmType; newRow["sMsgID"] = sMsgID; newRow["sColor"] = sColor; newRow["iLineWidth"] = iLineWidth; newRow["iFontSize"] = iFontSize; newRow["sSysMode"] = ""; newRow["bSolid"] = bSolid; newRow["bUnderLine"] = bUnderLine; newRow["bHorizon"] = bHorzion; dtDesign.Rows.Add(newRow); iOrder = iOrder + 1; } } //TODO:保存到數(shù)據(jù)庫(kù)操作 this.Btn_SaveButton.Enabled = false; this.Btn_SaveLabel.Enabled = false; this.Btn_SaveLine.Enabled = false; bDesign = false; bAddBtn = false; bAddLabel = false; bAddLine = false; this.Btn_Design.Enabled = true; this.Btn_Post.Enabled = false; this.kzxsBtnAddButton.Enabled = false; this.kzxsBtnAddLabel.Enabled = false; this.kzxsBtnAddLine.Enabled = false; this.Btn_Cancel.Enabled = false; this.TabControl2.Enabled = true; //TODO:從數(shù)據(jù)庫(kù)加載數(shù)據(jù)流并綁定數(shù)據(jù) this.TabControl2.TabPages.Remove(this.TabControl2.SelectedTabPage); CreateFlowMap(sModel, sModelName);
如上代碼TODO出需要根據(jù)自己實(shí)際完善,或者公眾號(hào)私信作者一起探討。
至此工作完成!一起來看看最終效果:

由于后續(xù)所有重寫/重繪控件都在同一個(gè)項(xiàng)目使用,而且Dev系統(tǒng)引用文件較多,壓縮后源碼文件仍然很大,如果有需要源碼的朋友,可以微信公眾號(hào)聯(lián)系博主,源碼可以免費(fèi)贈(zèng)予~!有疑問的也可以CALL我一起探討。
最后,感謝您的耐心陪伴!如果覺得本篇博文對(duì)您或者身邊朋友有幫助的,麻煩點(diǎn)個(gè)關(guān)注!贈(zèng)人玫瑰,手留余香,您的支持就是我寫作最大的動(dòng)力,感謝您的關(guān)注,期待和您一起探討!再會(huì)!(update:公眾號(hào)回復(fù):Fucking ERP或者ERP 獲取源碼)
作者:Stephen-kzx
出處:http://www.rzrgm.cn/axing/
公眾號(hào):會(huì)定時(shí)分享寫工作中或者生活中遇到的小游戲和小工具源碼。有興趣的幫忙點(diǎn)下關(guān)注!感恩!
本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁(yè)面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。

浙公網(wǎng)安備 33010602011771號(hào)