Ejemplo n.º 1
0
 private void shtListView_MouseDoubleClick_1(object sender, MouseEventArgs e)
 {
     ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
     if (selItems.Count == 1)
     {
         ListViewItem item     = selItems[0];
         long         iSheetID = (long)item.Tag;
         SheetEx      sheet    = m_sheetList.GetSheetByID(iSheetID);
         if (sheet != null)
         {
             SheetInfoForm form = new SheetInfoForm(m_impDataList, m_partColorConfig, sheet);
             form.ShowDialog();
         }
     }
 }
Ejemplo n.º 2
0
        private void viewShtBtn_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
            if (selItems.Count != 1)
            {
                MessageBox.Show("Please select one sheet to view.", "NestProfessor DEMO");
                return;
            }
            else
            {
                ListViewItem  item        = selItems[0];
                long          iSheetID    = (long)item.Tag;
                SheetEx       sheet       = m_sheetList.GetSheetByID(iSheetID);
                string        M_Name      = sheet.GetMat().GetName();
                PartPmtListEx partPmtList = sheet.GetPartPmtList();
                int           partsCount  = partPmtList.GetPartList().Size();
                Rect2DEx      sheetRec    = sheet.GetMat().GetGeomItemList().GetItemByIndex(0).GetRectBox();
                string        info        = "SheetName:" + M_Name + "\r\nWidth:" + sheetRec.GetWidth().ToString() + "--Height:" + sheetRec.GetHeight().ToString();
                for (int i = 0; i < partsCount; i++)
                {
                    PartEx     partEx = partPmtList.GetPartList().GetPartByIndex(i);
                    PartPmtEx  part   = sheet.GetPartTopItemList().GetPartPmtByIndex(i).GetPartPmt();
                    Rect2DEx   re2    = part.GetRectBox();
                    Matrix2DEx Matrix = part.GetMatrix();
                    info += "\r\nPartName:" + partEx.GetName()
                            + "\r\n角度:" + Math.Round(Math.Asin(Matrix.GetMatVal(0, 1)) * 180 / Math.PI).ToString() + "度"
                            + "\r\nX:" + Math.Round(Matrix.GetMatVal(2, 0)).ToString()
                            + "\tY:" + Math.Round(Matrix.GetMatVal(2, 1)).ToString()
                            + "\r\n长:" + Math.Round(re2.GetWidth()).ToString()
                            + "\t宽:" + Math.Round(re2.GetHeight()).ToString()
                            + "\t面积:" + Math.Round(re2.GetWidth() * re2.GetHeight()).ToString();
                }

                Bitmap   bmp         = new Bitmap(300, 300);
                Graphics GraphicsObj = Graphics.FromImage(bmp);
                GraphicsObj.Clear(Color.White);
                //写字
                string str      = "OrderNo:0025";
                Font   font     = new Font("微软雅黑", 15f);
                double strWidth = TextRenderer.MeasureText(str, font).Width;
                Brush  brush    = Brushes.Red;
                PointF point    = new PointF(10f, 10f);
                GraphicsObj.DrawString(str, font, brush, 10, 10);
                //画图形
                Pen myPen = new Pen(Color.Red, 1);
                GraphicsObj.DrawRectangle(myPen, 50, 50, 30, 30);//画矩形
                SolidBrush myBrush = new SolidBrush(Color.Red);
                GraphicsObj.FillRectangle(myBrush, 70, 70, 30, 30);
                //添加图形
                Bitmap   tBtm      = new Bitmap(1000, 1000);
                Brush    blackrush = Brushes.Black;
                Graphics gTest     = Graphics.FromImage(tBtm);
                gTest.FillRectangle(blackrush, 0, 0, 1000, 1000);
                GraphicsObj.DrawImage(tBtm, 100, 100, 50, 50);



                MessageBox.Show(info);

                if (sheet != null)
                {
                    SheetInfoForm form = new SheetInfoForm(m_impDataList, m_partColorConfig, sheet);
                    form.ShowDialog();
                }
            }
        }