//add template private void button5_Click(object sender, EventArgs e) { corel.Shapes shapes = corelApp.ActiveSelection.Shapes; //get selected shapes corel.ShapeRange shapeRange = shapes.All(); // used for clone templates.Add(shapeRange); lb_tcount.Text = templates.Count.ToString(); }
//generate a lot of plates private void button1_Click(object sender, EventArgs e) { myOptimize(true, true); corel.Shapes shapes = corelApp.ActiveSelection.Shapes; //get selected shapes corel.Shape plate = shapes.FindShape("plate"); corel.ShapeRange shapeRange = shapes.All(); // used for clone MessageBox.Show(shapeRange.Count.ToString()); double dx = plate.RightX - plate.LeftX; double dy = plate.TopY - plate.BottomY; int count = 1; for (int x = 1; x < 3; x++) { for (int y = 1; y < 3; y++) { string[] data = (string[])datas[count]; corel.ShapeRange sr = shapeRange.Clone(x * dx, y * dy); corel.Shapes shs = sr.Shapes; corel.Text sh_platename = shs.FindShape("H_第1列").Text; corel.Text sh_platenum = shs.FindShape("H_第2列").Text; if (sh_platename.IsArtisticText) { //sh_platename.Replace("大氹村前街十二巷", "我卢本伟没有开挂", false, ReplaceAll: true); sh_platename.Story.Text = data[0]; } if (sh_platenum.IsArtisticText) { //String num = count.ToString(); //sh_platenum.Replace("1", num, false, ReplaceAll: true); sh_platenum.Story.Text = data[1]; } count++; } } myOptimize(true, false); }