Beispiel #1
0
        public ScreensaverForm(ScreenInformation screen)
        {
            _currentURLIndex = 0;

            _closeOnMouseMovement = Preferences.CloseOnMouseMovement;
            _rotationInterval     = screen.RotationInterval;
            _shuffle = screen.Shuffle;
            _urls    = screen.URLs.ToList();

            _savedSize     = new Size(screen.Bounds.Width, screen.Bounds.Height);
            _savedLocation = new Point(screen.Bounds.Left, screen.Bounds.Top);

            Cursor.Hide();
            InitializeComponent();

            // Manually change size and location, since the `InitializeComponent` code tends to get autoreplaced by the Designer
            this.SuspendLayout();
            this._webBrowser.Size     = _savedSize;
            this._webBrowser.Location = _savedLocation;
            this.ClientSize           = _savedSize;
            this.Location             = _savedLocation;
            this.ResumeLayout(false);

            _timer = new Timer();
        }
Beispiel #2
0
        /// <summary>
        /// Saves the selected preferences for a specific screen.
        /// This method must be called by the general Save method of the Preferences window, and must pass each available screen number.
        /// </summary>
        /// <param name="screenNumber">The specific screen number for which these preferences must be saved.</param>
        public void Save(int screenNumber)
        {
            ScreenInformation currentScreen = Preferences.Screens[screenNumber];

            currentScreen.URLs             = (from ListViewItem item in _listViewURLs.Items.Cast <ListViewItem>() select item.Text);
            currentScreen.RotationInterval = (int)_numericUpDownRotationInterval.Value;
            currentScreen.Shuffle          = _checkBoxShuffle.Checked;
        }
Beispiel #3
0
        private void RadioButtonMultiScreenMode_Checked(object sender, EventArgs e)
        {
            if (sender is not RadioButton radioButton || !radioButton.Checked)
            {
                return;
            }

            MultiScreenMode multiScreenMode = radioButton.Name switch
            {
                nameof(_radioButtonMirrorScreens) => MultiScreenMode.Mirror,
                nameof(_radioButtonSeparateScreens) => MultiScreenMode.Separate,
                nameof(_radioButtonSpanScreens) => MultiScreenMode.Span,
                _ => throw new IndexOutOfRangeException("Unexpected radio button."),
            };

            // Save it to the registry
            Preferences.MultiScreen = multiScreenMode;

            int totalTabs = multiScreenMode switch
            {
                MultiScreenMode.Mirror or MultiScreenMode.Span => 1,
                MultiScreenMode.Separate => Screen.AllScreens.Length,
                _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.")
            };

            string tabTextSuffix = multiScreenMode switch
            {
                MultiScreenMode.Mirror => " (Mirror)",
                MultiScreenMode.Span => " (Composite)",
                MultiScreenMode.Separate => "",
                _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.")
            };

            _tabControlScreens.TabPages.Clear();

            for (int tabNumber = 0; tabNumber < totalTabs; tabNumber++)
            {
                TabPage tab = new TabPage
                {
                    Text = $"Display {tabNumber + 1}{tabTextSuffix}" // Matches registry key name
                };

                var currentUserControl = new PrefsByScreenUserControl
                {
                    AutoSize  = true,
                    BackColor = Color.White,
                    Dock      = DockStyle.Fill,
                    Name      = $"_prefsByScreenUserControl{tabNumber}",
                    TabIndex  = 5
                };

                ScreenInformation currentScreen = Preferences.Screens[tabNumber];

                foreach (string url in currentScreen.URLs)
                {
                    currentUserControl._listViewURLs.Items.Add(url);
                }

                currentUserControl._numericUpDownRotationInterval.Value = currentScreen.RotationInterval;
                currentUserControl._checkBoxShuffle.Checked             = currentScreen.Shuffle;

                tab.Controls.Add(currentUserControl);
                _tabControlScreens.TabPages.Add(tab);
            }
        }