-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainWindow.xaml
231 lines (224 loc) · 17.8 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<Window
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:FingersApp"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" x:Class="FingersApp.MainWindow"
mc:Ignorable="d"
Loaded="Page_Loaded"
Closing="Window_Closing"
ResizeMode="CanMinimize" Height="390" Width="280"
Title="Fingers" Background="#FF0F0F0F">
<Window.Resources>
<ResourceDictionary>
<ImageSource x:Key="IndicatorOff">Assets/indicator_off.png</ImageSource>
<ImageSource x:Key="IndicatorOn">Assets/indicator_on.png</ImageSource>
<ImageSource x:Key="Swap">Assets/swap.png</ImageSource>
<Style TargetType="{x:Type Button}" x:Key="ImageButtonStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Window Chrome -->
<!-- Flat ComboBox -->
<!-- https://gist.github.com/hansmaad/9187633 -->
<SolidColorBrush x:Key="ComboBoxNormalBorderBrush" Color="#333" />
<SolidColorBrush x:Key="ComboBoxNormalBackgroundBrush" Color="#000" />
<SolidColorBrush x:Key="ComboBoxDisabledForegroundBrush" Color="#888" />
<SolidColorBrush x:Key="ComboBoxDisabledBackgroundBrush" Color="#333" />
<SolidColorBrush x:Key="ComboBoxDisabledBorderBrush" Color="#666" />
<Style TargetType="ComboBoxItem">
<Setter Property="BorderBrush" Value="White" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<!--This Does the Magic-->
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border x:Name="Bd"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0, 0, 0, 0"
Padding="1, 3, 0, 4"
SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="True" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate TargetType="ToggleButton" x:Key="ComboBoxToggleButtonTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2" Name="Border"
BorderBrush="{StaticResource ComboBoxNormalBorderBrush}"
CornerRadius="0" BorderThickness="1, 1, 1, 1"
Background="{StaticResource ComboBoxNormalBackgroundBrush}" />
<Border Grid.Column="1" Margin="1, 1, 1, 1" BorderBrush="#444" Name="ButtonBorder"
CornerRadius="0, 0, 0, 0" BorderThickness="0, 0, 0, 0"
Background="{StaticResource ComboBoxNormalBackgroundBrush}" />
<Path Name="Arrow" Grid.Column="1"
Data="M0,0 L0,2 L4,6 L8,2 L8,0 L4,4 z"
HorizontalAlignment="Center" Fill="#444"
VerticalAlignment="Center" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Panel.Background" TargetName="ButtonBorder" Value="Black"/>
</Trigger>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter Property="Panel.Background" TargetName="ButtonBorder" Value="Black"/>
<Setter Property="Shape.Fill" TargetName="Arrow" Value="#FF8D979E"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="Panel.Background" TargetName="Border" Value="{StaticResource ComboBoxDisabledBackgroundBrush}"/>
<Setter Property="Panel.Background" TargetName="ButtonBorder" Value="{StaticResource ComboBoxDisabledBackgroundBrush}"/>
<Setter Property="Border.BorderBrush" TargetName="ButtonBorder" Value="{StaticResource ComboBoxDisabledBorderBrush}"/>
<Setter Property="TextElement.Foreground" Value="{StaticResource ComboBoxDisabledForegroundBrush}"/>
<Setter Property="Shape.Fill" TargetName="Arrow" Value="#999"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ComboBoxFlatStyle" TargetType="{x:Type ComboBox}">
<Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
<Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="TextElement.Foreground" Value="White"/>
<Setter Property="FrameworkElement.FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton Name="ToggleButton" Grid.Column="2"
ClickMode="Press" Focusable="False"
IsChecked="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Template="{StaticResource ComboBoxToggleButtonTemplate}"/>
<ContentPresenter Name="ContentSite" Margin="5, 3, 23, 3" IsHitTestVisible="False"
HorizontalAlignment="Left" VerticalAlignment="Center"
Content="{TemplateBinding ComboBox.SelectionBoxItem}"
ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
<TextBox Name="PART_EditableTextBox" Margin="3, 3, 23, 3"
IsReadOnly="{TemplateBinding IsReadOnly}"
Visibility="Hidden" Background="Transparent"
HorizontalAlignment="Left" VerticalAlignment="Center"
Focusable="True" >
<TextBox.Template>
<ControlTemplate TargetType="TextBox" >
<Border Name="PART_ContentHost" Focusable="False" />
</ControlTemplate>
</TextBox.Template>
</TextBox>
<!-- Popup showing items -->
<Popup Name="Popup" Placement="Bottom"
Focusable="False" AllowsTransparency="True"
IsOpen="{TemplateBinding ComboBox.IsDropDownOpen}"
PopupAnimation="Slide">
<Grid Name="DropDown" SnapsToDevicePixels="True"
MinWidth="{TemplateBinding FrameworkElement.ActualWidth}"
MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
<Border Name="DropDownBorder" Background="Black" Margin="0, 1, 0, 0"
CornerRadius="0" BorderThickness="1,1,1,1"
BorderBrush="{StaticResource ComboBoxNormalBorderBrush}"/>
<ScrollViewer Margin="4" SnapsToDevicePixels="True">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ItemsControl.HasItems" Value="False">
<Setter Property="FrameworkElement.MinHeight" TargetName="DropDownBorder" Value="95"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="{StaticResource ComboBoxDisabledForegroundBrush}"/>
</Trigger>
<Trigger Property="ItemsControl.IsGrouping" Value="True">
<Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
</Trigger>
<Trigger Property="ComboBox.IsEditable" Value="True">
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
<Setter Property="UIElement.Visibility" TargetName="PART_EditableTextBox" Value="Visible"/>
<Setter Property="UIElement.Visibility" TargetName="ContentSite" Value="Hidden"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- End of Flat ComboBox -->
</ResourceDictionary>
</Window.Resources>
<Grid Margin="0,0,0,0">
<Grid HorizontalAlignment="Left" Height="105" Margin="10,14,0,0" VerticalAlignment="Top" Width="252">
<TextBlock HorizontalAlignment="Center" Height="19" Margin="0,0,0,0" TextWrapping="Wrap" TextAlignment="Center" Text="LEAP" VerticalAlignment="Top" Width="67" Foreground="White" FontSize="14"/>
<Grid HorizontalAlignment="Center" Height="96" Margin="10,10,10,0" VerticalAlignment="Top" Width="200">
<TextBlock HorizontalAlignment="Left" Height="19" Margin="0,24,0,0" TextAlignment="Left" TextWrapping="Wrap" Text="Mount:" VerticalAlignment="Top" Width="93" Foreground="White"/>
<ComboBox Background="Black" x:Name="LeapProfileSelector" HorizontalAlignment="Left" Margin="46,22,0,0" VerticalAlignment="Top" Width="150" SelectionChanged="LeapProfileSelectionChanged" Style="{DynamicResource ComboBoxFlatStyle}">
<ComboBoxItem Content="Generic" HorizontalAlignment="Left" Width="118"/>
<ComboBoxItem Content="Pimax" HorizontalAlignment="Left" Width="118"/>
<ComboBoxItem Content="Joculus" HorizontalAlignment="Left" Width="118"/>
</ComboBox>
<TextBlock HorizontalAlignment="Left" Height="19" Margin="0,53,0,0" TextAlignment="Left" TextWrapping="Wrap" Text="Status:" VerticalAlignment="Top" Width="93" Foreground="White"/>
<TextBlock x:Name="LeapStatus" HorizontalAlignment="Left" Height="19" Margin="50,53,0,0" TextAlignment="Left" TextWrapping="Wrap" Text="Connecting..." VerticalAlignment="Top" Width="94" Foreground="White"/>
</Grid>
</Grid>
<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Center" Height="1" Margin="32,114,32,0" Stroke="#222" VerticalAlignment="Top" Width="274"/>
<Grid Height="158" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="10,110,0,0" Width="262">
<Grid HorizontalAlignment="Center" Height="96" Margin="10,10,10,0" VerticalAlignment="Top" Width="200">
<TextBlock HorizontalAlignment="Left" Height="19" Margin="0,10,0,0" TextAlignment="Left" TextWrapping="Wrap" Text="Sens:" ToolTip="Sensitivity; this roughly corresponds to horizontal FOV" VerticalAlignment="Top" Width="93" Foreground="White"/>
<Slider x:Name="SensitivitySlider"
Margin="46,10,0,0"
Minimum="90"
Maximum="180"
SmallChange="1"
BorderThickness="0"
TickFrequency="1"
AutoToolTipPlacement="TopLeft"
ValueChanged="SensitivityValueChanged" />
</Grid>
</Grid>
<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Center" Height="1" Margin="32,164,32,0" Stroke="#222" VerticalAlignment="Top" Width="274"/>
<Grid Height="158" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,180,0,0" Width="262">
<TextBlock HorizontalAlignment="Center" Height="19" Margin="0,0,0,0" TextWrapping="Wrap" TextAlignment="Center" Text="RINGS" VerticalAlignment="Top" Width="67" Foreground="White" FontSize="14"/>
<Grid Name="LeftRing" Width="102" Height="109" HorizontalAlignment="Left" Margin="12,36,0,0" VerticalAlignment="Top">
<TextBlock HorizontalAlignment="Left" Height="14" Margin="0,96,0,-1" TextWrapping="Wrap" Text="LEFT" VerticalAlignment="Top" Width="102" Foreground="White" TextAlignment="Center" FontSize="9"/>
<TextBlock x:Name="LeftRingStatus" ToolTip="Status" HorizontalAlignment="Left" Height="19" Margin="0,76,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="102" Foreground="White" TextAlignment="Center" LineHeight="19"><Run Text="SEARCHING"/><LineBreak/><Run/><LineBreak/><Run/></TextBlock>
<Grid HorizontalAlignment="Center" Height="64" Margin="0,0,0,0" VerticalAlignment="Top" Width="64">
<Image x:Name="LeftRingBtnCenter" ToolTip="Left click" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Source="Assets/indicator_off.png" />
<Image x:Name="LeftRingBtnFwd" ToolTip="Scroll up" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="42, 0, 0, 0" Source="Assets/indicator_off.png" />
<Image x:Name="LeftRingBtnBack" ToolTip="Right click" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="-42, 0, 0, 0" Source="Assets/indicator_off.png" />
<Image x:Name="LeftRingBtnDown" ToolTip="Scroll down" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="0, 42, 0, 0" Source="Assets/indicator_off.png" />
<Image x:Name="LeftRingBtnUp" ToolTip="Temporarily disable fingers" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="0, -42, 0, 0" Source="Assets/indicator_off.png" />
</Grid>
</Grid>
<Grid Name="RightRing" Width="102" Height="109" HorizontalAlignment="Right" Margin="0,36,12,0" VerticalAlignment="Top">
<TextBlock HorizontalAlignment="Left" Height="14" Margin="0,96,0,-1" TextWrapping="Wrap" Text="RIGHT" VerticalAlignment="Top" Width="102" Foreground="White" TextAlignment="Center" FontSize="9"/>
<TextBlock x:Name="RightRingStatus" ToolTip="Status" HorizontalAlignment="Left" Height="19" Margin="0,76,0,0" TextWrapping="Wrap" Text="SEARCHING" VerticalAlignment="Top" Width="102" Foreground="White" TextAlignment="Center"/>
<Grid HorizontalAlignment="Center" Height="64" Margin="0,0,0,0" VerticalAlignment="Top" Width="64">
<Image x:Name="RightRingBtnCenter" ToolTip="Left click" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Source="Assets/indicator_off.png" />
<Image x:Name="RightRingBtnFwd" ToolTip="Scroll up" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="-42, 0, 0, 0" Source="Assets/indicator_off.png" />
<Image x:Name="RightRingBtnBack" ToolTip="Right click" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="42, 0, 0, 0" Source="Assets/indicator_off.png" />
<Image x:Name="RightRingBtnDown" ToolTip="Scroll down" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="0, 42, 0, 0" Source="Assets/indicator_off.png" />
<Image x:Name="RightRingBtnUp" ToolTip="Temporarily disable fingers" HorizontalAlignment="Center" VerticalAlignment="Center" Width="14" Height="14" Margin="0, -42, 0, 0" Source="Assets/indicator_off.png" />
</Grid>
</Grid>
<Button Style="{StaticResource ImageButtonStyle}" HorizontalAlignment="Center" Margin="0,112,0,0" VerticalAlignment="Top" Width="24" Height="32" Click="Swap">
<Image Source="Assets/swap.png" Height="24" VerticalAlignment="Top" HorizontalAlignment="Left" Width="24" RenderTransformOrigin="0.49,0.51" />
</Button>
</Grid>
<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Center" Height="1" Margin="32,114,32,0" Stroke="#222" VerticalAlignment="Top" Width="274"/>
</Grid>
</Window>