Пример #1
0
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            // Preview mode--display in little window in Screen Saver dialog
            // (Not invoked with Preview button, which runs Screen Saver in
            // normal /s mode).
            if (e.Args[0].ToLower().StartsWith("/p"))
            {
                System.Environment.Exit(1);
            }
            // Normal screensaver mode.  Either screen saver kicked in normally,
            // or was launched from Preview button
            else if (e.Args[0].ToLower().StartsWith("/s"))
            {
                foreach (Screen s in Screen.AllScreens)
                {
                    if (s != Screen.PrimaryScreen)
                    {
                        Blackout blackOut = new Blackout();
                        blackOut.Top    = s.WorkingArea.Top;
                        blackOut.Left   = s.WorkingArea.Left;
                        blackOut.Width  = s.WorkingArea.Width;
                        blackOut.Height = s.WorkingArea.Height;
                        blackOut.Show();
                    }
                }

                SaverSettings settings = new SaverSettings();
                if (settings.Load())
                {
                    (new MainWindow(settings)).Show();
                }
                else
                {
                    (new MainWindow()).Show();
                }
            }
            else if (e.Args[0].ToLower().StartsWith("/c"))
            {
                SaverSettings settings = new SaverSettings();
                if (settings.Load())
                {
                    (new SettingsWindow(settings)).Show();
                }
                else
                {
                    (new SettingsWindow()).Show();
                }
            }
            // If not running in one of the sanctioned modes, shut down the app
            // immediately (because we don't have a GUI).
            else
            {
                System.Environment.Exit(1);
            }
        }
Пример #2
0
        public MainWindow(SaverSettings settings)
            : this()
        {
            this.slideshowSpeed = (int)(settings.SlideShowSpeed * 1000);
            this.transitionSpeed = (int)(settings.TransitionSpeed * 1000);
            this.transitionsToUse = settings.Transitions;
            this.useTransitions = settings.UseTransitions;

            if (transitionsToUse.Count == 0)
                this.useTransitions = false;
        }
Пример #3
0
        public MainWindow(SaverSettings settings)
            : this()
        {
            this.slideshowSpeed   = (int)(settings.SlideShowSpeed * 1000);
            this.transitionSpeed  = (int)(settings.TransitionSpeed * 1000);
            this.transitionsToUse = settings.Transitions;
            this.useTransitions   = settings.UseTransitions;

            if (transitionsToUse.Count == 0)
            {
                this.useTransitions = false;
            }
        }
Пример #4
0
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            // Preview mode--display in little window in Screen Saver dialog
            // (Not invoked with Preview button, which runs Screen Saver in
            // normal /s mode).
            if (e.Args[0].ToLower().StartsWith("/p"))
            {
                System.Environment.Exit(1);
            }
            // Normal screensaver mode.  Either screen saver kicked in normally,
            // or was launched from Preview button
            else if (e.Args[0].ToLower().StartsWith("/s"))
            {
                foreach (Screen s in Screen.AllScreens)
                {
                    if (s != Screen.PrimaryScreen)
                    {
                        Blackout blackOut = new Blackout();
                        blackOut.Top = s.WorkingArea.Top;
                        blackOut.Left = s.WorkingArea.Left;
                        blackOut.Width = s.WorkingArea.Width;
                        blackOut.Height = s.WorkingArea.Height;
                        blackOut.Show();
                    }
                }

                SaverSettings settings = new SaverSettings();
                if (settings.Load())
                    (new MainWindow(settings)).Show();
                else
                    (new MainWindow()).Show();

            }
            else if (e.Args[0].ToLower().StartsWith("/c"))
            {
                SaverSettings settings = new SaverSettings();
                if (settings.Load())
                    (new SettingsWindow(settings)).Show();
                else
                    (new SettingsWindow()).Show();

            }
            // If not running in one of the sanctioned modes, shut down the app
            // immediately (because we don't have a GUI).
            else
            {
                System.Environment.Exit(1);
            }
        }
Пример #5
0
        public SettingsViewModel(SaverSettings settings)
            : this()
        {
            foreach (TransitionSelection t in Transitions)
            {
                t.IsChecked = false;
            }

            foreach (TransitionName t in settings.Transitions)
            {
                this.Transitions.Where(x => x.Transition == t).First().IsChecked = true;
            }

            this.SlideShowSpeed  = settings.SlideShowSpeed;
            this.TransitionSpeed = settings.TransitionSpeed;
            this.UseTransitions  = settings.UseTransitions;
        }
Пример #6
0
        public SettingsViewModel(SaverSettings settings)
            : this()
        {
            foreach(TransitionSelection t in Transitions)
            {
                t.IsChecked = false;
            }

            foreach (TransitionName t in settings.Transitions)
            {
                this.Transitions.Where(x => x.Transition == t).First().IsChecked = true;
            }

            this.SlideShowSpeed = settings.SlideShowSpeed;
            this.TransitionSpeed = settings.TransitionSpeed;
            this.UseTransitions = settings.UseTransitions;
        }
Пример #7
0
        public bool Load()
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + SaverSettings.SettingsFile;

            if (File.Exists(filePath))
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open))
                {
                    XmlSerializer x  = new XmlSerializer(this.GetType());
                    SaverSettings ss = x.Deserialize(fs) as SaverSettings;

                    this.SlideShowSpeed  = ss.SlideShowSpeed;
                    this.UseTransitions  = ss.UseTransitions;
                    this.TransitionSpeed = ss.TransitionSpeed;
                    this.Transitions     = ss.Transitions;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
 public SettingsWindow(SaverSettings s = null)
 {
     InitializeComponent();
     this.DataContext = s != null ? new SettingsViewModel(s) : new SettingsViewModel();
 }
Пример #9
0
 public SettingsWindow(SaverSettings s = null)
 {
     InitializeComponent();
     this.DataContext = s != null ? new SettingsViewModel(s) : new SettingsViewModel();
 }