示例#1
0
 public void MakeHistory(string id = "")
 {
     if (!TrackChanges)
     {
         return;
     }
     if (id == null)
     {
         id = "";
     }
     if (id == "" || id != lastid)
     {
         UndoBuffer.AddLast(Model.Clone());
         RedoBuffer.Clear();
         if (UndoBuffer.Count > 100)
         {
             UndoBuffer.RemoveFirst();
         }
         UnsavedChanges++;
         Device.BeginInvokeOnMainThread(() =>
         {
             Save.ChangeCanExecute();
             Undo.ChangeCanExecute();
             Redo.ChangeCanExecute();
         });
     }
     lastid = id;
 }
示例#2
0
 private void Player_HistoryButtonChange(object sender, bool CanUndo, bool CanRedo)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         Undo.ChangeCanExecute();
         Redo.ChangeCanExecute();
     });
 }
 public LevelEditModel(OGLContext context)
 {
     context.Levels.ToAP(0);
     Context = context;
     Undo    = new Command(() =>
     {
         if (UndoBuffer.Count > 0)
         {
             lastid = "";
             RedoBuffer.AddLast(Model);
             Model = UndoBuffer.Last.Value;
             UndoBuffer.RemoveLast();
             if (UnsavedChanges > 0)
             {
                 UnsavedChanges--;
             }
             Undo.ChangeCanExecute();
             Redo.ChangeCanExecute();
             Save.ChangeCanExecute();
             bool old     = TrackChanges;
             TrackChanges = false;
             FireModelChanged();
             OnPropertyChanged("");
             TrackChanges = old;
         }
     },
                           () => UndoBuffer.Count > 0);
     Redo = new Command(() =>
     {
         if (RedoBuffer.Count > 0)
         {
             lastid = "";
             UndoBuffer.AddLast(Model);
             Model = RedoBuffer.Last.Value;
             RedoBuffer.RemoveLast();
             UnsavedChanges++;
             Undo.ChangeCanExecute();
             Redo.ChangeCanExecute();
             Save.ChangeCanExecute();
             bool old = TrackChanges;
             FireModelChanged();
             TrackChanges = false;
             OnPropertyChanged("");
             TrackChanges = old;
         }
     },
                        () => RedoBuffer.Count > 0);
     Save = new Command(async() =>
     {
         if (IsBusy)
         {
             return;
         }
         IsBusy = true;
         await SaveAsync();
         IsBusy = false;
     }, () => UnsavedChanges > 0);
 }
示例#4
0
 private void Player_HistoryButtonChange(object sender, bool CanUndo, bool CanRedo)
 {
     Undo.ChangeCanExecute();
     Redo.ChangeCanExecute();
 }