玩轉控件: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我一起探討。

    最后,感謝您的耐心陪伴!如果覺得本篇博文對您或者身邊朋友有幫助的,麻煩點個關注!贈人玫瑰,手留余香,您的支持就是我寫作最大的動力,感謝您的關注,期待和您一起探討!再會!(update:公眾號回復:Fucking ERP或者ERP 獲取源碼)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM