コード例 #1
0
        private async void ExecuteRunDialog(object o)
        {
            var source = new SourceDatabase();

            var view = new Domain.SourceEditorDialog
            {
                DataContext = new SourceEditorViewModel()
                {
                    Source = source
                }
            };

            view.Width  = 480;
            view.Height = 600;

            //show the dialog
            var result = await MaterialDesignThemes.Wpf.DialogHost.Show(view, "RootDialog", ClosingEventHandler);

            if (result is bool)
            {
                if ((bool)result)
                {
                    DocumentManager.Current.Deployment.Sources.Add(source);
                }

                //check the result...
                Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
            }
        }
コード例 #2
0
        private async void ExecuteEditSelectedItemCommand(object o)
        {
            UserControl view         = null;
            object      editedObject = null;

            if (TreeSelectedItem is SourceDatabase)
            {
                editedObject = new SourceDatabase((SourceDatabase)TreeSelectedItem);
                view         = new Domain.SourceEditorDialog
                {
                    DataContext = new SourceEditorViewModel()
                    {
                        Source = (SourceDatabase)editedObject
                    }
                };
                view.Width  = 480;
                view.Height = 600;
            }
            else if (TreeSelectedItem is SqlScriptFile)
            {
                editedObject = new SqlScriptFile((SqlScriptFile)TreeSelectedItem);
                view         = new ScriptEditor
                {
                    DataContext = new ScriptEditorViewModel()
                    {
                        Script = (SqlScriptFile)editedObject
                    }
                };
                view.Width  = WindowSize.Width * 0.80;
                view.Height = WindowSize.Height * 0.75;
            }

            if (view == null)
            {
                return;
            }



            //show the dialog
            var result = await MaterialDesignThemes.Wpf.DialogHost.Show(view, "RootDialog");

            if (result is bool)
            {
                if ((bool)result)
                {
                    if (TreeSelectedItem is SourceDatabase)
                    {
                        ((SourceDatabase)TreeSelectedItem).CopyFrom(editedObject as SourceDatabase);
                    }
                    else if (TreeSelectedItem is SqlScriptFile)
                    {
                        ((SqlScriptFile)TreeSelectedItem).CopyFrom(editedObject as SqlScriptFile);
                    }
                }
            }
        }