Skip to content

Commit d478f14

Browse files
OATControl V0.01
1 parent 5f7f2a7 commit d478f14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4197
-1
lines changed

Software/OATMobile/OATCommunications/CommunicationHandlers/TcpCommunicationHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ public async Task<CommandResponse> SendCommand(string command) {
2525
return await SendCommand(command, true);
2626
}
2727

28+
public bool Connected
29+
{
30+
get
31+
{
32+
return _client != null && _client.Connected;
33+
}
34+
}
35+
2836
private async Task<CommandResponse> SendCommand(string command, bool needsResponse) {
2937
if (!_client.Connected) {
3038
try {

Software/OATMobile/OATCommunications/ICommunicationHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ namespace OATCommunications
88
{
99
public interface ICommunicationHandler {
1010
Task<CommandResponse> SendCommand(string command);
11+
bool Connected { get; }
1112
}
1213
}

Software/OATMobile/OATCommunications/TelescopeCommandHandlers/OatmealTelescopeCommandHandlers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public OatmealTelescopeCommandHandlers(ICommunicationHandler commHandler) {
1919
_commHandler = commHandler;
2020
}
2121

22+
public bool Connected { get { return _commHandler.Connected; } }
23+
2224
public async Task<bool> RefreshMountState() {
2325
var _slewingStates = new []{"SlewToTarget", "FreeSlew", "ManualSlew"};
2426

@@ -169,7 +171,7 @@ public async Task<bool> SetLocation(double lat, double lon, double altitudeInMet
169171
return status.Success;
170172
}
171173

172-
private async Task<CommandResponse> SendCommand(string cmd) {
174+
public async Task<CommandResponse> SendCommand(string cmd) {
173175
if (!cmd.StartsWith(":")) {
174176
cmd = $":{cmd}";
175177
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<configSections>
4+
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5+
<section name="OATControl.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6+
</sectionGroup>
7+
</configSections>
8+
<startup>
9+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
10+
</startup>
11+
<userSettings>
12+
<OATControl.Properties.Settings>
13+
<setting name="Scope" serializeAs="String">
14+
<value />
15+
</setting>
16+
</OATControl.Properties.Settings>
17+
</userSettings>
18+
</configuration>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Application x:Class="OATControl.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:OATControl"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
10+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
11+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
12+
<!-- Accent and AppTheme setting -->
13+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />
14+
<ResourceDictionary Source="pack://application:,,,/;component/Resources/RedControls.xaml" />
15+
</ResourceDictionary.MergedDictionaries>
16+
</ResourceDictionary>
17+
</Application.Resources>
18+
</Application>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using MahApps.Metro;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Configuration;
5+
using System.Data;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using System.Windows;
9+
10+
namespace OATControl
11+
{
12+
/// <summary>
13+
/// Interaction logic for App.xaml
14+
/// </summary>
15+
16+
public partial class App : Application
17+
{
18+
protected override void OnStartup(StartupEventArgs e)
19+
{
20+
ThemeManager.AddAccent("RedAccent", new Uri("pack://application:,,,/OATControl;component/Resources/RedAccent.xaml"));
21+
ThemeManager.AddAppTheme("RedTheme", new Uri("pack://application:,,,/OATControl;component/Resources/RedTheme.xaml"));
22+
ThemeManager.AddAccent("RedControls", new Uri("pack://application:,,,/OATControl;component/Resources/RedControls.xaml"));
23+
24+
// get the current app style (theme and accent) from the application
25+
// you can then use the current theme and custom accent instead set a new theme
26+
Tuple<AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
27+
28+
// now set the Green accent and dark theme
29+
ThemeManager.ChangeAppStyle(Application.Current,
30+
ThemeManager.GetAccent("RedAccent"),
31+
ThemeManager.GetAppTheme("RedTheme"));
32+
33+
base.OnStartup(e);
34+
}
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<#
2+
This script initializes a bare minimum set of registry entries required for ASCOM.Utilities.Profile to work
3+
without throwing any exceptions. When building on a build server, or on a computer without the ASCOM Platform installed,
4+
it may be useful to execute this script as a build step prior to running any unit tests, or calling any code that relies on
5+
ASCOM.Utilities.Profile. The alternative is to install the ASCOM Platform on the build agent.
6+
7+
NOTE: This script equires elevated permissions because it creates registry keys in the LocalMachine hive.
8+
#>
9+
10+
$wow = Test-Path HKLM:\SOFTWARE\Wow6432Node
11+
if ($wow)
12+
{
13+
$root = "HKLM:\SOFTWARE\Wow6432Node"
14+
}
15+
else
16+
{
17+
$root = "HKLM:\SOFTWARE"
18+
}
19+
$ascomRoot = $root + "\ASCOM"
20+
21+
if (Test-Path $ascomRoot)
22+
{
23+
<# Don't upset an already-existing ASCOM registry #>
24+
exit
25+
}
26+
27+
<# Create the ASCOM root key and set it's ACL to allow all users read/write access #>
28+
New-Item -Path $root -Name ASCOM –Force
29+
$ascomAcl = Get-Acl $ascomRoot
30+
$aclRule = New-Object System.Security.AccessControl.RegistryAccessRule ("Users","FullControl","Allow")
31+
$ascomAcl.SetAccessRule($aclRule)
32+
$ascomAcl | Set-Acl -Path $ascomRoot
33+
34+
<# Now create the bare minimum keys required so that ASCOM.Utilities.Profile doesn't crash and burn #>
35+
New-ItemProperty -Path $ascomRoot -Name PlatformVersion -Value "6.1" -PropertyType String –Force
36+
New-ItemProperty -Path $ascomRoot -Name SerTraceFile -Value "C:\SerialTraceAuto.txt" -PropertyType String –Force
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<UserControl x:Class="OATControl.Controls.InlineSlider"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:convert="clr-namespace:OATControl.Converters"
7+
xmlns:local="clr-namespace:OATControl.Controls"
8+
Name="InlineSliderControl"
9+
mc:Ignorable="d"
10+
d:DesignHeight="30" d:DesignWidth="300">
11+
12+
<UserControl.Resources>
13+
14+
<ResourceDictionary>
15+
<!--<ResourceDictionary.MergedDictionaries>
16+
<ResourceDictionary Source="pack://application:,,,/OATControl;component/Resources/Controls.xaml" />
17+
</ResourceDictionary.MergedDictionaries>-->
18+
19+
20+
<convert:BoolToVisibilityConverter x:Key="BoolToVisibleConverter" Collapse="True" />
21+
22+
<LinearGradientBrush x:Key="UnsetBackground" StartPoint="0,0" EndPoint="0,1">
23+
<GradientStop Color="{StaticResource USBGTop}" Offset="0" />
24+
<GradientStop Color="{StaticResource USBGBottom}" Offset="1" />
25+
</LinearGradientBrush>
26+
<LinearGradientBrush x:Key="SetBackground" StartPoint="0,0" EndPoint="0,1">
27+
<GradientStop Color="{StaticResource SBGTop}" Offset="0" />
28+
<GradientStop Color="{StaticResource SBGBottom}" Offset="1" />
29+
</LinearGradientBrush>
30+
<LinearGradientBrush x:Key="SetBackgroundActive" StartPoint="0,0" EndPoint="0,1">
31+
<GradientStop Color="{StaticResource SBGActTop}" Offset="0" />
32+
<GradientStop Color="{StaticResource SBGActBottom}" Offset="1" />
33+
</LinearGradientBrush>
34+
<LinearGradientBrush x:Key="ButtonBackground" StartPoint="0,0" EndPoint="0,1">
35+
<GradientStop Color="{StaticResource ButtonBGTop}" Offset="0" />
36+
<GradientStop Color="{StaticResource ButtonBGBottom}" Offset="1" />
37+
</LinearGradientBrush>
38+
39+
<LinearGradientBrush x:Key="ButtonBackgroundActive" StartPoint="0,0" EndPoint="0,1">
40+
<GradientStop Color="{StaticResource ButtonBGActTop}" Offset="0" />
41+
<GradientStop Color="{StaticResource ButtonBGActBottom}" Offset="1" />
42+
</LinearGradientBrush>
43+
44+
<SolidColorBrush x:Key="PromptBrush" Color="{StaticResource PromptColor}"/>
45+
<SolidColorBrush x:Key="PromptActBrush" Color="{StaticResource PromptActColor}"/>
46+
<SolidColorBrush x:Key="TextBrush" Color="{StaticResource TextColor}"/>
47+
<SolidColorBrush x:Key="SliderPosBrush" Color="{StaticResource SliderPosColor}"/>
48+
<SolidColorBrush x:Key="SliderBorderBrush" Color="{StaticResource SliderBorderColor}"/>
49+
50+
<ControlTemplate x:Key="EditButtonTemplate">
51+
<Border BorderBrush="Black" BorderThickness="1" Padding="2" CornerRadius="2" >
52+
<Border.Style>
53+
<Style TargetType="Border">
54+
<Setter Property="Background" Value="{StaticResource ButtonBackground}" />
55+
<Style.Triggers>
56+
<Trigger Property="IsMouseOver" Value="True">
57+
<Setter Property="Background" Value="{StaticResource ButtonBackgroundActive}" />
58+
</Trigger>
59+
</Style.Triggers>
60+
</Style>
61+
</Border.Style>
62+
<Viewbox >
63+
<Grid >
64+
<Polygon Fill="{StaticResource SliderBorderBrush}" StrokeThickness="0" Points="20,68 0,75 8,55" />
65+
<Polygon Fill="{StaticResource SliderBorderBrush}" Stroke="Black" StrokeThickness="2" Points="62,0 75,13 62,26 49,13" />
66+
<Polygon Fill="{StaticResource SliderBorderBrush}" Stroke="Black" StrokeThickness="2" Points="49,13 62,26 20,68 8,55" />
67+
68+
<Polygon Fill="{StaticResource SliderPosBrush}" StrokeThickness="0" Points="25,85 35,85 35,75 25,75" />
69+
<Polygon Fill="{StaticResource SliderPosBrush}" StrokeThickness="0" Points="45,85 55,85 55,75 45,75" />
70+
<Polygon Fill="{StaticResource SliderPosBrush}" StrokeThickness="0" Points="65,85 75,85 75,75 65,75" />
71+
</Grid>
72+
</Viewbox>
73+
</Border>
74+
</ControlTemplate>
75+
76+
</ResourceDictionary>
77+
78+
</UserControl.Resources>
79+
80+
<Grid VerticalAlignment="Top" Name="MainGrid" Background="Transparent" IsHitTestVisible="True" MouseDown="MainGrid_OnMouseButtonDown" MouseUp="MainGrid_OnMouseButtonUp" MouseMove="MainGrid_OnMouseMove">
81+
<Grid.ColumnDefinitions>
82+
<ColumnDefinition Width="*"/>
83+
<ColumnDefinition Width="Auto"/>
84+
<ColumnDefinition Width="Auto"/>
85+
<ColumnDefinition Width="Auto"/>
86+
</Grid.ColumnDefinitions>
87+
<Grid.RowDefinitions>
88+
<RowDefinition Height="Auto" />
89+
<RowDefinition Height="Auto" />
90+
</Grid.RowDefinitions>
91+
<Grid Name="TrackPart" SizeChanged="TrackPart_OnSizeChanged">
92+
<Grid.ColumnDefinitions>
93+
<ColumnDefinition Width="{Binding ElementName=InlineSliderControl, Path=SetPartWidth}"/>
94+
<ColumnDefinition Width="2"/>
95+
<ColumnDefinition Width="{Binding ElementName=InlineSliderControl, Path=UnsetPartWidth}"/>
96+
</Grid.ColumnDefinitions>
97+
<Border BorderBrush="{StaticResource SliderBorderBrush}" BorderThickness="1,1,0,1" CornerRadius="2,0,0,2" >
98+
<Rectangle RadiusX="2" RadiusY="2" Margin="0,0,-2,0">
99+
<Rectangle.Style>
100+
<Style TargetType="Rectangle">
101+
<Setter Property="Fill" Value="{StaticResource SetBackground}" />
102+
<Style.Triggers>
103+
<DataTrigger Binding="{Binding ElementName=MainGrid, Path=IsMouseOver}" Value="True">
104+
<Setter Property="Fill" Value="{StaticResource SetBackgroundActive}" />
105+
</DataTrigger>
106+
</Style.Triggers>
107+
</Style>
108+
</Rectangle.Style>
109+
</Rectangle>
110+
</Border>
111+
112+
<Border Grid.Column="2" BorderBrush="{StaticResource SliderBorderBrush}" BorderThickness="0,1,1,1" Name="UnsetBorder" CornerRadius="0,2,2,0">
113+
<Rectangle Fill="{StaticResource UnsetBackground}" RadiusX="2" RadiusY="2" Margin="-2,0,0,0" />
114+
</Border>
115+
116+
<Border Grid.Column="1" BorderBrush="{StaticResource SliderPosBrush}" BorderThickness="1">
117+
<Rectangle Fill="{StaticResource SliderPosBrush}" />
118+
</Border>
119+
120+
<Canvas Grid.Column="0" Name="TickCanvas" Grid.ColumnSpan="3" IsHitTestVisible="False" />
121+
122+
</Grid>
123+
124+
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding ElementName=InlineSliderControl, Path=Prompt}"
125+
IsHitTestVisible="False" Padding="4,0,4,2" VerticalAlignment="Center">
126+
<TextBlock.Style>
127+
<Style TargetType="TextBlock">
128+
<Setter Property="Foreground" Value="{StaticResource PromptBrush}" />
129+
<Style.Triggers>
130+
<DataTrigger Binding="{Binding ElementName=MainGrid, Path=IsMouseOver, Mode=OneWay}" Value="True">
131+
<Setter Property="Foreground" Value="{StaticResource PromptActBrush}" />
132+
</DataTrigger>
133+
</Style.Triggers>
134+
</Style>
135+
</TextBlock.Style>
136+
</TextBlock>
137+
<TextBox Grid.Column="0" Grid.Row="0" Name="ValueTextBox"
138+
139+
IsHitTestVisible="False"
140+
HorizontalAlignment="Right"
141+
VerticalAlignment="Center"
142+
Background="Transparent"
143+
Padding="0,0,3,1"
144+
BorderThickness="0"
145+
IsReadOnly="True"
146+
Focusable="False"
147+
TextWrapping="NoWrap"
148+
KeyDown="ValueTextBox_OnKeyDown"
149+
LostFocus="ValueTextBox_OnLostFocus">
150+
<TextBox.Style>
151+
<Style TargetType="TextBox">
152+
<Setter Property="Foreground" Value="{StaticResource PromptBrush}" />
153+
<Style.Triggers>
154+
<DataTrigger Binding="{Binding ElementName=MainGrid, Path=IsMouseOver, Mode=OneWay}" Value="True">
155+
<Setter Property="Foreground" Value="{StaticResource PromptActBrush}" />
156+
</DataTrigger>
157+
</Style.Triggers>
158+
</Style>
159+
</TextBox.Style>
160+
</TextBox>
161+
162+
<Button Grid.Row="0" Grid.Column="1" Name="ButtonEdit" Content="Edit" Width="17"
163+
Click="ButtonBase_OnClick" Template="{StaticResource EditButtonTemplate}"/>
164+
165+
<Canvas Grid.Row="1" Grid.Column="0" Name="TickLabelCanvas" />
166+
167+
</Grid>
168+
</UserControl>

0 commit comments

Comments
 (0)