[ADD] add updating lobbies on exiting window

This commit is contained in:
Sem van der Hoeven
2020-10-21 21:40:35 +02:00
parent c339746a82
commit 442cdccc49
6 changed files with 50 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ using GalaSoft.MvvmLight.Command;
using SharedClientServer;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
@@ -120,6 +121,12 @@ namespace Client.ViewModels
data.Client.SendMessage(JSONConvert.GetMessageToSend(JSONConvert.MESSAGE, _payload));
}
public void LeaveGame(object sender, System.ComponentModel.CancelEventArgs e)
{
Debug.WriteLine("Leaving...");
data.Client.SendMessage(JSONConvert.ConstructLobbyLeaveMessage(data.Lobby.ID));
}
}
}

View File

@@ -3,10 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Client.Views"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Closing="Window_Closing"
Title="Scrubl.io" Height="600" Width="1200">
<Grid>
<Grid.RowDefinitions>

View File

@@ -1,15 +1,8 @@
using Client.ViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Client.Views
{
@@ -24,6 +17,7 @@ namespace Client.Views
{
this.viewModel = new ViewModelGame();
DataContext = this.viewModel;
Closing += this.viewModel.LeaveGame;
InitializeComponent();
}
@@ -59,9 +53,5 @@ namespace Client.Views
viewModel.Color_Picker(e, this);
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
}
}
}