Skip to content

Commit

Permalink
#17 add always-on-top button
Browse files Browse the repository at this point in the history
  • Loading branch information
shapoco committed Dec 1, 2022
1 parent 9a8d178 commit b6c8992
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Calctus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<None Include="Resources\ToolIcon_TopMostOn.png" />
<None Include="Resources\ToolIcon_TopMostOff.png" />
<None Include="Resources\ToolIcon_TopMost.png" />
<None Include="Resources\ToolIcon_Help.png" />
<None Include="materials\tool_settings.png" />
<None Include="Resources\ToolIcon_Settings.png" />
Expand Down
53 changes: 33 additions & 20 deletions Calctus/UI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Calctus/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(); };
Expand Down Expand Up @@ -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();
Expand Down
22 changes: 21 additions & 1 deletion Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@
<data name="ToolIcon_Settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ToolIcon_Settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ToolIcon_TopMostOff" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ToolIcon_TopMostOff.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ToolIcon_TopMostOn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ToolIcon_TopMostOn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added Resources/ToolIcon_TopMostOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/ToolIcon_TopMostOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b6c8992

Please sign in to comment.