-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml
69 lines (64 loc) · 4.04 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<Window x:Class="MultiplayerTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:MultiplayerTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<Style TargetType="TextBox">
<Setter Property="Margin" Value="2"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="2"/>
</Style>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Window.Resources>
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Port" Grid.Row="0" Grid.Column="0" Visibility="{Binding IsServer, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Port}" Visibility="{Binding IsServer, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Button Content="Start server" Grid.Row="1" Grid.Column="1" Command="{Binding StartServerCommand}" Visibility="{Binding IsServer, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Button Content="Start game" Grid.Row="2" Grid.Column="1" Command="{Binding StartGameCommand}" Visibility="{Binding IsServer, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBlock Text="Address" Grid.Row="0" Grid.Column="0" Visibility="{Binding IsClient, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Endpoint}" Visibility="{Binding IsClient, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBlock Text="Port" Grid.Row="1" Grid.Column="0" Visibility="{Binding IsClient, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Port}" Visibility="{Binding IsClient, Converter={StaticResource BooleanToVisibilityConverter}}" />
<Button Content="Connect" Grid.Row="2" Grid.Column="1" Command="{Binding ConnectCommand}" Visibility="{Binding IsClient, Converter={StaticResource BooleanToVisibilityConverter}}" />
<Border BorderBrush="Black" BorderThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="3" Grid.ColumnSpan="2" Margin="0,20,0,0">
<Viewbox>
<ItemsControl ItemsSource="{Binding Players}" MouseDown="OnMouseDown" Background="White">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Width="500" Height="500"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Fill="{Binding Color}" Width="20" Height="20" Margin="-10,-10,0,0"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Viewbox>
</Border>
</Grid>
</Window>