private void Window_StateChanged(object sender, EventArgs e) { if (this.WindowState == WindowState.Minimized) { this.Hide(); _notifyIcon.Visible = true; } else { _windowState = this.WindowState; } }