コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: dylech30th/Marsher
        private async void ListCreateButton_Click(object sender, RoutedEventArgs e)
        {
            string name;

            _viewModel.FixAirspace = true;
            do
            {
                name = await this.ShowInputAsync(T("dialog.header.new"), T("dialog.create_list"),
                                                 CreateMetroDialogSettings());

                if (name == null)
                {
                    break;
                }
                try
                {
                    _localListPersistence.CreateList(name);
                }
                catch (IllegalListNameException)
                {
                    await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.invalid_list_name", "name", name), MessageDialogStyle.Affirmative, CreateMetroDialogSettings());

                    name = null;
                }
                catch (ArgumentException)
                {
                    await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.list_name_already_exists", "name", name), MessageDialogStyle.Affirmative, CreateMetroDialogSettings());

                    name = null;
                }
                catch (Exception ex)
                {
                    await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.create_failed", "name", name, "exception", ex.ToString()), MessageDialogStyle.Affirmative, CreateMetroDialogSettings());
                }
            } while (name == null);
            _viewModel.FixAirspace = false;
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: cqjjjzr/Marsher
        private async void ListCreateButton_Click(object sender, RoutedEventArgs e)
        {
            _viewModel.FixAirspace = true;
            var dialog = new InputWithCheckDialog(T("dialog.header.new"), T("dialog.create_list"),
                                                  DateTime.Now.ToLongDateString(), s =>
            {
                if (!_localListPersistence.CheckValidListName(s))
                {
                    return(T("dialog.invalid_list_name", "name", s));
                }
                if (_localListPersistence.CheckDuplicateListName(s))
                {
                    return(T("dialog.list_name_already_exists", "name", s));
                }
                return(null);
            });

            await this.ShowMetroDialogAsync(dialog, CreateMetroDialogSettings());

            var(result, name) = await dialog.WaitUntilButton();

            await this.HideMetroDialogAsync(dialog);

            if (result != MessageDialogResult.Affirmative)
            {
                return;
            }
            try
            {
                _localListPersistence.CreateList(name);
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.create_failed", "name", name, "exception", ex.ToString()), MessageDialogStyle.Affirmative, CreateMetroDialogSettings());
            }
            _viewModel.FixAirspace = false;
        }
コード例 #3
0
        public void ImportToNew(string listName)
        {
            ImportToDatabase();

            _persistence.CreateList(listName, _data.items);
        }