internal void anchorableDoneMoving(Anchorable anchorable) { if (((CustomStroke)anchorable).Id.ToString() == this.FirstAnchorId || ((CustomStroke)anchorable).Id.ToString() == this.SecondAncorId) { EditionSocket.EditStroke(this.toJson()); } }
private void DupliquerSelection(object sender, RoutedEventArgs e) { VueModele vueModele = ((VueModele)this.DataContext); List <CustomStroke> selectedStrokes = vueModele.Traits.Where(stroke => ((CustomStroke)stroke).isSelected()).Cast <CustomStroke>().ToList(); //If no stroke is selected ==> Cut/Paste operation if (selectedStrokes.Count == 0) { vueModele.Traits.Add(ClipBoard); ClipBoard.ToList().ForEach(stroke => { EditionSocket.AddStroke(((Savable)stroke).toJson()); Editeur.instance.Do(new NewStroke(((CustomStroke)stroke).Id.ToString(), ((Savable)stroke).toJson())); }); ClipBoard.Clear(); } else { EditionSocket.UnlockStrokes(); vueModele.editeur.EditingStroke = null; selectedStrokes.ForEach(stroke => { CustomStroke duplicate = stroke.Duplicate(); ((VueModele)this.DataContext).Traits.Add(duplicate); duplicate.Select(); EditionSocket.AddStroke(((Savable)duplicate).toJson()); Editeur.instance.Do(new NewStroke(((CustomStroke)duplicate).Id.ToString(), ((Savable)duplicate).toJson())); }); } }
public void SetText(string text) { string before = this.toJson(); this.Name = text; this.Refresh(); EditionSocket.EditStroke(this.toJson()); Editeur.instance.Do(new EditStroke(this.Id.ToString(), before, this.toJson())); }
internal void setSecondRelation(Relation value) { string before = this.toJson(); this.SecondRelation = value; this.Refresh(); EditionSocket.EditStroke(this.toJson()); Editeur.instance.Do(new EditStroke(this.Id.ToString(), before, this.toJson())); }
internal void setFirstLabel(string value) { string before = this.toJson(); this.FirstText = value; this.Refresh(); EditionSocket.EditStroke(this.toJson()); Editeur.instance.Do(new EditStroke(this.Id.ToString(), before, this.toJson())); }
public void SetText(string text) { string before = this.toJson(); this.textContent = text.Split(new[] { "\r\n" }, StringSplitOptions.None).ToList(); this.Refresh(); EditionSocket.EditStroke(this.toJson()); Editeur.instance.Do(new EditStroke(this.Id.ToString(), before, this.toJson())); }
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 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 MouseUp(Point point, CustomStrokeCollection strokes) { if (ActiveStroke != null) { strokes.Remove(ActiveStroke); var clone = ActiveStroke.Clone(); strokes.Add(clone); ((CustomStroke)clone).Select(); EditionSocket.AddStroke(((Savable)clone).toJson()); Editeur.instance.Do(new NewStroke(((CustomStroke)clone).Id.ToString(), ((Savable)clone).toJson())); } IsDrawing = false; this.FirstAnchorPointId = null; }
private void Canvas_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e) { VueModele vueModele = ((VueModele)this.DataContext); //Empiler la modification if (e.Stroke is Savable && !((CustomStroke)e.Stroke).isLocked()) { CustomStroke erasedStroke = (CustomStroke)e.Stroke; vueModele.editeur.Do(new DeleteStroke(erasedStroke.Id.ToString(), ((Savable)erasedStroke).toJson())); EditionSocket.RemoveStroke(erasedStroke.Id.ToString()); } else if (((CustomStroke)e.Stroke).isLocked()) { e.Cancel = true; } }
public override void MouseUp(Point point, CustomStrokeCollection strokes) { if (ActiveStroke != null) { strokes.Remove(ActiveStroke); var clone = ActiveStroke.Clone(); if (clone is TextStroke) { ((TextStroke)clone).showBorder = false; } strokes.Add(clone); ((CustomStroke)clone).Select(); EditionSocket.AddStroke(((Savable)clone).toJson()); Editeur.instance.Do(new NewStroke(((CustomStroke)clone).Id.ToString(), ((Savable)clone).toJson())); } IsDrawing = false; }
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)); } } }
public void HandleStoped(Guid id) { int movedIndex = this.HandlePoints.FindIndex(i => i.ToString() == id.ToString()); if (!(movedIndex == 0 || movedIndex == this.HandlePoints.Count - 1)) { if (10 > this.FindDistanceToSegment(this.StylusPoints[movedIndex].ToPoint(), this.StylusPoints[movedIndex - 1].ToPoint(), this.StylusPoints[movedIndex + 1].ToPoint())) { this.deleteDragHandles(); this.HandlePoints.RemoveAt(movedIndex); this.StylusPoints.RemoveAt(movedIndex); this.Refresh(); } } EditionSocket.EditStroke(this.toJson()); Editeur.instance.Do(new EditStroke(this.Id.ToString(), beforeMove, this.toJson())); this.beforeMove = null; }
private void SupprimerSelection(object sender, RoutedEventArgs e) { VueModele vueModele = ((VueModele)this.DataContext); vueModele.editeur.EditingStroke = null; var selectedStrokes = vueModele.Traits.Where(stroke => ((CustomStroke)stroke).isSelected()).ToList(); if (selectedStrokes.Count > 0) { ClipBoard.Clear(); selectedStrokes.ForEach(stroke => { vueModele.Traits.Remove(stroke); ClipBoard.Add(stroke); EditionSocket.RemoveStroke(((CustomStroke)stroke).Id.ToString()); Editeur.instance.Do(new DeleteStroke(((CustomStroke)stroke).Id.ToString(), ((Savable)stroke).toJson())); }); } }