private void CreateSize(bool isMeter) { if (checkActive()) { MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { app.ActiveDocument.Unit = cdrUnit.cdrCentimeter; ShapeRange orSh = app.ActiveSelectionRange; Size s = new Size(orSh.SizeWidth, orSh.SizeHeight); int point = 0; int space = (int)(Math.Sqrt(s.x) / 2); if (s.x < 200) { point = (int)s.x * 2; } else { point = (int)s.x; } string width, height; if (isMeter) { width = Math.Round(s.x / 100, 2).ToString() + "m"; height = Math.Round(s.y / 100, 2).ToString() + "m"; } else { width = Math.Round(s.x, 1).ToString() + "cm"; height = Math.Round(s.y, 1).ToString() + "cm"; } Shape sizeHeight = app.ActiveLayer.CreateArtisticText(0, 0, width); sizeHeight.Text.FontProperties.Size = point; Shape sizeWidth = app.ActiveLayer.CreateArtisticText(0, 0, height); sizeWidth.Text.FontProperties.Size = point; orSh.Add(sizeHeight); orSh.AlignAndDistribute(cdrAlignDistributeH.cdrAlignDistributeHAlignCenter, cdrAlignDistributeV.cdrAlignDistributeVAlignTop, cdrAlignShapesTo.cdrAlignShapesToLastSelected, cdrDistributeArea.cdrDistributeToSelection, false); sizeHeight.Move(0, space + sizeHeight.SizeHeight); orSh.Remove(2); orSh.Add(sizeWidth); orSh.AlignAndDistribute(cdrAlignDistributeH.cdrAlignDistributeHAlignRight, cdrAlignDistributeV.cdrAlignDistributeVAlignCenter, cdrAlignShapesTo.cdrAlignShapesToLastSelected, cdrDistributeArea.cdrDistributeToSelection, false); sizeWidth.Move(space + sizeWidth.SizeWidth, 0); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi"); } }
private void DelImg() { ShapeRange orSh = app.ActiveSelectionRange; ShapeRange img = new ShapeRange(); ShapeRange unColor = new ShapeRange(); orSh.UngroupAll(); foreach (Shape sh in orSh) { if (sh.Type == cdrShapeType.cdrBitmapShape) { img.Add(sh); } else if (sh.Fill.Type == cdrFillType.cdrNoFill && sh.Outline.Type == cdrOutlineType.cdrNoOutline) { unColor.Add(sh); } } img.Delete(); if (unColor.Count > 0) { MessageBoxResult result = MessageBox.Show("Phát hiện viền bế ẩn, bạn có muốn tự động xóa?", "Cảnh báo!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { unColor.Delete(); } } }
private void btnDelOutline_Click(object sender, RoutedEventArgs e) { if (checkActive()) { MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { ShapeRange orSh = app.ActiveSelectionRange; ShapeRange img = new ShapeRange(); orSh.UngroupAll(); foreach (Shape sh in orSh) { if (sh.Name == "txtOutline") { img.Add(sh); } } img.Delete(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi"); } }
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"); } }
private ShapeRange traceBitmap(Shape s, Point p) { var sr = new ShapeRange(); sr.RemoveAll(); try { Shape dub = s.Duplicate(p.X, p.Y); dub.Bitmap.Resample(0, 0, true, 72, 72); dub.ApplyEffectBCI(-100, 100, -100); ShapeRange tr = dub.Bitmap.Trace( cdrTraceType.cdrTraceLineArt, -1, 1, cdrColorType.cdrColorCMYK, cdrPaletteID.cdrCustom, 1, true, false, true ).Finish(); Shape path = tr.UngroupAllEx().Combine(); path.Curve.Nodes.All().AutoReduce(0.01); sr.Add(path); if ((bool)cbBitmapToPowerClip.IsChecked) { Shape clip = path.Duplicate(p.X * -1, p.Y * -1); clip.OrderBackOf(s); clip.Fill.ApplyNoFill(); clip.Outline.SetNoOutline(); s.AddToPowerClip(clip); sr.Add(clip); } return(sr); } catch (Exception err) { MessageBox.Show(err.ToString(), MName, MessageBoxButton.OK, MessageBoxImage.Error); return(sr); } }
private void DrawMarks(HashSet <Mark> marks, DoMarksProperties props) { ShapeRange sr = new ShapeRange(); foreach (var item in marks) { sr.Add(DrawLine(item)); } Shape groupMarks = sr.Group(); if (props.WhiteSubMark) { Shape wsm = groupMarks.Duplicate(); wsm.Outline.SetProperties(1, corelApp.OutlineStyles[0], corelApp.CreateCMYKColor(0, 0, 0, 0)); wsm.OrderBackOne(); ShapeRange tempSr = new ShapeRange(); tempSr.Add(wsm); tempSr.Add(groupMarks); tempSr.Group(); } }
//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(); }
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); } }
private void btnCrLineColor_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 rowRange = app.ActiveSelectionRange; ShapeRange colRev = app.ActiveSelectionRange; ShapeRange rowRev = app.ActiveSelectionRange; colRev.RemoveAll(); rowRev.RemoveAll(); rowRange.RemoveAll(); Size position = new Size(app.ActiveSelectionRange.PositionX, app.ActiveSelectionRange.PositionY); Size size = new Size(s.x * numCol.Value, s.y * numRow.Value); app.ActiveSelection.Delete(); Shape shapeCol = app.ActiveLayer.CreateLineSegment(position.x, position.y, position.x, position.y - size.y); shapeCol.Outline.Color.CMYKAssign(100, 0, 100, 0); double space = 0; for (int i = 0; i < numCol.Value; i++) { space += s.x; if (i % 2 == 0 || i == numCol.Value - 1) { colRev.Add(shapeCol.Duplicate(space, 0)); } else { shapeCol.Duplicate(space, 0); } } shapeCol.OrderToFront(); colRev.Flip(cdrFlipAxes.cdrFlipVertical); space = 0; Shape shapeRow = app.ActiveLayer.CreateLineSegment(position.x, position.y, position.x + size.x, position.y); shapeRow.Outline.Color.CMYKAssign(0, 100, 100, 0); rowRev.Add(shapeRow); for (int j = 0; j < numRow.Value; j++) { space += s.y; if (j % 2 != 0 || j == numRow.Value - 1) { rowRev.Add(shapeRow.Duplicate(0, -space)); } else { rowRange.Add(shapeRow.Duplicate(0, -space)); } } shapeRow.OrderToFront(); rowRange.AddRange(rowRev); rowRange.OrderReverse(); rowRev.Flip(cdrFlipAxes.cdrFlipHorizontal); app.ActiveLayer.CreateRectangle2(position.x, position.y - size.y, size.x, size.y).CreateSelection(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi"); } }
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"); } }
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"); } }
private void createShadow(Shape s, Shape sh, int dpi, double angle, double size) { try { ShapeRange forComb = null; double tw = 0, th = 0, tx = 0, ty = 0; if ((bool)cbInnerShadow.IsChecked) { double nw = 0, nh = 0, nx = 0, ny = 0; sh.GetSize(out nw, out nh); sh.GetPositionEx(cdrReferencePoint.cdrCenter, out nx, out ny); //double dist = str2dbl(tbDistance.Text); //if (dist == 0) dist = size; //if (dist == 0) dist = 0.1; //nw = nw + (dist * 4); nh = nh + (dist * 4); nw = nw + (nw / 2); nh = nh + (nh / 2); Shape sAround = sh.Layer.CreateRectangle2(0, 0, nw, nh, 0, 0, 0, 0); sAround.SetPositionEx(cdrReferencePoint.cdrCenter, nx, ny); forComb = new ShapeRange(); forComb.Add(sh); forComb.Add(sAround); sh = forComb.Combine(); } sh.OrderBackOf(s); sh.Fill.UniformColor.CopyAssign(_shColor); sh.Outline.SetProperties(size, null, _shColor); if ((bool)cbInnerShadow.IsChecked) { sh.FillMode = cdrFillMode.cdrFillAlternate; //new fill fix } var imgType = cdrImageType.cdrCMYKColorImage; switch (_shColor.Type.ToString()) { case "cdrColorGray": imgType = cdrImageType.cdrGrayscaleImage; break; case "cdrColorLab": imgType = cdrImageType.cdrLABImage; break; case "cdrColorRGB": imgType = cdrImageType.cdrRGBColorImage; break; } sh = sh.ConvertToBitmapEx(imgType, false, true, dpi, cdrAntiAliasingType.cdrNormalAntiAliasing, true, false); double feather = str2dbl(tbFeather.Text) * 100; // TODO: Looks like ApplyBitmapEffect doesn't work correctly in 2019 sh.Bitmap.ApplyBitmapEffect(@"Gaussian Blur", @"GaussianBlurEffect GaussianBlurRadius=" + feather.ToString(CultureInfo.InvariantCulture) + ", GaussianBlurResampled=0"); int opacity = (Convert.ToInt32(tbOpacity.Text) - 100) * -1; sh.Transparency.ApplyUniformTransparency(opacity); sh.Transparency.AppliedTo = cdrTransparencyAppliedTo.cdrApplyToFillAndOutline; switch (cbMode.SelectedValue.ToString()) { case "Normal": sh.Transparency.MergeMode = cdrMergeMode.cdrMergeNormal; break; case "Multiply": sh.Transparency.MergeMode = cdrMergeMode.cdrMergeMultiply; break; case "Add": sh.Transparency.MergeMode = cdrMergeMode.cdrMergeAdd; break; //case "0": sh.Transparency.MergeMode = } sh = sh.ConvertToBitmapEx(imgType, false, true, dpi, cdrAntiAliasingType.cdrNormalAntiAliasing, true, false); sh.Properties["DS2", 1] = createPresetStr(); //add settings if ((bool)cbOverPrint.IsChecked) { sh.OverprintBitmap = true; } if ((bool)cbInnerShadow.IsChecked) { sh.AddToPowerClip(s); } else { if ((bool)cbGroup.IsChecked) { var gr = new ShapeRange(); gr.Add(s); gr.Add(sh); gr.Group(); gr = null; } } } catch (Exception err) { MessageBox.Show(err.ToString(), MName, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void DoDrawCropMarks() { double X, y, cx, cy; double sx, sy, dx, ty; double Off, l, Cu; long N; ShapeRange sr = new ShapeRange(); Shape s, s1; ShapeRange AllShapes = new ShapeRange(); this.StartEvent(); app.ActiveDocument.Unit = cdrUnit.cdrMillimeter; app.ActiveDocument.PreserveSelection = false; app.ActiveDocument.Selection().GetBoundingBox(out X, out y, out cx, out cy, false); Off = (double)nudOffset.Value; l = (double)nudLen.Value; sr.Add(DrawLine(X - Off - l, y, X - Off, y)); sr.Add(DrawLine(X - Off - l, y + cy, X - Off, y + cy)); sr.Add(DrawLine(X + cx + Off, y, X + cx + Off + l, y)); sr.Add(DrawLine(X + cx + Off, y + cy, X + cx + Off + l, y + cy)); sr.Add(DrawLine(X, y - Off - l, X, y - Off)); sr.Add(DrawLine(X + cx, y - Off - l, X + cx, y - Off)); sr.Add(DrawLine(X, y + Off + l + cy, X, y + Off + cy)); sr.Add(DrawLine(X + cx, y + Off + l + cy, X + cx, y + Off + cy)); AllShapes.Add(sr.Group()); if (chkCu.Checked) { Cu = (double)nudCu.Value; sr.RemoveAll(); sr.Add(DrawLine(X - Off - l, y + Cu, X - Off, y + Cu)); sr.Add(DrawLine(X - Off - l, y + cy - Cu, X - Off, y + cy - Cu)); sr.Add(DrawLine(X + cx + Off, y + Cu, X + cx + Off + l, y + Cu)); sr.Add(DrawLine(X + cx + Off, y + cy - Cu, X + cx + Off + l, y + cy - Cu)); sr.Add(DrawLine(X + Cu, y - Off - l, X + Cu, y - Off)); sr.Add(DrawLine(X + cx - Cu, y - Off - l, X + cx - Cu, y - Off)); sr.Add(DrawLine(X + Cu, y + Off + l + cy, X + Cu, y + Off + cy)); sr.Add(DrawLine(X + cx - Cu, y + Off + l + cy, X + cx - Cu, y + Off + cy)); AllShapes.Add(sr.Group()); } if (chkZxsp.Checked) { sr.RemoveAll(); sr.RemoveAll(); sr.Add(DrawLine(X - Off - l, y + cy / 2, X, y + cy / 2)); sr.Add(DrawLine(X + cx, y + cy / 2, X + cx + Off + l, y + cy / 2)); Outline ol = new Outline(); sr.SetOutlinePropertiesEx(-1, new OutlineStyle(), app.CreateCMYKColor(100, 100, 100, 100), null, null, cdrTriState.cdrFalse, cdrTriState.cdrFalse, cdrOutlineLineCaps.cdrOutlineButtLineCaps); //sr.SetOutlineProperties(0.2, new OutlineStyle(2)); AllShapes.Add(sr.Group()); } if (chkZxcz.Checked) { sr.RemoveAll(); sr.Add(DrawLine(X + cx / 2, y + cy, X + cx / 2, y + cy + Off + l)); sr.Add(DrawLine(X + cx / 2, y, X + cx / 2, y - Off - l)); OutlineStyle ols = new OutlineStyle(); sr.SetOutlineProperties(0.2, ols); AllShapes.Add(sr.Group()); } if (chkJdsp.Checked) { Cu = (double)nudCu.Value; sr.RemoveAll(); sr.Add(DrawLine(X - Off - l, y + cy / 2 + Cu, X - Off, y + cy / 2 + Cu)); sr.Add(DrawLine(X - Off - l, y + cy / 2 - Cu, X - Off, y + cy / 2 - Cu)); sr.Add(DrawLine(X + cx + Off, y + cy / 2 + Cu, X + cx + Off + l, y + cy / 2 + Cu)); sr.Add(DrawLine(X + cx + Off, y + cy / 2 - Cu, X + cx + Off + l, y + cy / 2 - Cu)); AllShapes.Add(sr.Group()); } if (chkJdcz.Checked) { Cu = (double)nudCu.Value; sr.RemoveAll(); sr.Add(DrawLine(X + cx / 2 + Cu, y + cy + Off, X + cx / 2 + Cu, y + cy + Off + l)); sr.Add(DrawLine(X + cx / 2 - Cu, y + cy + Off, X + cx / 2 - Cu, y + cy + Off + l)); sr.Add(DrawLine(X + cx / 2 + Cu, y - Off, X + cx / 2 + Cu, y - Off - l)); sr.Add(DrawLine(X + cx / 2 - Cu, y - Off, X + cx / 2 - Cu, y - Off - l)); AllShapes.Add(sr.Group()); } AllShapes.Group(); this.EndEvent(); }
private void decorateShape(semImage curShape) { ShapeRange SR = new ShapeRange(); ShapeRange TextShapes = new ShapeRange(); Shape Brect, Lrect, Wline, Ttext, Gr; double LmarginH, LmarginV, TmarginH, TmarginV, Theight; double Lwidth, Wwidth, Wheight, Lheight; double Left, Bottom, Width, Height; double oldCenterX, oldCenterY; double cimgratio; bool NoBar = false; Shape s = curShape.imgShape; semImageData d = curShape.imgData; double OffsetResolution = s.Bitmap.SizeWidth / s.SizeWidth; double bCut = 1d - d.CutBottom; Color White, Black; White = new Color(); Black = new Color(); Black.CMYKAssign(0, 0, 0, 100); White.CMYKAssign(0, 0, 0, 0); oldCenterX = s.CenterX; oldCenterY = s.CenterY; Left = s.LeftX; Bottom = s.BottomY; cimgratio = (s.SizeHeight * bCut) / s.SizeWidth; if (d.Width == 0d && d.Height == 0d) { Width = s.SizeWidth; Height = s.SizeHeight * bCut; } else if (d.Width == 0d) { Height = cmToUnit(d.Height); Width = Height / cimgratio; } else if (d.Height == 0d) { Width = cmToUnit(d.Width); Height = Width * cimgratio; } else { Width = cmToUnit(d.Width); Height = cmToUnit(d.Height); } double newRatio = Height / Width; if (newRatio <= cimgratio) { s.SizeWidth = Width; s.SizeHeight = (Width * cimgratio) / bCut; } else { s.SizeHeight = Height / bCut; s.SizeWidth = Height / cimgratio; } s.LeftX = Left; s.BottomY = Bottom; if (d.Mode == (int)CreateMode.Calib) { curShape.calcScale(); } else if (d.Width == 0 || d.BarText == "") { NoBar = true; } Lwidth = cmToUnit(curShape.imgData.BarLength); Lheight = ptToUnit(8); LmarginH = ptToUnit(8); LmarginV = ptToUnit(4); TmarginH = ptToUnit(4); TmarginV = ptToUnit(4); Theight = ptToUnit(d.FontSize); Wwidth = Lwidth + 2 * LmarginH; Wheight = Lheight + LmarginV + TmarginV; Brect = CDWin.ActiveLayer.CreateRectangle2(Left, Bottom, Width, Height); Brect.Outline.Color = Black; Brect.Outline.Width = ptToUnit(d.BorderWidth); s.Name = "semItemContent"; s.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignTop, Brect); s.AddToPowerClip(Brect, CorelDRAW.cdrTriState.cdrFalse); if (d.ValInBar == true) { Wheight = Theight + 2 * TmarginV; } if (!NoBar) { Lrect = CDWin.ActiveLayer.CreateRectangle2(Left + Width - Wwidth, Bottom, Wwidth, Wheight + ((d.ValInBar != true) ? Theight : 0)); Wline = CDWin.ActiveLayer.CreateLineSegment(Left + Width - LmarginH - Lwidth, Bottom + Wheight / 2, Left + Width - LmarginH, Bottom + Wheight / 2); Ttext = CDWin.ActiveLayer.CreateArtisticText(Left + Width - Wwidth / 2, Bottom + Wheight / 2 + TmarginV, d.BarText, Alignment: CorelDRAW.cdrAlignment.cdrCenterAlignment, Size: d.FontSize, Font: d.FontName); //Ttext.Text.Story.Font Ttext.Text.Story.Bold = d.TextBold == true; Lrect.Outline.Width = 0; Lrect.Fill.ApplyUniformFill(White); Wline.Outline.Width = ptToUnit(d.BarWidth); Wline.Outline.Color = Black; Wline.Outline.EndArrow = CDWin.ArrowHeads[59]; Wline.Outline.StartArrow = CDWin.ArrowHeads[59]; if (d.ValInBar == true) { Shape Trect; Trect = CDWin.ActiveLayer.CreateRectangle2(Left + Width, Bottom, 2d * TmarginH + Ttext.SizeWidth, Ttext.SizeHeight); Ttext.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignVCenter, Wline, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignBoundingBox); Ttext.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignHCenter, Wline, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignBoundingBox); Trect.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignVCenter, Ttext); Trect.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignHCenter, Ttext); Trect.Fill.ApplyUniformFill(White); Trect.Outline.Width = 0; Trect.OrderBackOf(Ttext); SR.Add(Trect); } SR.Add(Lrect); SR.Add(Wline); SR.Add(Ttext); Gr = SR.Group(); Gr.AddToPowerClip(Brect, CorelDRAW.cdrTriState.cdrFalse); } if (d.ULtext.Trim() != "") { Shape back, text; text = CDWin.ActiveLayer.CreateArtisticText(Left + TmarginH, Bottom + Height - Theight - TmarginV, d.ULtext, Alignment: CorelDRAW.cdrAlignment.cdrLeftAlignment, Size: d.FontSize, Font: d.FontName); back = CDWin.ActiveLayer.CreateRectangle2(Left, Bottom + Height - Theight - 2d * TmarginV, text.SizeWidth + 2d * TmarginH, Theight + 2 * TmarginV); back.Fill.ApplyUniformFill(White); text.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignHCenter, back); text.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignBottom, back, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignFirstBaseline); text.BottomY += TmarginV; back.Outline.Width = 0; back.OrderBackOf(text); text.Text.Story.Bold = d.TextBold == true; TextShapes.Add(text); TextShapes.Add(back); } if (d.URtext != "") { Shape back, text; text = CDWin.ActiveLayer.CreateArtisticText(Left + Width - TmarginH, Bottom + Height - Theight - TmarginV, d.URtext, Alignment: CorelDRAW.cdrAlignment.cdrRightAlignment, Size: d.FontSize, Font: d.FontName); back = CDWin.ActiveLayer.CreateRectangle2(Left + Width - text.SizeWidth - 2 * TmarginH, Bottom + Height - Theight - 2 * TmarginV, text.SizeWidth + 2 * TmarginH, Theight + 2 * TmarginV); back.Fill.ApplyUniformFill(White); text.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignHCenter, back); text.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignBottom, back, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignFirstBaseline); text.BottomY += TmarginV; back.Outline.Width = 0; back.OrderBackOf(text); text.Text.Story.Bold = d.TextBold == true; TextShapes.Add(text); TextShapes.Add(back); } if (d.BLtext != "") { Shape back, text; text = CDWin.ActiveLayer.CreateArtisticText(Left + TmarginH, Bottom + TmarginV, d.BLtext, Alignment: CorelDRAW.cdrAlignment.cdrLeftAlignment, Size: d.FontSize, Font: d.FontName); back = CDWin.ActiveLayer.CreateRectangle2(Left, Bottom, text.SizeWidth + 2 * TmarginH, Theight + 2 * TmarginV); back.Fill.ApplyUniformFill(White); text.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignHCenter, back); text.AlignToShape(CorelDRAW.cdrAlignType.cdrAlignBottom, back, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignFirstBaseline); text.BottomY += TmarginV; back.Outline.Width = 0; back.OrderBackOf(text); text.Text.Story.Bold = d.TextBold == true; TextShapes.Add(text); TextShapes.Add(back); } TextShapes.AddToPowerClip(Brect, CorelDRAW.cdrTriState.cdrFalse); Brect.Properties["semItem", 0] = true; Brect.Properties["semItem", 1] = curShape.imgData.ToString(); if (d.filename != "") Brect.Name = d.filename; Brect.CenterX = oldCenterX; Brect.CenterY = oldCenterY; CDWin.ActiveWindow.Refresh(); CDWin.Application.Refresh(); CDWin.ActiveDocument.ClearSelection(); Brect.Selected = true; }