diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-11 20:05:13 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-11 20:05:13 +0300 |
| commit | 14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6 (patch) | |
| tree | 78901a0b5053610ce2f86b436a037f17715d6368 /Software/Visual_Studio/PPC | |
| parent | 009a02d57e244e9a8ed5d70fc0743f10f68f5a33 (diff) | |
| download | Tango-14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6.tar.gz Tango-14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6.zip | |
Working on PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC')
12 files changed, 160 insertions, 36 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml index 550accac3..c7f42f14d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml @@ -101,9 +101,13 @@ <Style TargetType="Grid"> <Setter Property="Visibility" Value="Collapsed"></Setter> <Style.Triggers> - <DataTrigger Binding="{Binding JobType}" Value="{x:Static enumerations:JobTypes.Embroidery}"> + <MultiDataTrigger> + <MultiDataTrigger.Conditions> + <Condition Binding="{Binding JobType}" Value="{x:Static enumerations:JobTypes.Embroidery}" /> + <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=IsActive}" Value="False" /> + </MultiDataTrigger.Conditions> <Setter Property="Visibility" Value="Visible"></Setter> - </DataTrigger> + </MultiDataTrigger> </Style.Triggers> </Style> </Grid.Style> @@ -112,6 +116,5 @@ <Run Text="x"></Run><Run Text="{Binding NumberOfUnits}"></Run> </TextBlock> </Grid> - <TextBlock></TextBlock> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs index 2b9d9c7a9..2c03ad452 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs @@ -20,7 +20,13 @@ namespace Tango.PPC.Jobs.Controls /// </summary> public partial class JobSummeryViewer : UserControl { - + public bool IsActive + { + get { return (bool)GetValue(IsActiveProperty); } + set { SetValue(IsActiveProperty, value); } + } + public static readonly DependencyProperty IsActiveProperty = + DependencyProperty.Register("IsActive", typeof(bool), typeof(JobSummeryViewer), new PropertyMetadata(false)); public bool DisplayMarkers { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index 12f2c9642..19e28f6a9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -47,7 +47,7 @@ namespace Tango.PPC.Jobs.ViewModels private void StartJob() { - ApplicationManager.ConnectedMachine.Print(Job, Adapter.ProcessParametersTables.First()); + ApplicationManager.ConnectedMachine.Print(Job); NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } 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 82cfc3456..b23e8b8ed 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 @@ -181,6 +181,11 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand StartSampleDyeCommand { get; set; } + /// <summary> + /// Gets or sets the dye command. + /// </summary> + public RelayCommand DyeCommand { get; set; } + #endregion #region Constructors @@ -230,6 +235,7 @@ namespace Tango.PPC.Jobs.ViewModels _check_gamut_thread.IsBackground = true; StartSampleDyeCommand = new RelayCommand(StartSampleDye); + DyeCommand = new RelayCommand(StartJob, CanStartJob); } #endregion @@ -260,6 +266,19 @@ namespace Tango.PPC.Jobs.ViewModels } } + private void StartJob() + { + ApplicationManager.ConnectedMachine.Print(Job); + NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); + } + + private bool CanStartJob() + { + return + Job != null && + !Job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.IsOutOfGamut); + } + #endregion #region Segments Management @@ -417,10 +436,10 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Starts a sample dye. /// </summary> - private async void StartSampleDye() + private void StartSampleDye() { Job sampleDyeJob = Job.Clone(); - sampleDyeJob.Name += " sample"; + sampleDyeJob.Name = Job.Name + " (sample)"; if (Job.JobType == BL.Enumerations.JobTypes.Embroidery) { @@ -436,7 +455,9 @@ namespace Tango.PPC.Jobs.ViewModels } } - await NavigationManager.NavigateForResult<JobsModule, JobProgressView, Object, Job>(sampleDyeJob); + ApplicationManager.ConnectedMachine.Print(sampleDyeJob); + + NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } #endregion @@ -458,6 +479,11 @@ namespace Tango.PPC.Jobs.ViewModels stop.IsOutOfGamut = TangoColorConverter.IsOutOfGamut(stop); stop.OutOfGamutChecked = true; } + + InvokeUI(() => + { + DyeCommand.RaiseCanExecuteChanged(); + }); } } } @@ -479,6 +505,8 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public async override void OnNavigatedTo() { + if (_job_to_load == null) return; + NotificationProvider.SetGlobalBusyMessage("Loading job details..."); _can_navigate_back = false; @@ -518,14 +546,17 @@ namespace Tango.PPC.Jobs.ViewModels { NotificationProvider.ReleaseGlobalBusyMessage(); }); + + _job_to_load = null; } + /// <summary> - /// Called before the navigation system navigates from this object. + /// Called before the navigation system navigates back from this object. /// Return false to abort the navigation. /// </summary> /// <returns></returns> - public async override Task<bool> OnNavigateOutRequest() + public async override Task<bool> OnNavigateBackRequest() { bool result = true; 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 39963201e..8f2ea355f 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 @@ -270,6 +270,9 @@ namespace Tango.PPC.Jobs.ViewModels Job job = new Job(); job.Name = "untitled"; + job.NumberOfHeads = 1; + job.NumberOfUnits = 1; + job.SampleUnitsOrMeters = 1; job.CreationDate = DateTime.UtcNow; job.JobStatus = JobStatuses.Draft; job.JobType = vm.SelectedJobType.Value; 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 3a4a895dc..28672a920 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 @@ -15,7 +15,7 @@ <UserControl.Resources> <converters:JobProgressToPositionConverter x:Key="JobProgressToPositionConverter" /> </UserControl.Resources> - + <Grid> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 100 0 0"> <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" HorizontalAlignment="Center" Text="{Binding Job.Name,FallbackValue='Job Name'}"></TextBlock> @@ -54,18 +54,25 @@ <StackPanel> <Canvas.Left> <MultiBinding Converter="{StaticResource JobProgressToPositionConverter}"> - <Binding Path="RunningJobStatus.Progress" /> - <Binding Path="RunningJobStatus.TotalProgress" /> + <Binding Path="RunningJobStatus.CurrentUnitProgress" /> + <Binding Path="RunningJobStatus.CurrentUnitTotalProgress" /> <Binding RelativeSource="{RelativeSource AncestorType=Canvas}" Path="ActualWidth" /> </MultiBinding> </Canvas.Left> - <StackPanel Margin="-30 0 0 0"> + <StackPanel Margin="-50 0 0 0"> <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">now dying</TextBlock> <touch:TouchIcon Margin="0 8 0 0" HorizontalAlignment="Center" Icon="Water" Angle="180" Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="40" Height="40" /> </StackPanel> </StackPanel> </Canvas> - <controls:JobSummeryViewer Height="30" Width="600" DisplayMarkers="False" DataContext="{Binding Job}" /> + + <Grid> + <controls:JobSummeryViewer Height="30" Width="600" DisplayMarkers="False" IsActive="True" DataContext="{Binding Job}" /> + + <TextBlock Margin="0 0 -40 0" VerticalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" HorizontalAlignment="Right"> + <Run Text="x"></Run><Run Text="{Binding RunningJobStatus.RemainingUnits}"></Run> + </TextBlock> + </Grid> </StackPanel> </Grid> </StackPanel> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml index b956d7b6c..377348581 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml @@ -56,7 +56,7 @@ <TextBlock Margin="40 10 0 0" FontSize="{StaticResource TangoTitleFontSize}">Tap 'DYE' to start the dying process...</TextBlock> </StackPanel> - <controls:JobSummeryViewer Height="50" Margin="-6 0 -6 0" DataContext="{Binding Job}" VerticalAlignment="Bottom" /> + <controls:JobSummeryViewer Height="50" DataContext="{Binding Job}" VerticalAlignment="Bottom" /> </Grid> </DockPanel> </Grid> 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 43917fe55..cf1c3fa37 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 @@ -573,21 +573,63 @@ </touch:TouchExpander.Header> <StackPanel Margin="60 20 0 0"> - <TextBlock> - <Run>Dye 1 or more units in order to get approval.</Run> - <LineBreak/> - <Run>Once approved, you can dye the entire job.</Run> - </TextBlock> - <DockPanel Margin="0 50 0 0" LastChildFill="True" Width="450" HorizontalAlignment="Left"> - <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">How many sample units?</TextBlock> + <ContentControl Content="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext}"> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="ContentTemplate"> + <Setter.Value> + <DataTemplate> + <StackPanel> + <TextBlock> + <Run>Dye 1 or more units in order to get approval.</Run> + <LineBreak/> + <Run>Once approved, you can dye the entire job.</Run> + </TextBlock> - <DockPanel Margin="50 0 0 0"> - <touch:TouchIconButton Command="{Binding IncreaseDecreaseSamplesToDyeCommand}" CommandParameter="-" DockPanel.Dock="Left" Icon="Minus" Padding="15" Style="{StaticResource TangoHollowButton}" BorderThickness="2" Width="51" Height="51" /> - <touch:TouchIconButton Command="{Binding IncreaseDecreaseSamplesToDyeCommand}" CommandParameter="+" DockPanel.Dock="Right" Icon="Plus" Padding="15" Style="{StaticResource TangoHollowButton}" BorderThickness="2" Width="51" Height="51" /> - <touch:TouchNumericTextBox Value="{Binding Job.SampleUnitsOrMeters}" Minimum="1" Maximum="100" HorizontalContentAlignment="Center" VerticalAlignment="Center" Margin="10 0" Foreground="{StaticResource TangoPrimaryAccentBrush}" FontSize="{StaticResource TangoTitleFontSize}" DockPanel.Dock="Right" KeyboardContainer="{Binding ElementName=Container}" /> - </DockPanel> - </DockPanel> + <DockPanel Margin="0 50 0 0" LastChildFill="True" Width="450" HorizontalAlignment="Left"> + <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">How many sample units?</TextBlock> + + <DockPanel Margin="50 0 0 0"> + <touch:TouchIconButton Command="{Binding IncreaseDecreaseSamplesToDyeCommand}" CommandParameter="-" DockPanel.Dock="Left" Icon="Minus" Padding="15" Style="{StaticResource TangoHollowButton}" BorderThickness="2" Width="51" Height="51" /> + <touch:TouchIconButton Command="{Binding IncreaseDecreaseSamplesToDyeCommand}" CommandParameter="+" DockPanel.Dock="Right" Icon="Plus" Padding="15" Style="{StaticResource TangoHollowButton}" BorderThickness="2" Width="51" Height="51" /> + <touch:TouchNumericTextBox Value="{Binding Job.SampleUnitsOrMeters}" Minimum="1" Maximum="100" HorizontalContentAlignment="Center" VerticalAlignment="Center" Margin="10 0" Foreground="{StaticResource TangoPrimaryAccentBrush}" FontSize="{StaticResource TangoTitleFontSize}" DockPanel.Dock="Right" KeyboardContainer="{Binding ElementName=Container}" /> + </DockPanel> + </DockPanel> + </StackPanel> + </DataTemplate> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Job.JobType}" Value="{x:Static enumerations:JobTypes.Sewing}"> + <Setter Property="ContentTemplate"> + <Setter.Value> + <DataTemplate> + <StackPanel> + <TextBlock> + <Run>Dye several meters per segment in order to get approval.</Run> + <LineBreak/> + <Run>Once approved, you can dye the entire job.</Run> + </TextBlock> + + <DockPanel Margin="0 50 0 0" LastChildFill="True" Width="450" HorizontalAlignment="Left"> + <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">Meters per segment</TextBlock> + + <DockPanel Margin="50 0 0 0"> + <touch:TouchIconButton Command="{Binding IncreaseDecreaseSamplesToDyeCommand}" CommandParameter="-" DockPanel.Dock="Left" Icon="Minus" Padding="15" Style="{StaticResource TangoHollowButton}" BorderThickness="2" Width="51" Height="51" /> + <touch:TouchIconButton Command="{Binding IncreaseDecreaseSamplesToDyeCommand}" CommandParameter="+" DockPanel.Dock="Right" Icon="Plus" Padding="15" Style="{StaticResource TangoHollowButton}" BorderThickness="2" Width="51" Height="51" /> + <touch:TouchNumericTextBox Value="{Binding Job.SampleUnitsOrMeters}" Minimum="1" Maximum="100" HorizontalContentAlignment="Center" VerticalAlignment="Center" Margin="10 0" Foreground="{StaticResource TangoPrimaryAccentBrush}" FontSize="{StaticResource TangoTitleFontSize}" DockPanel.Dock="Right" KeyboardContainer="{Binding ElementName=Container}" /> + </DockPanel> + </DockPanel> + </StackPanel> + </DataTemplate> + </Setter.Value> + </Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </ContentControl.Style> + </ContentControl> <touch:TouchButton Margin="0 50 0 15" DockPanel.Dock="Right" Height="54" Padding="0" Width="184" CornerRadius="30" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding StartSampleDyeCommand}"> START diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs index ea5173b95..622c9e2d4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs @@ -17,5 +17,12 @@ namespace Tango.PPC.Common.Navigation /// </summary> /// <returns></returns> Task<bool> OnNavigateOutRequest(); + + /// <summary> + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// </summary> + /// <returns></returns> + Task<bool> OnNavigateBackRequest(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index fae905b13..12534959e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -139,6 +139,16 @@ namespace Tango.PPC.Common { return Task.FromResult(true); } + + /// <summary> + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// </summary> + /// <returns></returns> + public virtual Task<bool> OnNavigateBackRequest() + { + return Task.FromResult(true); + } } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs index 448fc0edc..0ede1306f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -28,6 +28,7 @@ namespace Tango.PPC.UI.Navigation private Object _currentVM; private String _lastFullPath; private bool _preventHistory; + private bool _navigating_back; private Stack<String> _navigationHistory; @@ -139,9 +140,19 @@ namespace Tango.PPC.UI.Navigation if (_currentVM != null && _currentVM is INavigationBlocker) { - if (!await (_currentVM as INavigationBlocker).OnNavigateOutRequest()) + if (_navigating_back) { - return false; + if (!await (_currentVM as INavigationBlocker).OnNavigateBackRequest()) + { + return false; + } + } + else + { + if (!await (_currentVM as INavigationBlocker).OnNavigateOutRequest()) + { + return false; + } } } @@ -260,6 +271,8 @@ namespace Tango.PPC.UI.Navigation /// </summary> public async Task<bool> NavigateBack() { + _navigating_back = true; + String first = _navigationHistory.Pop(); _preventHistory = true; @@ -268,12 +281,14 @@ namespace Tango.PPC.UI.Navigation { RaisePropertyChanged(nameof(CanNavigateBack)); _preventHistory = false; + _navigating_back = false; return true; } else { _navigationHistory.Push(first); _preventHistory = false; + _navigating_back = false; RaisePropertyChanged(nameof(CanNavigateBack)); return false; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 8c112ff7a..c67e83fc6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -193,12 +193,12 @@ namespace Tango.PPC.UI.PPCApplication private async void ConnectToMachine() { - //Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_9600); - //var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); + Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_9600); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); - //var machine = new MachineOperator(response.Adapter); - //await machine.Connect(); - //ConnectedMachine = machine; + var machine = new MachineOperator(response.Adapter); + await machine.Connect(); + ConnectedMachine = machine; } } } |
