public async void SetConnectionInfo(ConnectionInfoEditorViewModel viewModel) { _options.BaselineServer = viewModel.BaselineServer; _options.BaselineDatabase = viewModel.BaselineDatabase; _options.BaselineSchema = viewModel.BaselineSchema; _options.BaselineUsername = viewModel.BaselineUsername; _options.BaselinePassword = viewModel.BaselinePassword; _options.BenchmarkServer = viewModel.BenchmarkServer; _options.BenchmarkDatabase = viewModel.BenchmarkDatabase; _options.BenchmarkSchema = viewModel.BenchmarkSchema; _options.BenchmarkUsername = viewModel.BenchmarkUsername; _options.BenchmarkPassword = viewModel.BenchmarkPassword; _invalidOptions = false; ShowStatusMessage("Pre InitializeAll"); // now that the options are filled, I can invoke the initialization InitializeAll(); BaseMetroDialog showingDialog = null; showingDialog = await _dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(this); if (showingDialog != null) { await _dialogCoordinator.HideMetroDialogAsync(this, showingDialog); } ShowStatusMessage("Post InitializeAll"); }
/// <summary> /// Sets up the connection between view and viewModel, shows the view as a metro dialog, /// calls <paramref name="onShown"/> and waits for the dialog to be closed. /// </summary> public static async Task <T> ShowDialogAsync <T>(this MetroWindow window, CloseableViewModelBase <T> viewModel, BaseMetroDialog view, Action?onShown = null) { view.DataContext = viewModel; // Undefault buttons not in the dialog as they would be pressed instead of a dialog button on enter. var oldDefaults = window.FindVisualChildren <Button>().Where(b => b.IsDefault).ToList(); oldDefaults.ForEach(b => b.IsDefault = false); // Save old keyboard focus. var oldFocus = Keyboard.FocusedElement; await window.ShowMetroDialogAsync(view, new MetroDialogSettings { AnimateShow = false }); // Focus the first focusable element in the view var element = view.FindVisualChildren <UIElement>().FirstOrDefault(e => e.Focusable); element?.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => Keyboard.Focus(element))); onShown?.Invoke(); var result = await viewModel.WaitForCloseAsync(); await window.HideMetroDialogAsync(view, new MetroDialogSettings { AnimateHide = false }); // Restore IsDefault and keyboard focus. oldDefaults.ForEach(b => b.IsDefault = true); Keyboard.Focus(oldFocus); return(result); }
public static void Show(this BaseMetroDialog dialog) { Argument.IsNotNull(() => dialog); var metroWindow = Application.Current.GetMainWindow(); metroWindow.Dispatcher.Invoke(() => metroWindow.ShowMetroDialogAsync(dialog)); }
void LoadDesigner() { busyDialog = (BaseMetroDialog)this.Resources["BusyIndicatorDialog"]; busyDialog.DialogSettings.ColorScheme = MetroDialogColorScheme.Theme; Logger.MethodCalled(); UpdateGridData(); PrintGridStatus(); }
public ChoiceBDEUC(BaseMetroDialog dialog, Collection <BasketItem> items, float reduction) { this.main = Application.Current.MainWindow as MainWindow; DataContext = new ChoiceBDEViewModel(DialogCoordinator.Instance, items, this, this.main, reduction); this.dialog = dialog; InitializeComponent(); }
private async void ShowAddPluginDialog(object sender, RoutedEventArgs e) { BaseMetroDialog dialog = (BaseMetroDialog)this.Resources["AddPluginDialog"]; dialog.DataContext = new AddAssemblyModel(); await this.ShowMetroDialogAsync(dialog); await dialog.WaitUntilUnloadedAsync(); }
public async void ShowCameraPositioningDialog() { _dialog = new CameraPositioningCalibrationView(_parentWindow) { DataContext = new CameraPositioningCalibrationViewModel(_viewModel.CamerasModel) }; await _parentWindow.ShowMetroDialogAsync(_dialog); }
static async Task <bool?> HandleMetroDialog(IMetroDialog model, BaseMetroDialog dialog) { var window = (MetroWindow)Application.Current.MainWindow; var tcs = new TaskCompletionSource <bool?>(); model.Close = CreateCommand(dialog, window, tcs); await window.ShowMetroDialogAsync(dialog); return(await tcs.Task); }
public async Task HideDialogAsync(BaseMetroDialog dialog, MetroDialogSettings settings = null) { try { await DialogCoordinator.Instance.HideMetroDialogAsync(DialogContext, dialog, settings); } finally { DialogContext.InUse = false; } }
static ReactiveCommand <bool?> CreateCommand(BaseMetroDialog dialog, MetroWindow window, TaskCompletionSource <bool?> tcs) { var command = ReactiveCommand.CreateAsyncTask(async x => { await window.HideMetroDialogAsync(dialog); return((bool?)x); }); SetupCommand(tcs, command); return(command); }
public SelectProcessViewModel(BaseMetroDialog dialog) { // When window is closed through X button. Processes = new ObservableCollection <Process>(); // Close window on when "Set character" is pressed. SelectCommand = new RelayCommand(async() => await OnSelect()); RefreshCommand = new RelayCommand(OnRefresh); OnRefresh(); Dialog = dialog; }
public async void ShowDialog() { _dialog = new CameraCalibrationView(_parentWindow) { DataContext = new CameraCalibrationViewModel { Camera = _viewModel.Camera } }; await _parentWindow.ShowMetroDialogAsync(_dialog); }
private void VisibleSettings(object obj) { _settingsView = new MainWindowUserControls.Settings(); MetroDialogSettings metroSettings = new MetroDialogSettings { AnimateShow = true, AnimateHide = true }; _settingsView.Title = Localization.Get("Base_Settings").ToUpper(); _view.ShowMetroDialogAsync(_settingsView, metroSettings); }
/// <summary> /// Hide currently displayed dialog. /// </summary> /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns> public virtual async Task HideCurrentDialogAsync() => await Application.Current.Dispatcher.Invoke(async() => { BaseMetroDialog dialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel); if (dialog != null) { await dialogCoordinator.HideMetroDialogAsync(viewModel, dialog, new MetroDialogSettings() { AnimateHide = false }); } });
public GeneratorDialogViewModel(BaseMetroDialog dialogView, PasswordScreen viewModel) : base(dialogView, viewModel) { // Sets default values Length = 32; IncludeLowercase = true; IncludeUppercase = true; IncludeNumeric = true; IncludeSpecial = true; GenerateRandomPassword(); CheckValidGeneration(); }
public async void ShowStereoCameraCalibrationDialog() { _viewModel.DoToggleCamera(false); _viewModel.DoToggleTracking(false); _dialog = new StereoCameraCalibrationView(_parentWindow) { DataContext = new StereoCameraCalibrationViewModel(_viewModel.CamerasModel.Cameras) }; await _parentWindow.ShowMetroDialogAsync(_dialog); }
private void LocalPathDialogButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog() { Filter = "DLL Files (*.dll)|*.dll" }; if (dialog.ShowDialog() == true) { BaseMetroDialog addPluginDialog = (BaseMetroDialog)this.Resources["AddPluginDialog"]; ((AddAssemblyModel)addPluginDialog.DataContext).DllPath = dialog.FileName; } }
public static void Close(this BaseMetroDialog dialog, Window parentDialogWindow = null) { Argument.IsNotNull(() => dialog); if (parentDialogWindow != null) { parentDialogWindow.Close(); } else { var mainWindow = Application.Current.GetMainWindow(); mainWindow.HideMetroDialogAsync(dialog); } }
public async void AddBasketToDB(BDE bdeChosen, BaseMetroDialog dialog) { var totalPrice = TotalPrice; var key = DateTime.Now.ToString().GetHashCode().ToString("x"); var u = Singleton <User> .GetInstance(); var ticket = new Ticket(key, new DateTime(), bdeChosen, BasketItems, u, u.Account, reductionQuantity * 0.2f); persistance.AddTicket(ticket); await dialogCoordinator.HideMetroDialogAsync(this, dialog); await main.ShowMessageAsync("Encaissement Réussi", $"Un montant de {totalPrice.ToString("C2")} a été encaissé au {bdeChosen.Name} avec le ticket {key}"); ClearBasket(); }
private async void NewConfiguration(BaseMetroDialog dialog) { dialog.CommandBindings.Clear(); dialog.CommandBindings.Add(new CommandBinding(RoutedCommands.AffirmConfigurationDialogCommand, AffirmNewConfigurationDialog, CanAffirmConfigurationDialog)); dialog.CommandBindings.Add(new CommandBinding(RoutedCommands.CancelConfigurationDialogCommand, CancelConfigurationDialog)); dialog.Title = "New Configuration"; var configuration = new NewConfiguration(); dialog.DataContext = configuration; await _mainWindow.ShowMetroDialogAsync(dialog); }
/// <summary> /// Tweak around mahapps' behaviour with dialogs - Unloaded fires when showing child dialogs as well as when hiding dialog itself. /// We need to wait til dialog itself is close. /// </summary> /// <param name="dialog">Dialog to show.</param> /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns> public virtual async Task ShowAndWaitForClosedAsync(BaseMetroDialog dialog) => await Application.Current.Dispatcher.Invoke(async() => { // Remember where we were before showing. BaseMetroDialog parentDialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel); await dialogCoordinator.ShowMetroDialogAsync(viewModel, dialog); BaseMetroDialog currentDialog; do { // Wailt until unload of this dialog (may happen multiple times) await dialog.WaitUntilUnloadedAsync(); // Check if current dialog is the one that we remembered currentDialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel); }while (currentDialog != parentDialog); });
public async Task ShowDialog(IDialogViewModel viewModel) { var view = ViewLocator.LocateForModel(viewModel, null, null) as UserControl; view.Loaded += (sender, args) => { ViewModelBinder.Bind(viewModel, view, null); }; var dialog = new CustomMetroDialog(); dialog.MainContent.Content = view; _currentlyShownDialog = dialog; await MetroWindow.ShowMetroDialogAsync(dialog); await viewModel.Task; await MetroWindow.HideMetroDialogAsync(dialog); }
public static void ShowModal(this BaseMetroDialog dialog) { Argument.IsNotNull(() => dialog); dialog.ShowModalDialogExternally(); }
protected Task <T> ShowDialogAsync <T>(object context, CloseableViewModel <T> viewModel, BaseMetroDialog view, Action onShown = null) { var metroWindow = GetMetroWindow(context); return(metroWindow.Invoke(() => metroWindow.ShowDialogAsync(viewModel, view, onShown))); }
public async Task ShowDialogAsync(BaseMetroDialog dialog, MetroDialogSettings settings = null) { DialogContext.InUse = true; await DialogCoordinator.Instance.ShowMetroDialogAsync(DialogContext, dialog, settings); }
public Task HideMetroDialogAsync(object context, BaseMetroDialog dialog, MetroDialogSettings settings = null) { var metroWindow = GetMetroWindow(context); return(metroWindow.Invoke(() => metroWindow.HideMetroDialogAsync(dialog, settings))); }
/// <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 CloseAddPluginDialog(object sender, RoutedEventArgs e) { BaseMetroDialog dialog = (BaseMetroDialog)this.Resources["AddPluginDialog"]; await this.HideMetroDialogAsync(dialog); }
protected async Task ShowDialogAsync(object context, CloseableViewModel viewModel, BaseMetroDialog view, Action onShown = null) { var metroWindow = await GetMetroWindowAsync(context); await metroWindow.ShowDialogAsync(viewModel, view, onShown); }
public MetroDialogAutomationPeer(BaseMetroDialog owner) : base(owner) { }