Esempio n. 1
0
        private async void ExecuteNewScriptDialog(object o)
        {
            var script   = new SqlScriptFile();
            var basename = "SqlScript";

            script.Name = basename + (DocumentManager.Current.Deployment.ScriptFiles.Where(x => x.Name.StartsWith(basename)).Count() + 1).ToString();
            var view = new ScriptEditor
            {
                DataContext = new ScriptEditorViewModel()
                {
                    Script = script
                }
            };

            view.Width  = WindowSize.Width * 0.80;
            view.Height = WindowSize.Height * 0.75;

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

            if (result is bool)
            {
                if ((bool)result)
                {
                    DocumentManager.Current.Deployment.ScriptFiles.Add(script);
                }

                //check the result...
                Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
            }
        }
Esempio n. 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);
                    }
                }
            }
        }