#115, version 0.11.1.11

[Feature] Show icon in taskbar when application is running #115
This commit is contained in:
Markus Hofknecht 2020-06-28 15:17:23 +02:00
parent c140284f2a
commit 1052dbb01c
5 changed files with 30 additions and 20 deletions

View file

@ -36,21 +36,22 @@ namespace SystemTrayMenu
menuNotifyIcon.OpenLog += Log.OpenLogFile; menuNotifyIcon.OpenLog += Log.OpenLogFile;
menus.MainPreload(); menus.MainPreload();
taskbarForm.Deactivate += TasbkarItemDeactivated;
taskbarForm.Activated += TasbkarItemActivated; taskbarForm.Activated += TasbkarItemActivated;
taskbarForm.Resize += TaskbarForm_Resize;
taskbarForm.Show(); taskbarForm.Show();
} }
internal void TasbkarItemDeactivated(object sender, EventArgs e) private void TaskbarForm_Resize(object sender, EventArgs e)
{ {
TaskbarForm taskbarForm = (TaskbarForm)sender; if (taskbarForm.WindowState == FormWindowState.Minimized)
taskbarForm.WindowState = FormWindowState.Minimized; {
taskbarForm.WindowState = FormWindowState.Normal;
}
} }
internal void TasbkarItemActivated(object sender, EventArgs e) internal void TasbkarItemActivated(object sender, EventArgs e)
{ {
TaskbarForm taskbarForm = (TaskbarForm)sender; taskbarForm.Activate();
taskbarForm.WindowState = FormWindowState.Minimized;
taskbarForm.Focus(); taskbarForm.Focus();
menus.SwitchOpenCloseByTaskbarItem(); menus.SwitchOpenCloseByTaskbarItem();
} }

View file

@ -710,7 +710,8 @@ namespace SystemTrayMenu.Business
private static bool IsActive() private static bool IsActive()
{ {
return Form.ActiveForm is Menu; return Form.ActiveForm is Menu ||
Form.ActiveForm is UserInterface.TaskbarForm;
} }
private void MenusFadeOut() private void MenusFadeOut()

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.1.10")] [assembly: AssemblyVersion("0.11.1.11")]
[assembly: AssemblyFileVersion("0.11.1.10")] [assembly: AssemblyFileVersion("0.11.1.11")]

View file

@ -36,14 +36,14 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(50, 50); this.ClientSize = new System.Drawing.Size(120, 0);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "TaskbarForm"; this.Name = "TaskbarForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "STM"; this.Text = "STM";
this.TransparencyKey = System.Drawing.Color.White; this.LocationChanged += new System.EventHandler(this.TaskbarForm_LocationChanged);
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View file

@ -8,14 +8,22 @@ namespace SystemTrayMenu.UserInterface
public TaskbarForm() public TaskbarForm()
{ {
InitializeComponent(); InitializeComponent();
SetLocation();
//Hide the form under the taskbar of primary screen }
private void TaskbarForm_LocationChanged(object sender, System.EventArgs e)
{
SetLocation();
}
private void SetLocation()
{
Screen screen = Screen.PrimaryScreen; Screen screen = Screen.PrimaryScreen;
Location = new Point(screen.Bounds.Right - 155, Location = new Point(screen.Bounds.Right - Size.Width,
screen.Bounds.Bottom); //we could show behind taskbar?
//This would be above of taskbar //screen.Bounds.Bottom- Size.Height);
//Location = new Point(screen.Bounds.Right - 155, //but at the moment we dont want to see this
// screen.Bounds.Bottom - Height - 65); screen.Bounds.Bottom); // - Size.Height);
} }
} }
} }