Пример #1
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);
        }
Пример #2
0
        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();
                }
            }
        }