前言
首先,跟守護在作者公衆号和私信作者催更的朋友們道個歉。疫情的原因,公司從年初到現在一直處于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我一起探讨。
最後,感謝您的耐心陪伴!如果覺得本篇博文對您或者身邊朋友有幫助的,麻煩點個關注!贈人玫瑰,手留餘香,您的支援就是我寫作最大的動力,感謝您的關注,期待和您一起探讨!再會!(update:公衆号回複:Fucking ERP或者ERP 擷取源碼)
作者:Stephen-kzx
出處:http://www.cnblogs.com/axing/
公衆号:會定時分享寫工作中或者生活中遇到的小遊戲和小工具源碼。有興趣的幫忙點下關注!感恩!
本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接,否則保留追究法律責任的權利。