Example #1
0
 public void AddAll(ShapeAccumulator accum)
 {
     if (accum == null)
     {
         throw new ArgumentException("В функцию передана пустая фигура");
     }
     for (int i = 0; i < accum.figures.Count; i++)
     {
         Add(accum.figures[i]);
     }
 }
Example #2
0
        public static void Save(ShapeAccumulator figures)
        {
            if (figures.figures.Count == 0)
            {
                return;
            }
            ShapeAccumulator shapeAccumulator = new ShapeAccumulator();

            Load(figures);
            shapeAccumulator.AddAll(figures);
            using (FileStream fs = new FileStream(figures.path + $"/figures.shape", FileMode.OpenOrCreate))
            {
                figures.formatter.Serialize(fs, shapeAccumulator.figures);
            }
        }
Example #3
0
 public static void Load(ShapeAccumulator figures)
 {
     string[] fileEntries = Directory.GetFiles(figures.path, "*.shape");
     foreach (string item in fileEntries)
     {
         using (FileStream fs = new FileStream(item, FileMode.OpenOrCreate))
         {
             List <IFigure> fig = (List <IFigure>)figures.formatter.Deserialize(fs);
             if (fig.Count == 0)
             {
                 return;
             }
             figures.AddAll(fig);
         }
     }
 }
Example #4
0
 public static void Delete_Save(ShapeAccumulator figures) => File.Delete(figures.path + $"/figures.shape");