玩轉控制元件:Fucking ERP之流程圖
前言
首先,跟守護在作者公眾號和私信作者催更的朋友們道個歉。疫情的原因,公司從年初到現在一直處於996+的高壓模式,導致公眾號更新頻率較低。而且作者每更新一篇原創公眾號,既要對自己沉澱知識負責,也要對願意和作者一起探討一起學習一起進步的小夥伴兒們負責,防止誤人子弟。所以作者的每一篇原創,都是作者在有限時間內仔細推敲後的產物,希望大家可以理解。
Talk is Cheap!
前面分享的幾個章節,差不多把實際用到的控制元件和容器的封裝、擴充套件、重繪都舉例到了(後續如果還有其他特例,作者也會更新進來)。今天要分享的依然是“Fucking ERP”系列中比較重要的環節——流程圖。
本章的流程圖並非工作流,winform在市面上有很多經典的工作流元件比如微軟的WWF,還有很多開源自主研發的工作流元件等等,後續作者實際用到的話也會分享出來和大家一起探討。此處分享的流程圖,主要是"標識"的作用,主要用來表示業務資料的流轉,具體資料如何流轉,都需要各位後臺自行處理(說白了,就是從A表查出資料,插入到B表,然後更新A表標識罷了。)
Show me the Code!
首先,介面載入的時候,初始化控制元件可用性,以及所有模組列表
private void frmWorkFlow_Load(object sender, EventArgs e) { //建立大模組 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來模擬資料庫操作。初始化模組選單方法如下:
//建立主目錄 public void CreateModule() { //此處拿DataTable來儲存資料庫的所有選單節點,此處用銷售模組來舉例 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"); //存在子選單生產樹結構 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); } } }
模組按鈕綁定了點選事件,用於觸發當前選擇的選單的流程圖(程式碼邏輯已經新增,時間有限,本文不做處理,如有疑問,可公眾號私信作者一起探討)
private void onBtnClick(object sender, EventArgs e) { sModel = ((DevExpress.XtraEditors.SimpleButton)sender).Name.ToString().Trim(); sModelName = ((DevExpress.XtraEditors.SimpleButton)sender).Text.ToString().Trim(); //根據選擇的選單模組,載入當前選單的流程圖 CreateFlowMap(((DevExpress.XtraEditors.SimpleButton)sender).Name.ToString().Trim(), ((DevExpress.XtraEditors.SimpleButton)sender).Text.ToString().Trim()); }
建立流程圖部分方法如下(有需要原始碼可關注作者公眾號,私信作者免費獲取):
//建立流程圖 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; } } //不存在需要增加頁面 if (!bExists) { .....
You say a JB without pictures !無圖言X,先給大家看看設計圖
圖片展示解析:
1.左側欄初始化動作,載入所有系統模組
2.右側上部分為操作欄,設計按鈕處理當前選中的選單模組,用於載入/新增/刪除當前模組的流程圖
3.右側左邊部分為繪製工具欄,此處只拿繪製直線(或帶箭頭的直線),Label(流程註釋),按鈕來舉例子。
4.右側下部分為繪製工具欄的屬性配置,點選儲存,呈現繪製結果如圖右側中間部分
5.流程圖展示區,用於載入或繪製流程圖
(以上因篇幅和時間限制未做詳細測試,主要實現功能為主舉個例子,作者繪製期間也有遇到不完善的地方,後續有時間在優化)
程式碼沒有太大難度(需要原始碼研究可關注作者公眾號,私信作者免費獲取),主要跟大家分享下繪製流程模組吧。
(帶箭頭的)直線的繪製
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是作者封裝的使用者控制元件,(如有需要,請關注公眾號私信作者,原始碼免費贈送)部分程式碼如下:
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(); }
點選如圖"箭頭/直線"按鈕後,下面會顯示控制元件的屬性配置區域,設定好後點擊儲存,就會把繪製好的控制元件新增到流程圖展示區。儲存事件如下:
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()); } } }
因所有繪製控制元件都綁定了拖拽事件,所以可以在流程圖展示區隨意拖拽部署顯示控制元件(效果見下圖)。
Label(註釋)控制元件封裝
/// <summary> /// 標籤驗證 /// </summary> public partial class KzxLabel : KzxBaseControl
Label無需重繪只需封裝,初始化繫結多語言即可。
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一樣,具體請移步《玩轉控制元件:擴充套件Dev中SimpleButton》.或者直接用Dev原生的SimpleButton亦可,此處不做過多廢話。只需在屬性配置區域的儲存事件中,新增到流程圖展示區即可,配置區的按鈕儲存程式碼如下:
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註釋","按鈕"等功能的準備工作,具體效果如圖:
再次強調,因時間和篇幅問題,作者沒有對程式碼做嚴格的校驗,主要以實現功能為主。所以當您拿到原始碼時需要根據實際情況自行完善,或者後續作者有時間也會繼續完善(工作996+的我太難了!)
各個模組功能實現後,就是儲存當前繪製的流程圖環節了,為了演示效果,作者沒有處理資料庫相關的工作,主要以DataTable來儲存相關繪製資料的。至於圖片,作者是用流的方式來儲存的,展示時解析即可。
#region 圖片處理 /// <summary> /// 點選上傳圖片 /// </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> /// 用流的方式來儲存圖片 /// </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資料儲存如下圖:
大家可以根據自己實際情況,儲存到資料庫或者配置檔案中,具體儲存程式碼如下:
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:儲存到資料庫操作 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:從資料庫載入資料流並繫結資料 this.TabControl2.TabPages.Remove(this.TabControl2.SelectedTabPage); CreateFlowMap(sModel, sModelName);
如上程式碼TODO出需要根據自己實際完善,或者公眾號私信作者一起探討。
至此工作完成!一起來看看最終效果:
由於後續所有重寫/重繪控制元件都在同一個專案使用,而且Dev系統引用檔案較多,壓縮後原始碼檔案仍然很大,如果有需要原始碼的朋友,可以微信公眾號聯絡博主,原始碼可以免費贈予~!有疑問的也可以CALL我一起探討。
最後,感謝您的耐心陪伴!如果覺得本篇博文對您或者身邊朋友有幫助的,麻煩點個關注!贈人玫瑰,手留餘香,您的支援就是我寫作最大的動力,感謝您的關注,期待和您一起探討!再會!
&n