Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        public async void ShowCameraPositioningDialog()
        {
            _dialog = new CameraPositioningCalibrationView(_parentWindow)
            {
                DataContext = new CameraPositioningCalibrationViewModel(_viewModel.CamerasModel)
            };

            await _parentWindow.ShowMetroDialogAsync(_dialog);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 public async Task HideDialogAsync(BaseMetroDialog dialog, MetroDialogSettings settings = null)
 {
     try
     {
         await DialogCoordinator.Instance.HideMetroDialogAsync(DialogContext, dialog, settings);
     }
     finally
     {
         DialogContext.InUse = false;
     }
 }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
        public async void ShowDialog()
        {
            _dialog = new CameraCalibrationView(_parentWindow)
            {
                DataContext = new CameraCalibrationViewModel
                {
                    Camera = _viewModel.Camera
                }
            };

            await _parentWindow.ShowMetroDialogAsync(_dialog);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 /// <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
         });
     }
 });
Ejemplo n.º 15
0
        public GeneratorDialogViewModel(BaseMetroDialog dialogView, PasswordScreen viewModel) : base(dialogView, viewModel)
        {
            // Sets default values
            Length           = 32;
            IncludeLowercase = true;
            IncludeUppercase = true;
            IncludeNumeric   = true;
            IncludeSpecial   = true;

            GenerateRandomPassword();
            CheckValidGeneration();
        }
Ejemplo n.º 16
0
        public async void ShowStereoCameraCalibrationDialog()
        {
            _viewModel.DoToggleCamera(false);
            _viewModel.DoToggleTracking(false);

            _dialog = new StereoCameraCalibrationView(_parentWindow)
            {
                DataContext = new StereoCameraCalibrationViewModel(_viewModel.CamerasModel.Cameras)
            };

            await _parentWindow.ShowMetroDialogAsync(_dialog);
        }
Ejemplo n.º 17
0
        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;
            }
        }
Ejemplo n.º 18
0
        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);
            }
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 21
0
    /// <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);
    });
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        public static void ShowModal(this BaseMetroDialog dialog)
        {
            Argument.IsNotNull(() => dialog);

            dialog.ShowModalDialogExternally();
        }
Ejemplo n.º 24
0
        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)));
        }
Ejemplo n.º 25
0
 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)));
        }
Ejemplo n.º 27
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));
 }
Ejemplo n.º 28
0
        private async void CloseAddPluginDialog(object sender, RoutedEventArgs e)
        {
            BaseMetroDialog dialog = (BaseMetroDialog)this.Resources["AddPluginDialog"];

            await this.HideMetroDialogAsync(dialog);
        }
Ejemplo n.º 29
0
        protected async Task ShowDialogAsync(object context, CloseableViewModel viewModel, BaseMetroDialog view, Action onShown = null)
        {
            var metroWindow = await GetMetroWindowAsync(context);

            await metroWindow.ShowDialogAsync(viewModel, view, onShown);
        }
Ejemplo n.º 30
0
 public MetroDialogAutomationPeer(BaseMetroDialog owner)
     : base(owner)
 {
 }