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);
 }
示例#2
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);
 }
示例#3
0
        public static void ShowExportDialog(long[] contextBoxIds, long[] contextPersonIds)
        {
            var dialog = new ExportHtmlDialog()
            {
                Owner            = App.Current.MainWindow,
                ContextBoxIds    = contextBoxIds,
                ContextPersonIds = contextPersonIds
            };

            if (contextPersonIds != null)
            {
                dialog.eContextNote.Text = $"This will only export the {contextPersonIds.Length} found record(s) in the active pane.";
            }
            else if (contextBoxIds != null)
            {
                dialog.eContextNote.Text = $"This will only export the {contextBoxIds.Length} found record(s) in the active search pane. (These may be sub-items of a the active note.)";
            }
            else
            {
                dialog.eContextNote.Text = "All records will be exported";
            }

            dialog.ShowDialog();
        }
示例#4
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.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);
 }