Code fertig Kommentiert
Kommentare hinzugefügt wo sie noch gefehlt haben
This commit is contained in:
parent
d9976ff520
commit
f9d5053029
@ -9,40 +9,44 @@ namespace bib_talk.Business
|
|||||||
{
|
{
|
||||||
public class LoginManager
|
public class LoginManager
|
||||||
{
|
{
|
||||||
private LoginDatabase loginDatabase;
|
private LoginDatabase loginDatabase; // LoginDatabase Objekt initialisieren
|
||||||
|
|
||||||
|
// Konstruktor für den LoginManager
|
||||||
public LoginManager(Login loginWindow)
|
public LoginManager(Login loginWindow)
|
||||||
{
|
{
|
||||||
loginDatabase = new LoginDatabase(loginWindow);
|
loginDatabase = new LoginDatabase(loginWindow); // LoginDatabase Objekt deklarieren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum User einloggen via LoginDatabase
|
||||||
public async void Login()
|
public async void Login()
|
||||||
{
|
{
|
||||||
await loginDatabase.LoginServer();
|
await loginDatabase.LoginServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LoginBots(string username, string password)
|
// DEBUG METHODE
|
||||||
{
|
// Methode um Bots einzuloggen
|
||||||
var loginData = new { Username = username, Password = password, Email = "", Birthday = "", IsOnline = "" };
|
//public async Task LoginBots(string username, string password)
|
||||||
string json = JsonConvert.SerializeObject(loginData);
|
//{
|
||||||
|
// var loginData = new { Username = username, Password = password, Email = "", Birthday = "", IsOnline = "" };
|
||||||
|
// string json = JsonConvert.SerializeObject(loginData);
|
||||||
|
|
||||||
using (var client = new HttpClient())
|
// using (var client = new HttpClient())
|
||||||
{
|
// {
|
||||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
// var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/login", content);
|
// var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/login", content);
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
// if (response.IsSuccessStatusCode)
|
||||||
{
|
// {
|
||||||
var responseContent = await response.Content.ReadAsStringAsync();
|
// var responseContent = await response.Content.ReadAsStringAsync();
|
||||||
var responseData = JsonConvert.DeserializeObject<dynamic>(responseContent);
|
// var responseData = JsonConvert.DeserializeObject<dynamic>(responseContent);
|
||||||
|
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var responseContent = await response.Content.ReadAsStringAsync();
|
// var responseContent = await response.Content.ReadAsStringAsync();
|
||||||
MessageBox.Show($"Login failed: {responseContent}");
|
// MessageBox.Show($"Login failed: {responseContent}");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,40 +5,41 @@ namespace bib_talk.Business
|
|||||||
{
|
{
|
||||||
public class MainWindowManager
|
public class MainWindowManager
|
||||||
{
|
{
|
||||||
private MainWindowDatabase mwDatabase;
|
private MainWindowDatabase mwDatabase; //MainWindowDatabase initializeren
|
||||||
private string loggedinUser;
|
private string loggedInUser; // Feld um eingeloggten User zu speichern
|
||||||
|
|
||||||
public MainWindowManager(MainWindow mainWindow)
|
|
||||||
{
|
|
||||||
mwDatabase = new MainWindowDatabase(mainWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Konstruktor für MainWindowManager mit MainWindow und User Referenz
|
||||||
public MainWindowManager(MainWindow mainWindow, string user)
|
public MainWindowManager(MainWindow mainWindow, string user)
|
||||||
{
|
{
|
||||||
mwDatabase = new MainWindowDatabase(mainWindow, user);
|
mwDatabase = new MainWindowDatabase(mainWindow, user);
|
||||||
loggedinUser = user;
|
loggedInUser = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Senden einer Nachricht via Datenbankmanager
|
||||||
public void SendMessage()
|
public void SendMessage()
|
||||||
{
|
{
|
||||||
mwDatabase.SendMessage();
|
mwDatabase.SendMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Laden der Nachrichten via Datenbankmanager
|
||||||
public void LoadMessages()
|
public void LoadMessages()
|
||||||
{
|
{
|
||||||
mwDatabase.LoadMessages();
|
mwDatabase.LoadMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Laden der Online Benutzer via Datenbankmanager
|
||||||
public void LoadOnlineUsers()
|
public void LoadOnlineUsers()
|
||||||
{
|
{
|
||||||
mwDatabase.LoadOnlineUsers();
|
mwDatabase.LoadOnlineUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Ausloggen des Users via Datenbankmanager
|
||||||
public void LogoutUser()
|
public void LogoutUser()
|
||||||
{
|
{
|
||||||
mwDatabase.LogoutUser();
|
mwDatabase.LogoutUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Hochladen eines Profilbildes via Datenbankmanager
|
||||||
public async Task UploadProfileImage(string filePath)
|
public async Task UploadProfileImage(string filePath)
|
||||||
{
|
{
|
||||||
await mwDatabase.UploadProfileImage(filePath);
|
await mwDatabase.UploadProfileImage(filePath);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace bib_talk.Business
|
namespace bib_talk.Business
|
||||||
{
|
{
|
||||||
|
// Klasse um die Nachrichten in der Datenbank zu speichern
|
||||||
public class Message
|
public class Message
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace bib_talk.Business
|
namespace bib_talk.Business
|
||||||
{
|
{
|
||||||
|
// Klasse damit die Nachrichten in der App benutzt werden können
|
||||||
public class MessageDto
|
public class MessageDto
|
||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
@ -8,18 +8,23 @@ namespace bib_talk.Business
|
|||||||
{
|
{
|
||||||
public class RegisterManager
|
public class RegisterManager
|
||||||
{
|
{
|
||||||
private RegisterDatabase registerDatabase;
|
private RegisterDatabase registerDatabase; // RegisterDatabase Objekt initialisieren
|
||||||
|
|
||||||
|
// Konstruktor für den RegisterManager
|
||||||
public RegisterManager(RegisterWindow registerWindow)
|
public RegisterManager(RegisterWindow registerWindow)
|
||||||
{
|
{
|
||||||
registerDatabase = new RegisterDatabase(registerWindow);
|
registerDatabase = new RegisterDatabase(registerWindow); // RegisterDatabase Objekt deklarieren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um einen neuen Nutzer zu Registrieren via der RegisterDatabase
|
||||||
public async void RegisterServer()
|
public async void RegisterServer()
|
||||||
{
|
{
|
||||||
await registerDatabase.RegisterServer();
|
await registerDatabase.RegisterServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DEBUG METHODE
|
||||||
|
// Methode um einen Bot Nutzer auf der Datenbank anzulegen
|
||||||
public async void RegisterBots(string username, string password, string email, string birthday)
|
public async void RegisterBots(string username, string password, string email, string birthday)
|
||||||
{
|
{
|
||||||
var newUser = new { Username = username, Password = password, Email = email, Birthday = birthday, IsOnline = "" };
|
var newUser = new { Username = username, Password = password, Email = email, Birthday = birthday, IsOnline = "" };
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
namespace bib_talk.Business
|
namespace bib_talk.Business
|
||||||
{
|
{
|
||||||
|
// User Klasse mit den Eigenschaften Id, Username, Password,
|
||||||
|
// Email, Birthday, IsOnline und ProfileImagePath
|
||||||
|
// um diese in der App zu Benutzen und in der Datenbank zu speichern
|
||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@ -8,13 +8,15 @@ namespace bib_talk.Repository
|
|||||||
{
|
{
|
||||||
public class LoginDatabase
|
public class LoginDatabase
|
||||||
{
|
{
|
||||||
Login loginWindow;
|
Login loginWindow; // Login Window initialisieren
|
||||||
|
|
||||||
|
// Konstruker der LoginDatabase
|
||||||
public LoginDatabase(Login loginWindow)
|
public LoginDatabase(Login loginWindow)
|
||||||
{
|
{
|
||||||
this.loginWindow = loginWindow;
|
this.loginWindow = loginWindow; // Login Window deklarieren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um den User einzuloggen via eines Server aufrufs
|
||||||
public async Task LoginServer()
|
public async Task LoginServer()
|
||||||
{
|
{
|
||||||
string username = loginWindow.usernbox.Text;
|
string username = loginWindow.usernbox.Text;
|
||||||
|
@ -12,28 +12,25 @@ namespace bib_talk.Repository
|
|||||||
{
|
{
|
||||||
public class MainWindowDatabase
|
public class MainWindowDatabase
|
||||||
{
|
{
|
||||||
private MainWindow mainWindow;
|
private MainWindow mainWindow; // MainWindow initialisieren
|
||||||
private string loggedinUser;
|
private string loggedinUser; // Feld um eingeloggten User zu speichern
|
||||||
|
|
||||||
public MainWindowDatabase(MainWindow mainWindow)
|
|
||||||
{
|
|
||||||
this.mainWindow = mainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Konstruktor für MainWindowDatabase mit MainWindow und User Referenz
|
||||||
public MainWindowDatabase(MainWindow mainWindow, string user)
|
public MainWindowDatabase(MainWindow mainWindow, string user)
|
||||||
{
|
{
|
||||||
this.mainWindow = mainWindow;
|
this.mainWindow = mainWindow;
|
||||||
loggedinUser = user;
|
loggedinUser = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Senden einer Nachricht via Datenbank
|
||||||
public async void SendMessage()
|
public async void SendMessage()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(mainWindow.messageBOX.Text))
|
if (!string.IsNullOrEmpty(mainWindow.messageBox.Text))
|
||||||
{
|
{
|
||||||
var message = new MessageDto
|
var message = new MessageDto
|
||||||
{
|
{
|
||||||
Username = mainWindow.loggedinUser,
|
Username = mainWindow.loggedinUser,
|
||||||
Message = mainWindow.messageBOX.Text,
|
Message = mainWindow.messageBox.Text,
|
||||||
Timestamp = DateTime.Now,
|
Timestamp = DateTime.Now,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,13 +42,14 @@ namespace bib_talk.Repository
|
|||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
mainWindow.messageBOX.Clear();
|
mainWindow.messageBox.Clear();
|
||||||
LoadMessages(); // Reload messages after sending
|
LoadMessages(); // Reload messages after sending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Laden der Nachrichten via Datenbank
|
||||||
public async void LoadMessages()
|
public async void LoadMessages()
|
||||||
{
|
{
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
@ -71,6 +69,7 @@ namespace bib_talk.Repository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Laden der Online Benutzer via Datenbank
|
||||||
public async void LoadOnlineUsers()
|
public async void LoadOnlineUsers()
|
||||||
{
|
{
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
@ -88,6 +87,7 @@ namespace bib_talk.Repository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Ausloggen des Users via Datenbank
|
||||||
public async void LogoutUser()
|
public async void LogoutUser()
|
||||||
{
|
{
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
@ -104,6 +104,7 @@ namespace bib_talk.Repository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Hochladen eines Profilbildes via Datenbank
|
||||||
public async Task UploadProfileImage(string filePath)
|
public async Task UploadProfileImage(string filePath)
|
||||||
{
|
{
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
|
@ -8,13 +8,16 @@ namespace bib_talk.Repository
|
|||||||
{
|
{
|
||||||
public class RegisterDatabase
|
public class RegisterDatabase
|
||||||
{
|
{
|
||||||
RegisterWindow registerWindow;
|
RegisterWindow registerWindow; // RegisterWindow initailisieren
|
||||||
|
|
||||||
|
// Konstruktor für die RegisterDatabase
|
||||||
public RegisterDatabase(RegisterWindow registerWindow)
|
public RegisterDatabase(RegisterWindow registerWindow)
|
||||||
{
|
{
|
||||||
this.registerWindow = registerWindow;
|
this.registerWindow = registerWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um einen Nutzer zu registrieren und die Daten
|
||||||
|
// in die Datenbank zu schreiben
|
||||||
public async Task RegisterServer()
|
public async Task RegisterServer()
|
||||||
{
|
{
|
||||||
string username = registerWindow.usernbox.Text;
|
string username = registerWindow.usernbox.Text;
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
Margin="0,30,0,0"
|
Margin="0,30,0,0"
|
||||||
Background="#FF323134"
|
Background="#FF323134"
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
SelectionBrush="#FF6332A0" KeyDown="usernbox_KeyDown"/>
|
SelectionBrush="#FF6332A0" KeyDown="userNameBox_KeyDown"/>
|
||||||
|
|
||||||
<!-- Benutzername TextBox -->
|
<!-- Benutzername TextBox -->
|
||||||
<TextBlock Text="Passwort"
|
<TextBlock Text="Passwort"
|
||||||
@ -124,8 +124,8 @@
|
|||||||
FontSize="12"
|
FontSize="12"
|
||||||
Width="136"
|
Width="136"
|
||||||
Margin="20,20,0,0"/>
|
Margin="20,20,0,0"/>
|
||||||
<Button Style="{StaticResource InvisibleButtonStyle}" Click="Register_Click">
|
<Button x:Name="RegisterButton" Style="{StaticResource InvisibleButtonStyle}" Click="Register_Click">
|
||||||
<TextBlock Text="Registrieren"
|
<TextBlock x:Name="RegisterTextBlock" Text="Registrieren"
|
||||||
Foreground="#FF6332A0"
|
Foreground="#FF6332A0"
|
||||||
FontSize="12"
|
FontSize="12"
|
||||||
Width="66"
|
Width="66"
|
||||||
|
@ -11,16 +11,17 @@ namespace bib_talk
|
|||||||
{
|
{
|
||||||
LoginManager loginManager;
|
LoginManager loginManager;
|
||||||
|
|
||||||
// Field to store logged in user
|
public static string loggedInUser; // Feld um eingeloggten User zu speichern
|
||||||
public static string loggedInUser;
|
|
||||||
|
|
||||||
public Login()
|
// Konstruktor für das Login Fenster
|
||||||
|
public Login()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
loginManager = new LoginManager(this);
|
loginManager = new LoginManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode für Custom Draggable Area
|
||||||
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ButtonState == MouseButtonState.Pressed)
|
if (e.ButtonState == MouseButtonState.Pressed)
|
||||||
@ -29,18 +30,13 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um das Fenster zu schließen
|
||||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
// Methode um den User einzuloggen
|
||||||
{
|
|
||||||
RegisterWindow register = new RegisterWindow();
|
|
||||||
register.Show();
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
|
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (usernbox.Text != "" && passwordbox.Password != "")
|
if (usernbox.Text != "" && passwordbox.Password != "")
|
||||||
@ -49,6 +45,7 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um den Weiter Button zu Aktivieren, wenn ein Nutzername und Passwort eingegeben ist
|
||||||
private void passwordbox_PasswordChanged(object sender, RoutedEventArgs e)
|
private void passwordbox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (usernbox.Text != "" && passwordbox.Password != "")
|
if (usernbox.Text != "" && passwordbox.Password != "")
|
||||||
@ -65,13 +62,16 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um das Registrierungs Fenster zu öffnen
|
||||||
private void Register_Click(object sender, RoutedEventArgs e)
|
private void Register_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RegisterWindow register = new RegisterWindow();
|
RegisterWindow register = new RegisterWindow();
|
||||||
register.Show();
|
register.Show();
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
private void usernbox_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
|
// Methode um via der Enter Taste zum nächsten Feld zu springen
|
||||||
|
private void userNameBox_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
@ -79,6 +79,7 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um via der Enter Taste den User einzuloggen
|
||||||
private void passwordbox_KeyDown(object sender, KeyEventArgs e)
|
private void passwordbox_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
@ -90,18 +91,20 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoginBotUser(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
// for (int i = 1; i <= 100; i++)
|
|
||||||
// {
|
|
||||||
// string name = "Bot";
|
|
||||||
// string password = "Bot123";
|
|
||||||
// loginManager.LoginBots(name + i, password);
|
|
||||||
// Thread.Sleep(1000);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
// Debug Methode um 100 Bot User einzuloggen
|
||||||
|
// Man fügt die Methode einem Button hinzu und ruft sie als Button Click Event auf
|
||||||
}
|
|
||||||
|
//private void LoginBotUser(object sender, RoutedEventArgs e)
|
||||||
|
//{
|
||||||
|
// for (int i = 1; i <= 100; i++)
|
||||||
|
// {
|
||||||
|
// string name = "Bot";
|
||||||
|
// string password = "Bot123";
|
||||||
|
// loginManager.LoginBots(name + i, password);
|
||||||
|
// Thread.Sleep(1000);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@
|
|||||||
Margin="10,61,10,10"
|
Margin="10,61,10,10"
|
||||||
Background="#FF6332A0"
|
Background="#FF6332A0"
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
SelectionBrush="#FF6332A0" KeyDown="messageBOX_KeyDown" RenderTransformOrigin="0.5,0.5">
|
SelectionBrush="#FF6332A0" KeyDown="messageBox_KeyDown" RenderTransformOrigin="0.5,0.5">
|
||||||
<TextBox.RenderTransform>
|
<TextBox.RenderTransform>
|
||||||
<TransformGroup>
|
<TransformGroup>
|
||||||
<ScaleTransform ScaleX="-1" ScaleY="-1"/>
|
<ScaleTransform ScaleX="-1" ScaleY="-1"/>
|
||||||
@ -147,7 +147,7 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<TextBlock HorizontalAlignment="Left" x:Name="loggedinuser" Margin="0,-3,0,0" TextWrapping="Wrap" Text="xxxx" VerticalAlignment="Top" Height="20" Width="184" Foreground="White" RenderTransformOrigin="0.6,0.591"/>
|
<TextBlock HorizontalAlignment="Left" x:Name="loggedInUser" Margin="0,-3,0,0" TextWrapping="Wrap" Text="xxxx" VerticalAlignment="Top" Height="20" Width="184" Foreground="White" RenderTransformOrigin="0.6,0.591"/>
|
||||||
<ListBox x:Name="chatlistbox" Margin="298,112,0,50" d:ItemsSource="{d:SampleData ItemCount=5}" Background="#FF323134" BorderBrush="{x:Null}" Foreground="#FF6332A0" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Grid.ColumnSpan="4" Grid.RowSpan="2">
|
<ListBox x:Name="chatlistbox" Margin="298,112,0,50" d:ItemsSource="{d:SampleData ItemCount=5}" Background="#FF323134" BorderBrush="{x:Null}" Foreground="#FF6332A0" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Grid.ColumnSpan="4" Grid.RowSpan="2">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@ -165,13 +165,13 @@
|
|||||||
</ListBox>
|
</ListBox>
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="messageBOX"
|
x:Name="messageBox"
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
BorderBrush="Transparent"
|
BorderBrush="Transparent"
|
||||||
Margin="298,346,76,0"
|
Margin="298,346,76,0"
|
||||||
Background="#FF323134"
|
Background="#FF323134"
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
SelectionBrush="#FF6332A0" KeyDown="messageBOX_KeyDown" Grid.ColumnSpan="4" Grid.Row="1"/>
|
SelectionBrush="#FF6332A0" KeyDown="messageBox_KeyDown" Grid.ColumnSpan="4" Grid.Row="1"/>
|
||||||
<Button x:Name="weiterbutton" Click="send_Click" Content="Weiter" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="44,346,10,0" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633" Grid.Column="3" Grid.Row="1"/>
|
<Button x:Name="weiterbutton" Click="send_Click" Content="Weiter" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="44,346,10,0" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633" Grid.Column="3" Grid.Row="1"/>
|
||||||
<Button x:Name="uplaodpb" Click="uploadpbclick" Content="Upload" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="10,351,574,5" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633" Grid.Row="1"/>
|
<Button x:Name="uplaodpb" Click="uploadpbclick" Content="Upload" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="10,351,574,5" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633" Grid.Row="1"/>
|
||||||
|
|
||||||
|
@ -9,21 +9,13 @@ namespace bib_talk
|
|||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
MainWindowManager mwManager;
|
MainWindowManager mwManager; // MainWindowManager initializeren
|
||||||
|
|
||||||
private DispatcherTimer _timer;
|
private DispatcherTimer _timer; // DispatcherTimer initialisieren
|
||||||
public string loggedinUser;
|
public string loggedinUser; // Feld um eingeloggten User zu speichern
|
||||||
private bool isFirstLoad = true;
|
private bool isFirstLoad = true;
|
||||||
|
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
InitializeTimer();
|
|
||||||
LoadData();
|
|
||||||
|
|
||||||
mwManager = new MainWindowManager(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// MainWindow Konstruktor mit einem User und LoadMessages Methode
|
||||||
public MainWindow(string user)
|
public MainWindow(string user)
|
||||||
{
|
{
|
||||||
loggedinUser = user;
|
loggedinUser = user;
|
||||||
@ -36,6 +28,7 @@ namespace bib_talk
|
|||||||
mwManager.LoadMessages();
|
mwManager.LoadMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Der 3 Sekunden Timer für die Nachrichten und Online Benutzer
|
||||||
private void InitializeTimer()
|
private void InitializeTimer()
|
||||||
{
|
{
|
||||||
_timer = new DispatcherTimer
|
_timer = new DispatcherTimer
|
||||||
@ -45,17 +38,21 @@ namespace bib_talk
|
|||||||
_timer.Tick += (sender, e) => { mwManager.LoadMessages(); mwManager.LoadOnlineUsers(); };
|
_timer.Tick += (sender, e) => { mwManager.LoadMessages(); mwManager.LoadOnlineUsers(); };
|
||||||
_timer.Start();
|
_timer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum Usernamen in dem MainWindow anzeigen
|
||||||
public void LoadData()
|
public void LoadData()
|
||||||
{
|
{
|
||||||
loggedinuser.Text = "Logged in as: " + loggedinUser;
|
loggedInUser.Text = "Logged in as: " + loggedinUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode zum User ausloggen und App schließen
|
||||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
mwManager.LogoutUser();
|
mwManager.LogoutUser();
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom DraggableArea für das MainWindow
|
||||||
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ButtonState == MouseButtonState.Pressed)
|
if (e.ButtonState == MouseButtonState.Pressed)
|
||||||
@ -64,7 +61,8 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void messageBOX_KeyDown(object sender, KeyEventArgs e)
|
// Hotkey (Enter) für das Senden einer Nachricht
|
||||||
|
private async void messageBox_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
@ -72,12 +70,15 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Senden Button für das Senden einer Nachricht
|
||||||
private async void send_Click(object sender, RoutedEventArgs e)
|
private async void send_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
mwManager.SendMessage();
|
mwManager.SendMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChatFenster_Click(object sender, RoutedEventArgs e)
|
// temporäre Methoden, löschen wenn karl nichts gemacht hat
|
||||||
|
#region Temporär, Karl
|
||||||
|
private void ChatFenster_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (popup.IsOpen = true)
|
if (popup.IsOpen = true)
|
||||||
{
|
{
|
||||||
@ -116,8 +117,10 @@ namespace bib_talk
|
|||||||
{
|
{
|
||||||
popup.IsOpen = false;
|
popup.IsOpen = false;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private async void uploadpbclick(object sender, RoutedEventArgs e)
|
// Methode zum Profilbilder hochladen
|
||||||
|
private async void uploadpbclick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png, *.gif) | *.jpg; *.jpeg; *.png; *.gif";
|
openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png, *.gif) | *.jpg; *.jpeg; *.png; *.gif";
|
||||||
|
@ -95,9 +95,6 @@
|
|||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Hyperlink">
|
|
||||||
<EventSetter Event="RequestNavigate" Handler="Hyperlink_RequestNavigate"/>
|
|
||||||
</Style>
|
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Border CornerRadius="15" BorderThickness="20" BorderBrush="#FF282828">
|
<Border CornerRadius="15" BorderThickness="20" BorderBrush="#FF282828">
|
||||||
|
@ -13,26 +13,23 @@ namespace bib_talk
|
|||||||
{
|
{
|
||||||
public partial class RegisterWindow : Window
|
public partial class RegisterWindow : Window
|
||||||
{
|
{
|
||||||
RegisterManager registerManager;
|
RegisterManager registerManager; // RegisterManager Objekt initialisieren
|
||||||
|
|
||||||
|
// Konstruktor für das RegisterWindow
|
||||||
public RegisterWindow()
|
public RegisterWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
registerManager = new RegisterManager(this);
|
registerManager = new RegisterManager(this); // RegisterManager Objekt erstellen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
// Methode für das Schließen des Fensters
|
||||||
{
|
|
||||||
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true });
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode für die Custom Draggable Area
|
||||||
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ButtonState == MouseButtonState.Pressed)
|
if (e.ButtonState == MouseButtonState.Pressed)
|
||||||
@ -41,6 +38,7 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um das Login Window aufzurufen
|
||||||
private void Login_Click(object sender, RoutedEventArgs e)
|
private void Login_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Login login = new Login();
|
Login login = new Login();
|
||||||
@ -48,6 +46,7 @@ namespace bib_talk
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um das Registrieren abzuschließen und das Login Window aufzurufen
|
||||||
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
|
private async void WeiterButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (checkboxAGB.IsChecked == true)
|
if (checkboxAGB.IsChecked == true)
|
||||||
@ -68,6 +67,8 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um den Weiter Button zu aktivieren, wenn die "Nutzungsbedingungen"
|
||||||
|
// akzeptiert wurden
|
||||||
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6332A0"));
|
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6332A0"));
|
||||||
@ -75,6 +76,8 @@ namespace bib_talk
|
|||||||
weiterbutton.Background = customBrush;
|
weiterbutton.Background = customBrush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um den Weiter Button zu deaktivieren, wenn die "Nutzungsbedingungen"
|
||||||
|
// abgelehnt wurden
|
||||||
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
|
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF323134"));
|
SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF323134"));
|
||||||
@ -82,6 +85,7 @@ namespace bib_talk
|
|||||||
weiterbutton.Background = customBrush;
|
weiterbutton.Background = customBrush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um die Eingaben des Benutzers zu validieren
|
||||||
private bool ValidateRegistration()
|
private bool ValidateRegistration()
|
||||||
{
|
{
|
||||||
string username = usernbox.Text;
|
string username = usernbox.Text;
|
||||||
@ -122,6 +126,8 @@ namespace bib_talk
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um via den Enter Key zum nächsten Textfeld zu springen
|
||||||
private void emailbox_KeyDown(object sender, KeyEventArgs e)
|
private void emailbox_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
@ -129,6 +135,8 @@ namespace bib_talk
|
|||||||
usernbox.Focus();
|
usernbox.Focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Methode um via den Enter Key zum nächsten Textfeld zu springen
|
||||||
private void usernbox_KeyDown(object sender, KeyEventArgs e)
|
private void usernbox_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
@ -137,14 +145,17 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void passwordbox_KeyDown(object sender, KeyEventArgs e)
|
// Methode um via den Enter Key zum nächsten Textfeld zu springen
|
||||||
|
private void passwordbox_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
bday1.Focus();
|
bday1.Focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void bday1_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
|
// Methode um via den Enter Key zum nächsten Textfeld zu springen
|
||||||
|
private void bday1_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
@ -152,7 +163,8 @@ namespace bib_talk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bday2_KeyDown(object sender, KeyEventArgs e)
|
// Methode um via den Enter Key zum nächsten Textfeld zu springen
|
||||||
|
private void bday2_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user