Files
Chat/PrototypChat/MainWindow.xaml.cs

66 lines
1.8 KiB
C#
Raw Normal View History

2017-09-12 14:32:34 +02:00
using System;
using System.Threading;
2017-09-12 14:32:34 +02:00
using System.Windows;
2019-04-04 13:00:10 +02:00
using ChatController.LoginKlassen;
2017-09-12 14:32:34 +02:00
using Point = System.Windows.Point;
2017-09-15 16:39:07 +02:00
namespace ownChat
2017-09-12 14:32:34 +02:00
{
2019-04-02 13:43:30 +02:00
public partial class MainWindow
2017-09-12 14:32:34 +02:00
{
2019-04-02 13:43:30 +02:00
private readonly ChatEmojisView _EmojiView;
2017-09-12 14:32:34 +02:00
2017-09-12 14:32:34 +02:00
public MainWindow(ChatDatenUebergabe x)
{
InitializeComponent();
2023-03-03 21:23:48 +01:00
var currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += ExceptionHandler;
ChatMainControl.ContainingWindow = this;
2017-09-12 14:32:34 +02:00
ChatMainControl.InitMitChatdaten(x);
2017-10-06 12:08:05 +02:00
2019-04-02 13:43:30 +02:00
_EmojiView = new ChatEmojisView(ChatMainControl);
2017-09-12 14:32:34 +02:00
}
2023-03-03 21:23:48 +01:00
private void ExceptionHandler(object sender, UnhandledExceptionEventArgs args)
{
var exception = (Exception)args.ExceptionObject;
new ExceptionWindow(exception) { Owner = this }.Show();
}
2017-09-12 14:32:34 +02:00
private void ChatMainControl_OnOnEmojii(System.Windows.Controls.Button emojiButton)
{
2019-04-02 13:43:30 +02:00
_EmojiView.Visibility = Visibility.Visible;
2017-09-12 14:32:34 +02:00
2019-04-02 13:43:30 +02:00
var pointToScreen = emojiButton.PointToScreen(new Point(0, 0));
var presentationSource = PresentationSource.FromVisual(emojiButton);
2017-09-12 14:32:34 +02:00
2023-03-03 21:23:48 +01:00
if(presentationSource?.CompositionTarget == null)
2017-09-12 14:32:34 +02:00
{
2023-03-03 21:23:48 +01:00
return;
2017-09-12 14:32:34 +02:00
}
2023-03-03 21:23:48 +01:00
_EmojiView.Top = pointToScreen.Y / presentationSource.CompositionTarget.TransformToDevice.M22 - _EmojiView.Height - 5;
_EmojiView.Left = pointToScreen.X / presentationSource.CompositionTarget.TransformToDevice.M11 - 270;
2017-09-12 14:32:34 +02:00
}
private void MainWindow_OnClosed(object sender, EventArgs e)
{
ChatMainControl.DeleteTempFiles();
ChatMainControl.WriteToNewSyncFile();
ChatMainControl.ClearNotifications();
Thread.Sleep(500);
2017-10-24 12:44:15 +02:00
Environment.Exit(0);
}
2017-09-12 14:32:34 +02:00
}
}