Skip to content

Commit 8297ce5

Browse files
committed
Create an assistant UI that guides the user through calibration
Magnetic calibration, which now has to be done on first setup, is somewhat more complicated than the old DMP-method which just required the user to lay it on a flat surface. Therefore, the app now has an assistant that guides the user through the setup process.
1 parent 7946847 commit 8297ce5

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

TVR.Service/TVR.Service.UI/TVR.Service.UI.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
<Compile Include="Setup\CameraSetup.cs" />
9292
<Compile Include="Setup\FirstStartup.cs" />
9393
<Compile Include="Util\TreeViewItemHelper.cs" />
94+
<Compile Include="Windows\CalibrationDialog.xaml.cs">
95+
<DependentUpon>CalibrationDialog.xaml</DependentUpon>
96+
</Compile>
9497
<Compile Include="Windows\CommonDialog.xaml.cs">
9598
<DependentUpon>CommonDialog.xaml</DependentUpon>
9699
</Compile>
@@ -118,6 +121,10 @@
118121
<SubType>Designer</SubType>
119122
<Generator>MSBuild:Compile</Generator>
120123
</Page>
124+
<Page Include="Windows\CalibrationDialog.xaml">
125+
<SubType>Designer</SubType>
126+
<Generator>MSBuild:Compile</Generator>
127+
</Page>
121128
<Page Include="Windows\CommonDialog.xaml">
122129
<SubType>Designer</SubType>
123130
<Generator>MSBuild:Compile</Generator>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Window x:Class="TVR.Service.UI.Windows.CalibrationDialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:TVR.Service.UI.Windows"
7+
mc:Ignorable="d"
8+
Title="Calibration" Height="400" Width="400" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" Icon="../Icon.ico" SizeToContent="WidthAndHeight">
9+
<Grid Margin="20">
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="Auto"/>
12+
<RowDefinition Height="*"/>
13+
</Grid.RowDefinitions>
14+
<Grid.ColumnDefinitions>
15+
<ColumnDefinition Width="Auto"/>
16+
<ColumnDefinition Width="*"/>
17+
</Grid.ColumnDefinitions>
18+
<Label x:Name="CaptionLabel" Content="Caption" FontSize="35" FontWeight="Light" Grid.Row="0" Grid.ColumnSpan="2"/>
19+
<TextBlock x:Name="ContentLabel" Text="Content text goes here!" FontSize="20" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" TextWrapping="Wrap"/>
20+
</Grid>
21+
</Window>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Shapes;
14+
15+
namespace TVR.Service.UI.Windows
16+
{
17+
/// <summary>
18+
/// Interaction logic for CalibrationDialog.xaml
19+
/// </summary>
20+
public partial class CalibrationDialog : Window
21+
{
22+
public CalibrationDialog()
23+
{
24+
InitializeComponent();
25+
}
26+
27+
public void UpdateState(string title, string message)
28+
{
29+
CaptionLabel.Content = title;
30+
ContentLabel.Text = message;
31+
}
32+
}
33+
}

TVR.Service/TVR.Service.UI/Windows/MainWindow.xaml.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public partial class MainWindow : Window
1818
{
1919
private readonly ServiceHost serviceHost = new ServiceHost();
2020

21+
private CalibrationDialog calibrationDialog;
22+
2123
public MainWindow()
2224
{
2325
InitializeComponent();
@@ -27,6 +29,7 @@ public MainWindow()
2729
try
2830
{
2931
serviceHost.Start();
32+
serviceHost.Services.ControllerServer.StatusChanged += ControllerServer_StatusChanged;
3033
}
3134
catch (FileNotFoundException)
3235
{
@@ -40,6 +43,31 @@ public MainWindow()
4043
}
4144
}
4245

46+
private void ControllerServer_StatusChanged(object sender, Network.Controllers.StatusChangedEventArgs e)
47+
{
48+
Dispatcher.Invoke(() =>
49+
{
50+
switch (e.StatusMessage)
51+
{
52+
case Network.Controllers.StatusMessage.BeginCalibrationMode:
53+
calibrationDialog = new CalibrationDialog { Owner = this };
54+
calibrationDialog.UpdateState("Calibration", "Lay the controller down somewhere flat and wait for the calibration to complete...");
55+
calibrationDialog.Show();
56+
break;
57+
case Network.Controllers.StatusMessage.MagnetometerCalibration:
58+
calibrationDialog.UpdateState("Magnetic calibration", "Pick up the controller, go to your playspace and rotate it around and point it in all directions to calibrate the compass.");
59+
break;
60+
case Network.Controllers.StatusMessage.ExitCalibrationMode:
61+
calibrationDialog.Close();
62+
CommonDialog.Show(this, "Calibration complete", "Controller calibrated", "The current controller was calibrated successfully!");
63+
break;
64+
case Network.Controllers.StatusMessage.Reset:
65+
CommonDialog.Show(this, "Factory reset", "Reset complete", "The controller did a factory reset!");
66+
break;
67+
}
68+
});
69+
}
70+
4371
private async void StartUpdateLoop()
4472
{
4573
while (IsLoaded)
@@ -109,7 +137,8 @@ private void AboutMenuItem_Click(object sender, RoutedEventArgs e)
109137

110138
private string PrettifyHostState(HostState state)
111139
{
112-
switch (state) {
140+
switch (state)
141+
{
113142
case HostState.Starting:
114143
return "Initializing...";
115144
case HostState.Active:

0 commit comments

Comments
 (0)