From f1a47b509d78c5dbe8801cc404fa4ac72028a909 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Tue, 20 Oct 2020 18:55:12 +0200 Subject: [PATCH] [ADD] added mvvm button commands for host and join --- Client/ViewModels/ViewModel.cs | 21 ++++++++++++++++----- Client/Views/MainWindow.xaml | 4 ++-- Client/Views/MainWindow.xaml.cs | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Client/ViewModels/ViewModel.cs b/Client/ViewModels/ViewModel.cs index c66fd15..876cb5c 100644 --- a/Client/ViewModels/ViewModel.cs +++ b/Client/ViewModels/ViewModel.cs @@ -6,6 +6,7 @@ using System.Text; using System.Windows.Input; using SharedClientServer; using System.Diagnostics; +using System.Windows; namespace Client { @@ -13,9 +14,13 @@ namespace Client { public event PropertyChangedEventHandler PropertyChanged; + public ICommand OnHostButtonClick { get; set; } + public ICommand JoinSelectedLobby { get; set; } + public ViewModel() { _model = new Model(); + ButtonCommand = new RelayCommand(() => { @@ -26,6 +31,17 @@ namespace Client _lobbies.Add(new Lobby(50, 3, 8)); _lobbies.Add(new Lobby(69, 1, 9)); _lobbies.Add(new Lobby(420, 7, 7)); + + OnHostButtonClick = new RelayCommand(() => + { + Debug.WriteLine("Host button clicked"); + }); + + JoinSelectedLobby = new RelayCommand(() => + { + + Debug.WriteLine("Joining selected lobby"); + }); } private void ClickCheck() @@ -59,10 +75,5 @@ namespace Client get { return _lobbies; } set { _lobbies = value; } } - - public void OnHostButtonClick() - { - Debug.WriteLine("Click host button"); - } } } diff --git a/Client/Views/MainWindow.xaml b/Client/Views/MainWindow.xaml index 68bf586..3af77f3 100644 --- a/Client/Views/MainWindow.xaml +++ b/Client/Views/MainWindow.xaml @@ -67,8 +67,8 @@ -