private void plMain_MouseDoubleClick(object sender, MouseEventArgs e) { if (statusPaint.isNotDrawing == false) { if (isShape == IsShape.Polygon) { isShape = IsShape.Non; Polygon temp = lShape[lShape.Count - 1] as Polygon; temp.lPoint.RemoveAt(temp.lPoint.Count - 1); this.plMain.Refresh(); statusPaint.isStart = false; statusPaint.isDrawPolygon = false; this.Cursor = Cursors.Default; FindRegion.setPolygonPointFirstEnd(temp); } if (isShape == IsShape.Curve) { isShape = IsShape.Non; Curve temp = lShape[lShape.Count - 1] as Curve; temp.lPoint.RemoveAt(temp.lPoint.Count - 1); this.plMain.Refresh(); statusPaint.isStart = false; statusPaint.isDrawPolygon = false; this.Cursor = Cursors.Default; FindRegion.setCurvePointFirstEnd(temp); } } }
private void plMain_Paint(object sender, PaintEventArgs e) { if (statusPaint.isStart == true) { lShape.ForEach(shape => { using (GraphicsPath path = shape.graphicsPath) { shape.draw(e); if (shape.isSelected == true) { if (shape is Ellipse) { e.Graphics.DrawRectangle(framPen, shape.p1.X, shape.p1.Y, Math.Abs(shape.p2.X - shape.p1.X), Math.Abs(shape.p2.Y - shape.p1.Y)); //FindRegion.drawPointControl(e.Graphics, framBrush, shape); } else if (shape is Circle) { e.Graphics.DrawPath(framPen, FindRegion.framOfCircle(shape as Circle)); } else if (shape is Curve || shape is Polygon) { for (int i = 0; i < shape.lPoint.Count; i++) { e.Graphics.FillEllipse(framBrush, shape.lPoint[i].X - 3, shape.lPoint[i].Y - 3, 8, 8); } } else if (shape is lPen) { // Không thực hiện chọn } else if (shape is GroupShape) { using (GraphicsPath pathG = shape.graphicsPath) { e.Graphics.DrawPath(framPen, FindRegion.framOfGroup(shape as GroupShape)); } } FindRegion.drawPointControl(e.Graphics, framBrush, shape); } else { shape.draw(e); } } } ); this.plMain.Focus(); } }
public bool isPointOfControl(Point location) { List <GraphicsPath> lPath = FindRegion.listPointControl(this); if (lPath != null) { for (int i = 0; i < lPath.Count; i++) { if (lPath[i].IsVisible(location)) { return(true); } } } return(false); }
private void bntGroup_Click(object sender, EventArgs e) { if (statusPaint.isSelectedShape) { statusPaint.isStart = true;// Shape lgroup = new GroupShape(); for (int i = 0; i < lShape.Count; i++) { if (lShape[i].isSelected) { if (lShape[i] is GroupShape) { for (int index = 0; index < lShape[i].lGroup.Count; index++) { Shape temp = lShape[i].lGroup[index]; lgroup.lGroup.Add(temp); } lShape[i].lGroup.Clear(); lShape.Remove(lShape[i]); i--; } else { lgroup.lGroup.Add(lShape[i]); lShape.Remove(lShape[i]); i--; } } } if (lgroup.lGroup.Count > 0) { FindRegion.regionOfGroup(lgroup); lgroup.isSelected = true; lShape.Add(lgroup); indexShapeSelected = lShape.Count - 1; } plMain.Refresh(); } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { pressControl = e.Control; this.plMain.Focus(); if (statusPaint.isSelectedShape) { switch (e.KeyCode) { case Keys.Delete: case Keys.Back: { bntEaser.PerformClick(); break; } default: { break; } } if (e.Shift) { if (indexShapeSelected != -1 && indexShapeSelected < lShape.Count && lShape[indexShapeSelected] is GroupShape) // unGroup { if (e.Control == true && e.KeyCode == Keys.G) { for (int i = 0; i < lShape[indexShapeSelected].lGroup.Count; i++) { Shape temp = lShape[indexShapeSelected].lGroup[i]; lShape.Add(temp); } lShape[indexShapeSelected].lGroup.Clear(); lShape.Remove(lShape[indexShapeSelected]); statusPaint.isSelectedOneShape = false; statusPaint.isStart = true; plMain.Refresh(); } } } else { if (e.Control == true && e.KeyCode == Keys.G) // Group { Shape lgroup = new GroupShape(); for (int i = 0; i < lShape.Count; i++) { if (lShape[i].isSelected) { if (lShape[i] is GroupShape) { for (int index = 0; index < lShape[i].lGroup.Count; index++) { Shape temp = lShape[i].lGroup[index]; lgroup.lGroup.Add(temp); } lShape[i].lGroup.Clear(); lShape.Remove(lShape[i]); i--; } else { lgroup.lGroup.Add(lShape[i]); lShape.Remove(lShape[i]); i--; } } } if (lgroup.lGroup.Count > 0) { FindRegion.regionOfGroup(lgroup); lgroup.isSelected = true; lShape.Add(lgroup); indexShapeSelected = lShape.Count - 1; } plMain.Refresh(); } } } }