public static void SaveState() { firstSaveState = true; ringBuffer.Push(SerializerFigure.SerializeAllFigures(ref _figureArray)); _form.IsChanged = !ringBuffer.IsSaved; _btnRedo.Enabled = false; _btnUndo.Enabled = true; }
public static void Copy(List <Figure> selectedFigureArray) { if (selectedFigureArray == null) { return; } Clipboard.SetText(MainDrawForm.Signature + SerializerFigure.SerializeAllFigures(ref selectedFigureArray)); }
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; }
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)); }
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(); }
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); } } }
static void Cut(List <Figure> selectedFigureArray, ref List <Figure> figureArray) { Clipboard.SetText(MainDrawForm.Signature + SerializerFigure.SerializeAllFigures(ref selectedFigureArray)); }