diff --git a/DoctorApp/DoctorApp.csproj b/DoctorApp/DoctorApp.csproj index 152865f..2ff8d95 100644 --- a/DoctorApp/DoctorApp.csproj +++ b/DoctorApp/DoctorApp.csproj @@ -1,29 +1,32 @@  - - WinExe - netcoreapp3.1 - true - + + WinExe + netcoreapp3.1 + true + doctor.ico + - - true - + + + - - true - + + + Always + + - - - - - + + + + + - - - + + + - + \ No newline at end of file diff --git a/DoctorApp/Models/PatientInfo.cs b/DoctorApp/Models/PatientInfo.cs new file mode 100644 index 0000000..c7ed295 --- /dev/null +++ b/DoctorApp/Models/PatientInfo.cs @@ -0,0 +1,25 @@ +using System.Collections.ObjectModel; +using Util; + +namespace DoctorApp.Models +{ + class PatientInfo : ObservableObject + { + public ObservableCollection ChatLog { get; set; } + public string Username { get; set; } + + public string Status { get; set; } + + public int Speed { get; set; } + + public int BPM { get; set; } + + public int Resistance { get; set; } + public int Acc_Power { get; set; } + + public int Curr_Power { get; set; } + + public int Distance { get; set; } + + } +} diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs index 00f3832..bbd3674 100644 --- a/DoctorApp/Utils/Client.cs +++ b/DoctorApp/Utils/Client.cs @@ -82,7 +82,6 @@ namespace DoctorApp.Utils string identifier; bool isJson = DataParser.getJsonIdentifier(messageBytes, out identifier); - Debug.WriteLine("doctor " + Encoding.ASCII.GetString(payloadbytes)); if (isJson) { switch (identifier) diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs index d186d78..0e98724 100644 --- a/DoctorApp/ViewModels/ClientInfoViewModel.cs +++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs @@ -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 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(); + this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" }; + PatientInfo.ChatLog = new ObservableCollection(); 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((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 diff --git a/DoctorApp/ViewModels/MainViewModel.cs b/DoctorApp/ViewModels/MainViewModel.cs index d245e2f..f8f7ab6 100644 --- a/DoctorApp/ViewModels/MainViewModel.cs +++ b/DoctorApp/ViewModels/MainViewModel.cs @@ -22,19 +22,14 @@ namespace DoctorApp.ViewModels { this.MainWindowViewModel = mainWindowViewModel; client = this.MainWindowViewModel.client; - Tabs= new ObservableCollection(); + Tabs = new ObservableCollection(); } public void NewConnectedUser(string username) { - System.Diagnostics.Debug.WriteLine("CREATING TAB FOR " + username); App.Current.Dispatcher.Invoke((Action)delegate { - Tabs.Add(new ClientInfoViewModel(MainWindowViewModel) - { - Username = username, - Status = "Waiting to start" - }); + Tabs.Add(new ClientInfoViewModel(MainWindowViewModel, username)); }); } @@ -44,7 +39,7 @@ namespace DoctorApp.ViewModels { foreach (ClientInfoViewModel item in Tabs) { - if (item.Username == username) + if (item.PatientInfo.Username == username) { Tabs.Remove(item); break; diff --git a/DoctorApp/Views/ClientInfoView.xaml b/DoctorApp/Views/ClientInfoView.xaml index 33a0c12..b5b11cc 100644 --- a/DoctorApp/Views/ClientInfoView.xaml +++ b/DoctorApp/Views/ClientInfoView.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:DoctorApp.Views" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" + > @@ -24,8 +25,8 @@ -