-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a mini controller that shows RA/DEC and allows manual slewing, homing and park, with keyboard support. - Site altitude is now persisted across sessions. - Connections are attempted multiple times if they fail. - Prevented crashes when the firmware said GPS or Digital Level was attached, but weren't actually connected. - Window positions are persisted across sessions. - Moved Settings button down to above Connect button.
- Loading branch information
1 parent
c7a2d9f
commit 1e56f99
Showing
13 changed files
with
343 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<Window x:Class="OATControl.MiniController" | ||
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:OATControl" xmlns:controls="clr-namespace:OATControl.Controls" | ||
mc:Ignorable="d" | ||
Title="Mini OAT Control" Height="75" MinHeight="75" MaxHeight="75" Width="330" MaxWidth="330" MinWidth="330" WindowStyle="None" > | ||
<Window.Resources> | ||
<Style x:Key="TextBlockHeading" TargetType="TextBlock" BasedOn="{StaticResource MetroTextBlock}"> | ||
<Setter Property="VerticalAlignment" Value="Center" /> | ||
<Setter Property="FontWeight" Value="Bold" /> | ||
<Setter Property="FontSize" Value="20" /> | ||
<Setter Property="Margin" Value="2,0" /> | ||
<Setter Property="Padding" Value="6,0" /> | ||
<Setter Property="HorizontalAlignment" Value="Left" /> | ||
</Style> | ||
<Style x:Key="TextBlockLabel" TargetType="TextBlock" BasedOn="{StaticResource TextBlockHeading}"> | ||
<Setter Property="Padding" Value="2,0" /> | ||
<Setter Property="HorizontalAlignment" Value="Left" /> | ||
</Style> | ||
<Style x:Key="TextBlockLabelSmall" TargetType="TextBlock" BasedOn="{StaticResource TextBlockLabel}"> | ||
<Setter Property="FontSize" Value="14" /> | ||
<Setter Property="Padding" Value="4,4" /> | ||
<Setter Property="HorizontalAlignment" Value="Right" /> | ||
</Style> | ||
<Style x:Key="TextBlockLabelValue" TargetType="TextBlock" BasedOn="{StaticResource TextBlockLabelSmall}"> | ||
<Setter Property="Padding" Value="12,2" /> | ||
<Setter Property="Margin" Value="0,4" /> | ||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | ||
<Setter Property="TextAlignment" Value="Center" /> | ||
<Setter Property="Background" Value="{StaticResource AccentColorBrush2}" /> | ||
</Style> | ||
</Window.Resources> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="95"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="80"/> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock Grid.Row="0" Grid.Column="0" Text="RA:" Style="{StaticResource TextBlockLabelSmall}" MouseDown="TextBlock_MouseDown" MouseUp="TextBlock_MouseUp" MouseMove="TextBlock_MouseMove" Cursor="SizeAll" /> | ||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding CurrentRAString}" Style="{StaticResource TextBlockLabelValue}" /> | ||
|
||
<controls:PushButton Grid.RowSpan="2" Grid.Column="2" Width="36" Height="32" Direction="W" IsEnabled="{Binding MountConnected}" Command="{Binding StartSlewingCommand}" CommandParameter="W" /> | ||
<controls:PushButton Grid.Row="0" Grid.Column="3" Width="36" Height="36" Direction="N" Padding="0,0,0,4" IsEnabled="{Binding MountConnected}" Command="{Binding StartSlewingCommand}" CommandParameter="N" /> | ||
<controls:PushButton Grid.Row="1" Grid.Column="3" Width="36" Height="36" Direction="S" Padding="0,0,0,4" IsEnabled="{Binding MountConnected}" Command="{Binding StartSlewingCommand}" CommandParameter="S" /> | ||
<controls:PushButton Grid.RowSpan="2" Grid.Column="4" Width="36" Height="32" Direction="E" IsEnabled="{Binding MountConnected}" Command="{Binding StartSlewingCommand}" CommandParameter="E" /> | ||
|
||
<TextBlock Grid.Row="1" Grid.Column="0" Text="DEC:" Style="{StaticResource TextBlockLabelSmall}" MouseDown="TextBlock_MouseDown" MouseUp="TextBlock_MouseUp" MouseMove="TextBlock_MouseMove" Cursor="SizeAll" /> | ||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding CurrentDECString}" Style="{StaticResource TextBlockLabelValue}" /> | ||
|
||
<Button Grid.Row="0" Grid.Column="5" Margin="8,2" Padding="10,0" Content="Home" Style="{StaticResource AccentedSquareButtonStyle}" Command="{Binding HomeCommand}"/> | ||
<Button Grid.Row="1" Grid.Column="5" Margin="8,2" Padding="10,0" Content="{Binding ParkCommandString}" Style="{StaticResource AccentedSquareButtonStyle}" Command="{Binding ParkCommand}"/> | ||
|
||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using OATControl.ViewModels; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
|
||
namespace OATControl | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MiniController.xaml | ||
/// </summary> | ||
public partial class MiniController : Window | ||
{ | ||
MountVM _mount; | ||
private Point _startCapturePos; | ||
private Point _startWindowPos; | ||
|
||
public MiniController(MountVM mount) | ||
{ | ||
_mount = mount; | ||
this.DataContext = mount; | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnKeyDown(KeyEventArgs e) | ||
{ | ||
string cmdParam = string.Empty; | ||
switch (e.Key) | ||
{ | ||
case Key.Up: cmdParam = "+N"; break; | ||
case Key.Down: cmdParam = "+S"; break; | ||
case Key.Left: cmdParam = "+W"; break; | ||
case Key.Right: cmdParam = "+E"; break; | ||
} | ||
|
||
if (!String.IsNullOrEmpty(cmdParam)) | ||
{ | ||
_mount.StartSlewingCommand.Execute(cmdParam); | ||
e.Handled = true; | ||
} | ||
|
||
base.OnKeyDown(e); | ||
} | ||
|
||
protected override void OnKeyUp(KeyEventArgs e) | ||
{ | ||
string cmdParam = string.Empty; | ||
switch (e.Key) | ||
{ | ||
case Key.H: _mount.HomeCommand.Execute(null); e.Handled = true; break; | ||
case Key.P: _mount.ParkCommand.Execute(null); e.Handled = true; break; | ||
case Key.Up: cmdParam = "-N"; break; | ||
case Key.Down: cmdParam = "-S"; break; | ||
case Key.Left: cmdParam = "-W"; break; | ||
case Key.Right: cmdParam = "-E"; break; | ||
case Key.Escape: this.Hide(); break; | ||
} | ||
|
||
if (!String.IsNullOrEmpty(cmdParam)) | ||
{ | ||
_mount.StartSlewingCommand.Execute(cmdParam); | ||
e.Handled = true; | ||
} | ||
|
||
base.OnKeyUp(e); | ||
} | ||
|
||
private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e) | ||
{ | ||
UIElement el = (UIElement)sender; | ||
if (el.IsEnabled) | ||
{ | ||
el.CaptureMouse(); | ||
_startCapturePos = PointToScreen(e.GetPosition(el)); | ||
_startWindowPos = new Point(this.Left, this.Top); | ||
e.Handled = true; | ||
} | ||
} | ||
|
||
private void TextBlock_MouseUp(object sender, MouseButtonEventArgs e) | ||
{ | ||
UIElement el = (UIElement)sender; | ||
if (el.IsMouseCaptured) | ||
{ | ||
el.ReleaseMouseCapture(); | ||
e.Handled = true; | ||
} | ||
} | ||
|
||
private void TextBlock_MouseMove(object sender, MouseEventArgs e) | ||
{ | ||
UIElement el = (UIElement)sender; | ||
if (el.IsMouseCaptured) | ||
{ | ||
var mousePos = PointToScreen(e.GetPosition(el)); | ||
var delta = new Point(_startCapturePos.X - mousePos.X, _startCapturePos.Y - mousePos.Y); | ||
this.Left = _startWindowPos.X - delta.X; | ||
this.Top = _startWindowPos.Y - delta.Y; | ||
e.Handled = true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.