} // Window_StateChanged private void NotifyIcon_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { m_NotifyIconMenu.IsOpen = !m_NotifyIconMenu.IsOpen; }else if (e.Button == System.Windows.Forms.MouseButtons.Left){ m_NotifyIconMenu.IsOpen = false; if (m_MiniPlayer != null){ m_MiniPlayer.Close(); m_MiniPlayer = null; } Show(); WindowState = m_StoredWindowState; Activate(); Focus(); m_NotifyIcon.Visible = false; } } // NotifyIcon_MouseDown
private void CloseHandler(object sender, CancelEventArgs e) { if (!m_Close && m_Settings.CloseToTray){ Hide(); if (m_NotifyIcon != null && !m_Close){ m_StoredWindowState = WindowState; m_NotifyIcon.BalloonTipText = "WpfMpdClient has been minimized. Click the tray icon to show."; m_NotifyIcon.BalloonTipTitle = "WpfMpdClient"; m_NotifyIcon.Visible = true; m_NotifyIcon.ShowBalloonTip(2000); if (m_Settings.ShowMiniPlayer){ if (m_MiniPlayer == null){ m_MiniPlayer = new MiniPlayerWindow(m_Mpc, m_Settings); if (m_Settings.MiniWindowLeft >= 0 && m_Settings.MiniWindowTop >= 0){ m_MiniPlayer.Left = m_Settings.MiniWindowLeft; m_MiniPlayer.Top = m_Settings.MiniWindowTop; } m_MiniPlayer.Update(m_LastStatus, m_CurrentTrack); } m_MiniPlayer.Show(); } } e.Cancel = true; } if (m_Close){ if (IsVisible) m_Settings.WindowMaximized = WindowState == System.Windows.WindowState.Maximized; else m_Settings.WindowMaximized = m_StoredWindowState == System.Windows.WindowState.Maximized; m_Settings.WindowLeft = Left; m_Settings.WindowTop = Top; m_Settings.WindowWidth = ActualWidth; m_Settings.WindowHeight = ActualHeight; m_Settings.TracksListView = lstTracks.GetColumnsInfo(); m_Settings.PlayListView = lstPlaylist.GetColumnsInfo(); m_Settings.Serialize(Settings.GetSettingsFileName()); m_LastfmScrobbler.SaveCache(); } } // CloseHandler