[ADDED] other canvas can be reset via an other canvas

This commit is contained in:
Lars
2020-10-23 21:04:14 +02:00
parent 8ca4efc296
commit 398ba1d5bd
3 changed files with 16 additions and 3 deletions

View File

@@ -100,7 +100,7 @@ namespace Client.ViewModels
private void CanvasResetLocal() private void CanvasResetLocal()
{ {
this.window.CanvasForPaint.Children.Clear(); this.window.CanvasForPaint.Children.Clear();
data.Client.SendMessage(JSONConvert.GetMessageToSend(JSONConvert.CANVAS, JSONConvert.CANVAS_RESET)); data.Client.SendMessage(JSONConvert.ConstructCanvasReset());
} }
@@ -193,7 +193,11 @@ namespace Client.ViewModels
private void CanvasResetData() private void CanvasResetData()
{ {
this.window.CanvasForPaint.Children.Clear(); Application.Current.Dispatcher.Invoke(delegate
{
this.window.CanvasForPaint.Children.Clear();
});
} }
private void ChatBox_KeyDown() private void ChatBox_KeyDown()

View File

@@ -40,7 +40,7 @@
<Label Name="GuessWord" Grid.Row="0" Grid.Column="2" Content="{Binding Path=RandomWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20"/> <Label Name="GuessWord" Grid.Row="0" Grid.Column="2" Content="{Binding Path=RandomWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20"/>
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="3" Content="RESET"/> <Button Name="CanvasReset" Command="{Binding ButtonResetCanvas}" Grid.Row="0" Grid.Column="3" Content="RESET"/>
</Grid> </Grid>

View File

@@ -194,6 +194,15 @@ namespace SharedClientServer
}); });
} }
public static byte[] ConstructCanvasReset()
{
dynamic payload = new
{
canvasType = CANVAS_RESET
};
return GetMessageToSend(CANVAS, payload);
}
public static int GetCanvasMessageType(byte[] json) public static int GetCanvasMessageType(byte[] json)
{ {
dynamic d = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(json)); dynamic d = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(json));