Beispiel #1
0
        private void MysticalDraw_MouseUp(object sender, MouseEventArgs e)
        {
            mouseIsDown = false;

            x1 = y1 = x2 = y2 = -1;

            if (newFigure != null && figureType != 1)
            {
                ListOfFigures.AddFigures(newFigure);
            }
        }
Beispiel #2
0
        //private void Fgineric()
        //{
        //    width = (x2 - x1);
        //    SaveX = x1;
        //    if (width < 0)
        //    {
        //        SaveX = x1;
        //        x1 = x2;
        //        //x2 = SaveX;
        //    }
        //    width = Math.Abs(width);
        //    height = (y2 - y1);
        //    SaveY = y1;
        //    if (height < 0)
        //    {
        //        SaveY = y1;
        //        y1 = y2;
        //        // y2 = SaveY;
        //    }
        //    height = Math.Abs(height);
        //}

        private void MysticalDraw_Paint(object sender, PaintEventArgs e)
        {
            if (x1 >= 0 && y1 >= 0 && x2 >= 0 && y2 >= 0)
            {
                width  = Math.Abs(x1 - x2);
                height = Math.Abs(x2 - x1);
                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;

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

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

                newFigure.Draw(graphics);
                //x1 = SaveX;
                //y1 = SaveY;
            }
        }