예제 #1
0
        private void ExecuteAdd()
        {
            string selectedJob;

            //Present a dialog for the user to select the type of job they want to add
            var dialog = new CustomDialog {
                Title = "Add New Job"
            };
            var panel = new StackPanel();

            panel.Children.Add(new RadioButton {
                Content = "Data Update", Margin = new Thickness(5), IsChecked = true
            });
            panel.Children.Add(new RadioButton {
                Content = "Economic Release Update", Margin = new Thickness(5), IsChecked = false
            });
            panel.Children.Add(new RadioButton {
                Content = "Dividend Update", Margin = new Thickness(5), IsChecked = false
            });

            var addBtn = new Button {
                Content = "Add"
            };

            addBtn.Click += (s, e) =>
            {
                DialogCoordinator.HideMetroDialogAsync(this, dialog);
                selectedJob = (string)panel.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked.HasValue && r.IsChecked.Value)?.Content;
                AddJob(selectedJob);
            };
            panel.Children.Add(addBtn);
            dialog.Content = panel;

            DialogCoordinator.ShowMetroDialogAsync(this, dialog);
        }
예제 #2
0
        /// <summary>
        /// Open signin modal
        /// </summary>
        /// <returns>Task</returns>
        private async Task OpenSigninModal()
        {
            var signinDialog = new SigninDialog(new SigninDialogSettings());
            await DialogCoordinator.ShowMetroDialogAsync(this, signinDialog);

            var signinDialogResult = await signinDialog.WaitForButtonPressAsync();

            await DialogCoordinator.HideMetroDialogAsync(this, signinDialog);

            if (signinDialogResult == null)
            {
                return;
            }

            if (signinDialogResult.ShouldSignup)
            {
                var user = await OpenSignupModal();

                if (user == null)
                {
                    return;
                }
                await Signin(user);
            }
            else
            {
                var user = new Models.Account.User
                {
                    Username = signinDialogResult.Username,
                    Password = signinDialogResult.Password
                };

                await Signin(user);
            }
        }
예제 #3
0
        private async void CloseDialog(object sender, RoutedEventArgs e)
        {
            try
            {
                await _dialogCoordinator.HideMetroDialogAsync(_viewModel, this);
                await _WaitForCloseAsync();

                if (_closeWindow)
                {
                    _dialogCoordinator.DestroyMetroWindow(_viewModel);
                }
            }
            catch { }
        }
예제 #4
0
        /// <summary>
        /// Open signup modal
        /// </summary>
        /// <returns>User</returns>
        private async Task <Models.Account.User> OpenSignupModal()
        {
            var signupDialog = new SignupDialog(new SignupDialogSettings());
            await DialogCoordinator.ShowMetroDialogAsync(this, signupDialog);

            var signupDialogResult = await signupDialog.WaitForButtonPressAsync();

            await DialogCoordinator.HideMetroDialogAsync(this, signupDialog);

            if (signupDialogResult == null)
            {
                return(null);
            }
            return(await
                   UserService.CreateUser(signupDialogResult.Username, signupDialogResult.FirstName,
                                          signupDialogResult.LastName, signupDialogResult.Password, signupDialogResult.Email,
                                          new CancellationToken()));
        }
예제 #5
0
        /// <summary>
        /// Manage an exception
        /// </summary>
        /// <param name="exception">The exception</param>
        private void ManageException(Exception exception)
        {
            if (IsManagingException)
            {
                return;
            }

            IsManagingException = true;
            if (exception is WebException || exception is SocketException)
            {
                IsConnectionInError = true;
            }

            DispatcherHelper.CheckBeginInvokeOnUI(async() =>
            {
                var exceptionDialog = new ExceptionDialog(new ExceptionDialogSettings(LocalizationProviderHelper.GetLocalizedValue <string>("EmbarrassingError"), exception.Message));
                await DialogCoordinator.ShowMetroDialogAsync(this, exceptionDialog);
                await exceptionDialog.WaitForButtonPressAsync();
                IsManagingException = false;
                await DialogCoordinator.HideMetroDialogAsync(this, exceptionDialog);
            });
        }
예제 #6
0
 /// <summary>
 /// カスタムダイアログを非表示にします。
 /// </summary>
 /// <param name="dialog">カスタムダイアログのインスタンス</param>
 /// <param name="settings">設定情報</param>
 /// <returns><code>Task</code></returns>
 public Task HideMetroDialogAsync(BaseMetroDialog dialog, MetroDialogSettings settings = null)
 {
     return(DialogCoordinator.HideMetroDialogAsync(this, dialog, settings));
 }
        private async void OnNav(string destination)
        {
            ViewModelBase nextPage;

            switch (destination)
            {
            case "ExistingPackagedSolutionView":
                nextPage = new ExistingPackagedSolutionsViewModel(_dialogCoordinator);
                break;

            case "CreatePackagedSolutionView":
                using (var ctx = new AssistantContext())
                {
                    nextPage = new CreatePackagedSolutionViewModel(_dialogCoordinator);
                    if (!ctx.CompanyInformation.Any())
                    {
                        OpenOfferSettingsDialog(instanceCanceled =>
                        {
                            _dialogCoordinator.HideMetroDialogAsync(this, _customDialog);
                            NavigationService.GoBack();
                        }, async instanceCompleted =>
                        {
                            await _dialogCoordinator.HideMetroDialogAsync(this, _customDialog);
                            DisplayTimedMessage("Information gemt!", "", 2);
                        });
                    }
                }

                break;

            case "ExistingOffersView":
                nextPage = new ExistingOffersViewModel(_dialogCoordinator);
                break;

            case "CreateOfferView":
                using (var ctx = new AssistantContext())
                {
                    nextPage = new CreateOfferViewModel(_dialogCoordinator);
                    if (!ctx.CompanyInformation.Any())
                    {
                        OpenOfferSettingsDialog(instanceCanceled =>
                        {
                            _dialogCoordinator.HideMetroDialogAsync(this, _customDialog);
                            NavigationService.GoBack();
                        }, async instanceCompleted =>
                        {
                            await _dialogCoordinator.HideMetroDialogAsync(this, _customDialog);
                            DisplayTimedMessage("Information gemt!", "", 2);
                        });
                    }
                }
                break;

            case "SettingsView":
                nextPage = new SettingsViewModel(_dialogCoordinator);
                break;

            case "GoBack":
                NavigationService.GoBack();
                return;

            default:
                return;
            }

            // Navigate to page
            await NavigationService.BeginNavigate(nextPage);

            NavigationService.EndNavigate();
        }
예제 #8
0
 private async void Cancel_Pressed(RoutedEventArgs e)
 {
     Cancel = true;
     await _dialogCoordinator.HideMetroDialogAsync(Context, Dialog);
 }