public UserControl_Write(StateUpdate_Model stateUpdate, HomePage_ViewModel homePageViewModel) { InitializeComponent(); gameInfoBar = new UserControl_GameInfoBar(stateUpdate, homePageViewModel); this.InfoBar.Children.Add(gameInfoBar); this.DrawingArea.Children.Add(drawView); }
public UserControl_Passive(StateUpdate_Model stateUpdate, HomePage_ViewModel homePageViewModel) { this.activatetuto = false; this.BarInfoPassive = new UserControl_GameInfoBar(stateUpdate, homePageViewModel); InitializeComponent(); this.virtualP = new VirtualPlayer(this.PassiveCanvas, this.PassiveCanvasPath); this.InfoBar.Children.Add(this.BarInfoPassive); }
public UserControl_Guess(StateUpdate_Model stateUpdate, HomePage_ViewModel homePageViewModel) { thirdGess = false; this.activateTuto = false; InitializeComponent(); DataContext = new Guess_ViewModel(this); this.PassivViewGuess = new UserControl_Passive(stateUpdate, homePageViewModel); this.PassiveView.Children.Add(this.PassivViewGuess); //if (stateUpdate.attemptLeft == 0) // this.GuessButton.IsEnabled = false; }
public UserControl_GameInfoBar(StateUpdate_Model stateUpdate, HomePage_ViewModel homePageViewModel) { InitializeComponent(); if (stateUpdate.answer != null) { this.Answer.Content = "Réponse: " + stateUpdate.answer; } else { if (stateUpdate.attemptsLeft >= 0) { this.Answer.Content = "Tentatives : " + stateUpdate.attemptsLeft; } else { this.Answer.Content = "Tentative: infini"; } } this.MyPoints.Content = "Mon équipe: " + stateUpdate.points; if (stateUpdate.otherPoints >= 0) { this.OtherPoints.Content = "Autre équipe: " + stateUpdate.otherPoints; } this.Round.Content = "Manche: " + stateUpdate.currentRound; switch (stateUpdate.role) { case "WRITE": this.Role.Content = "Auteur"; break; case "GUESS": this.Role.Content = "Devineur"; break; case "PASSIVE": this.Role.Content = "Passive"; this.Bar1.Background = (Brush) new BrushConverter().ConvertFrom("#FF2EC3B6"); this.Bar2.Background = (Brush) new BrushConverter().ConvertFrom("#FF2EC3B6"); break; } this.Countdown(stateUpdate.startTimer / 1000, TimeSpan.FromSeconds(1), cur => this.Timer.Content = cur.ToString()); }
public void switchState(StateUpdate_Model d) { this.gameInfoBar.switchtoPassiv(d); drawView.Dispatcher.Invoke(() => { InkCanvas b = new InkCanvas(); UserControl_WriteToPassif temp = new UserControl_WriteToPassif(); foreach (var s in drawView.surfaceDessin.Strokes) { b.Strokes.Add(s); } this.DrawingArea.Children.Clear(); temp.doc.Children.Add(b); this.DrawingArea.Children.Add(temp); }); }
public void StateUpdateEvent() { var passiv = new UserControl_Passive(); var write = new UserControl_Write(); SocketService.MySocket.Off("state update"); SocketService.MySocket.On("state update", (data) => { Console.WriteLine(data); StateUpdate_Model d = JsonConvert.DeserializeObject <StateUpdate_Model>(data.ToString()); if (d.role == "WRITE" && d.answer != null) { this._homePageView.Dispatcher.Invoke(() => { if (d.clear) { lastState = "WRITE"; this._homePageView.MiddleView.Children.Clear(); write = new UserControl_Write(d, this); this._homePageView.MiddleView.Children.Add(write); } }); } else if (d.role == "GUESS" && d.answer == null) { this._homePageView.Dispatcher.Invoke(() => { if (d.clear) { lastState = "GUESS"; this._homePageView.MiddleView.Children.Clear(); guess = new UserControl_Guess(d, this); this._homePageView.MiddleView.Children.Add(guess); } else { if (lastState == "PASSIVE") { this._homePageView.MiddleView.Children.Remove(passiv); passiv.switchState(d); this._homePageView.MiddleView.Children.Add(new UserControl_Guess(passiv)); } else { if (d.attemptsLeft.ToString() == "-1") { guess.PassivViewGuess.BarInfoPassive.Answer.Content = "Tentatives : " + "Infinies"; } else { guess.PassivViewGuess.BarInfoPassive.Answer.Content = "Tentatives : " + d.attemptsLeft.ToString(); } } } }); } else if (d.role == "PASSIVE" && d.answer == null) { this._homePageView.Dispatcher.Invoke(() => { if (d.clear) { lastState = "PASSIVE"; this._homePageView.MiddleView.Children.Clear(); passiv = new UserControl_Passive(d, this); this._homePageView.MiddleView.Children.Add(passiv); } else { if (lastState == "WRITE") { write.switchState(d); } else if (lastState == "GUESS") { guess.SwitchToPassive(d); } else { passiv.BarInfoPassive.switchtoPassiv(d); } } }); } }); }
public void SwitchToPassive(StateUpdate_Model state) { this.buttons.Children.Clear(); this.PassivViewGuess.switchState(state); }
public void switchState(StateUpdate_Model state) { this.BarInfoPassive.switchtoPassiv(state); }