コード例 #1
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            // Рисование равносторонних фигур
            if (e.Key == Key.LeftShift && Mouse.LeftButton == MouseButtonState.Pressed)
            {
                if ((bool)rectangle.IsChecked)
                {
                    curShape.Remove(canvas, shapesHistory);

                    curShape = new Square(curShape);
                    curShape.Draw(canvas, shapesHistory);
                }
                if ((bool)ellipse.IsChecked)
                {
                    curShape.Remove(canvas, shapesHistory);

                    curShape = new Circle(curShape);
                    curShape.Draw(canvas, shapesHistory);
                }
            }

            // Удаление последней фигуры
            if (e.Key == Key.Z && Keyboard.IsKeyDown(Key.LeftCtrl) && canvas.Children.Count != 0)
            {
                shapesHistory.Last().Remove(canvas, shapesHistory);

                if (shapesHistory.Count != 0)
                {
                    curShape = shapesHistory.Last();
                }
                else
                {
                    curShape = null;
                }
            }
        }