public ScreenSaverSettingsViewModel(ScreenSaverSettingsModel dataModel)
        {
            this.dataModel = dataModel;

            this.dataModel.PropertyChanged += this.OnPropertyChanged;

            this.RegisterCommands();
        }
        public void Startup(string[] args)
        {
            if (args.Length > 0)
            {
                string arg = args[0].ToLower(CultureInfo.InvariantCulture).Trim().Substring(0, 2);

                switch (arg)
                {
                    case "/c": // configuration mode
                        var settingsModel = new ScreenSaverSettingsModel(this.service, this.projectPicker);
                        settingsModel.Load();
                        var viewModel = new ScreenSaverSettingsViewModel(settingsModel);
                        ScreenSaverSettings settings = new ScreenSaverSettings(viewModel);
                        viewModel.CloseRequested += (object sender, EventArgs e) => {
                            settings.Close();
                        };
                        viewModel.SaveRequested += (object sender, EventArgs e) => {
                            settings.Close();
                        };
                        settings.ShowDialog();
                        break;
                    case "/p": // preview mode
                        this.InitializeScreenSaver(false, 1);

                        if (this.screenSaver != null)
                        {
                            this.screenSaver.ShowPreview(Convert.ToInt32(args[1]));
                            this.service.Start();
                        }
                        break;
                    case "/s": // normal mode
                        this.InitializeScreenSaver(true);

                        if (this.screenSaver != null)
                        {
                            this.screenSaver.Show();
                            this.service.Start();
                        }
                        break;
                    default: // unknown argument
                        Application.Current.Shutdown();
                        break;
                }
            }
            else
            {
                this.InitializeScreenSaver(true);

                if (this.screenSaver != null)
                {
                    this.screenSaver.Show();
                    this.service.Start();
                }
            }
        }
Пример #3
0
        private bool ShowSettingsDialog(ScreenSaverSettingsModel settingsModel)
        {
            var saved = false;
            var viewModel = new ScreenSaverSettingsViewModel(settingsModel);
            var settings = new ScreenSaverSettings(viewModel);

            // load settings
            settingsModel.Load();

            // configure view model
            viewModel.CloseRequested += (object sender, EventArgs e) =>
            {
                settings.Close();
            };
            viewModel.SaveRequested += (object sender, EventArgs e) =>
            {
                saved = true;
                settings.Close();
            };

            // show view
            settings.ShowDialog();

            return saved;
        }
Пример #4
0
        public void Startup()
        {
            // we will take care of shutting things down
            Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            var settingsModel = new ScreenSaverSettingsModel(this.service, this.projectPicker);

            if (string.IsNullOrEmpty(settingsModel.TfsUri))
            {
                // no config found, show settings dialog
                var saved = this.ShowSettingsDialog(settingsModel);

                if (!saved || string.IsNullOrEmpty(settingsModel.TfsUri))
                {
                    // no config found, user cancelled settings dialog - exit application
                    Application.Current.Shutdown();
                    return;
                }
            }

            this.service.TfsUrl = settingsModel.TfsUri;
            var builds = Settings.Default.Builds;
            var viewModel = new DesktopViewModel(this.service, builds);
            var desktop = new Desktop(viewModel);

            // configure view model
            viewModel.Columns = Settings.Default.Columns;
            viewModel.ConfigRequested += (object sender, EventArgs e) =>
            {
                // restore the view
                desktop.Restore();

                // stop querying the server
                this.service.Stop();

                // this is a blocking call
                var saved = this.ShowSettingsDialog(settingsModel);

                if (saved)
                {
                    // re-init builds after settings dialog is closed
                    viewModel.InitializeBuildPanels(Settings.Default.Builds);
                    viewModel.Columns = Settings.Default.Columns;
                }

                this.service.Start();
            };

            // configure view
            desktop.Title = this.title;
            desktop.Closed += (object sender, EventArgs e) =>
            {
                Application.Current.Shutdown();
            };

            // show view
            desktop.Show();

            // start monitoring the builds
            this.service.Start();
        }