Files
BeWoPlaner/BeWo/MainWindow.xaml.cs
Rene Evertz 6f0c28a7c7 Not Finished
Translation into SharedLauncher.csproj
Uninstall
2024-06-03 11:58:46 +02:00

162 lines
5.1 KiB
C#

using System;
using System.ComponentModel;
using System.Threading;
using System.Windows;
using BeWo.Core.Config;
using BeWo.MultiLanguage;
using BS.SharedLauncher.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";
if (Loader.Loaded)
ShowNewWay();
else
ShowOldWay(false);
//throw new Exception("Loader failed");
}
private void ShowNewWay()
{
Translator t = new Translator(new ServiceTranslator());
//WebRequest.DefaultWebProxy
//System.Net.WebRequest.GetSystemWebProxy()
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);
}
private void ShowOldWay(bool skiplogin)
{
if (skiplogin)
{
throw new NotImplementedException("47845978233134");
// Muss hier ggf string anpassen
//Loader.Load("tedemo?undemo?pwdemo?ip?sn1?cs?vr1.0.4.1");
//ShowNewWay();
}
else
{
//WebRequest.DefaultWebProxy
//System.Net.WebRequest.GetSystemWebProxy()
var lc = new LoginControl();
rootGrid.Children.Add(lc);
lc.LoginSuccessful += lc_LoginSuccessful;
}
}
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")
{
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);
}
void mc_LogoutClicked(object sender, EventArgs e)
{
rootGrid.Children.Clear();
BeWoApp.MainControl = null;
if(Loader.Loaded)
Application.Current.Shutdown(100);
else
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.LoescheTempDateien();
Application.Current.Shutdown();
}
private void Window_SourceInitialized(object sender, EventArgs e)
{
Console.WriteLine("GUI geladen");
Thread.Sleep(500);
}
}
}