private void PolygonCutterViewer_MouseDown(object sender, MouseEventArgs e) { MouseEventOld = e; int RealX = MouseEventOld.X; int RealY = MouseEventOld.Y; PolygonTriangle SelectedPolygonTriangle = PolygonCutterViewer.SelectedPolygonTriangle; switch (SelectionChoice) { #region None case SelectionChoices.None: if (PolygonCutterViewer.SelectedPolygonTriangle.SelectionType != PolygonTriangle.SelectionTypes.None) { Polygon ActivePolygon = PolygonCutterViewer.SelectedPolygonTriangle.ActivePolygon; if (e.Button == MouseButtons.Left) { SelectionChoice = SelectionChoices.Move; if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Edge) { if (Control.ModifierKeys == Keys.Shift) { SelectedPolygonTriangle.VertexIndex = (short)ActivePolygon.ArrayVertex.Length; ActivePolygon.AddVertexOnEdge(new Vector2(RealX, RealY), SelectedPolygonTriangle.EdgeIndex1, SelectedPolygonTriangle.EdgeIndex2); ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f); } else if (Control.ModifierKeys == Keys.Alt) { SelectedPolygonTriangle.VertexIndex = (short)ActivePolygon.ArrayVertex.Length; ActivePolygon.SplitEdge(new Vector2(RealX, RealY), SelectedPolygonTriangle.TriangleIndex, SelectedPolygonTriangle.EdgeIndex1, SelectedPolygonTriangle.EdgeIndex2); ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f); } } else if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Triangle) { if (Control.ModifierKeys == Keys.Shift) { ActivePolygon.SplitTriangle(new Vector2(e.X, e.Y), SelectedPolygonTriangle.TriangleIndex); ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f); } } } else if (e.Button == MouseButtons.Right) { if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Vertex && SelectedPolygonTriangle.VertexIndex >= 0) //Delete Vertex. { SelectedPolygonTriangle.ActivePolygon.RemoveVertex(SelectedPolygonTriangle.VertexIndex); } else if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Triangle && SelectedPolygonTriangle.TriangleIndex >= 0) //Delete Triangle. { } } } break; #endregion case SelectionChoices.SplitPolygon: PolygonCutterViewer.SplittingPoint1 = new Vector2(e.X, e.Y); break; } }