2024-07-01 16:21:03 +02:00
|
|
|
|
using bib_talk.Repository;
|
2024-07-02 22:40:43 +02:00
|
|
|
|
using Microsoft.Win32;
|
2024-07-01 16:21:03 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
2024-07-02 22:40:43 +02:00
|
|
|
|
using System.IO;
|
2024-07-01 16:21:03 +02:00
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Threading;
|
2024-07-03 15:58:51 +02:00
|
|
|
|
using bib_talk.Business;
|
2024-07-01 16:21:03 +02:00
|
|
|
|
|
|
|
|
|
namespace bib_talk
|
|
|
|
|
{
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
2024-07-03 15:58:51 +02:00
|
|
|
|
MainWindowManager mwManager;
|
2024-07-01 16:21:03 +02:00
|
|
|
|
|
|
|
|
|
private DispatcherTimer _timer;
|
|
|
|
|
public string loggedinUser;
|
|
|
|
|
private bool isFirstLoad = true;
|
2024-07-02 22:40:43 +02:00
|
|
|
|
|
2024-07-01 16:21:03 +02:00
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeTimer();
|
|
|
|
|
LoadData();
|
|
|
|
|
|
2024-07-03 15:58:51 +02:00
|
|
|
|
mwManager = new MainWindowManager(this);
|
2024-07-01 16:21:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MainWindow(string user)
|
|
|
|
|
{
|
|
|
|
|
loggedinUser = user;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeTimer();
|
|
|
|
|
LoadData();
|
|
|
|
|
|
2024-07-03 15:58:51 +02:00
|
|
|
|
mwManager = new MainWindowManager(this, user);
|
2024-07-01 16:21:03 +02:00
|
|
|
|
|
2024-07-03 15:58:51 +02:00
|
|
|
|
mwManager.LoadMessages();
|
2024-07-01 16:21:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeTimer()
|
|
|
|
|
{
|
|
|
|
|
_timer = new DispatcherTimer
|
|
|
|
|
{
|
|
|
|
|
Interval = TimeSpan.FromSeconds(2)
|
|
|
|
|
};
|
2024-07-03 15:58:51 +02:00
|
|
|
|
_timer.Tick += (sender, e) => { mwManager.LoadMessages(); mwManager.LoadOnlineUsers(); };
|
2024-07-01 16:21:03 +02:00
|
|
|
|
_timer.Start();
|
|
|
|
|
}
|
|
|
|
|
public void LoadData()
|
|
|
|
|
{
|
|
|
|
|
loggedinuser.Text = "Logged in as: " + loggedinUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2024-07-03 15:58:51 +02:00
|
|
|
|
mwManager.LogoutUser();
|
2024-07-01 16:21:03 +02:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ButtonState == MouseButtonState.Pressed)
|
|
|
|
|
{
|
|
|
|
|
DragMove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void messageBOX_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Key == Key.Enter)
|
|
|
|
|
{
|
2024-07-03 15:58:51 +02:00
|
|
|
|
mwManager.SendMessage();
|
2024-07-01 16:21:03 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void send_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2024-07-03 15:58:51 +02:00
|
|
|
|
mwManager.SendMessage();
|
2024-07-01 16:21:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ChatFenster_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (popup.IsOpen = true)
|
|
|
|
|
{
|
|
|
|
|
popup.Focus();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
popup.IsOpen = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void Button1_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Button 1 wurde geklickt!");
|
|
|
|
|
ClosePopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button2_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Button 2 wurde geklickt!");
|
|
|
|
|
ClosePopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button3_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Button 3 wurde geklickt!");
|
|
|
|
|
ClosePopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Popup_LostFocus(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ClosePopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClosePopup()
|
|
|
|
|
{
|
|
|
|
|
popup.IsOpen = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-14 14:31:45 +02:00
|
|
|
|
//private void onlineUsersListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
//{
|
2024-07-01 16:21:03 +02:00
|
|
|
|
|
2024-08-14 14:31:45 +02:00
|
|
|
|
//}
|
2024-07-02 22:40:43 +02:00
|
|
|
|
private async void uploadpbclick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
|
|
openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png, *.gif) | *.jpg; *.jpeg; *.png; *.gif";
|
|
|
|
|
if (openFileDialog.ShowDialog() == true)
|
|
|
|
|
{
|
|
|
|
|
string filePath = openFileDialog.FileName;
|
2024-07-03 15:58:51 +02:00
|
|
|
|
await mwManager.UploadProfileImage(filePath);
|
2024-07-02 22:40:43 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-01 16:21:03 +02:00
|
|
|
|
}
|
|
|
|
|
}
|