Connect new tab

This commit is contained in:
fabjuuuh
2020-10-07 14:56:04 +02:00
parent aea1b4fce4
commit acbe3e9d55
8 changed files with 59 additions and 29 deletions

View File

@@ -18,10 +18,12 @@ namespace DokterApp
private IHandler handler = null;
private string username;
private string password;
private Del callback;
public Client(string adress, int port, string username, string password)
public Client(string adress, int port, string username, string password, Del callback)
{
this.callback = callback;
this.username = username;
this.password = password;
this.client = new TcpClient();
@@ -82,8 +84,9 @@ namespace DokterApp
}
else
{
callback("yeet");
Console.WriteLine($"login failed \"{responseStatus}\"");
tryLogin();
//tryLogin();
}
break;
case DataParser.START_SESSION:
@@ -173,14 +176,6 @@ namespace DokterApp
private void tryLogin()
{
//TODO File in lezen
/*Console.WriteLine("enter username");
string username = Console.ReadLine();
Console.WriteLine("enter password");
string password = Console.ReadLine();*/
string hashUser = Hashing.Hasher.HashString(username);
string hashPassword = Hashing.Hasher.HashString(password);

View File

@@ -17,7 +17,7 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.ColumnSpan="2" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0" Orientation="Vertical">
<Label Content="Yo dokter login" Margin="0,0,0,20" HorizontalAlignment="Center"/>
<Label x:Name="Label" Content="Yo dokter login" Margin="0,0,0,20" HorizontalAlignment="Center"/>
<Label Content="Username" HorizontalContentAlignment="Center"/>
<TextBox x:Name="Username" TextWrapping="Wrap" Width="120"/>
<Label Content="Password" HorizontalContentAlignment="Center"/>

View File

@@ -20,6 +20,7 @@ namespace DokterApp
/// </summary>
public partial class MainWindow : Window
{
Del handler;
Client client;
public MainWindow()
{
@@ -27,18 +28,27 @@ namespace DokterApp
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
}
private void Login_Click_1(object sender, RoutedEventArgs e)
{
WindowTabs windowTabs = new WindowTabs();
handler = windowTabs.NewTab;
this.Label.Content = "Waiting";
this.client = new Client("localhost", 5555, this.Username.Text, this.Password.Text, handler);
while (!client.IsConnected())
{
}
windowTabs.Show();
this.client = new Client("localhost", 5555, this.Username.Text, this.Password.Text);
this.Close();
}
}
public delegate void Del(string message);
}

View File

@@ -31,14 +31,23 @@ namespace DokterApp
private void Button_Click(object sender, RoutedEventArgs e)
{
TabItem newTabItem = new TabItem
{
Header = "Test",
Width = 110,
Height = 40
};
newTabItem.Content = new UserControlForTab();
this.tbControl.Items.Add(newTabItem);
NewTab("Test");
}
public void NewTab(string username)
{
Application.Current.Dispatcher.Invoke((Action)delegate {
// your code
TabItem newTabItem = new TabItem
{
Header = username,
Width = 110,
Height = 40
};
newTabItem.Content = new UserControlForTab();
this.tbControl.Items.Add(newTabItem);
});
}
}
}