使用NetronGraphLib類庫開發Qfd品質屋編製工具

來源:互聯網
上載者:User

標籤:href   count   jpg   point   高度   drawing   cti   設定圖   檔案   

前言

可執行檔下載  QfdHouse-exe.zip  

因項目需要做了一個品質功能配置(Quality Function Deployment 簡稱Qfd)的品質屋編製工具軟體,本軟體是在發布一個免費開源軟體-- PAD流程圖繪製軟體PADFlowChart基礎之上做的,效果如下:

 支援建立、儲存、匯出圖片,自訂使用者需求和技術特性,儲存格點擊切換關聯矩陣程度和自關聯矩陣的相關性。

開發中解決的問題

相信來這的人對Qfd是不感興趣的,下面就把遇到的問題說一下。

如何設定圖形的初始大小

1.在Shape類增加預設高度和寬度的屬性

       /// <summary>        /// 預設寬度        /// </summary>        private float mDefaultWidth = 0f;        /// <summary>        /// 預設高度        /// </summary>        private float mDefaultHeigh = 0f;
  /// <summary>        /// 預設寬度        /// </summary>        [GraphMLData]public float DefaultWidth        {            get { return mDefaultWidth; }            set { mDefaultWidth = value; }        }        /// <summary>        /// 預設高度        /// </summary>        [GraphMLData]        public float DefaultHeigh        {            get { return mDefaultHeigh; }            set { mDefaultHeigh = value; }        }

2.在TableShape類中初始化

        public TableShape() : base()        {            this.Init();            this.InitTestData3();            BindingEventHandler();            base.DefaultWidth = 300;            base.DefaultHeigh = 100;        }

3.修改GraphControl的DrawShapeMouseUp(PointF p)函數

   private void DrawShapeMouseUp(PointF p)        {            Cursor = System.Windows.Forms.Cursors.Default;            float t_left = (mMouseDownPoint.X < p.X ? mMouseDownPoint.X : p.X);            float t_right = (mMouseDownPoint.X >= p.X ? mMouseDownPoint.X : p.X);            float t_top = (mMouseDownPoint.Y < p.Y ? mMouseDownPoint.Y : p.Y);            float t_bottom = (mMouseDownPoint.Y >= p.Y ? mMouseDownPoint.Y : p.Y);            if (t_right - t_left < 10)            {               // t_right = t_left + mDefaultShapeWidth;                t_right = t_left + Math.Max(mDefaultShapeWidth, mshapeObject.DefaultWidth);            }            if (t_bottom - t_top < 10)            {                //t_bottom = t_top + mDefaultShapeHeight;                t_bottom = t_top + Math.Max(mDefaultShapeHeight, mshapeObject.DefaultHeigh);                      }            mshapeObject.Rectangle = RectangleF.FromLTRB(t_left, t_top, t_right, t_bottom);            Invalidate();            EndDrawShapeWithMouse();        }

注釋掉的是原來的代碼

如何匯出圖形到圖片格式

1. 在FlowChartForm.cs中增加儲存圖形圖片的方法

  public bool SaveShapeImage()        {            if (graphControl.SelectedShapes.Count != 1)            {                MessageBox.Show("請選中一個圖形");                return false;            }            var fileName = string.Empty;            using (SaveFileDialog sfd = new SaveFileDialog())            {                sfd.DefaultExt = ".jpg";                sfd.Filter = "jpg file(*.jpg)|*.jpg";                if (sfd.ShowDialog() == DialogResult.OK)                {                    fileName = sfd.FileName;                }                else                {                    return false;                }            }            var shape = graphControl.SelectedShapes[0];            graphControl.SaveShapeImage(fileName, shape);            return true;        }

2.在GraphControl.cs中增加SaveShapeImage方法

  public void SaveShapeImage(string path,Shape shape)        {            Image bmp = GetShapeImage(shape);            bmp.Save(path);        }        public Image GetShapeImage(Shape  shape)        {            var oldRectangle = shape.Rectangle;            var newRectangle = new RectangleF(0, 0, oldRectangle.Width, oldRectangle.Height);            shape.Rectangle = newRectangle;            Bitmap bmp = new Bitmap((int)shape.Rectangle.Width, (int)shape.Rectangle.Height, this.CreateGraphics());               using (Graphics g = Graphics.FromImage(bmp))            {                g.SmoothingMode = SmoothingMode.AntiAlias;                shape.Paint(g);                         }            shape.Rectangle = oldRectangle;         Image.GetThumbnailImageAbort tCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);            return bmp.GetThumbnailImage((int)shape.Rectangle.Width,(int)shape.Rectangle.Height, tCallback, IntPtr.Zero);        }

 

使用NetronGraphLib類庫開發Qfd品質屋編製工具

相關關鍵詞:
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.