Exemplo n.º 1
0
        void Move_Click(object sender, RoutedEventArgs e)
        {
            var sel = SelectedCat;

            if (sel == null)
            {
                return;
            }
            var  kindOfMove  = MessageBox.Show("Make this a sub-item of another category? (If No, it will be moved to the root level.)", "Move Category", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
            long?newParentId = null;

            if (kindOfMove == MessageBoxResult.Yes)
            {
                var item = CatSelectDialog.SelectCat("The category will become a sub-item of the item you select here");
                if (item == null)
                {
                    return;
                }
                newParentId = item.RowId;
            }
            else if (kindOfMove != MessageBoxResult.No)
            {
                return; //canceled
            }
            Globals.UI.ModifyCat(sel.RowId, cat =>
            {
                cat.ParentId = newParentId;
            });
            DataContext = new VM();
        }
Exemplo n.º 2
0
        void ImportPeopleCSV_Click(object sender, RoutedEventArgs e)
        {
            //category to auto-apply
            long?autocCatId = CatSelectDialog.SelectCat("Choose category to apply to each imported person, or cancel to skip")?.RowId;

            string filename = AskForImportFileName(false);

            if (filename == null)
            {
                return;
            }
            var cvt = new CsvConverter();

            try
            {
                using var rdr = new StreamReader(filename);
                var persons = cvt.PersonFromCsv(rdr).ToArray();
                foreach (var person in persons)
                {
                    var eperson = new ExtPerson(person, null, null);
                    if (autocCatId != null)
                    {
                        eperson.SelectedCatIds = new long[] { autocCatId.Value }
                    }
                    ;
                    Globals.UI.SavePerson(eperson);
                }
                VisualUtils.ShowMessageDialog($"Imported {persons.Length} record(s)");
            }
            catch (Exception ex)
            {
                VisualUtils.ShowMessageDialog("Importing failed: " + ex.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get a category; return null if canceled
        /// </summary>
        public static CatCache.Item SelectCat(string caption)
        {
            var dialog = new CatSelectDialog
            {
                Owner       = App.Current.MainWindow,
                DataContext = new VM()
            };

            dialog.eCaption.Text = caption;
            if (dialog.ShowDialog() != true)
            {
                return(null);
            }
            return(dialog.SelectedCat);
        }
Exemplo n.º 4
0
 void SelectCat_Click(object sender, RoutedEventArgs e)
 {
     CatId = CatSelectDialog.SelectCat("Category to export")?.RowId;
 }