/// <summary> /// Makes convex decomposition of the selected polygon if any. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void makeConvexDecompositionButton_Click(object sender, EventArgs e) { PolygonEditState polygonState = ShapesScreen.State as PolygonEditState; if (polygonState != null) { List <Polygon> newPolygons = polygonState.MakeConvexDecomposition(); if (newPolygons != null && newPolygons.Count > 0) { // remove actual polygon state RemoveShape(polygonState); // add new polygons foreach (Polygon polygon in newPolygons) { shapesList.Items.Add(ShapesScreen.AddShape(polygon)); } // select last added shape shapesList.SelectedIndex = shapesList.Items.Count - 1; } } ShapesScreen.Invalidate(); }
/// <summary> /// Creates new shape based on chosen type from checkbox. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void addShapeButton_Click(object sender, EventArgs e) { // find chosen shape foreach (Shape.ShapeType shape in Enum.GetValues(typeof(Shape.ShapeType))) { if (selectShapeBox.Text == shape.ToString()) { // add new shape ShapeState newItem = ShapesScreen.AddShape(shape); if (newItem != null) { shapesList.Items.Add(newItem); shapesList.SelectedIndex = shapesList.Items.Count - 1; } break; } } }