예제 #1
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            isMousePressed = false;
            IShape shape;

            switch (curTool)
            {
            case Tool.Pen:
                break;

            case Tool.Line:
                shape = new MyLine(prevPoint, curPoint, pen);
                shapes.Add(shape);
                break;

            case Tool.Circle:
                shape = new MyCircle(prevPoint, curPoint, pen);
                shapes.Add(shape);
                break;

            case Tool.Rectangle:
                shape = new MyRectangle(prevPoint, curPoint, pen);
                shapes.Add(shape);
                break;

            case Tool.Triangle:
                shape = new MyTriangle(prevPoint, curPoint, pen);
                shapes.Add(shape);
                break;

            case Tool.Select:
                ShapesApplyNewPosition();
                break;

            default:
                break;
            }
            prevPoint = e.Location;
        }
예제 #2
0
        } // Save

        public void Load(string fileName)
        {
            Clear();
            XmlReader reader;

            reader = XmlReader.Create(fileName);

            while (reader.Read())
            {
                if (reader.HasAttributes)
                {
                    if (reader.Name == "Figures")
                    {
                        reader.MoveToFirstAttribute();
                        borderWidth = int.Parse(reader.Value);

                        reader.MoveToNextAttribute();
                        borderHeight = int.Parse(reader.Value);
                    } // if
                    else if (reader.Name == "MyPencil")
                    {
                        Add(MyPencil.ReadData(reader));
                    }
                    else if (reader.Name == "MyRectangle")
                    {
                        Add(MyRectangle.ReadData(reader));
                    }
                    else if (reader.Name == "MyCircle")
                    {
                        Add(MyCircle.ReadData(reader));
                    }
                    else if (reader.Name == "MyTriangle")
                    {
                        Add(MyTriangle.ReadData(reader));
                    }
                } // if
            }     // while
            reader.Close();
        }         // Load