Example #1
0
        public async void Execute(object parameter)
        {
            var store       = (DrxStoreViewModel)parameter;
            var storeDialog = new StorePropertiesDialog(store);
            await storeDialog.ShowAsync();

            await store.SaveAsync();
        }
Example #2
0
        private void HandleShowWindowMessage(ShowWindowMessage msg)
        {
            switch (msg.Name)
            {
            case "NewConnection":
            {
                var connectionModel     = new Connection();
                var newConnectionDialog = new ConnectionPropertiesDialog {
                    DataContext = connectionModel
                };
                var dlgResult = newConnectionDialog.ShowDialog();
                if (dlgResult.HasValue && dlgResult.Value)
                {
                    var model = DataContext as MainViewModel;
                    if (model != null)
                    {
                        model.StoreSources.Add(connectionModel);
                        model.Configuration.ConnectionStrings.Add(new NamedConnectionString
                            {
                                Name             = connectionModel.Name,
                                ConnectionString =
                                    connectionModel.ConnectionString.
                                    ToString()
                            });
                        model.Configuration.Save();
                    }
                }
                break;
            }

            case "EditConnection":
            {
                var connectionModel = msg.ViewModel as Connection;
                if (connectionModel != null)
                {
                    var editModel = connectionModel.Clone();
                    var dlg       = new ConnectionPropertiesDialog {
                        DataContext = editModel
                    };
                    var dlgResult = dlg.ShowDialog();
                    if (dlgResult.HasValue && dlgResult.Value)
                    {
                        connectionModel.Name             = editModel.Name;
                        connectionModel.ConnectionString = editModel.ConnectionString;
                        var mvm = DataContext as MainViewModel;
                        if (mvm != null)
                        {
                            mvm.ServerRefresh(connectionModel);
                        }
                    }
                }
                break;
            }

            case "PrefixesDialog":
            {
                var configuration = msg.ViewModel as PolarisConfigurationModel;
                if (configuration != null)
                {
                    var oldPrefixes = new List <PrefixConfiguration>(configuration.Prefixes);
                    var dlg         = new PrefixesDialog {
                        DataContext = configuration
                    };
                    var dlgResult = dlg.ShowDialog();
                    if (dlgResult.HasValue && dlgResult.Value)
                    {
                        configuration.Save();
                    }
                    else
                    {
                        configuration.Prefixes = oldPrefixes;
                    }
                }
                break;
            }

            case "CreateStore":
            {
                var connection = msg.ViewModel as Connection;
                if (connection != null)
                {
                    var storeModel            = new Store(connection, Guid.NewGuid().ToString());
                    var storePropertiesDialog = new StorePropertiesDialog
                    {
                        DataContext = storeModel, Title = "New Store Properties"
                    };
                    var dlgResult = storePropertiesDialog.ShowDialog();
                    if (dlgResult.HasValue && dlgResult.Value && msg.Continuation != null)
                    {
                        msg.Continuation(storePropertiesDialog.DataContext);
                    }
                }
                break;
            }

            case "AboutDialog":
            {
                var dlg = new AboutDialog {
                    DataContext = msg.ViewModel
                };
                dlg.ShowDialog();
                break;
            }
            }
        }