diff --git a/App.config b/App.config index 5ef77f1..332a430 100644 --- a/App.config +++ b/App.config @@ -10,6 +10,9 @@ True + + True + \ No newline at end of file diff --git a/NotificationAreaIcon.ico b/NotificationAreaIcon.ico deleted file mode 100644 index 5d06b9f..0000000 Binary files a/NotificationAreaIcon.ico and /dev/null differ diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 466807d..9145df4 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -60,6 +60,26 @@ internal Resources() { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon AltClampFalse { + get { + object obj = ResourceManager.GetObject("AltClampFalse", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon AltClampTrue { + get { + object obj = ResourceManager.GetObject("AltClampTrue", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index b9d5cf1..490df85 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -118,6 +118,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\AltClampFalse.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\AltClampTrue.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\ClampFalse.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 71fb320..1a1a7d3 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -34,5 +34,17 @@ public bool ClampedToScreen { this["ClampedToScreen"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool AltIcon { + get { + return ((bool)(this["AltIcon"])); + } + set { + this["AltIcon"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index c09191c..1630517 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -5,5 +5,8 @@ True + + True + \ No newline at end of file diff --git a/Resources/AltClampFalse.ico b/Resources/AltClampFalse.ico new file mode 100644 index 0000000..d147f31 Binary files /dev/null and b/Resources/AltClampFalse.ico differ diff --git a/Resources/AltClampTrue.ico b/Resources/AltClampTrue.ico new file mode 100644 index 0000000..5766e01 Binary files /dev/null and b/Resources/AltClampTrue.ico differ diff --git a/WindowTool 128x128.ico b/WindowTool 128x128.ico new file mode 100644 index 0000000..ec80157 Binary files /dev/null and b/WindowTool 128x128.ico differ diff --git a/WindowTool.csproj b/WindowTool.csproj index 7d74c68..0822ac9 100644 --- a/WindowTool.csproj +++ b/WindowTool.csproj @@ -4,6 +4,7 @@ WinExe netcoreapp3.1 true + WindowTool 128x128.ico @@ -14,6 +15,10 @@ none + + + + True @@ -35,13 +40,16 @@ - - PreserveNewest - SettingsSingleFileGenerator Settings.Designer.cs + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/mainForm.Designer.cs b/mainForm.Designer.cs index ff615f0..ee54c17 100644 --- a/mainForm.Designer.cs +++ b/mainForm.Designer.cs @@ -28,95 +28,99 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.mainMenuStrip = new System.Windows.Forms.MenuStrip(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); - this.notifyMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); - this.settingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.clampMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exitMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.mainMenuStrip.SuspendLayout(); - this.notifyMenuStrip.SuspendLayout(); - this.SuspendLayout(); + mainMenuStrip = new System.Windows.Forms.MenuStrip(); + aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + notifyIcon = new System.Windows.Forms.NotifyIcon(components); + notifyMenuStrip = new System.Windows.Forms.ContextMenuStrip(components); + settingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + clampMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + iconMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + exitMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + mainMenuStrip.SuspendLayout(); + notifyMenuStrip.SuspendLayout(); + SuspendLayout(); // // mainMenuStrip // - this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.aboutToolStripMenuItem}); - this.mainMenuStrip.Location = new System.Drawing.Point(0, 0); - this.mainMenuStrip.Name = "mainMenuStrip"; - this.mainMenuStrip.Size = new System.Drawing.Size(620, 24); - this.mainMenuStrip.TabIndex = 0; - this.mainMenuStrip.Text = "menuStrip1"; + mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { aboutToolStripMenuItem }); + mainMenuStrip.Location = new System.Drawing.Point(0, 0); + mainMenuStrip.Name = "mainMenuStrip"; + mainMenuStrip.Size = new System.Drawing.Size(620, 24); + mainMenuStrip.TabIndex = 0; + mainMenuStrip.Text = "menuStrip1"; // // aboutToolStripMenuItem // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20); - this.aboutToolStripMenuItem.Text = "About"; + aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20); + aboutToolStripMenuItem.Text = "About"; // // notifyIcon // - this.notifyIcon.ContextMenuStrip = this.notifyMenuStrip; - this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon"))); - this.notifyIcon.Text = "Window Tool"; - this.notifyIcon.Visible = true; - this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick); + notifyIcon.ContextMenuStrip = notifyMenuStrip; + notifyIcon.Icon = (System.Drawing.Icon)resources.GetObject("notifyIcon.Icon"); + notifyIcon.Text = "Window Tool"; + notifyIcon.Visible = true; + notifyIcon.MouseDoubleClick += notifyIcon_MouseDoubleClick; // // notifyMenuStrip // - this.notifyMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.settingsMenuItem, - this.clampMenuItem, - this.exitMenuItem}); - this.notifyMenuStrip.Name = "notifyMenuStrip"; - this.notifyMenuStrip.Size = new System.Drawing.Size(161, 70); + notifyMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { settingsMenuItem, clampMenuItem, iconMenuItem, exitMenuItem }); + notifyMenuStrip.Name = "notifyMenuStrip"; + notifyMenuStrip.Size = new System.Drawing.Size(161, 92); // // settingsMenuItem // - this.settingsMenuItem.Name = "settingsMenuItem"; - this.settingsMenuItem.Size = new System.Drawing.Size(160, 22); - this.settingsMenuItem.Text = "Settings"; - this.settingsMenuItem.Visible = false; - this.settingsMenuItem.Click += new System.EventHandler(this.settingsMenuItem_Click); + settingsMenuItem.Name = "settingsMenuItem"; + settingsMenuItem.Size = new System.Drawing.Size(160, 22); + settingsMenuItem.Text = "Settings"; + settingsMenuItem.Visible = false; + settingsMenuItem.Click += settingsMenuItem_Click; // // clampMenuItem // - this.clampMenuItem.CheckOnClick = true; - this.clampMenuItem.Name = "clampMenuItem"; - this.clampMenuItem.Size = new System.Drawing.Size(160, 22); - this.clampMenuItem.Text = "Clamp to screen"; - this.clampMenuItem.Click += new System.EventHandler(this.clampMenuItem_Click); + clampMenuItem.CheckOnClick = true; + clampMenuItem.Name = "clampMenuItem"; + clampMenuItem.Size = new System.Drawing.Size(160, 22); + clampMenuItem.Text = "Clamp to screen"; + clampMenuItem.Click += clampMenuItem_Click; + // + // iconMenuItem + // + iconMenuItem.CheckOnClick = true; + iconMenuItem.Name = "iconMenuItem"; + iconMenuItem.Size = new System.Drawing.Size(160, 22); + iconMenuItem.Text = "Alternate icon"; + iconMenuItem.Click += iconMenuItem_Click; // // exitMenuItem // - this.exitMenuItem.Name = "exitMenuItem"; - this.exitMenuItem.Size = new System.Drawing.Size(160, 22); - this.exitMenuItem.Text = "Exit"; - this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click); + exitMenuItem.Name = "exitMenuItem"; + exitMenuItem.Size = new System.Drawing.Size(160, 22); + exitMenuItem.Text = "Exit"; + exitMenuItem.Click += exitMenuItem_Click; // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(620, 406); - this.Controls.Add(this.mainMenuStrip); - this.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.MainMenuStrip = this.mainMenuStrip; - this.Margin = new System.Windows.Forms.Padding(5); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "MainForm"; - this.Text = "WindowTool"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.mainForm_FormClosing); - this.mainMenuStrip.ResumeLayout(false); - this.mainMenuStrip.PerformLayout(); - this.notifyMenuStrip.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new System.Drawing.SizeF(11F, 25F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(620, 406); + Controls.Add(mainMenuStrip); + Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + MainMenuStrip = mainMenuStrip; + Margin = new System.Windows.Forms.Padding(5); + MaximizeBox = false; + MinimizeBox = false; + Name = "MainForm"; + Text = "WindowTool"; + FormClosing += mainForm_FormClosing; + mainMenuStrip.ResumeLayout(false); + mainMenuStrip.PerformLayout(); + notifyMenuStrip.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -128,5 +132,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem exitMenuItem; private System.Windows.Forms.ToolStripMenuItem settingsMenuItem; private System.Windows.Forms.ToolStripMenuItem clampMenuItem; + private System.Windows.Forms.ToolStripMenuItem iconMenuItem; } } diff --git a/mainForm.cs b/mainForm.cs index 70bd26d..b8c3d98 100644 --- a/mainForm.cs +++ b/mainForm.cs @@ -19,12 +19,13 @@ public partial class MainForm : Form public MainForm() { InitializeComponent(); - + hotkeyHandler = new HotkeyHandler(); hotkeyHandler.Start(); Application.ApplicationExit += Application_ApplicationExit; + iconMenuItem.Checked = Properties.Settings.Default.AltIcon; bool isClamped = Properties.Settings.Default.ClampedToScreen; handleSetClampToScreen(isClamped); @@ -79,6 +80,10 @@ private void clampMenuItem_Click(object sender, EventArgs e) { handleSetClampToScreen(clampMenuItem.Checked); } + private void iconMenuItem_Click(object sender, EventArgs e) + { + updateIcon(); + } private void handleSetClampToScreen(bool isClamped) { @@ -86,15 +91,36 @@ private void handleSetClampToScreen(bool isClamped) Properties.Settings.Default.Save(); clampMenuItem.Checked = isClamped; hotkeyHandler.SetClampToScreen(isClamped); + updateIcon(); + /* if (isClamped) { - notifyIcon.Icon = WindowTool.Properties.Resources.ClampTrue; + notifyIcon.Icon = iconMenuItem.Checked ? Properties.Resources.ClampTrue : Properties.Resources.AltClampTrue; + //notifyIcon.Icon = WindowTool.Properties.Resources.AltClampTrue; + } + else + { + notifyIcon.Icon = iconMenuItem.Checked ? Properties.Resources.ClampFalse : Properties.Resources.AltClampFalse; + //notifyIcon.Icon = WindowTool.Properties.Resources.AltClampFalse; + } + */ + } + + private void updateIcon() + { + Properties.Settings.Default.AltIcon = iconMenuItem.Checked; + Properties.Settings.Default.Save(); + + if (clampMenuItem.Checked) + { + notifyIcon.Icon = iconMenuItem.Checked ? Properties.Resources.AltClampTrue : Properties.Resources.ClampTrue; } else { - notifyIcon.Icon = WindowTool.Properties.Resources.ClampFalse; + notifyIcon.Icon = iconMenuItem.Checked ? Properties.Resources.AltClampFalse : Properties.Resources.ClampFalse; } } + } }