/* * Left click callback handler. Enables/disables, switches between icons. */ private void SystrayIcon_Click(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { // No device selected handling if (selectedPort == null) { MessageBox.Show("Please select a port.", "No port selected.", MessageBoxButtons.OK); } else { enabled = !enabled; // Icon switching if (enabled == true) { systrayIcon.Icon = Icon.FromHandle(Resources.SoundSamplerON.GetHicon()); } else { systrayIcon.Icon = Icon.FromHandle(Resources.SoundSamplerOFF.GetHicon()); } SamplerApp.SetEnabled(enabled); } } }