[ADD] added mvvm button commands for host and join
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Name="joinButton" Grid.Row="0" Content="join a selected lobby" Click="Button_Click" Width="200" Height="40" HorizontalAlignment="Left" Margin="10, 0, 0, 0"/>
|
||||
<Button Name="hostButton" Grid.Row="1" Content="host a new lobby" Command="{Binding Path=OnHostButtonClick}" Width="200" Height="40" HorizontalAlignment="left" Margin="10, 0, 0, 0"/>
|
||||
<Button Name="joinButton" Grid.Row="0" Content="join a selected lobby" Command="{Binding JoinSelectedLobby}" Width="200" Height="40" HorizontalAlignment="Left" Margin="10, 0, 0, 0"/>
|
||||
<Button Name="hostButton" Grid.Row="1" Content="host a new lobby" Command="{Binding OnHostButtonClick}" Width="200" Height="40" HorizontalAlignment="left" Margin="10, 0, 0, 0"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Client
|
||||
|
||||
GameWindow window = new GameWindow();
|
||||
window.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user