Exemplo n.º 1
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();
     }
 }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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));
                }
            }
        }