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 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 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; }
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; }