private void forEachShapeOnShapeRange(actionMethod method, corel.ShapeRange sr) { corel.Shape s; while (sr.Count > 0) { s = sr[1]; sr.Remove(1); // работа в группе if (s.Type == Corel.Interop.VGCore.cdrShapeType.cdrGroupShape) { groupShape(method, s); } // работа в PowerClip if (s.PowerClip != null) { powerClipShape(method, s); } // текст обрабатывается своими методами if (s.Type == corel.cdrShapeType.cdrTextShape) { textShape(method, s); } else { method(s); } } }
private void btn_bulkEdit_Click(object sender, RoutedEventArgs e) { Corel.Interop.VGCore.ShapeRange sel = corelApp.ActiveDocument.SelectionRange; LatexEquation eq = ShapeTags.getLatexEquation(sel.FirstShape); if (eq != null) { m_sdialog.init(eq, "Bulk-edit style"); m_sdialog.ShowDialog(); if (m_sdialog.Result == System.Windows.Forms.DialogResult.OK) { foreach (Corel.Interop.VGCore.Shape s in sel) { eq = ShapeTags.getLatexEquation(s); m_sdialog.LatexEquation = eq; if (m_sdialog.generateEquation()) { Corel.Interop.VGCore.Shape latexObj = m_sdialog.LatexEquation.m_shape; if (latexObj != null) { latexObj.TransformationMatrix = s.TransformationMatrix; s.Delete(); } } } } } }
private void RemapInPowerClipShape(corel.Shape s) { corel.ShapeRange sr = s.PowerClip.Shapes.All(); s.PowerClip.EnterEditMode(); RemapInShapeRange(sr); s.PowerClip.LeaveEditMode(); }
private void powerClipShape(actionMethod method, corel.Shape s) { corel.ShapeRange sr = s.PowerClip.Shapes.All(); s.PowerClip.EnterEditMode(); forEachShapeOnShapeRange(method, sr); s.PowerClip.LeaveEditMode(); }
private void ReadText(corel.Application app) { try { corel.Documents docs = app.Documents; foreach (corel.Document d in docs) { txtBox_Info.Text += d.Name + "\r\n"; corel.Pages pgs = d.Pages; foreach (corel.Page p in pgs) { txtBox_Info.Text += p.Name + "\r\n"; corel.Layers lyrs = p.Layers; foreach (corel.Layer l in lyrs) { Corel.Interop.VGCore.ShapeRange sr = l.Shapes.FindShapes(); txtBox_Info.Text += l.Name + " *** Number of objects : " + sr.Count + "\r\n"; for (int i = 1; i <= sr.Count; i++) { if (sr[i] != null && sr[i].Type == corel.cdrShapeType.cdrTextShape) { txtBox_Info.Text += sr[i].Text.Story.Text + "\r\n"; } } } txtBox_Info.Text += "*****-----*****\r\n"; } } } catch (Exception ex) { txtBox_Info.Text = ex.Message; } }
private void btn_selectAll_Click(object sender, RoutedEventArgs e) { corelApp.ActiveDocument.ClearSelection(); corel.ShapeRange sr = corelApp.CreateShapeRange(); sr = corelApp.ActivePage.Shapes.FindShapes(Name: "teximport.pdf"); sr.AddToSelection(); sr = corelApp.ActivePage.Shapes.FindShapes(Name: "LaTeX"); sr.AddToSelection(); }
/// <summary> /// перекрасить массив шейпов /// </summary> /// <param name="checkColor">метод проверки</param> /// <param name="convertColor">метод конвертации</param> /// <param name="shapeRange">массив шейпов</param> /// <param name="fill">применить к заливке</param> /// <param name="outline">применить к обводке</param> /// <param name="textAsStory">текст посимвольно</param> public RemapShapeRange(ICheckColor checkColor, IConvertColor convertColor, corel.ShapeRange shapeRange, bool fill, bool outline, bool textAsStory) { this.checkColor = checkColor; this.convertColor = convertColor; this.shapeRange = shapeRange; this.applyFill = fill; this.applyOutline = outline; this.textAsStory = textAsStory; }
private void Apply(corel.ShapeRange sr, ICheckColor check, IConvertColor convert) { bool fill = chbApplyFill.IsChecked ?? false; bool outline = chbApplyOutline.IsChecked ?? false; bool textAs = rbTextAsStory.IsChecked ?? false; if (sr != null) { if (sr.Count > 0) { RemapShapeRange remapShapeRange = new RemapShapeRange(check, convert, sr, fill, outline, textAs); remapShapeRange.Start(); } } }
private void btn_editLatex_Click(object sender, RoutedEventArgs e) { Corel.Interop.VGCore.ShapeRange sel = corelApp.ActiveDocument.SelectionRange; bool found = false; foreach (Corel.Interop.VGCore.Shape s in sel) { if (editLatexObject(s)) { found = true; } } if (!found) { createLatexObject(null, "Create latex object"); } }
private void MakeToShapeRange(corel.ShapeRange sr, Action <corel.Shape> action) { foreach (corel.Shape shape in sr) { if (shape.Type == corel.cdrShapeType.cdrGroupShape) { MakeToShapeRange(shape.Shapes.All(), action); } if (shape.PowerClip != null) { MakeToShapeRange(shape.PowerClip.Shapes.All(), action); } action(shape); } }
private void LinkText(corel.Application app) { try { corel.ShapeRange sr = app.ActiveSelectionRange; for (int i = 1; i <= sr.Count; i++) { if (sr[i] != null && sr[i].Type != corel.cdrShapeType.cdrTextShape) { txtBox_Info.Text = "Add Text"; corel.Layer s_l = sr[i].Layer; corel.Shape s1 = s_l.CreateArtisticText(5, 6, "Text_123"); s1.Fill.UniformColor.CMYKAssign(0, 0, 0, 100); s1.Outline.SetNoOutline(); corel.Shape s2 = s_l.CreateConnectorEx(corel.cdrConnectorType.cdrConnectorStraight, sr[i].SnapPoints.Object(corel.cdrObjectSnapPointType.cdrObjectPointRight), app.ActiveDocument.CreateFreeSnapPoint(6, 6)); s2.Connector.EndPoint = s1.SnapPoints.Object(corel.cdrObjectSnapPointType.cdrObjectPointTop); } } //corel.Shapes sh = app.ActiveDocument.ActiveLayer.Shapes; //for (int i = 1; i <= sh.Count; i++) //{ // corel.Shape s = sh[i]; // if (s.Selected && s.Type != corel.cdrShapeType.cdrTextShape) // { // corel.Shape s1 = app.ActiveLayer.CreateArtisticText(5, 6, "Text_123"); // s1.Fill.UniformColor.CMYKAssign(0, 0, 0, 100); // s1.Outline.SetNoOutline(); // corel.Shape s2 = app.ActiveLayer.CreateConnectorEx(corel.cdrConnectorType.cdrConnectorStraight, s.SnapPoints.Object(corel.cdrObjectSnapPointType.cdrObjectPointRight), app.ActiveDocument.CreateFreeSnapPoint(6, 6)); // s2.Connector.EndPoint = s1.SnapPoints.Object(corel.cdrObjectSnapPointType.cdrObjectPointTop); // } //} } catch (Exception ex) { txtBox_Info.Text = ex.Message; } finally { } }
private void MakeNewPlate(ShapeRange sr_origin, string[] data, double x, double y) { string key = data[2]; //clone to the grid corel.Shape sh_plate = sr_origin.Shapes.FindShape("plate"); corel.Shape sh_pn_orign = sr_origin.Shapes.FindShape("H_第1列"); corel.ShapeRange sr_new = sr_origin.Clone(); sr_new.SetPosition(x, y); //replace things corel.Shape sh_pn = sr_new.Shapes.FindShape("H_第1列"); corel.Text platenum_1 = sr_new.Shapes.FindShape("H_第2列").Text; corel.Shape sh_qrLB = sr_new.Shapes.FindShape("qrLB"); corel.Shape sh_qrRT = sr_new.Shapes.FindShape("qrRT"); sh_pn.Text.Story.Text = data[0]; sh_pn.SetSize(sh_pn_orign.SizeWidth, sh_pn_orign.SizeHeight);//resize the font if (dict_qrPath.ContainsKey(key)) { myQrcode("a", sh_qrLB, dict_qrPath[key][0]); myQrcode("a", sh_qrRT, dict_qrPath[key][1]); } if (!data[1].Contains("号")) { platenum_1.Story.Text = data[1]; } else { string[] num = data[1].Split('号'); corel.Shape platenum_2 = sr_new.Shapes.FindShape("H_第3列"); platenum_1.Story.Text = num[0]; //platenum_1.SetSize(sh_num1_orign.SizeWidth, sh_num1_orign.SizeHeight);//resize the font platenum_2.Text.Story.Text = "号" + num[1]; //platenum_2.SetSize(sh_num2_orign.SizeWidth, sh_num2_orign.SizeHeight);//resize the font } }
private void btn_editLatex_Click(object sender, RoutedEventArgs e) { try { Corel.Interop.VGCore.ShapeRange sel = corelApp.ActiveDocument.SelectionRange; bool found = false; foreach (Corel.Interop.VGCore.Shape s in sel) { if (editLatexObject(s)) { found = true; } } if (!found) { createLatexObject(null, "Create latex object"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Latex4Corel"); //throw; } }
private void CreateVetorLocal2() { CreateBitmapLocal(); Shapes shapes = this.app.ActiveLayer.Shapes; foreach (Corel.Interop.VGCore.Shape shape in shapes) { if (shape.Name == "temp_qrcode.jpg") { double x, y, w, h; shape.GetPosition(out x, out y); shape.GetSize(out w, out h); TraceSettings traceSettings = shape.Bitmap.Trace(cdrTraceType.cdrTraceLineDrawing); traceSettings.DetailLevelPercent = 100; traceSettings.BackgroundRemovalMode = cdrTraceBackgroundMode.cdrTraceBackgroundAutomatic; traceSettings.CornerSmoothness = 0; traceSettings.DeleteOriginalObject = true; traceSettings.RemoveBackground = true; traceSettings.RemoveEntireBackColor = true; traceSettings.RemoveOverlap = true; traceSettings.SetColorCount(2); traceSettings.SetColorMode(cdrColorType.cdrColorGray, cdrPaletteID.cdrCustom); traceSettings.Smoothing = 0; traceSettings.TraceType = cdrTraceType.cdrTraceClipart; traceSettings.Finish(); Corel.Interop.VGCore.ShapeRange sr = new Corel.Interop.VGCore.ShapeRange(); foreach (Corel.Interop.VGCore.Shape s in this.app.ActiveLayer.Shapes) { sr.Add(s); } sr.CreateSelection(); Corel.Interop.VGCore.Shape qrShape = this.app.ActiveSelection; Corel.Interop.VGCore.Shape cod = this.app.ActiveSelection.Weld(qrShape); cod.Name = "Cod"; Corel.Interop.VGCore.Color cWhite = new Corel.Interop.VGCore.Color(); cWhite.CMYKAssign(0, 0, 0, 0); Corel.Interop.VGCore.Shape border = this.app.ActiveLayer.CreateRectangle2(x, y - h, w, h); border.Fill.ApplyUniformFill(cWhite); border.Outline.Width = 0; border.OrderToBack(); border.Name = "Borda"; int strSize = 221; cod.AddToSelection(); border.AddToSelection(); Corel.Interop.VGCore.Shape g = this.app.ActiveSelection.Group(); this.app.ActiveDocument.Unit = this.app.ActiveDocument.Rulers.HUnits; if (Int32.TryParse(txt_size.Text, out strSize)) { g.SetSize(strSize, strSize); } else { System.Windows.MessageBox.Show("Formato de tamanho inválido", "Aviso para Você!"); } } } this.app.ActiveLayer.Name = "QrCode Vetor"; }
private void RemapInShapeRange(corel.ShapeRange sr) { foreach (corel.Shape s in sr) { if (s.Type == cdrShapeType.cdrGroupShape) { RemapInGroupShape(s); } if (s.PowerClip != null) { RemapInPowerClipShape(s); } switch (s.Type) { case cdrShapeType.cdr3DObjectShape: break; case cdrShapeType.cdrArtisticMediaGroupShape: break; case cdrShapeType.cdrBevelGroupShape: break; case cdrShapeType.cdrBitmapShape: RemapCdrBitmapShape(s); break; case cdrShapeType.cdrBlendGroupShape: break; case cdrShapeType.cdrConnectorShape: break; case cdrShapeType.cdrContourGroupShape: break; case cdrShapeType.cdrCurveShape: RemapCdrSimpleShape(s); break; case cdrShapeType.cdrCustomEffectGroupShape: break; case cdrShapeType.cdrCustomShape: //table break; case cdrShapeType.cdrDropShadowGroupShape: break; case cdrShapeType.cdrEPSShape: break; case cdrShapeType.cdrEllipseShape: RemapCdrSimpleShape(s); break; case cdrShapeType.cdrExtrudeGroupShape: break; //case cdrShapeType.cdrGroupShape: // break; case cdrShapeType.cdrGuidelineShape: break; case cdrShapeType.cdrHTMLActiveObjectShape: break; case cdrShapeType.cdrHTMLFormObjectShape: break; case cdrShapeType.cdrLinearDimensionShape: break; case cdrShapeType.cdrMeshFillShape: break; case cdrShapeType.cdrNoShape: break; case cdrShapeType.cdrOLEObjectShape: break; case cdrShapeType.cdrPerfectShape: RemapCdrSimpleShape(s); break; case cdrShapeType.cdrPolygonShape: RemapCdrSimpleShape(s); break; case cdrShapeType.cdrRectangleShape: RemapCdrSimpleShape(s); break; case cdrShapeType.cdrSelectionShape: break; case cdrShapeType.cdrSymbolShape: break; case cdrShapeType.cdrTextShape: RemapCdrTextShape(s); break; default: break; } } }