Esempio n. 1
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);
            }
        }
Esempio n. 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);
        }
 void FinishConstructor(ExtPerson ep, bool editMode)
 {
 public ExtPersonController(ExtPerson ep, Action <BlockController> blockGotFocusHandler, Action <BlockController, bool> collapseRequested, bool editMode)
     : base(blockGotFocusHandler, collapseRequested)
 {
     FinishConstructor(ep, editMode);
 }
Esempio n. 5
0
 public ExtPersonVM(ExtPerson person, Action <BaseBlockVM> gotFocusAction) : base(gotFocusAction)
 {
     Persistent = person;
     InitializeFromPersistent();
 }