示例#1
0
 public override void Render(Graphics g)
 {
     if (shape != null)
     {
         shape.Draw(g);
     }
 }
示例#2
0
        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Cursor = Cursors.Pen;

            curColor = GetRandomColor();
            Point curPos = e.GetPosition(canvas);

            curShape = curCreator.FactoryMethod(curColor, curPos, curPos);

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

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

                    curShape = new Ellipse(curShape);
                    curShape.Draw(canvas, shapesHistory);
                }
            }
        }
示例#4
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;
                }
            }
        }