diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-21 13:05:37 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-21 13:05:37 +0300 |
| commit | 5c58e6499306b3087015758c1054497dccc407e6 (patch) | |
| tree | 82d3b43c83f57d381d7a4fd4d7071861387fb68f /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer | |
| parent | b4a1c833f0e67835e89961e77329efe5bf2a7797 (diff) | |
| download | Tango-5c58e6499306b3087015758c1054497dccc407e6.tar.gz Tango-5c58e6499306b3087015758c1054497dccc407e6.zip | |
Done with Developer Module.
Implemented DB auth using Azure Active Directory Interactive!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
2 files changed, 55 insertions, 33 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 6ce1a6108..9eaa56870 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -184,14 +184,14 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - private bool _isLoading; + private bool _canWork; /// <summary> /// Gets or sets a value indicating whether this instance is loading machine. /// </summary> - public bool IsLoading + public bool CanWork { - get { return _isLoading; } - set { _isLoading = value; RaisePropertyChangedAuto(); } + get { return _canWork; } + set { _canWork = value; RaisePropertyChangedAuto(); } } private List<LiquidTypesRml> _liquidTypesRmls; @@ -655,6 +655,8 @@ namespace Tango.MachineStudio.Developer.ViewModels /// <param name="notificationProvider">The notification provider.</param> public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech) { + CanWork = true; + _authentication = authentication; _notification = notificationProvider; @@ -673,31 +675,31 @@ namespace Tango.MachineStudio.Developer.ViewModels }); //Initialize Commands... - EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); - EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null); + EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null && CanWork); + EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null && CanWork); ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened); - SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors, () => SelectedRML != null); - AddSegmentCommand = new RelayCommand(AddSegment, () => ActiveJob != null); - RemoveSegmentCommand = new RelayCommand(RemoveSelectedSegments, () => SelectedSegment != null); - AddJobCommand = new RelayCommand(AddJob, () => SelectedMachine != null && !IsLoading); - RemoveJobCommand = new RelayCommand(RemoveSelectedJobs, () => SelectedMachineJob != null && !IsLoading); - AddBrushStopCommand = new RelayCommand(AddBrushStop, () => SelectedSegment != null); - RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null); - SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null); - DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null); - StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); + SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors, () => SelectedRML != null && CanWork); + AddSegmentCommand = new RelayCommand(AddSegment, () => ActiveJob != null && CanWork); + RemoveSegmentCommand = new RelayCommand(RemoveSelectedSegments, () => SelectedSegment != null && CanWork); + AddJobCommand = new RelayCommand(AddJob, () => SelectedMachine != null && CanWork); + RemoveJobCommand = new RelayCommand(RemoveSelectedJobs, () => SelectedMachineJob != null && CanWork); + AddBrushStopCommand = new RelayCommand(AddBrushStop, () => SelectedSegment != null && CanWork); + RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null && CanWork); + SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null && CanWork); + DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null && CanWork); + StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); - StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); + StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning && CanWork); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); - LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null && !IsLoading); - DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null && !IsLoading); - DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null); - DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null); - SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0); - PushProcessParametersCommand = new RelayCommand(PushProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0 && SelectedProcessParametersTable != null && MachineOperator != null); - ImportEmbroideryFileCommand = new RelayCommand(ImportEmbroideryFile, () => SelectedMachine != null && !IsLoading); - DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile); - ReloadMachinesCommand = new RelayCommand(() => LoadMachine()); + LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null && CanWork); + DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null && CanWork); + DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null && CanWork); + DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null && CanWork); + SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && CanWork && SelectedRML.ProcessParametersTablesGroups.Count > 0); + PushProcessParametersCommand = new RelayCommand(PushProcessParameters, () => SelectedRML != null && CanWork && SelectedRML.ProcessParametersTablesGroups.Count > 0 && SelectedProcessParametersTable != null && MachineOperator != null); + ImportEmbroideryFileCommand = new RelayCommand(ImportEmbroideryFile, () => SelectedMachine != null && CanWork); + DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile, () => CanWork); + ReloadMachinesCommand = new RelayCommand(() => LoadMachine(), () => CanWork); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; @@ -1322,6 +1324,8 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedRML != null) { + CanWork = false; + using (_notification.PushTaskItem("Saving Liquid Factors...")) { LogManager.Log(String.Format("Saving liquid factors for RML {0}...", SelectedRML.Name)); @@ -1333,6 +1337,8 @@ namespace Tango.MachineStudio.Developer.ViewModels SetSegmentBrushStopsLiquidVolumes(SelectedSegment); } } + + CanWork = true; } } @@ -1423,6 +1429,8 @@ namespace Tango.MachineStudio.Developer.ViewModels if (response == null) return; + CanWork = false; + using (_notification.PushTaskItem("Saving Parameters Group...")) { LogManager.Log(String.Format("Saving process parameters group under the name {0}...", response)); @@ -1456,6 +1464,8 @@ namespace Tango.MachineStudio.Developer.ViewModels InvalidateLiquidFactorsAndProcessTables(); } + + CanWork = true; } #endregion @@ -1469,6 +1479,8 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedMachineJob != null) { + CanWork = false; + using (_notification.PushTaskItem("Loading job details...")) { await Task.Factory.StartNew(() => @@ -1546,6 +1558,8 @@ namespace Tango.MachineStudio.Developer.ViewModels UIHelper.DoEvents(); _navigation.NavigateTo(DeveloperNavigationView.JobView); } + + CanWork = true; } } @@ -1556,6 +1570,8 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (ActiveJob != null) { + CanWork = false; + using (_notification.PushTaskItem("Saving job details...")) { await Task.Factory.StartNew(() => @@ -1590,6 +1606,8 @@ namespace Tango.MachineStudio.Developer.ViewModels }); } + + CanWork = true; } } @@ -1628,7 +1646,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Loading selected machine..."); - IsLoading = true; + CanWork = false; using (_notification.PushTaskItem("Loading selected machine...")) { @@ -1652,11 +1670,11 @@ namespace Tango.MachineStudio.Developer.ViewModels JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); } - IsLoading = false; + CanWork = true; foreach (var job in SelectedMachine.Jobs.OrderByDescending(x => x.LastUpdated)) { - if (IsLoading) break; + if (!CanWork) break; job.Segments.EnableCrossThreadOperations(); await _machineDbContext.Segments.Where(x => x.JobGuid == job.Guid).Include(x => x.BrushStops).OrderBy(x => x.SegmentIndex).LoadAsync(); } @@ -1665,7 +1683,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log(ex); _notification.ShowError("An error occurred while trying to load the selected machine."); - IsLoading = false; + CanWork = true; } } @@ -1949,6 +1967,8 @@ namespace Tango.MachineStudio.Developer.ViewModels { using (_notification.PushTaskItem("Cloning selected jobs...")) { + CanWork = false; + LogManager.LogFormat("Duplicating {0} jobs...", SelectedJobs.Count); int index = SelectedMachine.Jobs.Max(x => x.JobIndex); @@ -1962,6 +1982,8 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Saving selected machine to database..."); await SelectedMachine.SaveAsync(_machineDbContext); + + CanWork = true; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 71e8f6b11..279a9daf3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -39,11 +39,11 @@ <StackPanel> <TextBlock Margin="40 20" FontSize="30" FontWeight="SemiBold" FontStyle="Italic">TARGET MACHINE</TextBlock> - <DockPanel Margin="40 0 40 0" IsEnabled="{Binding IsLoading,Converter={StaticResource BooleanInverseConverter}}"> + <DockPanel Margin="40 0 40 0" IsEnabled="{Binding CanWork}"> <Button Command="{Binding ReloadMachinesCommand}" DockPanel.Dock="Right" ToolTip="Reload" Foreground="#404040" Margin="20 0 0 0" Padding="0" Width="40" Height="Auto" Style="{StaticResource MaterialDesignFlatButton}"> <materialDesign:PackIcon Kind="Refresh" Width="24" Height="24" /> </Button> - <autoComplete:AutoCompleteTextBox Provider="{Binding MachinesProvider}" FontSize="20" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number" DisplayMember="SerialNumber"> + <autoComplete:AutoCompleteTextBox Provider="{Binding MachinesProvider}" LoadingContent="Loading..." FontSize="20" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number" DisplayMember="SerialNumber"> <autoComplete:AutoCompleteTextBox.ItemTemplate> <DataTemplate> <StackPanel> @@ -130,7 +130,7 @@ </Grid> <Grid Margin="0 20 0 0"> - <commonControls:LoadingPanel IsLoading="{Binding IsLoading}"> + <commonControls:LoadingPanel IsLoading="{Binding CanWork,Converter={StaticResource BooleanInverseConverter}}"> <controls:MultiSelectDataGrid MouseDoubleClick="MultiSelectDataGrid_MouseDoubleClick" AutomationProperties.AutomationId="{x:Static automation:Developer.JobsDataGrid}" Style="{StaticResource {x:Type DataGrid}}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="True" CanUserSortColumns="True" AutoGenerateColumns="False" Background="Transparent" ItemsSource="{Binding JobsCollectionView}" SelectedItem="{Binding SelectedMachineJob}" SelectedItemsList="{Binding SelectedJobs,Mode=TwoWay}"> <DataGrid.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> |
