-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml
135 lines (130 loc) · 8.57 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<mah:MetroWindow x:Class="virtual_cube.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:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Virtual Cube"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
xmlns:local="clr-namespace:virtual_cube" >
<Window.Resources>
<local:MethodToValueConverter x:Key="MethodToValueConverter" />
<Style x:Key="connected" TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=ConnectionStatus}" Value="{x:Static local:ConnectionStatus.CONNECTED}">
<Setter Property="Visibility" Value="Hidden"/>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=ConnectionStatus}" Value="{x:Static local:ConnectionStatus.CONNECTING}">
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=ConnectionStatus}" Value="{x:Static local:ConnectionStatus.DISCONNECTED}">
<Setter Property="Visibility" Value="Visible"/>
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="disconnected" TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=ConnectionStatus}" Value="{x:Static local:ConnectionStatus.CONNECTED}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=ConnectionStatus}" Value="{x:Static local:ConnectionStatus.CONNECTING}">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=ConnectionStatus}" Value="{x:Static local:ConnectionStatus.DISCONNECTED}">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="300*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Supported cubes are the GoCube and the Rubiks Connected."></TextBlock>
<TextBlock Grid.Row="1" Text="Keep Green in front and White on top."></TextBlock>
<StackPanel Grid.Row="2">
<RadioButton x:Name="notations" GroupName="mode" Content="Send proper notations as text" IsChecked="True" Checked="HandleCheck"/>
<RadioButton x:Name="keyMapping" GroupName="mode" Content="Map to different keys" Checked="HandleCheck"/>
<Grid x:Name="KeyMappingGrid" Width="600">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Label x:Name="LABEL_F">F</Label>
<ComboBox x:Name="F" Grid.Column="1" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_FI" Grid.Column="2">F'</Label>
<ComboBox x:Name="FI" Grid.Column="3" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_R" Grid.Column="0" Grid.Row="1">R</Label>
<ComboBox x:Name="R" Grid.Column="1" Grid.Row="1" Text="R" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_RI" Grid.Column="2" Grid.Row="1">R'</Label>
<ComboBox x:Name="RI" Grid.Column="3" Grid.Row="1" Text="E" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_U" Grid.Column="0" Grid.Row="2">U</Label>
<ComboBox x:Name="U" Grid.Column="1" Grid.Row="2" Text="Q" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_UI" Grid.Column="2" Grid.Row="2">U'</Label>
<ComboBox x:Name="UI" Grid.Column="3" Grid.Row="2" Text="D" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_L" Grid.Column="0" Grid.Row="3">L</Label>
<ComboBox x:Name="L" Grid.Column="1" Grid.Row="3" Text="V" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_LI" Grid.Column="2" Grid.Row="3">L'</Label>
<ComboBox x:Name="LI" Grid.Column="3" Grid.Row="3" Text="C" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_D" Grid.Column="0" Grid.Row="4">D</Label>
<ComboBox x:Name="D" Grid.Column="1" Grid.Row="4" Text="D" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_DI" Grid.Column="2" Grid.Row="4">D'</Label>
<ComboBox x:Name="DI" Grid.Column="3" Grid.Row="4" Text="C" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_B" Grid.Column="0" Grid.Row="5">B</Label>
<ComboBox x:Name="B" Grid.Column="1" Grid.Row="5" Text="Z" SelectionChanged="UpdateMapping"></ComboBox>
<Label x:Name="LABEL_BI" Grid.Column="2" Grid.Row="5">B'</Label>
<ComboBox x:Name="BI" Grid.Column="3" Grid.Row="5" Text="X" SelectionChanged="UpdateMapping"></ComboBox>
<Label Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="6">ms per keypress</Label>
<TextBox x:Name="PRESSTIME" Grid.Column="3" Grid.Row="6" Text="500" TextChanged="PRESSTIME_TextChanged" PreviewTextInput="PreviewTextInput" ></TextBox>
</Grid>
<Button x:Name="ScanButton" Click="ScanButton_Click" Content="Start Scanning"></Button>
<TextBlock>Devices:</TextBlock>
<Grid Margin="10">
<ItemsControl Name="cubeGrid" >
<ItemsControl.ItemTemplate>
<DataTemplate >
<Grid Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" />
<TextBlock Grid.Column="1" Text="{Binding Converter={StaticResource MethodToValueConverter},
ConverterParameter='GetTypeName'}" />
<TextBlock Grid.Column="2" Text="{Binding FormattedBluetoothAddress }" />
<TextBlock Grid.Column="3" Text="{Binding ConnectionStatus}" />
<TextBlock Grid.Column="4" Text="{Binding BatteryLevel}" />
<Button Style="{StaticResource connected}" Grid.Column="5" Content="Connect" Click="ConnectButton_Click"></Button>
<Button Style="{StaticResource disconnected}" Grid.Column="5" Content="Disconnect" Click="DisconnectButton_Click"></Button>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</StackPanel>
</Grid>
</mah:MetroWindow>