Remove Tabs when disconnect
This commit is contained in:
@@ -125,7 +125,7 @@ namespace DoctorApp.Utils
|
||||
this.MainViewModel.NewConnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes));
|
||||
break;
|
||||
case DataParser.DISCONNECT:
|
||||
this.MainViewModel.NewConnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes));
|
||||
this.MainViewModel.DisconnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes));
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DoctorApp.ViewModels
|
||||
{
|
||||
class MainViewModel : ObservableObject
|
||||
{
|
||||
public ObservableCollection<object> Tabs { get; set; }
|
||||
public ObservableCollection<ClientInfoViewModel> Tabs { get; set; }
|
||||
public int Selected { get; set; }
|
||||
public MainWindowViewModel MainWindowViewModel { get; set; }
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace DoctorApp.ViewModels
|
||||
{
|
||||
this.MainWindowViewModel = mainWindowViewModel;
|
||||
client = this.MainWindowViewModel.client;
|
||||
Tabs= new ObservableCollection<object>();
|
||||
Tabs= new ObservableCollection<ClientInfoViewModel>();
|
||||
}
|
||||
|
||||
public void NewConnectedUser(string username)
|
||||
@@ -37,7 +37,17 @@ namespace DoctorApp.ViewModels
|
||||
|
||||
public void DisconnectedUser(string username)
|
||||
{
|
||||
|
||||
App.Current.Dispatcher.Invoke((Action)delegate
|
||||
{
|
||||
foreach (ClientInfoViewModel item in Tabs)
|
||||
{
|
||||
if (item.Username == username)
|
||||
{
|
||||
Tabs.Remove(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<Grid>
|
||||
<TabControl ItemsSource="{Binding Tabs}" SelectedItem="{Binding Selected}">
|
||||
<TabControl TabStripPlacement="Left" ItemsSource="{Binding Tabs}" SelectedItem="{Binding Selected}">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding TabName}"/>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
Title="MainWindow" Height="450" Width="800"
|
||||
WindowState="Maximized">
|
||||
<Grid>
|
||||
<ContentControl HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding SelectedViewModel}" Focusable="False" />
|
||||
<ContentControl Content="{Binding SelectedViewModel}" Focusable="False" />
|
||||
<Label Content="gemaakt door: mensen" DockPanel.Dock="Bottom" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontStyle="Italic" Foreground="Gray"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user