Esempio n. 1
0
        public ShellViewModel(
            IServer server,
            ServerUriProvider uriProvider,
            NavigationViewModel navigation,
            NotificationsViewModel notifications,
            BusyStatusViewModel busyStatus,
            SelectDatabaseViewModel start,
            DatabaseExplorer databaseScreen,
            IKeyboardShortcutBinder binder,
            IEventAggregator events)
        {
            this.navigation    = navigation;
            this.notifications = notifications;
            this.busyStatus    = busyStatus;
            navigation.SetGoHome(() =>
            {
                this.TrackNavigationTo(start, events);
                navigation.Breadcrumbs.Clear();
            });
            this.databaseScreen = databaseScreen;
            this.binder         = binder;
            this.events         = events;
            this.server         = server;
            events.Subscribe(this);


            Items.Add(start);
            Items.Add(databaseScreen);

            serverUri = new Uri(uriProvider.GetServerUri());

            events.Publish(new WorkStarted("Connecting to server"));
            server.Connect(serverUri,
                           () =>
            {
                events.Publish(new WorkCompleted("Connecting to server"));

                switch (server.Databases.Count())
                {
                case 0:
                    //NOTE: perhaps we should display a retry button?
                    break;

                case 1:
                    ActivateItem(databaseScreen);
                    break;

                default:
                    ActivateItem(start);
                    break;
                }
            });
        }
Esempio n. 2
0
        public ShellViewModel(
            IServer server,
            ServerUriProvider uriProvider,
            NavigationViewModel navigation,
            NotificationsViewModel notifications,
            BusyStatusViewModel busyStatus,
            SelectDatabaseViewModel start,
            DatabaseViewModel databaseScreen,
            IKeyboardShortcutBinder binder,
            IEventAggregator events)
        {
            this.navigation    = navigation;
            this.notifications = notifications;
            this.busyStatus    = busyStatus;
            navigation.SetGoHome(() =>
            {
                this.TrackNavigationTo(start, events);
                navigation.Breadcrumbs.Clear();
            });
            this.databaseScreen = databaseScreen;
            this.binder         = binder;
            this.events         = events;
            events.Subscribe(this);


            Items.Add(start);
            Items.Add(databaseScreen);

            events.Publish(new WorkStarted("Connecting to server"));
            server.Connect(new Uri(uriProvider.GetServerUri()),
                           () =>
            {
                events.Publish(new WorkCompleted("Connecting to server"));

                if (server.Databases.Count() == 1)
                {
                    ActivateItem(databaseScreen);
                }
                else
                {
                    ActivateItem(start);
                }
            });
        }