public override void Redo(CustomStrokeCollection strokes) { if (!strokes.has(Id)) { strokes.Add(SerializationHelper.stringToStroke(JObject.Parse(SerializedStroke), strokes)); EditionSocket.AddStroke(SerializedStroke); strokes.get(Id).Select(); } }
public virtual void Refresh() { int index = -1; if (strokes.has(this.Id.ToString())) { if (this is Handleable) { ((Handleable)strokes.get(this.Id.ToString())).deleteDragHandles(); } index = strokes.IndexOf(strokes.get(this.Id.ToString())); if (strokes.has(this.Id.ToString())) { strokes.Remove(strokes.get(this.Id.ToString())); } } strokes.Insert(index, this.Clone()); }
public override void Undo(CustomStrokeCollection strokes) { if (strokes.has(Id)) { CustomStroke old = strokes.get(Id); if (old.isLocked()) { throw new Exception("Stroke is Locked"); } strokes.Remove(strokes.get(Id)); EditionSocket.RemoveStroke(Id); } }
public override void Undo(CustomStrokeCollection strokes) { if (strokes.has(Id)) { CustomStroke old = strokes.get(Id); if (old.isLocked()) { throw new Exception("Stroke is Locked"); } EditionSocket.EditStroke(SerializedStrokeBefore); CustomStroke updated = SerializationHelper.stringToStroke(JObject.Parse(SerializedStrokeBefore), strokes); bool selected = ((CustomStroke)old).isSelected(); bool editting = ((CustomStroke)old).isEditing(); ((CustomStroke)old).stopEditing(); strokes.Remove(strokes.get(Id)); int newindex = strokes.ToList().FindIndex(stroke => ((CustomStroke)stroke).Index > updated.Index); try { strokes.Insert(newindex, updated); } catch { strokes.Add(updated); } if (selected) { strokes.get(updated.Id.ToString()).Select(); } if (editting) { strokes.get(updated.Id.ToString()).startEditing(); } if (updated is Anchorable) { strokes.ToList().FindAll(stroke => stroke is BaseLine).ForEach(stroke => ((BaseLine)stroke).anchorableMoved((Anchorable)updated)); } } }