From b6c899238917984ac8b29b966f5a20e51aba3bc8 Mon Sep 17 00:00:00 2001 From: shapoco <40152459+shapoco@users.noreply.github.com> Date: Thu, 1 Dec 2022 16:11:57 +0900 Subject: [PATCH] #17 add always-on-top button --- Calctus.csproj | 3 ++ Calctus/UI/MainForm.Designer.cs | 53 +++++++++++++++++++----------- Calctus/UI/MainForm.cs | 12 +++++++ Properties/Resources.Designer.cs | 22 ++++++++++++- Properties/Resources.resx | 6 ++++ Resources/ToolIcon_TopMostOff.png | Bin 0 -> 276 bytes Resources/ToolIcon_TopMostOn.png | Bin 0 -> 225 bytes 7 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 Resources/ToolIcon_TopMostOff.png create mode 100644 Resources/ToolIcon_TopMostOn.png diff --git a/Calctus.csproj b/Calctus.csproj index 0c02962..89c1947 100644 --- a/Calctus.csproj +++ b/Calctus.csproj @@ -155,6 +155,9 @@ + + + diff --git a/Calctus/UI/MainForm.Designer.cs b/Calctus/UI/MainForm.Designer.cs index 18c3931..adf8d1e 100644 --- a/Calctus/UI/MainForm.Designer.cs +++ b/Calctus/UI/MainForm.Designer.cs @@ -32,8 +32,7 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.toolStrip = new System.Windows.Forms.ToolStrip(); - this.helpButton = new System.Windows.Forms.ToolStripButton(); - this.settingsButton = new System.Windows.Forms.ToolStripButton(); + this.topMostButton = new System.Windows.Forms.ToolStripButton(); this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.trayMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextOpen = new System.Windows.Forms.ToolStripMenuItem(); @@ -45,6 +44,8 @@ private void InitializeComponent() this.radixDecButton = new Shapoco.Calctus.UI.FlatRadioButton(); this.radixAutoButton = new Shapoco.Calctus.UI.FlatRadioButton(); this.calcListBox = new Shapoco.Calctus.UI.CalcListBox(); + this.helpButton = new System.Windows.Forms.ToolStripButton(); + this.settingsButton = new System.Windows.Forms.ToolStripButton(); this.toolStrip.SuspendLayout(); this.trayMenuStrip.SuspendLayout(); this.panel2.SuspendLayout(); @@ -54,6 +55,7 @@ private void InitializeComponent() // this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.helpButton, + this.topMostButton, this.settingsButton}); this.toolStrip.Location = new System.Drawing.Point(0, 0); this.toolStrip.Name = "toolStrip"; @@ -61,25 +63,15 @@ private void InitializeComponent() this.toolStrip.TabIndex = 4; this.toolStrip.Text = "toolStrip1"; // - // helpButton + // topMostButton // - this.helpButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.helpButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.helpButton.Image = global::Shapoco.Properties.Resources.ToolIcon_Help; - this.helpButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.helpButton.Name = "helpButton"; - this.helpButton.Size = new System.Drawing.Size(23, 22); - this.helpButton.Text = "Help"; - // - // settingsButton - // - this.settingsButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.settingsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.settingsButton.Image = global::Shapoco.Properties.Resources.ToolIcon_Settings; - this.settingsButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.settingsButton.Name = "settingsButton"; - this.settingsButton.Size = new System.Drawing.Size(23, 22); - this.settingsButton.Text = "Settings"; + this.topMostButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.topMostButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.topMostButton.Image = global::Shapoco.Properties.Resources.ToolIcon_TopMostOff; + this.topMostButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.topMostButton.Name = "topMostButton"; + this.topMostButton.Size = new System.Drawing.Size(23, 22); + this.topMostButton.Text = "Always on top"; // // notifyIcon // @@ -188,6 +180,26 @@ private void InitializeComponent() this.calcListBox.TabIndex = 7; this.calcListBox.Text = "calcListBox1"; // + // helpButton + // + this.helpButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.helpButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.helpButton.Image = global::Shapoco.Properties.Resources.ToolIcon_Help; + this.helpButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.helpButton.Name = "helpButton"; + this.helpButton.Size = new System.Drawing.Size(23, 22); + this.helpButton.Text = "Help"; + // + // settingsButton + // + this.settingsButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.settingsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.settingsButton.Image = global::Shapoco.Properties.Resources.ToolIcon_Settings; + this.settingsButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.settingsButton.Name = "settingsButton"; + this.settingsButton.Size = new System.Drawing.Size(23, 22); + this.settingsButton.Text = "Settings"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -225,6 +237,7 @@ private void InitializeComponent() private FlatRadioButton radixDecButton; private FlatRadioButton radixAutoButton; private CalcListBox calcListBox; + private System.Windows.Forms.ToolStripButton topMostButton; } } diff --git a/Calctus/UI/MainForm.cs b/Calctus/UI/MainForm.cs index 16d838a..92db754 100644 --- a/Calctus/UI/MainForm.cs +++ b/Calctus/UI/MainForm.cs @@ -54,6 +54,7 @@ public MainForm() { radixAutoButton.Checked = true; settingsButton.Click += (sender, e) => { new SettingsDialog().ShowDialog(); reloadSettings(); }; + topMostButton.Click += TopMostButton_Click; helpButton.Click += (sender, e) => { System.Diagnostics.Process.Start(@"https://github.com/shapoco/calctus"); }; contextOpen.Click += (sender, e) => { showForeground(); }; @@ -147,6 +148,17 @@ private void disableHotkey() { } } + private void TopMostButton_Click(object sender, EventArgs e) { + var btn = (ToolStripButton)sender; + this.TopMost = !this.TopMost; + if (this.TopMost) { + btn.Image = Properties.Resources.ToolIcon_TopMostOn; + } + else { + btn.Image = Properties.Resources.ToolIcon_TopMostOff; + } + } + private void NotifyIcon_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { showForeground(); diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 8c2892a..ffe537b 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Shapoco.Properties { // または Visual Studio のようなツールを使用して自動生成されました。 // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -79,5 +79,25 @@ internal static System.Drawing.Bitmap ToolIcon_Settings { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// 型 System.Drawing.Bitmap のローカライズされたリソースを検索します。 + /// + internal static System.Drawing.Bitmap ToolIcon_TopMostOff { + get { + object obj = ResourceManager.GetObject("ToolIcon_TopMostOff", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 型 System.Drawing.Bitmap のローカライズされたリソースを検索します。 + /// + internal static System.Drawing.Bitmap ToolIcon_TopMostOn { + get { + object obj = ResourceManager.GetObject("ToolIcon_TopMostOn", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 260bf8a..8984548 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -124,4 +124,10 @@ ..\Resources\ToolIcon_Settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ToolIcon_TopMostOff.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ToolIcon_TopMostOn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/ToolIcon_TopMostOff.png b/Resources/ToolIcon_TopMostOff.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe7a0865e0bc79d32025ae87752f24fdd44cdf0 GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GGLLkg|>2BR0prCY# zYeY$Kep*R+Vo@rCb81d;WwAnVNoh)EzCuWTe$K(=4{LzR=6kw0hFF}wI{6@PvjLB* zyl{w4gMf4i(C)o)-v zH)*3vCHqaLO{@=?&%C_HR66VIb+ag~5(j0gq618OyhAR`Tk`HeJ;N1!om|!jSz!-l TH9YPBoyy?p>gTe~DWM4f)VN|d literal 0 HcmV?d00001 diff --git a/Resources/ToolIcon_TopMostOn.png b/Resources/ToolIcon_TopMostOn.png new file mode 100644 index 0000000000000000000000000000000000000000..7dca328b1338bf37ab8e4d96d8f379b5e20d95e6 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GGLLkg|>2BR0prCY# zYeY$Kep*R+Vo@rCb81d;WwAnVNoh)EzCuWTe$K(=4{LzRay(reLo808o#@Edpuoej z{Qsoc|AqcP<^9(x&L41Vg`iNi;@t}`)3le0gp@XEWzLdhXkgLtI_>ZxgYQ6*(z3ac z4ZIy*-3R`Oe9&ah-u*i1hvfS<>k|bIa}P(c&TM>qR&