diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-19 12:07:38 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-19 12:07:38 +0300 |
| commit | 5ed1e236bc0db0f1480344d0934cbb42df20df7b (patch) | |
| tree | d242fecf6d74a1af7b00760c1fd23a62fddda1c0 /Software/Visual_Studio/PPC/Modules | |
| parent | db94be7a673886297f5a6dfe4331793452a9f609 (diff) | |
| parent | 1d2d515c91a78a8a3e373e05ae925ba6af1f32fd (diff) | |
| download | Tango-5ed1e236bc0db0f1480344d0934cbb42df20df7b.tar.gz Tango-5ed1e236bc0db0f1480344d0934cbb42df20df7b.zip | |
merge, no change
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
14 files changed, 219 insertions, 37 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs new file mode 100644 index 000000000..fce5bedf6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobToEmbroideryImageConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobToEmbroideryImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Job job = value as Job; + + if (job != null && job.EmbroideryFileData != null) + { + try + { + return job.EmbroideryJpeg.ToBitmapSource(); + } + catch + { + return null; + } + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png Binary files differnew file mode 100644 index 000000000..f71bc2a70 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/Embroider.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs new file mode 100644 index 000000000..cb1b892fd --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.NavigationObjects +{ + public class TwineCatalogNavigationObject + { + public Rml RML { get; set; } + + public BrushStop BrushStop { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 8659367b3..bbfef32fd 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -172,6 +172,7 @@ <Compile Include="Converters\ColorSpaceToVisibilityConverter.cs" /> <Compile Include="Converters\JobProgressToPositionConverter.cs" /> <Compile Include="Converters\JobsCategoryToVisibilityConverter.cs" /> + <Compile Include="Converters\JobToEmbroideryImageConverter.cs" /> <Compile Include="Converters\JobToPieImageConverter.cs" /> <Compile Include="Converters\JobTypeToImageConverter.cs" /> <Compile Include="Dialogs\AdvancedColorCorrectionView.xaml.cs"> @@ -216,6 +217,7 @@ <Compile Include="Messages\NavigatedToJobsModuleMessage.cs" /> <Compile Include="NavigationObjects\JobNavigationObject.cs" /> <Compile Include="NavigationObjects\JobSummeryNavigationObject.cs" /> + <Compile Include="NavigationObjects\TwineCatalogNavigationObject.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs index 8884d471b..f63d2959e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs @@ -22,5 +22,10 @@ namespace Tango.PPC.Jobs.ViewContracts /// Displays the fine tuning region. /// </summary> void DisplayFineTuning(); + + /// <summary> + /// Scrolls to top. + /// </summary> + void ScrollToTop(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 3b7c70bf8..d1c5a8536 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -34,6 +34,9 @@ using Tango.PPC.Jobs.AppButtons; using Tango.Core.Threading; using System.Diagnostics; using System.Runtime.ExceptionServices; +using Tango.Explorer; +using Tango.PPC.Storage; +using System.IO; namespace Tango.PPC.Jobs.ViewModels { @@ -306,6 +309,11 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand RepeatFineTuningCommand { get; set; } + /// <summary> + /// Gets or sets the export embroidery command. + /// </summary> + public RelayCommand ExportEmbroideryCommand { get; set; } + #endregion #region Constructors @@ -385,6 +393,7 @@ namespace Tango.PPC.Jobs.ViewModels RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); OpenTwineCatalogCommand = new RelayCommand<BrushStop>(OpenTwineCatalog); + ExportEmbroideryCommand = new RelayCommand(ExportEmbroidery); } #endregion @@ -400,6 +409,8 @@ namespace Tango.PPC.Jobs.ViewModels { if (!(_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid))) { + View.ScrollToTop(); + LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); @@ -487,7 +498,7 @@ namespace Tango.PPC.Jobs.ViewModels } finally { - InvokeUIOnIdle(() => + InvokeUI(() => { IsFree = true; //NotificationProvider.ReleaseGlobalBusyMessage(); @@ -522,6 +533,8 @@ namespace Tango.PPC.Jobs.ViewModels } } + Job.LastUpdated = DateTime.UtcNow; + Job.JobStatus = BL.Enumerations.JobStatuses.Draft; await _db.SaveChangesAsync(); RaiseMessage(new JobSavedMessage() { Job = Job }); @@ -863,7 +876,11 @@ namespace Tango.PPC.Jobs.ViewModels /// <param name="stop">The stop.</param> private async void OpenTwineCatalog(BrushStop stop) { - var catalogItem = await NavigationManager.NavigateForResult<JobsModule, TwineCatalogView, CatalogItem, BrushStop>(stop, true); + var catalogItem = await NavigationManager.NavigateForResult<JobsModule, TwineCatalogView, CatalogItem, TwineCatalogNavigationObject>(new TwineCatalogNavigationObject() + { + BrushStop = stop, + RML = Job.Rml, + }, true); if (catalogItem != null) { @@ -1140,6 +1157,45 @@ namespace Tango.PPC.Jobs.ViewModels #endregion + #region Export Embroidery + + private async void ExportEmbroidery() + { + try + { + if (!StorageProvider.IsConnected) + { + await NotificationProvider.ShowError("No storage device connected."); + return; + } + + var result = await NavigationManager. + NavigateForResult<StorageModule, + Storage.Views.MainView, ExplorerFileItem, + Storage.Models.StorageNavigationRequest>( + new Storage.Models.StorageNavigationRequest() + { + Intent = Storage.Models.StorageNavigationIntent.SaveFile, + DefaultFileName = Job.Name + Path.GetExtension(Job.EmbroideryFileName), + Filter = Path.GetExtension(Job.EmbroideryFileName), + Title = "Export Embroidery File", + }); + + if (result != null) + { + File.WriteAllBytes(Path.HasExtension(result.Path) ? result.Path : result.Path + Path.GetExtension(Job.EmbroideryFileName), Job.EmbroideryFileData); + await NotificationProvider.ShowSuccess("Embroidery file exported successfully."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting embroidery file."); + await NotificationProvider.ShowError("An error occurred while trying to save the selected embroidery file."); + } + } + + #endregion + #region IPPC ViewModel Overrides /// <summary> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 530eae385..08d135e21 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -422,15 +422,18 @@ namespace Tango.PPC.Jobs.ViewModels vm.SelectedJobType = vm.SupportedJobTypes.First(); } - if (machine.SupportedJobTypes.Count != 1 || machine.SupportedColorSpaces.Count != 1) + if (twnFile == null) { - vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); - if (!vm.DialogResult) return; - } - else - { - vm.SelectedJobType = machine.SupportedJobTypes.First(); - vm.SelectedColorSpace = machine.SupportedColorSpaces.First(); + if (machine.SupportedJobTypes.Count != 1 || machine.SupportedColorSpaces.Count != 1) + { + vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); + if (!vm.DialogResult) return; + } + else + { + vm.SelectedJobType = machine.SupportedJobTypes.First(); + vm.SelectedColorSpace = machine.SupportedColorSpaces.First(); + } } settings.LastJobType = vm.SelectedJobType; @@ -498,6 +501,7 @@ namespace Tango.PPC.Jobs.ViewModels st.Red = stop.R; st.Green = stop.G; st.Blue = stop.B; + st.ColorSpaceGuid = job.ColorSpaceGuid; s.BrushStops.Add(st); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs index 1fd5c8474..7c6ed0c81 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs @@ -9,6 +9,7 @@ using Tango.BL.Entities; using Tango.Core.Commands; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; +using Tango.PPC.Jobs.NavigationObjects; using Tango.Settings; namespace Tango.PPC.Jobs.ViewModels @@ -16,11 +17,12 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Represents the twine catalog view model. /// </summary> - /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> - /// <seealso cref="Tango.PPC.Common.Navigation.INavigationResultProvider{Tango.BL.Catalogs.CatalogItem, Tango.BL.Entities.BrushStop}" /> - public class TwineCatalogViewVM : PPCViewModel, INavigationResultProvider<CatalogItem, BrushStop> + /// <seealso cref="PPCViewModel" /> + /// <seealso cref="INavigationResultProvider{CatalogItem, TwineCatalogNavigationObject}" /> + public class TwineCatalogViewVM : PPCViewModel, INavigationResultProvider<CatalogItem, TwineCatalogNavigationObject> { private bool _confirmed; + private ObservablesContext _db; private Catalog _catalog; /// <summary> @@ -73,11 +75,7 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public override void OnApplicationStarted() { - InvokeUI(() => - { - Catalog = CatalogLoader.LoadCatalog(BL.Enumerations.ColorSpaces.Twine, ObservablesStaticCollections.Instance.Context); - Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); - }); + _db = ObservablesContext.CreateDefault(); } /// <summary> @@ -96,7 +94,6 @@ namespace Tango.PPC.Jobs.ViewModels { SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors.Add(SelectedItem.Entity.Name); SettingsManager.Default.Save(); - Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); _confirmed = true; NavigationManager.NavigateBack(); @@ -122,11 +119,16 @@ namespace Tango.PPC.Jobs.ViewModels /// Called when the navigation object has been received /// </summary> /// <param name="brushStop">The brush stop.</param> - public virtual void OnNavigationObjectReceived(BrushStop brushStop) + public async virtual void OnNavigationObjectReceived(TwineCatalogNavigationObject obj) { - if (brushStop.ColorCatalog != null) + IsFree = false; + Catalog = await CatalogLoader.LoadCatalog(BL.Enumerations.ColorSpaces.Twine, obj.RML, _db); + Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); + IsFree = true; + + if (obj.BrushStop.ColorCatalog != null) { - SelectedItem = Catalog.Groups.SelectMany(x => x.Items).SingleOrDefault(x => x.Entity.Guid == brushStop.ColorCatalog.Guid); + SelectedItem = Catalog.Groups.SelectMany(x => x.Items).SingleOrDefault(x => x.Entity.Guid == obj.BrushStop.ColorCatalog.Guid); } else { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml index 2655bdf89..cf49bd024 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml @@ -148,7 +148,7 @@ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}"> <TextBlock.Style> <Style TargetType="TextBlock"> - <Setter Property="Text" Value="now dying"></Setter> + <Setter Property="Text" Value="now dyeing"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding RunningJobStatus.IsSettingUp}" Value="True"> <Setter Property="Text" Value="getting ready"></Setter> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index aa04398f1..6febb02ef 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -22,6 +22,7 @@ <UserControl.Resources> <localConverters:ColorSpaceToVisibilityConverter x:Key="ColorSpaceToVisibilityConverter" /> + <localConverters:JobToEmbroideryImageConverter x:Key="JobToEmbroideryImageConverter" /> <BitmapImage x:Key="Image_Out_Of_Gamut" UriSource="../Images/JobView/error.png" /> <BitmapImage x:Key="Image_Replace_Color" UriSource="../Images/JobView/replace-color.png" /> <BitmapImage x:Key="Image_Color_Picker" UriSource="../Images/JobView/color-picker.png" /> @@ -39,7 +40,7 @@ <DataTemplate x:Key="Volume_Template" DataType="{x:Type entities:BrushStop}"> <Grid> - <ItemsControl ItemsSource="{Binding LiquidVolumes}" VerticalAlignment="Center" Margin="0 0 -90 0"> + <ItemsControl ItemsSource="{Binding LiquidVolumesOrdered}" VerticalAlignment="Center" Margin="0 0 -90 0"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel> @@ -100,7 +101,7 @@ <DataTemplate x:Key="TWINE_Template" DataType="{x:Type entities:BrushStop}"> <DockPanel> - <touch:TouchIconButton Margin="0 0 -40 0" CornerRadius="50" Width="32" Height="32" Padding="5" RippleBrush="{StaticResource TangoRippleDarkBrush}" DockPanel.Dock="Right" Icon="Palette" Foreground="{StaticResource TangoPrimaryAccentBrush}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.OpenTwineCatalogCommand}" CommandParameter="{Binding}"></touch:TouchIconButton> + <touch:TouchIconButton Margin="0 0 -50 -10" CornerRadius="50" Width="50" Height="50" Padding="13" RippleBrush="{StaticResource TangoRippleDarkBrush}" DockPanel.Dock="Right" Icon="Palette" Foreground="{StaticResource TangoPrimaryAccentBrush}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.OpenTwineCatalogCommand}" CommandParameter="{Binding}"></touch:TouchIconButton> <touch:TouchAutoComplete Margin="2 0" ItemsSource="{Binding ElementName=view,Path=DataContext.TwineCatalogItems}" Watermark="Color Code" PopupHeight="250" DisplayMemberPath="Name" AutoCompleteProvider="{Binding ElementName=view,Path=DataContext.TwineCatalogAutoCompleteProvider}" SelectedItem="{Binding ColorCatalog,Mode=TwoWay,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" keyboard:KeyboardView.Container="{Binding ElementName=Container}"> <touch:TouchAutoComplete.ItemTemplate> <DataTemplate> @@ -624,6 +625,26 @@ </Grid> </Border> + <Border Style="{StaticResource TangoTouchBorder}" Margin="0 20 0 0" Padding="0 0 0 50" Visibility="{Binding Job.EmbroideryFileData,Converter={StaticResource IsNullToVisibilityConverter}}"> + <StackPanel> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"> + <Image Source="../Images/embroidery.png" RenderOptions.BitmapScalingMode="Fant" Width="39" /> + <TextBlock FontWeight="Medium" Margin="20 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource TangoExpanderHeaderFontSize}">Embroidery File</TextBlock> + </StackPanel> + + <StackPanel Style="{StaticResource Level2ContainerExtraMargin}"> + <DockPanel> + <Image Source="{Binding Job,Converter={StaticResource JobToEmbroideryImageConverter}}" Width="230" Stretch="Uniform" HorizontalAlignment="Left"></Image> + + <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right"> + <TextBlock TextWrapping="Wrap" TextAlignment="Right">Export the attached embroidery file to storage.</TextBlock> + <touch:TouchButton Command="{Binding ExportEmbroideryCommand}" Style="{StaticResource TangoHollowButton}" Width="240" Height="60" Margin="0 30 0 0" HorizontalAlignment="Right">EXPORT FILE</touch:TouchButton> + </StackPanel> + </DockPanel> + </StackPanel> + </StackPanel> + </Border> + <Border Style="{StaticResource TangoTouchBorder}" Margin="0 20 0 0" Padding="0 0 0 50"> <StackPanel> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs index 3cd6e1bce..880aa8a3a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs @@ -44,8 +44,7 @@ namespace Tango.PPC.Jobs.Views public void OnNavigatedTo() { - FloatEditing(); - scrollViewer.ScrollToTop(); + } private void OnBrushStopFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) @@ -122,5 +121,11 @@ namespace Tango.PPC.Jobs.Views _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); } } + + public void ScrollToTop() + { + FloatEditing(); + scrollViewer.ScrollToTop(); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml index 3a29c3dd2..a5ce50ad2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml @@ -22,15 +22,17 @@ </Border> <Grid Grid.Row="1"> - <DockPanel Margin="10"> - <Border DockPanel.Dock="Bottom" Height="100"> - <touch:TouchButton Command="{Binding OKCommand}" HorizontalAlignment="Right" VerticalAlignment="Center" Content="OK" Height="50" Width="150" Style="{StaticResource TangoHollowButton}" Margin="0 0 20 0" /> - </Border> + <touch:TouchLoadingPanel IsLoading="{Binding IsBusy}"> + <DockPanel Margin="10"> + <Border DockPanel.Dock="Bottom" Height="100"> + <touch:TouchButton Command="{Binding OKCommand}" HorizontalAlignment="Right" VerticalAlignment="Center" Content="OK" Height="50" Width="150" Style="{StaticResource TangoHollowButton}" Margin="0 0 20 0" /> + </Border> - <Border Style="{StaticResource TangoTouchBorder}" Padding="20 20 20 100" Margin="0 10 0 0"> - <controls:TwineCatalogViewer Catalog="{Binding Catalog}" Recent="{Binding Recent}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" /> - </Border> - </DockPanel> + <Border Style="{StaticResource TangoTouchBorder}" Padding="20 20 20 100" Margin="0 10 0 0"> + <controls:TwineCatalogViewer Catalog="{Binding Catalog}" Recent="{Binding Recent}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" /> + </Border> + </DockPanel> + </touch:TouchLoadingPanel> </Grid> </Grid> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs index 47d5835f5..c368e77e2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs @@ -17,6 +17,7 @@ namespace Tango.PPC.Technician.ViewModels { private IOperationSystemManager _os; private Timer _statsTimer; + private bool _resettingDevice; private float _cpu; public float CPU @@ -39,6 +40,8 @@ namespace Tango.PPC.Technician.ViewModels set { _temperature = value; RaisePropertyChangedAuto(); } } + public RelayCommand ResetDeviceCommand { get; set; } + public RelayCommand RestartCommand { get; set; } public RelayCommand ShutdownCommand { get; set; } @@ -58,6 +61,27 @@ namespace Tango.PPC.Technician.ViewModels ShutdownCommand = new RelayCommand(ShutdownSystem); FactoryResetCommand = new RelayCommand(FactoryReset); ExitToExplorerCommand = new RelayCommand(ExitToExplorer); + ResetDeviceCommand = new RelayCommand(ResetDevice, () => !_resettingDevice); + } + + private async void ResetDevice() + { + try + { + _resettingDevice = true; + ResetDeviceCommand.RaiseCanExecuteChanged(); + await MachineProvider.MachineOperator.ResetDFU(); + await NotificationProvider.ShowInfo("Embedded device has been reset successfully."); + } + catch (Exception ex) + { + await NotificationProvider.ShowError(ex.FlattenMessage()); + } + finally + { + _resettingDevice = false; + ResetDeviceCommand.RaiseCanExecuteChanged(); + } } private async void FactoryReset() @@ -114,7 +138,7 @@ namespace Tango.PPC.Technician.ViewModels { CPU = GetAppCPU(); RAM = GetAppRam(); - Temperature = GetTemperature(); + //Temperature = GetTemperature(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml index 0b067b09b..f6e6370c1 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml @@ -50,7 +50,14 @@ </UniformGrid> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" TextElement.FontSize="{StaticResource TangoTitleFontSize}"> - <touch:TouchButton Command="{Binding RestartCommand}" Height="60" Background="{StaticResource TangoErrorBrush}">Restart Device</touch:TouchButton> + <touch:TouchButton Command="{Binding ResetDeviceCommand}" Height="60" Content="Reset Machine"> + <touch:TouchButton.Style> + <Style TargetType="touch:TouchButton" BasedOn="{StaticResource {x:Type touch:TouchButton}}"> + <Setter Property="Background" Value="{StaticResource TangoErrorBrush}"></Setter> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> + <touch:TouchButton Command="{Binding RestartCommand}" Height="60" Background="{StaticResource TangoErrorBrush}" Margin="0 20 0 0">Restart Device</touch:TouchButton> <touch:TouchButton Command="{Binding ShutdownCommand}" Height="60" Background="{StaticResource TangoErrorBrush}" Margin="0 20 0 0">Shutdown Device</touch:TouchButton> <touch:TouchButton Command="{Binding FactoryResetCommand}" Height="60" Background="{StaticResource TangoErrorBrush}" Margin="0 20 0 0">Factory Reset</touch:TouchButton> <touch:TouchButton Command="{Binding ExitToExplorerCommand}" Height="60" Background="{StaticResource TangoErrorBrush}" Margin="0 20 0 0">Exit To Shell</touch:TouchButton> |
