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 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()); }
private ShapeRange CrLine(Size s, Size position, Size size) { app.ActiveLayer.CreateLineSegment(position.x, position.y, position.x, position.y - size.y).CreateSelection(); ShapeRange orSh = app.ActiveSelectionRange; double space = 0; for (int i = 0; i < numCol.Value; i++) { space += s.x; orSh.AddRange(app.ActiveSelectionRange.Duplicate(space, 0)); } space = 0; app.ActiveLayer.CreateLineSegment(position.x, position.y, position.x + size.x, position.y).CreateSelection(); orSh.AddRange(app.ActiveSelectionRange); for (int j = 0; j < numRow.Value; j++) { space += s.y; orSh.AddRange(app.ActiveSelectionRange.Duplicate(0, -space)); } orSh.Group(); return(orSh); }
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"); } }