added test bool to server gui

This commit is contained in:
Sem van der Hoeven
2020-10-12 16:53:15 +02:00
parent 7879aa301d
commit 934c1cd48b
4 changed files with 8 additions and 4 deletions

View File

@@ -10,5 +10,7 @@ namespace Server.Models
class Information : ObservableObject class Information : ObservableObject
{ {
public bool CanStartServer { get; set; } public bool CanStartServer { get; set; }
public bool ServerOnline { get; set; }
} }
} }

View File

@@ -22,6 +22,7 @@ namespace Server.ViewModels
Debug.WriteLine("init mainviewmodel"); Debug.WriteLine("init mainviewmodel");
InformationModel = new Information(); InformationModel = new Information();
InformationModel.CanStartServer = true; InformationModel.CanStartServer = true;
InformationModel.ServerOnline = false;
this.ServerStartCommand = new RelayCommand(() => this.ServerStartCommand = new RelayCommand(() =>
{ {
Debug.WriteLine("connect button clicked"); Debug.WriteLine("connect button clicked");
@@ -35,7 +36,7 @@ namespace Server.ViewModels
Debug.WriteLine("can start server " + InformationModel.CanStartServer); Debug.WriteLine("can start server " + InformationModel.CanStartServer);
serverCommunication.Start(); serverCommunication.Start();
InformationModel.ServerOnline = true;
InformationModel.CanStartServer = false; InformationModel.CanStartServer = false;
} }
}); });

View File

@@ -7,7 +7,8 @@
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"> Title="MainWindow" Height="450" Width="800">
<Grid> <Grid>
<Button Content="Start Server" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Command="{Binding ServerStartCommand}" IsEnabled="{Binding MainViewModel.InformationModel.CanStartServer}"/> <Button Content="Start Server" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Command="{Binding ServerStartCommand}" IsEnabled="{Binding InformationModel.CanStartServer}"/>
<Label Content="{Binding MainViewModel.InformationModel.CanStartServer}" HorizontalAlignment="Left" Margin="97,7,0,0" VerticalAlignment="Top"/> <Label Content="{Binding InformationModel.ServerOnline}" HorizontalAlignment="Left" Margin="169,10,0,0" VerticalAlignment="Top"/>
<Label Content="Server Online:" HorizontalAlignment="Left" Margin="80,7,0,0" VerticalAlignment="Top"/>
</Grid> </Grid>
</Window> </Window>

View File

@@ -26,9 +26,9 @@ namespace Server
public MainWindow() public MainWindow()
{ {
InitializeComponent();
// use mainviewmodel for the bindings of our methods // use mainviewmodel for the bindings of our methods
DataContext = new MainViewModel(); DataContext = new MainViewModel();
InitializeComponent();
} }
} }
} }