Minimize to tray on Alt+F4 window close
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
Loaded="Window_Loaded"
|
||||
Icon="Resources/icons/logo_CustomerPanel.ico"
|
||||
KeyDown="App_KeyDown"
|
||||
Closing="Window_Closing"
|
||||
Closed="Window_Closed"
|
||||
SizeChanged="Window_SizeChanged">
|
||||
<Window.Resources>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
@@ -71,6 +72,7 @@ namespace C4IT_CustomerPanel
|
||||
private TimeSpan _lastTicketInterval;
|
||||
private TimeSpan _lastAdHocInterval;
|
||||
private TimeSpan _lastRegularInterval;
|
||||
private bool _allowApplicationShutdown = false;
|
||||
internal DateTime lastUpdate;
|
||||
|
||||
//private Dictionary<announcementType, List<Guid>> announcementIDCollection = new Dictionary<announcementType, List<Guid>>();
|
||||
@@ -166,7 +168,7 @@ namespace C4IT_CustomerPanel
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
Application.Current.Shutdown();
|
||||
RequestApplicationShutdown();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
@@ -1056,12 +1058,18 @@ namespace C4IT_CustomerPanel
|
||||
Application.Current.MainWindow.Topmost = false;
|
||||
}
|
||||
|
||||
private void RequestApplicationShutdown()
|
||||
{
|
||||
_allowApplicationShutdown = true;
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void ChangeLang(string lang)
|
||||
{
|
||||
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
|
||||
|
||||
System.Windows.Forms.Application.Restart();
|
||||
Application.Current.Shutdown();
|
||||
RequestApplicationShutdown();
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
|
||||
@@ -1511,7 +1519,7 @@ namespace C4IT_CustomerPanel
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
RequestApplicationShutdown();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
@@ -1834,19 +1842,19 @@ namespace C4IT_CustomerPanel
|
||||
}
|
||||
}
|
||||
|
||||
public void Button_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is Button bu))
|
||||
return;
|
||||
|
||||
Color hoverColor = ConfigSettings.GetButtonHoverColor(ConfigSettings.GetBackgroundColor().Color);
|
||||
bu.Background = new SolidColorBrush(hoverColor);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
cLogManager.LogException(exp);
|
||||
public void Button_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is Button bu))
|
||||
return;
|
||||
|
||||
Color hoverColor = ConfigSettings.GetButtonHoverColor(ConfigSettings.GetBackgroundColor().Color);
|
||||
bu.Background = new SolidColorBrush(hoverColor);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
cLogManager.LogException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2073,6 +2081,15 @@ namespace C4IT_CustomerPanel
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (_allowApplicationShutdown)
|
||||
return;
|
||||
|
||||
e.Cancel = true;
|
||||
HideMainForm();
|
||||
}
|
||||
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
SetLocation();
|
||||
|
||||
Reference in New Issue
Block a user