コード例 #1
0
 public override bool HandleCommand(CommandCenter.Item command)
 {
     if (command == Globals.Commands.OPEN)
     {
         VM.IsEditMode = true;
         return(true);
     }
     if (command == Globals.Commands.ABANDON)
     {
         Globals.UI.AbandonBox(VM.Persistent.Person.RowId);
         CollapseRequested(this, VM.Persistent.Person.RowId == 0);
         UIGlobals.Do.ShowTimedMessge("Edits rolled back");
         return(true);
     }
     if (command == Globals.Commands.ENDEDITS)
     {
         if (VM.IsEditMode)
         {
             ChangeMode(Mode.ReadOnly, true);
             return(true);
         }
         return(false); //ancestor will collapse block
     }
     if (command == Globals.Commands.CLOSE)
     {
         VisualUtils.LoseRegainFocus();
         if (ChangeMode(Mode.ReadOnly, true))
         {
             CollapseRequested(this, false);
         }
         return(true);
     }
     if (command == Globals.Commands.NEWLINKEDBOX)
     {
         //if not saved, save to get parent id
         if (VM.Persistent.Person.RowId == 0)
         {
             if (!ChangeMode(Mode.Edit, true))
             {
                 return(true);
             }
         }
         UIGlobals.Deferred.OnNewBox = new DeferredBehaviors.NewBoxBehavior {
             LinkedPersonId = VM.Persistent.Person.RowId
         };
         UIGlobals.Do.HandleGlobalCommand(Globals.Commands.NEWITEM);
         return(true);
     }
     if (command == Globals.Commands.EDITLINKS)
     {
         UIGlobals.RecordLinkController.ActivateFor(this);
         return(true);
     }
     if (command == Globals.Commands.EDITCATEGORIES)
     {
         ChangeMode(Mode.Edit, false);
         if (CatMultiselectDialog.SelectCats(VM.Persistent))
         {
             VM.IsDirty = true;
             VM.InitializeCatsFromPersistent();
         }
         return(true);
     }
     if (command == Globals.Commands.SENDEMAIL)
     {
         if (!string.IsNullOrEmpty(VM.MainEmail))
         {
             VisualUtils.ComposeEmailTo(VM.MainEmail);
         }
         return(true);
     }
     if (command == Globals.Commands.DELETEPERSON)
     {
         if (VM.Persistent.Person.RowId == 0)
         {
             UIGlobals.Do.HandleGlobalCommand(Globals.Commands.ABANDON);
         }
         else
         {
             if (MessageBox.Show(App.Current.MainWindow, $"Really permanently delete person ({VM.Name})?", "Systematizer", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
             {
                 CollapseRequested(this, true);
                 Globals.UI.DeletePerson(VM.Persistent.Person.RowId);
             }
         }
         return(true);
     }
     return(false);
 }