Beispiel #1
0
        public static bool HasDatabaseUri([NotNull] this IStartPageCommand command, [NotNull] StartPageContext context)
        {
            Assert.ArgumentNotNull(command, nameof(command));
            Assert.ArgumentNotNull(context, nameof(context));

            var result = context.StartPageViewer.DatabaseUri;

            return(result != DatabaseUri.Empty);
        }
Beispiel #2
0
        private void Execute([NotNull] CommandDescriptor command)
        {
            Debug.ArgumentNotNull(command, nameof(command));

            var startPage = this.GetAncestor<StartPageViewer>();
            if (startPage == null)
            {
                return;
            }

            var context = new StartPageContext(startPage);

            command.Command.Execute(context);
        }
Beispiel #3
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);
        }