Ejemplo n.º 1
0
 public static void AddVisual(string path,DrawingCanvas dc)
 {
     using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
     {
        dc.AddVisual((Visual) XamlReader.Load(fs));
     }
 }
Ejemplo n.º 2
0
        public static DrawingCanvas LoadDC(string path)
        {
            DrawingCanvas dc = new DrawingCanvas();
            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
               //dc = (DrawingCanvas)XamlReader.Load(fs);
                BinaryFormatter f = new BinaryFormatter();
                dc = (DrawingCanvas)f.Deserialize(fs);

            }
            return dc;
        }
Ejemplo n.º 3
0
        public static void SaveVisual(string path, DrawingCanvas dc)
        {
            using (FileStream fs = new FileStream(path, FileMode.Create,FileAccess.ReadWrite))
            {
                //XamlWriter.Save(dc, fs);
                BinaryFormatter f = new BinaryFormatter();

                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(dc); i++)
                {
                    XamlWriter.Save(VisualTreeHelper.GetChild(dc, i), fs);
                    //f.Serialize(fs, VisualTreeHelper.GetChild(dc,i));
                }
            }
        }