/// <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>
 /// 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);
 }