[
ADD] added message sending to all clients, doesn't work yet
This commit is contained in:
@@ -43,12 +43,14 @@ namespace DoctorApp.ViewModels
|
||||
|
||||
public MainWindowViewModel MainWindowViewModel { get; set; }
|
||||
private Client client;
|
||||
private MainViewModel parent;
|
||||
|
||||
public Chart Chart { get; set; }
|
||||
|
||||
public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel, string username)
|
||||
public ClientInfoViewModel(MainViewModel parent,MainWindowViewModel mainWindowViewModel, string username)
|
||||
{
|
||||
MainWindowViewModel = mainWindowViewModel;
|
||||
this.parent = parent;
|
||||
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
|
||||
this.Chart = new Chart(this.PatientInfo);
|
||||
PatientInfo.ChatLog = new ObservableCollection<string>();
|
||||
@@ -75,8 +77,7 @@ namespace DoctorApp.ViewModels
|
||||
|
||||
ChatToAll = new RelayCommand<object>((parameter) =>
|
||||
{
|
||||
//todo save clientinfoviewmodels in mainviewmodel
|
||||
//todo send message to client of every clientinfoviewmodel
|
||||
this.parent?.SendToAllClients(((TextBox)parameter).Text);
|
||||
});
|
||||
|
||||
SetResistance = new RelayCommand<object>((parameter) =>
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace DoctorApp.ViewModels
|
||||
Debug.WriteLine("new tab with name " + username);
|
||||
App.Current.Dispatcher.Invoke((Action)delegate
|
||||
{
|
||||
Tabs.Add(new ClientInfoViewModel(MainWindowViewModel, username));
|
||||
Tabs.Add(new ClientInfoViewModel(this,MainWindowViewModel, username));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,6 +72,15 @@ namespace DoctorApp.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void SendToAllClients(string text)
|
||||
{
|
||||
Debug.WriteLine("[MAINVIEWMODEL] Sending message to all clients: " + text);
|
||||
foreach (ClientInfoViewModel item in Tabs)
|
||||
{
|
||||
item.SendMessageToClient(item.PatientInfo.Username, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Windows.Input;
|
||||
using DoctorApp.Models;
|
||||
using DoctorApp.Utils;
|
||||
using Util.MagicCode;
|
||||
using System;
|
||||
|
||||
namespace DoctorApp.ViewModels
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user