Exemplo n.º 1
0
        public void Load(string path)
        {
            try
            {
                string extention = Path.GetExtension(path);
                if (extention == ".bin")
                {
                    BinSerializator serializator = new BinSerializator();
                    serializator.Deserialize(figures, path);
                }
                else if (extention == ".xml")
                {
                    XmlSerializator serializator = new XmlSerializator();
                    serializator.Deserialize(figures, path);
                }
                else if (extention == ".json")
                {
                    JsonSerializator serializator = new JsonSerializator();
                    serializator.Deserialize(figures, path);
                }
                RefreshTree();

            }
            catch (Exception e)
            {
                MessageBox.Show("Возникла ошибка при загрузке: " + e.Message);
            }
        }
Exemplo n.º 2
0
        public void Save(string path)
        {
            try
            {
                string extention = Path.GetExtension(path);
                if (extention == ".bin")
                {
                    BinSerializator serializator = new BinSerializator();
                    serializator.Serialize(figures, path);
                }
                else if (extention == ".xml")
                {
                    XmlSerializator serializator = new XmlSerializator();
                    serializator.Serialize(figures, path);
                }
                else if (extention == ".json")
                {
                    JsonSerializator serializator = new JsonSerializator();
                    serializator.Serialize(figures, path);
                }

            }
            catch (Exception e)
            {
                MessageBox.Show("Возникла ошибка при сохранении: " + e.Message);
            }
        }