Merge remote-tracking branch 'origin/develop' into dataOnTabs

This commit is contained in:
fabjuuuh
2020-10-19 11:14:57 +02:00
11 changed files with 90 additions and 76 deletions

View File

@@ -1,4 +1,5 @@
using DoctorApp.Utils;
using DoctorApp.Models;
using DoctorApp.Utils;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
@@ -11,7 +12,7 @@ using Util;
namespace DoctorApp.ViewModels
{
class ClientInfoViewModel : ObservableObject
{
public ObservableCollection<string> ChatLog { get; set; }
@@ -45,26 +46,29 @@ namespace DoctorApp.ViewModels
public MainWindowViewModel MainWindowViewModel { get; set; }
private Client client;
public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel)
public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel, string username)
{
MainWindowViewModel = mainWindowViewModel;
ChatLog = new ObservableCollection<string>();
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
PatientInfo.ChatLog = new ObservableCollection<string>();
client = mainWindowViewModel.client;
StartSession = new RelayCommand(()=>{
client.sendMessage(DataParser.getStartSessionJson(Username));
Status = "Session started";
StartSession = new RelayCommand(() =>
{
client.sendMessage(DataParser.getStartSessionJson(PatientInfo.Username));
PatientInfo.Status = "Session started";
});
StopSession = new RelayCommand(() => {
client.sendMessage(DataParser.getStopSessionJson(Username));
Status = "Session stopped, waiting to start again.";
StopSession = new RelayCommand(() =>
{
client.sendMessage(DataParser.getStopSessionJson(PatientInfo.Username));
PatientInfo.Status = "Session stopped, waiting to start again.";
});
Chat = new RelayCommand<object>((parameter) =>
{
client.sendMessage(DataParser.getChatJson(Username, ((TextBox)parameter).Text));
ChatLog.Add(DateTime.Now+": "+ ((TextBox)parameter).Text);
client.sendMessage(DataParser.getChatJson(PatientInfo.Username, ((TextBox)parameter).Text));
PatientInfo.ChatLog.Add(DateTime.Now + ": " + ((TextBox)parameter).Text);
});
//TODO RelayCommand ChatToAll