diff --git a/VirtualDestopCycle/Form1.Designer.cs b/VirtualDestopCycle/Form1.Designer.cs index ee2ab39..0524953 100644 --- a/VirtualDestopCycle/Form1.Designer.cs +++ b/VirtualDestopCycle/Form1.Designer.cs @@ -57,6 +57,7 @@ private void InitializeComponent() this.notifyIcon1.Text = "Virtual Desktop Manager"; this.notifyIcon1.Visible = true; this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); + this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click); // // contextMenuStrip1 // diff --git a/VirtualDestopCycle/Form1.cs b/VirtualDestopCycle/Form1.cs index 1aa076c..aabfa30 100644 --- a/VirtualDestopCycle/Form1.cs +++ b/VirtualDestopCycle/Form1.cs @@ -34,6 +34,8 @@ public partial class Form1 : Form private bool useAltKeySettings; + private int previousDesktopIndex; + public Form1() { InitializeComponent(); @@ -82,7 +84,8 @@ private void NumberHotkeyPressed(object sender, KeyPressedEventArgs e) { return; } - + + previousDesktopIndex = currentDesktopIndex; desktops.ElementAt(index)?.Switch(); } @@ -287,6 +290,8 @@ VirtualDesktop initialDesktopState() void RightKeyManagerPressed(object sender, KeyPressedEventArgs e) { + previousDesktopIndex = getCurrentDesktopIndex(); + var desktop = initialDesktopState(); if(desktop.GetRight() != null) @@ -300,6 +305,8 @@ void RightKeyManagerPressed(object sender, KeyPressedEventArgs e) void LeftKeyManagerPressed(object sender, KeyPressedEventArgs e) { + previousDesktopIndex = getCurrentDesktopIndex(); + var desktop = initialDesktopState(); if (desktop.GetLeft() != null) @@ -326,9 +333,33 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e) private void notifyIcon1_DoubleClick(object sender, EventArgs e) { - openSettings(); + } + private void notifyIcon1_Click(object sender, EventArgs e) + { + var currentDesktopIndex = getCurrentDesktopIndex(); + MouseEventArgs me = (MouseEventArgs)e; + + if (me.Button == MouseButtons.Left) + { + if ( previousDesktopIndex > desktops.Count -1 ) + { + previousDesktopIndex = desktops.Count - 1; + + if (previousDesktopIndex == currentDesktopIndex) + { + previousDesktopIndex = 0; + } + } + if (previousDesktopIndex != currentDesktopIndex) + { + desktops.ElementAt(previousDesktopIndex)?.Switch(); + previousDesktopIndex = currentDesktopIndex; + } + } + } + private void upButton_Click(object sender, EventArgs e) { try