[FIX] randomword is not visible
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Client
|
||||
{
|
||||
public delegate void LobbyCallback(int id);
|
||||
public delegate void LobbyJoinCallback(bool isHost);
|
||||
public delegate void RandomWord(string word);
|
||||
class Client : ObservableObject
|
||||
{
|
||||
private TcpClient tcpClient;
|
||||
@@ -30,6 +31,7 @@ namespace Client
|
||||
public Callback OnClientJoinLobby;
|
||||
public LobbyCallback OnLobbyCreated;
|
||||
public LobbyCallback OnLobbyLeave;
|
||||
public RandomWord RandomWord;
|
||||
private ClientData data = ClientData.Instance;
|
||||
public Lobby[] Lobbies { get; set; }
|
||||
|
||||
@@ -182,7 +184,8 @@ namespace Client
|
||||
string randomWord = JSONConvert.GetRandomWord(payload);
|
||||
|
||||
if (data.Lobby?.ID == lobbyId)
|
||||
ViewModels.ViewModelGame.HandleRandomWord(randomWord);
|
||||
RandomWord?.Invoke(randomWord);
|
||||
|
||||
break;
|
||||
default:
|
||||
Debug.WriteLine("[CLIENT] Received weird identifier: " + id);
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace Client.ViewModels
|
||||
|
||||
private dynamic _payload;
|
||||
|
||||
private static string _randomWord;
|
||||
private string _randomWord;
|
||||
|
||||
public string RandomWord
|
||||
{
|
||||
get { return _randomWord; }
|
||||
@@ -97,6 +98,7 @@ namespace Client.ViewModels
|
||||
public ViewModelGame()
|
||||
{
|
||||
OnKeyDown = new RelayCommand(ChatBox_KeyDown);
|
||||
data.Client.RandomWord = HandleRandomWord;
|
||||
}
|
||||
|
||||
private void ChatBox_KeyDown()
|
||||
@@ -144,9 +146,9 @@ namespace Client.ViewModels
|
||||
* MISC make this a callback
|
||||
* Handles the random word that has been received from the server.
|
||||
*/
|
||||
public static void HandleRandomWord(string randomWord)
|
||||
public void HandleRandomWord(string randomWord)
|
||||
{
|
||||
_randomWord = randomWord;
|
||||
RandomWord = randomWord;
|
||||
Debug.WriteLine($"[CLIENT] The random word is: {_randomWord}");
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="2" Margin="84,10,10,10" Content="RESET"/>
|
||||
|
||||
<Label Name="GuessWord" Grid.Row="0" Grid.Column="1" Content="{Binding Path=Word, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="140,0,109,0"/>
|
||||
<Label Name="GuessWord" Grid.Row="0" Grid.Column="1" Content="{Binding Path=RandomWord, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
|
||||
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="22" Width="100"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user