Files
BeWoPlaner/BeWo/MainWindow.xaml.cs

122 lines
3.9 KiB
C#

using System;
using System.ComponentModel;
using System.Threading;
using System.Windows;
using BeWo.Core.Config;
using BeWo.MultiLanguage;
using BeWo.ServiceProxy;
using BS.Shared.Translation;
using DevExpress.Xpf.Core;
namespace BeWo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ApplicationThemeHelper.ApplicationThemeName = "Office2010Black";
ShowLoginControl();
}
private void ShowLoginControl()
{
//WebRequest.DefaultWebProxy
//System.Net.WebRequest.GetSystemWebProxy()
var lc = new LoginControl();
rootGrid.Children.Add(lc);
lc.LoginSuccessful += lc_LoginSuccessful;
}
void lc_LoginSuccessful(object sender, EventArgs e)
{
Translator t = new Translator(new ServiceTranslator());
#if DEBUG
//if (BeWoApp.Tenant == "demo")
//{
// var dlg = new ConfirmDemoDialog();
// dlg.ShowDialog();
//}
#else
if (BeWoApp.Tenant == "demo" || BeWoApp.Tenant == "7514581436")
{
var dlg = new ConfirmDemoDialog();
dlg.ShowDialog();
}
#endif
rootGrid.Children.Clear();
MainControl mc = new MainControl();
mc.IsMaximized = BeWoApp.AppSettings.WindowState == AppSettings.WindowStateType.Maximised;
mc.LogoutClicked += new EventHandler(mc_LogoutClicked);
rootGrid.Children.Add(mc);
if (BeWoApp.AppSettings.ShowAI)
{
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiConfig(), null, null, false);
}
}
void mc_LogoutClicked(object sender, EventArgs e)
{
rootGrid.Children.Clear();
BeWoApp.MainControl = null;
ShowLoginControl();
}
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
{
if (BeWoApp.MainControl != null)
{
//BeWoApp.SaveAppSettings();
if (!BeWoApp.MainControl.DoSaveCheck())
{
e.Cancel = true;
return;
}
}
if(BeWoApp.MainControl != null && BeWoApp.MainControl.HomeView.ServiceChatView != null) {
if (BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl != null &&
BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.GlobalListeningThreadtimer != null)
{
BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.GlobalListeningThreadtimer.Stop();
BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.GlobalListeningThreadtimer = null;
//BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.disableKontaktNachrichtenThread = true;
}
if (BeWoApp.MainControl.HomeView.ServiceChatView.ServiceChat.EmojiView != null) {
BeWoApp.MainControl.HomeView.ServiceChatView.ServiceChat.EmojiView.Close();
BeWoApp.MainControl.HomeView.ServiceChatView.ServiceChat.EmojiView = null;
}
BeWoApp.MainControl.HomeView.ServiceChatView.Close();
BeWoApp.MainControl.HomeView.ServiceChatView = null;
}
BeWoApp.CurrentBeWo.DocumentWatcher.LoescheAlleTempDateien();
Application.Current.Shutdown();
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
#if DEBUG
// Setze den Titel auf die aktuelle Breite und Höhe
this.Title = $"BeWoPlaner ({e.NewSize.Width}x{e.NewSize.Height})";
#endif
}
}
}