示例#1
0
 public static void SaveState()
 {
     firstSaveState = true;
     ringBuffer.Push(SerializerFigure.SerializeAllFigures(ref _figureArray));
     _form.IsChanged  = !ringBuffer.IsSaved;
     _btnRedo.Enabled = false;
     _btnUndo.Enabled = true;
 }
示例#2
0
 public static void Copy(List <Figure> selectedFigureArray)
 {
     if (selectedFigureArray == null)
     {
         return;
     }
     Clipboard.SetText(MainDrawForm.Signature + SerializerFigure.SerializeAllFigures(ref selectedFigureArray));
 }
示例#3
0
 public static void Reset()
 {
     firstSaveState   = false;
     _btnRedo.Enabled = false;
     _btnUndo.Enabled = false;
     ringBuffer       = new RingBuffer <string>(bufferSize);
     ringBuffer.Push(SerializerFigure.SerializeAllFigures(ref _figureArray));
     ringBuffer.IsSaved = true;
     _form.IsChanged    = !ringBuffer.IsSaved;
 }
示例#4
0
 public static void Init(Button btnUndo, Button btnRedo, PaintBox paintBox, ref List <Figure> figureArray, MainDrawForm form)
 {
     _btnUndo        = btnUndo;
     _btnUndo.Click += Undo;
     _btnRedo        = btnRedo;
     _btnRedo.Click += Redo;
     _paintBox       = paintBox;
     _figureArray    = figureArray;
     _form           = form;
     ringBuffer.Push(SerializerFigure.SerializeAllFigures(ref _figureArray));
 }
示例#5
0
 public static void Redo(object sender, EventArgs e)
 {
     if (!firstSaveState)
     {
         return;
     }
     _btnUndo.Enabled = true;
     _btnRedo.Enabled = ringBuffer.Up();;
     for (int i = _figureArray.Count - 1; i >= 0; i--)
     {
         _figureArray.Remove(_figureArray[i]);
     }
     _figureArray.AddRange(SerializerFigure.Parse(ringBuffer.Value));
     _form.IsChanged = !ringBuffer.IsSaved;
     _paintBox.Invalidate();
 }
示例#6
0
 public static void Paste(ref List <Figure> figureArray)
 {
     if (Clipboard.ContainsText())
     {
         string str = Clipboard.GetText();
         if (str.Substring(0, MainDrawForm.Signature.Length) == MainDrawForm.Signature)
         {
             str = str.Remove(0, MainDrawForm.Signature.Length);
             Figure[] figures = SerializerFigure.Parse(str);
             foreach (var figure in figures)
             {
                 figure.Move(PointW.ScrnToPointW(new Point(Offeset, Offeset)));
             }
             figureArray.AddRange(figures);
         }
     }
 }
示例#7
0
 static void Cut(List <Figure> selectedFigureArray, ref List <Figure> figureArray)
 {
     Clipboard.SetText(MainDrawForm.Signature + SerializerFigure.SerializeAllFigures(ref selectedFigureArray));
 }