diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs index 23ca371..58b0177 100644 --- a/ClientApp/Utils/Client.cs +++ b/ClientApp/Utils/Client.cs @@ -130,7 +130,7 @@ namespace ClientApp.Utils Debug.WriteLine($"login failed \"{responseStatus}\""); } break; - case DataParser.START_SESSION: + /*case DataParser.START_SESSION: Console.WriteLine("Session started!"); this.sessionRunning = true; if (engineConnection.Connected && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow(); @@ -140,7 +140,7 @@ namespace ClientApp.Utils Console.WriteLine("Stop session identifier"); this.sessionRunning = false; sendMessage(DataParser.getStopSessionJson()); - break; + break;*/ case DataParser.SET_RESISTANCE: Console.WriteLine("Set resistance identifier"); if (this.handler == null) diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs index 558a300..c51d53d 100644 --- a/DoctorApp/Utils/Client.cs +++ b/DoctorApp/Utils/Client.cs @@ -99,7 +99,7 @@ namespace DoctorApp.Utils Debug.WriteLine($"login failed \"{responseStatus}\""); } break; - case DataParser.START_SESSION: + /*case DataParser.START_SESSION: Console.WriteLine("Session started!"); this.sessionRunning = true; sendMessage(DataParser.getStartSessionJson()); @@ -108,7 +108,7 @@ namespace DoctorApp.Utils Console.WriteLine("Stop session identifier"); this.sessionRunning = false; sendMessage(DataParser.getStopSessionJson()); - break; + break;*/ case DataParser.SET_RESISTANCE: Console.WriteLine("Set resistance identifier"); if (this.handler == null) diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs index f316a6e..6f4e2ae 100644 --- a/DoctorApp/ViewModels/ClientInfoViewModel.cs +++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs @@ -2,18 +2,34 @@ using GalaSoft.MvvmLight.Command; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; using System.Text; +using System.Windows.Controls; using System.Windows.Input; using Util; namespace DoctorApp.ViewModels { - class ClientInfoViewModel + class ClientInfoViewModel : 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; } + public ICommand StartSession { get; set; } public ICommand StopSession { get; set; } @@ -29,23 +45,38 @@ namespace DoctorApp.ViewModels public MainWindowViewModel MainWindowViewModel { get; set; } private Client client; - - public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel) { MainWindowViewModel = mainWindowViewModel; + ChatLog = new ObservableCollection(); client = mainWindowViewModel.client; StartSession = new RelayCommand(()=>{ - client.sendMessage(DataParser.getStartSessionJson()); + client.sendMessage(DataParser.getStartSessionJson(Username)); + Status = "Session started"; }); StopSession = new RelayCommand(() => { - client.sendMessage(DataParser.getStopSessionJson()); + client.sendMessage(DataParser.getStopSessionJson(Username)); + Status = "Session stopped, waiting to start again."; }); + Chat = new RelayCommand((parameter) => { - /*client.sendMessage(DataParser.)*/ + client.sendMessage(DataParser.getChatJson(Username, ((TextBox)parameter).Text)); + ChatLog.Add(DateTime.Now+": "+ ((TextBox)parameter).Text); + }); + + //TODO RelayCommand ChatToAll + + ClientInfo = new RelayCommand(() => + { + //TODO POPUP + }); + + SetResistance = new RelayCommand((parameter) => + { + client.sendMessage(DataParser.getSetResistanceJson(Username, float.Parse(((TextBox)parameter).Text))); }); } diff --git a/DoctorApp/Views/ClientInfoView.xaml b/DoctorApp/Views/ClientInfoView.xaml index fb111f7..8dcc068 100644 --- a/DoctorApp/Views/ClientInfoView.xaml +++ b/DoctorApp/Views/ClientInfoView.xaml @@ -24,8 +24,8 @@ -