Esempio n. 1
0
        public override void Execute(object parameter)
        {
            var context = parameter as IDatabaseUriContext;

            if (context == null)
            {
                return;
            }

            var dialog = new SelectDatabaseDialog
            {
                SelectedDatabaseUri = context.DatabaseUri
            };

            if (!dialog.ShowDialog())
            {
                return;
            }

            var databaseUri = dialog.SelectedDatabaseUri;

            if (databaseUri != DatabaseUri.Empty)
            {
                context.SetDatabaseUri(databaseUri);
            }
        }
        public override DataSourceString Execute(DatabaseUri databaseUri, BuildSourceField field, DataSourceString dataSource)
        {
            Assert.ArgumentNotNull(databaseUri, nameof(databaseUri));
            Assert.ArgumentNotNull(field, nameof(field));
            Assert.ArgumentNotNull(dataSource, nameof(dataSource));

            var dialog = new SelectDatabaseDialog
            {
                SelectedDatabaseUri = databaseUri
            };

            if (!dialog.ShowDialog())
            {
                return(null);
            }

            var d = dialog.SelectedDatabaseUri;

            if (d == DatabaseUri.Empty)
            {
                return(null);
            }

            SetDataSource(dataSource);
            dataSource["databasename"] = d.DatabaseName.ToString();

            return(dataSource);
        }
        private void ChangeDatabase([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var dialog = new SelectDatabaseDialog
            {
                SelectedDatabaseUri = DatabaseUri
            };

            if (dialog.ShowDialog())
            {
                AppHost.Settings.ActiveDatabaseUri = dialog.SelectedDatabaseUri;
            }
        }
Esempio n. 4
0
        public static DatabaseUri GetDatabaseUri([NotNull] this IStartPageCommand command, [NotNull] StartPageContext context)
        {
            Assert.ArgumentNotNull(command, nameof(command));
            Assert.ArgumentNotNull(context, nameof(context));

            var result = context.StartPageViewer.DatabaseUri;

            if (result != DatabaseUri.Empty)
            {
                return(result);
            }

            if (result == DatabaseUri.Empty)
            {
                var dialog = new SelectDatabaseDialog
                {
                    SelectedDatabaseUri = AppHost.Settings.ActiveDatabaseUri
                };

                if (dialog.ShowDialog())
                {
                    result = dialog.SelectedDatabaseUri;
                    if (result != DatabaseUri.Empty)
                    {
                        AppHost.Settings.ActiveDatabaseUri = result;

                        context.StartPageViewer.DatabaseUri = result;
                        context.StartPageViewer.UpdateLinks();

                        return(result);
                    }
                }
            }

            return(DatabaseUri.Empty);
        }