コード例 #1
0
ファイル: Main.cs プロジェクト: AnnyShym/sketcher
        private void ShowFigures()
        {
            ListOfFigures.AddFigures(new Line(100, 200, 250, 200, pen), new Rectangle(350, 150, 200, 100, pen),
                                     new Square(650, 125, 150, pen), new Rhombus(175, 340, 240, 425, pen),
                                     new Ellipse(350, 375, 200, 100, pen), new Circle(650, 350, 150, pen));

            ListOfFigures.DrawFigures(graphics);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: AnnyShym/sketcher
        private void pbSketchingArea_Paint(object sender, PaintEventArgs e)
        {
            if (x1 >= 0 && y1 >= 0 && x2 >= 0 && y2 >= 0)
            {
                width  = Math.Abs(x1 - x2);
                height = Math.Abs(y1 - y2);

                switch (figureType)
                {
                case 0:
                    return;

                case 1:
                    newFigure = new Line(x1, y1, x2, y2, pen);

                    if (newFigure != null)
                    {
                        ListOfFigures.AddFigures(newFigure);
                    }

                    break;

                case 2:
                    newFigure = new Line(x1, y1, x2, y2, pen);
                    break;

                case 3:
                    newFigure = new Ellipse(x1, y1, width, height, pen);
                    break;

                case 4:
                    newFigure = new Circle(x1, y1, (width <= height) ? width : height, pen);
                    break;

                case 5:
                    newFigure = new Rectangle(x1, y1, width, height, pen);
                    break;

                case 6:
                    newFigure = new Square(x1, y1, (width <= height) ? width : height, pen);
                    break;

                case 7:
                    newFigure = new Rhombus(x1, y1, x2, y2, pen);
                    break;
                }

                if (figureType != 1)
                {
                    InitializeDrawingArea();
                    ListOfFigures.DrawFigures(graphics);
                }

                newFigure.Draw(graphics);
            }
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: AnnyShym/sketcher
        private void pbSketchingArea_MouseUp(object sender, MouseEventArgs e)
        {
            mouseIsDown = false;

            x1 = y1 = x2 = y2 = -1;

            if (newFigure != null && figureType != 1)
            {
                ListOfFigures.AddFigures(newFigure);
            }
        }