Esempio n. 1
0
 private void btnCrSemiLine_Click(object sender, RoutedEventArgs e)
 {
     if (checkActive())
     {
         MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     try
     {
         Size       s    = new Size(app.ActiveSelection.SizeWidth, app.ActiveSelection.SizeHeight);
         ShapeRange orSh = app.ActiveSelectionRange;
         Shape      sh   = app.ActiveLayer.CreateRectangle(orSh.LeftX, orSh.TopY, orSh.RightX, orSh.BottomY);
         sh.ConvertToCurves();
         Curve   c  = app.ActiveDocument.CreateCurve();
         SubPath ss = c.CreateSubPath(orSh.RightX, orSh.BottomY);
         ss.AppendCurveSegment(orSh.LeftX, orSh.BottomY);
         ss.AppendCurveSegment(orSh.LeftX, orSh.TopY);
         sh.Curve.CopyAssign(c);
         orSh.Delete();
         sh.CreateSelection();
         orSh = app.ActiveSelectionRange;
         double space = 0;
         for (int i = 1; i < numRow.Value; i++)
         {
             space += s.y;
             orSh.AddRange(app.ActiveSelectionRange.Duplicate(0, -space));
         }
         orSh.CreateSelection();
         space = 0;
         for (int j = 1; j < numCol.Value; j++)
         {
             space += s.x;
             orSh.AddRange(app.ActiveSelectionRange.Duplicate(space, 0));
         }
         orSh.Add(app.ActiveLayer.CreateLineSegment(orSh.PositionX, orSh.PositionY, orSh.PositionX + orSh.SizeWidth, orSh.PositionY));
         orSh.Add(app.ActiveLayer.CreateLineSegment(orSh.PositionX + orSh.SizeWidth, orSh.PositionY, orSh.PositionX + orSh.SizeWidth, orSh.PositionY - orSh.SizeHeight));
         orSh.Group();
         app.ActiveLayer.CreateRectangle(orSh.LeftX, orSh.TopY, orSh.RightX, orSh.BottomY).CreateSelection();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi");
     }
 }
Esempio n. 2
0
        //exports image

        private void ExportImage(VGCore.ShapeRange kit, VGCore.Shape background, cdrFilter imageType, int width, int height, string variant = null, string number = null, string name = null)
        {
            ShapeRange exportRange = kit;

            exportRange.Add(background);

            exportRange.CreateSelection();

            String fileName = this.appDraw.ActiveDocument.FileName;

            String filePath = this.appDraw.ActiveDocument.FilePath;

            fileName = fileName.Remove(fileName.Length - 4, 4);
            String       suffix = "";
            ExportFilter expFil;

            if (variant == null)
            {
                if (background.Name != "FMR_W.cdr")
                {
                    suffix = " -" + background.Name.ElementAt(4);
                }

                if (imageType == cdrFilter.cdrPNG)
                {
                    suffix += ".png";
                }

                expFil = this.appDraw.ActiveDocument.ExportBitmap(filePath + fileName + suffix, imageType, cdrExportRange.cdrSelection, cdrImageType.cdrRGBColorImage, width, height, 300, 300);
            }
            else
            {
                if (imageType == cdrFilter.cdrJPEG)
                {
                    suffix += ".jpg";
                }
                //fileName = variant + fileName.Substring(6);
                expFil = this.appDraw.ActiveDocument.ExportBitmap(filePath + fileName + suffix, imageType, cdrExportRange.cdrSelection, cdrImageType.cdrRGBColorImage, width, height, 300, 300,
                                                                  cdrAntiAliasingType.cdrNormalAntiAliasing, false, false, true, false, cdrCompressionType.cdrCompressionJPEG);
            }

            expFil.Finish();
        }
Esempio n. 3
0
        private Shape CreateBe()
        {
            ShapeRange orSh  = app.ActiveSelectionRange;
            Size       s     = new Size(orSh.SizeWidth, orSh.SizeHeight);
            double     space = 0;

            for (int i = 1; i < numRow.Value; i++)
            {
                space += s.y + _space;
                orSh.AddRange(app.ActiveSelectionRange.Duplicate(0, -space));
            }
            orSh.CreateSelection();
            space = 0;
            for (int j = 1; j < numCol.Value; j++)
            {
                space += s.x + _space;
                orSh.AddRange(app.ActiveSelectionRange.Duplicate(space, 0));
            }
            return(orSh.Group());
        }
Esempio n. 4
0
        private bool initFile(string type)
        {
            app.ActiveDocument.Unit = cdrUnit.cdrCentimeter;
            ShapeRange orSh = app.ActiveSelectionRange;
            Size       size = new Size(orSh.SizeWidth, orSh.SizeHeight);

            try
            {
                if (orSh.Count == 1)
                {
                    if (orSh.Shapes.First.Type == cdrShapeType.cdrBitmapShape)
                    {
                        if (type == "circle")
                        {
                            orSh.Add(app.ActiveLayer.CreateEllipse2(orSh.CenterX, orSh.CenterY, orSh.SizeWidth / 2, orSh.SizeHeight / 2));
                            orSh.CreateSelection();
                            return(true);
                        }
                        if (type == "line")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else if (orSh.Shapes.First.Type == cdrShapeType.cdrGroupShape)
                    {
                        if (type == "custom")
                        {
                            return(true);
                        }
                        else
                        {
                            orSh.Add(orSh.Shapes.First.ConvertToBitmapEx(cdrImageType.cdrCMYKColorImage, false, false, 720, cdrAntiAliasingType.cdrNormalAntiAliasing, true, false, 95));
                            orSh.SizeWidth  = size.x;
                            orSh.SizeHeight = size.y;
                            if (type == "circle")
                            {
                                orSh.Add(app.ActiveLayer.CreateEllipse2(orSh.CenterX, orSh.CenterY, orSh.SizeWidth / 2, orSh.SizeHeight / 2));
                            }
                            orSh.CreateSelection();
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (type == "custom")
                    {
                        return(true);
                    }
                    else
                    {
                        orSh.Group().CreateSelection();
                        orSh = app.ActiveSelectionRange;
                        orSh.Add(orSh.FirstShape.ConvertToBitmapEx(cdrImageType.cdrCMYKColorImage, false, false, 720, cdrAntiAliasingType.cdrNormalAntiAliasing, true, false, 95));
                        orSh.SizeWidth  = size.x;
                        orSh.SizeHeight = size.y;
                        if (type == "circle")
                        {
                            orSh.Add(app.ActiveLayer.CreateEllipse2(orSh.CenterX, orSh.CenterY, orSh.SizeWidth / 2, orSh.SizeHeight / 2));
                        }
                        orSh.CreateSelection();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi");
                return(false);
            }
        }
Esempio n. 5
0
 private void btnCreInsert_Click(object sender, RoutedEventArgs e)
 {
     if (checkActive())
     {
         MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     try
     {
         app.ActiveDocument.Unit = cdrUnit.cdrCentimeter;
         Size       s    = new Size(app.ActiveSelection.SizeWidth, app.ActiveSelection.SizeHeight);
         ShapeRange orSh = app.ActiveSelectionRange;
         if (orSh.Shapes[1].Type == cdrShapeType.cdrBitmapShape && orSh.Count == 1)
         {
             Shape ell    = app.ActiveLayer.CreateEllipse2(orSh.CenterX, orSh.CenterY, orSh.SizeWidth / 2, orSh.SizeHeight / 2);
             Shape newell = ell.Intersect(orSh.Shapes[1], true, true);
             orSh.Delete();
             orSh.Add(newell);
             orSh.Add(ell);
             orSh.CreateSelection();
         }
         double size = numInsert.Value;
         if (size == 0)
         {
             return;
         }
         double space = 0;
         spaceCal();
         ShapeRange insert = app.ActiveSelectionRange.Duplicate(0, 0);
         app.ActiveDocument.ReferencePoint = cdrReferencePoint.cdrBottomRight;
         insert.SizeHeight = size;
         insert.SizeWidth  = size;
         app.ActiveDocument.ReferencePoint = cdrReferencePoint.cdrTopLeft;
         double move = (size / 2) + (_space / 2);
         insert.Move(move, -move);
         for (int i = 1; i < numRow.Value; i++)
         {
             space += s.y + _space;
             orSh.AddRange(app.ActiveSelectionRange.Duplicate(0, -space));
         }
         orSh.CreateSelection();
         space = 0;
         for (int j = 1; j < numCol.Value; j++)
         {
             space += s.x + _space;
             orSh.AddRange(app.ActiveSelectionRange.Duplicate(space, 0));
         }
         space = 0;
         insert.CreateSelection();
         ShapeRange insertRange = insert;
         for (int ii = 1; ii < numRow.Value - 1; ii++)
         {
             space += s.y + _space;
             insertRange.AddRange(app.ActiveSelectionRange.Duplicate(0, -space));
         }
         space = 0;
         insertRange.CreateSelection();
         for (int jj = 1; jj < numCol.Value - 1; jj++)
         {
             space += s.x + _space;
             insertRange.AddRange(app.ActiveSelectionRange.Duplicate(space, 0));
         }
         orSh.AddRange(insertRange);
         orSh.Group();
         app.ActiveLayer.CreateRectangle(orSh.LeftX, orSh.TopY, orSh.RightX, orSh.BottomY).CreateSelection();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi");
     }
 }
Esempio n. 6
0
 private void btnCreaNum_Click(object sender, RoutedEventArgs e)
 {
     if (checkActive())
     {
         MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     try
     {
         if (string.IsNullOrWhiteSpace(txtTextName.Text))
         {
             txtTextName.SetResourceReference(System.Windows.Controls.Control.BorderBrushProperty, "ErrorColor");
             MessageBox.Show("Không được để trống phần số gốc đang chọn!", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         ShapeRange orSh = app.ActiveSelectionRange;
         bool       flag = false, outline = false, find = false;
         double     x = 0, y = 0;
         Color      black = new Color();
         black.CMYKAssign(0, 0, 0, 100);
         if (orSh.Shapes.Count == 1 && orSh.Shapes.First.Type == cdrShapeType.cdrGroupShape)
         {
             orSh.Ungroup();
         }
         foreach (Shape ss in orSh.Shapes)
         {
             if (ss.Type == cdrShapeType.cdrTextShape)
             {
                 if (ss.Text.Contents == txtTextName.Text)
                 {
                     x = ss.PositionX;
                     y = ss.PositionY;
                     ss.Text.AlignProperties.Alignment = cdrAlignment.cdrCenterAlignment;
                     ss.PositionX = x;
                     ss.PositionY = y;
                     flag         = true;
                     ss.Name      = "txtName";
                 }
             }
             if (!outline)
             {
                 if (ss.Type == cdrShapeType.cdrCurveShape || ss.Type == cdrShapeType.cdrEllipseShape || ss.Type == cdrShapeType.cdrPolygonShape ||
                     ss.Type == cdrShapeType.cdrRectangleShape || ss.Type == cdrShapeType.cdrPerfectShape || ss.Type == cdrShapeType.cdrCustomShape)
                 {
                     if (ss.Fill.Type == cdrFillType.cdrNoFill && ss.Outline.Type != cdrOutlineType.cdrNoOutline)
                     {
                         if (!find)
                         {
                             ss.Name = "txtOutline";
                             find    = true;
                         }
                         if (ss.Outline.Color.IsSame(black))
                         {
                             ss.Name = "txtOutline";
                             outline = true;
                         }
                     }
                 }
             }
         }
         if (!flag)
         {
             MessageBox.Show("Không tìm thấy Text có nội dung '" + txtTextName.Text + "'!", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         orSh.Group().CreateSelection();
         Size   s     = new Size(orSh.SizeWidth, orSh.SizeHeight);
         double space = 0;
         double p     = spaceCalNum();
         orSh = app.ActiveSelectionRange;
         for (int j = 1; j < numColNum.Value; j++)
         {
             space += s.x + p;
             orSh.AddRange(app.ActiveSelectionRange.Duplicate(space, 0));
         }
         orSh.CreateSelection();
         space = 0;
         for (int i = 1; i < Convert.ToInt32(lblRowNum.Content); i++)
         {
             space += s.y + p;
             orSh.AddRange(app.ActiveSelectionRange.Duplicate(0, -space));
         }
         if (Convert.ToInt32(lblTotalNum.Content) < Convert.ToInt32(lblRowNum.Content) * numColNum.Value)
         {
             ShapeRange remove = new ShapeRange();
             for (int i = Convert.ToInt32(lblTotalNum.Content) + 1; i <= Convert.ToInt32(lblRowNum.Content) * numColNum.Value; i++)
             {
                 remove.Add(orSh.Shapes[i]);
             }
             remove.Delete();
         }
         orSh.CreateSelection();
         orSh = app.ActiveSelectionRange;
         int count  = numFirstNum.Value;
         int lenght = numLastNum.Value.ToString().Length;
         foreach (Shape sp in orSh)
         {
             if (chk00.IsChecked.Value)
             {
                 if (chkAuto.IsChecked.Value)
                 {
                     sp.Shapes["txtName"].Text.Contents = txtTextFirst.Text + count.ToString().PadLeft(lenght, '0') + txtTextLast.Text;
                 }
                 else
                 {
                     string num0String = new string('0', num0.Value);
                     sp.Shapes["txtName"].Text.Contents = txtTextFirst.Text + num0String + count.ToString() + txtTextLast.Text;
                 }
             }
             else
             {
                 sp.Shapes["txtName"].Text.Contents = txtTextFirst.Text + count.ToString() + txtTextLast.Text;
             }
             count++;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi");
     }
 }