65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
|
|
using ChatController.LoginKlassen;
|
|
|
|
using Point = System.Windows.Point;
|
|
|
|
|
|
namespace ownChat
|
|
{
|
|
public partial class MainWindow
|
|
{
|
|
private readonly ChatEmojisView _EmojiView;
|
|
|
|
public MainWindow(ChatDatenUebergabe x)
|
|
{
|
|
InitializeComponent();
|
|
|
|
var currentDomain = AppDomain.CurrentDomain;
|
|
currentDomain.UnhandledException += ExceptionHandler;
|
|
|
|
ChatMainControl.ContainingWindow = this;
|
|
|
|
ChatMainControl.InitMitChatdaten(x);
|
|
|
|
_EmojiView = new ChatEmojisView(ChatMainControl);
|
|
}
|
|
|
|
private void ExceptionHandler(object sender, UnhandledExceptionEventArgs args)
|
|
{
|
|
var exception = (Exception)args.ExceptionObject;
|
|
|
|
new ExceptionWindow(exception) { Owner = this }.Show();
|
|
}
|
|
|
|
private void ChatMainControl_OnOnEmojii(System.Windows.Controls.Button emojiButton)
|
|
{
|
|
_EmojiView.Visibility = Visibility.Visible;
|
|
|
|
var pointToScreen = emojiButton.PointToScreen(new Point(0, 0));
|
|
var presentationSource = PresentationSource.FromVisual(emojiButton);
|
|
|
|
if(presentationSource?.CompositionTarget == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_EmojiView.Top = pointToScreen.Y / presentationSource.CompositionTarget.TransformToDevice.M22 - _EmojiView.Height - 5;
|
|
_EmojiView.Left = pointToScreen.X / presentationSource.CompositionTarget.TransformToDevice.M11 - 270;
|
|
}
|
|
|
|
private void MainWindow_OnClosed(object sender, EventArgs e)
|
|
{
|
|
ChatMainControl.DeleteTempFiles();
|
|
ChatMainControl.WriteToNewSyncFile();
|
|
ChatMainControl.ClearNotifications();
|
|
|
|
Thread.Sleep(500);
|
|
|
|
Environment.Exit(0);
|
|
}
|
|
}
|
|
}
|