From ab7b53b33f136f77fffb38b6f236856ae22004a4 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez <1175054+carlossanlop@users.noreply.github.com> Date: Tue, 19 Mar 2019 20:51:09 -0700 Subject: [PATCH 01/45] Fixing a crash and a UI issue PrefsByScreenUserControl does not have the correct size to show all the buttons at the same time when inside PreferencesForm. I am facing this issue in a high resolution screen in Windows 10. I fixed it by making sure the sizes are exact. I also made sure that the sub-form would stay in the same place when switching tabs. --- PreferencesForm.Designer.cs | 78 ++++++++++++++-------------- PreferencesForm.cs | 33 +++++++----- PrefsByScreenUserControl.Designer.cs | 50 +++++++++--------- 3 files changed, 83 insertions(+), 78 deletions(-) diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index ee7e032..652ad52 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -54,20 +54,18 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(101, 11); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(76, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(158, 17); + this.label1.Size = new System.Drawing.Size(121, 13); this.label1.TabIndex = 0; this.label1.Text = "Web Page Screensaver"; // // llProjectLocationUrl // this.llProjectLocationUrl.AutoSize = true; - this.llProjectLocationUrl.Location = new System.Drawing.Point(29, 31); - this.llProjectLocationUrl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.llProjectLocationUrl.Location = new System.Drawing.Point(22, 25); this.llProjectLocationUrl.Name = "llProjectLocationUrl"; - this.llProjectLocationUrl.Size = new System.Drawing.Size(293, 17); + this.llProjectLocationUrl.Size = new System.Drawing.Size(233, 13); this.llProjectLocationUrl.TabIndex = 1; this.llProjectLocationUrl.TabStop = true; this.llProjectLocationUrl.Text = "http://github.com/cwc/web-page-screensaver/"; @@ -77,10 +75,9 @@ private void InitializeComponent() // this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(127, 441); - this.okButton.Margin = new System.Windows.Forms.Padding(4); + this.okButton.Location = new System.Drawing.Point(115, 404); this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(100, 28); + this.okButton.Size = new System.Drawing.Size(75, 23); this.okButton.TabIndex = 4; this.okButton.Text = "OK"; this.okButton.UseVisualStyleBackColor = true; @@ -90,10 +87,9 @@ private void InitializeComponent() // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(235, 441); - this.cancelButton.Margin = new System.Windows.Forms.Padding(4); + this.cancelButton.Location = new System.Drawing.Point(196, 404); this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(100, 28); + this.cancelButton.Size = new System.Drawing.Size(75, 23); this.cancelButton.TabIndex = 5; this.cancelButton.Text = "Cancel"; this.cancelButton.UseVisualStyleBackColor = true; @@ -105,10 +101,9 @@ private void InitializeComponent() this.cbCloseOnActivity.AutoSize = true; this.cbCloseOnActivity.Checked = true; this.cbCloseOnActivity.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbCloseOnActivity.Location = new System.Drawing.Point(20, 411); - this.cbCloseOnActivity.Margin = new System.Windows.Forms.Padding(4); + this.cbCloseOnActivity.Location = new System.Drawing.Point(15, 381); this.cbCloseOnActivity.Name = "cbCloseOnActivity"; - this.cbCloseOnActivity.Size = new System.Drawing.Size(200, 21); + this.cbCloseOnActivity.Size = new System.Drawing.Size(153, 17); this.cbCloseOnActivity.TabIndex = 6; this.cbCloseOnActivity.Text = "Close on mouse movement"; this.cbCloseOnActivity.UseVisualStyleBackColor = true; @@ -119,19 +114,21 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.screenTabControl.Controls.Add(this.screenTabPage1); - this.screenTabControl.Location = new System.Drawing.Point(20, 119); + this.screenTabControl.Location = new System.Drawing.Point(15, 97); + this.screenTabControl.Margin = new System.Windows.Forms.Padding(2); this.screenTabControl.Name = "screenTabControl"; this.screenTabControl.SelectedIndex = 0; - this.screenTabControl.Size = new System.Drawing.Size(319, 271); + this.screenTabControl.Size = new System.Drawing.Size(261, 279); this.screenTabControl.TabIndex = 13; // // screenTabPage1 // this.screenTabPage1.Controls.Add(this.prefsByScreenUserControl1); - this.screenTabPage1.Location = new System.Drawing.Point(4, 25); + this.screenTabPage1.Location = new System.Drawing.Point(4, 22); + this.screenTabPage1.Margin = new System.Windows.Forms.Padding(2); this.screenTabPage1.Name = "screenTabPage1"; - this.screenTabPage1.Padding = new System.Windows.Forms.Padding(3); - this.screenTabPage1.Size = new System.Drawing.Size(311, 242); + this.screenTabPage1.Padding = new System.Windows.Forms.Padding(2); + this.screenTabPage1.Size = new System.Drawing.Size(253, 253); this.screenTabPage1.TabIndex = 0; this.screenTabPage1.Text = "Screen 1"; this.screenTabPage1.UseVisualStyleBackColor = true; @@ -143,17 +140,19 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.prefsByScreenUserControl1.BackColor = System.Drawing.Color.White; this.prefsByScreenUserControl1.Location = new System.Drawing.Point(0, 0); + this.prefsByScreenUserControl1.Margin = new System.Windows.Forms.Padding(0); this.prefsByScreenUserControl1.Name = "prefsByScreenUserControl1"; - this.prefsByScreenUserControl1.Size = new System.Drawing.Size(312, 242); + this.prefsByScreenUserControl1.Size = new System.Drawing.Size(253, 254); this.prefsByScreenUserControl1.TabIndex = 21; // // spanScreensButton // this.spanScreensButton.AutoSize = true; this.spanScreensButton.Checked = true; - this.spanScreensButton.Location = new System.Drawing.Point(100, 10); + this.spanScreensButton.Location = new System.Drawing.Point(75, 8); + this.spanScreensButton.Margin = new System.Windows.Forms.Padding(2); this.spanScreensButton.Name = "spanScreensButton"; - this.spanScreensButton.Size = new System.Drawing.Size(62, 21); + this.spanScreensButton.Size = new System.Drawing.Size(50, 17); this.spanScreensButton.TabIndex = 14; this.spanScreensButton.TabStop = true; this.spanScreensButton.Tag = "MultiScreenMode"; @@ -165,9 +164,10 @@ private void InitializeComponent() // separateScreensButton // this.separateScreensButton.AutoSize = true; - this.separateScreensButton.Location = new System.Drawing.Point(238, 10); + this.separateScreensButton.Location = new System.Drawing.Point(178, 8); + this.separateScreensButton.Margin = new System.Windows.Forms.Padding(2); this.separateScreensButton.Name = "separateScreensButton"; - this.separateScreensButton.Size = new System.Drawing.Size(87, 21); + this.separateScreensButton.Size = new System.Drawing.Size(68, 17); this.separateScreensButton.TabIndex = 15; this.separateScreensButton.TabStop = true; this.separateScreensButton.Tag = "MultiScreenMode"; @@ -179,29 +179,28 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(4, 12); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Location = new System.Drawing.Point(3, 10); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(84, 17); + this.label4.Size = new System.Drawing.Size(64, 13); this.label4.TabIndex = 16; this.label4.Text = "Multiscreen:"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(16, 97); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(12, 79); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(98, 17); + this.label2.Size = new System.Drawing.Size(76, 13); this.label2.TabIndex = 2; this.label2.Text = "Website URLs"; // // mirrorScreensButton // this.mirrorScreensButton.AutoSize = true; - this.mirrorScreensButton.Location = new System.Drawing.Point(168, 10); + this.mirrorScreensButton.Location = new System.Drawing.Point(126, 8); + this.mirrorScreensButton.Margin = new System.Windows.Forms.Padding(2); this.mirrorScreensButton.Name = "mirrorScreensButton"; - this.mirrorScreensButton.Size = new System.Drawing.Size(66, 21); + this.mirrorScreensButton.Size = new System.Drawing.Size(51, 17); this.mirrorScreensButton.TabIndex = 17; this.mirrorScreensButton.TabStop = true; this.mirrorScreensButton.Tag = "MultiScreenMode"; @@ -216,19 +215,21 @@ private void InitializeComponent() this.multiScreenGroup.Controls.Add(this.mirrorScreensButton); this.multiScreenGroup.Controls.Add(this.spanScreensButton); this.multiScreenGroup.Controls.Add(this.separateScreensButton); - this.multiScreenGroup.Location = new System.Drawing.Point(20, 56); + this.multiScreenGroup.Location = new System.Drawing.Point(15, 46); + this.multiScreenGroup.Margin = new System.Windows.Forms.Padding(2); this.multiScreenGroup.Name = "multiScreenGroup"; - this.multiScreenGroup.Size = new System.Drawing.Size(326, 34); + this.multiScreenGroup.Padding = new System.Windows.Forms.Padding(2); + this.multiScreenGroup.Size = new System.Drawing.Size(258, 28); this.multiScreenGroup.TabIndex = 18; this.multiScreenGroup.TabStop = false; // // PreferencesForm // this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(360, 478); + this.ClientSize = new System.Drawing.Size(292, 434); this.Controls.Add(this.multiScreenGroup); this.Controls.Add(this.screenTabControl); this.Controls.Add(this.cbCloseOnActivity); @@ -237,10 +238,9 @@ private void InitializeComponent() this.Controls.Add(this.label2); this.Controls.Add(this.llProjectLocationUrl); this.Controls.Add(this.label1); - this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(378, 428); + this.MinimumSize = new System.Drawing.Size(288, 355); this.Name = "PreferencesForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; diff --git a/PreferencesForm.cs b/PreferencesForm.cs index 5c63c85..3c43c1a 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -14,7 +14,8 @@ public partial class PreferencesForm : Form { private PreferencesManager prefsManager = new PreferencesManager(); - private List screenUserControls; + // Need to initialize in advance to prevent crashes when retrieving screenUserControls by index (LoadValuesForTab or ReadBackValuesFromUI) + private List screenUserControls = new List(); public PreferencesForm() { @@ -39,7 +40,7 @@ private void PreferencesForm_Load(object sender, EventArgs e) private void LoadValuesForTab(int screenNum) { var currentPrefsUserControl = screenUserControls[screenNum]; - loadUrlsForTabToControl(screenNum, currentPrefsUserControl); + LoadUrlsForTabToControl(screenNum, currentPrefsUserControl); currentPrefsUserControl.nudRotationInterval.Value = prefsManager.GetRotationIntervalByScreen(screenNum); currentPrefsUserControl.cbRandomize.Checked = prefsManager.GetRandomizeFlagByScreen(screenNum); } @@ -51,13 +52,17 @@ private void ArrangeScreenTabs() case PreferencesManager.MultiScreenModeItem.Span: RemoveExtraTabPages(); screenTabControl.TabPages[0].Text = "Composite Screen"; - screenUserControls = new List() { prefsByScreenUserControl1 }; + // Need to clear because we only expect one tab + screenUserControls.Clear(); + screenUserControls.Add(prefsByScreenUserControl1); LoadValuesForTab(0); break; case PreferencesManager.MultiScreenModeItem.Mirror: RemoveExtraTabPages(); screenTabControl.TabPages[0].Text = "Each Screen"; - screenUserControls = new List() { prefsByScreenUserControl1 }; + // Need to clear because we only expect one tab + screenUserControls.Clear(); + screenUserControls.Add(prefsByScreenUserControl1); LoadValuesForTab(0); break; case PreferencesManager.MultiScreenModeItem.Separate: @@ -75,13 +80,14 @@ private void ArrangeScreenTabs() var prefsByScreenUserControl = new PrefsByScreenUserControl { Name = string.Format("prefsByScreenUserControl{0}", i + 1), - Location = new Point(0, 0), //prefsByScreenUserControl1.Location, + Location = new Point(0, 0), Size = prefsByScreenUserControl1.Size, Anchor = prefsByScreenUserControl1.Anchor, BackColor = prefsByScreenUserControl1.BackColor }; prefsByScreenUserControl.lvUrls.ContextMenuStrip = prefsByScreenUserControl1.ContextMenuStrip; + // No need to clear because we are re-adding the missing tabs screenUserControls.Add(prefsByScreenUserControl); tabPage.Controls.Add(prefsByScreenUserControl); } @@ -89,8 +95,9 @@ private void ArrangeScreenTabs() else if (screenTabControl.TabPages.Count == 1) { tabPage = screenTabControl.TabPages[0]; - screenUserControls = - new List() { prefsByScreenUserControl1 }; + // Clearing before adding prevents a crash when going from Separate to Mirror and back to Separate + screenUserControls.Clear(); + screenUserControls.Add(prefsByScreenUserControl1); } LoadValuesForTab(i); @@ -127,7 +134,7 @@ private void SetMultiScreenButtonFromMode() } } - private void setMultiScreenModeFromButtonState() + private void SetMultiScreenModeFromButtonState() { if (spanScreensButton.Checked) { @@ -145,7 +152,7 @@ private void setMultiScreenModeFromButtonState() prefsManager.ResetEffectiveScreensList(); } - private void readBackValuesFromUI() + private void ReadBackValuesFromUI() { for (var i = 0; i < screenUserControls.Count; i++) { @@ -160,7 +167,7 @@ private void readBackValuesFromUI() } } - private void loadUrlsForTabToControl(int screenNum, PrefsByScreenUserControl currentPrefsUserControl) + private void LoadUrlsForTabToControl(int screenNum, PrefsByScreenUserControl currentPrefsUserControl) { currentPrefsUserControl.lvUrls.Items.Clear(); @@ -176,7 +183,7 @@ protected override void OnClosed(EventArgs e) { if (DialogResult == DialogResult.OK) { - readBackValuesFromUI(); + ReadBackValuesFromUI(); prefsManager.SavePreferences(); } @@ -200,8 +207,8 @@ private void cancelButton_Click(object sender, EventArgs e) private void anyMultiScreenModeButton_Click(object sender, EventArgs e) { - readBackValuesFromUI(); - setMultiScreenModeFromButtonState(); + ReadBackValuesFromUI(); + SetMultiScreenModeFromButtonState(); ArrangeScreenTabs(); } } diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index d58b32e..f7fdd7f 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -44,15 +44,14 @@ private void InitializeComponent() // nudRotationInterval // this.nudRotationInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.nudRotationInterval.Location = new System.Drawing.Point(10, 275); - this.nudRotationInterval.Margin = new System.Windows.Forms.Padding(4); + this.nudRotationInterval.Location = new System.Drawing.Point(9, 220); this.nudRotationInterval.Maximum = new decimal(new int[] { 999, 0, 0, 0}); this.nudRotationInterval.Name = "nudRotationInterval"; - this.nudRotationInterval.Size = new System.Drawing.Size(53, 22); + this.nudRotationInterval.Size = new System.Drawing.Size(40, 20); this.nudRotationInterval.TabIndex = 6; this.nudRotationInterval.Value = new decimal(new int[] { 30, @@ -64,10 +63,9 @@ private void InitializeComponent() // this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(71, 277); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(55, 222); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(188, 17); + this.label3.Size = new System.Drawing.Size(142, 13); this.label3.TabIndex = 7; this.label3.Text = "Seconds to display each site"; // @@ -75,24 +73,24 @@ private void InitializeComponent() // this.cbRandomize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.cbRandomize.AutoSize = true; - this.cbRandomize.Location = new System.Drawing.Point(10, 247); - this.cbRandomize.Margin = new System.Windows.Forms.Padding(4); + this.cbRandomize.Location = new System.Drawing.Point(10, 195); this.cbRandomize.Name = "cbRandomize"; - this.cbRandomize.Size = new System.Drawing.Size(160, 21); + this.cbRandomize.Size = new System.Drawing.Size(121, 17); this.cbRandomize.TabIndex = 5; this.cbRandomize.Text = "Shuffle display order"; this.cbRandomize.UseVisualStyleBackColor = true; // // lvUrls // - this.lvUrls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.lvUrls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lvUrls.HideSelection = false; this.lvUrls.LabelEdit = true; - this.lvUrls.Location = new System.Drawing.Point(3, 3); + this.lvUrls.Location = new System.Drawing.Point(10, 10); + this.lvUrls.Margin = new System.Windows.Forms.Padding(2); this.lvUrls.Name = "lvUrls"; - this.lvUrls.Size = new System.Drawing.Size(272, 187); + this.lvUrls.Size = new System.Drawing.Size(230, 150); this.lvUrls.TabIndex = 0; this.lvUrls.UseCompatibleStateImageBehavior = false; this.lvUrls.View = System.Windows.Forms.View.List; @@ -100,10 +98,10 @@ private void InitializeComponent() // addUrlButton // this.addUrlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.addUrlButton.Location = new System.Drawing.Point(3, 197); - this.addUrlButton.Margin = new System.Windows.Forms.Padding(4); + this.addUrlButton.Location = new System.Drawing.Point(9, 165); + this.addUrlButton.Margin = new System.Windows.Forms.Padding(0); this.addUrlButton.Name = "addUrlButton"; - this.addUrlButton.Size = new System.Drawing.Size(77, 28); + this.addUrlButton.Size = new System.Drawing.Size(50, 25); this.addUrlButton.TabIndex = 11; this.addUrlButton.Text = "Add"; this.addUrlButton.UseVisualStyleBackColor = true; @@ -113,10 +111,10 @@ private void InitializeComponent() // this.upButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.upButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.upButton.Location = new System.Drawing.Point(251, 197); + this.upButton.Location = new System.Drawing.Point(190, 165); this.upButton.Margin = new System.Windows.Forms.Padding(0); this.upButton.Name = "upButton"; - this.upButton.Size = new System.Drawing.Size(24, 28); + this.upButton.Size = new System.Drawing.Size(25, 25); this.upButton.TabIndex = 3; this.upButton.Text = "▲"; this.urlButtonsTooltip.SetToolTip(this.upButton, "Move selected URLs up"); @@ -127,10 +125,10 @@ private void InitializeComponent() // this.downButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.downButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.downButton.Location = new System.Drawing.Point(251, 225); + this.downButton.Location = new System.Drawing.Point(215, 165); this.downButton.Margin = new System.Windows.Forms.Padding(0); this.downButton.Name = "downButton"; - this.downButton.Size = new System.Drawing.Size(24, 28); + this.downButton.Size = new System.Drawing.Size(25, 25); this.downButton.TabIndex = 12; this.downButton.Text = "▼"; this.urlButtonsTooltip.SetToolTip(this.downButton, "Move selected URLs down"); @@ -139,13 +137,12 @@ private void InitializeComponent() // // deleteButton // - this.deleteButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.deleteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.deleteButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.deleteButton.ForeColor = System.Drawing.Color.Red; - this.deleteButton.Location = new System.Drawing.Point(146, 197); - this.deleteButton.Margin = new System.Windows.Forms.Padding(0); + this.deleteButton.Location = new System.Drawing.Point(59, 165); this.deleteButton.Name = "deleteButton"; - this.deleteButton.Size = new System.Drawing.Size(24, 28); + this.deleteButton.Size = new System.Drawing.Size(25, 25); this.deleteButton.TabIndex = 13; this.deleteButton.Text = "X"; this.urlButtonsTooltip.SetToolTip(this.deleteButton, "DELETE selected URLs"); @@ -154,7 +151,7 @@ private void InitializeComponent() // // PrefsByScreenUserControl // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.Controls.Add(this.deleteButton); @@ -165,8 +162,9 @@ private void InitializeComponent() this.Controls.Add(this.cbRandomize); this.Controls.Add(this.lvUrls); this.Controls.Add(this.addUrlButton); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "PrefsByScreenUserControl"; - this.Size = new System.Drawing.Size(279, 309); + this.Size = new System.Drawing.Size(250, 250); ((System.ComponentModel.ISupportInitialize)(this.nudRotationInterval)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); From b6bf0f9ed9c25710869c544d177241137ee00fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= Date: Wed, 20 Mar 2019 19:25:52 -0700 Subject: [PATCH 02/45] Fix crash I realized that when the user has multiple monitors, but then changes to 1 monitor, the preferences form shows the single screen tab list empty, instead of showing all the previously saved websites. By moving two function calls inside PreferencesForm_Load outside the if/else, we ensure that switching from 1 to multi monitors, and back, will always show the expected list of pages in the expected tabs. --- PreferencesForm.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PreferencesForm.cs b/PreferencesForm.cs index 3c43c1a..a394667 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -32,9 +32,9 @@ private void PreferencesForm_Load(object sender, EventArgs e) else { multiScreenGroup.Enabled = true; - SetMultiScreenButtonFromMode(); - ArrangeScreenTabs(); } + SetMultiScreenButtonFromMode(); + ArrangeScreenTabs(); } private void LoadValuesForTab(int screenNum) From f6474682a2719183ad048170c5960a25ce57bd64 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:00:05 -0700 Subject: [PATCH 03/45] Delete unnecessary files. --- .hgignore | 4 -- Properties/AssemblyInfo.cs | 36 ---------- Properties/Resources.Designer.cs | 63 ----------------- Properties/Resources.resx | 117 ------------------------------- Properties/Settings.Designer.cs | 26 ------- Properties/Settings.settings | 7 -- app.config | 3 - 7 files changed, 256 deletions(-) delete mode 100644 .hgignore delete mode 100644 Properties/AssemblyInfo.cs delete mode 100644 Properties/Resources.Designer.cs delete mode 100644 Properties/Resources.resx delete mode 100644 Properties/Settings.Designer.cs delete mode 100644 Properties/Settings.settings delete mode 100644 app.config diff --git a/.hgignore b/.hgignore deleted file mode 100644 index f6552a8..0000000 --- a/.hgignore +++ /dev/null @@ -1,4 +0,0 @@ -relre:bin/ -relre:obj/ -glob:Web-Page-Screensaver.csproj.user -glob:Web-Page-Screensaver.suo diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs deleted file mode 100644 index 702d1e3..0000000 --- a/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Web-Page-Screensaver")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Web-Page-Screensaver")] -[assembly: AssemblyCopyright("Copyright © 2010")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("07b0594f-48cb-454d-bc88-116fe5170e3c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs deleted file mode 100644 index fdca2fd..0000000 --- a/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Web_Page_Screensaver.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Web_Page_Screensaver.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Properties/Resources.resx b/Properties/Resources.resx deleted file mode 100644 index ffecec8..0000000 --- a/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs deleted file mode 100644 index 3455aec..0000000 --- a/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Web_Page_Screensaver.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/Properties/Settings.settings b/Properties/Settings.settings deleted file mode 100644 index abf36c5..0000000 --- a/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/app.config b/app.config deleted file mode 100644 index fcd0c93..0000000 --- a/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - From 57967cf4acbccc7f5c912ce723a43a5f6a1cb2f7 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:01:16 -0700 Subject: [PATCH 04/45] csproj upgrade to .NET 5.0, remove name dashes. --- Web-Page-Screensaver.csproj | 141 ------------------------------------ WebPageScreensaver.csproj | 22 ++++++ 2 files changed, 22 insertions(+), 141 deletions(-) delete mode 100644 Web-Page-Screensaver.csproj create mode 100644 WebPageScreensaver.csproj diff --git a/Web-Page-Screensaver.csproj b/Web-Page-Screensaver.csproj deleted file mode 100644 index 7fdcffd..0000000 --- a/Web-Page-Screensaver.csproj +++ /dev/null @@ -1,141 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F} - WinExe - Properties - Web_Page_Screensaver - Web-Page-Screensaver - v4.0 - 512 - - - - - 3.5 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - true - bin\Settings\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Debug-Prefs\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - - - - - - - - Form - - - PreferencesForm.cs - - - UserControl - - - PrefsByScreenUserControl.cs - - - Form - - - ScreensaverForm.cs - - - - - PreferencesForm.cs - - - PrefsByScreenUserControl.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - Designer - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - if $(ConfigurationName) == Release move $(TargetPath) $(TargetDir)$(TargetName).scr - - - \ No newline at end of file diff --git a/WebPageScreensaver.csproj b/WebPageScreensaver.csproj new file mode 100644 index 0000000..caf4cb0 --- /dev/null +++ b/WebPageScreensaver.csproj @@ -0,0 +1,22 @@ + + + + WinExe + net5.0 + true + enable + WebPageScreensaver.Program + WebPageScreensaver + WebPageScreensaver + 2.0.0 + + + + + + + + + + + From 3bdff09ab2fd82c46fdc11fae36491dc41394c18 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:01:41 -0700 Subject: [PATCH 05/45] sln upgrade and remove name dashes. --- ...-Screensaver.sln => WebPageScreensaver.sln | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) rename Web-Page-Screensaver.sln => WebPageScreensaver.sln (53%) diff --git a/Web-Page-Screensaver.sln b/WebPageScreensaver.sln similarity index 53% rename from Web-Page-Screensaver.sln rename to WebPageScreensaver.sln index 78c42bb..bc48d2b 100644 --- a/Web-Page-Screensaver.sln +++ b/WebPageScreensaver.sln @@ -1,28 +1,25 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web-Page-Screensaver", "Web-Page-Screensaver.csproj", "{3E640398-E4D5-4AC8-A200-7AD96E7CC77F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug-Prefs|Any CPU = Debug-Prefs|Any CPU - Release|Any CPU = Release|Any CPU - Settings|Any CPU = Settings|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug-Prefs|Any CPU.ActiveCfg = Debug-Prefs|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug-Prefs|Any CPU.Build.0 = Debug-Prefs|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.Build.0 = Release|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Settings|Any CPU.ActiveCfg = Settings|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Settings|Any CPU.Build.0 = Settings|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28705.295 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebPageScreensaver", "WebPageScreensaver.csproj", "{3E640398-E4D5-4AC8-A200-7AD96E7CC77F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A5437866-76AE-4B0D-AE55-81697D5D1414} + EndGlobalSection +EndGlobal From e7d391ea7cc9af048340d20f17a2d0b4573ee562 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:02:02 -0700 Subject: [PATCH 06/45] .gitignore simplify. --- .gitignore | 198 +---------------------------------------------------- 1 file changed, 3 insertions(+), 195 deletions(-) diff --git a/.gitignore b/.gitignore index 2c70369..ab73c76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,196 +1,4 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo +.vs +bin/ +obj/ *.user -*.sln.docstates - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -x64/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Roslyn cache directories -*.ide/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -#NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -## TODO: Comment the next line if you want to checkin your -## web deploy settings but do note that will include unencrypted -## passwords -#*.pubxml - -# NuGet Packages Directory -packages/* -## TODO: If the tool you use requires repositories.config -## uncomment the next line -#!packages/repositories.config - -# Enable "build/" folder in the NuGet Packages folder since -# NuGet packages use it for MSBuild targets. -# This line needs to be after the ignore of the build folder -# (and the packages folder if the line above has been uncommented) -!packages/build/ - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml - -Thumbs.db -/.vs -/.vs -/.vs/slnx.sqlite -/.vs/ProjectSettings.json From 53a0656b5e96d61a22aa4604203c71aebf5643ba Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:02:24 -0700 Subject: [PATCH 07/45] launchSettings.json add new file. --- Properties/launchSettings.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Properties/launchSettings.json diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..87a61df --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "WebPageScreensaver": { + "commandName": "Project", + "commandLineArgs": "/c" + } + } +} \ No newline at end of file From 44660af1c87d318b564df255dbc3418a396d0b94 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:05:49 -0700 Subject: [PATCH 08/45] .reg rename regkey (remove dashes), simplify URLs. --- PreUpgradePrefs.reg | Bin 896 -> 538 bytes ThreeScreensSetUp.reg | Bin 2030 -> 1014 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/PreUpgradePrefs.reg b/PreUpgradePrefs.reg index 6751843569d05f8e10b78b23ef94dfaaf3c441df..8c9e5ce479fc52c52a2d34a97b655766785e60f5 100644 GIT binary patch delta 171 zcmZo*pT#m^0($^MB11Yu>crW``o#=Z4EjKr!jR8U!jQ+13MBOyav3rik{ODCV#Pq5 z1{O;OvT`RIG6@@|17%AXG8jr3l7MQ#;%Fx51ND{yO)CMa%wCy(NO97g%$4~|o ZEe6UbGUNd15+ExDD3XsbYw|;;`2ccJB=!IR literal 896 zcma)*SxduE5QWdP;D0Cuee0s2pdeC;lpxo1gFV9g`A!OCD@Gg#HL%AbQW zCr7MjqO2bc*UJ`}Q%;L0v)Vg#m?N-z=tIt!&PSlf+{-DJ6_4nPN6eEBiLp7%@d(fq zbhWKbWY6`a)NE)Q?ceNdmg!d|&5G9xNRwav`d=Mg>KIZ%$5mpF diff --git a/ThreeScreensSetUp.reg b/ThreeScreensSetUp.reg index 0b69bc91e7c4d8e650449b354fe99f19c23af84d..7fb1ccf2ce8d85e563cb2ac37aba6c622c9b27ee 100644 GIT binary patch delta 173 zcmaFI|BZdZ1oi-iM22*R)QPh`0xmmzg>BD1k3NL>oh i4n2l4plC5rK9L~@NS6RvDL|2Ym{~x3%qRa~`vw5$yDIGf literal 2030 zcmeH|U27Uq5QgWv(ElJpy%9hAMGK)=X{i*`u*Qbc7Fl(p;<}owQS#^8KJVFGW7Wj; zz8p55GiToOu@52w7}PyS7^-AGn=xnsd(CSMIO5op6pg zzqGPdSx@bW`@Y*J`;5&u>siyf;CY-*?VNMhI_y3B!SCEI!CadUT7cw&zkMs&8IlqE z5;_BS7vLvGx^kX>Ixl&!Loi}wU$}3eyCkNSi}cp=cEWd#{S6xV)TYfTbb8y^ZE%K8 zOEw*L3m27-=ACU9tnjaxs;QSTdP{8HT7@+uh6Q*L+1wCK$X@)^xNEWAoBTyCPBAL> zN8pO#0G*s=cyWptAy;k6=*?LpFau5l_A`Ec{8TnMdPtYZ#D@H|_=J2-T>ilfhM+5w zA^sHU-SSi3JS>wQnZdR+g}2RN#>GeHLsiK*-{-A%kheY_#QXsNuj~yO4ajstAM_nZ z6;~N$A>U^%;w7x?^A&>6RYMir-7;bH+`?z4}t`UsGbA?=}6iKGL1)2yr%W{HdaA zSgSETo>T3DtMM4gYkR?0z+0axoZwxZU$86oVzkbj7&DcGpgv4wMY__nVtQ(GQzS>l zK0Tg~ID9`@RVJ-xGJx@a%`=*M*@WDmrpG67HdS_QmCqj$ C!cUn1 From 6c19cb8d7705dd55914b982cb4c93737485ff3cf Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:17:03 -0700 Subject: [PATCH 09/45] Program.cs Sort and remove usings. Rename namespace. Fix a nullability issue. Add SetHighDpiMode call, which is added by default in new WinForms apps. Use ToUpperInvariant to check arguments. Clean spaces. --- Program.cs | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/Program.cs b/Program.cs index 577a025..3a9cfbc 100644 --- a/Program.cs +++ b/Program.cs @@ -1,31 +1,42 @@ -using System; -using System.Windows.Forms; -using Microsoft.Win32; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Drawing; using System.IO; +using System.Windows.Forms; -namespace pl.polidea.lab.Web_Page_Screensaver +namespace WebPageScreensaver { - using System.Collections.Generic; - using System.Drawing; - static class Program { - public static readonly string KEY = "Software\\Web-Page-Screensaver"; + public const string KeyWebPageScreensaver = @"Software\WebPageScreensaver"; + private const string KeyBrowserEmulation = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; + + /// + /// The main entry point for the application. + /// [STAThread] static void Main(string[] args) { - // Set version of embedded browser (http://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version) - var exeName = Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); - Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", exeName, 0x2AF8, RegistryValueKind.DWord); + var mainModule = System.Diagnostics.Process.GetCurrentProcess().MainModule; + if (mainModule == null) + { + throw new NullReferenceException("Current process main module is null."); + } + + var exeName = Path.GetFileName(mainModule.FileName); + Registry.SetValue(KeyBrowserEmulation, exeName, 0x2AF8, RegistryValueKind.DWord); + + Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - if (args.Length > 0 && args[0].ToLower().Contains("/p")) + if (args.Length > 0 && args[0].ToUpperInvariant().Equals("/P")) return; - if (args.Length > 0 && args[0].ToLower().Contains("/c")) + if (args.Length > 0 && args[0].ToUpperInvariant().Equals("/C")) { Application.Run(new PreferencesForm()); } @@ -41,8 +52,6 @@ static void Main(string[] args) Size = new Size(screen.Bounds.Width, screen.Bounds.Height) }; - FormStartPosition x = screensaverForm.StartPosition; - formsList.Add(screensaverForm); } @@ -59,9 +68,8 @@ public MultiFormContext(List
forms) { form.FormClosed += (s, args) => { - //When we have closed any form, - //end the program. - ExitThread(); + // End program on form close + ExitThread(); }; form.Show(); From 896e06479a30f27237829ca1831951965523a674 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:18:23 -0700 Subject: [PATCH 10/45] PreferencesForm.cs Sort and remove usings. Rename namespace. --- PreferencesForm.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/PreferencesForm.cs b/PreferencesForm.cs index a394667..9e72b2a 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -1,15 +1,11 @@ using System; +using System.Collections.Generic; +using System.Drawing; using System.Linq; -using Microsoft.Win32; using System.Windows.Forms; -namespace pl.polidea.lab.Web_Page_Screensaver +namespace WebPageScreensaver { - using System.Collections.Generic; - using System.Drawing; - - using global::Web_Page_Screensaver; - public partial class PreferencesForm : Form { private PreferencesManager prefsManager = new PreferencesManager(); @@ -68,7 +64,7 @@ private void ArrangeScreenTabs() case PreferencesManager.MultiScreenModeItem.Separate: for (int i = 0; i < Screen.AllScreens.Length; i++) { - TabPage tabPage = null; + TabPage tabPage = null; if (i >= screenTabControl.TabPages.Count) { @@ -105,7 +101,7 @@ private void ArrangeScreenTabs() if (Screen.AllScreens[i].Primary) primaryIndicator = " (main)"; tabPage.Text = string.Format("Screen {0}{1}", i + 1, primaryIndicator); } - + break; } } From 0bfa5bbf24872883da6da9ff865419812beceffc Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:19:26 -0700 Subject: [PATCH 11/45] PreferencesForm.Designer.cs Rename namespace. Remove unnecessary global using. Point default URL to this fork. Spacing. --- PreferencesForm.Designer.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 652ad52..6118883 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -1,7 +1,5 @@ -namespace pl.polidea.lab.Web_Page_Screensaver +namespace WebPageScreensaver { - using global::Web_Page_Screensaver; - partial class PreferencesForm { /// @@ -68,7 +66,7 @@ private void InitializeComponent() this.llProjectLocationUrl.Size = new System.Drawing.Size(233, 13); this.llProjectLocationUrl.TabIndex = 1; this.llProjectLocationUrl.TabStop = true; - this.llProjectLocationUrl.Text = "http://github.com/cwc/web-page-screensaver/"; + this.llProjectLocationUrl.Text = "http://github.com/carlossanlop/web-page-screensaver/"; this.llProjectLocationUrl.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llProjectLocationUrl_LinkClicked); // // okButton @@ -110,8 +108,8 @@ private void InitializeComponent() // // screenTabControl // - this.screenTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.screenTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.screenTabControl.Controls.Add(this.screenTabPage1); this.screenTabControl.Location = new System.Drawing.Point(15, 97); @@ -135,8 +133,8 @@ private void InitializeComponent() // // prefsByScreenUserControl1 // - this.prefsByScreenUserControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.prefsByScreenUserControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.prefsByScreenUserControl1.BackColor = System.Drawing.Color.White; this.prefsByScreenUserControl1.Location = new System.Drawing.Point(0, 0); From d74ed21ad1f29b70de8bafc41daeafcbf05e79c6 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:20:53 -0700 Subject: [PATCH 12/45] PreferencesManager.cs Sort and remove usings, move them to top. Rename namespace. Update reference to regkey in Program. Spacing. --- PreferencesManager.cs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/PreferencesManager.cs b/PreferencesManager.cs index 56a2c79..48b001b 100644 --- a/PreferencesManager.cs +++ b/PreferencesManager.cs @@ -1,14 +1,13 @@ -namespace pl.polidea.lab.Web_Page_Screensaver +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; + +namespace WebPageScreensaver { - using System; - using System.Collections; - using System.Collections.Generic; - using System.Drawing; - using System.Linq; - using System.Windows.Forms; - using Microsoft.Win32; - - public class PreferencesManager + public class PreferencesManager { private const string MULTISCREEN_PREF = "MultiScreenMode"; private const string URL_PREF = "Url"; @@ -25,7 +24,7 @@ public class PreferencesManager private const string RANDOMIZE_PREF_DEFAULT = "False"; private const string CLOSE_ON_ACTIVITY_PREF_DEFAULT = "True"; - private static RegistryKey reg = Registry.CurrentUser.CreateSubKey(Program.KEY); + private static RegistryKey reg = Registry.CurrentUser.CreateSubKey(Program.KeyWebPageScreensaver); public PreferencesManager() { @@ -132,7 +131,7 @@ public List GetUrlsByScreen(int screenNum) // this can happen either due to actual screen removal as noted in the LoadUrlsAllScreens() method, // OR because we are in Span mode, making just one effective screen, // OR we want to treat multiple screens as one (mirror mode). - if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count-1) + if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) { // for the GET operation, the last effective screen has the URLS // for additional screens in prefs appended to it's list. @@ -175,7 +174,7 @@ public void SetUrlsForScreen(int screenNum, List providedUrlsList) urlsList.RemoveRange(0, urlsList.Count); } - int defaultRelativeScreenNumForNewUrls = Math.Max(0, RealPrimaryScreenNum()-startAtScreenNum); + int defaultRelativeScreenNumForNewUrls = Math.Max(0, RealPrimaryScreenNum() - startAtScreenNum); foreach (var url in providedUrlsList) { @@ -195,7 +194,7 @@ public void SetUrlsForScreen(int screenNum, List providedUrlsList) // not found - use default relativeScreenNumForThisUrl = defaultRelativeScreenNumForNewUrls; } - + relativeScreenUrlsList[relativeScreenNumForThisUrl].Add(url); } } @@ -244,7 +243,7 @@ public void SavePreferences() reg.Close(); } - private void LoadPreferences() + private void LoadPreferences() { MultiScreenMode = (MultiScreenModeItem)Enum.Parse(typeof(MultiScreenModeItem), (string)reg.GetValue(MULTISCREEN_PREF, MULTISCREEN_PREF_DEFAULT)); CloseOnActivity = bool.Parse((string)reg.GetValue(CLOSE_ON_ACTIVITY_PREF, CLOSE_ON_ACTIVITY_PREF_DEFAULT)); @@ -268,7 +267,7 @@ private List> LoadUrlsAllScreens() // and SetUrlsByScreen() methods. const string TempDefaultValue = "DEFAULT VALUE"; int i = allUrls.Count; - string nextScreenUrlsPrefResult = LoadPrefByScreen(i, URL_PREF, TempDefaultValue, TempDefaultValue); + string nextScreenUrlsPrefResult = LoadPrefByScreen(i, URL_PREF, TempDefaultValue, TempDefaultValue); while (nextScreenUrlsPrefResult != TempDefaultValue) { allUrls.Add( From 17435ffccb845989dfdb07054ae8848c632cdefc Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:21:35 -0700 Subject: [PATCH 13/45] PrefsByScreenUserControl.cs Rename namespace. Sort and remove usings. --- PrefsByScreenUserControl.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index ca4e4d8..9978f6d 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -1,16 +1,8 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; using System.Windows.Forms; -namespace Web_Page_Screensaver +namespace WebPageScreensaver { - using pl.polidea.lab.Web_Page_Screensaver; - public partial class PrefsByScreenUserControl : UserControl { public PrefsByScreenUserControl() From df668f031ab1e6458f7be16e2dddaecfc0931240 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:22:42 -0700 Subject: [PATCH 14/45] PrefsByScreenUserControl.Designer.cs Rename namespace. Spacing. --- PrefsByScreenUserControl.Designer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index f7fdd7f..3fde513 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -1,4 +1,4 @@ -namespace Web_Page_Screensaver +namespace WebPageScreensaver { partial class PrefsByScreenUserControl { @@ -82,8 +82,8 @@ private void InitializeComponent() // // lvUrls // - this.lvUrls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.lvUrls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lvUrls.HideSelection = false; this.lvUrls.LabelEdit = true; From f64852109d81d289a5e01191fc9414e240ab7e34 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:23:42 -0700 Subject: [PATCH 15/45] ScreensaverForm.cs Sort and remove usings. Rename namespace. Temporarily substitute Navigate call to NavigateToString to prevent build failure. May not be the right call. --- ScreensaverForm.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index 4f63bed..97a531d 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -1,15 +1,11 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; +using System.Diagnostics; using System.Drawing; using System.Linq; -using System.Text; using System.Windows.Forms; -using Microsoft.Win32; -using System.Diagnostics; -namespace pl.polidea.lab.Web_Page_Screensaver +namespace WebPageScreensaver { public partial class ScreensaverForm : Form { @@ -109,7 +105,7 @@ private void BrowseTo(string url) try { Debug.WriteLine($"Navigating: {url}"); - webBrowser.Navigate(url); + webBrowser.NavigateToString(url); // May not be the correct method to call } catch { From 8e66a84e01a8813aba296e52a2d032cef9debb86 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:25:39 -0700 Subject: [PATCH 16/45] ScreensaverForm.Designer.cs Rename namespace. Upgrade obsolete WebBrowser to new WebView2, which is supported in 5.0 and uses Edge. Add BeginInit and EndInit calls for the new WebView2. Spacing. --- ScreensaverForm.Designer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ScreensaverForm.Designer.cs b/ScreensaverForm.Designer.cs index bdec2a6..bf18353 100644 --- a/ScreensaverForm.Designer.cs +++ b/ScreensaverForm.Designer.cs @@ -1,4 +1,4 @@ -namespace pl.polidea.lab.Web_Page_Screensaver +namespace WebPageScreensaver { partial class ScreensaverForm { @@ -28,8 +28,10 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.webBrowser = new System.Windows.Forms.WebBrowser(); + this.webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2(); this.closeButton = new System.Windows.Forms.Button(); + + ((System.ComponentModel.ISupportInitialize)(this.webBrowser)).BeginInit(); this.SuspendLayout(); // // webBrowser @@ -39,7 +41,6 @@ private void InitializeComponent() this.webBrowser.Margin = new System.Windows.Forms.Padding(4); this.webBrowser.MinimumSize = new System.Drawing.Size(27, 25); this.webBrowser.Name = "webBrowser"; - this.webBrowser.ScriptErrorsSuppressed = true; this.webBrowser.Size = new System.Drawing.Size(379, 322); this.webBrowser.TabIndex = 0; // @@ -56,7 +57,7 @@ private void InitializeComponent() this.closeButton.UseVisualStyleBackColor = true; this.closeButton.Visible = false; this.closeButton.Click += new System.EventHandler(this.closeButton_Click); - // + // // ScreensaverForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -74,14 +75,15 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Form1"; this.Load += new System.EventHandler(this.ScreensaverForm_Load); + + ((System.ComponentModel.ISupportInitialize)(this.webBrowser)).EndInit(); this.ResumeLayout(false); } #endregion - private System.Windows.Forms.WebBrowser webBrowser; + private Microsoft.Web.WebView2.WinForms.WebView2 webBrowser; private System.Windows.Forms.Button closeButton; } } - From 5fdf32d95724dee4e711b0ab1d06b310b9e1f713 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 00:54:02 -0700 Subject: [PATCH 17/45] ScreensaverForm.resx add new automatically created file. --- ScreensaverForm.resx | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 ScreensaverForm.resx diff --git a/ScreensaverForm.resx b/ScreensaverForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ScreensaverForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From fc7c55d3d2ff6e2f476d791fc18e29370dfebc6d Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 14:27:03 -0700 Subject: [PATCH 18/45] ScreenSaverForm Upgrade to WebView2. At the time of this commit, Edge Canary is a dependency of this app, but this may change soon when WebView2 gets a stable release. --- ScreensaverForm.Designer.cs | 5 ++--- ScreensaverForm.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ScreensaverForm.Designer.cs b/ScreensaverForm.Designer.cs index bf18353..8475ddb 100644 --- a/ScreensaverForm.Designer.cs +++ b/ScreensaverForm.Designer.cs @@ -31,7 +31,6 @@ private void InitializeComponent() this.webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2(); this.closeButton = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.webBrowser)).BeginInit(); this.SuspendLayout(); // // webBrowser @@ -43,6 +42,8 @@ private void InitializeComponent() this.webBrowser.Name = "webBrowser"; this.webBrowser.Size = new System.Drawing.Size(379, 322); this.webBrowser.TabIndex = 0; + this.webBrowser.Text = "webBrowser"; + this.webBrowser.ZoomFactor = 1D; // // closeButton // @@ -75,8 +76,6 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Form1"; this.Load += new System.EventHandler(this.ScreensaverForm_Load); - - ((System.ComponentModel.ISupportInitialize)(this.webBrowser)).EndInit(); this.ResumeLayout(false); } diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index 97a531d..e6d1e29 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -49,8 +49,14 @@ public List Urls } } - private void ScreensaverForm_Load(object sender, EventArgs e) + private async void ScreensaverForm_Load(object sender, EventArgs e) { + if (webBrowser == null) + { + throw new NullReferenceException("webBrowser should have been initialized by now."); + } + await webBrowser.EnsureCoreWebView2Async(); + if (Urls.Any()) { if (Urls.Count > 1) @@ -105,7 +111,7 @@ private void BrowseTo(string url) try { Debug.WriteLine($"Navigating: {url}"); - webBrowser.NavigateToString(url); // May not be the correct method to call + webBrowser.CoreWebView2.Navigate(url); } catch { From 1d624b211d5bcdd383e23cf536baf68294542197 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 14:37:49 -0700 Subject: [PATCH 19/45] Program.cs remove obsolete regkey set, required for Internet Explorer, but not for Edge. --- Program.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Program.cs b/Program.cs index 3a9cfbc..6fc190a 100644 --- a/Program.cs +++ b/Program.cs @@ -11,8 +11,6 @@ static class Program { public const string KeyWebPageScreensaver = @"Software\WebPageScreensaver"; - private const string KeyBrowserEmulation = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; - /// /// The main entry point for the application. /// @@ -26,9 +24,6 @@ static void Main(string[] args) throw new NullReferenceException("Current process main module is null."); } - var exeName = Path.GetFileName(mainModule.FileName); - Registry.SetValue(KeyBrowserEmulation, exeName, 0x2AF8, RegistryValueKind.DWord); - Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); From e407b43f4e7d6bac9ccc8a400239f4606934abd5 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 14:38:18 -0700 Subject: [PATCH 20/45] PreferencesManager.cs update default websites. --- PreferencesManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PreferencesManager.cs b/PreferencesManager.cs index 48b001b..afcfc35 100644 --- a/PreferencesManager.cs +++ b/PreferencesManager.cs @@ -18,7 +18,7 @@ public class PreferencesManager private const string SCREEN_SPECIFIC_PREF_NAME_FORMATSTRING = "{0}Screen{1}"; private const string MULTISCREEN_PREF_DEFAULT = "Separate"; - private const string URL_PREF_PRIMARYSCREEN_DEFAULT = "https://www.google.com/trends/hottrends/visualize?nrow=5&ncol=5 https://screensaver.twingly.com/"; + private const string URL_PREF_PRIMARYSCREEN_DEFAULT = "https://dotnet.microsoft.com/ https://code.visualstudio.com/"; private const string URL_PREF_NONPRIMARYSCREEN_DEFAULT = ""; private const string INTERVAL_PREF_DEFAULT = "30"; private const string RANDOMIZE_PREF_DEFAULT = "False"; From b23b4b2f423c333bf9ffa504b522460d01bc1384 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Sun, 6 Sep 2020 14:57:23 -0700 Subject: [PATCH 21/45] PrefsByScreenUserControl.resx automatic update. --- PrefsByScreenUserControl.resx | 65 +---------------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/PrefsByScreenUserControl.resx b/PrefsByScreenUserControl.resx index 42c4e49..f298a7b 100644 --- a/PrefsByScreenUserControl.resx +++ b/PrefsByScreenUserControl.resx @@ -1,64 +1,4 @@ - - - + @@ -117,7 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file From 2104146b4423995b4e65e83b388c27210935fd57 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Mon, 7 Sep 2020 00:05:10 -0700 Subject: [PATCH 22/45] resx files delete. --- PreferencesForm.resx | 123 ---------------------------------- PrefsByScreenUserControl.resx | 60 ----------------- ScreensaverForm.resx | 60 ----------------- 3 files changed, 243 deletions(-) delete mode 100644 PreferencesForm.resx delete mode 100644 PrefsByScreenUserControl.resx delete mode 100644 ScreensaverForm.resx diff --git a/PreferencesForm.resx b/PreferencesForm.resx deleted file mode 100644 index c13c2e3..0000000 --- a/PreferencesForm.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/PrefsByScreenUserControl.resx b/PrefsByScreenUserControl.resx deleted file mode 100644 index f298a7b..0000000 --- a/PrefsByScreenUserControl.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ScreensaverForm.resx b/ScreensaverForm.resx deleted file mode 100644 index f298a7b..0000000 --- a/ScreensaverForm.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file From 7b6d05ad5ee3db261f228bc1870f3f27c5243cea Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Mon, 7 Sep 2020 00:05:47 -0700 Subject: [PATCH 23/45] Design changes Alter the layout and make it look better. --- PreferencesForm.Designer.cs | 501 +++++++++++++++------------ PreferencesForm.cs | 75 ++-- PreferencesManager.cs | 83 ++--- PrefsByScreenUserControl.Designer.cs | 349 +++++++++++-------- PrefsByScreenUserControl.cs | 26 +- Program.cs | 8 +- ScreensaverForm.Designer.cs | 27 +- 7 files changed, 615 insertions(+), 454 deletions(-) diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 6118883..4bd3b75 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -1,4 +1,8 @@ -namespace WebPageScreensaver +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace WebPageScreensaver { partial class PreferencesForm { @@ -29,225 +33,284 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.label1 = new System.Windows.Forms.Label(); - this.llProjectLocationUrl = new System.Windows.Forms.LinkLabel(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.cbCloseOnActivity = new System.Windows.Forms.CheckBox(); - this.screenTabControl = new System.Windows.Forms.TabControl(); - this.screenTabPage1 = new System.Windows.Forms.TabPage(); - this.prefsByScreenUserControl1 = new PrefsByScreenUserControl(); - this.spanScreensButton = new System.Windows.Forms.RadioButton(); - this.separateScreensButton = new System.Windows.Forms.RadioButton(); - this.label4 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.mirrorScreensButton = new System.Windows.Forms.RadioButton(); - this.multiScreenGroup = new System.Windows.Forms.GroupBox(); - this.screenModeTooltip = new System.Windows.Forms.ToolTip(this.components); - this.screenTabControl.SuspendLayout(); - this.screenTabPage1.SuspendLayout(); - this.multiScreenGroup.SuspendLayout(); + this._linkLabelProjectURL = new LinkLabel(); + this._tabControlScreens = new TabControl(); + this._tabPageScreen = new TabPage(); + this._labelWebsiteURLs = new Label(); + this._toolTipScreenMode = new ToolTip(this.components); + this._radioButtonSeparateScreens = new RadioButton(); + this._radioButtonMirrorScreens = new RadioButton(); + this._radioButtonSpanScreens = new RadioButton(); + this._tableLayoutPanelMain = new TableLayoutPanel(); + this._tableLayoutPanelMainBottom = new TableLayoutPanel(); + this._buttonCancel = new Button(); + this._buttonOK = new Button(); + this._tableLayoutPanelMainTop = new TableLayoutPanel(); + this._labelMultiScreen = new Label(); + this._checkBoxCloseOnMouseMovement = new CheckBox(); + this._flowLayoutPanelMultiScreenButtons = new FlowLayoutPanel(); + this._prefsByScreenUserControl = new WebPageScreensaver.PrefsByScreenUserControl(); + this._tabControlScreens.SuspendLayout(); + this._tabPageScreen.SuspendLayout(); + this._tableLayoutPanelMain.SuspendLayout(); + this._tableLayoutPanelMainBottom.SuspendLayout(); + this._tableLayoutPanelMainTop.SuspendLayout(); + this._flowLayoutPanelMultiScreenButtons.SuspendLayout(); this.SuspendLayout(); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(76, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(121, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Web Page Screensaver"; - // - // llProjectLocationUrl - // - this.llProjectLocationUrl.AutoSize = true; - this.llProjectLocationUrl.Location = new System.Drawing.Point(22, 25); - this.llProjectLocationUrl.Name = "llProjectLocationUrl"; - this.llProjectLocationUrl.Size = new System.Drawing.Size(233, 13); - this.llProjectLocationUrl.TabIndex = 1; - this.llProjectLocationUrl.TabStop = true; - this.llProjectLocationUrl.Text = "http://github.com/carlossanlop/web-page-screensaver/"; - this.llProjectLocationUrl.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llProjectLocationUrl_LinkClicked); - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(115, 404); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 4; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(196, 404); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 5; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); - // - // cbCloseOnActivity - // - this.cbCloseOnActivity.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.cbCloseOnActivity.AutoSize = true; - this.cbCloseOnActivity.Checked = true; - this.cbCloseOnActivity.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbCloseOnActivity.Location = new System.Drawing.Point(15, 381); - this.cbCloseOnActivity.Name = "cbCloseOnActivity"; - this.cbCloseOnActivity.Size = new System.Drawing.Size(153, 17); - this.cbCloseOnActivity.TabIndex = 6; - this.cbCloseOnActivity.Text = "Close on mouse movement"; - this.cbCloseOnActivity.UseVisualStyleBackColor = true; + // _linkLabelProjectURL + // + this._linkLabelProjectURL.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Bottom) + | AnchorStyles.Left))); + this._linkLabelProjectURL.AutoSize = true; + this._linkLabelProjectURL.Location = new Point(6, 0); + this._linkLabelProjectURL.Margin = new Padding(6, 0, 6, 0); + this._linkLabelProjectURL.Name = "_linkLabelProjectURL"; + this._linkLabelProjectURL.Size = new Size(99, 59); + this._linkLabelProjectURL.TabIndex = 1; + this._linkLabelProjectURL.TabStop = true; + this._linkLabelProjectURL.Text = "Website"; + this._linkLabelProjectURL.TextAlign = ContentAlignment.MiddleCenter; + this._toolTipScreenMode.SetToolTip(this._linkLabelProjectURL, "http://github.com/carlossanlop/web-page-screensaver/"); + this._linkLabelProjectURL.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llProjectLocationUrl_LinkClicked); // // screenTabControl // - this.screenTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.screenTabControl.Controls.Add(this.screenTabPage1); - this.screenTabControl.Location = new System.Drawing.Point(15, 97); - this.screenTabControl.Margin = new System.Windows.Forms.Padding(2); - this.screenTabControl.Name = "screenTabControl"; - this.screenTabControl.SelectedIndex = 0; - this.screenTabControl.Size = new System.Drawing.Size(261, 279); - this.screenTabControl.TabIndex = 13; + this._tabControlScreens.Controls.Add(this._tabPageScreen); + this._tabControlScreens.Dock = DockStyle.Fill; + this._tabControlScreens.Location = new Point(4, 186); + this._tabControlScreens.Margin = new Padding(4, 5, 4, 5); + this._tabControlScreens.Name = "screenTabControl"; + this._tabControlScreens.SelectedIndex = 0; + this._tabControlScreens.Size = new Size(990, 697); + this._tabControlScreens.TabIndex = 13; // // screenTabPage1 // - this.screenTabPage1.Controls.Add(this.prefsByScreenUserControl1); - this.screenTabPage1.Location = new System.Drawing.Point(4, 22); - this.screenTabPage1.Margin = new System.Windows.Forms.Padding(2); - this.screenTabPage1.Name = "screenTabPage1"; - this.screenTabPage1.Padding = new System.Windows.Forms.Padding(2); - this.screenTabPage1.Size = new System.Drawing.Size(253, 253); - this.screenTabPage1.TabIndex = 0; - this.screenTabPage1.Text = "Screen 1"; - this.screenTabPage1.UseVisualStyleBackColor = true; + this._tabPageScreen.Controls.Add(this._prefsByScreenUserControl); + this._tabPageScreen.Location = new Point(8, 46); + this._tabPageScreen.Margin = new Padding(4, 5, 4, 5); + this._tabPageScreen.Name = "screenTabPage1"; + this._tabPageScreen.Padding = new Padding(4, 5, 4, 5); + this._tabPageScreen.Size = new Size(974, 643); + this._tabPageScreen.TabIndex = 0; + this._tabPageScreen.Text = "Screen 1"; + this._tabPageScreen.UseVisualStyleBackColor = true; + // + // _labelWebsiteURLs + // + this._labelWebsiteURLs.AutoSize = true; + this._labelWebsiteURLs.Dock = DockStyle.Left; + this._labelWebsiteURLs.Location = new Point(6, 122); + this._labelWebsiteURLs.Margin = new Padding(6); + this._labelWebsiteURLs.Name = "_labelWebsiteURLs"; + this._labelWebsiteURLs.Size = new Size(157, 53); + this._labelWebsiteURLs.TabIndex = 2; + this._labelWebsiteURLs.Text = "Website URLs"; + this._labelWebsiteURLs.TextAlign = ContentAlignment.BottomLeft; + // + // _radioButtonSeparateScreens + // + this._radioButtonSeparateScreens.AutoSize = true; + this._radioButtonSeparateScreens.Location = new Point(233, 9); + this._radioButtonSeparateScreens.Margin = new Padding(4, 5, 4, 5); + this._radioButtonSeparateScreens.Name = "_radioButtonSeparateScreens"; + this._radioButtonSeparateScreens.Size = new Size(138, 36); + this._radioButtonSeparateScreens.TabIndex = 15; + this._radioButtonSeparateScreens.TabStop = true; + this._radioButtonSeparateScreens.Tag = "MultiScreenMode"; + this._radioButtonSeparateScreens.Text = "Separate"; + this._toolTipScreenMode.SetToolTip(this._radioButtonSeparateScreens, "Each to their own."); + this._radioButtonSeparateScreens.UseVisualStyleBackColor = true; + // + // _radioButtonMirrorScreens + // + this._radioButtonMirrorScreens.AutoSize = true; + this._radioButtonMirrorScreens.Location = new Point(114, 9); + this._radioButtonMirrorScreens.Margin = new Padding(4, 5, 4, 5); + this._radioButtonMirrorScreens.Name = "_radioButtonMirrorScreens"; + this._radioButtonMirrorScreens.Size = new Size(111, 36); + this._radioButtonMirrorScreens.TabIndex = 26; + this._radioButtonMirrorScreens.TabStop = true; + this._radioButtonMirrorScreens.Tag = "MultiScreenMode"; + this._radioButtonMirrorScreens.Text = "Mirror"; + this._toolTipScreenMode.SetToolTip(this._radioButtonMirrorScreens, "One for All!"); + this._radioButtonMirrorScreens.UseVisualStyleBackColor = true; + // + // _radioButtonSpanScreens + // + this._radioButtonSpanScreens.AutoSize = true; + this._radioButtonSpanScreens.Checked = true; + this._radioButtonSpanScreens.Location = new Point(8, 9); + this._radioButtonSpanScreens.Margin = new Padding(4, 5, 4, 5); + this._radioButtonSpanScreens.Name = "_radioButtonSpanScreens"; + this._radioButtonSpanScreens.Size = new Size(98, 36); + this._radioButtonSpanScreens.TabIndex = 21; + this._radioButtonSpanScreens.TabStop = true; + this._radioButtonSpanScreens.Tag = "MultiScreenMode"; + this._radioButtonSpanScreens.Text = "Span"; + this._toolTipScreenMode.SetToolTip(this._radioButtonSpanScreens, "All for One!"); + this._radioButtonSpanScreens.UseVisualStyleBackColor = true; + // + // _tableLayoutPanelMain + // + this._tableLayoutPanelMain.AutoSize = true; + this._tableLayoutPanelMain.AutoSizeMode = AutoSizeMode.GrowAndShrink; + this._tableLayoutPanelMain.ColumnCount = 1; + this._tableLayoutPanelMain.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMain.Controls.Add(this._tabControlScreens, 0, 2); + this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainBottom, 0, 3); + this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainTop, 0, 0); + this._tableLayoutPanelMain.Controls.Add(this._labelWebsiteURLs, 0, 1); + this._tableLayoutPanelMain.Dock = DockStyle.Fill; + this._tableLayoutPanelMain.Location = new Point(0, 0); + this._tableLayoutPanelMain.Margin = new Padding(4); + this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; + this._tableLayoutPanelMain.RowCount = 4; + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 116F)); + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F)); + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F)); + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + this._tableLayoutPanelMain.Size = new Size(998, 953); + this._tableLayoutPanelMain.TabIndex = 19; + // + // _tableLayoutPanelMainBottom + // + this._tableLayoutPanelMainBottom.ColumnCount = 3; + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainBottom.Controls.Add(this._buttonCancel, 2, 0); + this._tableLayoutPanelMainBottom.Controls.Add(this._linkLabelProjectURL, 0, 0); + this._tableLayoutPanelMainBottom.Controls.Add(this._buttonOK, 1, 0); + this._tableLayoutPanelMainBottom.Dock = DockStyle.Fill; + this._tableLayoutPanelMainBottom.Location = new Point(3, 891); + this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; + this._tableLayoutPanelMainBottom.RowCount = 1; + this._tableLayoutPanelMainBottom.RowStyles.Add(new RowStyle()); + this._tableLayoutPanelMainBottom.Size = new Size(992, 59); + this._tableLayoutPanelMainBottom.TabIndex = 0; + // + // _buttonCancel + // + this._buttonCancel.Anchor = AnchorStyles.None; + this._buttonCancel.DialogResult = DialogResult.Cancel; + this._buttonCancel.Location = new Point(836, 7); + this._buttonCancel.Margin = new Padding(6); + this._buttonCancel.Name = "_buttonCancel"; + this._buttonCancel.Size = new Size(150, 44); + this._buttonCancel.TabIndex = 6; + this._buttonCancel.Text = "Cancel"; + this._buttonCancel.UseVisualStyleBackColor = true; + // + // _buttonOK + // + this._buttonOK.Anchor = AnchorStyles.None; + this._buttonOK.DialogResult = DialogResult.OK; + this._buttonOK.Location = new Point(674, 7); + this._buttonOK.Margin = new Padding(6); + this._buttonOK.Name = "_buttonOK"; + this._buttonOK.Size = new Size(150, 44); + this._buttonOK.TabIndex = 8; + this._buttonOK.Text = "OK"; + this._buttonOK.UseVisualStyleBackColor = true; + // + // _tableLayoutPanelMainTop + // + this._tableLayoutPanelMainTop.ColumnCount = 2; + this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + this._tableLayoutPanelMainTop.Controls.Add(this._labelMultiScreen, 0, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._checkBoxCloseOnMouseMovement, 1, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._flowLayoutPanelMultiScreenButtons, 0, 1); + this._tableLayoutPanelMainTop.Dock = DockStyle.Fill; + this._tableLayoutPanelMainTop.Location = new Point(3, 3); + this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; + this._tableLayoutPanelMainTop.RowCount = 2; + this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle()); + this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle()); + this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + this._tableLayoutPanelMainTop.Size = new Size(992, 110); + this._tableLayoutPanelMainTop.TabIndex = 1; + // + // _labelMultiScreen + // + this._labelMultiScreen.AutoSize = true; + this._labelMultiScreen.Dock = DockStyle.Left; + this._labelMultiScreen.Location = new Point(6, 0); + this._labelMultiScreen.Margin = new Padding(6, 0, 6, 0); + this._labelMultiScreen.Name = "_labelMultiScreen"; + this._labelMultiScreen.Size = new Size(144, 50); + this._labelMultiScreen.TabIndex = 17; + this._labelMultiScreen.Text = "Multiscreen:"; + this._labelMultiScreen.TextAlign = ContentAlignment.MiddleLeft; + // + // _checkBoxCloseOnMouseMovement + // + this._checkBoxCloseOnMouseMovement.AutoSize = true; + this._checkBoxCloseOnMouseMovement.Checked = true; + this._checkBoxCloseOnMouseMovement.CheckState = CheckState.Checked; + this._checkBoxCloseOnMouseMovement.Dock = DockStyle.Left; + this._checkBoxCloseOnMouseMovement.Location = new Point(502, 7); + this._checkBoxCloseOnMouseMovement.Margin = new Padding(6, 7, 6, 7); + this._checkBoxCloseOnMouseMovement.Name = "_checkBoxCloseOnMouseMovement"; + this._checkBoxCloseOnMouseMovement.Size = new Size(341, 36); + this._checkBoxCloseOnMouseMovement.TabIndex = 20; + this._checkBoxCloseOnMouseMovement.Text = "Close on mouse movement"; + this._checkBoxCloseOnMouseMovement.UseVisualStyleBackColor = true; + // + // _flowLayoutPanelMultiScreenButtons + // + this._flowLayoutPanelMultiScreenButtons.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right))); + this._flowLayoutPanelMultiScreenButtons.AutoSize = true; + this._flowLayoutPanelMultiScreenButtons.AutoSizeMode = AutoSizeMode.GrowAndShrink; + this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonSpanScreens); + this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonMirrorScreens); + this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonSeparateScreens); + this._flowLayoutPanelMultiScreenButtons.Location = new Point(4, 54); + this._flowLayoutPanelMultiScreenButtons.Margin = new Padding(4); + this._flowLayoutPanelMultiScreenButtons.Name = "_flowLayoutPanelMultiScreenButtons"; + this._flowLayoutPanelMultiScreenButtons.Padding = new Padding(4); + this._flowLayoutPanelMultiScreenButtons.Size = new Size(488, 54); + this._flowLayoutPanelMultiScreenButtons.TabIndex = 22; // // prefsByScreenUserControl1 // - this.prefsByScreenUserControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.prefsByScreenUserControl1.BackColor = System.Drawing.Color.White; - this.prefsByScreenUserControl1.Location = new System.Drawing.Point(0, 0); - this.prefsByScreenUserControl1.Margin = new System.Windows.Forms.Padding(0); - this.prefsByScreenUserControl1.Name = "prefsByScreenUserControl1"; - this.prefsByScreenUserControl1.Size = new System.Drawing.Size(253, 254); - this.prefsByScreenUserControl1.TabIndex = 21; - // - // spanScreensButton - // - this.spanScreensButton.AutoSize = true; - this.spanScreensButton.Checked = true; - this.spanScreensButton.Location = new System.Drawing.Point(75, 8); - this.spanScreensButton.Margin = new System.Windows.Forms.Padding(2); - this.spanScreensButton.Name = "spanScreensButton"; - this.spanScreensButton.Size = new System.Drawing.Size(50, 17); - this.spanScreensButton.TabIndex = 14; - this.spanScreensButton.TabStop = true; - this.spanScreensButton.Tag = "MultiScreenMode"; - this.spanScreensButton.Text = "Span"; - this.screenModeTooltip.SetToolTip(this.spanScreensButton, "All for One!"); - this.spanScreensButton.UseVisualStyleBackColor = true; - this.spanScreensButton.Click += new System.EventHandler(this.anyMultiScreenModeButton_Click); - // - // separateScreensButton - // - this.separateScreensButton.AutoSize = true; - this.separateScreensButton.Location = new System.Drawing.Point(178, 8); - this.separateScreensButton.Margin = new System.Windows.Forms.Padding(2); - this.separateScreensButton.Name = "separateScreensButton"; - this.separateScreensButton.Size = new System.Drawing.Size(68, 17); - this.separateScreensButton.TabIndex = 15; - this.separateScreensButton.TabStop = true; - this.separateScreensButton.Tag = "MultiScreenMode"; - this.separateScreensButton.Text = "Separate"; - this.screenModeTooltip.SetToolTip(this.separateScreensButton, "Each to their own."); - this.separateScreensButton.UseVisualStyleBackColor = true; - this.separateScreensButton.Click += new System.EventHandler(this.anyMultiScreenModeButton_Click); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 10); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(64, 13); - this.label4.TabIndex = 16; - this.label4.Text = "Multiscreen:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 79); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(76, 13); - this.label2.TabIndex = 2; - this.label2.Text = "Website URLs"; - // - // mirrorScreensButton - // - this.mirrorScreensButton.AutoSize = true; - this.mirrorScreensButton.Location = new System.Drawing.Point(126, 8); - this.mirrorScreensButton.Margin = new System.Windows.Forms.Padding(2); - this.mirrorScreensButton.Name = "mirrorScreensButton"; - this.mirrorScreensButton.Size = new System.Drawing.Size(51, 17); - this.mirrorScreensButton.TabIndex = 17; - this.mirrorScreensButton.TabStop = true; - this.mirrorScreensButton.Tag = "MultiScreenMode"; - this.mirrorScreensButton.Text = "Mirror"; - this.screenModeTooltip.SetToolTip(this.mirrorScreensButton, "One for All!"); - this.mirrorScreensButton.UseVisualStyleBackColor = true; - this.mirrorScreensButton.Click += new System.EventHandler(this.anyMultiScreenModeButton_Click); - // - // multiScreenGroup - // - this.multiScreenGroup.Controls.Add(this.label4); - this.multiScreenGroup.Controls.Add(this.mirrorScreensButton); - this.multiScreenGroup.Controls.Add(this.spanScreensButton); - this.multiScreenGroup.Controls.Add(this.separateScreensButton); - this.multiScreenGroup.Location = new System.Drawing.Point(15, 46); - this.multiScreenGroup.Margin = new System.Windows.Forms.Padding(2); - this.multiScreenGroup.Name = "multiScreenGroup"; - this.multiScreenGroup.Padding = new System.Windows.Forms.Padding(2); - this.multiScreenGroup.Size = new System.Drawing.Size(258, 28); - this.multiScreenGroup.TabIndex = 18; - this.multiScreenGroup.TabStop = false; + this._prefsByScreenUserControl.BackColor = Color.White; + this._prefsByScreenUserControl.Dock = DockStyle.Fill; + this._prefsByScreenUserControl.Location = new Point(4, 5); + this._prefsByScreenUserControl.Margin = new Padding(0); + this._prefsByScreenUserControl.Name = "prefsByScreenUserControl1"; + this._prefsByScreenUserControl.Size = new Size(966, 633); + this._prefsByScreenUserControl.TabIndex = 25; // // PreferencesForm // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(292, 434); - this.Controls.Add(this.multiScreenGroup); - this.Controls.Add(this.screenTabControl); - this.Controls.Add(this.cbCloseOnActivity); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.label2); - this.Controls.Add(this.llProjectLocationUrl); - this.Controls.Add(this.label1); + this.AutoScaleDimensions = new SizeF(13F, 32F); + this.AutoScaleMode = AutoScaleMode.Font; + this.ClientSize = new Size(998, 953); + this.Controls.Add(this._tableLayoutPanelMain); + this.Margin = new Padding(6, 7, 6, 7); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(288, 355); + this.MinimumSize = new Size(1024, 768); this.Name = "PreferencesForm"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.SizeGripStyle = SizeGripStyle.Show; + this.StartPosition = FormStartPosition.CenterParent; this.Text = "Web Page Screensaver Settings"; this.Load += new System.EventHandler(this.PreferencesForm_Load); - this.screenTabControl.ResumeLayout(false); - this.screenTabPage1.ResumeLayout(false); - this.multiScreenGroup.ResumeLayout(false); - this.multiScreenGroup.PerformLayout(); + this._tabControlScreens.ResumeLayout(false); + this._tabPageScreen.ResumeLayout(false); + this._tableLayoutPanelMain.ResumeLayout(false); + this._tableLayoutPanelMain.PerformLayout(); + this._tableLayoutPanelMainBottom.ResumeLayout(false); + this._tableLayoutPanelMainBottom.PerformLayout(); + this._tableLayoutPanelMainTop.ResumeLayout(false); + this._tableLayoutPanelMainTop.PerformLayout(); + this._flowLayoutPanelMultiScreenButtons.ResumeLayout(false); + this._flowLayoutPanelMultiScreenButtons.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -255,20 +318,26 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.Label label1; - private System.Windows.Forms.LinkLabel llProjectLocationUrl; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.CheckBox cbCloseOnActivity; - private System.Windows.Forms.TabControl screenTabControl; - private System.Windows.Forms.TabPage screenTabPage1; - private System.Windows.Forms.RadioButton spanScreensButton; - private System.Windows.Forms.RadioButton separateScreensButton; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.RadioButton mirrorScreensButton; - private System.Windows.Forms.GroupBox multiScreenGroup; - private PrefsByScreenUserControl prefsByScreenUserControl1; - private System.Windows.Forms.ToolTip screenModeTooltip; + private TableLayoutPanel _tableLayoutPanelMain; + + private TableLayoutPanel _tableLayoutPanelMainTop; + private FlowLayoutPanel _flowLayoutPanelMultiScreenButtons; + private Label _labelMultiScreen; + private RadioButton _radioButtonSpanScreens; + private RadioButton _radioButtonMirrorScreens; + private RadioButton _radioButtonSeparateScreens; + private CheckBox _checkBoxCloseOnMouseMovement; + + private Label _labelWebsiteURLs; + private TabControl _tabControlScreens; + private TabPage _tabPageScreen; + private PrefsByScreenUserControl _prefsByScreenUserControl; + + private TableLayoutPanel _tableLayoutPanelMainBottom; + private LinkLabel _linkLabelProjectURL; + private Button _buttonCancel; + private Button _buttonOK; + + private ToolTip _toolTipScreenMode; } } \ No newline at end of file diff --git a/PreferencesForm.cs b/PreferencesForm.cs index 9e72b2a..cab320c 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -20,14 +20,14 @@ public PreferencesForm() private void PreferencesForm_Load(object sender, EventArgs e) { - cbCloseOnActivity.Checked = prefsManager.CloseOnActivity; - if (Screen.AllScreens.Count() == 1) + _checkBoxCloseOnMouseMovement.Checked = prefsManager.CloseOnActivity; + if (Screen.AllScreens.Length == 1) { - multiScreenGroup.Enabled = false; + _flowLayoutPanelMultiScreenButtons.Enabled = false; } else { - multiScreenGroup.Enabled = true; + _flowLayoutPanelMultiScreenButtons.Enabled = true; } SetMultiScreenButtonFromMode(); ArrangeScreenTabs(); @@ -37,8 +37,8 @@ private void LoadValuesForTab(int screenNum) { var currentPrefsUserControl = screenUserControls[screenNum]; LoadUrlsForTabToControl(screenNum, currentPrefsUserControl); - currentPrefsUserControl.nudRotationInterval.Value = prefsManager.GetRotationIntervalByScreen(screenNum); - currentPrefsUserControl.cbRandomize.Checked = prefsManager.GetRandomizeFlagByScreen(screenNum); + currentPrefsUserControl._numericUpDownSecondsToDisplay.Value = prefsManager.GetRotationIntervalByScreen(screenNum); + currentPrefsUserControl._checkBoxShuffle.Checked = prefsManager.GetRandomizeFlagByScreen(screenNum); } private void ArrangeScreenTabs() @@ -47,29 +47,29 @@ private void ArrangeScreenTabs() { case PreferencesManager.MultiScreenModeItem.Span: RemoveExtraTabPages(); - screenTabControl.TabPages[0].Text = "Composite Screen"; + _tabControlScreens.TabPages[0].Text = "Composite Screen"; // Need to clear because we only expect one tab screenUserControls.Clear(); - screenUserControls.Add(prefsByScreenUserControl1); + screenUserControls.Add(_prefsByScreenUserControl); LoadValuesForTab(0); break; case PreferencesManager.MultiScreenModeItem.Mirror: RemoveExtraTabPages(); - screenTabControl.TabPages[0].Text = "Each Screen"; + _tabControlScreens.TabPages[0].Text = "Each Screen"; // Need to clear because we only expect one tab screenUserControls.Clear(); - screenUserControls.Add(prefsByScreenUserControl1); + screenUserControls.Add(_prefsByScreenUserControl); LoadValuesForTab(0); break; case PreferencesManager.MultiScreenModeItem.Separate: for (int i = 0; i < Screen.AllScreens.Length; i++) { - TabPage tabPage = null; + TabPage? tabPage = null; - if (i >= screenTabControl.TabPages.Count) + if (i >= _tabControlScreens.TabPages.Count) { tabPage = new TabPage(); - screenTabControl.TabPages.Add(tabPage); + _tabControlScreens.TabPages.Add(tabPage); if (i > 0) { @@ -77,23 +77,28 @@ private void ArrangeScreenTabs() { Name = string.Format("prefsByScreenUserControl{0}", i + 1), Location = new Point(0, 0), - Size = prefsByScreenUserControl1.Size, - Anchor = prefsByScreenUserControl1.Anchor, - BackColor = prefsByScreenUserControl1.BackColor + Size = _prefsByScreenUserControl.Size, + Anchor = _prefsByScreenUserControl.Anchor, + BackColor = _prefsByScreenUserControl.BackColor }; - prefsByScreenUserControl.lvUrls.ContextMenuStrip = - prefsByScreenUserControl1.ContextMenuStrip; + prefsByScreenUserControl._listViewURLs.ContextMenuStrip = + _prefsByScreenUserControl.ContextMenuStrip; // No need to clear because we are re-adding the missing tabs screenUserControls.Add(prefsByScreenUserControl); tabPage.Controls.Add(prefsByScreenUserControl); } } - else if (screenTabControl.TabPages.Count == 1) + else if (_tabControlScreens.TabPages.Count == 1) { - tabPage = screenTabControl.TabPages[0]; + tabPage = _tabControlScreens.TabPages[0]; // Clearing before adding prevents a crash when going from Separate to Mirror and back to Separate screenUserControls.Clear(); - screenUserControls.Add(prefsByScreenUserControl1); + screenUserControls.Add(_prefsByScreenUserControl); + } + + if (tabPage == null) + { + throw new NullReferenceException("tabPage should not be null."); } LoadValuesForTab(i); @@ -108,9 +113,9 @@ private void ArrangeScreenTabs() private void RemoveExtraTabPages() { - while (screenTabControl.TabPages.Count > 1) + while (_tabControlScreens.TabPages.Count > 1) { - screenTabControl.TabPages.RemoveAt(screenTabControl.TabPages.Count - 1); + _tabControlScreens.TabPages.RemoveAt(_tabControlScreens.TabPages.Count - 1); } } @@ -119,24 +124,24 @@ private void SetMultiScreenButtonFromMode() switch (prefsManager.MultiScreenMode) { case PreferencesManager.MultiScreenModeItem.Span: - spanScreensButton.Checked = true; + _radioButtonSpanScreens.Checked = true; break; case PreferencesManager.MultiScreenModeItem.Mirror: - mirrorScreensButton.Checked = true; + _radioButtonMirrorScreens.Checked = true; break; case PreferencesManager.MultiScreenModeItem.Separate: - separateScreensButton.Checked = true; + _radioButtonSeparateScreens.Checked = true; break; } } private void SetMultiScreenModeFromButtonState() { - if (spanScreensButton.Checked) + if (_radioButtonSpanScreens.Checked) { prefsManager.MultiScreenMode = PreferencesManager.MultiScreenModeItem.Span; } - else if (mirrorScreensButton.Checked) + else if (_radioButtonMirrorScreens.Checked) { prefsManager.MultiScreenMode = PreferencesManager.MultiScreenModeItem.Mirror; } @@ -153,25 +158,25 @@ private void ReadBackValuesFromUI() for (var i = 0; i < screenUserControls.Count; i++) { var currentPrefsUserControl = screenUserControls[i]; - List urls = (from ListViewItem lvUrlsItem in currentPrefsUserControl.lvUrls.Items + List urls = (from ListViewItem lvUrlsItem in currentPrefsUserControl._listViewURLs.Items select lvUrlsItem.Text).ToList(); prefsManager.SetUrlsForScreen(i, urls); prefsManager.SetRotationIntervalForScreen(i, - (int)currentPrefsUserControl.nudRotationInterval.Value); - prefsManager.SetRandomizeFlagForScreen(i, currentPrefsUserControl.cbRandomize.Checked); - prefsManager.CloseOnActivity = cbCloseOnActivity.Checked; + (int)currentPrefsUserControl._numericUpDownSecondsToDisplay.Value); + prefsManager.SetRandomizeFlagForScreen(i, currentPrefsUserControl._checkBoxShuffle.Checked); + prefsManager.CloseOnActivity = _checkBoxCloseOnMouseMovement.Checked; } } private void LoadUrlsForTabToControl(int screenNum, PrefsByScreenUserControl currentPrefsUserControl) { - currentPrefsUserControl.lvUrls.Items.Clear(); + currentPrefsUserControl._listViewURLs.Items.Clear(); var urls = prefsManager.GetUrlsByScreen(screenNum); foreach (var url in urls) { - currentPrefsUserControl.lvUrls.Items.Add(url); + currentPrefsUserControl._listViewURLs.Items.Add(url); } } @@ -188,7 +193,7 @@ protected override void OnClosed(EventArgs e) private void llProjectLocationUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - System.Diagnostics.Process.Start(llProjectLocationUrl.Text); + System.Diagnostics.Process.Start(Program.Webpage); } private void okButton_Click(object sender, EventArgs e) diff --git a/PreferencesManager.cs b/PreferencesManager.cs index afcfc35..ab1de52 100644 --- a/PreferencesManager.cs +++ b/PreferencesManager.cs @@ -31,26 +31,26 @@ public PreferencesManager() LoadPreferences(); } - private List effectiveScreensListField; + private List? _effectiveScreensListField; public List EffectiveScreensList { get { - if (effectiveScreensListField == null) + if (_effectiveScreensListField == null) { - effectiveScreensListField = new List(); + _effectiveScreensListField = new List(); switch (MultiScreenMode) { case MultiScreenModeItem.Span: Rectangle enclosingRect = FindEnclosingRect(Screen.AllScreens.Select(r => r.Bounds).ToList()); - effectiveScreensListField.Add( + _effectiveScreensListField.Add( new BasicScreenInfo { ScreenNum = 0, Bounds = enclosingRect, IsPrimary = true }); break; case MultiScreenModeItem.Mirror: for (int i = 0; i < Screen.AllScreens.Length; i++) { - effectiveScreensListField.Add( + _effectiveScreensListField.Add( new BasicScreenInfo { ScreenNum = i, @@ -63,7 +63,7 @@ public List EffectiveScreensList case MultiScreenModeItem.Separate: for (int i = 0; i < Screen.AllScreens.Length; i++) { - effectiveScreensListField.Add( + _effectiveScreensListField.Add( new BasicScreenInfo { ScreenNum = i, @@ -74,30 +74,33 @@ public List EffectiveScreensList break; } } - return effectiveScreensListField; + return _effectiveScreensListField; } } public void ResetEffectiveScreensList() { - effectiveScreensListField = null; + _effectiveScreensListField = null; } - private int? realPrimaryScreenNumField; - private int RealPrimaryScreenNum() + private int _realPrimaryScreenNumField = -1; + private int RealPrimaryScreenNumber { - if (realPrimaryScreenNumField == null) + get { - realPrimaryScreenNumField = 0; - for (int i = 0; i < Screen.AllScreens.Length; i++) + if (_realPrimaryScreenNumField == -1) { - if (!Screen.AllScreens[i].Primary) continue; - realPrimaryScreenNumField = i; - break; + _realPrimaryScreenNumField = 0; + for (int i = 0; i < Screen.AllScreens.Length; i++) + { + if (!Screen.AllScreens[i].Primary) continue; + _realPrimaryScreenNumField = i; + break; + } } - } - return (int)realPrimaryScreenNumField; + return _realPrimaryScreenNumField; + } } public bool CloseOnActivity { get; set; } @@ -123,7 +126,7 @@ public class BasicScreenInfo // options: 1) retro-fit more ordering stuff onto screen URLS, 2) make the URLS list just one list again, and // add another list that specifies which screen each URL is for. (i.e. rewrite URL list handling completely). // 2. is actually the better option. - private List> urlsByScreen; + private List> _urlsByScreen = new List>(); public List GetUrlsByScreen(int screenNum) { int startAtScreenNum = MultiScreenMode == MultiScreenModeItem.Mirror ? 0 : screenNum; @@ -131,12 +134,12 @@ public List GetUrlsByScreen(int screenNum) // this can happen either due to actual screen removal as noted in the LoadUrlsAllScreens() method, // OR because we are in Span mode, making just one effective screen, // OR we want to treat multiple screens as one (mirror mode). - if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) + if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < _urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) { // for the GET operation, the last effective screen has the URLS // for additional screens in prefs appended to it's list. - List urlsList = urlsByScreen[startAtScreenNum].ToList(); - var urlsForRestOfScreens = urlsByScreen.GetRange(startAtScreenNum + 1, urlsByScreen.Count - startAtScreenNum - 1); + List urlsList = _urlsByScreen[startAtScreenNum]; + var urlsForRestOfScreens = _urlsByScreen.GetRange(startAtScreenNum + 1, _urlsByScreen.Count - startAtScreenNum - 1); foreach (var additionalScreenUrls in urlsForRestOfScreens) { urlsList.AddRange(additionalScreenUrls); @@ -145,7 +148,7 @@ public List GetUrlsByScreen(int screenNum) } else { - return urlsByScreen[startAtScreenNum].ToList(); + return _urlsByScreen[startAtScreenNum]; } } public void SetUrlsForScreen(int screenNum, List providedUrlsList) @@ -154,7 +157,7 @@ public void SetUrlsForScreen(int screenNum, List providedUrlsList) // special treatment for URLs for the 'last' effective screen // this can happen either due to physical screen changes as noted in the LoadUrlsAllScreens() method, // OR because we are in Span or Mirror mode, making just one effective screen. - if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) + if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < _urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) { // For the SET operation, we want any URLS that came to the last effective screen // from later screens in prefs to go back where they came from rather than directly @@ -165,7 +168,7 @@ public void SetUrlsForScreen(int screenNum, List providedUrlsList) // we only care about Url lists from this screen up. // This screen, whatever it is, is always RELATIVE screen 0. var relativeScreenUrlsList = - urlsByScreen.GetRange(startAtScreenNum, urlsByScreen.Count - startAtScreenNum); + _urlsByScreen.GetRange(startAtScreenNum, _urlsByScreen.Count - startAtScreenNum); // make a deep copy that we can manipulate independantly of the actual list. var originalsUnaccountedFor = relativeScreenUrlsList.Select(t => new List(t)).ToList(); // then delete all that actual entries in the actual set to fill in below. @@ -174,7 +177,7 @@ public void SetUrlsForScreen(int screenNum, List providedUrlsList) urlsList.RemoveRange(0, urlsList.Count); } - int defaultRelativeScreenNumForNewUrls = Math.Max(0, RealPrimaryScreenNum() - startAtScreenNum); + int defaultRelativeScreenNumForNewUrls = Math.Max(0, RealPrimaryScreenNumber - startAtScreenNum); foreach (var url in providedUrlsList) { @@ -201,28 +204,28 @@ public void SetUrlsForScreen(int screenNum, List providedUrlsList) else // normal case for normal screen nums is MUCH simpler: { - urlsByScreen[screenNum] = providedUrlsList; + _urlsByScreen[screenNum] = providedUrlsList; } } - private List rotationIntervalsByScreen; + private List? _rotationIntervalsByScreen; public int GetRotationIntervalByScreen(int screenNum) { - return rotationIntervalsByScreen[TranslateScreenNumToScreenPrefNum(screenNum)]; + return _rotationIntervalsByScreen[TranslateScreenNumToScreenPrefNum(screenNum)]; } public void SetRotationIntervalForScreen(int screenNum, int value) { - rotationIntervalsByScreen[TranslateScreenNumToScreenPrefNum(screenNum)] = value; + _rotationIntervalsByScreen[TranslateScreenNumToScreenPrefNum(screenNum)] = value; } - private List randomizeFlagByScreen; + private List? _randomizeFlagByScreen; public bool GetRandomizeFlagByScreen(int screenNum) { - return randomizeFlagByScreen[TranslateScreenNumToScreenPrefNum(screenNum)]; + return _randomizeFlagByScreen[TranslateScreenNumToScreenPrefNum(screenNum)]; } public void SetRandomizeFlagForScreen(int screenNum, bool randomizeSetting) { - randomizeFlagByScreen[TranslateScreenNumToScreenPrefNum(screenNum)] = randomizeSetting; + _randomizeFlagByScreen[TranslateScreenNumToScreenPrefNum(screenNum)] = randomizeSetting; } private int TranslateScreenNumToScreenPrefNum(int screenNum) @@ -230,7 +233,7 @@ private int TranslateScreenNumToScreenPrefNum(int screenNum) // if the screen they're asking for is an effective primary, // then the actual set of prefs to use is the real primary screen's set, // regardless of the actual number they asked for. - return EffectiveScreensList[screenNum].IsPrimary ? RealPrimaryScreenNum() : screenNum; + return EffectiveScreensList[screenNum].IsPrimary ? RealPrimaryScreenNumber : screenNum; } public void SavePreferences() @@ -238,8 +241,8 @@ public void SavePreferences() reg.SetValue(MULTISCREEN_PREF, MultiScreenMode); reg.SetValue(CLOSE_ON_ACTIVITY_PREF, CloseOnActivity); SaveUrlsAllScreens(); - SavePrefAllScreens(INTERVAL_PREF, rotationIntervalsByScreen); - SavePrefAllScreens(RANDOMIZE_PREF, randomizeFlagByScreen); + SavePrefAllScreens(INTERVAL_PREF, _rotationIntervalsByScreen); + SavePrefAllScreens(RANDOMIZE_PREF, _randomizeFlagByScreen); reg.Close(); } @@ -247,9 +250,9 @@ private void LoadPreferences() { MultiScreenMode = (MultiScreenModeItem)Enum.Parse(typeof(MultiScreenModeItem), (string)reg.GetValue(MULTISCREEN_PREF, MULTISCREEN_PREF_DEFAULT)); CloseOnActivity = bool.Parse((string)reg.GetValue(CLOSE_ON_ACTIVITY_PREF, CLOSE_ON_ACTIVITY_PREF_DEFAULT)); - urlsByScreen = LoadUrlsAllScreens(); - rotationIntervalsByScreen = LoadPrefAllScreens(INTERVAL_PREF, INTERVAL_PREF_DEFAULT, INTERVAL_PREF_DEFAULT); - randomizeFlagByScreen = LoadPrefAllScreens(RANDOMIZE_PREF, RANDOMIZE_PREF_DEFAULT, RANDOMIZE_PREF_DEFAULT); + _urlsByScreen = LoadUrlsAllScreens(); + _rotationIntervalsByScreen = LoadPrefAllScreens(INTERVAL_PREF, INTERVAL_PREF_DEFAULT, INTERVAL_PREF_DEFAULT); + _randomizeFlagByScreen = LoadPrefAllScreens(RANDOMIZE_PREF, RANDOMIZE_PREF_DEFAULT, RANDOMIZE_PREF_DEFAULT); } private List> LoadUrlsAllScreens() @@ -292,7 +295,7 @@ private List LoadPrefAllScreens(string prefBaseName, string primaryScreenP private void SaveUrlsAllScreens() { - SavePrefAllScreens(URL_PREF, urlsByScreen.Select(urlList => String.Join(" ", urlList)).ToList()); + SavePrefAllScreens(URL_PREF, _urlsByScreen.Select(urlList => string.Join(" ", urlList)).ToList()); } private void SavePrefAllScreens(string preferenceName, List prefsList) diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index 3fde513..86d2908 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -1,11 +1,16 @@ -namespace WebPageScreensaver +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace WebPageScreensaver { partial class PrefsByScreenUserControl { /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private IContainer _components = null; /// /// Clean up any resources being used. @@ -13,9 +18,9 @@ partial class PrefsByScreenUserControl /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (components != null)) + if (disposing && (_components != null)) { - components.Dispose(); + _components.Dispose(); } base.Dispose(disposing); } @@ -28,158 +33,230 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.nudRotationInterval = new System.Windows.Forms.NumericUpDown(); - this.label3 = new System.Windows.Forms.Label(); - this.cbRandomize = new System.Windows.Forms.CheckBox(); - this.lvUrls = new System.Windows.Forms.ListView(); - this.addUrlButton = new System.Windows.Forms.Button(); - this.upButton = new System.Windows.Forms.Button(); - this.urlButtonsTooltip = new System.Windows.Forms.ToolTip(this.components); - this.downButton = new System.Windows.Forms.Button(); - this.deleteButton = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.nudRotationInterval)).BeginInit(); + this._components = new Container(); + this._numericUpDownSecondsToDisplay = new NumericUpDown(); + this._labelSecondsToDisplay = new Label(); + this._checkBoxShuffle = new CheckBox(); + this._listViewURLs = new ListView(); + this._buttonAddURL = new Button(); + this._buttonUp = new Button(); + this._toolTipURLButtons = new ToolTip(this._components); + this._buttonDown = new Button(); + this._buttonDeleteURL = new Button(); + this._tableLayoutPanelMain = new TableLayoutPanel(); + this._tableLayoutPanelMainTop = new TableLayoutPanel(); + this._tableLayoutPanelMainBottom = new TableLayoutPanel(); + ((ISupportInitialize)(this._numericUpDownSecondsToDisplay)).BeginInit(); + this._tableLayoutPanelMain.SuspendLayout(); + this._tableLayoutPanelMainTop.SuspendLayout(); + this._tableLayoutPanelMainBottom.SuspendLayout(); this.SuspendLayout(); // - // nudRotationInterval + // _numericUpDownSecondsToDisplay // - this.nudRotationInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.nudRotationInterval.Location = new System.Drawing.Point(9, 220); - this.nudRotationInterval.Maximum = new decimal(new int[] { + this._numericUpDownSecondsToDisplay.Anchor = AnchorStyles.Right; + this._numericUpDownSecondsToDisplay.Location = new Point(315, 14); + this._numericUpDownSecondsToDisplay.Margin = new Padding(4); + this._numericUpDownSecondsToDisplay.Maximum = new decimal(new int[] { 999, 0, 0, 0}); - this.nudRotationInterval.Name = "nudRotationInterval"; - this.nudRotationInterval.Size = new System.Drawing.Size(40, 20); - this.nudRotationInterval.TabIndex = 6; - this.nudRotationInterval.Value = new decimal(new int[] { + this._numericUpDownSecondsToDisplay.Name = "_numericUpDownSecondsToDisplay"; + this._numericUpDownSecondsToDisplay.Size = new Size(80, 39); + this._numericUpDownSecondsToDisplay.TabIndex = 6; + this._numericUpDownSecondsToDisplay.Value = new decimal(new int[] { 30, 0, 0, 0}); // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(55, 222); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(142, 13); - this.label3.TabIndex = 7; - this.label3.Text = "Seconds to display each site"; - // - // cbRandomize - // - this.cbRandomize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.cbRandomize.AutoSize = true; - this.cbRandomize.Location = new System.Drawing.Point(10, 195); - this.cbRandomize.Name = "cbRandomize"; - this.cbRandomize.Size = new System.Drawing.Size(121, 17); - this.cbRandomize.TabIndex = 5; - this.cbRandomize.Text = "Shuffle display order"; - this.cbRandomize.UseVisualStyleBackColor = true; - // - // lvUrls - // - this.lvUrls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lvUrls.HideSelection = false; - this.lvUrls.LabelEdit = true; - this.lvUrls.Location = new System.Drawing.Point(10, 10); - this.lvUrls.Margin = new System.Windows.Forms.Padding(2); - this.lvUrls.Name = "lvUrls"; - this.lvUrls.Size = new System.Drawing.Size(230, 150); - this.lvUrls.TabIndex = 0; - this.lvUrls.UseCompatibleStateImageBehavior = false; - this.lvUrls.View = System.Windows.Forms.View.List; - // - // addUrlButton - // - this.addUrlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.addUrlButton.Location = new System.Drawing.Point(9, 165); - this.addUrlButton.Margin = new System.Windows.Forms.Padding(0); - this.addUrlButton.Name = "addUrlButton"; - this.addUrlButton.Size = new System.Drawing.Size(50, 25); - this.addUrlButton.TabIndex = 11; - this.addUrlButton.Text = "Add"; - this.addUrlButton.UseVisualStyleBackColor = true; - this.addUrlButton.Click += new System.EventHandler(this.addUrlButton_Click); - // - // upButton - // - this.upButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.upButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.upButton.Location = new System.Drawing.Point(190, 165); - this.upButton.Margin = new System.Windows.Forms.Padding(0); - this.upButton.Name = "upButton"; - this.upButton.Size = new System.Drawing.Size(25, 25); - this.upButton.TabIndex = 3; - this.upButton.Text = "▲"; - this.urlButtonsTooltip.SetToolTip(this.upButton, "Move selected URLs up"); - this.upButton.UseVisualStyleBackColor = true; - this.upButton.Click += new System.EventHandler(this.MoveAllSelectedUrlsUp_Click); - // - // downButton - // - this.downButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.downButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.downButton.Location = new System.Drawing.Point(215, 165); - this.downButton.Margin = new System.Windows.Forms.Padding(0); - this.downButton.Name = "downButton"; - this.downButton.Size = new System.Drawing.Size(25, 25); - this.downButton.TabIndex = 12; - this.downButton.Text = "▼"; - this.urlButtonsTooltip.SetToolTip(this.downButton, "Move selected URLs down"); - this.downButton.UseVisualStyleBackColor = true; - this.downButton.Click += new System.EventHandler(this.MoveAllSelectedUrlsDown_Click); - // - // deleteButton - // - this.deleteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.deleteButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.deleteButton.ForeColor = System.Drawing.Color.Red; - this.deleteButton.Location = new System.Drawing.Point(59, 165); - this.deleteButton.Name = "deleteButton"; - this.deleteButton.Size = new System.Drawing.Size(25, 25); - this.deleteButton.TabIndex = 13; - this.deleteButton.Text = "X"; - this.urlButtonsTooltip.SetToolTip(this.deleteButton, "DELETE selected URLs"); - this.deleteButton.UseVisualStyleBackColor = true; - this.deleteButton.Click += new System.EventHandler(this.DeleteAllSelectedUrls_Click); + // _labelSecondsToDisplay + // + this._labelSecondsToDisplay.Anchor = AnchorStyles.Left; + this._labelSecondsToDisplay.AutoSize = true; + this._labelSecondsToDisplay.Location = new Point(405, 18); + this._labelSecondsToDisplay.Margin = new Padding(6, 0, 6, 0); + this._labelSecondsToDisplay.Name = "_labelSecondsToDisplay"; + this._labelSecondsToDisplay.Size = new Size(314, 32); + this._labelSecondsToDisplay.TabIndex = 7; + this._labelSecondsToDisplay.Text = "Seconds to display each site"; + this._labelSecondsToDisplay.TextAlign = ContentAlignment.MiddleLeft; + // + // _checkBoxShuffle + // + this._checkBoxShuffle.AutoSize = true; + this._checkBoxShuffle.Dock = DockStyle.Left; + this._checkBoxShuffle.Location = new Point(6, 7); + this._checkBoxShuffle.Margin = new Padding(6, 7, 6, 7); + this._checkBoxShuffle.Name = "_checkBoxShuffle"; + this._checkBoxShuffle.Size = new Size(267, 54); + this._checkBoxShuffle.TabIndex = 5; + this._checkBoxShuffle.Text = "Shuffle display order"; + this._checkBoxShuffle.UseVisualStyleBackColor = true; + // + // _listViewURLs + // + this._listViewURLs.Dock = DockStyle.Fill; + this._listViewURLs.HideSelection = false; + this._listViewURLs.LabelEdit = true; + this._listViewURLs.Location = new Point(4, 79); + this._listViewURLs.Margin = new Padding(4, 5, 4, 5); + this._listViewURLs.Name = "_listViewURLs"; + this._listViewURLs.Size = new Size(723, 442); + this._listViewURLs.TabIndex = 0; + this._listViewURLs.UseCompatibleStateImageBehavior = false; + this._listViewURLs.View = View.List; + // + // _buttonAddURL + // + this._buttonAddURL.Location = new Point(8, 8); + this._buttonAddURL.Margin = new Padding(4); + this._buttonAddURL.Name = "_buttonAddURL"; + this._buttonAddURL.Size = new Size(150, 44); + this._buttonAddURL.TabIndex = 11; + this._buttonAddURL.Text = "Add URL"; + this._buttonAddURL.UseVisualStyleBackColor = true; + this._buttonAddURL.Click += new EventHandler(this.AddUrlButton_Click); + // + // _buttonUp + // + this._buttonUp.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right))); + this._buttonUp.Font = new Font("Microsoft Sans Serif", 6F, FontStyle.Regular, GraphicsUnit.Point); + this._buttonUp.Location = new Point(619, 8); + this._buttonUp.Margin = new Padding(4); + this._buttonUp.Name = "_buttonUp"; + this._buttonUp.Size = new Size(44, 44); + this._buttonUp.TabIndex = 3; + this._buttonUp.Text = "▲"; + this._toolTipURLButtons.SetToolTip(this._buttonUp, "Move selected URLs up"); + this._buttonUp.UseVisualStyleBackColor = true; + this._buttonUp.Click += new EventHandler(this.MoveAllSelectedUrlsUp_Click); + // + // _buttonDown + // + this._buttonDown.Font = new Font("Microsoft Sans Serif", 6F, FontStyle.Regular, GraphicsUnit.Point); + this._buttonDown.Location = new Point(671, 8); + this._buttonDown.Margin = new Padding(4); + this._buttonDown.Name = "_buttonDown"; + this._buttonDown.Size = new Size(44, 44); + this._buttonDown.TabIndex = 12; + this._buttonDown.Text = "▼"; + this._toolTipURLButtons.SetToolTip(this._buttonDown, "Move selected URLs down"); + this._buttonDown.UseVisualStyleBackColor = true; + this._buttonDown.Click += new EventHandler(this.MoveAllSelectedUrlsDown_Click); + // + // _buttonDeleteURL + // + this._buttonDeleteURL.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + this._buttonDeleteURL.ForeColor = Color.Black; + this._buttonDeleteURL.Location = new Point(166, 8); + this._buttonDeleteURL.Margin = new Padding(4); + this._buttonDeleteURL.Name = "_buttonDeleteURL"; + this._buttonDeleteURL.Size = new Size(150, 44); + this._buttonDeleteURL.TabIndex = 13; + this._buttonDeleteURL.Text = "Delete URL"; + this._toolTipURLButtons.SetToolTip(this._buttonDeleteURL, "DELETE selected URLs"); + this._buttonDeleteURL.UseVisualStyleBackColor = true; + this._buttonDeleteURL.Click += new EventHandler(this.DeleteAllSelectedUrls_Click); + // + // _tableLayoutPanelMain + // + this._tableLayoutPanelMain.AutoSize = true; + this._tableLayoutPanelMain.AutoSizeMode = AutoSizeMode.GrowAndShrink; + this._tableLayoutPanelMain.ColumnCount = 1; + this._tableLayoutPanelMain.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainTop, 0, 0); + this._tableLayoutPanelMain.Controls.Add(this._listViewURLs, 0, 1); + this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainBottom, 0, 2); + this._tableLayoutPanelMain.Dock = DockStyle.Fill; + this._tableLayoutPanelMain.Location = new Point(0, 0); + this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; + this._tableLayoutPanelMain.RowCount = 3; + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 74F)); + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 74F)); + this._tableLayoutPanelMain.Size = new Size(731, 600); + this._tableLayoutPanelMain.TabIndex = 14; + // + // _tableLayoutPanelMainTop + // + this._tableLayoutPanelMainTop.AutoSize = true; + this._tableLayoutPanelMainTop.AutoSizeMode = AutoSizeMode.GrowAndShrink; + this._tableLayoutPanelMainTop.ColumnCount = 4; + this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 52F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 52F)); + this._tableLayoutPanelMainTop.Controls.Add(this._buttonAddURL, 0, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._buttonDown, 3, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._buttonUp, 2, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._buttonDeleteURL, 1, 0); + this._tableLayoutPanelMainTop.Dock = DockStyle.Fill; + this._tableLayoutPanelMainTop.Location = new Point(4, 4); + this._tableLayoutPanelMainTop.Margin = new Padding(4); + this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; + this._tableLayoutPanelMainTop.Padding = new Padding(4); + this._tableLayoutPanelMainTop.RowCount = 1; + this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMainTop.Size = new Size(723, 66); + this._tableLayoutPanelMainTop.TabIndex = 0; + // + // _tableLayoutPanelMainBottom + // + this._tableLayoutPanelMainBottom.AutoSize = true; + this._tableLayoutPanelMainBottom.AutoSizeMode = AutoSizeMode.GrowAndShrink; + this._tableLayoutPanelMainBottom.ColumnCount = 3; + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainBottom.Controls.Add(this._checkBoxShuffle, 0, 0); + this._tableLayoutPanelMainBottom.Controls.Add(this._labelSecondsToDisplay, 2, 0); + this._tableLayoutPanelMainBottom.Controls.Add(this._numericUpDownSecondsToDisplay, 1, 0); + this._tableLayoutPanelMainBottom.Dock = DockStyle.Fill; + this._tableLayoutPanelMainBottom.Location = new Point(3, 529); + this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; + this._tableLayoutPanelMainBottom.RowCount = 1; + this._tableLayoutPanelMainBottom.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMainBottom.Size = new Size(725, 68); + this._tableLayoutPanelMainBottom.TabIndex = 1; // // PrefsByScreenUserControl // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.deleteButton); - this.Controls.Add(this.downButton); - this.Controls.Add(this.upButton); - this.Controls.Add(this.nudRotationInterval); - this.Controls.Add(this.label3); - this.Controls.Add(this.cbRandomize); - this.Controls.Add(this.lvUrls); - this.Controls.Add(this.addUrlButton); - this.Margin = new System.Windows.Forms.Padding(2); + this.AutoScaleDimensions = new SizeF(13F, 32F); + this.AutoScaleMode = AutoScaleMode.Font; + this.BackColor = Color.White; + this.Controls.Add(this._tableLayoutPanelMain); + this.Margin = new Padding(4, 5, 4, 5); this.Name = "PrefsByScreenUserControl"; - this.Size = new System.Drawing.Size(250, 250); - ((System.ComponentModel.ISupportInitialize)(this.nudRotationInterval)).EndInit(); + this.Size = new Size(731, 600); + ((ISupportInitialize)(this._numericUpDownSecondsToDisplay)).EndInit(); + this._tableLayoutPanelMain.ResumeLayout(false); + this._tableLayoutPanelMain.PerformLayout(); + this._tableLayoutPanelMainTop.ResumeLayout(false); + this._tableLayoutPanelMainBottom.ResumeLayout(false); + this._tableLayoutPanelMainBottom.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); - } #endregion - public System.Windows.Forms.NumericUpDown nudRotationInterval; - private System.Windows.Forms.Label label3; - public System.Windows.Forms.CheckBox cbRandomize; - public System.Windows.Forms.ListView lvUrls; - private System.Windows.Forms.ToolTip urlButtonsTooltip; - private System.Windows.Forms.Button addUrlButton; - private System.Windows.Forms.Button upButton; - private System.Windows.Forms.Button downButton; - private System.Windows.Forms.Button deleteButton; + + private TableLayoutPanel _tableLayoutPanelMain; + + private TableLayoutPanel _tableLayoutPanelMainTop; + private Button _buttonAddURL; + private Button _buttonDeleteURL; + private Button _buttonUp; + private Button _buttonDown; + + public ListView _listViewURLs; + + private TableLayoutPanel _tableLayoutPanelMainBottom; + public CheckBox _checkBoxShuffle; + public NumericUpDown _numericUpDownSecondsToDisplay; + private Label _labelSecondsToDisplay; + + private ToolTip _toolTipURLButtons; } } diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index 9978f6d..bb495e5 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -17,13 +17,13 @@ private void MoveAllSelectedUrlsDown_Click(object sender, EventArgs e) // scan from the bottom up, but don't start moving selected items down until // we find an unselected gap to move items(s) down in to. - for (int i = lvUrls.Items.Count - 1; i >= 0; i--) + for (int i = _listViewURLs.Items.Count - 1; i >= 0; i--) { - if (lvUrls.Items[i].Selected) + if (_listViewURLs.Items[i].Selected) { if (gapFound) { - Swap(lvUrls.Items, i, i + 1); + Swap(_listViewURLs.Items, i, i + 1); } } else @@ -35,7 +35,7 @@ private void MoveAllSelectedUrlsDown_Click(object sender, EventArgs e) // 'select'ing the list makes sure the selections of items within it are being displayed. // Otherwise the button becomes the 'selected' control and the selections within the list // are invisible or hard to see. - lvUrls.Select(); + _listViewURLs.Select(); } private void MoveAllSelectedUrlsUp_Click(object sender, EventArgs e) @@ -45,13 +45,13 @@ private void MoveAllSelectedUrlsUp_Click(object sender, EventArgs e) // scan through for all selected, but don't start moving selected items up until // we find an unselected gap to move items(s) up in to. - for (int i = 0; i < lvUrls.Items.Count; i++) + for (int i = 0; i < _listViewURLs.Items.Count; i++) { - if (lvUrls.Items[i].Selected) + if (_listViewURLs.Items[i].Selected) { if (gapFound) { - Swap(lvUrls.Items, i, i - 1); + Swap(_listViewURLs.Items, i, i - 1); } } else @@ -63,7 +63,7 @@ private void MoveAllSelectedUrlsUp_Click(object sender, EventArgs e) // 'select'ing the list makes sure the selections of items within it are being displayed. // Otherwise the button becomes the 'selected' control and the selections within the list // are invisible or hard to see. - lvUrls.Select(); + _listViewURLs.Select(); } private void DeleteAllSelectedUrls_Click(object sender, EventArgs e) @@ -71,18 +71,18 @@ private void DeleteAllSelectedUrls_Click(object sender, EventArgs e) // TODO: undo capability? // TODO: make button grey out when no selection. // work from the bottom up, deleting any we find - for (int i = lvUrls.Items.Count - 1; i >= 0; i--) + for (int i = _listViewURLs.Items.Count - 1; i >= 0; i--) { - if (lvUrls.Items[i].Selected) + if (_listViewURLs.Items[i].Selected) { - lvUrls.Items[i].Remove(); + _listViewURLs.Items[i].Remove(); } } } - private void addUrlButton_Click(object sender, EventArgs e) + private void AddUrlButton_Click(object sender, EventArgs e) { - ListViewItem item = lvUrls.Items.Add(String.Empty); + ListViewItem item = _listViewURLs.Items.Add(string.Empty); item.BeginEdit(); } diff --git a/Program.cs b/Program.cs index 6fc190a..1212e6f 100644 --- a/Program.cs +++ b/Program.cs @@ -1,14 +1,14 @@ -using Microsoft.Win32; -using System; +using System; using System.Collections.Generic; using System.Drawing; -using System.IO; using System.Windows.Forms; namespace WebPageScreensaver { static class Program { + public const string Webpage = "http://github.com/carlossanlop/web-page-screensaver/"; + public const string KeyWebPageScreensaver = @"Software\WebPageScreensaver"; /// @@ -24,7 +24,7 @@ static void Main(string[] args) throw new NullReferenceException("Current process main module is null."); } - Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/ScreensaverForm.Designer.cs b/ScreensaverForm.Designer.cs index 8475ddb..cfc8d12 100644 --- a/ScreensaverForm.Designer.cs +++ b/ScreensaverForm.Designer.cs @@ -30,7 +30,6 @@ private void InitializeComponent() { this.webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2(); this.closeButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); // // webBrowser @@ -38,9 +37,10 @@ private void InitializeComponent() this.webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; this.webBrowser.Location = new System.Drawing.Point(0, 0); this.webBrowser.Margin = new System.Windows.Forms.Padding(4); - this.webBrowser.MinimumSize = new System.Drawing.Size(27, 25); + this.webBrowser.MinimumSize = new System.Drawing.Size(44, 50); this.webBrowser.Name = "webBrowser"; - this.webBrowser.Size = new System.Drawing.Size(379, 322); + this.webBrowser.Size = new System.Drawing.Size(616, 644); + this.webBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); this.webBrowser.TabIndex = 0; this.webBrowser.Text = "webBrowser"; this.webBrowser.ZoomFactor = 1D; @@ -48,23 +48,30 @@ private void InitializeComponent() // closeButton // this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.closeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.closeButton.Location = new System.Drawing.Point(323, 15); + this.closeButton.BackColor = System.Drawing.Color.Transparent; + this.closeButton.FlatAppearance.BorderColor = System.Drawing.Color.White; + this.closeButton.FlatAppearance.BorderSize = 0; + this.closeButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.closeButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.closeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.closeButton.ForeColor = System.Drawing.Color.Transparent; + this.closeButton.Location = new System.Drawing.Point(576, 0); this.closeButton.Margin = new System.Windows.Forms.Padding(4); this.closeButton.Name = "closeButton"; - this.closeButton.Size = new System.Drawing.Size(40, 28); + this.closeButton.Size = new System.Drawing.Size(40, 44); this.closeButton.TabIndex = 1; this.closeButton.Text = "X"; - this.closeButton.UseVisualStyleBackColor = true; + this.closeButton.UseVisualStyleBackColor = false; this.closeButton.Visible = false; this.closeButton.Click += new System.EventHandler(this.closeButton_Click); - // + // // ScreensaverForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(379, 322); + this.ClientSize = new System.Drawing.Size(616, 644); this.Controls.Add(this.closeButton); this.Controls.Add(this.webBrowser); this.ForeColor = System.Drawing.Color.White; From a3aac9453117e8817831792a5c23489e4c8c69a4 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Mon, 7 Sep 2020 23:06:02 -0700 Subject: [PATCH 24/45] Remove obsolete reg files --- PreUpgradePrefs.reg | Bin 538 -> 0 bytes ThreeScreensSetUp.reg | Bin 1014 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 PreUpgradePrefs.reg delete mode 100644 ThreeScreensSetUp.reg diff --git a/PreUpgradePrefs.reg b/PreUpgradePrefs.reg deleted file mode 100644 index 8c9e5ce479fc52c52a2d34a97b655766785e60f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 538 zcmZXR-Acni6oltm@Et-PAk_O|}HD!6(Xe#B->F_&(}N*YrH- zMMF*D%Rx7qfTtRB&h^CK>kZDW3fLTx8Q)jkftQ@dn#Z_9qan75s?Sj&g{Rg^sm^%c zVF~)6>Qn_kv7@ zW7}bi_Z9!Z$+qbKFsJ=ALn_Rl(=FWR_%nX%5A462auSst$o8DFLz}XQm39xK=*n(p e6BWCzWA5d*qoBsNQ=wBwmvzs6*}L5Fo5m0AFI?yV diff --git a/ThreeScreensSetUp.reg b/ThreeScreensSetUp.reg deleted file mode 100644 index 7fb1ccf2ce8d85e563cb2ac37aba6c622c9b27ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1014 zcmb7@-A=+#5QOL2#CIS(KmnsSCSDk$(HPVekQgrOGtXg3KwWF;PNX(Jki_PGjOR@qs+mxpuYV?t7i< zlAb#~=|mmye4;D0i92fX?(2cyL@!{@6@V6z>GJI9hPcmLOV2JJ!I6@iIo3zVPz85L ze@gC}^J8i==9#%E7pm%ryG{R;it4hbNi=kIo7hcoLRV!yE#6+;L;;oS-VRv9Pczk* zECcE?dQu&##$`Tc%oOqTG-4vtVYB9XJ>rCXZ8ewgI*c!O^nz~Vo}efAmNmpR+eHYc zIlsPwrB Date: Mon, 7 Sep 2020 23:06:15 -0700 Subject: [PATCH 25/45] Heavy update. --- Extensions.cs | 78 ++++++ MouseEventHandler.cs | 43 ++++ MultiFormContext.cs | 23 ++ MultiScreenMode.cs | 21 ++ Preferences.cs | 79 ++++++ PreferencesForm.Designer.cs | 255 ++++++++++--------- PreferencesForm.cs | 169 +++++++------ PreferencesManager.cs | 356 --------------------------- PrefsByScreenUserControl.Designer.cs | 219 ++++++++-------- PrefsByScreenUserControl.cs | 2 +- Program.cs | 69 +++--- README.md | 17 +- ScreenInformation.cs | 104 ++++++++ ScreensaverForm.Designer.cs | 75 +++--- ScreensaverForm.cs | 130 +++------- 15 files changed, 792 insertions(+), 848 deletions(-) create mode 100644 Extensions.cs create mode 100644 MouseEventHandler.cs create mode 100644 MultiFormContext.cs create mode 100644 MultiScreenMode.cs create mode 100644 Preferences.cs delete mode 100644 PreferencesManager.cs create mode 100644 ScreenInformation.cs diff --git a/Extensions.cs b/Extensions.cs new file mode 100644 index 0000000..e6384e0 --- /dev/null +++ b/Extensions.cs @@ -0,0 +1,78 @@ +using Microsoft.Win32; +using System; + +namespace WebPageScreensaver +{ + public static class Extensions + { + public static RegistryKey GetOrCreateSubKey(this RegistryKey root, string subKeyName) + { + if (root == null) + { + throw new ArgumentNullException(nameof(root)); + } + if (string.IsNullOrWhiteSpace(subKeyName)) + { + throw new ArgumentException(nameof(subKeyName)); + } + + RegistryKey? key = root.OpenSubKey(subKeyName, writable: true); + if (key == null) + { + key = root.CreateSubKey(subKeyName, writable: true); + if (key == null) + { + throw new UnauthorizedAccessException($"Could not get/create key to registry: {subKeyName}"); + } + } + return key; + } + + public static string GetOrCreateValue(this RegistryKey root, string valueName, object defaultValue) + { + if (root == null) + { + throw new ArgumentNullException(nameof(root)); + } + if (defaultValue == null) + { + throw new ArgumentNullException(nameof(defaultValue)); + } + if (string.IsNullOrWhiteSpace(valueName)) + { + throw new ArgumentNullException(nameof(valueName)); + } + + object? obj = root.GetValue(valueName); + if (obj == null) + { + root.SetValue(valueName, defaultValue!.ToString()); + obj = root.GetValue(valueName); + if (obj == null) + { + throw new UnauthorizedAccessException($"Could not get/create the registry value: {valueName}"); + } + } + return obj!.ToString(); + } + + public static string GetOrCreateValue(this RegistryKey root, string valueName) + { + if (root == null) + { + throw new ArgumentNullException(nameof(root)); + } + if (string.IsNullOrWhiteSpace(valueName)) + { + throw new ArgumentNullException(nameof(valueName)); + } + + object? obj = root.GetValue(valueName); + if (obj == null) + { + throw new UnauthorizedAccessException($"Could not get/create the registry value: {valueName}"); + } + return obj!.ToString(); + } + } +} diff --git a/MouseEventHandler.cs b/MouseEventHandler.cs new file mode 100644 index 0000000..8518b9e --- /dev/null +++ b/MouseEventHandler.cs @@ -0,0 +1,43 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace WebPageScreensaver +{ + /// + /// Screensavers, and especially multi-window apps, can get spurious WM_MOUSEMOVE events + /// that don't actually involve any movement (cursor chnages and some mouse driver software + /// can generate them, for example) - so we record the actual mouse position and compare + /// against it for actual movement. + /// + internal class MouseEventHandler : IMessageFilter + { + private const int WM_MOUSEMOVE = 0x0200; + private const int WM_MBUTTONDBLCLK = 0x209; + private const int WM_KEYDOWN = 0x100; + private const int WM_KEYUP = 0x101; + + private Point? _lastMousePosition; + + public delegate void UserEvent(); + + public event UserEvent? Event; + + public bool PreFilterMessage(ref Message m) + { + if (_lastMousePosition == null && m.Msg == WM_MOUSEMOVE) + { + _lastMousePosition = Cursor.Position; + } + + if ((m.Msg == WM_MOUSEMOVE && Cursor.Position != _lastMousePosition) + || (m.Msg > WM_MOUSEMOVE && m.Msg <= WM_MBUTTONDBLCLK) || m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) + { + + Event?.Invoke(); + } + + // Always allow message to continue to the next filter control + return false; + } + } +} diff --git a/MultiFormContext.cs b/MultiFormContext.cs new file mode 100644 index 0000000..736821f --- /dev/null +++ b/MultiFormContext.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace WebPageScreensaver +{ + internal class MultiFormContext : ApplicationContext + { + public MultiFormContext(List forms) + { + if (forms == null) + { + throw new ArgumentNullException(nameof(forms)); + } + + foreach (Form form in forms) + { + form.FormClosed += (s, args) => ExitThread(); + form.Show(); + } + } + } +} diff --git a/MultiScreenMode.cs b/MultiScreenMode.cs new file mode 100644 index 0000000..e6324bc --- /dev/null +++ b/MultiScreenMode.cs @@ -0,0 +1,21 @@ +namespace WebPageScreensaver +{ + /// + /// Specifies the different ways a screensaver can be shown in multiple screens. + /// + internal enum MultiScreenMode + { + /// + /// Same webpage in all screens. + /// + Mirror, + /// + /// Each screen has its own individual list of webpages. + /// + Separate, + /// + /// Show one webpage split among all the screens. + /// + Span + } +} diff --git a/Preferences.cs b/Preferences.cs new file mode 100644 index 0000000..e9bfe4f --- /dev/null +++ b/Preferences.cs @@ -0,0 +1,79 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace WebPageScreensaver +{ + internal static class Preferences + { + #region Setting names and default values + + private struct SettingName + { + public const string ScreenCount = "ScreenCount"; + public const string CloseOnMouseMovement = "CloseOnMouseMovement"; + public const string MultiScreenMode = "MultiScreenMode"; + public const string RotationInterval = "RotationInterval"; + public const string Shuffle = "Shuffle"; + public const string Url = "Url"; + } + + private struct SettingDefaultValue + { + public const int ScreenCount = 1; + public const bool CloseOnMouseMovement = true; + public const MultiScreenMode MultiScreen = MultiScreenMode.Separate; + public const int RotationInterval = 30; + public const bool Shuffle = false; + public const string URLsPrimaryScreen = "https://dotnet.microsoft.com/ https://code.visualstudio.com/"; + } + + #endregion + + #region Private fields + + private const string KeyWebPageScreensaver = @"Software\WebPageScreensaver"; + + #endregion + + #region Properties + + private static RegistryKey RootKey => Registry.CurrentUser.GetOrCreateSubKey(KeyWebPageScreensaver); + + public static int ScreenCount => Screen.AllScreens.Length; + + public static MultiScreenMode MultiScreen + { + get => Enum.Parse(RootKey.GetOrCreateValue(SettingName.MultiScreenMode, SettingDefaultValue.MultiScreen)); + set => RootKey.SetValue(SettingName.MultiScreenMode, value); + } + + public static bool CloseOnMouseMovement + { + get => bool.Parse(RootKey.GetOrCreateValue(SettingName.CloseOnMouseMovement, SettingDefaultValue.CloseOnMouseMovement)); + set => RootKey.SetValue(SettingName.CloseOnMouseMovement, value); + } + + public static Dictionary Screens + { + get + { + Dictionary screens = new Dictionary(); + + MultiScreenMode multiScreenMode = MultiScreen; + for (int screenNumber = 1; screenNumber <= ScreenCount; screenNumber++) + { + string screenKeyName = $"Screen{screenNumber}"; + RegistryKey subKey = RootKey.GetOrCreateSubKey(screenKeyName); + ScreenInformation info = new ScreenInformation(subKey, screenNumber, multiScreenMode); + screens.Add(screenNumber, info); + } + + return screens; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 4bd3b75..711dc00 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -1,15 +1,14 @@ using System; -using System.Drawing; using System.Windows.Forms; namespace WebPageScreensaver { - partial class PreferencesForm + internal partial class PreferencesForm { /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private System.ComponentModel.IContainer _components = null; /// /// Clean up any resources being used. @@ -17,9 +16,9 @@ partial class PreferencesForm /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (components != null)) + if (disposing && (_components != null)) { - components.Dispose(); + _components.Dispose(); } base.Dispose(disposing); } @@ -32,24 +31,24 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this._linkLabelProjectURL = new LinkLabel(); - this._tabControlScreens = new TabControl(); - this._tabPageScreen = new TabPage(); - this._labelWebsiteURLs = new Label(); - this._toolTipScreenMode = new ToolTip(this.components); - this._radioButtonSeparateScreens = new RadioButton(); - this._radioButtonMirrorScreens = new RadioButton(); - this._radioButtonSpanScreens = new RadioButton(); - this._tableLayoutPanelMain = new TableLayoutPanel(); - this._tableLayoutPanelMainBottom = new TableLayoutPanel(); - this._buttonCancel = new Button(); - this._buttonOK = new Button(); - this._tableLayoutPanelMainTop = new TableLayoutPanel(); - this._labelMultiScreen = new Label(); - this._checkBoxCloseOnMouseMovement = new CheckBox(); - this._flowLayoutPanelMultiScreenButtons = new FlowLayoutPanel(); + this._components = new System.ComponentModel.Container(); + this._linkLabelProjectURL = new System.Windows.Forms.LinkLabel(); + this._tabControlScreens = new System.Windows.Forms.TabControl(); + this._tabPageScreen = new System.Windows.Forms.TabPage(); this._prefsByScreenUserControl = new WebPageScreensaver.PrefsByScreenUserControl(); + this._labelWebsiteURLs = new System.Windows.Forms.Label(); + this._toolTipScreenMode = new System.Windows.Forms.ToolTip(this._components); + this._radioButtonSeparateScreens = new System.Windows.Forms.RadioButton(); + this._radioButtonMirrorScreens = new System.Windows.Forms.RadioButton(); + this._radioButtonSpanScreens = new System.Windows.Forms.RadioButton(); + this._tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel(); + this._tableLayoutPanelMainBottom = new System.Windows.Forms.TableLayoutPanel(); + this._buttonCancel = new System.Windows.Forms.Button(); + this._buttonOK = new System.Windows.Forms.Button(); + this._tableLayoutPanelMainTop = new System.Windows.Forms.TableLayoutPanel(); + this._labelMultiScreen = new System.Windows.Forms.Label(); + this._checkBoxCloseOnMouseMovement = new System.Windows.Forms.CheckBox(); + this._flowLayoutPanelMultiScreenButtons = new System.Windows.Forms.FlowLayoutPanel(); this._tabControlScreens.SuspendLayout(); this._tabPageScreen.SuspendLayout(); this._tableLayoutPanelMain.SuspendLayout(); @@ -60,76 +59,88 @@ private void InitializeComponent() // // _linkLabelProjectURL // - this._linkLabelProjectURL.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Bottom) - | AnchorStyles.Left))); + this._linkLabelProjectURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this._linkLabelProjectURL.AutoSize = true; - this._linkLabelProjectURL.Location = new Point(6, 0); - this._linkLabelProjectURL.Margin = new Padding(6, 0, 6, 0); + this._linkLabelProjectURL.Location = new System.Drawing.Point(6, 0); + this._linkLabelProjectURL.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this._linkLabelProjectURL.Name = "_linkLabelProjectURL"; - this._linkLabelProjectURL.Size = new Size(99, 59); + this._linkLabelProjectURL.Size = new System.Drawing.Size(99, 59); this._linkLabelProjectURL.TabIndex = 1; this._linkLabelProjectURL.TabStop = true; this._linkLabelProjectURL.Text = "Website"; - this._linkLabelProjectURL.TextAlign = ContentAlignment.MiddleCenter; + this._linkLabelProjectURL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this._toolTipScreenMode.SetToolTip(this._linkLabelProjectURL, "http://github.com/carlossanlop/web-page-screensaver/"); - this._linkLabelProjectURL.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llProjectLocationUrl_LinkClicked); + this._linkLabelProjectURL.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelProjectURL_LinkClicked); // - // screenTabControl + // _tabControlScreens // this._tabControlScreens.Controls.Add(this._tabPageScreen); - this._tabControlScreens.Dock = DockStyle.Fill; - this._tabControlScreens.Location = new Point(4, 186); - this._tabControlScreens.Margin = new Padding(4, 5, 4, 5); - this._tabControlScreens.Name = "screenTabControl"; + this._tabControlScreens.Dock = System.Windows.Forms.DockStyle.Fill; + this._tabControlScreens.Location = new System.Drawing.Point(4, 186); + this._tabControlScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._tabControlScreens.Name = "_tabControlScreens"; this._tabControlScreens.SelectedIndex = 0; - this._tabControlScreens.Size = new Size(990, 697); + this._tabControlScreens.Size = new System.Drawing.Size(990, 441); this._tabControlScreens.TabIndex = 13; // - // screenTabPage1 + // _tabPageScreen // this._tabPageScreen.Controls.Add(this._prefsByScreenUserControl); - this._tabPageScreen.Location = new Point(8, 46); - this._tabPageScreen.Margin = new Padding(4, 5, 4, 5); - this._tabPageScreen.Name = "screenTabPage1"; - this._tabPageScreen.Padding = new Padding(4, 5, 4, 5); - this._tabPageScreen.Size = new Size(974, 643); + this._tabPageScreen.Location = new System.Drawing.Point(8, 46); + this._tabPageScreen.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._tabPageScreen.Name = "_tabPageScreen"; + this._tabPageScreen.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._tabPageScreen.Size = new System.Drawing.Size(974, 387); this._tabPageScreen.TabIndex = 0; this._tabPageScreen.Text = "Screen 1"; this._tabPageScreen.UseVisualStyleBackColor = true; // + // _prefsByScreenUserControl + // + this._prefsByScreenUserControl.AutoSize = true; + this._prefsByScreenUserControl.BackColor = System.Drawing.Color.White; + this._prefsByScreenUserControl.Dock = System.Windows.Forms.DockStyle.Fill; + this._prefsByScreenUserControl.Location = new System.Drawing.Point(4, 5); + this._prefsByScreenUserControl.Margin = new System.Windows.Forms.Padding(0); + this._prefsByScreenUserControl.MinimumSize = new System.Drawing.Size(640, 480); + this._prefsByScreenUserControl.Name = "_prefsByScreenUserControl"; + this._prefsByScreenUserControl.Size = new System.Drawing.Size(966, 480); + this._prefsByScreenUserControl.TabIndex = 25; + // // _labelWebsiteURLs // this._labelWebsiteURLs.AutoSize = true; - this._labelWebsiteURLs.Dock = DockStyle.Left; - this._labelWebsiteURLs.Location = new Point(6, 122); - this._labelWebsiteURLs.Margin = new Padding(6); + this._labelWebsiteURLs.Dock = System.Windows.Forms.DockStyle.Left; + this._labelWebsiteURLs.Location = new System.Drawing.Point(6, 122); + this._labelWebsiteURLs.Margin = new System.Windows.Forms.Padding(6); this._labelWebsiteURLs.Name = "_labelWebsiteURLs"; - this._labelWebsiteURLs.Size = new Size(157, 53); + this._labelWebsiteURLs.Size = new System.Drawing.Size(157, 53); this._labelWebsiteURLs.TabIndex = 2; this._labelWebsiteURLs.Text = "Website URLs"; - this._labelWebsiteURLs.TextAlign = ContentAlignment.BottomLeft; + this._labelWebsiteURLs.TextAlign = System.Drawing.ContentAlignment.BottomLeft; // // _radioButtonSeparateScreens // this._radioButtonSeparateScreens.AutoSize = true; - this._radioButtonSeparateScreens.Location = new Point(233, 9); - this._radioButtonSeparateScreens.Margin = new Padding(4, 5, 4, 5); + this._radioButtonSeparateScreens.Location = new System.Drawing.Point(233, 9); + this._radioButtonSeparateScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._radioButtonSeparateScreens.Name = "_radioButtonSeparateScreens"; - this._radioButtonSeparateScreens.Size = new Size(138, 36); + this._radioButtonSeparateScreens.Size = new System.Drawing.Size(138, 36); this._radioButtonSeparateScreens.TabIndex = 15; this._radioButtonSeparateScreens.TabStop = true; this._radioButtonSeparateScreens.Tag = "MultiScreenMode"; this._radioButtonSeparateScreens.Text = "Separate"; - this._toolTipScreenMode.SetToolTip(this._radioButtonSeparateScreens, "Each to their own."); + this._toolTipScreenMode.SetToolTip(this._radioButtonSeparateScreens, "Each to their own!"); this._radioButtonSeparateScreens.UseVisualStyleBackColor = true; // // _radioButtonMirrorScreens // this._radioButtonMirrorScreens.AutoSize = true; - this._radioButtonMirrorScreens.Location = new Point(114, 9); - this._radioButtonMirrorScreens.Margin = new Padding(4, 5, 4, 5); + this._radioButtonMirrorScreens.Location = new System.Drawing.Point(114, 9); + this._radioButtonMirrorScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._radioButtonMirrorScreens.Name = "_radioButtonMirrorScreens"; - this._radioButtonMirrorScreens.Size = new Size(111, 36); + this._radioButtonMirrorScreens.Size = new System.Drawing.Size(111, 36); this._radioButtonMirrorScreens.TabIndex = 26; this._radioButtonMirrorScreens.TabStop = true; this._radioButtonMirrorScreens.Tag = "MultiScreenMode"; @@ -141,10 +152,10 @@ private void InitializeComponent() // this._radioButtonSpanScreens.AutoSize = true; this._radioButtonSpanScreens.Checked = true; - this._radioButtonSpanScreens.Location = new Point(8, 9); - this._radioButtonSpanScreens.Margin = new Padding(4, 5, 4, 5); + this._radioButtonSpanScreens.Location = new System.Drawing.Point(8, 9); + this._radioButtonSpanScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._radioButtonSpanScreens.Name = "_radioButtonSpanScreens"; - this._radioButtonSpanScreens.Size = new Size(98, 36); + this._radioButtonSpanScreens.Size = new System.Drawing.Size(98, 36); this._radioButtonSpanScreens.TabIndex = 21; this._radioButtonSpanScreens.TabStop = true; this._radioButtonSpanScreens.Tag = "MultiScreenMode"; @@ -155,154 +166,143 @@ private void InitializeComponent() // _tableLayoutPanelMain // this._tableLayoutPanelMain.AutoSize = true; - this._tableLayoutPanelMain.AutoSizeMode = AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMain.ColumnCount = 1; - this._tableLayoutPanelMain.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMain.Controls.Add(this._tabControlScreens, 0, 2); this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainBottom, 0, 3); this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainTop, 0, 0); this._tableLayoutPanelMain.Controls.Add(this._labelWebsiteURLs, 0, 1); - this._tableLayoutPanelMain.Dock = DockStyle.Fill; - this._tableLayoutPanelMain.Location = new Point(0, 0); - this._tableLayoutPanelMain.Margin = new Padding(4); + this._tableLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill; + this._tableLayoutPanelMain.Location = new System.Drawing.Point(0, 0); + this._tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(4); this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; this._tableLayoutPanelMain.RowCount = 4; - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 116F)); - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F)); - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F)); - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); - this._tableLayoutPanelMain.Size = new Size(998, 953); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 116F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 65F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 65F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this._tableLayoutPanelMain.Size = new System.Drawing.Size(998, 697); this._tableLayoutPanelMain.TabIndex = 19; // // _tableLayoutPanelMainBottom // this._tableLayoutPanelMainBottom.ColumnCount = 3; - this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); - this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this._tableLayoutPanelMainBottom.Controls.Add(this._buttonCancel, 2, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._linkLabelProjectURL, 0, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._buttonOK, 1, 0); - this._tableLayoutPanelMainBottom.Dock = DockStyle.Fill; - this._tableLayoutPanelMainBottom.Location = new Point(3, 891); + this._tableLayoutPanelMainBottom.Dock = System.Windows.Forms.DockStyle.Fill; + this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(3, 635); this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; this._tableLayoutPanelMainBottom.RowCount = 1; - this._tableLayoutPanelMainBottom.RowStyles.Add(new RowStyle()); - this._tableLayoutPanelMainBottom.Size = new Size(992, 59); + this._tableLayoutPanelMainBottom.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(992, 59); this._tableLayoutPanelMainBottom.TabIndex = 0; // // _buttonCancel // - this._buttonCancel.Anchor = AnchorStyles.None; - this._buttonCancel.DialogResult = DialogResult.Cancel; - this._buttonCancel.Location = new Point(836, 7); - this._buttonCancel.Margin = new Padding(6); + this._buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.None; + this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this._buttonCancel.Location = new System.Drawing.Point(836, 7); + this._buttonCancel.Margin = new System.Windows.Forms.Padding(6); this._buttonCancel.Name = "_buttonCancel"; - this._buttonCancel.Size = new Size(150, 44); + this._buttonCancel.Size = new System.Drawing.Size(150, 44); this._buttonCancel.TabIndex = 6; this._buttonCancel.Text = "Cancel"; this._buttonCancel.UseVisualStyleBackColor = true; + this._buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // _buttonOK // - this._buttonOK.Anchor = AnchorStyles.None; - this._buttonOK.DialogResult = DialogResult.OK; - this._buttonOK.Location = new Point(674, 7); - this._buttonOK.Margin = new Padding(6); + this._buttonOK.Anchor = System.Windows.Forms.AnchorStyles.None; + this._buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this._buttonOK.Location = new System.Drawing.Point(674, 7); + this._buttonOK.Margin = new System.Windows.Forms.Padding(6); this._buttonOK.Name = "_buttonOK"; - this._buttonOK.Size = new Size(150, 44); + this._buttonOK.Size = new System.Drawing.Size(150, 44); this._buttonOK.TabIndex = 8; this._buttonOK.Text = "OK"; this._buttonOK.UseVisualStyleBackColor = true; + this._buttonOK.Click += new System.EventHandler(this.ButtonOK_Click); // // _tableLayoutPanelMainTop // this._tableLayoutPanelMainTop.ColumnCount = 2; - this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this._tableLayoutPanelMainTop.Controls.Add(this._labelMultiScreen, 0, 0); this._tableLayoutPanelMainTop.Controls.Add(this._checkBoxCloseOnMouseMovement, 1, 0); this._tableLayoutPanelMainTop.Controls.Add(this._flowLayoutPanelMultiScreenButtons, 0, 1); - this._tableLayoutPanelMainTop.Dock = DockStyle.Fill; - this._tableLayoutPanelMainTop.Location = new Point(3, 3); + this._tableLayoutPanelMainTop.Dock = System.Windows.Forms.DockStyle.Fill; + this._tableLayoutPanelMainTop.Location = new System.Drawing.Point(3, 3); this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; this._tableLayoutPanelMainTop.RowCount = 2; - this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle()); - this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle()); - this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); - this._tableLayoutPanelMainTop.Size = new Size(992, 110); + this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(992, 110); this._tableLayoutPanelMainTop.TabIndex = 1; // // _labelMultiScreen // this._labelMultiScreen.AutoSize = true; - this._labelMultiScreen.Dock = DockStyle.Left; - this._labelMultiScreen.Location = new Point(6, 0); - this._labelMultiScreen.Margin = new Padding(6, 0, 6, 0); + this._labelMultiScreen.Dock = System.Windows.Forms.DockStyle.Left; + this._labelMultiScreen.Location = new System.Drawing.Point(6, 0); + this._labelMultiScreen.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this._labelMultiScreen.Name = "_labelMultiScreen"; - this._labelMultiScreen.Size = new Size(144, 50); + this._labelMultiScreen.Size = new System.Drawing.Size(144, 50); this._labelMultiScreen.TabIndex = 17; this._labelMultiScreen.Text = "Multiscreen:"; - this._labelMultiScreen.TextAlign = ContentAlignment.MiddleLeft; + this._labelMultiScreen.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // _checkBoxCloseOnMouseMovement // this._checkBoxCloseOnMouseMovement.AutoSize = true; this._checkBoxCloseOnMouseMovement.Checked = true; - this._checkBoxCloseOnMouseMovement.CheckState = CheckState.Checked; - this._checkBoxCloseOnMouseMovement.Dock = DockStyle.Left; - this._checkBoxCloseOnMouseMovement.Location = new Point(502, 7); - this._checkBoxCloseOnMouseMovement.Margin = new Padding(6, 7, 6, 7); + this._checkBoxCloseOnMouseMovement.CheckState = System.Windows.Forms.CheckState.Checked; + this._checkBoxCloseOnMouseMovement.Dock = System.Windows.Forms.DockStyle.Left; + this._checkBoxCloseOnMouseMovement.Location = new System.Drawing.Point(502, 7); + this._checkBoxCloseOnMouseMovement.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); this._checkBoxCloseOnMouseMovement.Name = "_checkBoxCloseOnMouseMovement"; - this._checkBoxCloseOnMouseMovement.Size = new Size(341, 36); + this._checkBoxCloseOnMouseMovement.Size = new System.Drawing.Size(341, 36); this._checkBoxCloseOnMouseMovement.TabIndex = 20; this._checkBoxCloseOnMouseMovement.Text = "Close on mouse movement"; this._checkBoxCloseOnMouseMovement.UseVisualStyleBackColor = true; // // _flowLayoutPanelMultiScreenButtons // - this._flowLayoutPanelMultiScreenButtons.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) - | AnchorStyles.Right))); + this._flowLayoutPanelMultiScreenButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._flowLayoutPanelMultiScreenButtons.AutoSize = true; - this._flowLayoutPanelMultiScreenButtons.AutoSizeMode = AutoSizeMode.GrowAndShrink; this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonSpanScreens); this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonMirrorScreens); this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonSeparateScreens); - this._flowLayoutPanelMultiScreenButtons.Location = new Point(4, 54); - this._flowLayoutPanelMultiScreenButtons.Margin = new Padding(4); + this._flowLayoutPanelMultiScreenButtons.Location = new System.Drawing.Point(4, 54); + this._flowLayoutPanelMultiScreenButtons.Margin = new System.Windows.Forms.Padding(4); this._flowLayoutPanelMultiScreenButtons.Name = "_flowLayoutPanelMultiScreenButtons"; - this._flowLayoutPanelMultiScreenButtons.Padding = new Padding(4); - this._flowLayoutPanelMultiScreenButtons.Size = new Size(488, 54); + this._flowLayoutPanelMultiScreenButtons.Padding = new System.Windows.Forms.Padding(4); + this._flowLayoutPanelMultiScreenButtons.Size = new System.Drawing.Size(488, 54); this._flowLayoutPanelMultiScreenButtons.TabIndex = 22; // - // prefsByScreenUserControl1 - // - this._prefsByScreenUserControl.BackColor = Color.White; - this._prefsByScreenUserControl.Dock = DockStyle.Fill; - this._prefsByScreenUserControl.Location = new Point(4, 5); - this._prefsByScreenUserControl.Margin = new Padding(0); - this._prefsByScreenUserControl.Name = "prefsByScreenUserControl1"; - this._prefsByScreenUserControl.Size = new Size(966, 633); - this._prefsByScreenUserControl.TabIndex = 25; - // // PreferencesForm // - this.AutoScaleDimensions = new SizeF(13F, 32F); - this.AutoScaleMode = AutoScaleMode.Font; - this.ClientSize = new Size(998, 953); + this.ClientSize = new System.Drawing.Size(998, 697); this.Controls.Add(this._tableLayoutPanelMain); - this.Margin = new Padding(6, 7, 6, 7); + this.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new Size(1024, 768); + this.MinimumSize = new System.Drawing.Size(1024, 768); this.Name = "PreferencesForm"; - this.SizeGripStyle = SizeGripStyle.Show; - this.StartPosition = FormStartPosition.CenterParent; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Web Page Screensaver Settings"; this.Load += new System.EventHandler(this.PreferencesForm_Load); this._tabControlScreens.ResumeLayout(false); this._tabPageScreen.ResumeLayout(false); + this._tabPageScreen.PerformLayout(); this._tableLayoutPanelMain.ResumeLayout(false); this._tableLayoutPanelMain.PerformLayout(); this._tableLayoutPanelMainBottom.ResumeLayout(false); @@ -326,6 +326,7 @@ private void InitializeComponent() private RadioButton _radioButtonSpanScreens; private RadioButton _radioButtonMirrorScreens; private RadioButton _radioButtonSeparateScreens; + private ToolTip _toolTipScreenMode; private CheckBox _checkBoxCloseOnMouseMovement; private Label _labelWebsiteURLs; @@ -337,7 +338,5 @@ private void InitializeComponent() private LinkLabel _linkLabelProjectURL; private Button _buttonCancel; private Button _buttonOK; - - private ToolTip _toolTipScreenMode; } } \ No newline at end of file diff --git a/PreferencesForm.cs b/PreferencesForm.cs index cab320c..4d4edad 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -1,17 +1,17 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace WebPageScreensaver { - public partial class PreferencesForm : Form + internal partial class PreferencesForm : Form { - private PreferencesManager prefsManager = new PreferencesManager(); + private const string Webpage = "http://github.com/carlossanlop/web-page-screensaver/"; - // Need to initialize in advance to prevent crashes when retrieving screenUserControls by index (LoadValuesForTab or ReadBackValuesFromUI) - private List screenUserControls = new List(); + private List Tabs => new List(); public PreferencesForm() { @@ -20,7 +20,7 @@ public PreferencesForm() private void PreferencesForm_Load(object sender, EventArgs e) { - _checkBoxCloseOnMouseMovement.Checked = prefsManager.CloseOnActivity; + _checkBoxCloseOnMouseMovement.Checked = Preferences.CloseOnMouseMovement; if (Screen.AllScreens.Length == 1) { _flowLayoutPanelMultiScreenButtons.Enabled = false; @@ -33,35 +33,27 @@ private void PreferencesForm_Load(object sender, EventArgs e) ArrangeScreenTabs(); } - private void LoadValuesForTab(int screenNum) - { - var currentPrefsUserControl = screenUserControls[screenNum]; - LoadUrlsForTabToControl(screenNum, currentPrefsUserControl); - currentPrefsUserControl._numericUpDownSecondsToDisplay.Value = prefsManager.GetRotationIntervalByScreen(screenNum); - currentPrefsUserControl._checkBoxShuffle.Checked = prefsManager.GetRandomizeFlagByScreen(screenNum); - } - private void ArrangeScreenTabs() { - switch (prefsManager.MultiScreenMode) + switch (Preferences.MultiScreen) { - case PreferencesManager.MultiScreenModeItem.Span: + case MultiScreenMode.Span: RemoveExtraTabPages(); _tabControlScreens.TabPages[0].Text = "Composite Screen"; // Need to clear because we only expect one tab - screenUserControls.Clear(); - screenUserControls.Add(_prefsByScreenUserControl); - LoadValuesForTab(0); + Tabs.Clear(); + Tabs.Add(_prefsByScreenUserControl); + Fetch(); break; - case PreferencesManager.MultiScreenModeItem.Mirror: + case MultiScreenMode.Mirror: RemoveExtraTabPages(); _tabControlScreens.TabPages[0].Text = "Each Screen"; // Need to clear because we only expect one tab - screenUserControls.Clear(); - screenUserControls.Add(_prefsByScreenUserControl); - LoadValuesForTab(0); + Tabs.Clear(); + Tabs.Add(_prefsByScreenUserControl); + Fetch(); break; - case PreferencesManager.MultiScreenModeItem.Separate: + case MultiScreenMode.Separate: for (int i = 0; i < Screen.AllScreens.Length; i++) { TabPage? tabPage = null; @@ -84,7 +76,7 @@ private void ArrangeScreenTabs() prefsByScreenUserControl._listViewURLs.ContextMenuStrip = _prefsByScreenUserControl.ContextMenuStrip; // No need to clear because we are re-adding the missing tabs - screenUserControls.Add(prefsByScreenUserControl); + Tabs.Add(prefsByScreenUserControl); tabPage.Controls.Add(prefsByScreenUserControl); } } @@ -92,8 +84,8 @@ private void ArrangeScreenTabs() { tabPage = _tabControlScreens.TabPages[0]; // Clearing before adding prevents a crash when going from Separate to Mirror and back to Separate - screenUserControls.Clear(); - screenUserControls.Add(_prefsByScreenUserControl); + Tabs.Clear(); + Tabs.Add(_prefsByScreenUserControl); } if (tabPage == null) @@ -101,7 +93,7 @@ private void ArrangeScreenTabs() throw new NullReferenceException("tabPage should not be null."); } - LoadValuesForTab(i); + Fetch(); string primaryIndicator = string.Empty; if (Screen.AllScreens[i].Primary) primaryIndicator = " (main)"; tabPage.Text = string.Format("Screen {0}{1}", i + 1, primaryIndicator); @@ -121,17 +113,19 @@ private void RemoveExtraTabPages() private void SetMultiScreenButtonFromMode() { - switch (prefsManager.MultiScreenMode) + switch (Preferences.MultiScreen) { - case PreferencesManager.MultiScreenModeItem.Span: + case MultiScreenMode.Span: _radioButtonSpanScreens.Checked = true; break; - case PreferencesManager.MultiScreenModeItem.Mirror: + case MultiScreenMode.Mirror: _radioButtonMirrorScreens.Checked = true; break; - case PreferencesManager.MultiScreenModeItem.Separate: + case MultiScreenMode.Separate: _radioButtonSeparateScreens.Checked = true; break; + default: + throw new ArgumentOutOfRangeException("Unrecognized MultiScreenMode."); } } @@ -139,78 +133,103 @@ private void SetMultiScreenModeFromButtonState() { if (_radioButtonSpanScreens.Checked) { - prefsManager.MultiScreenMode = PreferencesManager.MultiScreenModeItem.Span; + Preferences.MultiScreen = MultiScreenMode.Span; } else if (_radioButtonMirrorScreens.Checked) { - prefsManager.MultiScreenMode = PreferencesManager.MultiScreenModeItem.Mirror; + Preferences.MultiScreen = MultiScreenMode.Mirror; } else { - prefsManager.MultiScreenMode = PreferencesManager.MultiScreenModeItem.Separate; + Preferences.MultiScreen = MultiScreenMode.Separate; } - - prefsManager.ResetEffectiveScreensList(); } - private void ReadBackValuesFromUI() - { - for (var i = 0; i < screenUserControls.Count; i++) - { - var currentPrefsUserControl = screenUserControls[i]; - List urls = (from ListViewItem lvUrlsItem in currentPrefsUserControl._listViewURLs.Items - select lvUrlsItem.Text).ToList(); - prefsManager.SetUrlsForScreen(i, urls); - prefsManager.SetRotationIntervalForScreen(i, - (int)currentPrefsUserControl._numericUpDownSecondsToDisplay.Value); - prefsManager.SetRandomizeFlagForScreen(i, currentPrefsUserControl._checkBoxShuffle.Checked); - prefsManager.CloseOnActivity = _checkBoxCloseOnMouseMovement.Checked; - } - } - private void LoadUrlsForTabToControl(int screenNum, PrefsByScreenUserControl currentPrefsUserControl) + private void anyMultiScreenModeButton_Click(object sender, EventArgs e) { - currentPrefsUserControl._listViewURLs.Items.Clear(); - - var urls = prefsManager.GetUrlsByScreen(screenNum); - - foreach (var url in urls) - { - currentPrefsUserControl._listViewURLs.Items.Add(url); - } + Save(); + SetMultiScreenModeFromButtonState(); + ArrangeScreenTabs(); } - protected override void OnClosed(EventArgs e) + /// + /// Opens the project website in a new default browser tab. + /// + private void LinkLabelProjectURL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - if (DialogResult == DialogResult.OK) + ProcessStartInfo startInfo = new ProcessStartInfo() { - ReadBackValuesFromUI(); - prefsManager.SavePreferences(); - } - - base.OnClosed(e); + FileName = "cmd", + Arguments = $"/c start {Webpage}", + CreateNoWindow = true + }; + Process.Start(startInfo); } - private void llProjectLocationUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + /// + /// Saves the selected settings and closes the window. + /// + private void ButtonOK_Click(object sender, EventArgs e) { - System.Diagnostics.Process.Start(Program.Webpage); + Save(); + Close(); } - private void okButton_Click(object sender, EventArgs e) + /// + /// Closes the window without saving the settings. + /// + private void ButtonCancel_Click(object sender, EventArgs e) { Close(); } - private void cancelButton_Click(object sender, EventArgs e) + /// + /// Retrieve data for the specified screen from the registry and show it in the form. + /// + /// The screen number. + private void Fetch() { - Close(); + _checkBoxCloseOnMouseMovement.Checked = Preferences.CloseOnMouseMovement; + + for (int screenNumber = 0; screenNumber < Tabs.Count; screenNumber++) + { + PrefsByScreenUserControl currentTab = Tabs[screenNumber]; + ScreenInformation currentScreen = Preferences.Screens[screenNumber]; + + + currentTab._listViewURLs.Items.Clear(); + foreach (string url in currentScreen.URLs) + { + currentTab._listViewURLs.Items.Add(url); + } + + currentTab._numericUpDownRotationInterval.Value = Preferences.Screens[screenNumber].RotationInterval; + currentTab._checkBoxShuffle.Checked = Preferences.Screens[screenNumber].Shuffle; + } } - private void anyMultiScreenModeButton_Click(object sender, EventArgs e) + /// + /// Retrieve data from the form and save it in the registry. + /// + private void Save() { - ReadBackValuesFromUI(); - SetMultiScreenModeFromButtonState(); - ArrangeScreenTabs(); + Preferences.CloseOnMouseMovement = _checkBoxCloseOnMouseMovement.Checked; + + for (int screenNumber = 0; screenNumber < Tabs.Count; screenNumber++) + { + PrefsByScreenUserControl currentTab = Tabs[screenNumber]; + ScreenInformation currentScreen = Preferences.Screens[screenNumber]; + + currentScreen.URLs.Clear(); + foreach (ListViewItem item in currentTab._listViewURLs.Items) + { + currentScreen.URLs.Add(item.Text); + } + + currentScreen.RotationInterval = (int)currentTab._numericUpDownRotationInterval.Value; + currentScreen.Shuffle = currentTab._checkBoxShuffle.Checked; + } } } } diff --git a/PreferencesManager.cs b/PreferencesManager.cs deleted file mode 100644 index ab1de52..0000000 --- a/PreferencesManager.cs +++ /dev/null @@ -1,356 +0,0 @@ -using Microsoft.Win32; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; - -namespace WebPageScreensaver -{ - public class PreferencesManager - { - private const string MULTISCREEN_PREF = "MultiScreenMode"; - private const string URL_PREF = "Url"; - private const string INTERVAL_PREF = "RotationInterval"; - private const string RANDOMIZE_PREF = "RandomOrder"; - private const string CLOSE_ON_ACTIVITY_PREF = "CloseOnActivity"; - - private const string SCREEN_SPECIFIC_PREF_NAME_FORMATSTRING = "{0}Screen{1}"; - - private const string MULTISCREEN_PREF_DEFAULT = "Separate"; - private const string URL_PREF_PRIMARYSCREEN_DEFAULT = "https://dotnet.microsoft.com/ https://code.visualstudio.com/"; - private const string URL_PREF_NONPRIMARYSCREEN_DEFAULT = ""; - private const string INTERVAL_PREF_DEFAULT = "30"; - private const string RANDOMIZE_PREF_DEFAULT = "False"; - private const string CLOSE_ON_ACTIVITY_PREF_DEFAULT = "True"; - - private static RegistryKey reg = Registry.CurrentUser.CreateSubKey(Program.KeyWebPageScreensaver); - - public PreferencesManager() - { - LoadPreferences(); - } - - private List? _effectiveScreensListField; - public List EffectiveScreensList - { - get - { - if (_effectiveScreensListField == null) - { - _effectiveScreensListField = new List(); - switch (MultiScreenMode) - { - case MultiScreenModeItem.Span: - Rectangle enclosingRect = FindEnclosingRect(Screen.AllScreens.Select(r => r.Bounds).ToList()); - _effectiveScreensListField.Add( - new BasicScreenInfo { ScreenNum = 0, Bounds = enclosingRect, IsPrimary = true }); - break; - - case MultiScreenModeItem.Mirror: - for (int i = 0; i < Screen.AllScreens.Length; i++) - { - _effectiveScreensListField.Add( - new BasicScreenInfo - { - ScreenNum = i, - Bounds = Screen.AllScreens[i].Bounds, - IsPrimary = true - }); - } - break; - - case MultiScreenModeItem.Separate: - for (int i = 0; i < Screen.AllScreens.Length; i++) - { - _effectiveScreensListField.Add( - new BasicScreenInfo - { - ScreenNum = i, - Bounds = Screen.AllScreens[i].Bounds, - IsPrimary = Screen.AllScreens[i].Primary - }); - } - break; - } - } - return _effectiveScreensListField; - } - } - - public void ResetEffectiveScreensList() - { - _effectiveScreensListField = null; - } - - private int _realPrimaryScreenNumField = -1; - private int RealPrimaryScreenNumber - { - get - { - if (_realPrimaryScreenNumField == -1) - { - _realPrimaryScreenNumField = 0; - for (int i = 0; i < Screen.AllScreens.Length; i++) - { - if (!Screen.AllScreens[i].Primary) continue; - _realPrimaryScreenNumField = i; - break; - } - } - - return _realPrimaryScreenNumField; - } - } - - public bool CloseOnActivity { get; set; } - public MultiScreenModeItem MultiScreenMode { get; set; } - public enum MultiScreenModeItem - { - Span, - Mirror, - Separate - } - - public class BasicScreenInfo - { - public int ScreenNum { get; set; } - public Rectangle Bounds { get; set; } - public bool IsPrimary { get; set; } - } - - // TODO: the URLs handling mostly works, but it is overcomplicted and there is a fundamental issue with ordering: - // specifically, if the user has a single-screen view of what is actually stored as multiple screens underneath, - // and they order a later-screen item before an earlier screen item, those items will still wind up in screen- - // order whe reading back for single-screen view. - // options: 1) retro-fit more ordering stuff onto screen URLS, 2) make the URLS list just one list again, and - // add another list that specifies which screen each URL is for. (i.e. rewrite URL list handling completely). - // 2. is actually the better option. - private List> _urlsByScreen = new List>(); - public List GetUrlsByScreen(int screenNum) - { - int startAtScreenNum = MultiScreenMode == MultiScreenModeItem.Mirror ? 0 : screenNum; - // special treatment for URLs for the 'last' effective screen - // this can happen either due to actual screen removal as noted in the LoadUrlsAllScreens() method, - // OR because we are in Span mode, making just one effective screen, - // OR we want to treat multiple screens as one (mirror mode). - if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < _urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) - { - // for the GET operation, the last effective screen has the URLS - // for additional screens in prefs appended to it's list. - List urlsList = _urlsByScreen[startAtScreenNum]; - var urlsForRestOfScreens = _urlsByScreen.GetRange(startAtScreenNum + 1, _urlsByScreen.Count - startAtScreenNum - 1); - foreach (var additionalScreenUrls in urlsForRestOfScreens) - { - urlsList.AddRange(additionalScreenUrls); - } - return urlsList; - } - else - { - return _urlsByScreen[startAtScreenNum]; - } - } - public void SetUrlsForScreen(int screenNum, List providedUrlsList) - { - int startAtScreenNum = MultiScreenMode == MultiScreenModeItem.Mirror ? 0 : screenNum; - // special treatment for URLs for the 'last' effective screen - // this can happen either due to physical screen changes as noted in the LoadUrlsAllScreens() method, - // OR because we are in Span or Mirror mode, making just one effective screen. - if (MultiScreenMode == MultiScreenModeItem.Mirror || EffectiveScreensList.Count < _urlsByScreen.Count && startAtScreenNum == EffectiveScreensList.Count - 1) - { - // For the SET operation, we want any URLS that came to the last effective screen - // from later screens in prefs to go back where they came from rather than directly - // to the screen number specified. - // at the same time, we want any NEW urls to go to either the screenNum provided, - // or to the primary screen if that is one of the screens in the ones we are considering. - - // we only care about Url lists from this screen up. - // This screen, whatever it is, is always RELATIVE screen 0. - var relativeScreenUrlsList = - _urlsByScreen.GetRange(startAtScreenNum, _urlsByScreen.Count - startAtScreenNum); - // make a deep copy that we can manipulate independantly of the actual list. - var originalsUnaccountedFor = relativeScreenUrlsList.Select(t => new List(t)).ToList(); - // then delete all that actual entries in the actual set to fill in below. - foreach (var urlsList in relativeScreenUrlsList) - { - urlsList.RemoveRange(0, urlsList.Count); - } - - int defaultRelativeScreenNumForNewUrls = Math.Max(0, RealPrimaryScreenNumber - startAtScreenNum); - - foreach (var url in providedUrlsList) - { - // find where it exists in the unaccounted for lists - int relativeScreenNumForThisUrl; - for (relativeScreenNumForThisUrl = 0; relativeScreenNumForThisUrl < originalsUnaccountedFor.Count; relativeScreenNumForThisUrl++) - { - if (originalsUnaccountedFor[relativeScreenNumForThisUrl].Contains(url)) - { - // remove from further consideration, and use this relative screen number - originalsUnaccountedFor[relativeScreenNumForThisUrl].Remove(url); - break; - } - } - if (relativeScreenNumForThisUrl == originalsUnaccountedFor.Count) - { - // not found - use default - relativeScreenNumForThisUrl = defaultRelativeScreenNumForNewUrls; - } - - relativeScreenUrlsList[relativeScreenNumForThisUrl].Add(url); - } - } - else - // normal case for normal screen nums is MUCH simpler: - { - _urlsByScreen[screenNum] = providedUrlsList; - } - } - - private List? _rotationIntervalsByScreen; - public int GetRotationIntervalByScreen(int screenNum) - { - return _rotationIntervalsByScreen[TranslateScreenNumToScreenPrefNum(screenNum)]; - } - public void SetRotationIntervalForScreen(int screenNum, int value) - { - _rotationIntervalsByScreen[TranslateScreenNumToScreenPrefNum(screenNum)] = value; - } - - private List? _randomizeFlagByScreen; - public bool GetRandomizeFlagByScreen(int screenNum) - { - return _randomizeFlagByScreen[TranslateScreenNumToScreenPrefNum(screenNum)]; - } - public void SetRandomizeFlagForScreen(int screenNum, bool randomizeSetting) - { - _randomizeFlagByScreen[TranslateScreenNumToScreenPrefNum(screenNum)] = randomizeSetting; - } - - private int TranslateScreenNumToScreenPrefNum(int screenNum) - { - // if the screen they're asking for is an effective primary, - // then the actual set of prefs to use is the real primary screen's set, - // regardless of the actual number they asked for. - return EffectiveScreensList[screenNum].IsPrimary ? RealPrimaryScreenNumber : screenNum; - } - - public void SavePreferences() - { - reg.SetValue(MULTISCREEN_PREF, MultiScreenMode); - reg.SetValue(CLOSE_ON_ACTIVITY_PREF, CloseOnActivity); - SaveUrlsAllScreens(); - SavePrefAllScreens(INTERVAL_PREF, _rotationIntervalsByScreen); - SavePrefAllScreens(RANDOMIZE_PREF, _randomizeFlagByScreen); - reg.Close(); - } - - private void LoadPreferences() - { - MultiScreenMode = (MultiScreenModeItem)Enum.Parse(typeof(MultiScreenModeItem), (string)reg.GetValue(MULTISCREEN_PREF, MULTISCREEN_PREF_DEFAULT)); - CloseOnActivity = bool.Parse((string)reg.GetValue(CLOSE_ON_ACTIVITY_PREF, CLOSE_ON_ACTIVITY_PREF_DEFAULT)); - _urlsByScreen = LoadUrlsAllScreens(); - _rotationIntervalsByScreen = LoadPrefAllScreens(INTERVAL_PREF, INTERVAL_PREF_DEFAULT, INTERVAL_PREF_DEFAULT); - _randomizeFlagByScreen = LoadPrefAllScreens(RANDOMIZE_PREF, RANDOMIZE_PREF_DEFAULT, RANDOMIZE_PREF_DEFAULT); - } - - private List> LoadUrlsAllScreens() - { - List strings = LoadPrefAllScreens(URL_PREF, URL_PREF_PRIMARYSCREEN_DEFAULT, URL_PREF_NONPRIMARYSCREEN_DEFAULT); - var allUrls = strings.Select(stringValue => string.IsNullOrWhiteSpace(stringValue) - ? new List() - : stringValue.Split(' ').ToList()) - .ToList(); - - // special case for URLs, so that we don't lose any if/when the user physically removes a screen - // (this happens frequently eg if you remote desktop to your machine, or you undock your laptop) - // if there are more screens stored in the prefs than there are actual screens, append any extras. - // actually dealing appropriately with the extra lists of URLs is handled by the GetUrlsByScreen() - // and SetUrlsByScreen() methods. - const string TempDefaultValue = "DEFAULT VALUE"; - int i = allUrls.Count; - string nextScreenUrlsPrefResult = LoadPrefByScreen(i, URL_PREF, TempDefaultValue, TempDefaultValue); - while (nextScreenUrlsPrefResult != TempDefaultValue) - { - allUrls.Add( - string.IsNullOrWhiteSpace(nextScreenUrlsPrefResult) - ? new List() - : nextScreenUrlsPrefResult.Split(' ').ToList()); - nextScreenUrlsPrefResult = LoadPrefByScreen(++i, URL_PREF, TempDefaultValue, TempDefaultValue); - } - - return allUrls; - } - - private List LoadPrefAllScreens(string prefBaseName, string primaryScreenPrefDefaultValue, string nonPrimaryScreenPrefDefaultValue) - { - List myList = new List(); - for (int i = 0; i < Screen.AllScreens.Length; i++) - { - myList.Add(LoadPrefByScreen(i, prefBaseName, primaryScreenPrefDefaultValue, nonPrimaryScreenPrefDefaultValue)); - } - return myList; - } - - private void SaveUrlsAllScreens() - { - SavePrefAllScreens(URL_PREF, _urlsByScreen.Select(urlList => string.Join(" ", urlList)).ToList()); - } - - private void SavePrefAllScreens(string preferenceName, List prefsList) - { - for (int i = 0; i < prefsList.Count(); i++) - { - reg.SetValue(ScreenSpecificPrefName(preferenceName, i), prefsList[i]); - } - } - - private T LoadPrefByScreen(int screenNum, string prefBaseName, string primaryScreenPrefDefaultValue, string nonPrimaryScreenPrefDefaultValue) - { - string screenSpecificPrefEntryName = ScreenSpecificPrefName(prefBaseName, screenNum); - object regValue = reg.GetValue(screenSpecificPrefEntryName); - if (regValue == null) - { - // no screen-specific entry exists. - // for backward compatibility, if the current tab is only one, or else for the primary screen only, - // look for the non-screen-specific pref setting, and if found, move it from there. - // This is a one-off preferences upgrade. - - if (Screen.AllScreens.Length == 1 || (screenNum < Screen.AllScreens.Length && Screen.AllScreens[screenNum].Primary)) - { - if (reg.GetValueNames().Contains(prefBaseName)) - { - regValue = reg.GetValue(prefBaseName); - reg.DeleteValue(prefBaseName); - reg.SetValue(screenSpecificPrefEntryName, (T)Convert.ChangeType(regValue, typeof(T))); - } - else - { - regValue = (T)Convert.ChangeType(primaryScreenPrefDefaultValue, typeof(T)); - } - } - else - { - regValue = (T)Convert.ChangeType(nonPrimaryScreenPrefDefaultValue, typeof(T)); - } - } - - return (T)Convert.ChangeType(regValue, typeof(T)); - } - - private static string ScreenSpecificPrefName(string prefBaseName, int screenNum) - { - return string.Format(SCREEN_SPECIFIC_PREF_NAME_FORMATSTRING, prefBaseName, screenNum); - } - - private static Rectangle FindEnclosingRect(List rectangles) - { - return Rectangle.FromLTRB( - rectangles.Min(r => r.Left), - rectangles.Min(r => r.Top), - rectangles.Max(r => r.Right), - rectangles.Max(r => r.Bottom)); - } - } -} \ No newline at end of file diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index 86d2908..875fc9b 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -1,16 +1,11 @@ -using System; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -namespace WebPageScreensaver +namespace WebPageScreensaver { - partial class PrefsByScreenUserControl + internal partial class PrefsByScreenUserControl { /// /// Required designer variable. /// - private IContainer _components = null; + private System.ComponentModel.IContainer _components = null; /// /// Clean up any resources being used. @@ -33,39 +28,39 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this._components = new Container(); - this._numericUpDownSecondsToDisplay = new NumericUpDown(); - this._labelSecondsToDisplay = new Label(); - this._checkBoxShuffle = new CheckBox(); - this._listViewURLs = new ListView(); - this._buttonAddURL = new Button(); - this._buttonUp = new Button(); - this._toolTipURLButtons = new ToolTip(this._components); - this._buttonDown = new Button(); - this._buttonDeleteURL = new Button(); - this._tableLayoutPanelMain = new TableLayoutPanel(); - this._tableLayoutPanelMainTop = new TableLayoutPanel(); - this._tableLayoutPanelMainBottom = new TableLayoutPanel(); - ((ISupportInitialize)(this._numericUpDownSecondsToDisplay)).BeginInit(); + this.components = new System.ComponentModel.Container(); + this._numericUpDownRotationInterval = new System.Windows.Forms.NumericUpDown(); + this._labelSecondsToDisplay = new System.Windows.Forms.Label(); + this._checkBoxShuffle = new System.Windows.Forms.CheckBox(); + this._listViewURLs = new System.Windows.Forms.ListView(); + this._buttonAddURL = new System.Windows.Forms.Button(); + this._buttonUp = new System.Windows.Forms.Button(); + this._toolTipURLButtons = new System.Windows.Forms.ToolTip(this.components); + this._buttonDown = new System.Windows.Forms.Button(); + this._buttonDeleteURL = new System.Windows.Forms.Button(); + this._tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel(); + this._tableLayoutPanelMainTop = new System.Windows.Forms.TableLayoutPanel(); + this._tableLayoutPanelMainBottom = new System.Windows.Forms.TableLayoutPanel(); + ((System.ComponentModel.ISupportInitialize)(this._numericUpDownRotationInterval)).BeginInit(); this._tableLayoutPanelMain.SuspendLayout(); this._tableLayoutPanelMainTop.SuspendLayout(); this._tableLayoutPanelMainBottom.SuspendLayout(); this.SuspendLayout(); // - // _numericUpDownSecondsToDisplay + // _numericUpDownRotationInterval // - this._numericUpDownSecondsToDisplay.Anchor = AnchorStyles.Right; - this._numericUpDownSecondsToDisplay.Location = new Point(315, 14); - this._numericUpDownSecondsToDisplay.Margin = new Padding(4); - this._numericUpDownSecondsToDisplay.Maximum = new decimal(new int[] { + this._numericUpDownRotationInterval.Anchor = System.Windows.Forms.AnchorStyles.Right; + this._numericUpDownRotationInterval.Location = new System.Drawing.Point(284, 5); + this._numericUpDownRotationInterval.Margin = new System.Windows.Forms.Padding(4); + this._numericUpDownRotationInterval.Maximum = new decimal(new int[] { 999, 0, 0, 0}); - this._numericUpDownSecondsToDisplay.Name = "_numericUpDownSecondsToDisplay"; - this._numericUpDownSecondsToDisplay.Size = new Size(80, 39); - this._numericUpDownSecondsToDisplay.TabIndex = 6; - this._numericUpDownSecondsToDisplay.Value = new decimal(new int[] { + this._numericUpDownRotationInterval.Name = "_numericUpDownRotationInterval"; + this._numericUpDownRotationInterval.Size = new System.Drawing.Size(80, 39); + this._numericUpDownRotationInterval.TabIndex = 6; + this._numericUpDownRotationInterval.Value = new decimal(new int[] { 30, 0, 0, @@ -73,164 +68,160 @@ private void InitializeComponent() // // _labelSecondsToDisplay // - this._labelSecondsToDisplay.Anchor = AnchorStyles.Left; + this._labelSecondsToDisplay.Anchor = System.Windows.Forms.AnchorStyles.Left; this._labelSecondsToDisplay.AutoSize = true; - this._labelSecondsToDisplay.Location = new Point(405, 18); - this._labelSecondsToDisplay.Margin = new Padding(6, 0, 6, 0); + this._labelSecondsToDisplay.Location = new System.Drawing.Point(374, 9); + this._labelSecondsToDisplay.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this._labelSecondsToDisplay.Name = "_labelSecondsToDisplay"; - this._labelSecondsToDisplay.Size = new Size(314, 32); + this._labelSecondsToDisplay.Size = new System.Drawing.Size(314, 32); this._labelSecondsToDisplay.TabIndex = 7; this._labelSecondsToDisplay.Text = "Seconds to display each site"; - this._labelSecondsToDisplay.TextAlign = ContentAlignment.MiddleLeft; + this._labelSecondsToDisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // _checkBoxShuffle // this._checkBoxShuffle.AutoSize = true; - this._checkBoxShuffle.Dock = DockStyle.Left; - this._checkBoxShuffle.Location = new Point(6, 7); - this._checkBoxShuffle.Margin = new Padding(6, 7, 6, 7); + this._checkBoxShuffle.Dock = System.Windows.Forms.DockStyle.Left; + this._checkBoxShuffle.Location = new System.Drawing.Point(6, 7); + this._checkBoxShuffle.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); this._checkBoxShuffle.Name = "_checkBoxShuffle"; - this._checkBoxShuffle.Size = new Size(267, 54); + this._checkBoxShuffle.Size = new System.Drawing.Size(122, 36); this._checkBoxShuffle.TabIndex = 5; - this._checkBoxShuffle.Text = "Shuffle display order"; + this._checkBoxShuffle.Text = "Shuffle"; this._checkBoxShuffle.UseVisualStyleBackColor = true; // // _listViewURLs // - this._listViewURLs.Dock = DockStyle.Fill; + this._listViewURLs.Dock = System.Windows.Forms.DockStyle.Fill; this._listViewURLs.HideSelection = false; this._listViewURLs.LabelEdit = true; - this._listViewURLs.Location = new Point(4, 79); - this._listViewURLs.Margin = new Padding(4, 5, 4, 5); + this._listViewURLs.Location = new System.Drawing.Point(4, 73); + this._listViewURLs.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._listViewURLs.Name = "_listViewURLs"; - this._listViewURLs.Size = new Size(723, 442); + this._listViewURLs.Size = new System.Drawing.Size(692, 346); this._listViewURLs.TabIndex = 0; this._listViewURLs.UseCompatibleStateImageBehavior = false; - this._listViewURLs.View = View.List; + this._listViewURLs.View = System.Windows.Forms.View.List; // // _buttonAddURL // - this._buttonAddURL.Location = new Point(8, 8); - this._buttonAddURL.Margin = new Padding(4); + this._buttonAddURL.Location = new System.Drawing.Point(8, 8); + this._buttonAddURL.Margin = new System.Windows.Forms.Padding(4); this._buttonAddURL.Name = "_buttonAddURL"; - this._buttonAddURL.Size = new Size(150, 44); + this._buttonAddURL.Size = new System.Drawing.Size(150, 44); this._buttonAddURL.TabIndex = 11; this._buttonAddURL.Text = "Add URL"; this._buttonAddURL.UseVisualStyleBackColor = true; - this._buttonAddURL.Click += new EventHandler(this.AddUrlButton_Click); + this._buttonAddURL.Click += new System.EventHandler(this.AddUrlButton_Click); // // _buttonUp // - this._buttonUp.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right))); - this._buttonUp.Font = new Font("Microsoft Sans Serif", 6F, FontStyle.Regular, GraphicsUnit.Point); - this._buttonUp.Location = new Point(619, 8); - this._buttonUp.Margin = new Padding(4); + this._buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this._buttonUp.Location = new System.Drawing.Point(588, 8); + this._buttonUp.Margin = new System.Windows.Forms.Padding(4); this._buttonUp.Name = "_buttonUp"; - this._buttonUp.Size = new Size(44, 44); + this._buttonUp.Size = new System.Drawing.Size(44, 44); this._buttonUp.TabIndex = 3; this._buttonUp.Text = "▲"; this._toolTipURLButtons.SetToolTip(this._buttonUp, "Move selected URLs up"); this._buttonUp.UseVisualStyleBackColor = true; - this._buttonUp.Click += new EventHandler(this.MoveAllSelectedUrlsUp_Click); + this._buttonUp.Click += new System.EventHandler(this.MoveAllSelectedUrlsUp_Click); // // _buttonDown // - this._buttonDown.Font = new Font("Microsoft Sans Serif", 6F, FontStyle.Regular, GraphicsUnit.Point); - this._buttonDown.Location = new Point(671, 8); - this._buttonDown.Margin = new Padding(4); + this._buttonDown.Location = new System.Drawing.Point(640, 8); + this._buttonDown.Margin = new System.Windows.Forms.Padding(4); this._buttonDown.Name = "_buttonDown"; - this._buttonDown.Size = new Size(44, 44); + this._buttonDown.Size = new System.Drawing.Size(44, 44); this._buttonDown.TabIndex = 12; this._buttonDown.Text = "▼"; this._toolTipURLButtons.SetToolTip(this._buttonDown, "Move selected URLs down"); this._buttonDown.UseVisualStyleBackColor = true; - this._buttonDown.Click += new EventHandler(this.MoveAllSelectedUrlsDown_Click); + this._buttonDown.Click += new System.EventHandler(this.MoveAllSelectedUrlsDown_Click); // // _buttonDeleteURL // - this._buttonDeleteURL.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); - this._buttonDeleteURL.ForeColor = Color.Black; - this._buttonDeleteURL.Location = new Point(166, 8); - this._buttonDeleteURL.Margin = new Padding(4); + this._buttonDeleteURL.ForeColor = System.Drawing.Color.Black; + this._buttonDeleteURL.Location = new System.Drawing.Point(166, 8); + this._buttonDeleteURL.Margin = new System.Windows.Forms.Padding(4); this._buttonDeleteURL.Name = "_buttonDeleteURL"; - this._buttonDeleteURL.Size = new Size(150, 44); + this._buttonDeleteURL.Size = new System.Drawing.Size(150, 44); this._buttonDeleteURL.TabIndex = 13; this._buttonDeleteURL.Text = "Delete URL"; this._toolTipURLButtons.SetToolTip(this._buttonDeleteURL, "DELETE selected URLs"); this._buttonDeleteURL.UseVisualStyleBackColor = true; - this._buttonDeleteURL.Click += new EventHandler(this.DeleteAllSelectedUrls_Click); + this._buttonDeleteURL.Click += new System.EventHandler(this.DeleteAllSelectedUrls_Click); // // _tableLayoutPanelMain // this._tableLayoutPanelMain.AutoSize = true; - this._tableLayoutPanelMain.AutoSizeMode = AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMain.ColumnCount = 1; - this._tableLayoutPanelMain.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + this._tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainTop, 0, 0); this._tableLayoutPanelMain.Controls.Add(this._listViewURLs, 0, 1); this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainBottom, 0, 2); - this._tableLayoutPanelMain.Dock = DockStyle.Fill; - this._tableLayoutPanelMain.Location = new Point(0, 0); + this._tableLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill; + this._tableLayoutPanelMain.Location = new System.Drawing.Point(0, 0); this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; this._tableLayoutPanelMain.RowCount = 3; - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 74F)); - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMain.RowStyles.Add(new RowStyle(SizeType.Absolute, 74F)); - this._tableLayoutPanelMain.Size = new Size(731, 600); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 68F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 56F)); + this._tableLayoutPanelMain.Size = new System.Drawing.Size(700, 480); this._tableLayoutPanelMain.TabIndex = 14; // // _tableLayoutPanelMainTop // + this._tableLayoutPanelMainTop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._tableLayoutPanelMainTop.AutoSize = true; - this._tableLayoutPanelMainTop.AutoSizeMode = AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainTop.ColumnCount = 4; - this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle()); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 52F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 52F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 158F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 52F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 52F)); this._tableLayoutPanelMainTop.Controls.Add(this._buttonAddURL, 0, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonDown, 3, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonUp, 2, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonDeleteURL, 1, 0); - this._tableLayoutPanelMainTop.Dock = DockStyle.Fill; - this._tableLayoutPanelMainTop.Location = new Point(4, 4); - this._tableLayoutPanelMainTop.Margin = new Padding(4); + this._tableLayoutPanelMainTop.Location = new System.Drawing.Point(4, 4); + this._tableLayoutPanelMainTop.Margin = new System.Windows.Forms.Padding(4); this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; - this._tableLayoutPanelMainTop.Padding = new Padding(4); + this._tableLayoutPanelMainTop.Padding = new System.Windows.Forms.Padding(4); this._tableLayoutPanelMainTop.RowCount = 1; - this._tableLayoutPanelMainTop.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMainTop.Size = new Size(723, 66); + this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(692, 60); this._tableLayoutPanelMainTop.TabIndex = 0; // // _tableLayoutPanelMainBottom // this._tableLayoutPanelMainBottom.AutoSize = true; - this._tableLayoutPanelMainBottom.AutoSizeMode = AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainBottom.ColumnCount = 3; - this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); - this._tableLayoutPanelMainBottom.ColumnStyles.Add(new ColumnStyle()); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this._tableLayoutPanelMainBottom.Controls.Add(this._checkBoxShuffle, 0, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._labelSecondsToDisplay, 2, 0); - this._tableLayoutPanelMainBottom.Controls.Add(this._numericUpDownSecondsToDisplay, 1, 0); - this._tableLayoutPanelMainBottom.Dock = DockStyle.Fill; - this._tableLayoutPanelMainBottom.Location = new Point(3, 529); + this._tableLayoutPanelMainBottom.Controls.Add(this._numericUpDownRotationInterval, 1, 0); + this._tableLayoutPanelMainBottom.Dock = System.Windows.Forms.DockStyle.Fill; + this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(3, 427); this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; this._tableLayoutPanelMainBottom.RowCount = 1; - this._tableLayoutPanelMainBottom.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - this._tableLayoutPanelMainBottom.Size = new Size(725, 68); + this._tableLayoutPanelMainBottom.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(694, 50); this._tableLayoutPanelMainBottom.TabIndex = 1; // // PrefsByScreenUserControl // - this.AutoScaleDimensions = new SizeF(13F, 32F); - this.AutoScaleMode = AutoScaleMode.Font; - this.BackColor = Color.White; + this.AutoSize = true; + this.BackColor = System.Drawing.Color.White; this.Controls.Add(this._tableLayoutPanelMain); - this.Margin = new Padding(4, 5, 4, 5); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.MinimumSize = new System.Drawing.Size(640, 480); this.Name = "PrefsByScreenUserControl"; - this.Size = new Size(731, 600); - ((ISupportInitialize)(this._numericUpDownSecondsToDisplay)).EndInit(); + this.Size = new System.Drawing.Size(700, 480); + ((System.ComponentModel.ISupportInitialize)(this._numericUpDownRotationInterval)).EndInit(); this._tableLayoutPanelMain.ResumeLayout(false); this._tableLayoutPanelMain.PerformLayout(); this._tableLayoutPanelMainTop.ResumeLayout(false); @@ -238,25 +229,27 @@ private void InitializeComponent() this._tableLayoutPanelMainBottom.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); + } #endregion - private TableLayoutPanel _tableLayoutPanelMain; + private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMain; - private TableLayoutPanel _tableLayoutPanelMainTop; - private Button _buttonAddURL; - private Button _buttonDeleteURL; - private Button _buttonUp; - private Button _buttonDown; + private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMainTop; + private System.Windows.Forms.Button _buttonAddURL; + private System.Windows.Forms.Button _buttonDeleteURL; + private System.Windows.Forms.Button _buttonUp; + private System.Windows.Forms.Button _buttonDown; - public ListView _listViewURLs; + public System.Windows.Forms.ListView _listViewURLs; - private TableLayoutPanel _tableLayoutPanelMainBottom; - public CheckBox _checkBoxShuffle; - public NumericUpDown _numericUpDownSecondsToDisplay; - private Label _labelSecondsToDisplay; + private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMainBottom; + public System.Windows.Forms.CheckBox _checkBoxShuffle; + public System.Windows.Forms.NumericUpDown _numericUpDownRotationInterval; + private System.Windows.Forms.Label _labelSecondsToDisplay; - private ToolTip _toolTipURLButtons; + private System.Windows.Forms.ToolTip _toolTipURLButtons; + private System.ComponentModel.IContainer components; } } diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index bb495e5..96f6f8a 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -3,7 +3,7 @@ namespace WebPageScreensaver { - public partial class PrefsByScreenUserControl : UserControl + internal partial class PrefsByScreenUserControl : UserControl { public PrefsByScreenUserControl() { diff --git a/Program.cs b/Program.cs index 1212e6f..5c0d012 100644 --- a/Program.cs +++ b/Program.cs @@ -1,74 +1,71 @@ using System; using System.Collections.Generic; -using System.Drawing; +using System.Diagnostics; using System.Windows.Forms; namespace WebPageScreensaver { static class Program { - public const string Webpage = "http://github.com/carlossanlop/web-page-screensaver/"; - - public const string KeyWebPageScreensaver = @"Software\WebPageScreensaver"; - /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { - var mainModule = System.Diagnostics.Process.GetCurrentProcess().MainModule; + ProcessModule? mainModule = Process.GetCurrentProcess().MainModule; if (mainModule == null) { throw new NullReferenceException("Current process main module is null."); } - Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); + Application.SetHighDpiMode(HighDpiMode.DpiUnawareGdiScaled); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - if (args.Length > 0 && args[0].ToUpperInvariant().Equals("/P")) - return; + // Argument verification - More than 1 argument, or passing + // the wrong argument, will silently exit the program - if (args.Length > 0 && args[0].ToUpperInvariant().Equals("/C")) + // No arguments means preview the screensaver (cursor enabled) + if (args.Length == 0) { - Application.Run(new PreferencesForm()); + ShowScreenSaver(showCursor: true); } - else + else if(args.Length == 1) { - var formsList = new List(); - var screens = (new PreferencesManager()).EffectiveScreensList; - foreach (var screen in screens) + switch (args[0].ToUpperInvariant()) { - var screensaverForm = new ScreensaverForm(screen.ScreenNum) - { - Location = new Point(screen.Bounds.Left, screen.Bounds.Top), - Size = new Size(screen.Bounds.Width, screen.Bounds.Height) - }; - - formsList.Add(screensaverForm); + case "/C": + Application.Run(new PreferencesForm()); + break; + case "/P": + ShowScreenSaver(showCursor: true); + break; + case "/S": + ShowScreenSaver(showCursor: false); + break; } - - Application.Run(new MultiFormContext(formsList)); } } - } - public class MultiFormContext : ApplicationContext - { - public MultiFormContext(List forms) + /// + /// Shows the screensaver form in all the screens, and allows specifying if the + /// cursor should be shown. + /// + /// if the cursor should be shown + /// (for preview mode); otherwise (for show mode). + private static void ShowScreenSaver(bool showCursor) { - foreach (var form in forms) - { - form.FormClosed += (s, args) => - { - // End program on form close - ExitThread(); - }; + var forms = new List(); - form.Show(); + foreach (KeyValuePair kvp in Preferences.Screens) + { + var form = new ScreensaverForm(kvp.Value, showCursor); + forms.Add(form); } + + Application.Run(new MultiFormContext(forms)); } } } diff --git a/README.md b/README.md index b784a8b..9957e84 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,17 @@ -# web-page-screensaver +# Web Page Screensaver (.NET 5.0) -Display a web page as your screensaver +Display a web page as your screensaver. ## Dependencies -[.NET Framework 4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48130) +- .NET 5.0 x64 Desktop Runtime for Windows: https://dotnet.microsoft.com/download/dotnet/5.0 +- Microsoft Edge Insider (Canary) x64: https://www.microsoftedgeinsider.com/en-us/download/ ## Usage (Windows 7 & up) -1. Find Web-Page-Screensaver.scr on your computer, right click it -2. Select "Install" to install, or "Test" to test it out without installing -3. If installing, the Screen Saver Settings dialog will pop up with the correct screen saver selected -4. Use the `Settings...` button in the same dialog to change the web page(s) displayed by the screen saver +* Download Web-Page-Screensaver.scr: +* Right click it. +* Select "Test" if you want to preview it in full screen. +* Select "Install" if you want it to be added to your list of Windows screensavers. + * The screensaver Settings dialog will pop up with the correct screen saver selected. + * Use the `Settings...` button in the same dialog to change the web page(s) displayed by the screen saver. diff --git a/ScreenInformation.cs b/ScreenInformation.cs new file mode 100644 index 0000000..536728c --- /dev/null +++ b/ScreenInformation.cs @@ -0,0 +1,104 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; + +namespace WebPageScreensaver +{ + internal class ScreenInformation + { + private struct SettingName + { + public const string ScreenNumber = "ScreenNumber"; + public const string Bounds = "Bounds"; + public const string IsPrimary = "IsPrimary"; + public const string URLs = "URLs"; + public const string RotationInterval = "IntervalRotation"; + public const string Shuffle = "Shuffle"; + } + private struct SettingValue + { + public const int RotationInterval = 30; + public const bool Shuffle = true; + } + + public ScreenInformation(RegistryKey rootKey, int screenNumber, MultiScreenMode multiScreenMode) + { + + RootKey = rootKey; + ScreenNumber = multiScreenMode switch + { + MultiScreenMode.Span => 0, + MultiScreenMode.Mirror or MultiScreenMode.Separate => screenNumber, + _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.") + }; + + IsPrimary = multiScreenMode switch + { + MultiScreenMode.Span or MultiScreenMode.Mirror => true, + MultiScreenMode.Separate => Screen.AllScreens[screenNumber].Primary, + _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.") + }; + + Bounds = multiScreenMode switch + { + MultiScreenMode.Span => FindEnclosingRectangle(), + MultiScreenMode.Mirror or MultiScreenMode.Separate => Screen.AllScreens[screenNumber].Bounds, + _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.") + }; + } + + public RegistryKey RootKey { get; private set; } + + public int ScreenNumber + { + get => int.Parse(RootKey.GetOrCreateValue(SettingName.ScreenNumber)); + set => RootKey.SetValue(SettingName.ScreenNumber, value); + } + public Rectangle Bounds { get; set; } + + public bool IsPrimary + { + get => bool.Parse(RootKey.GetOrCreateValue(SettingName.IsPrimary)); + set => RootKey.SetValue(SettingName.IsPrimary, value); + } + + public List URLs + { + get + { + string urlsString = RootKey.GetOrCreateValue(SettingName.URLs, string.Empty); + return urlsString.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList(); + } + set + { + string urlsString = string.Join(' ', value); + RootKey.SetValue(SettingName.URLs, urlsString); + } + } + public int RotationInterval + { + get => int.Parse(RootKey.GetOrCreateValue(SettingName.RotationInterval, SettingValue.RotationInterval)); + set => RootKey.SetValue(SettingName.RotationInterval, value); + } + public bool Shuffle + { + get => bool.Parse(RootKey.GetOrCreateValue(SettingName.Shuffle, SettingValue.Shuffle)); + set => RootKey.SetValue(SettingName.Shuffle, value); + } + + private static Rectangle FindEnclosingRectangle() + { + IEnumerable bounds = Screen.AllScreens.Select(r => r.Bounds); + + return Rectangle.FromLTRB( + bounds.Min(r => r.Left), + bounds.Min(r => r.Top), + bounds.Max(r => r.Right), + bounds.Max(r => r.Bottom)); + } + } +} diff --git a/ScreensaverForm.Designer.cs b/ScreensaverForm.Designer.cs index cfc8d12..fe20c43 100644 --- a/ScreensaverForm.Designer.cs +++ b/ScreensaverForm.Designer.cs @@ -5,7 +5,7 @@ partial class ScreensaverForm /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private System.ComponentModel.IContainer _components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ partial class ScreensaverForm /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (components != null)) + if (disposing && (_components != null)) { - components.Dispose(); + _components.Dispose(); } base.Dispose(disposing); } @@ -28,52 +28,49 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2(); - this.closeButton = new System.Windows.Forms.Button(); + this._webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2(); + this._closeButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // webBrowser // - this.webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; - this.webBrowser.Location = new System.Drawing.Point(0, 0); - this.webBrowser.Margin = new System.Windows.Forms.Padding(4); - this.webBrowser.MinimumSize = new System.Drawing.Size(44, 50); - this.webBrowser.Name = "webBrowser"; - this.webBrowser.Size = new System.Drawing.Size(616, 644); - this.webBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); - this.webBrowser.TabIndex = 0; - this.webBrowser.Text = "webBrowser"; - this.webBrowser.ZoomFactor = 1D; + this._webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; + this._webBrowser.Location = new System.Drawing.Point(0, 0); + this._webBrowser.Margin = new System.Windows.Forms.Padding(4); + this._webBrowser.MinimumSize = new System.Drawing.Size(44, 50); + this._webBrowser.Name = "webBrowser"; + this._webBrowser.Size = new System.Drawing.Size(616, 644); + this._webBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); + this._webBrowser.TabIndex = 0; + this._webBrowser.ZoomFactor = 1D; // // closeButton // - this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.closeButton.BackColor = System.Drawing.Color.Transparent; - this.closeButton.FlatAppearance.BorderColor = System.Drawing.Color.White; - this.closeButton.FlatAppearance.BorderSize = 0; - this.closeButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.closeButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.closeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); - this.closeButton.ForeColor = System.Drawing.Color.Transparent; - this.closeButton.Location = new System.Drawing.Point(576, 0); - this.closeButton.Margin = new System.Windows.Forms.Padding(4); - this.closeButton.Name = "closeButton"; - this.closeButton.Size = new System.Drawing.Size(40, 44); - this.closeButton.TabIndex = 1; - this.closeButton.Text = "X"; - this.closeButton.UseVisualStyleBackColor = false; - this.closeButton.Visible = false; - this.closeButton.Click += new System.EventHandler(this.closeButton_Click); + this._closeButton.AutoSize = true; + this._closeButton.BackColor = System.Drawing.Color.Transparent; + this._closeButton.FlatAppearance.BorderColor = System.Drawing.Color.White; + this._closeButton.FlatAppearance.BorderSize = 0; + this._closeButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this._closeButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this._closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this._closeButton.ForeColor = System.Drawing.Color.Transparent; + this._closeButton.Location = new System.Drawing.Point(516, 0); + this._closeButton.Margin = new System.Windows.Forms.Padding(4); + this._closeButton.Name = "closeButton"; + this._closeButton.Size = new System.Drawing.Size(100, 100); + this._closeButton.TabIndex = 1; + this._closeButton.Text = "X"; + this._closeButton.UseVisualStyleBackColor = false; + this._closeButton.Visible = false; + this._closeButton.Click += new System.EventHandler(this.CloseButton_Click); // // ScreensaverForm // this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(616, 644); - this.Controls.Add(this.closeButton); - this.Controls.Add(this.webBrowser); + this.Controls.Add(this._closeButton); + this.Controls.Add(this._webBrowser); this.ForeColor = System.Drawing.Color.White; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Margin = new System.Windows.Forms.Padding(4); @@ -81,15 +78,15 @@ private void InitializeComponent() this.MinimizeBox = false; this.Name = "ScreensaverForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; - this.Text = "Form1"; this.Load += new System.EventHandler(this.ScreensaverForm_Load); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private Microsoft.Web.WebView2.WinForms.WebView2 webBrowser; - private System.Windows.Forms.Button closeButton; + private Microsoft.Web.WebView2.WinForms.WebView2 _webBrowser; + private System.Windows.Forms.Button _closeButton; } } diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index e6d1e29..f32cffb 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -7,80 +7,65 @@ namespace WebPageScreensaver { - public partial class ScreensaverForm : Form + internal partial class ScreensaverForm : Form { private DateTime StartTime; private Timer timer; private int currentSiteIndex = -1; - private GlobalUserEventHandler userEventHandler; - private bool shuffleOrder; - private List urls; + private MouseEventHandler userEventHandler; - private PreferencesManager prefsManager = new PreferencesManager(); - - private int screenNum; + private ScreenInformation Screen; [ThreadStatic] - private static Random random; + private static Random random = new Random(); - public ScreensaverForm(int? screenNumber = null) + public ScreensaverForm(ScreenInformation screen, bool showCursor) { - userEventHandler = new GlobalUserEventHandler(); - userEventHandler.Event += new GlobalUserEventHandler.UserEvent(HandleUserActivity); + userEventHandler = new MouseEventHandler(); + userEventHandler.Event += new MouseEventHandler.UserEvent(HandleUserActivity); - if (screenNumber == null) screenNum = prefsManager.EffectiveScreensList.FindIndex(s => s.IsPrimary); - else screenNum = (int)screenNumber; + Screen = screen; - InitializeComponent(); + Location = new Point(Screen.Bounds.Left, Screen.Bounds.Top); + Size = new Size(Screen.Bounds.Width, Screen.Bounds.Height); - Cursor.Hide(); - } + InitializeComponent(); - public List Urls - { - get + if (!showCursor) { - if (urls == null) - { - urls = prefsManager.GetUrlsByScreen(screenNum); - } - - return urls; + Cursor.Hide(); } } private async void ScreensaverForm_Load(object sender, EventArgs e) { - if (webBrowser == null) + if (_webBrowser == null) { throw new NullReferenceException("webBrowser should have been initialized by now."); } - await webBrowser.EnsureCoreWebView2Async(); + await _webBrowser.EnsureCoreWebView2Async(); - if (Urls.Any()) + if (Screen.URLs.Any()) { - if (Urls.Count > 1) + if (Screen.URLs.Count > 1) { - // Shuffle the URLs if necessary - shuffleOrder = prefsManager.GetRandomizeFlagByScreen(screenNum); - if (shuffleOrder) + if (Screen.Shuffle) { - random = new Random(); - int n = urls.Count; + int n = Screen.URLs.Count; while (n > 1) { n--; int k = random.Next(n + 1); - var value = urls[k]; - urls[k] = urls[n]; - urls[n] = value; + var value = Screen.URLs[k]; + Screen.URLs[k] = Screen.URLs[n]; + Screen.URLs[n] = value; } } // Set up timer to rotate to the next URL timer = new Timer(); - timer.Interval = prefsManager.GetRotationIntervalByScreen(screenNum) * 1000; + timer.Interval = Screen.RotationInterval * 1000; timer.Tick += (s, ee) => RotateSite(); timer.Start(); } @@ -92,7 +77,7 @@ private async void ScreensaverForm_Load(object sender, EventArgs e) } else { - webBrowser.Visible = false; + _webBrowser.Visible = false; } } @@ -103,21 +88,14 @@ private void BrowseTo(string url) if (string.IsNullOrWhiteSpace(url)) { - webBrowser.Visible = false; + _webBrowser.Visible = false; } else { - webBrowser.Visible = true; - try - { - Debug.WriteLine($"Navigating: {url}"); - webBrowser.CoreWebView2.Navigate(url); - } - catch - { - // This can happen if IE pops up a window that isn't closed before the next call to Navigate() - } + _webBrowser.Visible = true; + _webBrowser.CoreWebView2.Navigate(url); } + Application.AddMessageFilter(userEventHandler); } @@ -125,71 +103,37 @@ private void RotateSite() { currentSiteIndex++; - if (currentSiteIndex >= Urls.Count) + if (currentSiteIndex >= Screen.URLs.Count) { currentSiteIndex = 0; } - var url = Urls[currentSiteIndex]; + var url = Screen.URLs[currentSiteIndex]; BrowseTo(url); } private void HandleUserActivity() { - if (StartTime.AddSeconds(1) > DateTime.Now) return; + if (StartTime.AddSeconds(1) > DateTime.Now) + { + return; + } - if (prefsManager.CloseOnActivity) + if (Preferences.CloseOnMouseMovement) { Close(); } else { - closeButton.Visible = true; + _closeButton.Visible = true; Cursor.Show(); } } - private void closeButton_Click(object sender, EventArgs e) + private void CloseButton_Click(object sender, EventArgs e) { Close(); } } - - public class GlobalUserEventHandler : IMessageFilter - { - public delegate void UserEvent(); - - private const int WM_MOUSEMOVE = 0x0200; - private const int WM_MBUTTONDBLCLK = 0x209; - private const int WM_KEYDOWN = 0x100; - private const int WM_KEYUP = 0x101; - - // screensavers and especially multi-window apps can get spurrious WM_MOUSEMOVE events - // that don't actually involve any movement (cursor chnages and some mouse driver software - // can generate them, for example) - so we record the actual mouse position and compare against it for actual movement. - private Point? lastMousePos; - - public event UserEvent Event; - - public bool PreFilterMessage(ref Message m) - { - if ((m.Msg == WM_MOUSEMOVE) && (this.lastMousePos == null)) - { - this.lastMousePos = Cursor.Position; - } - - if (((m.Msg == WM_MOUSEMOVE) && (Cursor.Position != this.lastMousePos)) - || (m.Msg > WM_MOUSEMOVE && m.Msg <= WM_MBUTTONDBLCLK) || m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) - { - - if (Event != null) - { - Event(); - } - } - // Always allow message to continue to the next filter control - return false; - } - } } \ No newline at end of file From b2d54d0b69ef1c1f4f38f906d590b43b2c3d4bd5 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Tue, 8 Sep 2020 02:24:11 -0700 Subject: [PATCH 26/45] More updates --- Preferences.cs | 4 +- PreferencesForm.Designer.cs | 28 ++--- PreferencesForm.cs | 220 ++++++++++++------------------------ PrefsByScreenUserControl.cs | 10 ++ ScreenInformation.cs | 18 +-- ScreensaverForm.cs | 101 ++++++++--------- 6 files changed, 150 insertions(+), 231 deletions(-) diff --git a/Preferences.cs b/Preferences.cs index e9bfe4f..f85756e 100644 --- a/Preferences.cs +++ b/Preferences.cs @@ -62,9 +62,9 @@ public static Dictionary Screens Dictionary screens = new Dictionary(); MultiScreenMode multiScreenMode = MultiScreen; - for (int screenNumber = 1; screenNumber <= ScreenCount; screenNumber++) + for (int screenNumber = 0; screenNumber < ScreenCount; screenNumber++) { - string screenKeyName = $"Screen{screenNumber}"; + string screenKeyName = $"Display{screenNumber + 1}"; // To match tab name RegistryKey subKey = RootKey.GetOrCreateSubKey(screenKeyName); ScreenInformation info = new ScreenInformation(subKey, screenNumber, multiScreenMode); screens.Add(screenNumber, info); diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 711dc00..052f880 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -31,13 +31,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this._components = new System.ComponentModel.Container(); + this.components = new System.ComponentModel.Container(); this._linkLabelProjectURL = new System.Windows.Forms.LinkLabel(); this._tabControlScreens = new System.Windows.Forms.TabControl(); this._tabPageScreen = new System.Windows.Forms.TabPage(); - this._prefsByScreenUserControl = new WebPageScreensaver.PrefsByScreenUserControl(); this._labelWebsiteURLs = new System.Windows.Forms.Label(); - this._toolTipScreenMode = new System.Windows.Forms.ToolTip(this._components); + this._toolTipScreenMode = new System.Windows.Forms.ToolTip(this.components); this._radioButtonSeparateScreens = new System.Windows.Forms.RadioButton(); this._radioButtonMirrorScreens = new System.Windows.Forms.RadioButton(); this._radioButtonSpanScreens = new System.Windows.Forms.RadioButton(); @@ -50,7 +49,6 @@ private void InitializeComponent() this._checkBoxCloseOnMouseMovement = new System.Windows.Forms.CheckBox(); this._flowLayoutPanelMultiScreenButtons = new System.Windows.Forms.FlowLayoutPanel(); this._tabControlScreens.SuspendLayout(); - this._tabPageScreen.SuspendLayout(); this._tableLayoutPanelMain.SuspendLayout(); this._tableLayoutPanelMainBottom.SuspendLayout(); this._tableLayoutPanelMainTop.SuspendLayout(); @@ -86,7 +84,6 @@ private void InitializeComponent() // // _tabPageScreen // - this._tabPageScreen.Controls.Add(this._prefsByScreenUserControl); this._tabPageScreen.Location = new System.Drawing.Point(8, 46); this._tabPageScreen.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._tabPageScreen.Name = "_tabPageScreen"; @@ -96,18 +93,6 @@ private void InitializeComponent() this._tabPageScreen.Text = "Screen 1"; this._tabPageScreen.UseVisualStyleBackColor = true; // - // _prefsByScreenUserControl - // - this._prefsByScreenUserControl.AutoSize = true; - this._prefsByScreenUserControl.BackColor = System.Drawing.Color.White; - this._prefsByScreenUserControl.Dock = System.Windows.Forms.DockStyle.Fill; - this._prefsByScreenUserControl.Location = new System.Drawing.Point(4, 5); - this._prefsByScreenUserControl.Margin = new System.Windows.Forms.Padding(0); - this._prefsByScreenUserControl.MinimumSize = new System.Drawing.Size(640, 480); - this._prefsByScreenUserControl.Name = "_prefsByScreenUserControl"; - this._prefsByScreenUserControl.Size = new System.Drawing.Size(966, 480); - this._prefsByScreenUserControl.TabIndex = 25; - // // _labelWebsiteURLs // this._labelWebsiteURLs.AutoSize = true; @@ -123,6 +108,8 @@ private void InitializeComponent() // _radioButtonSeparateScreens // this._radioButtonSeparateScreens.AutoSize = true; + this._radioButtonSeparateScreens.Checked = true; + this._radioButtonSeparateScreens.Enabled = true; this._radioButtonSeparateScreens.Location = new System.Drawing.Point(233, 9); this._radioButtonSeparateScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._radioButtonSeparateScreens.Name = "_radioButtonSeparateScreens"; @@ -137,6 +124,7 @@ private void InitializeComponent() // _radioButtonMirrorScreens // this._radioButtonMirrorScreens.AutoSize = true; + this._radioButtonMirrorScreens.Enabled = true; this._radioButtonMirrorScreens.Location = new System.Drawing.Point(114, 9); this._radioButtonMirrorScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._radioButtonMirrorScreens.Name = "_radioButtonMirrorScreens"; @@ -151,7 +139,7 @@ private void InitializeComponent() // _radioButtonSpanScreens // this._radioButtonSpanScreens.AutoSize = true; - this._radioButtonSpanScreens.Checked = true; + this._radioButtonSpanScreens.Enabled = true; this._radioButtonSpanScreens.Location = new System.Drawing.Point(8, 9); this._radioButtonSpanScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._radioButtonSpanScreens.Name = "_radioButtonSpanScreens"; @@ -301,8 +289,6 @@ private void InitializeComponent() this.Text = "Web Page Screensaver Settings"; this.Load += new System.EventHandler(this.PreferencesForm_Load); this._tabControlScreens.ResumeLayout(false); - this._tabPageScreen.ResumeLayout(false); - this._tabPageScreen.PerformLayout(); this._tableLayoutPanelMain.ResumeLayout(false); this._tableLayoutPanelMain.PerformLayout(); this._tableLayoutPanelMainBottom.ResumeLayout(false); @@ -332,11 +318,11 @@ private void InitializeComponent() private Label _labelWebsiteURLs; private TabControl _tabControlScreens; private TabPage _tabPageScreen; - private PrefsByScreenUserControl _prefsByScreenUserControl; private TableLayoutPanel _tableLayoutPanelMainBottom; private LinkLabel _linkLabelProjectURL; private Button _buttonCancel; private Button _buttonOK; + private System.ComponentModel.IContainer components; } } \ No newline at end of file diff --git a/PreferencesForm.cs b/PreferencesForm.cs index 4d4edad..f0c3a2a 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -11,8 +11,6 @@ internal partial class PreferencesForm : Form { private const string Webpage = "http://github.com/carlossanlop/web-page-screensaver/"; - private List Tabs => new List(); - public PreferencesForm() { InitializeComponent(); @@ -20,137 +18,12 @@ public PreferencesForm() private void PreferencesForm_Load(object sender, EventArgs e) { - _checkBoxCloseOnMouseMovement.Checked = Preferences.CloseOnMouseMovement; - if (Screen.AllScreens.Length == 1) - { - _flowLayoutPanelMultiScreenButtons.Enabled = false; - } - else - { - _flowLayoutPanelMultiScreenButtons.Enabled = true; - } - SetMultiScreenButtonFromMode(); - ArrangeScreenTabs(); - } - - private void ArrangeScreenTabs() - { - switch (Preferences.MultiScreen) - { - case MultiScreenMode.Span: - RemoveExtraTabPages(); - _tabControlScreens.TabPages[0].Text = "Composite Screen"; - // Need to clear because we only expect one tab - Tabs.Clear(); - Tabs.Add(_prefsByScreenUserControl); - Fetch(); - break; - case MultiScreenMode.Mirror: - RemoveExtraTabPages(); - _tabControlScreens.TabPages[0].Text = "Each Screen"; - // Need to clear because we only expect one tab - Tabs.Clear(); - Tabs.Add(_prefsByScreenUserControl); - Fetch(); - break; - case MultiScreenMode.Separate: - for (int i = 0; i < Screen.AllScreens.Length; i++) - { - TabPage? tabPage = null; - - if (i >= _tabControlScreens.TabPages.Count) - { - tabPage = new TabPage(); - _tabControlScreens.TabPages.Add(tabPage); - - if (i > 0) - { - var prefsByScreenUserControl = new PrefsByScreenUserControl - { - Name = string.Format("prefsByScreenUserControl{0}", i + 1), - Location = new Point(0, 0), - Size = _prefsByScreenUserControl.Size, - Anchor = _prefsByScreenUserControl.Anchor, - BackColor = _prefsByScreenUserControl.BackColor - }; - prefsByScreenUserControl._listViewURLs.ContextMenuStrip = - _prefsByScreenUserControl.ContextMenuStrip; - // No need to clear because we are re-adding the missing tabs - Tabs.Add(prefsByScreenUserControl); - tabPage.Controls.Add(prefsByScreenUserControl); - } - } - else if (_tabControlScreens.TabPages.Count == 1) - { - tabPage = _tabControlScreens.TabPages[0]; - // Clearing before adding prevents a crash when going from Separate to Mirror and back to Separate - Tabs.Clear(); - Tabs.Add(_prefsByScreenUserControl); - } - - if (tabPage == null) - { - throw new NullReferenceException("tabPage should not be null."); - } - - Fetch(); - string primaryIndicator = string.Empty; - if (Screen.AllScreens[i].Primary) primaryIndicator = " (main)"; - tabPage.Text = string.Format("Screen {0}{1}", i + 1, primaryIndicator); - } - - break; - } - } - - private void RemoveExtraTabPages() - { - while (_tabControlScreens.TabPages.Count > 1) - { - _tabControlScreens.TabPages.RemoveAt(_tabControlScreens.TabPages.Count - 1); - } - } - - private void SetMultiScreenButtonFromMode() - { - switch (Preferences.MultiScreen) - { - case MultiScreenMode.Span: - _radioButtonSpanScreens.Checked = true; - break; - case MultiScreenMode.Mirror: - _radioButtonMirrorScreens.Checked = true; - break; - case MultiScreenMode.Separate: - _radioButtonSeparateScreens.Checked = true; - break; - default: - throw new ArgumentOutOfRangeException("Unrecognized MultiScreenMode."); - } + Fetch(); } - private void SetMultiScreenModeFromButtonState() - { - if (_radioButtonSpanScreens.Checked) - { - Preferences.MultiScreen = MultiScreenMode.Span; - } - else if (_radioButtonMirrorScreens.Checked) - { - Preferences.MultiScreen = MultiScreenMode.Mirror; - } - else - { - Preferences.MultiScreen = MultiScreenMode.Separate; - } - } - - private void anyMultiScreenModeButton_Click(object sender, EventArgs e) { Save(); - SetMultiScreenModeFromButtonState(); - ArrangeScreenTabs(); } /// @@ -185,50 +58,103 @@ private void ButtonCancel_Click(object sender, EventArgs e) } /// - /// Retrieve data for the specified screen from the registry and show it in the form. + /// Retrieve shared data and show it in the form. /// - /// The screen number. private void Fetch() { + MultiScreenMode multiScreenMode = Preferences.MultiScreen; + _checkBoxCloseOnMouseMovement.Checked = Preferences.CloseOnMouseMovement; - for (int screenNumber = 0; screenNumber < Tabs.Count; screenNumber++) + _flowLayoutPanelMultiScreenButtons.Enabled = Screen.AllScreens.Length > 1; + + _radioButtonMirrorScreens.Checked = multiScreenMode == MultiScreenMode.Mirror; + _radioButtonSeparateScreens.Checked = multiScreenMode == MultiScreenMode.Separate; + _radioButtonSpanScreens.Checked = multiScreenMode == MultiScreenMode.Span; + + _tabControlScreens.TabPages.Clear(); + + int totalTabs = multiScreenMode switch { - PrefsByScreenUserControl currentTab = Tabs[screenNumber]; - ScreenInformation currentScreen = Preferences.Screens[screenNumber]; + 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.") + }; - currentTab._listViewURLs.Items.Clear(); + for (int tabNumber = 0; tabNumber < totalTabs; tabNumber++) + { + TabPage tab = new TabPage(); + tab.Text = $"Display {tabNumber + 1}{tabTextSuffix}"; // Matches registry key name + + var currentUserControl = new PrefsByScreenUserControl + { + AutoSize = true, + BackColor = Color.White, + Dock = DockStyle.Fill, + Location = new Point(4, 5), + Margin = new Padding(0), + MinimumSize = new Size(640, 300), + Name = $"_prefsByScreenUserControl{tabNumber}", + Size = new Size(640, 300), + TabIndex = 25 + }; + + ScreenInformation currentScreen = Preferences.Screens[tabNumber]; + foreach (string url in currentScreen.URLs) { - currentTab._listViewURLs.Items.Add(url); + currentUserControl._listViewURLs.Items.Add(url); } - currentTab._numericUpDownRotationInterval.Value = Preferences.Screens[screenNumber].RotationInterval; - currentTab._checkBoxShuffle.Checked = Preferences.Screens[screenNumber].Shuffle; + currentUserControl._numericUpDownRotationInterval.Value = currentScreen.RotationInterval; + currentUserControl._checkBoxShuffle.Checked = currentScreen.Shuffle; + + tab.Controls.Add(currentUserControl); + _tabControlScreens.TabPages.Add(tab); } } /// - /// Retrieve data from the form and save it in the registry. + /// Read the data from the form and save it in the registry. /// private void Save() { Preferences.CloseOnMouseMovement = _checkBoxCloseOnMouseMovement.Checked; - for (int screenNumber = 0; screenNumber < Tabs.Count; screenNumber++) + if (_radioButtonSpanScreens.Checked) + { + Preferences.MultiScreen = MultiScreenMode.Span; + } + else if (_radioButtonMirrorScreens.Checked) { - PrefsByScreenUserControl currentTab = Tabs[screenNumber]; - ScreenInformation currentScreen = Preferences.Screens[screenNumber]; + Preferences.MultiScreen = MultiScreenMode.Mirror; + } + else // default + { + Preferences.MultiScreen = MultiScreenMode.Separate; + } - currentScreen.URLs.Clear(); - foreach (ListViewItem item in currentTab._listViewURLs.Items) + int screenNumber = 0; + foreach (TabPage tab in _tabControlScreens.TabPages) + { + if (tab.Controls[0] is PrefsByScreenUserControl userControl) { - currentScreen.URLs.Add(item.Text); + userControl.Save(screenNumber); + screenNumber++; + } + else + { + throw new KeyNotFoundException("PrefsByScreenUserControl instance not found in tab."); } - - currentScreen.RotationInterval = (int)currentTab._numericUpDownRotationInterval.Value; - currentScreen.Shuffle = currentTab._checkBoxShuffle.Checked; } } } diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index 96f6f8a..ce5657c 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; namespace WebPageScreensaver @@ -10,6 +12,14 @@ public PrefsByScreenUserControl() InitializeComponent(); } + public void Save(int screenNumber) + { + ScreenInformation currentScreen = Preferences.Screens[screenNumber]; + currentScreen.UpdateURLs(from ListViewItem item in _listViewURLs.Items.Cast() select item.Text); + currentScreen.RotationInterval = (int)_numericUpDownRotationInterval.Value; + currentScreen.Shuffle = _checkBoxShuffle.Checked; + } + private void MoveAllSelectedUrlsDown_Click(object sender, EventArgs e) { // TODO: make button grey out when none selected OR when all selected ones are in a bunch at the bottom. diff --git a/ScreenInformation.cs b/ScreenInformation.cs index 536728c..dce1652 100644 --- a/ScreenInformation.cs +++ b/ScreenInformation.cs @@ -58,6 +58,7 @@ public int ScreenNumber get => int.Parse(RootKey.GetOrCreateValue(SettingName.ScreenNumber)); set => RootKey.SetValue(SettingName.ScreenNumber, value); } + public Rectangle Bounds { get; set; } public bool IsPrimary @@ -66,24 +67,27 @@ public bool IsPrimary set => RootKey.SetValue(SettingName.IsPrimary, value); } - public List URLs + public IEnumerable URLs { get { string urlsString = RootKey.GetOrCreateValue(SettingName.URLs, string.Empty); - return urlsString.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList(); - } - set - { - string urlsString = string.Join(' ', value); - RootKey.SetValue(SettingName.URLs, urlsString); + return urlsString.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); } } + + public void UpdateURLs(IEnumerable urls) + { + string urlsString = string.Join(' ', urls); + RootKey.SetValue(SettingName.URLs, urlsString); + } + public int RotationInterval { get => int.Parse(RootKey.GetOrCreateValue(SettingName.RotationInterval, SettingValue.RotationInterval)); set => RootKey.SetValue(SettingName.RotationInterval, value); } + public bool Shuffle { get => bool.Parse(RootKey.GetOrCreateValue(SettingName.Shuffle, SettingValue.Shuffle)); diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index f32cffb..52aba8a 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -9,25 +9,29 @@ namespace WebPageScreensaver { internal partial class ScreensaverForm : Form { - private DateTime StartTime; - private Timer timer; - private int currentSiteIndex = -1; - private MouseEventHandler userEventHandler; + private int _currentURLIndex; - private ScreenInformation Screen; - - [ThreadStatic] - private static Random random = new Random(); + private readonly DateTime _startTime; + private readonly Timer _timer; + private readonly MouseEventHandler _mouseEventHandler; + private readonly bool _closeOnMouseMovement; + private readonly int _rotationInterval; + private readonly bool _shuffle; + private readonly List _urls; public ScreensaverForm(ScreenInformation screen, bool showCursor) { - userEventHandler = new MouseEventHandler(); - userEventHandler.Event += new MouseEventHandler.UserEvent(HandleUserActivity); + _mouseEventHandler = new MouseEventHandler(); + _mouseEventHandler.Event += new MouseEventHandler.UserEvent(HandleUserActivity); - Screen = screen; + _closeOnMouseMovement = Preferences.CloseOnMouseMovement; + _rotationInterval = screen.RotationInterval; + _shuffle = screen.Shuffle; + _urls = screen.URLs.ToList(); + _currentURLIndex = 0; - Location = new Point(Screen.Bounds.Left, Screen.Bounds.Top); - Size = new Size(Screen.Bounds.Width, Screen.Bounds.Height); + Location = new Point(screen.Bounds.Left, screen.Bounds.Top); + Size = new Size(screen.Bounds.Width, screen.Bounds.Height); InitializeComponent(); @@ -35,6 +39,9 @@ public ScreensaverForm(ScreenInformation screen, bool showCursor) { Cursor.Hide(); } + + _startTime = DateTime.Now; + _timer = new Timer(); } private async void ScreensaverForm_Load(object sender, EventArgs e) @@ -45,35 +52,25 @@ private async void ScreensaverForm_Load(object sender, EventArgs e) } await _webBrowser.EnsureCoreWebView2Async(); - if (Screen.URLs.Any()) + if (_urls.Any()) { - if (Screen.URLs.Count > 1) + if (_shuffle) { - if (Screen.Shuffle) + Random random = new Random(); + int n = _urls.Count; + while (n > 1) { - - int n = Screen.URLs.Count; - while (n > 1) - { - n--; - int k = random.Next(n + 1); - var value = Screen.URLs[k]; - Screen.URLs[k] = Screen.URLs[n]; - Screen.URLs[n] = value; - } + n--; + int k = random.Next(n + 1); + var value = _urls[k]; + _urls[k] = _urls[n]; + _urls[n] = value; } - - // Set up timer to rotate to the next URL - timer = new Timer(); - timer.Interval = Screen.RotationInterval * 1000; - timer.Tick += (s, ee) => RotateSite(); - timer.Start(); } - // Display the first site in the list - RotateSite(); - - StartTime = DateTime.Now; + _timer.Interval = _rotationInterval * 1000; + _timer.Tick += (s, ee) => RotateSite(); + _timer.Start(); } else { @@ -81,10 +78,20 @@ private async void ScreensaverForm_Load(object sender, EventArgs e) } } + private void RotateSite() + { + if (_currentURLIndex >= _urls.Count) + { + _currentURLIndex = 0; + } + BrowseTo(_urls[_currentURLIndex]); + _currentURLIndex++; + } + private void BrowseTo(string url) { // Disable the user event handler while navigating - Application.RemoveMessageFilter(userEventHandler); + Application.RemoveMessageFilter(_mouseEventHandler); if (string.IsNullOrWhiteSpace(url)) { @@ -96,31 +103,17 @@ private void BrowseTo(string url) _webBrowser.CoreWebView2.Navigate(url); } - Application.AddMessageFilter(userEventHandler); - } - - private void RotateSite() - { - currentSiteIndex++; - - if (currentSiteIndex >= Screen.URLs.Count) - { - currentSiteIndex = 0; - } - - var url = Screen.URLs[currentSiteIndex]; - - BrowseTo(url); + Application.AddMessageFilter(_mouseEventHandler); } private void HandleUserActivity() { - if (StartTime.AddSeconds(1) > DateTime.Now) + if (_startTime.AddSeconds(1) > DateTime.Now) { return; } - if (Preferences.CloseOnMouseMovement) + if (_closeOnMouseMovement) { Close(); } From b6fb83fc28d1c5f359840a04b9ccbd382e583998 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Lopez Date: Tue, 8 Sep 2020 20:30:49 -0700 Subject: [PATCH 27/45] Simplify mouse and keyboard handling. Pending to review why WebView2 does not read MouseMove (may be a bug on their side). Ensure sizes of fonts and windows are respected. --- Extensions.cs | 8 +- MouseEventHandler.cs | 43 ------ PreferencesForm.Designer.cs | 215 +++++++++++++++------------ PreferencesForm.cs | 103 +++++++------ PreferencesForm.resx | 120 +++++++++++++++ PrefsByScreenUserControl.Designer.cs | 120 +++++++++------ PrefsByScreenUserControl.cs | 1 - Program.cs | 27 ++-- Properties/launchSettings.json | 2 +- ScreensaverForm.Designer.cs | 41 ++--- ScreensaverForm.cs | 60 +++----- ScreensaverForm.resx | 60 ++++++++ 12 files changed, 477 insertions(+), 323 deletions(-) delete mode 100644 MouseEventHandler.cs create mode 100644 PreferencesForm.resx create mode 100644 ScreensaverForm.resx diff --git a/Extensions.cs b/Extensions.cs index e6384e0..4a7ff39 100644 --- a/Extensions.cs +++ b/Extensions.cs @@ -46,14 +46,14 @@ public static string GetOrCreateValue(this RegistryKey root, string valueName, o object? obj = root.GetValue(valueName); if (obj == null) { - root.SetValue(valueName, defaultValue!.ToString()); + root.SetValue(valueName, defaultValue.ToString() ?? string.Empty); obj = root.GetValue(valueName); if (obj == null) { throw new UnauthorizedAccessException($"Could not get/create the registry value: {valueName}"); } } - return obj!.ToString(); + return obj.ToString() ?? string.Empty; } public static string GetOrCreateValue(this RegistryKey root, string valueName) @@ -72,7 +72,7 @@ public static string GetOrCreateValue(this RegistryKey root, string valueName) { throw new UnauthorizedAccessException($"Could not get/create the registry value: {valueName}"); } - return obj!.ToString(); + return obj.ToString() ?? string.Empty; } } -} +} \ No newline at end of file diff --git a/MouseEventHandler.cs b/MouseEventHandler.cs deleted file mode 100644 index 8518b9e..0000000 --- a/MouseEventHandler.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace WebPageScreensaver -{ - /// - /// Screensavers, and especially multi-window apps, can get spurious WM_MOUSEMOVE events - /// that don't actually involve any movement (cursor chnages and some mouse driver software - /// can generate them, for example) - so we record the actual mouse position and compare - /// against it for actual movement. - /// - internal class MouseEventHandler : IMessageFilter - { - private const int WM_MOUSEMOVE = 0x0200; - private const int WM_MBUTTONDBLCLK = 0x209; - private const int WM_KEYDOWN = 0x100; - private const int WM_KEYUP = 0x101; - - private Point? _lastMousePosition; - - public delegate void UserEvent(); - - public event UserEvent? Event; - - public bool PreFilterMessage(ref Message m) - { - if (_lastMousePosition == null && m.Msg == WM_MOUSEMOVE) - { - _lastMousePosition = Cursor.Position; - } - - if ((m.Msg == WM_MOUSEMOVE && Cursor.Position != _lastMousePosition) - || (m.Msg > WM_MOUSEMOVE && m.Msg <= WM_MBUTTONDBLCLK) || m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) - { - - Event?.Invoke(); - } - - // Always allow message to continue to the next filter control - return false; - } - } -} diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 052f880..351113d 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -1,7 +1,4 @@ -using System; -using System.Windows.Forms; - -namespace WebPageScreensaver +namespace WebPageScreensaver { internal partial class PreferencesForm { @@ -45,42 +42,44 @@ private void InitializeComponent() this._buttonCancel = new System.Windows.Forms.Button(); this._buttonOK = new System.Windows.Forms.Button(); this._tableLayoutPanelMainTop = new System.Windows.Forms.TableLayoutPanel(); - this._labelMultiScreen = new System.Windows.Forms.Label(); this._checkBoxCloseOnMouseMovement = new System.Windows.Forms.CheckBox(); - this._flowLayoutPanelMultiScreenButtons = new System.Windows.Forms.FlowLayoutPanel(); + this._labelMultiScreen = new System.Windows.Forms.Label(); + this._flowLayoutPanelMultiScreenMode = new System.Windows.Forms.FlowLayoutPanel(); this._tabControlScreens.SuspendLayout(); this._tableLayoutPanelMain.SuspendLayout(); this._tableLayoutPanelMainBottom.SuspendLayout(); this._tableLayoutPanelMainTop.SuspendLayout(); - this._flowLayoutPanelMultiScreenButtons.SuspendLayout(); + this._flowLayoutPanelMultiScreenMode.SuspendLayout(); this.SuspendLayout(); // // _linkLabelProjectURL // - this._linkLabelProjectURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + this._linkLabelProjectURL.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._linkLabelProjectURL.AutoSize = true; + this._linkLabelProjectURL.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this._linkLabelProjectURL.Location = new System.Drawing.Point(6, 0); this._linkLabelProjectURL.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this._linkLabelProjectURL.Name = "_linkLabelProjectURL"; - this._linkLabelProjectURL.Size = new System.Drawing.Size(99, 59); - this._linkLabelProjectURL.TabIndex = 1; + this._linkLabelProjectURL.Size = new System.Drawing.Size(662, 65); + this._linkLabelProjectURL.TabIndex = 7; this._linkLabelProjectURL.TabStop = true; this._linkLabelProjectURL.Text = "Website"; - this._linkLabelProjectURL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this._toolTipScreenMode.SetToolTip(this._linkLabelProjectURL, "http://github.com/carlossanlop/web-page-screensaver/"); + this._linkLabelProjectURL.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this._linkLabelProjectURL.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelProjectURL_LinkClicked); // // _tabControlScreens // this._tabControlScreens.Controls.Add(this._tabPageScreen); this._tabControlScreens.Dock = System.Windows.Forms.DockStyle.Fill; - this._tabControlScreens.Location = new System.Drawing.Point(4, 186); - this._tabControlScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._tabControlScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._tabControlScreens.Location = new System.Drawing.Point(0, 181); + this._tabControlScreens.Margin = new System.Windows.Forms.Padding(0); this._tabControlScreens.Name = "_tabControlScreens"; this._tabControlScreens.SelectedIndex = 0; - this._tabControlScreens.Size = new System.Drawing.Size(990, 441); - this._tabControlScreens.TabIndex = 13; + this._tabControlScreens.Size = new System.Drawing.Size(998, 451); + this._tabControlScreens.TabIndex = 6; // // _tabPageScreen // @@ -88,72 +87,88 @@ private void InitializeComponent() this._tabPageScreen.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this._tabPageScreen.Name = "_tabPageScreen"; this._tabPageScreen.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this._tabPageScreen.Size = new System.Drawing.Size(974, 387); + this._tabPageScreen.Size = new System.Drawing.Size(982, 397); this._tabPageScreen.TabIndex = 0; this._tabPageScreen.Text = "Screen 1"; this._tabPageScreen.UseVisualStyleBackColor = true; // // _labelWebsiteURLs // + this._labelWebsiteURLs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._labelWebsiteURLs.AutoSize = true; - this._labelWebsiteURLs.Dock = System.Windows.Forms.DockStyle.Left; + this._labelWebsiteURLs.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this._labelWebsiteURLs.Location = new System.Drawing.Point(6, 122); this._labelWebsiteURLs.Margin = new System.Windows.Forms.Padding(6); this._labelWebsiteURLs.Name = "_labelWebsiteURLs"; - this._labelWebsiteURLs.Size = new System.Drawing.Size(157, 53); - this._labelWebsiteURLs.TabIndex = 2; - this._labelWebsiteURLs.Text = "Website URLs"; + this._labelWebsiteURLs.Size = new System.Drawing.Size(986, 53); + this._labelWebsiteURLs.TabIndex = 5; + this._labelWebsiteURLs.Text = "Website URLs:"; this._labelWebsiteURLs.TextAlign = System.Drawing.ContentAlignment.BottomLeft; // // _radioButtonSeparateScreens // + this._radioButtonSeparateScreens.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._radioButtonSeparateScreens.AutoSize = true; this._radioButtonSeparateScreens.Checked = true; - this._radioButtonSeparateScreens.Enabled = true; - this._radioButtonSeparateScreens.Location = new System.Drawing.Point(233, 9); - this._radioButtonSeparateScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._radioButtonSeparateScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._radioButtonSeparateScreens.Location = new System.Drawing.Point(6, 6); + this._radioButtonSeparateScreens.Margin = new System.Windows.Forms.Padding(6); this._radioButtonSeparateScreens.Name = "_radioButtonSeparateScreens"; this._radioButtonSeparateScreens.Size = new System.Drawing.Size(138, 36); - this._radioButtonSeparateScreens.TabIndex = 15; + this._radioButtonSeparateScreens.TabIndex = 1; this._radioButtonSeparateScreens.TabStop = true; this._radioButtonSeparateScreens.Tag = "MultiScreenMode"; this._radioButtonSeparateScreens.Text = "Separate"; this._toolTipScreenMode.SetToolTip(this._radioButtonSeparateScreens, "Each to their own!"); this._radioButtonSeparateScreens.UseVisualStyleBackColor = true; + this._radioButtonSeparateScreens.CheckedChanged += new System.EventHandler(this.RadioButtonMultiScreenMode_Checked); // // _radioButtonMirrorScreens // + this._radioButtonMirrorScreens.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._radioButtonMirrorScreens.AutoSize = true; - this._radioButtonMirrorScreens.Enabled = true; - this._radioButtonMirrorScreens.Location = new System.Drawing.Point(114, 9); - this._radioButtonMirrorScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._radioButtonMirrorScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._radioButtonMirrorScreens.Location = new System.Drawing.Point(156, 6); + this._radioButtonMirrorScreens.Margin = new System.Windows.Forms.Padding(6); this._radioButtonMirrorScreens.Name = "_radioButtonMirrorScreens"; this._radioButtonMirrorScreens.Size = new System.Drawing.Size(111, 36); - this._radioButtonMirrorScreens.TabIndex = 26; + this._radioButtonMirrorScreens.TabIndex = 2; this._radioButtonMirrorScreens.TabStop = true; this._radioButtonMirrorScreens.Tag = "MultiScreenMode"; this._radioButtonMirrorScreens.Text = "Mirror"; this._toolTipScreenMode.SetToolTip(this._radioButtonMirrorScreens, "One for All!"); this._radioButtonMirrorScreens.UseVisualStyleBackColor = true; + this._radioButtonMirrorScreens.CheckedChanged += new System.EventHandler(this.RadioButtonMultiScreenMode_Checked); // // _radioButtonSpanScreens // + this._radioButtonSpanScreens.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._radioButtonSpanScreens.AutoSize = true; - this._radioButtonSpanScreens.Enabled = true; - this._radioButtonSpanScreens.Location = new System.Drawing.Point(8, 9); - this._radioButtonSpanScreens.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._radioButtonSpanScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._radioButtonSpanScreens.Location = new System.Drawing.Point(279, 6); + this._radioButtonSpanScreens.Margin = new System.Windows.Forms.Padding(6); this._radioButtonSpanScreens.Name = "_radioButtonSpanScreens"; this._radioButtonSpanScreens.Size = new System.Drawing.Size(98, 36); - this._radioButtonSpanScreens.TabIndex = 21; + this._radioButtonSpanScreens.TabIndex = 3; this._radioButtonSpanScreens.TabStop = true; this._radioButtonSpanScreens.Tag = "MultiScreenMode"; this._radioButtonSpanScreens.Text = "Span"; this._toolTipScreenMode.SetToolTip(this._radioButtonSpanScreens, "All for One!"); this._radioButtonSpanScreens.UseVisualStyleBackColor = true; + this._radioButtonSpanScreens.CheckedChanged += new System.EventHandler(this.RadioButtonMultiScreenMode_Checked); // // _tableLayoutPanelMain // this._tableLayoutPanelMain.AutoSize = true; + this._tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMain.ColumnCount = 1; this._tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMain.Controls.Add(this._tabControlScreens, 0, 2); @@ -162,7 +177,7 @@ private void InitializeComponent() this._tableLayoutPanelMain.Controls.Add(this._labelWebsiteURLs, 0, 1); this._tableLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill; this._tableLayoutPanelMain.Location = new System.Drawing.Point(0, 0); - this._tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(4); + this._tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; this._tableLayoutPanelMain.RowCount = 4; this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 116F)); @@ -175,6 +190,8 @@ private void InitializeComponent() // // _tableLayoutPanelMainBottom // + this._tableLayoutPanelMainBottom.AutoSize = true; + this._tableLayoutPanelMainBottom.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainBottom.ColumnCount = 3; this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); @@ -183,22 +200,24 @@ private void InitializeComponent() this._tableLayoutPanelMainBottom.Controls.Add(this._linkLabelProjectURL, 0, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._buttonOK, 1, 0); this._tableLayoutPanelMainBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(3, 635); + this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(0, 632); + this._tableLayoutPanelMainBottom.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; this._tableLayoutPanelMainBottom.RowCount = 1; this._tableLayoutPanelMainBottom.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(992, 59); + this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(998, 65); this._tableLayoutPanelMainBottom.TabIndex = 0; // // _buttonCancel // this._buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.None; this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this._buttonCancel.Location = new System.Drawing.Point(836, 7); + this._buttonCancel.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonCancel.Location = new System.Drawing.Point(842, 10); this._buttonCancel.Margin = new System.Windows.Forms.Padding(6); this._buttonCancel.Name = "_buttonCancel"; this._buttonCancel.Size = new System.Drawing.Size(150, 44); - this._buttonCancel.TabIndex = 6; + this._buttonCancel.TabIndex = 9; this._buttonCancel.Text = "Cancel"; this._buttonCancel.UseVisualStyleBackColor = true; this._buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); @@ -207,7 +226,8 @@ private void InitializeComponent() // this._buttonOK.Anchor = System.Windows.Forms.AnchorStyles.None; this._buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this._buttonOK.Location = new System.Drawing.Point(674, 7); + this._buttonOK.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonOK.Location = new System.Drawing.Point(680, 10); this._buttonOK.Margin = new System.Windows.Forms.Padding(6); this._buttonOK.Name = "_buttonOK"; this._buttonOK.Size = new System.Drawing.Size(150, 44); @@ -218,71 +238,79 @@ private void InitializeComponent() // // _tableLayoutPanelMainTop // + this._tableLayoutPanelMainTop.AutoSize = true; + this._tableLayoutPanelMainTop.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainTop.ColumnCount = 2; this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this._tableLayoutPanelMainTop.Controls.Add(this._labelMultiScreen, 0, 0); - this._tableLayoutPanelMainTop.Controls.Add(this._checkBoxCloseOnMouseMovement, 1, 0); - this._tableLayoutPanelMainTop.Controls.Add(this._flowLayoutPanelMultiScreenButtons, 0, 1); + this._tableLayoutPanelMainTop.Controls.Add(this._checkBoxCloseOnMouseMovement, 0, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._labelMultiScreen, 1, 0); + this._tableLayoutPanelMainTop.Controls.Add(this._flowLayoutPanelMultiScreenMode, 1, 1); this._tableLayoutPanelMainTop.Dock = System.Windows.Forms.DockStyle.Fill; - this._tableLayoutPanelMainTop.Location = new System.Drawing.Point(3, 3); + this._tableLayoutPanelMainTop.Location = new System.Drawing.Point(0, 0); + this._tableLayoutPanelMainTop.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; this._tableLayoutPanelMainTop.RowCount = 2; this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle()); this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle()); this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(992, 110); + this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(998, 116); this._tableLayoutPanelMainTop.TabIndex = 1; // - // _labelMultiScreen - // - this._labelMultiScreen.AutoSize = true; - this._labelMultiScreen.Dock = System.Windows.Forms.DockStyle.Left; - this._labelMultiScreen.Location = new System.Drawing.Point(6, 0); - this._labelMultiScreen.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this._labelMultiScreen.Name = "_labelMultiScreen"; - this._labelMultiScreen.Size = new System.Drawing.Size(144, 50); - this._labelMultiScreen.TabIndex = 17; - this._labelMultiScreen.Text = "Multiscreen:"; - this._labelMultiScreen.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // _checkBoxCloseOnMouseMovement // + this._checkBoxCloseOnMouseMovement.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._checkBoxCloseOnMouseMovement.AutoSize = true; this._checkBoxCloseOnMouseMovement.Checked = true; this._checkBoxCloseOnMouseMovement.CheckState = System.Windows.Forms.CheckState.Checked; - this._checkBoxCloseOnMouseMovement.Dock = System.Windows.Forms.DockStyle.Left; - this._checkBoxCloseOnMouseMovement.Location = new System.Drawing.Point(502, 7); - this._checkBoxCloseOnMouseMovement.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); + this._checkBoxCloseOnMouseMovement.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._checkBoxCloseOnMouseMovement.Location = new System.Drawing.Point(6, 6); + this._checkBoxCloseOnMouseMovement.Margin = new System.Windows.Forms.Padding(6); this._checkBoxCloseOnMouseMovement.Name = "_checkBoxCloseOnMouseMovement"; - this._checkBoxCloseOnMouseMovement.Size = new System.Drawing.Size(341, 36); - this._checkBoxCloseOnMouseMovement.TabIndex = 20; + this._checkBoxCloseOnMouseMovement.Size = new System.Drawing.Size(487, 36); + this._checkBoxCloseOnMouseMovement.TabIndex = 4; this._checkBoxCloseOnMouseMovement.Text = "Close on mouse movement"; this._checkBoxCloseOnMouseMovement.UseVisualStyleBackColor = true; // - // _flowLayoutPanelMultiScreenButtons + // _labelMultiScreen // - this._flowLayoutPanelMultiScreenButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this._labelMultiScreen.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this._flowLayoutPanelMultiScreenButtons.AutoSize = true; - this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonSpanScreens); - this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonMirrorScreens); - this._flowLayoutPanelMultiScreenButtons.Controls.Add(this._radioButtonSeparateScreens); - this._flowLayoutPanelMultiScreenButtons.Location = new System.Drawing.Point(4, 54); - this._flowLayoutPanelMultiScreenButtons.Margin = new System.Windows.Forms.Padding(4); - this._flowLayoutPanelMultiScreenButtons.Name = "_flowLayoutPanelMultiScreenButtons"; - this._flowLayoutPanelMultiScreenButtons.Padding = new System.Windows.Forms.Padding(4); - this._flowLayoutPanelMultiScreenButtons.Size = new System.Drawing.Size(488, 54); - this._flowLayoutPanelMultiScreenButtons.TabIndex = 22; + this._labelMultiScreen.AutoSize = true; + this._labelMultiScreen.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._labelMultiScreen.Location = new System.Drawing.Point(505, 6); + this._labelMultiScreen.Margin = new System.Windows.Forms.Padding(6); + this._labelMultiScreen.Name = "_labelMultiScreen"; + this._labelMultiScreen.Size = new System.Drawing.Size(487, 36); + this._labelMultiScreen.TabIndex = 0; + this._labelMultiScreen.Text = "Multiscreen:"; + this._labelMultiScreen.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // _flowLayoutPanelMultiScreenMode + // + this._flowLayoutPanelMultiScreenMode.AutoSize = true; + this._flowLayoutPanelMultiScreenMode.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this._flowLayoutPanelMultiScreenMode.Controls.Add(this._radioButtonSeparateScreens); + this._flowLayoutPanelMultiScreenMode.Controls.Add(this._radioButtonMirrorScreens); + this._flowLayoutPanelMultiScreenMode.Controls.Add(this._radioButtonSpanScreens); + this._flowLayoutPanelMultiScreenMode.Dock = System.Windows.Forms.DockStyle.Fill; + this._flowLayoutPanelMultiScreenMode.Location = new System.Drawing.Point(502, 51); + this._flowLayoutPanelMultiScreenMode.Name = "_flowLayoutPanelMultiScreenMode"; + this._flowLayoutPanelMultiScreenMode.Size = new System.Drawing.Size(493, 62); + this._flowLayoutPanelMultiScreenMode.TabIndex = 20; // // PreferencesForm // + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.ClientSize = new System.Drawing.Size(998, 697); this.Controls.Add(this._tableLayoutPanelMain); this.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(1024, 768); this.Name = "PreferencesForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; @@ -295,8 +323,8 @@ private void InitializeComponent() this._tableLayoutPanelMainBottom.PerformLayout(); this._tableLayoutPanelMainTop.ResumeLayout(false); this._tableLayoutPanelMainTop.PerformLayout(); - this._flowLayoutPanelMultiScreenButtons.ResumeLayout(false); - this._flowLayoutPanelMultiScreenButtons.PerformLayout(); + this._flowLayoutPanelMultiScreenMode.ResumeLayout(false); + this._flowLayoutPanelMultiScreenMode.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -304,25 +332,26 @@ private void InitializeComponent() #endregion - private TableLayoutPanel _tableLayoutPanelMain; + private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMain; + + private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMainTop; + private System.Windows.Forms.Label _labelMultiScreen; + private System.Windows.Forms.RadioButton _radioButtonSpanScreens; + private System.Windows.Forms.RadioButton _radioButtonMirrorScreens; + private System.Windows.Forms.RadioButton _radioButtonSeparateScreens; + private System.Windows.Forms.ToolTip _toolTipScreenMode; + private System.Windows.Forms.CheckBox _checkBoxCloseOnMouseMovement; - private TableLayoutPanel _tableLayoutPanelMainTop; - private FlowLayoutPanel _flowLayoutPanelMultiScreenButtons; - private Label _labelMultiScreen; - private RadioButton _radioButtonSpanScreens; - private RadioButton _radioButtonMirrorScreens; - private RadioButton _radioButtonSeparateScreens; - private ToolTip _toolTipScreenMode; - private CheckBox _checkBoxCloseOnMouseMovement; + private System.Windows.Forms.Label _labelWebsiteURLs; + private System.Windows.Forms.TabControl _tabControlScreens; + private System.Windows.Forms.TabPage _tabPageScreen; - private Label _labelWebsiteURLs; - private TabControl _tabControlScreens; - private TabPage _tabPageScreen; + private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMainBottom; + private System.Windows.Forms.LinkLabel _linkLabelProjectURL; + private System.Windows.Forms.Button _buttonCancel; + private System.Windows.Forms.Button _buttonOK; + private System.Windows.Forms.FlowLayoutPanel _flowLayoutPanelMultiScreenMode; - private TableLayoutPanel _tableLayoutPanelMainBottom; - private LinkLabel _linkLabelProjectURL; - private Button _buttonCancel; - private Button _buttonOK; private System.ComponentModel.IContainer components; } } \ No newline at end of file diff --git a/PreferencesForm.cs b/PreferencesForm.cs index f0c3a2a..0ae5768 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; -using System.Linq; using System.Windows.Forms; namespace WebPageScreensaver @@ -16,63 +15,41 @@ public PreferencesForm() InitializeComponent(); } + /// + /// Method called when the form is loaded, so the UI gets updated with the registry data. + /// private void PreferencesForm_Load(object sender, EventArgs e) { - Fetch(); - } + _checkBoxCloseOnMouseMovement.Checked = Preferences.CloseOnMouseMovement; - private void anyMultiScreenModeButton_Click(object sender, EventArgs e) - { - Save(); - } + MultiScreenMode multiScreenMode = Preferences.MultiScreen; - /// - /// Opens the project website in a new default browser tab. - /// - private void LinkLabelProjectURL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - ProcessStartInfo startInfo = new ProcessStartInfo() - { - FileName = "cmd", - Arguments = $"/c start {Webpage}", - CreateNoWindow = true - }; - Process.Start(startInfo); - } + // The Checked event will determine what to show in the tabs + _radioButtonMirrorScreens.Checked = multiScreenMode == MultiScreenMode.Mirror; + _radioButtonSeparateScreens.Checked = multiScreenMode == MultiScreenMode.Separate; + _radioButtonSpanScreens.Checked = multiScreenMode == MultiScreenMode.Span; - /// - /// Saves the selected settings and closes the window. - /// - private void ButtonOK_Click(object sender, EventArgs e) - { - Save(); - Close(); + //_flowLayoutPanelMultiScreenMode.Enabled = Screen.AllScreens.Length > 1; } - /// - /// Closes the window without saving the settings. - /// - private void ButtonCancel_Click(object sender, EventArgs e) - { - Close(); - } - /// - /// Retrieve shared data and show it in the form. - /// - private void Fetch() + private void RadioButtonMultiScreenMode_Checked(object sender, EventArgs e) { - MultiScreenMode multiScreenMode = Preferences.MultiScreen; - - _checkBoxCloseOnMouseMovement.Checked = Preferences.CloseOnMouseMovement; - - _flowLayoutPanelMultiScreenButtons.Enabled = Screen.AllScreens.Length > 1; + if (!(sender is RadioButton radioButton) || !radioButton.Checked) + { + return; + } - _radioButtonMirrorScreens.Checked = multiScreenMode == MultiScreenMode.Mirror; - _radioButtonSeparateScreens.Checked = multiScreenMode == MultiScreenMode.Separate; - _radioButtonSpanScreens.Checked = multiScreenMode == MultiScreenMode.Span; + MultiScreenMode multiScreenMode = radioButton.Name switch + { + nameof(_radioButtonMirrorScreens) => MultiScreenMode.Mirror, + nameof(_radioButtonSeparateScreens) => MultiScreenMode.Separate, + nameof(_radioButtonSpanScreens) => MultiScreenMode.Span, + _ => throw new IndexOutOfRangeException("Unexpected radio button."), + }; - _tabControlScreens.TabPages.Clear(); + // Save it to the registry + Preferences.MultiScreen = multiScreenMode; int totalTabs = multiScreenMode switch { @@ -89,6 +66,7 @@ private void Fetch() _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.") }; + _tabControlScreens.TabPages.Clear(); for (int tabNumber = 0; tabNumber < totalTabs; tabNumber++) { @@ -123,6 +101,37 @@ private void Fetch() } } + /// + /// Opens the project website in a new default browser tab. + /// + private void LinkLabelProjectURL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + ProcessStartInfo startInfo = new ProcessStartInfo() + { + FileName = "cmd", + Arguments = $"/c start {Webpage}", + CreateNoWindow = true + }; + Process.Start(startInfo); + } + + /// + /// Saves the selected settings and closes the window. + /// + private void ButtonOK_Click(object sender, EventArgs e) + { + Save(); + Close(); + } + + /// + /// Closes the window without saving the settings. + /// + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } + /// /// Read the data from the form and save it in the registry. /// diff --git a/PreferencesForm.resx b/PreferencesForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/PreferencesForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index 875fc9b..9c8de31 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -49,9 +49,12 @@ private void InitializeComponent() // // _numericUpDownRotationInterval // - this._numericUpDownRotationInterval.Anchor = System.Windows.Forms.AnchorStyles.Right; - this._numericUpDownRotationInterval.Location = new System.Drawing.Point(284, 5); - this._numericUpDownRotationInterval.Margin = new System.Windows.Forms.Padding(4); + this._numericUpDownRotationInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._numericUpDownRotationInterval.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._numericUpDownRotationInterval.Location = new System.Drawing.Point(292, 6); + this._numericUpDownRotationInterval.Margin = new System.Windows.Forms.Padding(6); this._numericUpDownRotationInterval.Maximum = new decimal(new int[] { 999, 0, @@ -60,6 +63,7 @@ private void InitializeComponent() this._numericUpDownRotationInterval.Name = "_numericUpDownRotationInterval"; this._numericUpDownRotationInterval.Size = new System.Drawing.Size(80, 39); this._numericUpDownRotationInterval.TabIndex = 6; + this._numericUpDownRotationInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this._numericUpDownRotationInterval.Value = new decimal(new int[] { 30, 0, @@ -68,60 +72,77 @@ private void InitializeComponent() // // _labelSecondsToDisplay // - this._labelSecondsToDisplay.Anchor = System.Windows.Forms.AnchorStyles.Left; + this._labelSecondsToDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._labelSecondsToDisplay.AutoSize = true; - this._labelSecondsToDisplay.Location = new System.Drawing.Point(374, 9); - this._labelSecondsToDisplay.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this._labelSecondsToDisplay.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._labelSecondsToDisplay.Location = new System.Drawing.Point(384, 6); + this._labelSecondsToDisplay.Margin = new System.Windows.Forms.Padding(6); this._labelSecondsToDisplay.Name = "_labelSecondsToDisplay"; - this._labelSecondsToDisplay.Size = new System.Drawing.Size(314, 32); + this._labelSecondsToDisplay.Size = new System.Drawing.Size(314, 44); this._labelSecondsToDisplay.TabIndex = 7; this._labelSecondsToDisplay.Text = "Seconds to display each site"; - this._labelSecondsToDisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // _checkBoxShuffle // + this._checkBoxShuffle.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._checkBoxShuffle.AutoSize = true; - this._checkBoxShuffle.Dock = System.Windows.Forms.DockStyle.Left; - this._checkBoxShuffle.Location = new System.Drawing.Point(6, 7); - this._checkBoxShuffle.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); + this._checkBoxShuffle.CheckAlign = System.Drawing.ContentAlignment.TopLeft; + this._checkBoxShuffle.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._checkBoxShuffle.Location = new System.Drawing.Point(6, 6); + this._checkBoxShuffle.Margin = new System.Windows.Forms.Padding(6); this._checkBoxShuffle.Name = "_checkBoxShuffle"; - this._checkBoxShuffle.Size = new System.Drawing.Size(122, 36); + this._checkBoxShuffle.Size = new System.Drawing.Size(274, 44); this._checkBoxShuffle.TabIndex = 5; this._checkBoxShuffle.Text = "Shuffle"; + this._checkBoxShuffle.TextAlign = System.Drawing.ContentAlignment.TopLeft; this._checkBoxShuffle.UseVisualStyleBackColor = true; // // _listViewURLs // this._listViewURLs.Dock = System.Windows.Forms.DockStyle.Fill; + this._listViewURLs.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._listViewURLs.FullRowSelect = true; + this._listViewURLs.GridLines = true; this._listViewURLs.HideSelection = false; this._listViewURLs.LabelEdit = true; - this._listViewURLs.Location = new System.Drawing.Point(4, 73); - this._listViewURLs.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._listViewURLs.Location = new System.Drawing.Point(6, 62); + this._listViewURLs.Margin = new System.Windows.Forms.Padding(6); this._listViewURLs.Name = "_listViewURLs"; this._listViewURLs.Size = new System.Drawing.Size(692, 346); - this._listViewURLs.TabIndex = 0; + this._listViewURLs.TabIndex = 4; this._listViewURLs.UseCompatibleStateImageBehavior = false; this._listViewURLs.View = System.Windows.Forms.View.List; // // _buttonAddURL // - this._buttonAddURL.Location = new System.Drawing.Point(8, 8); - this._buttonAddURL.Margin = new System.Windows.Forms.Padding(4); + this._buttonAddURL.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._buttonAddURL.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonAddURL.Location = new System.Drawing.Point(6, 6); + this._buttonAddURL.Margin = new System.Windows.Forms.Padding(6); this._buttonAddURL.Name = "_buttonAddURL"; this._buttonAddURL.Size = new System.Drawing.Size(150, 44); - this._buttonAddURL.TabIndex = 11; + this._buttonAddURL.TabIndex = 0; this._buttonAddURL.Text = "Add URL"; this._buttonAddURL.UseVisualStyleBackColor = true; this._buttonAddURL.Click += new System.EventHandler(this.AddUrlButton_Click); // // _buttonUp // - this._buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this._buttonUp.Location = new System.Drawing.Point(588, 8); - this._buttonUp.Margin = new System.Windows.Forms.Padding(4); + this._buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._buttonUp.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonUp.Location = new System.Drawing.Point(598, 6); + this._buttonUp.Margin = new System.Windows.Forms.Padding(6); this._buttonUp.Name = "_buttonUp"; this._buttonUp.Size = new System.Drawing.Size(44, 44); - this._buttonUp.TabIndex = 3; + this._buttonUp.TabIndex = 2; this._buttonUp.Text = "▲"; this._toolTipURLButtons.SetToolTip(this._buttonUp, "Move selected URLs up"); this._buttonUp.UseVisualStyleBackColor = true; @@ -129,11 +150,15 @@ private void InitializeComponent() // // _buttonDown // - this._buttonDown.Location = new System.Drawing.Point(640, 8); - this._buttonDown.Margin = new System.Windows.Forms.Padding(4); + this._buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._buttonDown.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonDown.Location = new System.Drawing.Point(654, 6); + this._buttonDown.Margin = new System.Windows.Forms.Padding(6); this._buttonDown.Name = "_buttonDown"; this._buttonDown.Size = new System.Drawing.Size(44, 44); - this._buttonDown.TabIndex = 12; + this._buttonDown.TabIndex = 3; this._buttonDown.Text = "▼"; this._toolTipURLButtons.SetToolTip(this._buttonDown, "Move selected URLs down"); this._buttonDown.UseVisualStyleBackColor = true; @@ -141,12 +166,15 @@ private void InitializeComponent() // // _buttonDeleteURL // + this._buttonDeleteURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this._buttonDeleteURL.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this._buttonDeleteURL.ForeColor = System.Drawing.Color.Black; - this._buttonDeleteURL.Location = new System.Drawing.Point(166, 8); - this._buttonDeleteURL.Margin = new System.Windows.Forms.Padding(4); + this._buttonDeleteURL.Location = new System.Drawing.Point(168, 6); + this._buttonDeleteURL.Margin = new System.Windows.Forms.Padding(6); this._buttonDeleteURL.Name = "_buttonDeleteURL"; this._buttonDeleteURL.Size = new System.Drawing.Size(150, 44); - this._buttonDeleteURL.TabIndex = 13; + this._buttonDeleteURL.TabIndex = 1; this._buttonDeleteURL.Text = "Delete URL"; this._toolTipURLButtons.SetToolTip(this._buttonDeleteURL, "DELETE selected URLs"); this._buttonDeleteURL.UseVisualStyleBackColor = true; @@ -155,6 +183,7 @@ private void InitializeComponent() // _tableLayoutPanelMain // this._tableLayoutPanelMain.AutoSize = true; + this._tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMain.ColumnCount = 1; this._tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainTop, 0, 0); @@ -162,41 +191,41 @@ private void InitializeComponent() this._tableLayoutPanelMain.Controls.Add(this._tableLayoutPanelMainBottom, 0, 2); this._tableLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill; this._tableLayoutPanelMain.Location = new System.Drawing.Point(0, 0); + this._tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; this._tableLayoutPanelMain.RowCount = 3; - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 68F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 56F)); this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 56F)); - this._tableLayoutPanelMain.Size = new System.Drawing.Size(700, 480); + this._tableLayoutPanelMain.Size = new System.Drawing.Size(704, 470); this._tableLayoutPanelMain.TabIndex = 14; // // _tableLayoutPanelMainTop // - this._tableLayoutPanelMainTop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._tableLayoutPanelMainTop.AutoSize = true; + this._tableLayoutPanelMainTop.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainTop.ColumnCount = 4; - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 158F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 162F)); this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 52F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 52F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 56F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 56F)); this._tableLayoutPanelMainTop.Controls.Add(this._buttonAddURL, 0, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonDown, 3, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonUp, 2, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonDeleteURL, 1, 0); - this._tableLayoutPanelMainTop.Location = new System.Drawing.Point(4, 4); - this._tableLayoutPanelMainTop.Margin = new System.Windows.Forms.Padding(4); + this._tableLayoutPanelMainTop.Dock = System.Windows.Forms.DockStyle.Fill; + this._tableLayoutPanelMainTop.Location = new System.Drawing.Point(0, 0); + this._tableLayoutPanelMainTop.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; - this._tableLayoutPanelMainTop.Padding = new System.Windows.Forms.Padding(4); this._tableLayoutPanelMainTop.RowCount = 1; this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(692, 60); + this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(704, 56); this._tableLayoutPanelMainTop.TabIndex = 0; // // _tableLayoutPanelMainBottom // this._tableLayoutPanelMainBottom.AutoSize = true; + this._tableLayoutPanelMainBottom.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainBottom.ColumnCount = 3; this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this._tableLayoutPanelMainBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); @@ -205,22 +234,23 @@ private void InitializeComponent() this._tableLayoutPanelMainBottom.Controls.Add(this._labelSecondsToDisplay, 2, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._numericUpDownRotationInterval, 1, 0); this._tableLayoutPanelMainBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(3, 427); + this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(0, 414); + this._tableLayoutPanelMainBottom.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; this._tableLayoutPanelMainBottom.RowCount = 1; this._tableLayoutPanelMainBottom.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(694, 50); + this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(704, 56); this._tableLayoutPanelMainBottom.TabIndex = 1; // // PrefsByScreenUserControl // this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.BackColor = System.Drawing.Color.White; this.Controls.Add(this._tableLayoutPanelMain); - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.MinimumSize = new System.Drawing.Size(640, 480); + this.Margin = new System.Windows.Forms.Padding(0); this.Name = "PrefsByScreenUserControl"; - this.Size = new System.Drawing.Size(700, 480); + this.Size = new System.Drawing.Size(704, 470); ((System.ComponentModel.ISupportInitialize)(this._numericUpDownRotationInterval)).EndInit(); this._tableLayoutPanelMain.ResumeLayout(false); this._tableLayoutPanelMain.PerformLayout(); diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index ce5657c..538804e 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Windows.Forms; diff --git a/Program.cs b/Program.cs index 5c0d012..e2c48d6 100644 --- a/Program.cs +++ b/Program.cs @@ -20,48 +20,43 @@ static void Main(string[] args) throw new NullReferenceException("Current process main module is null."); } - Application.SetHighDpiMode(HighDpiMode.DpiUnawareGdiScaled); + Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); // Helps respect the specified window sizes Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + Application.SetCompatibleTextRenderingDefault(true); // Prevents seeing tiny unexpected fonts // Argument verification - More than 1 argument, or passing // the wrong argument, will silently exit the program - // No arguments means preview the screensaver (cursor enabled) + // No arguments is interpreted as "/P" or "/S" if (args.Length == 0) { - ShowScreenSaver(showCursor: true); + ShowScreenSaver(); } else if(args.Length == 1) { switch (args[0].ToUpperInvariant()) { - case "/C": + case "/C": // Configure Application.Run(new PreferencesForm()); break; - case "/P": - ShowScreenSaver(showCursor: true); - break; - case "/S": - ShowScreenSaver(showCursor: false); + case "/P": // Preview + case "/S": // Show + ShowScreenSaver(); break; } } } /// - /// Shows the screensaver form in all the screens, and allows specifying if the - /// cursor should be shown. + /// Shows the screensaver form in all the screens. /// - /// if the cursor should be shown - /// (for preview mode); otherwise (for show mode). - private static void ShowScreenSaver(bool showCursor) + private static void ShowScreenSaver() { var forms = new List(); foreach (KeyValuePair kvp in Preferences.Screens) { - var form = new ScreensaverForm(kvp.Value, showCursor); + var form = new ScreensaverForm(kvp.Value); forms.Add(form); } diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 87a61df..0a634ee 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "WebPageScreensaver": { "commandName": "Project", - "commandLineArgs": "/c" + "commandLineArgs": "" } } } \ No newline at end of file diff --git a/ScreensaverForm.Designer.cs b/ScreensaverForm.Designer.cs index fe20c43..b365e90 100644 --- a/ScreensaverForm.Designer.cs +++ b/ScreensaverForm.Designer.cs @@ -29,64 +29,41 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this._webBrowser = new Microsoft.Web.WebView2.WinForms.WebView2(); - this._closeButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // webBrowser + // _webBrowser // this._webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; - this._webBrowser.Location = new System.Drawing.Point(0, 0); + this._webBrowser.Location = _savedLocation; this._webBrowser.Margin = new System.Windows.Forms.Padding(4); - this._webBrowser.MinimumSize = new System.Drawing.Size(44, 50); - this._webBrowser.Name = "webBrowser"; - this._webBrowser.Size = new System.Drawing.Size(616, 644); + this._webBrowser.Name = "_webBrowser"; + this._webBrowser.Size = _savedSize; this._webBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); this._webBrowser.TabIndex = 0; + this._webBrowser.TabStop = false; this._webBrowser.ZoomFactor = 1D; // - // closeButton - // - this._closeButton.AutoSize = true; - this._closeButton.BackColor = System.Drawing.Color.Transparent; - this._closeButton.FlatAppearance.BorderColor = System.Drawing.Color.White; - this._closeButton.FlatAppearance.BorderSize = 0; - this._closeButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this._closeButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this._closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this._closeButton.ForeColor = System.Drawing.Color.Transparent; - this._closeButton.Location = new System.Drawing.Point(516, 0); - this._closeButton.Margin = new System.Windows.Forms.Padding(4); - this._closeButton.Name = "closeButton"; - this._closeButton.Size = new System.Drawing.Size(100, 100); - this._closeButton.TabIndex = 1; - this._closeButton.Text = "X"; - this._closeButton.UseVisualStyleBackColor = false; - this._closeButton.Visible = false; - this._closeButton.Click += new System.EventHandler(this.CloseButton_Click); - // // ScreensaverForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(616, 644); - this.Controls.Add(this._closeButton); + this.ClientSize = _savedSize; this.Controls.Add(this._webBrowser); this.ForeColor = System.Drawing.Color.White; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.Margin = new System.Windows.Forms.Padding(4); + this.Location = _savedLocation; + this.Margin = new System.Windows.Forms.Padding(0); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ScreensaverForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Load += new System.EventHandler(this.ScreensaverForm_Load); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.WebBrowser_MouseMove); this.ResumeLayout(false); - this.PerformLayout(); } #endregion private Microsoft.Web.WebView2.WinForms.WebView2 _webBrowser; - private System.Windows.Forms.Button _closeButton; } } diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index 52aba8a..38a3492 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -11,36 +11,28 @@ internal partial class ScreensaverForm : Form { private int _currentURLIndex; - private readonly DateTime _startTime; private readonly Timer _timer; - private readonly MouseEventHandler _mouseEventHandler; private readonly bool _closeOnMouseMovement; private readonly int _rotationInterval; private readonly bool _shuffle; private readonly List _urls; + private readonly Size _savedSize; + private readonly Point _savedLocation; - public ScreensaverForm(ScreenInformation screen, bool showCursor) + public ScreensaverForm(ScreenInformation screen) { - _mouseEventHandler = new MouseEventHandler(); - _mouseEventHandler.Event += new MouseEventHandler.UserEvent(HandleUserActivity); - _closeOnMouseMovement = Preferences.CloseOnMouseMovement; _rotationInterval = screen.RotationInterval; _shuffle = screen.Shuffle; _urls = screen.URLs.ToList(); _currentURLIndex = 0; - Location = new Point(screen.Bounds.Left, screen.Bounds.Top); - Size = new Size(screen.Bounds.Width, screen.Bounds.Height); + _savedSize = new Size(screen.Bounds.Width, screen.Bounds.Height); + _savedLocation = new Point(screen.Bounds.Left, screen.Bounds.Top); + Cursor.Hide(); InitializeComponent(); - if (!showCursor) - { - Cursor.Hide(); - } - - _startTime = DateTime.Now; _timer = new Timer(); } @@ -90,43 +82,29 @@ private void RotateSite() private void BrowseTo(string url) { - // Disable the user event handler while navigating - Application.RemoveMessageFilter(_mouseEventHandler); - - if (string.IsNullOrWhiteSpace(url)) - { - _webBrowser.Visible = false; - } - else - { - _webBrowser.Visible = true; - _webBrowser.CoreWebView2.Navigate(url); - } - - Application.AddMessageFilter(_mouseEventHandler); + _webBrowser.Visible = true; + _webBrowser.CoreWebView2.Navigate(url); } - private void HandleUserActivity() + private void WebBrowser_MouseMove(object sender, MouseEventArgs e) { - if (_startTime.AddSeconds(1) > DateTime.Now) - { - return; - } - if (_closeOnMouseMovement) { Close(); } - else - { - _closeButton.Visible = true; - Cursor.Show(); - } } - private void CloseButton_Click(object sender, EventArgs e) + /// + /// Allows capturing the ESC key to close the form. + /// + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { - Close(); + if (keyData == Keys.Escape) + { + this.Close(); + return true; + } + return base.ProcessCmdKey(ref msg, keyData); } } } \ No newline at end of file diff --git a/ScreensaverForm.resx b/ScreensaverForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ScreensaverForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From aa1c057febd6dfcc8d07614cb89239997a1a225f Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 18:34:14 -0700 Subject: [PATCH 28/45] Address .NET 5.0 RC1 warnings --- Extensions.cs | 2 +- PreferencesForm.cs | 8 +-- PreferencesForm.resx | 120 ------------------------------------------- Program.cs | 2 + ScreensaverForm.cs | 1 - ScreensaverForm.resx | 60 ---------------------- 6 files changed, 8 insertions(+), 185 deletions(-) delete mode 100644 PreferencesForm.resx delete mode 100644 ScreensaverForm.resx diff --git a/Extensions.cs b/Extensions.cs index 4a7ff39..411b4ae 100644 --- a/Extensions.cs +++ b/Extensions.cs @@ -13,7 +13,7 @@ public static RegistryKey GetOrCreateSubKey(this RegistryKey root, string subKey } if (string.IsNullOrWhiteSpace(subKeyName)) { - throw new ArgumentException(nameof(subKeyName)); + throw new ArgumentException($"Argument is null or whitespace: {nameof(subKeyName)}"); } RegistryKey? key = root.OpenSubKey(subKeyName, writable: true); diff --git a/PreferencesForm.cs b/PreferencesForm.cs index 0ae5768..31aba4e 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -35,7 +35,7 @@ private void PreferencesForm_Load(object sender, EventArgs e) private void RadioButtonMultiScreenMode_Checked(object sender, EventArgs e) { - if (!(sender is RadioButton radioButton) || !radioButton.Checked) + if (sender is not RadioButton radioButton || !radioButton.Checked) { return; } @@ -70,8 +70,10 @@ private void RadioButtonMultiScreenMode_Checked(object sender, EventArgs e) for (int tabNumber = 0; tabNumber < totalTabs; tabNumber++) { - TabPage tab = new TabPage(); - tab.Text = $"Display {tabNumber + 1}{tabTextSuffix}"; // Matches registry key name + TabPage tab = new TabPage + { + Text = $"Display {tabNumber + 1}{tabTextSuffix}" // Matches registry key name + }; var currentUserControl = new PrefsByScreenUserControl { diff --git a/PreferencesForm.resx b/PreferencesForm.resx deleted file mode 100644 index 1af7de1..0000000 --- a/PreferencesForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Program.cs b/Program.cs index e2c48d6..de0a74e 100644 --- a/Program.cs +++ b/Program.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Runtime.Versioning; using System.Windows.Forms; +[assembly: SupportedOSPlatform("windows")] namespace WebPageScreensaver { static class Program diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index 38a3492..ed6a320 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; using System.Linq; using System.Windows.Forms; diff --git a/ScreensaverForm.resx b/ScreensaverForm.resx deleted file mode 100644 index f298a7b..0000000 --- a/ScreensaverForm.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file From eff169180bce6deb219556325ea5e0fd85b40a1d Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 19:30:38 -0700 Subject: [PATCH 29/45] Fix tabIndex and address sizes in a screen with 100% DPI. --- PreferencesForm.Designer.cs | 143 +++++++++++---------------- PreferencesForm.cs | 6 +- PrefsByScreenUserControl.Designer.cs | 134 +++++++++++-------------- 3 files changed, 119 insertions(+), 164 deletions(-) diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 351113d..440fdea 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -58,12 +58,12 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._linkLabelProjectURL.AutoSize = true; - this._linkLabelProjectURL.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._linkLabelProjectURL.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this._linkLabelProjectURL.Location = new System.Drawing.Point(6, 0); this._linkLabelProjectURL.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this._linkLabelProjectURL.Name = "_linkLabelProjectURL"; - this._linkLabelProjectURL.Size = new System.Drawing.Size(662, 65); - this._linkLabelProjectURL.TabIndex = 7; + this._linkLabelProjectURL.Size = new System.Drawing.Size(278, 35); + this._linkLabelProjectURL.TabIndex = 13; this._linkLabelProjectURL.TabStop = true; this._linkLabelProjectURL.Text = "Website"; this._linkLabelProjectURL.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -73,54 +73,44 @@ private void InitializeComponent() // this._tabControlScreens.Controls.Add(this._tabPageScreen); this._tabControlScreens.Dock = System.Windows.Forms.DockStyle.Fill; - this._tabControlScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._tabControlScreens.Location = new System.Drawing.Point(0, 181); + this._tabControlScreens.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._tabControlScreens.Location = new System.Drawing.Point(0, 105); this._tabControlScreens.Margin = new System.Windows.Forms.Padding(0); this._tabControlScreens.Name = "_tabControlScreens"; this._tabControlScreens.SelectedIndex = 0; - this._tabControlScreens.Size = new System.Drawing.Size(998, 451); - this._tabControlScreens.TabIndex = 6; + this._tabControlScreens.Size = new System.Drawing.Size(464, 221); // // _tabPageScreen // - this._tabPageScreen.Location = new System.Drawing.Point(8, 46); - this._tabPageScreen.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this._tabPageScreen.Location = new System.Drawing.Point(4, 24); + this._tabPageScreen.Margin = new System.Windows.Forms.Padding(6); this._tabPageScreen.Name = "_tabPageScreen"; - this._tabPageScreen.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this._tabPageScreen.Size = new System.Drawing.Size(982, 397); - this._tabPageScreen.TabIndex = 0; - this._tabPageScreen.Text = "Screen 1"; + this._tabPageScreen.Size = new System.Drawing.Size(456, 193); + this._tabPageScreen.TabIndex = 5; this._tabPageScreen.UseVisualStyleBackColor = true; // // _labelWebsiteURLs // - this._labelWebsiteURLs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._labelWebsiteURLs.AutoSize = true; - this._labelWebsiteURLs.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._labelWebsiteURLs.Location = new System.Drawing.Point(6, 122); + this._labelWebsiteURLs.Dock = System.Windows.Forms.DockStyle.Fill; + this._labelWebsiteURLs.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._labelWebsiteURLs.Location = new System.Drawing.Point(6, 76); this._labelWebsiteURLs.Margin = new System.Windows.Forms.Padding(6); this._labelWebsiteURLs.Name = "_labelWebsiteURLs"; - this._labelWebsiteURLs.Size = new System.Drawing.Size(986, 53); - this._labelWebsiteURLs.TabIndex = 5; + this._labelWebsiteURLs.Size = new System.Drawing.Size(452, 23); this._labelWebsiteURLs.Text = "Website URLs:"; this._labelWebsiteURLs.TextAlign = System.Drawing.ContentAlignment.BottomLeft; // // _radioButtonSeparateScreens // - this._radioButtonSeparateScreens.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._radioButtonSeparateScreens.AutoSize = true; - this._radioButtonSeparateScreens.Checked = true; - this._radioButtonSeparateScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._radioButtonSeparateScreens.Dock = System.Windows.Forms.DockStyle.Fill; + this._radioButtonSeparateScreens.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this._radioButtonSeparateScreens.Location = new System.Drawing.Point(6, 6); this._radioButtonSeparateScreens.Margin = new System.Windows.Forms.Padding(6); this._radioButtonSeparateScreens.Name = "_radioButtonSeparateScreens"; - this._radioButtonSeparateScreens.Size = new System.Drawing.Size(138, 36); - this._radioButtonSeparateScreens.TabIndex = 1; - this._radioButtonSeparateScreens.TabStop = true; + this._radioButtonSeparateScreens.Size = new System.Drawing.Size(70, 19); + this._radioButtonSeparateScreens.TabIndex = 2; this._radioButtonSeparateScreens.Tag = "MultiScreenMode"; this._radioButtonSeparateScreens.Text = "Separate"; this._toolTipScreenMode.SetToolTip(this._radioButtonSeparateScreens, "Each to their own!"); @@ -129,17 +119,14 @@ private void InitializeComponent() // // _radioButtonMirrorScreens // - this._radioButtonMirrorScreens.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._radioButtonMirrorScreens.AutoSize = true; - this._radioButtonMirrorScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._radioButtonMirrorScreens.Location = new System.Drawing.Point(156, 6); + this._radioButtonMirrorScreens.Dock = System.Windows.Forms.DockStyle.Fill; + this._radioButtonMirrorScreens.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._radioButtonMirrorScreens.Location = new System.Drawing.Point(88, 6); this._radioButtonMirrorScreens.Margin = new System.Windows.Forms.Padding(6); this._radioButtonMirrorScreens.Name = "_radioButtonMirrorScreens"; - this._radioButtonMirrorScreens.Size = new System.Drawing.Size(111, 36); - this._radioButtonMirrorScreens.TabIndex = 2; - this._radioButtonMirrorScreens.TabStop = true; + this._radioButtonMirrorScreens.Size = new System.Drawing.Size(58, 19); + this._radioButtonMirrorScreens.TabIndex = 3; this._radioButtonMirrorScreens.Tag = "MultiScreenMode"; this._radioButtonMirrorScreens.Text = "Mirror"; this._toolTipScreenMode.SetToolTip(this._radioButtonMirrorScreens, "One for All!"); @@ -148,17 +135,14 @@ private void InitializeComponent() // // _radioButtonSpanScreens // - this._radioButtonSpanScreens.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._radioButtonSpanScreens.AutoSize = true; - this._radioButtonSpanScreens.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._radioButtonSpanScreens.Location = new System.Drawing.Point(279, 6); + this._radioButtonSpanScreens.Dock = System.Windows.Forms.DockStyle.Fill; + this._radioButtonSpanScreens.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._radioButtonSpanScreens.Location = new System.Drawing.Point(158, 6); this._radioButtonSpanScreens.Margin = new System.Windows.Forms.Padding(6); this._radioButtonSpanScreens.Name = "_radioButtonSpanScreens"; - this._radioButtonSpanScreens.Size = new System.Drawing.Size(98, 36); - this._radioButtonSpanScreens.TabIndex = 3; - this._radioButtonSpanScreens.TabStop = true; + this._radioButtonSpanScreens.Size = new System.Drawing.Size(51, 19); + this._radioButtonSpanScreens.TabIndex = 4; this._radioButtonSpanScreens.Tag = "MultiScreenMode"; this._radioButtonSpanScreens.Text = "Span"; this._toolTipScreenMode.SetToolTip(this._radioButtonSpanScreens, "All for One!"); @@ -180,13 +164,11 @@ private void InitializeComponent() this._tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; this._tableLayoutPanelMain.RowCount = 4; - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 116F)); - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 65F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 70F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 65F)); - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this._tableLayoutPanelMain.Size = new System.Drawing.Size(998, 697); - this._tableLayoutPanelMain.TabIndex = 19; + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); + this._tableLayoutPanelMain.Size = new System.Drawing.Size(464, 361); // // _tableLayoutPanelMainBottom // @@ -200,24 +182,23 @@ private void InitializeComponent() this._tableLayoutPanelMainBottom.Controls.Add(this._linkLabelProjectURL, 0, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._buttonOK, 1, 0); this._tableLayoutPanelMainBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(0, 632); + this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(0, 326); this._tableLayoutPanelMainBottom.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; this._tableLayoutPanelMainBottom.RowCount = 1; this._tableLayoutPanelMainBottom.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(998, 65); - this._tableLayoutPanelMainBottom.TabIndex = 0; + this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(464, 35); // // _buttonCancel // this._buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.None; this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this._buttonCancel.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._buttonCancel.Location = new System.Drawing.Point(842, 10); + this._buttonCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._buttonCancel.Location = new System.Drawing.Point(383, 6); this._buttonCancel.Margin = new System.Windows.Forms.Padding(6); this._buttonCancel.Name = "_buttonCancel"; - this._buttonCancel.Size = new System.Drawing.Size(150, 44); - this._buttonCancel.TabIndex = 9; + this._buttonCancel.Size = new System.Drawing.Size(75, 23); + this._buttonCancel.TabIndex = 15; this._buttonCancel.Text = "Cancel"; this._buttonCancel.UseVisualStyleBackColor = true; this._buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); @@ -226,12 +207,12 @@ private void InitializeComponent() // this._buttonOK.Anchor = System.Windows.Forms.AnchorStyles.None; this._buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this._buttonOK.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._buttonOK.Location = new System.Drawing.Point(680, 10); + this._buttonOK.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._buttonOK.Location = new System.Drawing.Point(296, 6); this._buttonOK.Margin = new System.Windows.Forms.Padding(6); this._buttonOK.Name = "_buttonOK"; - this._buttonOK.Size = new System.Drawing.Size(150, 44); - this._buttonOK.TabIndex = 8; + this._buttonOK.Size = new System.Drawing.Size(75, 23); + this._buttonOK.TabIndex = 14; this._buttonOK.Text = "OK"; this._buttonOK.UseVisualStyleBackColor = true; this._buttonOK.Click += new System.EventHandler(this.ButtonOK_Click); @@ -241,8 +222,8 @@ private void InitializeComponent() this._tableLayoutPanelMainTop.AutoSize = true; this._tableLayoutPanelMainTop.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainTop.ColumnCount = 2; - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this._tableLayoutPanelMainTop.Controls.Add(this._checkBoxCloseOnMouseMovement, 0, 0); this._tableLayoutPanelMainTop.Controls.Add(this._labelMultiScreen, 1, 0); this._tableLayoutPanelMainTop.Controls.Add(this._flowLayoutPanelMultiScreenMode, 1, 1); @@ -253,60 +234,54 @@ private void InitializeComponent() this._tableLayoutPanelMainTop.RowCount = 2; this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle()); this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(998, 116); - this._tableLayoutPanelMainTop.TabIndex = 1; + this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(464, 70); // // _checkBoxCloseOnMouseMovement // - this._checkBoxCloseOnMouseMovement.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._checkBoxCloseOnMouseMovement.AutoSize = true; this._checkBoxCloseOnMouseMovement.Checked = true; this._checkBoxCloseOnMouseMovement.CheckState = System.Windows.Forms.CheckState.Checked; - this._checkBoxCloseOnMouseMovement.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._checkBoxCloseOnMouseMovement.Dock = System.Windows.Forms.DockStyle.Fill; + this._checkBoxCloseOnMouseMovement.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this._checkBoxCloseOnMouseMovement.Location = new System.Drawing.Point(6, 6); this._checkBoxCloseOnMouseMovement.Margin = new System.Windows.Forms.Padding(6); this._checkBoxCloseOnMouseMovement.Name = "_checkBoxCloseOnMouseMovement"; - this._checkBoxCloseOnMouseMovement.Size = new System.Drawing.Size(487, 36); - this._checkBoxCloseOnMouseMovement.TabIndex = 4; + this._checkBoxCloseOnMouseMovement.Size = new System.Drawing.Size(172, 19); + this._checkBoxCloseOnMouseMovement.TabIndex = 1; this._checkBoxCloseOnMouseMovement.Text = "Close on mouse movement"; this._checkBoxCloseOnMouseMovement.UseVisualStyleBackColor = true; // // _labelMultiScreen // - this._labelMultiScreen.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this._labelMultiScreen.AutoSize = true; - this._labelMultiScreen.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._labelMultiScreen.Location = new System.Drawing.Point(505, 6); + this._labelMultiScreen.Dock = System.Windows.Forms.DockStyle.Fill; + this._labelMultiScreen.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._labelMultiScreen.Location = new System.Drawing.Point(190, 6); this._labelMultiScreen.Margin = new System.Windows.Forms.Padding(6); this._labelMultiScreen.Name = "_labelMultiScreen"; - this._labelMultiScreen.Size = new System.Drawing.Size(487, 36); - this._labelMultiScreen.TabIndex = 0; + this._labelMultiScreen.Size = new System.Drawing.Size(268, 19); this._labelMultiScreen.Text = "Multiscreen:"; this._labelMultiScreen.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // _flowLayoutPanelMultiScreenMode // + this._flowLayoutPanelMultiScreenMode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._flowLayoutPanelMultiScreenMode.AutoSize = true; this._flowLayoutPanelMultiScreenMode.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._flowLayoutPanelMultiScreenMode.Controls.Add(this._radioButtonSeparateScreens); this._flowLayoutPanelMultiScreenMode.Controls.Add(this._radioButtonMirrorScreens); this._flowLayoutPanelMultiScreenMode.Controls.Add(this._radioButtonSpanScreens); - this._flowLayoutPanelMultiScreenMode.Dock = System.Windows.Forms.DockStyle.Fill; - this._flowLayoutPanelMultiScreenMode.Location = new System.Drawing.Point(502, 51); + this._flowLayoutPanelMultiScreenMode.Location = new System.Drawing.Point(187, 34); this._flowLayoutPanelMultiScreenMode.Name = "_flowLayoutPanelMultiScreenMode"; - this._flowLayoutPanelMultiScreenMode.Size = new System.Drawing.Size(493, 62); - this._flowLayoutPanelMultiScreenMode.TabIndex = 20; + this._flowLayoutPanelMultiScreenMode.Size = new System.Drawing.Size(274, 33); // // PreferencesForm // this.AutoSize = true; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.ClientSize = new System.Drawing.Size(998, 697); + this.ClientSize = new System.Drawing.Size(464, 361); this.Controls.Add(this._tableLayoutPanelMain); this.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); this.MaximizeBox = false; diff --git a/PreferencesForm.cs b/PreferencesForm.cs index 31aba4e..1ca3c0f 100644 --- a/PreferencesForm.cs +++ b/PreferencesForm.cs @@ -80,12 +80,8 @@ private void RadioButtonMultiScreenMode_Checked(object sender, EventArgs e) AutoSize = true, BackColor = Color.White, Dock = DockStyle.Fill, - Location = new Point(4, 5), - Margin = new Padding(0), - MinimumSize = new Size(640, 300), Name = $"_prefsByScreenUserControl{tabNumber}", - Size = new Size(640, 300), - TabIndex = 25 + TabIndex = 5 }; ScreenInformation currentScreen = Preferences.Screens[tabNumber]; diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index 9c8de31..7a64dc7 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -36,8 +36,8 @@ private void InitializeComponent() this._buttonAddURL = new System.Windows.Forms.Button(); this._buttonUp = new System.Windows.Forms.Button(); this._toolTipURLButtons = new System.Windows.Forms.ToolTip(this.components); - this._buttonDown = new System.Windows.Forms.Button(); this._buttonDeleteURL = new System.Windows.Forms.Button(); + this._buttonDown = new System.Windows.Forms.Button(); this._tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel(); this._tableLayoutPanelMainTop = new System.Windows.Forms.TableLayoutPanel(); this._tableLayoutPanelMainBottom = new System.Windows.Forms.TableLayoutPanel(); @@ -49,11 +49,9 @@ private void InitializeComponent() // // _numericUpDownRotationInterval // - this._numericUpDownRotationInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this._numericUpDownRotationInterval.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._numericUpDownRotationInterval.Location = new System.Drawing.Point(292, 6); + this._numericUpDownRotationInterval.Anchor = System.Windows.Forms.AnchorStyles.Right; + this._numericUpDownRotationInterval.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._numericUpDownRotationInterval.Location = new System.Drawing.Point(98, 6); this._numericUpDownRotationInterval.Margin = new System.Windows.Forms.Padding(6); this._numericUpDownRotationInterval.Maximum = new decimal(new int[] { 999, @@ -61,8 +59,8 @@ private void InitializeComponent() 0, 0}); this._numericUpDownRotationInterval.Name = "_numericUpDownRotationInterval"; - this._numericUpDownRotationInterval.Size = new System.Drawing.Size(80, 39); - this._numericUpDownRotationInterval.TabIndex = 6; + this._numericUpDownRotationInterval.Size = new System.Drawing.Size(50, 23); + this._numericUpDownRotationInterval.TabIndex = 12; this._numericUpDownRotationInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this._numericUpDownRotationInterval.Value = new decimal(new int[] { 30, @@ -72,31 +70,26 @@ private void InitializeComponent() // // _labelSecondsToDisplay // - this._labelSecondsToDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this._labelSecondsToDisplay.Anchor = System.Windows.Forms.AnchorStyles.Left; this._labelSecondsToDisplay.AutoSize = true; - this._labelSecondsToDisplay.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._labelSecondsToDisplay.Location = new System.Drawing.Point(384, 6); + this._labelSecondsToDisplay.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._labelSecondsToDisplay.Location = new System.Drawing.Point(160, 10); this._labelSecondsToDisplay.Margin = new System.Windows.Forms.Padding(6); this._labelSecondsToDisplay.Name = "_labelSecondsToDisplay"; - this._labelSecondsToDisplay.Size = new System.Drawing.Size(314, 44); - this._labelSecondsToDisplay.TabIndex = 7; + this._labelSecondsToDisplay.Size = new System.Drawing.Size(154, 15); this._labelSecondsToDisplay.Text = "Seconds to display each site"; // // _checkBoxShuffle // - this._checkBoxShuffle.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this._checkBoxShuffle.Anchor = System.Windows.Forms.AnchorStyles.Left; this._checkBoxShuffle.AutoSize = true; this._checkBoxShuffle.CheckAlign = System.Drawing.ContentAlignment.TopLeft; - this._checkBoxShuffle.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._checkBoxShuffle.Location = new System.Drawing.Point(6, 6); + this._checkBoxShuffle.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._checkBoxShuffle.Location = new System.Drawing.Point(6, 8); this._checkBoxShuffle.Margin = new System.Windows.Forms.Padding(6); this._checkBoxShuffle.Name = "_checkBoxShuffle"; - this._checkBoxShuffle.Size = new System.Drawing.Size(274, 44); - this._checkBoxShuffle.TabIndex = 5; + this._checkBoxShuffle.Size = new System.Drawing.Size(63, 19); + this._checkBoxShuffle.TabIndex = 11; this._checkBoxShuffle.Text = "Shuffle"; this._checkBoxShuffle.TextAlign = System.Drawing.ContentAlignment.TopLeft; this._checkBoxShuffle.UseVisualStyleBackColor = true; @@ -104,82 +97,75 @@ private void InitializeComponent() // _listViewURLs // this._listViewURLs.Dock = System.Windows.Forms.DockStyle.Fill; - this._listViewURLs.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._listViewURLs.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this._listViewURLs.FullRowSelect = true; this._listViewURLs.GridLines = true; this._listViewURLs.HideSelection = false; this._listViewURLs.LabelEdit = true; - this._listViewURLs.Location = new System.Drawing.Point(6, 62); + this._listViewURLs.Location = new System.Drawing.Point(6, 41); this._listViewURLs.Margin = new System.Windows.Forms.Padding(6); this._listViewURLs.Name = "_listViewURLs"; - this._listViewURLs.Size = new System.Drawing.Size(692, 346); - this._listViewURLs.TabIndex = 4; + this._listViewURLs.Size = new System.Drawing.Size(308, 78); + this._listViewURLs.TabIndex = 10; this._listViewURLs.UseCompatibleStateImageBehavior = false; this._listViewURLs.View = System.Windows.Forms.View.List; // // _buttonAddURL // - this._buttonAddURL.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this._buttonAddURL.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonAddURL.Anchor = System.Windows.Forms.AnchorStyles.Right; + this._buttonAddURL.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this._buttonAddURL.Location = new System.Drawing.Point(6, 6); this._buttonAddURL.Margin = new System.Windows.Forms.Padding(6); this._buttonAddURL.Name = "_buttonAddURL"; - this._buttonAddURL.Size = new System.Drawing.Size(150, 44); - this._buttonAddURL.TabIndex = 0; + this._buttonAddURL.Size = new System.Drawing.Size(75, 23); + this._buttonAddURL.TabIndex = 6; this._buttonAddURL.Text = "Add URL"; this._buttonAddURL.UseVisualStyleBackColor = true; this._buttonAddURL.Click += new System.EventHandler(this.AddUrlButton_Click); // // _buttonUp // - this._buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this._buttonUp.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._buttonUp.Location = new System.Drawing.Point(598, 6); + this._buttonUp.Anchor = System.Windows.Forms.AnchorStyles.Right; + this._buttonUp.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._buttonUp.Location = new System.Drawing.Point(256, 6); this._buttonUp.Margin = new System.Windows.Forms.Padding(6); this._buttonUp.Name = "_buttonUp"; - this._buttonUp.Size = new System.Drawing.Size(44, 44); - this._buttonUp.TabIndex = 2; + this._buttonUp.Size = new System.Drawing.Size(23, 23); + this._buttonUp.TabIndex = 8; this._buttonUp.Text = "▲"; this._toolTipURLButtons.SetToolTip(this._buttonUp, "Move selected URLs up"); this._buttonUp.UseVisualStyleBackColor = true; this._buttonUp.Click += new System.EventHandler(this.MoveAllSelectedUrlsUp_Click); // - // _buttonDown - // - this._buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this._buttonDown.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this._buttonDown.Location = new System.Drawing.Point(654, 6); - this._buttonDown.Margin = new System.Windows.Forms.Padding(6); - this._buttonDown.Name = "_buttonDown"; - this._buttonDown.Size = new System.Drawing.Size(44, 44); - this._buttonDown.TabIndex = 3; - this._buttonDown.Text = "▼"; - this._toolTipURLButtons.SetToolTip(this._buttonDown, "Move selected URLs down"); - this._buttonDown.UseVisualStyleBackColor = true; - this._buttonDown.Click += new System.EventHandler(this.MoveAllSelectedUrlsDown_Click); - // // _buttonDeleteURL // - this._buttonDeleteURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this._buttonDeleteURL.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this._buttonDeleteURL.Anchor = System.Windows.Forms.AnchorStyles.Left; + this._buttonDeleteURL.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this._buttonDeleteURL.ForeColor = System.Drawing.Color.Black; - this._buttonDeleteURL.Location = new System.Drawing.Point(168, 6); + this._buttonDeleteURL.Location = new System.Drawing.Point(93, 6); this._buttonDeleteURL.Margin = new System.Windows.Forms.Padding(6); this._buttonDeleteURL.Name = "_buttonDeleteURL"; - this._buttonDeleteURL.Size = new System.Drawing.Size(150, 44); - this._buttonDeleteURL.TabIndex = 1; + this._buttonDeleteURL.Size = new System.Drawing.Size(75, 23); + this._buttonDeleteURL.TabIndex = 7; this._buttonDeleteURL.Text = "Delete URL"; this._toolTipURLButtons.SetToolTip(this._buttonDeleteURL, "DELETE selected URLs"); this._buttonDeleteURL.UseVisualStyleBackColor = true; this._buttonDeleteURL.Click += new System.EventHandler(this.DeleteAllSelectedUrls_Click); // + // _buttonDown + // + this._buttonDown.Anchor = System.Windows.Forms.AnchorStyles.Left; + this._buttonDown.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this._buttonDown.Location = new System.Drawing.Point(291, 6); + this._buttonDown.Margin = new System.Windows.Forms.Padding(6); + this._buttonDown.Name = "_buttonDown"; + this._buttonDown.Size = new System.Drawing.Size(23, 23); + this._buttonDown.TabIndex = 9; + this._buttonDown.Text = "▼"; + this._toolTipURLButtons.SetToolTip(this._buttonDown, "Move selected URLs down"); + this._buttonDown.UseVisualStyleBackColor = true; + this._buttonDown.Click += new System.EventHandler(this.MoveAllSelectedUrlsDown_Click); + // // _tableLayoutPanelMain // this._tableLayoutPanelMain.AutoSize = true; @@ -194,21 +180,20 @@ private void InitializeComponent() this._tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMain.Name = "_tableLayoutPanelMain"; this._tableLayoutPanelMain.RowCount = 3; - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 56F)); + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 56F)); - this._tableLayoutPanelMain.Size = new System.Drawing.Size(704, 470); - this._tableLayoutPanelMain.TabIndex = 14; + this._tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); + this._tableLayoutPanelMain.Size = new System.Drawing.Size(320, 160); // // _tableLayoutPanelMainTop // this._tableLayoutPanelMainTop.AutoSize = true; this._tableLayoutPanelMainTop.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this._tableLayoutPanelMainTop.ColumnCount = 4; - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 162F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 87F)); this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 56F)); - this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 56F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 35F)); + this._tableLayoutPanelMainTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 35F)); this._tableLayoutPanelMainTop.Controls.Add(this._buttonAddURL, 0, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonDown, 3, 0); this._tableLayoutPanelMainTop.Controls.Add(this._buttonUp, 2, 0); @@ -219,8 +204,7 @@ private void InitializeComponent() this._tableLayoutPanelMainTop.Name = "_tableLayoutPanelMainTop"; this._tableLayoutPanelMainTop.RowCount = 1; this._tableLayoutPanelMainTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(704, 56); - this._tableLayoutPanelMainTop.TabIndex = 0; + this._tableLayoutPanelMainTop.Size = new System.Drawing.Size(320, 35); // // _tableLayoutPanelMainBottom // @@ -234,13 +218,12 @@ private void InitializeComponent() this._tableLayoutPanelMainBottom.Controls.Add(this._labelSecondsToDisplay, 2, 0); this._tableLayoutPanelMainBottom.Controls.Add(this._numericUpDownRotationInterval, 1, 0); this._tableLayoutPanelMainBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(0, 414); + this._tableLayoutPanelMainBottom.Location = new System.Drawing.Point(0, 125); this._tableLayoutPanelMainBottom.Margin = new System.Windows.Forms.Padding(0); this._tableLayoutPanelMainBottom.Name = "_tableLayoutPanelMainBottom"; this._tableLayoutPanelMainBottom.RowCount = 1; this._tableLayoutPanelMainBottom.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(704, 56); - this._tableLayoutPanelMainBottom.TabIndex = 1; + this._tableLayoutPanelMainBottom.Size = new System.Drawing.Size(320, 35); // // PrefsByScreenUserControl // @@ -249,8 +232,9 @@ private void InitializeComponent() this.BackColor = System.Drawing.Color.White; this.Controls.Add(this._tableLayoutPanelMain); this.Margin = new System.Windows.Forms.Padding(0); + this.MinimumSize = new System.Drawing.Size(320, 160); this.Name = "PrefsByScreenUserControl"; - this.Size = new System.Drawing.Size(704, 470); + this.Size = new System.Drawing.Size(320, 160); ((System.ComponentModel.ISupportInitialize)(this._numericUpDownRotationInterval)).EndInit(); this._tableLayoutPanelMain.ResumeLayout(false); this._tableLayoutPanelMain.PerformLayout(); @@ -270,7 +254,6 @@ private void InitializeComponent() private System.Windows.Forms.Button _buttonAddURL; private System.Windows.Forms.Button _buttonDeleteURL; private System.Windows.Forms.Button _buttonUp; - private System.Windows.Forms.Button _buttonDown; public System.Windows.Forms.ListView _listViewURLs; @@ -281,5 +264,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolTip _toolTipURLButtons; private System.ComponentModel.IContainer components; + private System.Windows.Forms.Button _buttonDown; } } From c6cf7b08234c386bc91de2d270a60108e55f9b83 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 20:57:07 -0700 Subject: [PATCH 30/45] Remove AnyCPU --- WebPageScreensaver.sln | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/WebPageScreensaver.sln b/WebPageScreensaver.sln index bc48d2b..df364a4 100644 --- a/WebPageScreensaver.sln +++ b/WebPageScreensaver.sln @@ -8,13 +8,23 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.Build.0 = Release|Any CPU + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.ActiveCfg = Debug|x86 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x64.ActiveCfg = Debug|x64 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x64.Build.0 = Debug|x64 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x86.ActiveCfg = Debug|x64 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x86.Build.0 = Debug|x64 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.ActiveCfg = Release|x86 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x64.ActiveCfg = Release|x64 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x64.Build.0 = Release|x64 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x86.ActiveCfg = Release|x86 + {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From d9d1e76112afec48dc690808c4bc811bc7c4fc2a Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 20:57:54 -0700 Subject: [PATCH 31/45] Add PublishTrimmed and Platforms --- WebPageScreensaver.csproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WebPageScreensaver.csproj b/WebPageScreensaver.csproj index caf4cb0..46902a8 100644 --- a/WebPageScreensaver.csproj +++ b/WebPageScreensaver.csproj @@ -9,6 +9,8 @@ WebPageScreensaver WebPageScreensaver 2.0.0 + true + x64;x86 @@ -16,7 +18,7 @@ - + From 679d55d947bad10588fff304011d35a2682cd34a Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 20:58:04 -0700 Subject: [PATCH 32/45] Add FolderProfile.pubxml --- .../PublishProfiles/FolderProfile.pubxml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Properties/PublishProfiles/FolderProfile.pubxml diff --git a/Properties/PublishProfiles/FolderProfile.pubxml b/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..b33c4a6 --- /dev/null +++ b/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,18 @@ + + + + + Release + x64 + bin\Release\Publish + FileSystem + net5.0 + win-x64 + true + True + True + True + + \ No newline at end of file From da7596d75f206a776f172e1189727c626fc06ea4 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 20:59:01 -0700 Subject: [PATCH 33/45] PrefsByScreenUserControl.cs Rename EventHandler methods --- PrefsByScreenUserControl.Designer.cs | 8 ++++---- PrefsByScreenUserControl.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index 7a64dc7..adb5653 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -121,7 +121,7 @@ private void InitializeComponent() this._buttonAddURL.TabIndex = 6; this._buttonAddURL.Text = "Add URL"; this._buttonAddURL.UseVisualStyleBackColor = true; - this._buttonAddURL.Click += new System.EventHandler(this.AddUrlButton_Click); + this._buttonAddURL.Click += new System.EventHandler(this.ButtonAddURL_Click); // // _buttonUp // @@ -135,7 +135,7 @@ private void InitializeComponent() this._buttonUp.Text = "▲"; this._toolTipURLButtons.SetToolTip(this._buttonUp, "Move selected URLs up"); this._buttonUp.UseVisualStyleBackColor = true; - this._buttonUp.Click += new System.EventHandler(this.MoveAllSelectedUrlsUp_Click); + this._buttonUp.Click += new System.EventHandler(this.ButtonUp_Click); // // _buttonDeleteURL // @@ -150,7 +150,7 @@ private void InitializeComponent() this._buttonDeleteURL.Text = "Delete URL"; this._toolTipURLButtons.SetToolTip(this._buttonDeleteURL, "DELETE selected URLs"); this._buttonDeleteURL.UseVisualStyleBackColor = true; - this._buttonDeleteURL.Click += new System.EventHandler(this.DeleteAllSelectedUrls_Click); + this._buttonDeleteURL.Click += new System.EventHandler(this.ButtonDeleteURL_Click); // // _buttonDown // @@ -164,7 +164,7 @@ private void InitializeComponent() this._buttonDown.Text = "▼"; this._toolTipURLButtons.SetToolTip(this._buttonDown, "Move selected URLs down"); this._buttonDown.UseVisualStyleBackColor = true; - this._buttonDown.Click += new System.EventHandler(this.MoveAllSelectedUrlsDown_Click); + this._buttonDown.Click += new System.EventHandler(this.ButtonDown_Click); // // _tableLayoutPanelMain // diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index 538804e..c825e8c 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -19,7 +19,7 @@ public void Save(int screenNumber) currentScreen.Shuffle = _checkBoxShuffle.Checked; } - private void MoveAllSelectedUrlsDown_Click(object sender, EventArgs e) + private void ButtonDown_Click(object sender, EventArgs e) { // TODO: make button grey out when none selected OR when all selected ones are in a bunch at the bottom. bool gapFound = false; @@ -47,7 +47,7 @@ private void MoveAllSelectedUrlsDown_Click(object sender, EventArgs e) _listViewURLs.Select(); } - private void MoveAllSelectedUrlsUp_Click(object sender, EventArgs e) + private void ButtonUp_Click(object sender, EventArgs e) { // TODO: make button grey out when none selected OR when all selected ones are in a bunch at the top. bool gapFound = false; @@ -75,7 +75,7 @@ private void MoveAllSelectedUrlsUp_Click(object sender, EventArgs e) _listViewURLs.Select(); } - private void DeleteAllSelectedUrls_Click(object sender, EventArgs e) + private void ButtonDeleteURL_Click(object sender, EventArgs e) { // TODO: undo capability? // TODO: make button grey out when no selection. @@ -89,7 +89,7 @@ private void DeleteAllSelectedUrls_Click(object sender, EventArgs e) } } - private void AddUrlButton_Click(object sender, EventArgs e) + private void ButtonAddURL_Click(object sender, EventArgs e) { ListViewItem item = _listViewURLs.Items.Add(string.Empty); item.BeginEdit(); From 127126b59bae77982d7d1463950c3b585b3a2efb Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 21:00:01 -0700 Subject: [PATCH 34/45] ScreensaverForm.cs ensure the screen size is used (avoid overwrite by Designer autogenerated code). --- ScreensaverForm.Designer.cs | 7 +------ ScreensaverForm.cs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ScreensaverForm.Designer.cs b/ScreensaverForm.Designer.cs index b365e90..1a907bb 100644 --- a/ScreensaverForm.Designer.cs +++ b/ScreensaverForm.Designer.cs @@ -34,10 +34,8 @@ private void InitializeComponent() // _webBrowser // this._webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; - this._webBrowser.Location = _savedLocation; - this._webBrowser.Margin = new System.Windows.Forms.Padding(4); + this._webBrowser.Margin = new System.Windows.Forms.Padding(0); this._webBrowser.Name = "_webBrowser"; - this._webBrowser.Size = _savedSize; this._webBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); this._webBrowser.TabIndex = 0; this._webBrowser.TabStop = false; @@ -46,18 +44,15 @@ private void InitializeComponent() // ScreensaverForm // this.BackColor = System.Drawing.Color.Black; - this.ClientSize = _savedSize; this.Controls.Add(this._webBrowser); this.ForeColor = System.Drawing.Color.White; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.Location = _savedLocation; this.Margin = new System.Windows.Forms.Padding(0); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ScreensaverForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Load += new System.EventHandler(this.ScreensaverForm_Load); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.WebBrowser_MouseMove); this.ResumeLayout(false); } diff --git a/ScreensaverForm.cs b/ScreensaverForm.cs index ed6a320..fc89a8d 100644 --- a/ScreensaverForm.cs +++ b/ScreensaverForm.cs @@ -20,11 +20,12 @@ internal partial class ScreensaverForm : Form public ScreensaverForm(ScreenInformation screen) { + _currentURLIndex = 0; + _closeOnMouseMovement = Preferences.CloseOnMouseMovement; _rotationInterval = screen.RotationInterval; _shuffle = screen.Shuffle; _urls = screen.URLs.ToList(); - _currentURLIndex = 0; _savedSize = new Size(screen.Bounds.Width, screen.Bounds.Height); _savedLocation = new Point(screen.Bounds.Left, screen.Bounds.Top); @@ -32,6 +33,14 @@ public ScreensaverForm(ScreenInformation screen) 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(); } @@ -62,6 +71,8 @@ private async void ScreensaverForm_Load(object sender, EventArgs e) _timer.Interval = _rotationInterval * 1000; _timer.Tick += (s, ee) => RotateSite(); _timer.Start(); + + RotateSite(); // First call, second one will be done _rotationInterval seconds later by _timer } else { @@ -85,7 +96,7 @@ private void BrowseTo(string url) _webBrowser.CoreWebView2.Navigate(url); } - private void WebBrowser_MouseMove(object sender, MouseEventArgs e) + private void WebBrowser_MouseMove(object sender, EventArgs e) { if (_closeOnMouseMovement) { @@ -100,7 +111,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Escape) { - this.Close(); + Close(); return true; } return base.ProcessCmdKey(ref msg, keyData); From 5c9a9a870c32d1cb8fca154720f5e9f4db9260a5 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 21:00:31 -0700 Subject: [PATCH 35/45] ScreenInformation.cs remove unused properties, ensure URLs have a default. --- ScreenInformation.cs | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/ScreenInformation.cs b/ScreenInformation.cs index dce1652..b426f55 100644 --- a/ScreenInformation.cs +++ b/ScreenInformation.cs @@ -19,29 +19,16 @@ private struct SettingName public const string RotationInterval = "IntervalRotation"; public const string Shuffle = "Shuffle"; } - private struct SettingValue + private struct SettingDefaultValue { - public const int RotationInterval = 30; + public const int RotationInterval = 10; public const bool Shuffle = true; + public const string URLsPrimaryScreen = "https://dotnet.microsoft.com/ https://code.visualstudio.com/"; } public ScreenInformation(RegistryKey rootKey, int screenNumber, MultiScreenMode multiScreenMode) { - RootKey = rootKey; - ScreenNumber = multiScreenMode switch - { - MultiScreenMode.Span => 0, - MultiScreenMode.Mirror or MultiScreenMode.Separate => screenNumber, - _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.") - }; - - IsPrimary = multiScreenMode switch - { - MultiScreenMode.Span or MultiScreenMode.Mirror => true, - MultiScreenMode.Separate => Screen.AllScreens[screenNumber].Primary, - _ => throw new IndexOutOfRangeException("Unrecognized MultiScreenMode value.") - }; Bounds = multiScreenMode switch { @@ -53,25 +40,13 @@ public ScreenInformation(RegistryKey rootKey, int screenNumber, MultiScreenMode public RegistryKey RootKey { get; private set; } - public int ScreenNumber - { - get => int.Parse(RootKey.GetOrCreateValue(SettingName.ScreenNumber)); - set => RootKey.SetValue(SettingName.ScreenNumber, value); - } - public Rectangle Bounds { get; set; } - public bool IsPrimary - { - get => bool.Parse(RootKey.GetOrCreateValue(SettingName.IsPrimary)); - set => RootKey.SetValue(SettingName.IsPrimary, value); - } - public IEnumerable URLs { get { - string urlsString = RootKey.GetOrCreateValue(SettingName.URLs, string.Empty); + string urlsString = RootKey.GetOrCreateValue(SettingName.URLs, SettingDefaultValue.URLsPrimaryScreen); return urlsString.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); } } @@ -84,13 +59,13 @@ public void UpdateURLs(IEnumerable urls) public int RotationInterval { - get => int.Parse(RootKey.GetOrCreateValue(SettingName.RotationInterval, SettingValue.RotationInterval)); + get => int.Parse(RootKey.GetOrCreateValue(SettingName.RotationInterval, SettingDefaultValue.RotationInterval)); set => RootKey.SetValue(SettingName.RotationInterval, value); } public bool Shuffle { - get => bool.Parse(RootKey.GetOrCreateValue(SettingName.Shuffle, SettingValue.Shuffle)); + get => bool.Parse(RootKey.GetOrCreateValue(SettingName.Shuffle, SettingDefaultValue.Shuffle)); set => RootKey.SetValue(SettingName.Shuffle, value); } From d7e550fe4fb7712a900f7a0e7313740ebbe78fee Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 21:01:09 -0700 Subject: [PATCH 36/45] Properties.cs remove default URLs from here. --- Preferences.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Preferences.cs b/Preferences.cs index f85756e..7617022 100644 --- a/Preferences.cs +++ b/Preferences.cs @@ -26,7 +26,6 @@ private struct SettingDefaultValue public const MultiScreenMode MultiScreen = MultiScreenMode.Separate; public const int RotationInterval = 30; public const bool Shuffle = false; - public const string URLsPrimaryScreen = "https://dotnet.microsoft.com/ https://code.visualstudio.com/"; } #endregion From a78cc5b2ec0f59d3509af8cdbded399688507ff9 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 21:01:33 -0700 Subject: [PATCH 37/45] Extensions.cs remove redundant extensions, use typed extension. --- Extensions.cs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/Extensions.cs b/Extensions.cs index 411b4ae..8ca18f5 100644 --- a/Extensions.cs +++ b/Extensions.cs @@ -28,7 +28,7 @@ public static RegistryKey GetOrCreateSubKey(this RegistryKey root, string subKey return key; } - public static string GetOrCreateValue(this RegistryKey root, string valueName, object defaultValue) + public static string GetOrCreateValue(this RegistryKey root, string valueName, T defaultValue) { if (root == null) { @@ -46,7 +46,7 @@ public static string GetOrCreateValue(this RegistryKey root, string valueName, o object? obj = root.GetValue(valueName); if (obj == null) { - root.SetValue(valueName, defaultValue.ToString() ?? string.Empty); + root.SetValue(valueName, defaultValue); obj = root.GetValue(valueName); if (obj == null) { @@ -55,24 +55,5 @@ public static string GetOrCreateValue(this RegistryKey root, string valueName, o } return obj.ToString() ?? string.Empty; } - - public static string GetOrCreateValue(this RegistryKey root, string valueName) - { - if (root == null) - { - throw new ArgumentNullException(nameof(root)); - } - if (string.IsNullOrWhiteSpace(valueName)) - { - throw new ArgumentNullException(nameof(valueName)); - } - - object? obj = root.GetValue(valueName); - if (obj == null) - { - throw new UnauthorizedAccessException($"Could not get/create the registry value: {valueName}"); - } - return obj.ToString() ?? string.Empty; - } } } \ No newline at end of file From 66a89885b0526c3c7f8f339c5a027e31b13f1dea Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 9 Sep 2020 21:02:11 -0700 Subject: [PATCH 38/45] Program.cs revert versioning change (do not add yet). Ensure no arguments is equivalent to opening settings. --- Program.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Program.cs b/Program.cs index de0a74e..cc4b72d 100644 --- a/Program.cs +++ b/Program.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.Versioning; using System.Windows.Forms; -[assembly: SupportedOSPlatform("windows")] namespace WebPageScreensaver { static class Program @@ -29,10 +27,10 @@ static void Main(string[] args) // Argument verification - More than 1 argument, or passing // the wrong argument, will silently exit the program - // No arguments is interpreted as "/P" or "/S" + // No arguments is interpreted as "/C" if (args.Length == 0) { - ShowScreenSaver(); + Application.Run(new PreferencesForm()); } else if(args.Length == 1) { From 250607c7213e0970665d86c7d1e29774e2bf80b5 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Thu, 10 Sep 2020 12:23:43 -0700 Subject: [PATCH 39/45] Add *.pubxml files for x64 and x86. --- Properties/PublishProfiles/PublishX64.pubxml | 19 +++++++++++++++++++ Properties/PublishProfiles/PublishX86.pubxml | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Properties/PublishProfiles/PublishX64.pubxml create mode 100644 Properties/PublishProfiles/PublishX86.pubxml diff --git a/Properties/PublishProfiles/PublishX64.pubxml b/Properties/PublishProfiles/PublishX64.pubxml new file mode 100644 index 0000000..bd8b373 --- /dev/null +++ b/Properties/PublishProfiles/PublishX64.pubxml @@ -0,0 +1,19 @@ + + + + + Release + x64 + Publish\Release\x64\ + FileSystem + net5.0 + win-x64 + true + True + True + True + True + + \ No newline at end of file diff --git a/Properties/PublishProfiles/PublishX86.pubxml b/Properties/PublishProfiles/PublishX86.pubxml new file mode 100644 index 0000000..cd39b55 --- /dev/null +++ b/Properties/PublishProfiles/PublishX86.pubxml @@ -0,0 +1,19 @@ + + + + + Release + x86 + Publish\Release\x86\ + FileSystem + net5.0 + win-x86 + true + True + True + True + True + + \ No newline at end of file From 890bffd2af2966a1318afd7a87b5998f63d10828 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Thu, 10 Sep 2020 12:23:54 -0700 Subject: [PATCH 40/45] Delete the default pubxml file. --- .../PublishProfiles/FolderProfile.pubxml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Properties/PublishProfiles/FolderProfile.pubxml diff --git a/Properties/PublishProfiles/FolderProfile.pubxml b/Properties/PublishProfiles/FolderProfile.pubxml deleted file mode 100644 index b33c4a6..0000000 --- a/Properties/PublishProfiles/FolderProfile.pubxml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Release - x64 - bin\Release\Publish - FileSystem - net5.0 - win-x64 - true - True - True - True - - \ No newline at end of file From 9ebe7aedd0ca47207f3f157f5ed3c3a5cb65d707 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Thu, 10 Sep 2020 12:24:46 -0700 Subject: [PATCH 41/45] csproj Set the initial version to 2.0.1-Alpha. Add the trimming warning setting and set to true. --- WebPageScreensaver.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WebPageScreensaver.csproj b/WebPageScreensaver.csproj index 46902a8..6db7ac1 100644 --- a/WebPageScreensaver.csproj +++ b/WebPageScreensaver.csproj @@ -8,8 +8,9 @@ WebPageScreensaver.Program WebPageScreensaver WebPageScreensaver - 2.0.0 + 2.0.1-Alpha true + true x64;x86 From ced1bd70d9e586c0b00f0d2cc4c45b06304da57b Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Thu, 10 Sep 2020 12:48:58 -0700 Subject: [PATCH 42/45] FInal readme with screenshot, no published files yet. --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++-------- screenshot.png | Bin 0 -> 8821 bytes 2 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 screenshot.png diff --git a/README.md b/README.md index 9957e84..5aa53d1 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,63 @@ -# Web Page Screensaver (.NET 5.0) +# Web Page Screensaver -Display a web page as your screensaver. +Display webpages as your screensaver. + +Inspired by its predecesor [cwc/web-page-screensaver](https://github.com/cwc/web-page-screensaver) (_Achived_). + +## Binaries#Binaries + +Version|32-bit|64-bit +---|---|--- +| 2.0.1-Alpha | Download | Download | + _Due to 10MB size limit by GitHub (the generated files are ~130MB), need to find an alternative way to publish these._ + +_Workaround: Follow the [debugging instructions](#Debugging) and generate the files yourself._ + + +## Installation instructions + +* Install the [dependencies](#Dependencies). +* Download The *.scr for your architecture. +* Right click the *.scr file. You have three options to choose from: + * Select `Test` if you want to preview it in full screen. Note: Press ESC to exit the screensaver. + * Select `Configure` to modify the screensaver settings. You should see this Window: + ![Screenshot](screenshot.png) + * Select `Install` if you want it to be added to your list of Windows screensavers. The Windows `Screen Saver Settings` window will pop up with this screensaver selected. ## Dependencies -- .NET 5.0 x64 Desktop Runtime for Windows: https://dotnet.microsoft.com/download/dotnet/5.0 -- Microsoft Edge Insider (Canary) x64: https://www.microsoftedgeinsider.com/en-us/download/ +Whether you are just installing it or building it, you need the following dependencies: + +* .NET 5.0 Desktop Runtime for Windows (>= Preview 8): https://dotnet.microsoft.com/download/dotnet/5.0 +* Microsoft Edge Insider (Canary): https://www.microsoftedgeinsider.com/en-us/download/ +* Windows >= 7. + +## Fixes and improvements + +### 2.0.1-Alpha +* Upgrade to .NET 5.0. +* Use Edge (WebView2) instead of Internet Explorer. + +## Known issues + +### 2.0.1-Alpha + +* The WinForms theme does not look nice in the published single-file binary. It looks fine when debugging or when building normally (not publishing). It may be caused by the trimming process, which removes what it thinks are unnecessary UI dependencies. +* After installing the *.scr, it's not possible to open the Settings window directly from the Windows Screen Saver Settings button. The workaround is to open the settings by directly double clicking on the *.scr file and configuring the screen saver from there. +* Close on mouse movement does not work because Edge is capturing the mouse movement events, preventing the screensaver from detecting them. The workaround is to press the Esc key. +* Publishing does not yet convert the generated *.exe to *.scr. The extension needs to be changed manually. +* Can't host the final *.scr files in GitHub due to the large size. Workaround is to build it yourself. + +## Contributing + +Issues and PRs are welcome. -## Usage (Windows 7 & up) +## Debugging -* Download Web-Page-Screensaver.scr: -* Right click it. -* Select "Test" if you want to preview it in full screen. -* Select "Install" if you want it to be added to your list of Windows screensavers. - * The screensaver Settings dialog will pop up with the correct screen saver selected. - * Use the `Settings...` button in the same dialog to change the web page(s) displayed by the screen saver. +* Install the [dependencies](#Dependencies). +* Clone the repo. +* Build with `dotnet build`. +* To debug from Visual Studio, edit the [launchSettings.json](Properties/launch.json) file and set the `"commandLineArgs"` value to: + * `"/p"` if you want to debug the screensaver itself. + * `"/c"` if you want to debug the settings window. +* Generate a single *.exe by publishing the project using the *.pubxml files in the `Properties/PublishProfiles` folder. Then rename the *.exe to *.scr. \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..10efc3eedbd47e61460c8aee5e26f8be68a3afb0 GIT binary patch literal 8821 zcmd^lXIN9+x^2`?v4V<6#fzSgQiXaeb5|L^FqzFot5>Tpu1VRr1 zg3_c*2?Sw*bV)*x-r+{~-shh0oW0Mv&$-Y2b$_fUnQP58*E{DLW4?2Yxxx(fHBKGp zJPrbZPHAc0g@Ql_dYMPq(Syu0c%5r7=Fb5ysD>&C*Tp@@Ed25CPrW~xm!ePXJUGlO zA9L3<_X2@f8-5)JTHHR^fk0P}Yu)|R__6goP#YyM=+nHYbyA_v^$Y%>Sklp-$NQ~= zyboRddQ4*Iy7AS+N1B2n!cd1^6n=R=PCaC(>X71U=W><3_&`sVZvD+GqPKe%HUqlz zjL0xD+09^mC-CAzn*10{YIZ2uT+DwJSlHv|^ZWUUh0lQxj3ylhy}gV+P=5}80+jO- z4!WsEKNuv8-~j2KA%gBd@}LJOf!9EwNK1C&e*Yc%!FujSFh~@QLai=Mw?BTbnSHA% z;!MjcU>hJaloNKz!`(J55jlE!#PTfZlphsVNmZmmsp72*)+&L%!=cBlHy3u-=)v5 zcpWKjX_vQ4X+KtqfCv^;ilVQb=Q$&BE|kK`3} z`#c&tT@+%3a=UwBy%}w|FjAf~H}MD3%x$J5_Dg5~sH$|aD5`uoucYIR=~6Jd+n#sz z=CIO%=sq33s%0rtZUrN$fDB`LOzJ=|c27;M@)yCat7ZLhNR zRAXv7FW}2f&ZaT{J0YrUwhC5%3rO?~ocCQ263U5_M~npb3qC{?Ofo%z1#W3J)qB{#l-=jzT; z?%4WJ-R>F11Dg!#(oD6Q-3pCK5r|xAPi*^ie__ujzso3&aJF{EJsQnMs*9$rRL!R9%1L_A9Jb zUK3QnX+6*;PDDhWqvTdFSE2XHJ*j^3ZJ{NjlNEDAm?uhe0jdEpT6na$q7p$OBwxSYolh(NlG>XHm%xM3J^RfT>HB}s{-hC)&89O`$#x^taTMYZSa7K zedt?X#IE>ae7D0X{x_p`k{p#c--te0HLg3^>*5GDd*O^tLF6-;;pvgktnqiZ#4`y_jSaZ!?OkobesGP#YeWt?ZH7< zvo?9P@JSX=K!M(|D#vz&=|h~A44xJRpY_Y`o65LSsgo@Z(az_E9u#U?ZDhpthN8 zFngsp^u0n&exa{yzJu9EV&d+UnwQTW^NDYrr{&AEgJJ9n6k%KUufT_v|EZp=`<039iTc)2C z52&3TJG7h4XbvtlT+dqxrF|Q}50erd0485_R`ffimbae2kwfh@!z>$kH%-uMXVvvxN=hR|)=XDc2M4Ep zmwSRW!uxh%=7YRX>HIDY9E|>UVm^5NVmmMoQ$VfH?$>(-LwO=kErm$KV7ZrW77L-( zG=Dwv0X^JZv&Oxc`ut5}KD2Kxmd)uFH%_Ri?P>nph3vSgH$MB*MWNadX*H-@2{BS6 z|EW(?v4gaM!u~U-;l0kF{>h_L;EDe6O9{12R45c;RblFOYhmof`RB97tK1d(>)rNq z11krkoC4|kKbpb3H?Y=J@d1Gm=up$U+&vC95ti&9-?EfpA)L94$rqf`R&fJm4wjkQ zxsv!3mcJ;N91h6+W=|$F56T|-NB;Xwt$$6?e`DYOtO~+6-EXP2v$HcgU?o$?Ani*L zG$EOSCV=TUzFDE3Blrk0|IO({(ngc`sQ)?;t+Kb#9k{og0&$x%71nvxAGp}WfgiIc z6cYnd)9>muf-6>*)Ax5wNn7Nxy|qd=XXr9B%WFE*a{;)Gnt_{5Q}uGm4$cNpuC1=F zi!crIJ-c|RYT_O6WpYQr;wl<{X;W||S7p~pHiNVcECejYrhi$_T`GvXlU-IZ_Mv*G zb!+rfXM)jjfZ9|j;3Xs3yKs#;jDiGB+&g^={d_S%a#p{M2!nAN}eWCI+(XKh?91p`Z+b@ z%~g6?>Qt5eon_3ZkI-7w2qxFH{{`kxp;U*!k8llGu6#DmD!I(6L#K1MVkwVj>f-3gY>TDxho0rk} zB$yk~Tt0PA-~!{iHcYPKniR}n%nHR-mhV8G;zoaCdpx{KA}VF;44Dxs(StB^Q`1S< zyhs63DE8C~9%F^1b>ZRr%d^iYO%6yTQh9H~RxXLOzq?>NB1qbucgwc6U{RSi{!E~y z*5!+&J;;mDkb@K;u_ok?^1R@&)wiSY*~?48#M5<8hOuzd>8%SgkpQeRvr&xM^r~<{ zsFe(YBV}_c*5DW7-0C*fS#zi8(SbXY3xWIFOU_@c@)8Hu#6K1v8e~u%i7M!hZ|bn z3a#4_!#aBJ1<$R9Kqxx|=GbK0>@6k!TAEV!r;IFYNmm=Aa%}|`QHUsN`&k)%JD6h8kpTwswT;oVCA!$Qhfd_?R%3(;Mb`^UrmpxG?qIx-O z{NC(8?VC*x++)7jO;{V$t6s(Z$q$w#S&YA=3i;VuSs$7%@#pIIy>P0{Bn zN!#ZqeC_J2M@VHIja`9`ehCOSf_as@eh!Tr$^19D`~Pxc_;)Mt-!qUeVx6%?-2x|& zwy5NJBb2#~@aj9|xl&SWZ%5J~I#_h|bz5#_k?JK7Z-T!YQJ&$~7_Z2sHzT-$3Ho3#lgCywjQY8L*g zD1?TGA3L8$?F}}M^@s^1Xt$x9PqxIofmuY6Vyd;g>=MiYhu+hWQA|&Kc`@a&0*HG! zmEyYm_1e2AF$~Y-sKYiU2=>6T)Cd&gsUWSPE;pMyZgRuZ8 zWapFK2o75A^%+)T)(KiJS$ACz;MhMj-et*G7ey{o@za6N^T&29Sb5PF7?WzBhQUEn z^~KqyFhyxnuk;e|<{|^xbi#{5q~(f~ zIXh!5&iEJcr^&GF(rC-vE^|nWW0|&X?ki?r9zI$aWs(dCqZHj{2l;JFbJA_!Hl2R>siX)24s^x>z%RFep!l zsdi;gaGWKA+%Nnm;ro}w-#KfZynnyu)2=l4^fnkG|J( zE%~wf9mPMszhIRMauD)ITtPr2x9t?|B6ttFi-dCDE{#>jpT=_~`AhPasIeW8jlaYC zZb&QL>?P$@hw>%1p^Q*aYTFf-uk^d2I}SMC7Dq(Q6`kVB+(~F>+?hn z-Xk(&>&6;YTcY7|3q;^?qxa-}Gr2Poc@J^4ZbFNCdgLRg%FG@Wj~oQXTEJ~z_kz+N z-;LL@zUD40G?NC{l;%9?&HbTh#QV$^95-gD<8jpQ7Wfg`1ch1N&;ZE{^juBP(>zD) zqZ<{0g1@`mCoI5XJHgf2U{IYN_yO*LcyHT+OGT4X1g|bNV-^x+f0(FuZdf6p0qP_QSu`4bwY$b=O{>gQ(}w z$l*~rc9uhewK`tgC{`Tiul0WX=WfNeov}{Kl=InMEf`i1Ht4MPk0Ik{F{~T0Z0IZP z(K0P~mHL$#&?Ta)-IsEe%@`2jldFFX)C1*HamxrR=o4;!rjPO?_MRA=(coG*6mu)5 za}6mo>Rco}yz{r9yxHCrz z%=EX^yymzA*}Q7@eu_QUxYEHWU;c1F)b;|gdZ}JF?q**@O8fmMVduGI-Mcle65Avk ziyIi3M~XWxHRDqKcR!P@)cbTkQtBW0DksdRQMq?DPTfz+Y+}^<1!76N@yT|TM)q3^lrKTTzT_w310>cVkzs9~`%P6!pg=}k%*QZU!>u-1;?{4! z>YJVk44*S^goYt+XDzml`ZSJmd1RGfx#~SN!U1nDMD=b3t7$+VFDYJOAhJ`QEEF? zM9)%h?$N_+U8S}@pu~TDAD!5O^Y-WgnuGmvJkipNLsgxcB-<)K0v`D2(`Y97+DLm*!vj2A|23 zamxltbuF0#%R``gXEnT$BH`@wNx4P|XPnqUtW4y<@A541$bFfEL~AyD(O%(zyuk$&u$vo3hWj0lhe|>$3eejdFtIm zRzlv=l!@eLBB7PVHv#r7DCxsg&r zbZ4;$)^?sy>G-Zr_AnfbYb`ju8*GFBkP|l9k05`LG{?EMK_gW=KaW=j&S4dP3>|@_ zkPG!mfobTPj==W^WILXR10u&p)YyY?V9bS8dn~^`oc{(P;*p_+zpTkI{(jlohbp%i zr5GFg8O2Xb;Cw{ClmB3XIsvr=3;^oN_N-G&8(9$a@#kp-1b#B(3h&|w9EbAtnroT$ zQG)o;p@QP^IB=BV@XMwAy7cX6qnRe-*x7FY$~?0pal5+Nkdq5X^EKLpy3M*4aAGan zms-8|-;}IG+JZjXT_ED7HtrO(;TjzFYXP*~(YVWQc`KZoH_A)!w;C(so1lI7%b}Bd zGdE8fELRgxN@q6Ms#Q^SVIu3h@fP_#h4#&5qkDU<=IU`Rp!@N*jf|^XE(R$Zc(BXQ zj;E(m|4Ur`&uoeRs6PI`ZRMLNdh=I;*m%2nCbP6c6ny~1@|Ohhm%WmIm2xIBcG}(c z<_`okb{^oxM?@fAdyLn2XwWn8qG%GtfPU(2X&4ZQ)str@I*Ky05T^!x;zb8yJ<#DY zx<`#Zk@2>PVe{*Mxj8*xZHQ^iD)}x>sO5I^x#2P%lJ<Nag1ztIdx0W(Lo_Ofg2 zjwlLxNihO2sB&U7$9S*L_9o3tN?$)>YA#Xw5|>U}8^yJ|eep|}eDhf!3ye@HTmJNW z>#~6i;#>O^%BiI7QQrms-PJ)?zQlN+?!cY$Z5Pq1hjYm!u(3~%Q3Jmu|0Hua$MPzs z@&^9Kd#*Mpg|EibLcn0(GVF>E>U>eGG=5l4yronHZHg^JIU#*MnBvOG7a%X;Sc2!! z+8o{c(+tWKHcDOdaB_HP74Eg-G2Q4djADTvl1m4yNJ72hT%DE^BR z!7o1Eb^YKZX?illyyBZ*=@eukAN!bVODeuCFM^iUPM+6!NDk6Ks?kmE68zFKD`H8>6o;$Ga&C?8sxQ_k`PcCPUj1T z-^L4X>D=Y-GqLU8arG~^+*H!TZfo%gzp%MM)*ZcHWr=x2aX+3*9JY3P6^~bVKfm0P zQd8@_5BMgi`dQ$HzY_+hjr-wGQTQ9?TUsoxl{*Ev<)l+jwsR&a-wi(Noj! z&8j;4_JgPS<$Yk#y+ZU>Fib(`9M)+$V}1u`EkBpvOIWER2t&T-ba!V$1=)C>H0Y$4 zJeBo;tqID9=6ve=;pQ?jLBaB`9qB0Cj|z~H6N|}R(!GP?$NS z5zNVKt?f{UEP~?{^IkPc#@{EXf3^+$m#NK|X^Vg~U`@y>5Qv-WzgvAjHQM@j(s|$| z{CnJ#9aArJ>ZIaY)=vK_zl1YIdGQ_kaRf&Y55n{`5kx;td`2l8fd~5fbF|y|uaYVa z$kPQR<=Q7koDus(#-MYrM)yfYsD@tZFI5by*uFkcP35cEcLLLLI^QZ4sXk8(Y5=PcWDKNHM=u&t0{hRyortAn}c}7VD`OO4mnrb_kH#XCU{>%(JuEG z3QEOnV`hM59wER5vxa$>L0ZS1$_H5gHXXmXG9cA)pxa1a}Xxuw*LekhX zGR=Jp|9qvxiPnY-+-47xO}Xwy#O4K^z+_QYTfc=o%8%?RQPy`T4g(mjA_PDP$=WNM z6L(b!-Z9MHgw(y=+W7kUxMWMlxruG304K3GA|ug)0_D5TE}H~*2%5!c)8cy!k1(3( zaV2kp=2z_}Fr;wFJQN=W^ccr&HCECB@)WrX)a4k9Cl$opZ_~G4)|{FX-cgt<>}p#p zFXJHQiTY4kq8gD3=iSGn&J)iTx>`?R2*&QhrOHM*mzt2XGQ0lSDu&QU)RoBTE<@l3 z)wmO*Nw4OcRPI!1bp->?F395o(B+82INHG5!dl9_?qRDc+a?^_$yIrps^DSGE*l%m zEtl5o=+H{S^1|YxK0H&Lx}rNh-ihH2<*lMz!PCZ|%LZ_NL#obh!-4b)Fm!rew*O>6 z(COZaMx@Je_6nl|9E`{K8-4@oBKq3&X0Tqr%O_EEaCN7<5ZJXA0OvS}qwh#?4!j_& z)Hkt)!$BIJ{S>7u?G*oFlV)VVx?-!w$RF;6e*xXY_cioqvj5F6Vxs;(d{^;TLPf&= jCPX8Z>$ao!*%ZC3u85oq7G!=Z0@6~`zl&47|LlJOAmo4N literal 0 HcmV?d00001 From ba54dc0d6378268b9d1e4cad163d5edb269e60de Mon Sep 17 00:00:00 2001 From: ChayoteJarocho <77412126+ChayoteJarocho@users.noreply.github.com> Date: Sun, 28 Mar 2021 12:21:46 -0700 Subject: [PATCH 43/45] typo in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5aa53d1..80adcfb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Display webpages as your screensaver. Inspired by its predecesor [cwc/web-page-screensaver](https://github.com/cwc/web-page-screensaver) (_Achived_). -## Binaries#Binaries +## Binaries Version|32-bit|64-bit ---|---|--- @@ -60,4 +60,4 @@ Issues and PRs are welcome. * To debug from Visual Studio, edit the [launchSettings.json](Properties/launch.json) file and set the `"commandLineArgs"` value to: * `"/p"` if you want to debug the screensaver itself. * `"/c"` if you want to debug the settings window. -* Generate a single *.exe by publishing the project using the *.pubxml files in the `Properties/PublishProfiles` folder. Then rename the *.exe to *.scr. \ No newline at end of file +* Generate a single *.exe by publishing the project using the *.pubxml files in the `Properties/PublishProfiles` folder. Then rename the *.exe to *.scr. From 74e67815fc1a4b7c892eaad313bcbc9948c772fd Mon Sep 17 00:00:00 2001 From: ChayoteJarocho <77412126+ChayoteJarocho@users.noreply.github.com> Date: Sun, 28 Mar 2021 17:13:48 -0700 Subject: [PATCH 44/45] Create dotnet.yml (#7) --- .github/workflows/dotnet.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..a73cc8b --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,25 @@ +name: .NET + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal From 4788012c7fbc2155c42811d4cdd95fd6ccb932f6 Mon Sep 17 00:00:00 2001 From: ChayoteJarocho <77412126+ChayoteJarocho@users.noreply.github.com> Date: Sun, 28 Mar 2021 17:19:59 -0700 Subject: [PATCH 45/45] Small updates (#8) * Add some helpful console messages on wrong arguments. Move code to open preferences form to its own method. * Update WebView2 package version. * TFM must target .NET 5.0 and Windows specifically (due to WinForms). * .gitignore * Bump version * Remove "Any" from sln * Address info Roslyn messages * Clean some unused code, simplify some other, remove regions. * Add new version in readme. * unnecessary parenthesis --- .gitignore | 10 +++-- MultiScreenMode.cs | 2 + Preferences.cs | 38 ++++------------- PreferencesForm.Designer.cs | 6 +-- PrefsByScreenUserControl.Designer.cs | 6 +-- PrefsByScreenUserControl.cs | 7 +++- Program.cs | 62 +++++++++++++++++----------- README.md | 14 +++++-- ScreenInformation.cs | 43 +++++-------------- WebPageScreensaver.csproj | 6 +-- WebPageScreensaver.sln | 4 -- 11 files changed, 87 insertions(+), 111 deletions(-) diff --git a/.gitignore b/.gitignore index ab73c76..dc250f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -.vs -bin/ -obj/ -*.user +**/.vs/ +**/.vscode/ +**/bin/ +**/obj/ +**/Properties/* +**/*.user diff --git a/MultiScreenMode.cs b/MultiScreenMode.cs index e6324bc..c7fe5fa 100644 --- a/MultiScreenMode.cs +++ b/MultiScreenMode.cs @@ -9,10 +9,12 @@ internal enum MultiScreenMode /// Same webpage in all screens. /// Mirror, + /// /// Each screen has its own individual list of webpages. /// Separate, + /// /// Show one webpage split among all the screens. /// diff --git a/Preferences.cs b/Preferences.cs index 7617022..e5e7745 100644 --- a/Preferences.cs +++ b/Preferences.cs @@ -7,72 +7,50 @@ namespace WebPageScreensaver { internal static class Preferences { - #region Setting names and default values - - private struct SettingName - { - public const string ScreenCount = "ScreenCount"; - public const string CloseOnMouseMovement = "CloseOnMouseMovement"; - public const string MultiScreenMode = "MultiScreenMode"; - public const string RotationInterval = "RotationInterval"; - public const string Shuffle = "Shuffle"; - public const string Url = "Url"; - } + private const string CloseOnMouseMovementName = "CloseOnMouseMovement"; + private const string MultiScreenModeName = "MultiScreenMode"; private struct SettingDefaultValue { - public const int ScreenCount = 1; - public const bool CloseOnMouseMovement = true; - public const MultiScreenMode MultiScreen = MultiScreenMode.Separate; public const int RotationInterval = 30; public const bool Shuffle = false; } - #endregion - - #region Private fields - private const string KeyWebPageScreensaver = @"Software\WebPageScreensaver"; - #endregion - - #region Properties - private static RegistryKey RootKey => Registry.CurrentUser.GetOrCreateSubKey(KeyWebPageScreensaver); public static int ScreenCount => Screen.AllScreens.Length; public static MultiScreenMode MultiScreen { - get => Enum.Parse(RootKey.GetOrCreateValue(SettingName.MultiScreenMode, SettingDefaultValue.MultiScreen)); - set => RootKey.SetValue(SettingName.MultiScreenMode, value); + get => Enum.Parse(RootKey.GetOrCreateValue(MultiScreenModeName, MultiScreenMode.Separate /* default */)); + set => RootKey.SetValue(MultiScreenModeName, value); } public static bool CloseOnMouseMovement { - get => bool.Parse(RootKey.GetOrCreateValue(SettingName.CloseOnMouseMovement, SettingDefaultValue.CloseOnMouseMovement)); - set => RootKey.SetValue(SettingName.CloseOnMouseMovement, value); + get => bool.Parse(RootKey.GetOrCreateValue(CloseOnMouseMovementName, true /* default */)); + set => RootKey.SetValue(CloseOnMouseMovementName, value); } public static Dictionary Screens { get { - Dictionary screens = new Dictionary(); + var screens = new Dictionary(); MultiScreenMode multiScreenMode = MultiScreen; for (int screenNumber = 0; screenNumber < ScreenCount; screenNumber++) { string screenKeyName = $"Display{screenNumber + 1}"; // To match tab name RegistryKey subKey = RootKey.GetOrCreateSubKey(screenKeyName); - ScreenInformation info = new ScreenInformation(subKey, screenNumber, multiScreenMode); + var info = new ScreenInformation(subKey, screenNumber, multiScreenMode); screens.Add(screenNumber, info); } return screens; } } - - #endregion } } \ No newline at end of file diff --git a/PreferencesForm.Designer.cs b/PreferencesForm.Designer.cs index 440fdea..7126be6 100644 --- a/PreferencesForm.Designer.cs +++ b/PreferencesForm.Designer.cs @@ -13,15 +13,13 @@ internal partial class PreferencesForm /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (_components != null)) + if (disposing && _components != null) { _components.Dispose(); } base.Dispose(disposing); } - #region Windows Form Designer generated code - /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. @@ -305,8 +303,6 @@ private void InitializeComponent() } - #endregion - private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMain; private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMainTop; diff --git a/PrefsByScreenUserControl.Designer.cs b/PrefsByScreenUserControl.Designer.cs index adb5653..f5f6a63 100644 --- a/PrefsByScreenUserControl.Designer.cs +++ b/PrefsByScreenUserControl.Designer.cs @@ -13,15 +13,13 @@ internal partial class PrefsByScreenUserControl /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (_components != null)) + if (disposing && _components != null) { _components.Dispose(); } base.Dispose(disposing); } - #region Component Designer generated code - /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. @@ -246,8 +244,6 @@ private void InitializeComponent() } - #endregion - private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMain; private System.Windows.Forms.TableLayoutPanel _tableLayoutPanelMainTop; diff --git a/PrefsByScreenUserControl.cs b/PrefsByScreenUserControl.cs index c825e8c..fa289dd 100644 --- a/PrefsByScreenUserControl.cs +++ b/PrefsByScreenUserControl.cs @@ -11,10 +11,15 @@ public PrefsByScreenUserControl() InitializeComponent(); } + /// + /// 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. + /// + /// The specific screen number for which these preferences must be saved. public void Save(int screenNumber) { ScreenInformation currentScreen = Preferences.Screens[screenNumber]; - currentScreen.UpdateURLs(from ListViewItem item in _listViewURLs.Items.Cast() select item.Text); + currentScreen.URLs = (from ListViewItem item in _listViewURLs.Items.Cast() select item.Text); currentScreen.RotationInterval = (int)_numericUpDownRotationInterval.Value; currentScreen.Shuffle = _checkBoxShuffle.Checked; } diff --git a/Program.cs b/Program.cs index cc4b72d..1157d9a 100644 --- a/Program.cs +++ b/Program.cs @@ -13,9 +13,7 @@ static class Program [STAThread] static void Main(string[] args) { - ProcessModule? mainModule = Process.GetCurrentProcess().MainModule; - - if (mainModule == null) + if (Process.GetCurrentProcess().MainModule is not ProcessModule) { throw new NullReferenceException("Current process main module is null."); } @@ -24,29 +22,47 @@ static void Main(string[] args) Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); // Prevents seeing tiny unexpected fonts - // Argument verification - More than 1 argument, or passing - // the wrong argument, will silently exit the program + // Argument verification: + // - The arguments /C, /P and /S are required by Windows Control Panel. + // - More than 1 argument, or passing the wrong argument, will exit the program - // No arguments is interpreted as "/C" - if (args.Length == 0) - { - Application.Run(new PreferencesForm()); - } - else if(args.Length == 1) + // Passing no arguments is interpreted as using "/C" + switch (args.Length) { - switch (args[0].ToUpperInvariant()) - { - case "/C": // Configure - Application.Run(new PreferencesForm()); - break; - case "/P": // Preview - case "/S": // Show - ShowScreenSaver(); - break; - } + case 0: + ShowPreferences(); + break; + + case 1: + switch (args[0].ToUpperInvariant()) + { + case "/C": // Configure + ShowPreferences(); + break; + case "/P": // Preview + case "/S": // Show + ShowScreenSaver(); + break; + default: + Console.WriteLine($"Unrecognized argument: {args[0]}"); + break; + } + break; + + default: + Console.WriteLine("Unexpected number of arguments."); + break; } } + /// + /// Show the screensaver preferences window. + /// + private static void ShowPreferences() + { + Application.Run(new PreferencesForm()); + } + /// /// Shows the screensaver form in all the screens. /// @@ -54,9 +70,9 @@ private static void ShowScreenSaver() { var forms = new List(); - foreach (KeyValuePair kvp in Preferences.Screens) + foreach ((int _, ScreenInformation info) in Preferences.Screens) { - var form = new ScreensaverForm(kvp.Value); + var form = new ScreensaverForm(info); forms.Add(form); } diff --git a/README.md b/README.md index 80adcfb..e3e71b5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Inspired by its predecesor [cwc/web-page-screensaver](https://github.com/cwc/web Version|32-bit|64-bit ---|---|--- -| 2.0.1-Alpha | Download | Download | +| 2.0.2-Alpha | Download | Download | _Due to 10MB size limit by GitHub (the generated files are ~130MB), need to find an alternative way to publish these._ _Workaround: Follow the [debugging instructions](#Debugging) and generate the files yourself._ @@ -21,19 +21,25 @@ _Workaround: Follow the [debugging instructions](#Debugging) and generate the fi * Right click the *.scr file. You have three options to choose from: * Select `Test` if you want to preview it in full screen. Note: Press ESC to exit the screensaver. * Select `Configure` to modify the screensaver settings. You should see this Window: - ![Screenshot](screenshot.png) + + ![Screenshot](screenshot.png) + * Select `Install` if you want it to be added to your list of Windows screensavers. The Windows `Screen Saver Settings` window will pop up with this screensaver selected. ## Dependencies Whether you are just installing it or building it, you need the following dependencies: -* .NET 5.0 Desktop Runtime for Windows (>= Preview 8): https://dotnet.microsoft.com/download/dotnet/5.0 +* .NET 5.0 (>= Preview 8) Desktop Runtime for Windows: https://dotnet.microsoft.com/download/dotnet/5.0 * Microsoft Edge Insider (Canary): https://www.microsoftedgeinsider.com/en-us/download/ -* Windows >= 7. +* Windows 10. ## Fixes and improvements +### 2.0.2-Alpha +* TFM is now targeting net5.0-windows (due to WinForms). +* Upgraded Microsoft.Web.WebView2 to 1.0.774.44. + ### 2.0.1-Alpha * Upgrade to .NET 5.0. * Use Edge (WebView2) instead of Internet Explorer. diff --git a/ScreenInformation.cs b/ScreenInformation.cs index b426f55..f77a977 100644 --- a/ScreenInformation.cs +++ b/ScreenInformation.cs @@ -10,26 +10,13 @@ namespace WebPageScreensaver { internal class ScreenInformation { - private struct SettingName - { - public const string ScreenNumber = "ScreenNumber"; - public const string Bounds = "Bounds"; - public const string IsPrimary = "IsPrimary"; - public const string URLs = "URLs"; - public const string RotationInterval = "IntervalRotation"; - public const string Shuffle = "Shuffle"; - } - private struct SettingDefaultValue - { - public const int RotationInterval = 10; - public const bool Shuffle = true; - public const string URLsPrimaryScreen = "https://dotnet.microsoft.com/ https://code.visualstudio.com/"; - } + private const string URLsName = "URLs"; + private const string RotationIntervalName = "IntervalRotation"; + private const string ShuffleName = "Shuffle"; public ScreenInformation(RegistryKey rootKey, int screenNumber, MultiScreenMode multiScreenMode) { RootKey = rootKey; - Bounds = multiScreenMode switch { MultiScreenMode.Span => FindEnclosingRectangle(), @@ -44,35 +31,27 @@ public ScreenInformation(RegistryKey rootKey, int screenNumber, MultiScreenMode public IEnumerable URLs { - get - { - string urlsString = RootKey.GetOrCreateValue(SettingName.URLs, SettingDefaultValue.URLsPrimaryScreen); - return urlsString.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); - } - } - - public void UpdateURLs(IEnumerable urls) - { - string urlsString = string.Join(' ', urls); - RootKey.SetValue(SettingName.URLs, urlsString); + get => RootKey + .GetOrCreateValue(URLsName, "https://dotnet.microsoft.com/ https://code.visualstudio.com/" /* default */) + .Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + set => RootKey.SetValue(URLsName, string.Join(' ', value)); } public int RotationInterval { - get => int.Parse(RootKey.GetOrCreateValue(SettingName.RotationInterval, SettingDefaultValue.RotationInterval)); - set => RootKey.SetValue(SettingName.RotationInterval, value); + get => int.Parse(RootKey.GetOrCreateValue(RotationIntervalName, 10 /* default */)); + set => RootKey.SetValue(RotationIntervalName, value); } public bool Shuffle { - get => bool.Parse(RootKey.GetOrCreateValue(SettingName.Shuffle, SettingDefaultValue.Shuffle)); - set => RootKey.SetValue(SettingName.Shuffle, value); + get => bool.Parse(RootKey.GetOrCreateValue(ShuffleName, true /* default */)); + set => RootKey.SetValue(ShuffleName, value); } private static Rectangle FindEnclosingRectangle() { IEnumerable bounds = Screen.AllScreens.Select(r => r.Bounds); - return Rectangle.FromLTRB( bounds.Min(r => r.Left), bounds.Min(r => r.Top), diff --git a/WebPageScreensaver.csproj b/WebPageScreensaver.csproj index 6db7ac1..d67e0c0 100644 --- a/WebPageScreensaver.csproj +++ b/WebPageScreensaver.csproj @@ -2,20 +2,20 @@ WinExe - net5.0 + net5.0-windows true enable WebPageScreensaver.Program WebPageScreensaver WebPageScreensaver - 2.0.1-Alpha + 2.0.2-Alpha true true x64;x86 - + diff --git a/WebPageScreensaver.sln b/WebPageScreensaver.sln index df364a4..992a734 100644 --- a/WebPageScreensaver.sln +++ b/WebPageScreensaver.sln @@ -7,20 +7,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebPageScreensaver", "WebPa EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|Any CPU.ActiveCfg = Debug|x86 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x64.ActiveCfg = Debug|x64 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x64.Build.0 = Debug|x64 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x86.ActiveCfg = Debug|x64 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Debug|x86.Build.0 = Debug|x64 - {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|Any CPU.ActiveCfg = Release|x86 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x64.ActiveCfg = Release|x64 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x64.Build.0 = Release|x64 {3E640398-E4D5-4AC8-A200-7AD96E7CC77F}.Release|x86.ActiveCfg = Release|x86