Beispiel #1
0
        private void RecordEdit(object sender, EditAction e)
        {
            //Console.WriteLine("Received: " + e.Index0);
            if (editIndex < edits.Count)
            {
                edits.RemoveRange(editIndex, edits.Count - editIndex);
            }
            DateTime now = DateTime.Now;

            if (editIndex > 0)
            {
                EditAction lastEdit = edits[editIndex - 1];

                TimeSpan gap = now - editGroupEnd, span = now - editGroupStart;
                if (gap <= MAX_EDIT_GAP && span <= MAX_EDIT_SPAN)
                {
                    EditAction edit = e.CombineWith(lastEdit);
                    if (edit != null)
                    {
                        edits[editIndex - 1] = edit;
                        editGroupEnd         = now;
                        return;
                    }
                }
            }
            edits.Add(e);
            editIndex = edits.Count;
            UpdateUndoRedoEnabled();
            editGroupStart = editGroupEnd = now;
        }
 private void OnItemEdited(EditAction e)
 {
     if (OnObjectEdited != null)
     {
         e.AddIndexParent(Index);
         OnObjectEdited(null, e);
     }
     UpdateSelectedItemText();
 }
 private void RefreshEditors(object sender, EditAction e)
 {
     foreach (FieldEditor editor in editors)
     {
         if (editor.needsRefresh)
         {
             editor.Refresh();
         }
     }
 }
Beispiel #4
0
        private void Redo()
        {
            if (editIndex >= edits.Count)
            {
                return;
            }
            EditAction edit = edits[editIndex++];

            ApplyEdit(edit.Index0, edit.Index1, edit.state1);
            UpdateUndoRedoEnabled();
        }
Beispiel #5
0
        private void Undo()
        {
            if (editIndex <= 0)
            {
                return;
            }
            EditAction edit = edits[--editIndex];

            ApplyEdit(edit.Index1, edit.Index0, edit.state0);
            UpdateUndoRedoEnabled();
        }
Beispiel #6
0
        public override EditAction CombineWith(EditAction previous)
        {
            FieldEditAction edit = previous as FieldEditAction;

            if (previous == null)
            {
                return(null);
            }

            if (!(canCombime && edit.canCombime &&
                  edit.fieldIndex == fieldIndex &&
                  edit.index.Equals(index)))
            {
                return(null);
            }

            return(new FieldEditAction(edit.state0 as FieldEditState, state1 as FieldEditState, index, fieldIndex, true));
        }
Beispiel #7
0
 public virtual EditAction CombineWith(EditAction previous)
 {
     return(null);
 }