void CatFilter_Click(object sender, RoutedEventArgs e)
        {
            var cats = CatMultiselectDialog.SelectCats(true, "Choose categories to search by (Choose multiple to find people who are in ALL of the categories.)");

            //single cat version: var cat = CatSelectDialog.SelectCat("Choose category to include");
            if (cats == null)
            {
                return;
            }
            VM.CatIdCri = cats;
            VM.SearchRequested();
        }
Exemple #2
0
        /// <summary>
        /// Allow modifying the categories in the given ExtPerson; returns true if possibly changed
        /// </summary>
        public static bool SelectCats(ExtPerson ep)
        {
            var dialog = new CatMultiselectDialog
            {
                Owner = App.Current.MainWindow,
                _VM   = new VM(ep.SelectedCatIds)
            };

            dialog.DataContext   = dialog._VM;
            dialog.eCaption.Text = $"Choose categories for {ep.Person.Name}";
            if (dialog.ShowDialog() != true)
            {
                return(false);
            }
            ep.SelectedCatIds = dialog._VM.GetEditedSelectedIds();
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Allow selecting categories (such as for searching); returns null on cancel
        /// </summary>
        public static long[] SelectCats(bool allowNonLeafSelection, string caption)
        {
            var dialog = new CatMultiselectDialog
            {
                Owner = App.Current.MainWindow,
                _VM   = new VM(Array.Empty <long>())
                {
                    ShowNonLeafCheckboxes = allowNonLeafSelection
                }
            };

            dialog.DataContext   = dialog._VM;
            dialog.eCaption.Text = caption;
            if (dialog.ShowDialog() != true)
            {
                return(null);
            }
            return(dialog._VM.GetEditedSelectedIds());
        }
 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);
 }