예제 #1
0
 internal void anchorableDoneMoving(Anchorable anchorable)
 {
     if (((CustomStroke)anchorable).Id.ToString() == this.FirstAnchorId || ((CustomStroke)anchorable).Id.ToString() == this.SecondAncorId)
     {
         EditionSocket.EditStroke(this.toJson());
     }
 }
예제 #2
0
        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()));
                });
            }
        }
예제 #3
0
        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()));
        }
예제 #4
0
        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()));
        }
예제 #5
0
        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()));
        }
예제 #6
0
        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()));
        }
예제 #7
0
 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();
     }
 }
예제 #8
0
        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);
            }
        }
예제 #9
0
 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;
 }
예제 #10
0
        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;
            }
        }
예제 #11
0
        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;
        }
예제 #12
0
        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));
                }
            }
        }
예제 #13
0
        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;
        }
예제 #14
0
        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()));
                });
            }
        }