Skip to content

Commit

Permalink
Close to tray - WIP for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
prayerie committed Jul 5, 2023
1 parent fba3d37 commit 47114f1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions JpLayoutFixer/mainform.Designer.cs

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

22 changes: 22 additions & 0 deletions JpLayoutFixer/mainform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial class mainform : Form {
private Dictionary<string, string> layoutsDict = new Dictionary<string, string>();
private string currentLblMsg = string.Empty;
private string currentLblMsgJp = string.Empty;
private Boolean reallyClosing = false;

public mainform() {
InitializeComponent();
Expand All @@ -32,6 +33,27 @@ public mainform() {
LoadCurrentJpLayout();
SelectCurrentLayout();
LocaliseComponents();

this.FormClosing += (s, e) =>
{
if (!reallyClosing) {
e.Cancel = true;
this.Hide();
}
};

chJpLfTrayIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);

var closeMenuItem = new MenuItem("Quit", (s, e) =>
{
reallyClosing = true;
Application.Exit();
});

chJpLfTrayIcon.ContextMenu = new ContextMenu(new MenuItem[] { closeMenuItem });

chJpLfTrayIcon.Visible = true;

}

private async Task CheckForUpdates() {
Expand Down
3 changes: 3 additions & 0 deletions JpLayoutFixer/mainform.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="chJpLfTrayIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down

0 comments on commit 47114f1

Please sign in to comment.