Пример #1
0
        /// <summary>
        /// Given a date, allow the user to advance it by number of days or to the next DOW.
        /// Inputs and outputs in YYYYMMDD format.
        /// </summary>
        /// <returns>null if canceled</returns>
        public static string ShowDialog(string date)
        {
            var dlg = new RescheduleDialog
            {
                Owner = App.Current.MainWindow
            };

            dlg.Loaded += (s, e) => dlg.eCommand.Focus();
            if (dlg.ShowDialog() != true)
            {
                return(null);
            }
            return(DateUtil.AdvanceByShortcutKey(date, dlg.AdvanceChar));
        }
Пример #2
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);
 }