Esempio n. 1
0
        private void MaterialForm_Load(object sender, EventArgs e)
        {
            nameTextBox.Text  = m_mat.GetName();
            countTextBox.Text = m_mat.GetCount().ToString();

            if (m_mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx rectMat = (RectMatEx)(m_mat);
                Rect2DEx  rect    = rectMat.GetBoundaryRect();
                widthTextBox.Enabled  = true;
                widthTextBox.Text     = rect.GetWidth().ToString("0.000");
                heightTextBox.Enabled = true;
                heightTextBox.Text    = rect.GetHeight().ToString("0.000");
            }
            else if (m_mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                PolyMatEx   polyMat = (PolyMatEx)(m_mat);
                Polygon2DEx poly    = polyMat.GetMatPolygon();
                Rect2DEx    rect    = poly.GetBoundaryRect();
                widthTextBox.Enabled  = false;
                widthTextBox.Text     = rect.GetWidth().ToString("0.000");
                heightTextBox.Enabled = false;
                heightTextBox.Text    = rect.GetHeight().ToString("0.000");
            }
        }
Esempio n. 2
0
        private void RemnantMatInfoForm_Load(object sender, EventArgs e)
        {
            // build the remnant material from the sheet.
            double dMergeDis = 10;

            m_polyMat = NestFacadeEx.BuildRemnantMat(m_sheet, m_dConnectTol, dMergeDis);

            // init the tree.
            UpdateTree();

            /************************************************************************/
            // init the view port.

            m_matViewPort.InitEnv(matViewWnd.Handle, 0.00001, 10000);

            // all polygons in material.
            Poly2DListEx poly2DList = new Poly2DListEx();

            poly2DList.AddPoly(m_polyMat.GetMatPolygon());
            poly2DList.AddPolyList(m_polyMat.GetUselessHoleList());

            // set the drawing area.
            Int32     iWidth       = matViewWnd.Right - matViewWnd.Left;
            Int32     iHeight      = matViewWnd.Bottom - matViewWnd.Top;
            Rect2DEx  geomRect     = poly2DList.GetRectBox();
            Point2DEx leftBottomPt = new Point2DEx();
            double    dXDirRange   = m_matViewPort.GetFitAllParam(iWidth, iHeight, geomRect, 1.2, leftBottomPt);

            m_matViewPort.SetDrawingArea(1.1 * dXDirRange, iWidth, iHeight, leftBottomPt);
            /************************************************************************/

            mergeDisTextBox.Text = dMergeDis.ToString("0.000");
        }
Esempio n. 3
0
        // draw the material.
        static public void DrawMat(MatEx mat, GlViewPortEx viewPort)
        {
            viewPort.SetDrawColor(Color.White);
            viewPort.SetLineWidth(1);

            if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx   rectMat = (RectMatEx)mat;
                Rect2DEx    rect2D  = rectMat.GetBoundaryRect();
                Polygon2DEx poly    = new Polygon2DEx();
                poly.AddPoint(new Point2DEx(rect2D.GetXMin(), rect2D.GetYMin()));
                poly.AddPoint(new Point2DEx(rect2D.GetXMax(), rect2D.GetYMin()));
                poly.AddPoint(new Point2DEx(rect2D.GetXMax(), rect2D.GetYMax()));
                poly.AddPoint(new Point2DEx(rect2D.GetXMin(), rect2D.GetYMax()));
                viewPort.DrawPolygon(poly);
            }
            else if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                PolyMatEx   polyMat = (PolyMatEx)mat;
                Polygon2DEx poly    = polyMat.GetMatPolygon();
                viewPort.DrawPolygon(poly);

                // draw the useless holes.
                Poly2DListEx uselessHoles = polyMat.GetUselessHoleList();
                for (int i = 0; i < uselessHoles.Size(); i++)
                {
                    viewPort.DrawPolygon(uselessHoles.GetPolygonByIndex(i));
                }
            }
        }
Esempio n. 4
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            // verify input.
            try
            {
                Convert.ToDouble(widthTextBox.Text);
                Convert.ToDouble(heightTextBox.Text);
                Convert.ToInt32(countTextBox.Text);
            }
            catch (FormatException exception)
            {
                MessageBox.Show("Incorrect input: " + exception.Message, "NestProfessor DEMO");
                return;
            }

            // update MatEx object.
            m_mat.SetName(nameTextBox.Text);
            m_mat.SetCount(Convert.ToInt32(countTextBox.Text));
            if (m_mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx rectMat = (RectMatEx)(m_mat);
                Rect2DEx  rect    = new Rect2DEx(0.0, Convert.ToDouble(widthTextBox.Text), 0.0, Convert.ToDouble(heightTextBox.Text));
                rectMat.SetMatRect(rect);
            }

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 5
0
        // fit the view port to the rect.
        static public void FitWindow(Rect2DEx geomRect, GlViewPortEx viewPort, Control window)
        {
            Int32     iWidth       = window.Right - window.Left;
            Int32     iHeight      = window.Bottom - window.Top;
            Point2DEx leftBottomPt = new Point2DEx();
            double    dXDirRange   = viewPort.GetFitAllParam(iWidth, iHeight, geomRect, 1.2, leftBottomPt);

            viewPort.SetDrawingArea(1.1 * dXDirRange, iWidth, iHeight, leftBottomPt);
        }
Esempio n. 6
0
        // add material to list control.
        private void AddMat(MatEx mat)
        {
            // the boundary rect of the material.
            Rect2DEx boundaryRect = null;

            if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx rectMat = (RectMatEx)mat;
                boundaryRect = rectMat.GetBoundaryRect();
            }
            else if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                PolyMatEx   polyMat = (PolyMatEx)mat;
                Polygon2DEx polygon = polyMat.GetMatPolygon();
                boundaryRect = polygon.GetBoundaryRect();
            }

            /************************************************************************/
            // add a row to list control.

            // insert a row.
            int          iCount = matListView.Items.Count + 1;
            ListViewItem item   = matListView.Items.Add(iCount.ToString());

            // name column.
            item.SubItems.Add(mat.GetName());

            // material type column.
            if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                item.SubItems.Add("矩形材料");
            }
            else if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                item.SubItems.Add("不规则材料");
            }

            // the material height.
            item.SubItems.Add(boundaryRect.GetHeight().ToString("0.000"));

            // the material width.
            item.SubItems.Add(boundaryRect.GetWidth().ToString("0.000"));

            // the material count.
            item.SubItems.Add(mat.GetCount().ToString());

            // hold the ID.
            item.Tag = mat.GetID();
            /************************************************************************/

            // select the last row.
            matListView.SelectedItems.Clear();
            matListView.Items[matListView.Items.Count - 1].Selected = true;
            matListView.Items[matListView.Items.Count - 1].Focused  = true;
            matListView.Items[matListView.Items.Count - 1].EnsureVisible();
        }
Esempio n. 7
0
        // add part to list control.
        private void AddPart_to_listCtrl(NestPartEx nestPart, string order)
        {
            // insert a row.
            int          iCount = partListView.Items.Count + 1;
            ListViewItem item   = partListView.Items.Add(iCount.ToString());

            // part name column.
            item.SubItems.Add(nestPart.GetPart().GetName());

            // priority column.
            item.SubItems.Add(nestPart.GetPriority().GetVal().ToString());

            // nest count column.
            item.SubItems.Add(nestPart.GetNestCount().ToString());

            // rotate angle column.
            String strRotateAng = NestHelper.GetRotateAngName(nestPart.GetRotStyle());

            string temp = string.Empty;

            switch (strRotateAng.Trim())
            {
            case "Free Rotate": temp = "自由旋转"; break;

            case "90 Increment": temp = "90度增量"; break;

            case "180 Increment": temp = "180度增量"; break;

            case "0 Fixed": temp = "0度固定"; break;

            case "90 Fixed": temp = "90度固定"; break;

            case "180 Fixed": temp = "180度固定"; break;

            case "270 Fixed": temp = "270度固定"; break;
            }

            item.SubItems.Add(temp);

            // "Part Size" column.
            Rect2DEx      partRect = nestPart.GetPart().GetGeomItemList().GetRectBox();
            StringBuilder sb       = new StringBuilder();

            sb.Append(partRect.GetWidth().ToString("0.00")).Append("(W) * ").Append(partRect.GetHeight().ToString("0.00")).Append("(H)");
            item.SubItems.Add(sb.ToString());

            //添加订单号
            item.SubItems.Add(order);

            // hold the ID.
            item.Tag = nestPart.GetID();

            OrderManagerDal.Instance.AddOrder(nestPart.GetPart().GetID(), order);
        }
Esempio n. 8
0
        private void editMatBtn_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selItems = matListView.SelectedItems;
            if (selItems.Count != 1)
            {
                MessageBox.Show("Please select one row to edit.", "NestProfessor DEMO");
                return;
            }
            else
            {
                ListViewItem item   = selItems[0];
                long         iMatID = (long)item.Tag;
                MatEx        mat    = m_matList.GetMatByID(iMatID);
                if (mat != null)
                {
                    if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
                    {
                        MessageBox.Show("For irregular material, its width and height can be edited here.", "NestProfessor DEMO");
                    }

                    MaterialForm matForm = new MaterialForm(mat);
                    if (matForm.ShowDialog() == DialogResult.OK)
                    {
                        /************************************************************************/
                        // update the list control.

                        // name column.
                        item.SubItems[1].Text = mat.GetName();

                        if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
                        {
                            RectMatEx rectMat = (RectMatEx)(mat);
                            Rect2DEx  rect    = rectMat.GetBoundaryRect();

                            // the material width.
                            item.SubItems[3].Text = rect.GetWidth().ToString("0.000");

                            // the material height.
                            item.SubItems[4].Text = rect.GetHeight().ToString("0.000");
                        }

                        // count.
                        item.SubItems[5].Text = mat.GetCount().ToString();
                        /************************************************************************/

                        matPreviewWnd.Invalidate();
                    }
                }
            }
        }
Esempio n. 9
0
        private void newMatBtn_Click(object sender, EventArgs e)
        {
            // create a RectMatEx object.
            Rect2DEx  rect    = new Rect2DEx(0, 1200, 0, 2400);
            RectMatEx rectMat = new RectMatEx("新材料", rect, 1);

            MaterialForm matForm = new MaterialForm(rectMat);

            if (matForm.ShowDialog() == DialogResult.OK)
            {
                m_matList.AddMat(rectMat);

                // add material to list control.
                AddMat(rectMat);
            }
        }
Esempio n. 10
0
        private void reGenBtn_Click(object sender, EventArgs e)
        {
            // verify input.
            try
            {
                Convert.ToDouble(mergeDisTextBox.Text);
            }
            catch (FormatException exception)
            {
                MessageBox.Show("Incorrect input: " + exception.Message, "NestProfessor DEMO");
                return;
            }

            // re-generate the remnant material from the sheet.
            m_polyMat = NestFacadeEx.BuildRemnantMat(m_sheet, m_dConnectTol, Convert.ToDouble(mergeDisTextBox.Text));

            // update tree nodes.
            UpdateTree();

            /************************************************************************/
            // adjust the drawing area.

            // the boundary rect of all polygons in material.
            Poly2DListEx poly2DList = new Poly2DListEx();

            poly2DList.AddPoly(m_polyMat.GetMatPolygon());
            poly2DList.AddPolyList(m_polyMat.GetUselessHoleList());
            Rect2DEx geomRect = poly2DList.GetRectBox();

            // set the drawing area.
            Int32     iWidth       = matViewWnd.Right - matViewWnd.Left;
            Int32     iHeight      = matViewWnd.Bottom - matViewWnd.Top;
            Point2DEx leftBottomPt = new Point2DEx();
            double    dXDirRange   = m_matViewPort.GetFitAllParam(iWidth, iHeight, geomRect, 1.2, leftBottomPt);

            m_matViewPort.SetDrawingArea(1.1 * dXDirRange, iWidth, iHeight, leftBottomPt);

            m_selPoly = null;
            Invalidate();
            /************************************************************************/
        }
Esempio n. 11
0
        // preview the selected sheet.
        private void PreviewSheet()
        {
            // get the select sheet.
            ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
            if (selItems.Count == 0)
            {
                return;
            }
            ListViewItem item          = selItems[0];
            long         iSheetID      = (long)item.Tag;
            SheetEx      selectedSheet = m_sheetList.GetSheetByID(iSheetID);

            // clear screen and set the background color.
            m_shtViewPort.BindRendContext();
            m_shtViewPort.ClearScreen();
            m_shtViewPort.SetBackgroundColor(Color.Black);

            // draw coordinate.
            m_shtViewPort.SetDrawColor(Color.Blue);
            m_shtViewPort.SetLineWidth(1);
            m_shtViewPort.DrawCoordinate(0, 0, 0, false);

            // draw material.
            DrawHelper.DrawMat(selectedSheet.GetMat(), m_shtViewPort);

            // draw parts.
            DrawHelper.DrawPartPmts(selectedSheet.GetPartPmtList(), null, m_shtViewPort, m_partColorConfig, m_impDataList);

            // swap buffer to display the geometry.
            m_shtViewPort.SwapBuffers();

            // the rect of part region.
            Rect2DEx partsRect = selectedSheet.GetPartPmtList().GetRectBox();

            partRegionTextBox.Text = partsRect.GetWidth().ToString("0.000") + " * " + partsRect.GetHeight().ToString("0.000");
        }
Esempio n. 12
0
        private void QrCodeForm_Load(object sender, EventArgs e)
        {
            int v = 0;

            int        vv         = 0;
            int        vvv        = 0;
            Pen        blackPen   = new Pen(Color.Black, 1);
            Pen        blackPen2  = new Pen(Color.Black, 2);
            SolidBrush blackBrush = new SolidBrush(Color.Black);
            HatchBrush hatchBrush = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Black, Color.White);
            //外边距
            int space = 2;

            for (int length = 0; length < shtListView.Items.Count; length++)
            {
                SLTQrCodeItem SLTQrCodeItemTemp = new SLTQrCodeItem()
                {
                    SLTBmpShadowList = new List <SLTShadowBmp>()
                };
                ListViewItem  item        = shtListView.Items[length];
                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().GetBoundaryRect();
                int           MatWidth    = (int)sheetRec.GetWidth();
                int           MatHeight   = (int)sheetRec.GetHeight();
                SLTQrCodeItemTemp.BlankBmp = new Bitmap(MatWidth + 1, MatHeight + 1);
                Graphics gBlank = Graphics.FromImage(SLTQrCodeItemTemp.BlankBmp);
                gBlank.Clear(Color.FromArgb(255, 255, 255, 255));
                //边框
                gBlank.DrawRectangle(blackPen, 0, 0, MatWidth, MatHeight);
                //缩略图
                for (int i = 0; i < partsCount; i++)
                {
                    SLTShadowBmp SLTShadowBmpItem = new SLTShadowBmp();
                    PartPmtEx    partPmt          = sheet.GetPartTopItemList().GetPartPmtByIndex(i).GetPartPmt();
                    Rect2DEx     partRe2          = partPmt.GetRectBox();
                    Matrix2DEx   Matrix           = partPmt.GetMatrix();
                    int          PartWidth        = (int)partRe2.GetWidth();
                    int          PartHeight       = (int)partRe2.GetHeight();
                    int          PoX   = (int)Matrix.GetMatVal(2, 0);
                    int          PoY   = (int)Matrix.GetMatVal(2, 1);
                    int          Angle = (int)(Math.Asin(Matrix.GetMatVal(0, 1)) * 180 / Math.PI);
                    SLTShadowBmpItem.SLTPartInfos = new SLTPartShape()
                    {
                        PoX        = m_nestParam.GetNestDir() == NEST_DIRECTION_EX.NEST_DIR_X ? PoX : PoX - PartWidth,
                        PoY        = MatHeight - PoY - PartHeight,
                        PartWidth  = PartWidth,
                        PartHeight = PartHeight,
                        NestDir    = m_nestParam.GetNestDir() == NEST_DIRECTION_EX.NEST_DIR_X ? "X" : "Y",
                        MatName    = M_Name,
                    };
                    SLTQrCodeItemTemp.SLTBmpShadowList.Add(SLTShadowBmpItem);
                    gBlank.DrawRectangle(blackPen, SLTShadowBmpItem.SLTPartInfos.PoX, SLTShadowBmpItem.SLTPartInfos.PoY, PartWidth, PartHeight);
                }
                gBlank.Dispose();
                //加阴影缩略图
                for (int i = 0; i < SLTQrCodeItemTemp.SLTBmpShadowList.Count; i++)
                {
                    Bitmap       original  = SLTQrCodeItemTemp.BlankBmp;
                    Bitmap       copy      = new Bitmap(original.Width, original.Height);
                    SLTShadowBmp Shapeitem = SLTQrCodeItemTemp.SLTBmpShadowList[i];
                    using (Graphics gTemp = Graphics.FromImage(copy))
                    {
                        gTemp.Clear(Color.White);
                        Rectangle imageRectangle = new Rectangle(0, 0, copy.Width, copy.Height);
                        gTemp.DrawImage(original, imageRectangle, imageRectangle, GraphicsUnit.Pixel);
                        gTemp.FillRectangle(hatchBrush, Shapeitem.SLTPartInfos.PoX,
                                            Shapeitem.SLTPartInfos.PoY, Shapeitem.SLTPartInfos.PartWidth, Shapeitem.SLTPartInfos.PartHeight);
                        gTemp.DrawRectangle(blackPen2, Shapeitem.SLTPartInfos.PoX,
                                            Shapeitem.SLTPartInfos.PoY, Shapeitem.SLTPartInfos.PartWidth, Shapeitem.SLTPartInfos.PartHeight);//画矩形
                    }
                    SLTQrCodeItemTemp.SLTBmpShadowList[i].ShadowBmp = copy;
                    PartEx partEx        = partPmtList.GetPartList().GetPartByIndex(i);
                    string OrderNo       = OrderManagerDal.Instance.GetOrder(partEx.GetID());
                    string partNameIndex = partEx.GetName().Substring(1, 1);
                    string partName      = partEx.GetName();
                    SLTQrCodeItemTemp.SLTBmpShadowList[i].QrCodeText = OrderNo + "-" + partNameIndex;
                    SLTQrCodeItemTemp.SLTBmpShadowList[i].QrCodeBmp  = GenerateQRCode(partNameIndex);
                    //字体
                    Font font = new Font("微软雅黑", 60f);//8号
                    //设定字体格式
                    StringFormat format = new StringFormat()
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center,
                    };
                    string text1 = OrderNo + "-" + partNameIndex;
                    string text2 = partName;
                    string text3 = Shapeitem.SLTPartInfos.PartWidth + "*" + Shapeitem.SLTPartInfos.PartHeight;
                    string text4 = Shapeitem.SLTPartInfos.MatName;
                    SLTQrCodeItemTemp.SLTBmpShadowList[i].SLTText = text1 + "\r\n" + text2 + "\r\n" + text3 + "\r\n" + text4;
                    Size   SLTTextSize = TextRenderer.MeasureText(SLTQrCodeItemTemp.SLTBmpShadowList[i].SLTText, font);
                    Bitmap textBmp     = new Bitmap(SLTTextSize.Width + space + 5, SLTTextSize.Width + space + 5);
                    using (Graphics gTextTemp = Graphics.FromImage(textBmp))
                    {
                        gTextTemp.Clear(Color.White);
                        gTextTemp.SmoothingMode = SmoothingMode.HighQuality;
                        gTextTemp.DrawString(SLTQrCodeItemTemp.SLTBmpShadowList[i].SLTText, font, blackBrush,
                                             new RectangleF(space, (textBmp.Height - SLTTextSize.Height - (2 * space)) / 2 + space, textBmp.Width - space, textBmp.Height - space));
                    }
                    SLTQrCodeItemTemp.SLTBmpShadowList[i].SLTTextBmp = textBmp;
                }
                _SLTQrCodeList.Add(SLTQrCodeItemTemp);
                //g.DrawString(partName, font, blackBrush, new RectangleF(0, 0, 100, 100), format);
                //g.DrawImage(qrBmp, 150, 150, 50, 50);
            }

            //
            int          bmpPrintWidth = 500;
            int          Colunm        = 2;
            List <Shape> positionBase  = new List <Shape>();
            int          count         = 0;

            for (int i = 0; i < _SLTQrCodeList.Count; i++)
            {
                for (int j = 0; j < _SLTQrCodeList[i].SLTBmpShadowList.Count; j++)
                {
                    count++;
                }
            }
            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < Colunm; j++)
                {
                    if (i * j + j >= count)
                    {
                        break;
                    }
                    Shape itemTemp = new Shape()
                    {
                        PoX        = j * (bmpPrintWidth / Colunm),
                        PoY        = i * (bmpPrintWidth / Colunm),
                        PartWidth  = bmpPrintWidth / Colunm,
                        PartHeight = bmpPrintWidth / Colunm,
                    };
                    positionBase.Add(itemTemp);
                }
            }

            int    bmpPrintHeight = ((positionBase.Count / Colunm) + (positionBase.Count % Colunm)) * (bmpPrintWidth / Colunm);
            Bitmap PrintBmp       = new Bitmap(bmpPrintWidth, bmpPrintHeight);

            using (Graphics gPrint = Graphics.FromImage(PrintBmp))
            {
                gPrint.Clear(Color.White);
                count = 0;
                for (int i = 0; i < _SLTQrCodeList.Count; i++)
                {
                    for (int j = 0; j < _SLTQrCodeList[i].SLTBmpShadowList.Count; j++)
                    {
                        float TextPx   = positionBase[count].PoX;
                        float TextPy   = positionBase[count].PoY + positionBase[count].PartHeight * 0.1f;
                        float QrCodePx = TextPx;
                        float QrCodePy = positionBase[count].PoY + positionBase[count].PartHeight * 0.5f;

                        float  SLTPx      = positionBase[count].PoX + positionBase[count].PartWidth * 0.4f;
                        float  SLTPy      = positionBase[count].PoY;
                        Size   SLTSize    = _SLTQrCodeList[i].SLTBmpShadowList[j].ShadowBmp.Size;
                        float  SLTWidth   = (int)(positionBase[count].PartHeight * SLTSize.Width / SLTSize.Height);
                        float  SLTHeight  = (int)(positionBase[count].PartHeight);
                        Bitmap SLTBmpTemp = _SLTQrCodeList[i].SLTBmpShadowList[j].ShadowBmp;
                        float  scale      = (float)SLTSize.Width / (float)SLTSize.Height;
                        if (scale < 0.6f)//固定高度
                        {
                            SLTWidth  = (int)(positionBase[count].PartHeight * SLTSize.Width / SLTSize.Height);
                            SLTHeight = positionBase[count].PartHeight;
                        }
                        else if (0.6f < scale && scale < 1)//固定宽度
                        {
                            SLTWidth  = positionBase[count].PartWidth * 0.6f;
                            SLTHeight = (int)(positionBase[count].PartWidth * 0.6f * SLTSize.Height / SLTSize.Width);
                        }
                        else if (scale > 1)//旋转
                        {
                            SLTWidth  = positionBase[count].PartWidth * 0.6f;
                            SLTHeight = (int)(positionBase[count].PartWidth * 0.6f * SLTSize.Height / SLTSize.Width);
                            //SLTBmpTemp = new Bitmap(SLTSize.Width, SLTSize.Height);
                            //using (Graphics gCcopy = Graphics.FromImage(SLTBmpTemp))
                            //{
                            //    gCcopy.Clear(Color.White);
                            //    gCcopy.TranslateTransform(0, 0); //源点移动到旋转中心
                            //    gCcopy.RotateTransform(90f); //旋转
                            //    Rectangle imageRectangle = new Rectangle(0, 0, SLTSize.Width, SLTSize.Height);
                            //    gCcopy.DrawImage(_SLTQrCodeList[i].SLTBmpShadowList[j].ShadowBmp, imageRectangle, imageRectangle, GraphicsUnit.Pixel);
                            //}
                            //scale = SLTSize.Height / SLTSize.Width;
                            //if (0.6f < scale && scale < 1)//固定高度
                            //{
                            //    SLTWidth = (int)(positionBase[count].PartHeight * SLTSize.Width / SLTSize.Height);
                            //    SLTHeight = positionBase[count].PartHeight;
                            //}
                            //else if (0.6f < scale && scale < 1)//固定宽度
                            //{
                            //    SLTWidth = positionBase[count].PartWidth * 0.6f;
                            //    SLTHeight = (int)(positionBase[count].PartWidth * 0.6f * SLTSize.Height / SLTSize.Width);
                            //}
                        }
                        //else//固定高度
                        //{
                        //    SLTWidth = (int)(positionBase[count].PartHeight * SLTSize.Width / SLTSize.Height);
                        //    SLTHeight = positionBase[count].PartHeight;
                        //}
                        gPrint.DrawImage(_SLTQrCodeList[i].SLTBmpShadowList[j].SLTTextBmp,
                                         TextPx, TextPy,
                                         (int)(positionBase[count].PartWidth * 0.4),
                                         (int)(positionBase[count].PartHeight * 0.4));
                        gPrint.DrawImage(_SLTQrCodeList[i].SLTBmpShadowList[j].QrCodeBmp,
                                         QrCodePx, QrCodePy,
                                         (int)(positionBase[count].PartWidth * 0.4),
                                         (int)(positionBase[count].PartHeight * 0.4));
                        gPrint.DrawImage(SLTBmpTemp, SLTPx, SLTPy, SLTWidth, SLTHeight);
                        count++;
                    }
                }
            }
            panelQrCodePrint.BackgroundImage       = PrintBmp;
            panelQrCodePrint.BackgroundImageLayout = ImageLayout.Stretch;

            for (int i = 0; i < _SLTQrCodeList.Count; i++)
            {
                for (int j = 0; j < _SLTQrCodeList[i].SLTBmpShadowList.Count; j++)
                {
                    cbShadowBmp.Items.Add(_SLTQrCodeList[i].SLTBmpShadowList[j].QrCodeText);
                }
            }
        }
Esempio n. 13
0
        static private MatListEx LoadMats_V1(string strTaskFilePath, XmlNode matListNode, List <KeyValuePair <long, string> > matDxfPath, NestParamEx nestParam)
        {
            MatListEx mats = new MatListEx();

            for (int i = 0; i < matListNode.ChildNodes.Count; i++)
            {
                XmlNode matNode = matListNode.ChildNodes.Item(i);

                // whether load material from file.
                XmlNode pathNode = matNode.SelectSingleNode("MatPath");
                if (pathNode != null)
                {
                    string strMaterialFileFullPath = pathNode.InnerText;
                    if (!File.Exists(strMaterialFileFullPath))
                    {
                        // the new file path.
                        string strTaskFileFolder          = strTaskFilePath.Substring(0, strTaskFilePath.LastIndexOf("\\"));
                        string strMaterialFileName        = strMaterialFileFullPath.Substring(strMaterialFileFullPath.LastIndexOf("\\") + 1, strMaterialFileFullPath.Length - strMaterialFileFullPath.LastIndexOf("\\") - 1);
                        string strNewMaterialFileFullPath = strTaskFileFolder + "\\" + strMaterialFileName;

                        // try again.
                        if (!File.Exists(strNewMaterialFileFullPath))
                        {
                            string strMessage = "Cannot find material file: ";
                            MessageBox.Show(strMessage + strMaterialFileFullPath, "NestProfessor DEMO");
                            continue;
                        }
                        else
                        {
                            strMaterialFileFullPath = strNewMaterialFileFullPath;
                        }
                    }

                    MatEx mat = NestHelper.LoadMatFromDxfdwg(strMaterialFileFullPath, nestParam);
                    mats.AddMat(mat);
                    matDxfPath.Add(new KeyValuePair <long, string>(mat.GetID(), strMaterialFileFullPath));

                    // count.
                    mat.SetCount(Convert.ToInt32(matNode.SelectSingleNode("Count").InnerText));
                }
                else
                {
                    RectMatEx rectMat = new RectMatEx();
                    mats.AddMat(rectMat);

                    // name
                    rectMat.SetName(matNode.SelectSingleNode("Name").InnerText);

                    // width.
                    double dWidth = Convert.ToDouble(matNode.SelectSingleNode("Width").InnerText);

                    // height.
                    double dHeight = Convert.ToDouble(matNode.SelectSingleNode("Height").InnerText);

                    // the material rect.
                    Rect2DEx matRect = new Rect2DEx(0, dWidth, 0, dHeight);
                    rectMat.SetMatRect(matRect);

                    // count.
                    rectMat.SetCount(Convert.ToInt32(matNode.SelectSingleNode("Count").InnerText));
                }
            }

            return(mats);
        }
Esempio n. 14
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();
                }
            }
        }