private void button1_Click(object sender, EventArgs e) { StartEvent(true); if (application.ActiveDocument.Selection().Shapes.Count == 0) { MessageBox.Show("请至少选择一个对象"); } application.ActiveDocument.Unit = cdrUnit.cdrMillimeter; ShapeRange s = application.ActiveSelectionRange; Shape rec; double Radius = 0; if (checkBox1.Checked) { double.TryParse(textBox1.Text, out Radius); } rec = application.ActiveLayer.CreateRectangle2(s.LeftX, s.BottomY, s.SizeWidth, s.SizeHeight, Radius, Radius, Radius, Radius); rec.Rectangle.CornerType = cdrCornerType.cdrCornerTypeRound; rec.Rectangle.RelativeCornerScaling = true; rec.Fill.ApplyNoFill(); s.AddToPowerClip(rec, cdrTriState.cdrFalse); EndEvent(); }
private void doPage(Page page) { page.Activate(); double w = page.SizeWidth; double h = page.SizeHeight; page.SelectShapesFromRectangle(0, 0, w, h, true).Group(); ShapeRange shapeRange = app.ActiveSelectionRange; ShapeRange shapeRangeD = shapeRange.Duplicate(); Shape rec = null, recD = null; if (comboBox1.SelectedIndex == 0) { rec = app.ActiveLayer.CreateRectangle2(0, h / 2, w, h / 2); recD = app.ActiveLayer.CreateRectangle2(0, 0, w, h / 2); } if (comboBox1.SelectedIndex == 1) { rec = app.ActiveLayer.CreateRectangle2(0, 0, w / 2, h); recD = app.ActiveLayer.CreateRectangle2(w / 2, 0, w / 2, h); } rec.Fill.ApplyNoFill(); rec.Outline.Width = 0; recD.Fill.ApplyNoFill(); recD.Outline.Width = 0; shapeRange.AddToPowerClip(rec, cdrTriState.cdrFalse); shapeRangeD.AddToPowerClip(recD, cdrTriState.cdrFalse); rec.OrderToBack(); recD.OrderToBack(); double newW, newH; if (comboBox1.SelectedIndex == 0) { newW = w; newH = h / 2; } else { newW = w / 2; newH = h; } page.SizeWidth = newW; page.SizeHeight = newH; rec.LeftX = 0; rec.BottomY = 0; Page newPage = app.ActiveDocument.AddPagesEx(1, newW, newH); newPage.Activate(); recD.MoveToLayer(app.ActiveLayer); recD.LeftX = 0; recD.BottomY = 0; newPage.MoveTo(page.Index + 1); shapeRange.Ungroup(); shapeRangeD.Ungroup(); }
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; }