public override bool HandleCommand(CommandCenter.Item command)
 {
     if (command == Globals.Commands.OPEN)
     {
         if (VM.Results.Count == 0)
         {
             SearchRequested();
             return(true);
         }
         if (LastFocusedBoxId < 0)
         {
             return(false);
         }
         var ebox = Globals.UI.LoadBoxForEditing(LastFocusedBoxId);
         if (ebox == null)
         {
             UIGlobals.Do.ShowTimedMessge("Cannot find task"); return(true);
         }
         UIGlobals.Do.AddBoxToEditStack(ebox);
         return(true);
     }
     if (command == Globals.Commands.IMPORTEXPORT)
     {
         var ids = VM.Results.Select(r => r.Persistent.Box.RowId).ToArray();
         if (ids.Length == 0)
         {
             return(false);
         }
         ExportHtmlDialog.ShowExportDialog(ids, null);
         return(true);
     }
     return(false);
 }
 public override bool HandleCommand(CommandCenter.Item command)
 {
     if (command == Globals.Commands.OPEN)
     {
         if (LastFocusedBoxId < 0)
         {
             return(false);
         }
         var ebox = Globals.UI.LoadBoxForEditing(LastFocusedBoxId);
         if (ebox == null)
         {
             UIGlobals.Do.ShowTimedMessge("Cannot find task"); return(true);
         }
         UIGlobals.Do.AddBoxToEditStack(ebox);
         return(true);
     }
     if (command == Globals.Commands.CLOSE)
     {
         VisualUtils.LoseRegainFocus();
         SaveChunks();
         return(false); //caller can handle collapse
     }
     if (command == Globals.Commands.NEWLINKEDBOX)
     {
         NewTaskNearSelection();
     }
     return(false);
 }
 public override bool HandleCommand(CommandCenter.Item command)
 {
     if (command == Globals.Commands.OPEN)
     {
         if (LastFocusedBoxId < 0)
         {
             return(false);
         }
         var ebox = Globals.UI.LoadBoxForEditing(LastFocusedBoxId);
         if (ebox == null)
         {
             UIGlobals.Do.ShowTimedMessge("Cannot find task"); return(true);
         }
         UIGlobals.Do.AddBoxToEditStack(ebox);
         return(true);
     }
     if (command == Globals.Commands.NEWLINKEDBOX)
     {
         UIGlobals.Deferred.OnNewBox = new DeferredBehaviors.NewBoxBehavior {
             ParentId = LastFocusedBoxId
         };
         //UIGlobals.Do.HandleGlobalCommand(Globals.Commands.NEWITEM);
         var box = new Box
         {
             TimeType   = Constants.TIMETYPE_NONE,
             Importance = Constants.IMPORTANCE_NORMAL,
             Visibility = Constants.VISIBILITY_NORMAL
         };
         var ebox = new ExtBox(box, null);
         UIGlobals.Do.AddBoxToEditStack(ebox);
         UIGlobals.Do.ShowTimedMessge($"New note will be filed under selected note.");
     }
     return(base.HandleCommand(command));
 }
Exemple #4
0
 public override bool HandleCommand(CommandCenter.Item command)
 {
     if (command == Globals.Commands.CLOSE)
     {
         CollapseRequested(this, false);
         return(true);
     }
     return(false);
 }
Exemple #5
0
 public override bool HandleCommand(CommandCenter.Item command)
 {
     if (command == Globals.Commands.OPEN)
     {
         SearchRequested();
         return(true);
     }
     if (command == Globals.Commands.IMPORTEXPORT)
     {
         var ids = VM.Results.Select(r => r.PersonId).ToArray();
         if (ids.Length == 0)
         {
             return(false);
         }
         ExportHtmlDialog.ShowExportDialog(null, ids);
         return(true);
     }
     return(false);
 }
 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);
 }
Exemple #7
0
 /// <summary>
 /// Handle commands; returns true if handled at this level
 /// </summary>
 public virtual bool HandleCommand(CommandCenter.Item command)
 {
     return(false);
 }
 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.Box.RowId);
         CollapseRequested(this, VM.Persistent.Box.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)
     {
         bool saveOK = ChangeMode(Mode.ReadOnly, true);
         if (!VM.IsUnclass && saveOK)
         {
             CollapseRequested(this, false);
         }
         return(true);
     }
     if (command == Globals.Commands.NEWLINKEDBOX)
     {
         //if not saved, save to get parent id
         if (VM.Persistent.Box.RowId == 0)
         {
             if (!ChangeMode(Mode.Edit, true))
             {
                 return(true);
             }
         }
         UIGlobals.Deferred.OnNewBox = new DeferredBehaviors.NewBoxBehavior {
             ParentId = VM.Persistent.Box.RowId
         };
         UIGlobals.Do.HandleGlobalCommand(Globals.Commands.NEWITEM);
     }
     if (command == Globals.Commands.EDITLINKS)
     {
         UIGlobals.RecordLinkController.ActivateFor(this);
     }
     if (command == Globals.Commands.CLASSIFY)
     {
         HandleClassifyCommand();
         return(true);
     }
     if (command == Globals.Commands.RESCHEDULE)
     {
         string newDate = RescheduleDialog.ShowDialog(VM.BoxTime_Date.Date);
         if (newDate != null)
         {
             VM.BoxTime_Date.Date = newDate;
             UIGlobals.Do.ShowTimedMessge("Rescheduled for " + DateUtil.ToReadableDate(newDate, includeDOW: true));
             ChangeMode(Mode.ReadOnly, true);
             CollapseRequested(this, false);
         }
         return(true);
     }
     if (command == Globals.Commands.DONE)
     {
         HandleDoneCommand();
         return(true);
     }
     if (command == Globals.Commands.IMPORTEXPORT)
     {
         var childIds = VM.Links.Items.Where(r => r.Link == LinkType.FromBoxToChildBox).Select(r => r.OtherId).ToArray();
         if (childIds.Length == 0)
         {
             return(false);
         }
         ExportHtmlDialog.ShowExportDialog(childIds, null);
         return(true);
     }
     if (command == Globals.Commands.SELECTFOLDER)
     {
         var initialPath = GetDefaultFolderPath();
         var dlg         = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
         if (initialPath != null)
         {
             dlg.SelectedPath = initialPath;
         }
         if (dlg.ShowDialog(App.Current.MainWindow) != true)
         {
             return(true);
         }
         VM.RefDir = dlg.SelectedPath;
         VM.NotifyVisibilityDetails();
         return(true);
     }
     if (command == Globals.Commands.SELECTFILE)
     {
         var initialPath = GetDefaultFolderPath();
         var dlg         = new OpenFileDialog();
         if (initialPath != null)
         {
             dlg.InitialDirectory = initialPath;
         }
         if (dlg.ShowDialog(App.Current.MainWindow) != true)
         {
             return(true);
         }
         VM.RefFile = dlg.FileName;
         VM.NotifyVisibilityDetails();
         return(true);
     }
     if (command == Globals.Commands.OPENFOLDER)
     {
         if (!string.IsNullOrEmpty(VM.RefDir))
         {
             VisualUtils.OpenWithWithDefaultApp(VM.RefDir);
         }
         return(true);
     }
     if (command == Globals.Commands.OPENFILE)
     {
         if (!string.IsNullOrEmpty(VM.RefFile))
         {
             VisualUtils.OpenWithWithDefaultApp(VM.RefFile);
         }
         return(true);
     }
     if (command == Globals.Commands.CREATEFILE)
     {
         HandleCreateFileCommand();
         return(true);
     }
     if (command == Globals.Commands.CAPTUREEMAIL)
     {
         string s = Clipboard.GetText();
         if (string.IsNullOrEmpty(s))
         {
             VisualUtils.ShowMessageDialog("No text found on clipboard. (From Thunderbird, use Ctrl-UAC to copy it.");
             return(true);
         }
         VM.RawEmail.Value = s;
         VM.NotifyVisibilityDetails();
         UIGlobals.Do.ShowTimedMessge("Email captured");
         return(true);
     }
     if (command == Globals.Commands.CLEAREMAIL)
     {
         VM.RawEmail.Value = null;
         VM.NotifyVisibilityDetails();
         UIGlobals.Do.ShowTimedMessge("Email cleared");
         return(true);
     }
     if (command == Globals.Commands.VIEWEMAIL)
     {
         //string s = Clipboard.GetText();
         if (!VM.RawEmail.HasValue)
         {
             VisualUtils.ShowMessageDialog("No email was captured into this task.");
             return(true);
         }
         string filename = Path.Combine(Path.GetTempPath(), "systematizer.eml");
         File.WriteAllText(filename, VM.RawEmail.Value);
         VisualUtils.OpenWithWithDefaultApp(filename);
         return(true);
     }
     if (command == Globals.Commands.NEWLINKEDPERSON)
     {
         if (VM.Persistent.Box.RowId == 0)
         {
             return(true);
         }
         UIGlobals.Deferred.OnNewPerson = new DeferredBehaviors.NewPersonBehavior {
             LinkedBoxId = VM.Persistent.Box.RowId
         };
         UIGlobals.Do.HandleGlobalCommand(Globals.Commands.NEWPERSON);
         return(true);
     }
     return(false);
 }