Esempio n. 1
0
        partial void MainWindowCtor()
        {
            try
            {
                this.InitializeComponent();

                BaseViewModel.GetAddDatabseView         = this.GetAddDatabaseView;
                BaseViewModel.GetSettingView            = this.GetSettingView;
                BaseViewModel.GetCreateMinorVersionView = this.GetCreateMinorVersionView;
                BaseViewModel.GetMessageBox             = (text, title, buttons) => this.GetMessageBox(text, title, buttons, false);
                BaseViewModel.GetMarkdownBox            = (text, title, buttons) => this.GetMessageBox(text, title, buttons, true);
                BaseViewModel.OpenImportWindow          = this.OpenImportWindow;
                BaseViewModel.OpenExportWindow          = this.OpenExportWindow;
                this.DataContext = this.mainWindowViewModel;

                var monitor = new VerticalPositionMonitor();
                this.DatabaseList.PositionMonitor = monitor;
                this.DatabaseList.PreviewMouseUp += this.DatabaseListPreviewMouseUp;
                monitor.OrderChanged   += this.DatabaseOrderChanged;
                this.dialogHost.Loaded += this.DialogHostLoaded;
            }
            catch (Exception e)
            {
                var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
                n.ShowDialog();
            }
        }
        private async Task <MaterialMessageBoxResult> ShowDialog(object view, Func <MaterialMessageBoxResult, object> closingEventHandler)
        {
            try
            {
                MaterialMessageBoxResult result = Model.MaterialMessageBoxResult.None;

                await this.UIDispatcher.Invoke(async() =>
                {
                    try
                    {
                        var retval = await DialogHost.Show(
                            view,
                            this.DialogIdentifier,
                            new DialogClosingEventHandler(
                                (sender, eventArgs) =>
                        {
                            // if the settin view was closed return
                            if (eventArgs.Parameter.GetType() != typeof(MaterialMessageBoxResult))
                            {
                                return;
                            }

                            var displayableView = closingEventHandler?.Invoke((MaterialMessageBoxResult)eventArgs.Parameter);
                            if (displayableView != null)
                            {
                                eventArgs.Cancel();
                                eventArgs.Session.UpdateContent(displayableView);
                            }
                        }));

                        if (retval == null)
                        {
                            result = MaterialMessageBoxResult.None;
                        }
                        else
                        {
                            result = retval.GetType() == typeof(MaterialMessageBoxResult) ? (MaterialMessageBoxResult)retval : MaterialMessageBoxResult.None;
                        }
                    }
                    catch (InvalidOperationException)
                    {
                        // this can happen if the window is closed and the dialog can't be shown
                    }
                });

                return(result);
            }
            catch (Exception e)
            {
                this.UIDispatcher.Invoke(() =>
                {
                    var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
                    n.ShowDialog();
                });

                throw;
            }
        }
Esempio n. 3
0
 partial void ImportWindowCtor()
 {
     try
     {
         this.DataContext = new ImportWindowViewModel(this.processManager, this.selectedDatabase);
         this.InitializeComponent();
     }
     catch (Exception e)
     {
         var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
         n.ShowDialog();
     }
 }
Esempio n. 4
0
 partial void AddDatabaseViewCtor()
 {
     try
     {
         this.DataContext = new AddDatabaseViewModel(this.connectionManager, this.fileSystemAccess, this.processManager, this.differenceCreator, this.sQLFileTester, this.Close);
         this.InitializeComponent();
     }
     catch (Exception e)
     {
         var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
         n.ShowDialog();
     }
 }
 public SettingView(IConnectionManager connectionManager)
 {
     try
     {
         this.viewModel   = new SettingViewModel(connectionManager);
         this.DataContext = this.viewModel;
         this.InitializeComponent();
         this.passwordBox.Password = this.viewModel.Password;
     }
     catch (Exception e)
     {
         var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
         n.ShowDialog();
     }
 }
Esempio n. 6
0
 private void OpenExportWindow(SQLFileDisplayData diff, SQLFileDisplayData undoDiff)
 {
     try
     {
         this.UIDispatcher.Invoke(() => new ExportWindow(diff, undoDiff).ShowDialog());
     }
     catch (Exception e)
     {
         this.UIDispatcher.Invoke(() =>
         {
             var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
             n.ShowDialog();
         });
     }
 }
Esempio n. 7
0
 private void OpenImportWindow(DatabaseDisplayData database)
 {
     try
     {
         this.UIDispatcher.Invoke(() => new ImportWindow(this.processManager, database).ShowDialog());
         this.mainWindowViewModel.UpdateDatabases();
     }
     catch (Exception e)
     {
         this.UIDispatcher.Invoke(() =>
         {
             var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception");
             n.ShowDialog();
         });
     }
 }
Esempio n. 8
0
        private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var n = new Greg.WPF.Utility.ExceptionMessageBox((Exception)e.ExceptionObject, "CurrentDomainUnhandledException");

            n.ShowDialog();
        }
Esempio n. 9
0
        private void CurrentDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            var n = new Greg.WPF.Utility.ExceptionMessageBox(e.Exception, "CurrentDispatcherUnhandledException");

            n.ShowDialog();
        }