Example #1
0
        public LeCanvas(Control canvas)
        {
            xmlShapes = new XMLShapes();
            Canvas    = canvas;

            myMenu = new LeMenu();
            self   = this;
        }
Example #2
0
        private void OnShapesLoaded(XMLShapes ret)
        {
            if (ShapeReloaded != null)
            {
                ShapeReloaded(this, ret);
            }

            xmlShapes = ret;
        }
Example #3
0
        void leShapeList_ShapeReloaded(object sender, XMLShapes shapes)
        {
            xmlShapes = shapes;
            parent.Invalidate();

            /*
             * xmlShapes.ShapeList.Clear();
             * System.Console.WriteLine("Shapes count= " + xmlShapes.ShapeList.Count);
             * foreach (LeSerializableShape shape in xmlShapes.ShapeList)
             * {
             *  System.Console.WriteLine("Shapes type= " + typeof(shape));
             *  if (shapes.LeShapeType == LeShapeType.Rect)
             *  {
             *      AreaShape shape0 = new AreaShape(parent, shape.Boundary);
             *      AddShape(shape0);
             *      shape0.leShape =shape;
             *      System.Console.WriteLine("Added " + shape0.leShape.ToString());
             *  }
             * }
             */
        }
Example #4
0
 public void DeSerializeXML(string fileName)
 {
     if (File.Exists(fileName))
     {
         StreamReader  sr = new StreamReader(fileName);
         XmlTextReader xr = new XmlTextReader(sr);
         XmlSerializer xs = new XmlSerializer(typeof(XMLShapes));
         object        c;
         if (xs.CanDeserialize(xr))
         {
             try
             {
                 XMLShapes ret = (XMLShapes)xs.Deserialize(xr);
                 System.Console.WriteLine("XMLShapes Created");
                 OnShapesLoaded(ret);
             }
             catch (Exception e)
             {
                 System.Console.WriteLine("Open file " + e.InnerException.Message);
             }
             finally
             {
                 /*
                  * c = xs.Deserialize(xr);
                  * Type t = this.GetType();
                  * PropertyInfo[] properties = t.GetProperties();
                  * foreach (PropertyInfo p in properties)
                  * {
                  *  p.SetValue(this, p.GetValue(c, null), null);
                  * }
                  */
             }
         }
         xr.Close();
         sr.Close();
     }
 }
Example #5
0
 public static void DeSerializeXML(string fileName)
 {
     if (File.Exists(fileName))
     {
         StreamReader  sr = new StreamReader(fileName);
         XmlTextReader xr = new XmlTextReader(sr);
         XmlSerializer xs = new XmlSerializer(typeof(XMLShapes));
         if (xs.CanDeserialize(xr))
         {
             try
             {
                 XMLShapes ret = (XMLShapes)xs.Deserialize(xr);
                 LeCanvas.self.xmlShapes = ret;
                 OnShapeReloaded();
             }
             catch (Exception e)
             {
                 System.Console.WriteLine("Open file " + e.InnerException.Message);
             }
         }
         xr.Close();
         sr.Close();
     }
 }
Example #6
0
 public BaseCanvas(Control canvas)
 {
     xmlShapes = new XMLShapes();
     Canvas    = canvas;
 }