diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-25 17:27:24 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-25 17:27:24 +0300 |
| commit | 7689f77fe2f356d17a5ad59dbeb4a0fed3ca4a0d (patch) | |
| tree | de4a7897e4cd322435bab966769d98aeea324687 /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | 9e6f2a37d528a1bf50629dc7132f1e4496114aee (diff) | |
| download | Tango-7689f77fe2f356d17a5ad59dbeb4a0fed3ca4a0d.tar.gz Tango-7689f77fe2f356d17a5ad59dbeb4a0fed3ca4a0d.zip | |
Added PPC power up sequence support !
Refactored AppBarItems implementation.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
7 files changed, 174 insertions, 22 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItem.cs new file mode 100644 index 000000000..966e78769 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItem.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.Power; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.UI.AppBarItems +{ + public class PowerUpAppBarItem : AppBarItem + { + private StartPowerUpResponse _status; + public StartPowerUpResponse Status + { + get { return _status; } + set { _status = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Gets or sets the view type. + /// </summary> + public override Type ViewType + { + get + { + return typeof(PowerUpAppBarItemView); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItemView.xaml new file mode 100644 index 000000000..b6b769c69 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItemView.xaml @@ -0,0 +1,30 @@ +<UserControl x:Class="Tango.PPC.UI.AppBarItems.PowerUpAppBarItemView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.AppBarItems" + mc:Ignorable="d" + d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=local:PowerUpAppBarItem, IsDesignTimeCreatable=False}"> + <Grid> + <touch:TouchButton Style="{StaticResource TangoFlatButton}" Command="{Binding PressedCommand}" Padding="0"> + <StackPanel VerticalAlignment="Center"> + <TextBlock Text="{Binding Status.Message}" FontSize="{StaticResource TangoDefaultFontSize}" TextTrimming="CharacterEllipsis"></TextBlock> + <ProgressBar Maximum="100" Value="{Binding Status.ProgressPercentage}" Margin="0 10 0 5" Background="{StaticResource TangoGrayBrush}" Height="5" Foreground="{StaticResource TangoPrimaryAccentBrush}" BorderThickness="0" /> + <DockPanel LastChildFill="False"> + <TextBlock DockPanel.Dock="Left"> + + <Run Text="{Binding Status.ProgressPercentage}"></Run><Run>%</Run> + <Run>Completed</Run> + </TextBlock> + + <!--<TextBlock DockPanel.Dock="Right"> + <Run Text="{Binding MachineProvider.MachineOperator.RunningJobStatus.RemainingTime,Converter={StaticResource TimeSpanToTwoDigitsTimeConverter},FallbackValue=5}"></Run> + <Run FontSize="16" Text="{Binding MachineProvider.MachineOperator.RunningJobStatus.RemainingTime,Converter={StaticResource TimeSpanToLabelConverter},FallbackValue=min}"></Run> + </TextBlock>--> + </DockPanel> + </StackPanel> + </touch:TouchButton> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItemView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItemView.xaml.cs new file mode 100644 index 000000000..599f24d3b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/AppBarItems/PowerUpAppBarItemView.xaml.cs @@ -0,0 +1,28 @@ +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.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.AppBarItems +{ + /// <summary> + /// Interaction logic for PowerOffAppBarItemView.xaml + /// </summary> + public partial class PowerUpAppBarItemView : UserControl + { + public PowerUpAppBarItemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index 3b1e1e2f5..e9de2538e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -49,6 +49,11 @@ namespace Tango.PPC.UI.Notifications public ObservableCollection<NotificationItem> NotificationItems { get; private set; } /// <summary> + /// Gets the application bar items. + /// </summary> + public ObservableCollection<AppBarItem> AppBarItems { get; private set; } + + /// <summary> /// Gets the notification items view. /// </summary> public ICollectionView NotificationItemsView { get; private set; } @@ -65,6 +70,10 @@ namespace Tango.PPC.UI.Notifications { NotificationsVisible = true; NotificationItems = new ObservableCollection<NotificationItem>(); + + AppBarItems = new ObservableCollection<AppBarItem>(); + CollectionViewSource.GetDefaultView(AppBarItems).SortDescriptions.Add(new SortDescription(nameof(AppBarItem.Priority), ListSortDirection.Ascending)); + TaskBarItems = new ObservableCollection<TaskBarItem>(); _pendingMessageBoxes = new ConcurrentQueue<PendingNotification<MessageBoxVM, bool>>(); _pendingDialogs = new ConcurrentQueue<PendingNotification<DialogAndView, DialogViewVM>>(); @@ -472,22 +481,12 @@ namespace Tango.PPC.UI.Notifications /// </summary> public bool IsInGlobalBusyState { get; private set; } - private AppBarItem _currentAppBarItem; - /// <summary> - /// Gets the current application bar item. - /// </summary> - public AppBarItem CurrentAppBarItem - { - get { return _currentAppBarItem; } - set { _currentAppBarItem = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasAppBarItem)); } - } - /// <summary> /// Gets a value indicating whether this instance has application bar item. /// </summary> - public bool HasAppBarItem + public bool HasAppBarItems { - get { return CurrentAppBarItem != null; } + get { return AppBarItems.Count > 0; } } /// <summary> @@ -498,8 +497,9 @@ namespace Tango.PPC.UI.Notifications public AppBarItem PushAppBarItem(AppBarItem appBarItem) { LogManager.Log($"Pushing AppBarItem '{appBarItem.GetType().Name}'."); - CurrentAppBarItem = appBarItem; + AppBarItems.Add(appBarItem); appBarItem.RemoveAction = () => PopAppBarItem(appBarItem); + RaisePropertyChanged(nameof(HasAppBarItems)); return appBarItem; } @@ -508,9 +508,9 @@ namespace Tango.PPC.UI.Notifications /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> - public AppBarItem PushAppBarItem<T>() where T : AppBarItem + public T PushAppBarItem<T>() where T : AppBarItem { - return PushAppBarItem(Activator.CreateInstance<T>()); + return PushAppBarItem(Activator.CreateInstance<T>()) as T; } /// <summary> @@ -519,8 +519,12 @@ namespace Tango.PPC.UI.Notifications /// <param name="appBarItem">The application bar item.</param> public void PopAppBarItem(AppBarItem appBarItem) { - LogManager.Log($"Popping out AppBarItem '{appBarItem.GetType().Name}'."); - CurrentAppBarItem = null; + InvokeUI(() => + { + LogManager.Log($"Popping out AppBarItem '{appBarItem.GetType().Name}'."); + AppBarItems.Remove(appBarItem); + RaisePropertyChanged(nameof(HasAppBarItems)); + }); } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 10d3a82a5..0cdf78614 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -114,7 +114,11 @@ <Compile Include="..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="AppBarItems\PowerUpAppBarItem.cs" /> <Compile Include="AppBarItems\PowerOffAppBarItem.cs" /> + <Compile Include="AppBarItems\PowerUpAppBarItemView.xaml.cs"> + <DependentUpon>PowerUpAppBarItemView.xaml</DependentUpon> + </Compile> <Compile Include="AppBarItems\PowerOffAppBarItemView.xaml.cs"> <DependentUpon>PowerOffAppBarItemView.xaml</DependentUpon> </Compile> @@ -238,6 +242,10 @@ <Compile Include="Views\RestartingSystemView.xaml.cs"> <DependentUpon>RestartingSystemView.xaml</DependentUpon> </Compile> + <Page Include="AppBarItems\PowerUpAppBarItemView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="AppBarItems\PowerOffAppBarItemView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -705,7 +713,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)"</ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index b53a54682..e84fd81a1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -21,6 +21,7 @@ using Tango.PPC.Common.WatchDog; using Tango.PPC.UI.Dialogs; using Tango.SharedUI; using System.Data.Entity; +using Tango.PPC.UI.AppBarItems; namespace Tango.PPC.UI.ViewModels { @@ -33,6 +34,7 @@ namespace Tango.PPC.UI.ViewModels private DispatcherTimer _date_timer; private bool _isPowerUpDialogShown; private bool _isThreadLoadingShown; + private PowerUpAppBarItem _powerUpAppBar; private DateTime _currentDateTime; /// <summary> @@ -64,11 +66,47 @@ namespace Tango.PPC.UI.ViewModels { base.OnApplicationReady(); MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived; - MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; + MachineProvider.MachineOperator.FirmwareStarted += MachineOperator_FirmwareStarted; MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged; MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired; + + MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; + MachineProvider.MachineOperator.PowerUpProgress += MachineOperator_PowerUpProgress; + MachineProvider.MachineOperator.PowerUpEnded += MachineOperator_PowerUpEnded; + } + + #region Power Up + + private void MachineOperator_PowerUpEnded(object sender, EventArgs e) + { + _powerUpAppBar?.Close(); + _powerUpAppBar = null; + } + + private void MachineOperator_PowerUpProgress(object sender, PMR.Power.StartPowerUpResponse status) + { + if (_powerUpAppBar != null) + { + _powerUpAppBar.Status = status; + } } + private void MachineOperator_PowerUpStarted(object sender, PMR.Power.StartPowerUpResponse e) + { + InvokeUI(() => + { + if (_powerUpAppBar != null) + { + _powerUpAppBar.Close(); + } + + _powerUpAppBar = NotificationProvider.PushAppBarItem<PowerUpAppBarItem>(); + _powerUpAppBar.Priority = AppBarPriority.Low; + }); + } + + #endregion + #region Event Handlers /// <summary> @@ -101,7 +139,7 @@ namespace Tango.PPC.UI.ViewModels }); } - private async void MachineOperator_PowerUpStarted(object sender, EventArgs e) + private async void MachineOperator_FirmwareStarted(object sender, EventArgs e) { if (_isPowerUpDialogShown) { 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 1700749c2..21cc90f2d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -284,8 +284,21 @@ </Grid> <Grid> - <Grid Margin="20 0 60 0" Height="80" Visibility="{Binding NotificationProvider.HasAppBarItem,Converter={StaticResource BooleanToVisibilityConverter}}"> - <ContentControl Content="{Binding NotificationProvider.CurrentAppBarItem,Converter={StaticResource AppBarItemConverter}}"></ContentControl> + <Grid Margin="20 0 60 0" Height="80" Visibility="{Binding NotificationProvider.HasAppBarItems,Converter={StaticResource BooleanToVisibilityConverter}}"> + <ItemsControl ItemsSource="{Binding NotificationProvider.AppBarItems}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <Grid IsItemsHost="True" /> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <ContentControl Content="{Binding Converter={StaticResource AppBarItemConverter}}"></ContentControl> + </Grid> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> </Grid> <!--External Header Content Here--> |
