/// <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> /// Makes convex hull 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 makeConvexHullButton_Click(object sender, EventArgs e) { PolygonEditState polygonState = ShapesScreen.State as PolygonEditState; if (polygonState != null) { polygonState.MakeConvexHull(); } ShapesScreen.Invalidate(); }
/// <summary> /// Handles the KeyDown event of the shapesList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param> private void shapesList_KeyDown(object sender, KeyEventArgs e) { // delete selected shape if (e.KeyCode == Keys.Delete && shapesList.SelectedIndex != -1) { ShapeState shapeToRemove = shapesList.SelectedItem as ShapeState; if (shapeToRemove != null) { // remove shape ShapesScreen.RemoveShape(shapeToRemove); shapesList.Items.RemoveAt(shapesList.SelectedIndex); // select last shape if any if (shapesList.SelectedIndex == -1 && shapesList.Items.Count != 0) { shapesList.SelectedIndex = shapesList.Items.Count - 1; } } } }
/// <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; } } }
/// <summary> /// Removes the specified shape. /// </summary> /// <param name="shape">Shape as <see cref="ShapeState"/> to remove.</param> private void RemoveShape(ShapeState shape) { shapesList.Items.Remove(shape); ShapesScreen.RemoveShape(shape); }
/// <summary> /// Changes visibility of the origin. (Changed value of checkbox: Show Origin.) /// </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 showOriginButton_CheckedChanged(object sender, EventArgs e) { ShapesScreen.ShowOrigin = showOrigin.Checked; ShapesScreen.Invalidate(); Properties.Settings.Default.TextureEditor_ShowOrigin = showOrigin.Checked; }
/// <summary> /// Changes visibility of the convex decomposition. (Changed value of checkbox: Show Convex Decomposition.) /// </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 showConvexDecomposition_CheckedChanged(object sender, EventArgs e) { PolygonEditState.ShowConvexDecomposition = showConvexDecomposition.Checked; ShapesScreen.Invalidate(); Properties.Settings.Default.TextureEditor_ShowConvexDecomposition = showConvexDecomposition.Checked; }