Beispiel #1
0
 private void picObrazek_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     koncowyPunkt = new CCoordinate(e.X, e.Y);
     //w zaleznosci od zaznaczonego radio buttona dodaj figurę
     if (rbLinia.Checked)
     {
         CLine linia = new CLine();
         linia.CreateFromPoints(punkt, koncowyPunkt);
         drawing.AddShape(linia);
     }
     if (rbProstokąt.Checked)
     {
         CRectangle prostokat = new CRectangle();
         prostokat.CreateFromPoints(punkt, koncowyPunkt);
         drawing.AddShape(prostokat);
         //Dodaj nowy prostokąt
     }
     if (rbOkrąg.Checked)
     {
         CCircle okrag = new CCircle();
         okrag.CreateFromPoints(punkt, koncowyPunkt);
         drawing.AddShape(okrag);
         //Dodaj nowy okrąg
     }
     drawPicture();
 }
Beispiel #2
0
        public bool Load(string filename)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode     rootNode;

            doc.Load(filename);
            rootNode = doc.ChildNodes[1];

            if (rootNode.Name != "Drawing")
            {
                return(false);
            }

            foreach (XmlNode shape in rootNode.ChildNodes)
            {
                if (shape.Name == "Line")
                {
                    CLine linia = new CLine();
                    linia.CreateFromPoints(new CCoordinate(), new CCoordinate());
                    linia.Load(shape);
                    this.m_Shapes.Add(linia);
                }
                else if (shape.Name == "Rectangle")
                {
                    CRectangle prostokat = new CRectangle();
                    prostokat.CreateFromPoints(new CCoordinate(), new CCoordinate());
                    prostokat.Load(shape);
                    this.m_Shapes.Add(prostokat);
                }
                else if (shape.Name == "Circle")
                {
                    CCircle okrag = new CCircle();
                    okrag.CreateFromPoints(new CCoordinate(), new CCoordinate());
                    okrag.Load(shape);
                    this.m_Shapes.Add(okrag);
                }
            }

            return(true);
        }