aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-01-12 15:56:50 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-01-12 15:56:50 +0200
commit9949e351e152a929da696ef2f0a1f8b1668e83fa (patch)
tree40212bc488ea64cbaf137455c6a2280333c997dc /Software/Visual_Studio/PPC/Tango.PPC.UI
parent9016d57f876a70952dda4419d68b568b586ef0ec (diff)
downloadTango-9949e351e152a929da696ef2f0a1f8b1668e83fa.tar.gz
Tango-9949e351e152a929da696ef2f0a1f8b1668e83fa.zip
Merged Beta+ fixes to master.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs20
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs53
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml26
3 files changed, 92 insertions, 7 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs
index b90a1afff..dec58f336 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs
@@ -61,6 +61,12 @@ namespace Tango.PPC.UI
has_touch = true;
}
}
+
+#if !DEBUG
+ ForceTouch();
+ has_touch = true;
+#endif
+
#endif
if (!has_touch)
@@ -72,7 +78,7 @@ namespace Tango.PPC.UI
gridMain.Height = 1280;
viewBox.Child = gridMain;
LockAspectRatio();
- this.SizeChanged += (x, y) =>
+ this.SizeChanged += (x, y) =>
{
LockAspectRatio();
};
@@ -81,6 +87,18 @@ namespace Tango.PPC.UI
Closing += MainWindow_Closing;
}
+ private void ForceTouch()
+ {
+ WindowStyle = WindowStyle.None;
+ ResizeMode = ResizeMode.NoResize;
+ WindowStartupLocation = WindowStartupLocation.Manual;
+ Topmost = false; // sure?
+ Left = 0;
+ Top = 0;
+ Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
+ Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
+ }
+
protected override void OnSourceInitialized(EventArgs e)
{
//var hwndSource = PresentationSource.FromVisual(this) as HwndSource;
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
index d7717e6db..2bb4e9286 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
@@ -23,6 +23,7 @@ namespace Tango.PPC.UI.ViewModels
public class LayoutViewVM : PPCViewModel<ILayoutView>
{
private JobHandler _jobHandler;
+ private bool _resettingDevice;
/// <summary>
/// Gets or sets the module loader.
@@ -127,6 +128,11 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public RelayCommand PowerOffCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the reset command.
+ /// </summary>
+ public RelayCommand ResetCommand { get; set; }
+
#endregion
#region Constructors
@@ -152,7 +158,8 @@ namespace Tango.PPC.UI.ViewModels
PowerCommand = new RelayCommand(() => IsPowerOpened = true);
RestartApplicationCommand = new RelayCommand(RestartApplication);
- PowerOffCommand = new RelayCommand(PowerOffMachine);
+ PowerOffCommand = new RelayCommand(PowerOffMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected);
+ ResetCommand = new RelayCommand(ResetMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected);
}
#endregion
@@ -252,6 +259,7 @@ namespace Tango.PPC.UI.ViewModels
private async void PowerOffMachine()
{
IsMenuOpened = false;
+
if (await NotificationProvider.ShowQuestion("Are you sure you wish to turn off the machine?"))
{
try
@@ -261,10 +269,38 @@ namespace Tango.PPC.UI.ViewModels
catch (Exception ex)
{
LogManager.Log(ex, "Error triggering power down.");
+ await NotificationProvider.ShowError(ex.FlattenMessage());
}
}
}
+ /// <summary>
+ /// Resets the machine.
+ /// </summary>
+ private async void ResetMachine()
+ {
+ IsMenuOpened = false;
+
+ if (!await NotificationProvider.ShowQuestion("Are you sure you want to reset the machine?")) return;
+
+ try
+ {
+ _resettingDevice = true;
+ ResetCommand.RaiseCanExecuteChanged();
+ await MachineProvider.MachineOperator.Reset();
+ await NotificationProvider.ShowInfo("Machine was successfully restarted.");
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError(ex.FlattenMessage());
+ }
+ finally
+ {
+ _resettingDevice = false;
+ ResetCommand.RaiseCanExecuteChanged();
+ }
+ }
+
#endregion
#region Override Methods
@@ -286,6 +322,21 @@ namespace Tango.PPC.UI.ViewModels
}
+ public override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+ MachineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged;
+ }
+
+ private void MachineOperator_StatusChanged(object sender, MachineStatuses e)
+ {
+ InvokeUI(() =>
+ {
+ PowerOffCommand.RaiseCanExecuteChanged();
+ ResetCommand.RaiseCanExecuteChanged();
+ });
+ }
+
#endregion
#region Public Methods
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml
index b4f93fd0a..1700749c2 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml
@@ -130,6 +130,21 @@
<Border Background="{StaticResource TangoPowerMenuOpenedBackgroundBrush}" Height="350" Padding="20" RenderTransformOrigin="0.5,1" VerticalAlignment="Bottom">
+ <Border.Resources>
+ <Style x:Key="PowerButton" TargetType="touch:TouchButton" BasedOn="{StaticResource TangoLinkButton}">
+ <Setter Property="Foreground" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter>
+ <Setter Property="FontSize" Value="{StaticResource TangoTitleFontSize}"></Setter>
+ <Setter Property="HorizontalAlignment" Value="Left"></Setter>
+ <Setter Property="VerticalAlignment" Value="Center"></Setter>
+ <Setter Property="Padding" Value="50 20"></Setter>
+ <Setter Property="Height" Value="Auto"></Setter>
+ <Style.Triggers>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter Property="Foreground" Value="{StaticResource TangoGrayBrush}"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Resources>
<Border.Style>
<Style TargetType="Border">
<Setter Property="RenderTransform">
@@ -159,7 +174,7 @@
</Border.Style>
<Grid>
<Grid.RowDefinitions>
- <RowDefinition Height="1*"/>
+ <RowDefinition Height="1.4*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
@@ -171,9 +186,10 @@
<Image Source="/Images/power-machine.png" Margin="30" />
- <UniformGrid Grid.Column="1" Rows="2">
- <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" Command="{Binding PowerOffCommand}" >Turn Off</touch:TouchButton>
- <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}">Stand By</touch:TouchButton>
+ <UniformGrid Grid.Column="1" Rows="3">
+ <touch:TouchButton Style="{StaticResource PowerButton}" Command="{Binding PowerOffCommand}">Turn Off</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource PowerButton}">Stand By</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource PowerButton}" Command="{Binding ResetCommand}">Reset</touch:TouchButton>
</UniformGrid>
</Grid>
@@ -186,7 +202,7 @@
</Grid.ColumnDefinitions>
<Image Source="/Images/power-tablet.png" Margin="30" />
- <touch:TouchButton Command="{Binding RestartApplicationCommand}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" FontSize="{StaticResource TangoTitleFontSize}">Restart</touch:TouchButton>
+ <touch:TouchButton Command="{Binding RestartApplicationCommand}" Grid.Column="1" Style="{StaticResource PowerButton}">Restart</touch:TouchButton>
</Grid>
</Grid>
</Border>