diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-20 19:43:15 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-20 19:43:15 +0300 |
| commit | 51afc4f6a17383e91a72c2ce060e82604d43c3a8 (patch) | |
| tree | c0aa029d9864fc8f03b69716a42eda5efe65ccd5 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer | |
| parent | 2ea6653199844f5607d17a8912eb7a99e2471610 (diff) | |
| download | Tango-51afc4f6a17383e91a72c2ce060e82604d43c3a8.tar.gz Tango-51afc4f6a17383e91a72c2ce060e82604d43c3a8.zip | |
Working on new Machine Studio DB.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
6 files changed, 415 insertions, 292 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index bd7484de8..86549a695 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -196,6 +196,10 @@ <Project>{b9ae25d6-be35-492f-9079-21a7f3e6f7cc}</Project> <Name>RealTimeGraphEx</Name> </ProjectReference> + <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj"> + <Project>{BB2ABB74-BA58-4812-83AA-EC8171F42DF4}</Project> + <Name>Tango.AutoComplete</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> <Name>Tango.BL</Name> @@ -264,10 +268,6 @@ <Project>{fc337a7f-1214-41d8-9992-78092a3b961e}</Project> <Name>Tango.MachineStudio.DataCapture</Name> </ProjectReference> - <ProjectReference Include="..\Tango.MachineStudio.DB\Tango.MachineStudio.DB.csproj"> - <Project>{94f7acf8-55e1-4a02-b9bc-a818413fdbbf}</Project> - <Name>Tango.MachineStudio.DB</Name> - </ProjectReference> <ProjectReference Include="..\Tango.MachineStudio.Logging\Tango.MachineStudio.Logging.csproj"> <Project>{1674f726-0e66-414f-b9fd-c6f20d7f07c7}</Project> <Name>Tango.MachineStudio.Logging</Name> @@ -276,10 +276,6 @@ <Project>{d0ce8122-077d-42a2-9490-028ae4769b52}</Project> <Name>Tango.MachineStudio.MachineDesigner</Name> </ProjectReference> - <ProjectReference Include="..\Tango.MachineStudio.Technician\Tango.MachineStudio.Technician.csproj"> - <Project>{5d39c1e1-3ecd-4634-bd1b-2bcf71c54a15}</Project> - <Name>Tango.MachineStudio.Technician</Name> - </ProjectReference> </ItemGroup> <ItemGroup> <Resource Include="Images\rgb.png" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs index ebf2f2446..5f82984a4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs @@ -16,8 +16,8 @@ namespace Tango.MachineStudio.Developer /// </summary> static ViewModelLocator() { - TangoIOC.Default.Register<MainViewVM>(); TangoIOC.Default.Register<DeveloperNavigationManager, DeveloperNavigationManager>(); + TangoIOC.Default.Register<MainViewVM>(); } public static MainViewVM MainViewVM 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 dace2ceac..6ce1a6108 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 @@ -41,6 +41,9 @@ using Tango.MachineStudio.Common; using Tango.BL.ColorConversion; using Tango.MachineStudio.Logging.ViewModels; using Tango.MachineStudio.Logging.Views; +using Tango.AutoComplete.Editors; +using System.Data.Entity; +using System.Runtime.ExceptionServices; namespace Tango.MachineStudio.Developer.ViewModels { @@ -48,6 +51,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Represents the developer module main view, view model. /// </summary> /// <seealso cref="Tango.SharedUI.ViewModel" /> + [TangoCreateWhenRegistered] public class MainViewVM : StudioViewModel<DeveloperModule> { private static object _syncLock = new object(); @@ -71,6 +75,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private bool _hiveOpened; private bool _color_changed_from_hive; private bool _dialog_shown; + private bool _disable_gamut_check; #region Properties @@ -104,16 +109,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _runningJobStatus = value; RaisePropertyChangedAuto(); } } - private ObservableCollection<Machine> _machines; - /// <summary> - /// Gets or sets the machines. - /// </summary> - public ObservableCollection<Machine> Machines - { - get { return _machines; } - set { _machines = value; RaisePropertyChangedAuto(); } - } - private ObservableCollection<ColorSpace> _colorSpaces; /// <summary> /// Gets or sets the color spaces. @@ -173,19 +168,32 @@ namespace Tango.MachineStudio.Developer.ViewModels get { return _selectedMachine; } set { - _selectedMachine = value; - OnSelectedMachineChanged(); - RaisePropertyChangedAuto(); - InvalidateRelayCommands(); - - if (_selectedMachine != null) + if (value != null && _selectedMachine != value) { - _selectedMachine.Modified -= SelectedMachine_Modified; - _selectedMachine.Modified += SelectedMachine_Modified; + _selectedMachine = value; + OnSelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + + if (_selectedMachine != null) + { + _selectedMachine.Modified -= SelectedMachine_Modified; + _selectedMachine.Modified += SelectedMachine_Modified; + } } } } + private bool _isLoading; + /// <summary> + /// Gets or sets a value indicating whether this instance is loading machine. + /// </summary> + public bool IsLoading + { + get { return _isLoading; } + set { _isLoading = value; RaisePropertyChangedAuto(); } + } + private List<LiquidTypesRml> _liquidTypesRmls; /// <summary> /// Gets or sets the liquid types RMLS. @@ -248,7 +256,6 @@ namespace Tango.MachineStudio.Developer.ViewModels { _activeJob = value; RaisePropertyChangedAuto(); - OnActiveJobChanged(); } } @@ -322,7 +329,7 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _selectedRML = value; - InvalidateLiquidFactorsAndProcessTables(); + OnSelectedRMLChanged(); RaisePropertyChangedAuto(); InvalidateRelayCommands(); } @@ -504,6 +511,11 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _selectedJobEvent = value; RaisePropertyChangedAuto(); OnSelectedJobEventChanged(); } } + /// <summary> + /// Gets or sets the machines providers. + /// </summary> + public ISuggestionProvider MachinesProvider { get; set; } + #endregion #region Commands @@ -643,29 +655,6 @@ 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) { - _settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>(); - - SelectedJobs = new ObservableCollection<Job>(); - - JobEvents = new ObservableCollection<MachinesEvent>(); - - LogManager.Log("Initializing machine Db context..."); - _machineDbContext = ObservablesContext.CreateDefault(); - - Machines = _machineDbContext.Machines.ToObservableCollection(); - - if (_settings.LastSelectedMachineGuid != null) - { - LogManager.Log("Setting last selected machine from settings..."); - SelectedMachine = _machineDbContext.Machines.SingleOrDefault(x => x.Guid == _settings.LastSelectedMachineGuid); - } - - if (_settings.LastSelectedJobGuid != null && SelectedMachine != null) - { - LogManager.Log("Setting last selected job from settings..."); - SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == _settings.LastSelectedJobGuid); - } - _authentication = authentication; _notification = notificationProvider; @@ -690,8 +679,8 @@ namespace Tango.MachineStudio.Developer.ViewModels SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors, () => SelectedRML != null); AddSegmentCommand = new RelayCommand(AddSegment, () => ActiveJob != null); RemoveSegmentCommand = new RelayCommand(RemoveSelectedSegments, () => SelectedSegment != null); - AddJobCommand = new RelayCommand(AddJob, () => SelectedMachine != null); - RemoveJobCommand = new RelayCommand(RemoveSelectedJobs, () => SelectedMachineJob != 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); @@ -700,20 +689,63 @@ namespace Tango.MachineStudio.Developer.ViewModels 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); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); - LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null); - DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null); + 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); + ImportEmbroideryFileCommand = new RelayCommand(ImportEmbroideryFile, () => SelectedMachine != null && !IsLoading); DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile); - ReloadMachinesCommand = new RelayCommand(ReloadMachine); + ReloadMachinesCommand = new RelayCommand(() => LoadMachine()); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; _eventLogger.NewLog += _eventLogger_NewLog; + + MachinesProvider = new SuggestionProvider((filter) => + { + try + { + return _machineDbContext.Machines.Where(x => x.SerialNumber.StartsWith(filter)).ToList(); + } + catch + { + return null; + } + }); + } + + #endregion + + #region Application Ready + + public override void OnApplicationReady() + { + base.OnApplicationReady(); + + _settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>(); + + SelectedJobs = new ObservableCollection<Job>(); + JobEvents = new ObservableCollection<MachinesEvent>(); + + LogManager.Log("Initializing machine Db context..."); + _machineDbContext = ObservablesContext.CreateDefault(); + _machineDbContext.Configuration.LazyLoadingEnabled = false; + + if (_settings.LastSelectedMachineGuid != null) + { + LogManager.Log("Setting last selected machine from settings..."); + SelectedMachine = _machineDbContext.Machines.SingleOrDefault(x => x.Guid == _settings.LastSelectedMachineGuid); + } + + if (_settings.LastSelectedJobGuid != null && SelectedMachine != null) + { + LogManager.Log("Setting last selected job from settings..."); + SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == _settings.LastSelectedJobGuid); + } + _colorConversionThread = new Thread(ColorConversionThreadMethod); _colorConversionThread.IsBackground = true; _colorConversionThread.Start(); @@ -723,37 +755,42 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Color Conversion + [HandleProcessCorruptedStateExceptions] private void ColorConversionThreadMethod() { while (true) { - if (IsVisible && ActiveJob != null && ActiveJob.Segments != null) + if (!_disable_gamut_check && IsVisible && ActiveJob != null && ActiveJob.Segments != null) { - var stops = ActiveJob.Segments.SelectMany(x => x.BrushStops).ToList(); - - foreach (var stop in stops) + try { - if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32() && !stop.IsLiquidVolumesOutOfRange) + var stops = ActiveJob.Segments.SelectMany(x => x.BrushStops).ToList(); + + foreach (var stop in stops) { - try + if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32() && !stop.IsLiquidVolumesOutOfRange) { - var output = TangoColorConverter.GetSuggestions(stop); + try + { + var output = TangoColorConverter.GetSuggestions(stop); - stop.Red = output.SingleCoordinates.Red; - stop.Green = output.SingleCoordinates.Green; - stop.Blue = output.SingleCoordinates.Blue; + stop.Red = output.SingleCoordinates.Red; + stop.Green = output.SingleCoordinates.Green; + stop.Blue = output.SingleCoordinates.Blue; + } + catch { } } - catch { } - } - else if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() && !stop.Corrected) - { - try + else if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() && !stop.Corrected) { - stop.IsOutOfGamut = TangoColorConverter.IsOutOfGamut(stop); + try + { + stop.IsOutOfGamut = TangoColorConverter.IsOutOfGamut(stop); + } + catch { } } - catch { } } } + catch { } } Thread.Sleep(500); @@ -950,9 +987,12 @@ namespace Tango.MachineStudio.Developer.ViewModels if (RmlProcessParametersTableGroup != null && RmlProcessParametersTableGroup.ProcessParametersTables.Count > 0) { LogManager.Log("Process parameters group changed..."); - SelectedProcessParametersTable = RmlProcessParametersTableGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).FirstOrDefault(); - UpdateEstimatedDuration(); + InvokeUI(() => + { + SelectedProcessParametersTable = RmlProcessParametersTableGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).FirstOrDefault(); + UpdateEstimatedDuration(); + }); } } @@ -992,9 +1032,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedMachine != null) { LogManager.Log(String.Format("Machine {0} changed.", SelectedMachine.SerialNumber)); - ReloadMachine(); - JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); - JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + LoadMachine(); } } @@ -1018,19 +1056,6 @@ namespace Tango.MachineStudio.Developer.ViewModels }; } - /// <summary> - /// Called when the active job has changed. - /// </summary> - protected virtual void OnActiveJobChanged() - { - if (ActiveJob != null) - { - LogManager.Log(String.Format("Active job {0} changed.", ActiveJob.Name)); - SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); - SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - } - } - #endregion #region Drag & Drop @@ -1301,7 +1326,12 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log(String.Format("Saving liquid factors for RML {0}...", SelectedRML.Name)); await SelectedRML.SaveAsync(_activeJobDbContext); - InvalidateLiquidFactorsAndProcessTables(); + LiquidTypesRmls = ActiveJob.Machine.Configuration.NoneEmptyIdsPacks.Where(x => !x.IsEmpty).OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + + if (SelectedSegment != null) + { + SetSegmentBrushStopsLiquidVolumes(SelectedSegment); + } } } } @@ -1323,7 +1353,10 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedRML != null && SelectedMachine != null) { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.Where(x => !x.IsEmpty).OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + LiquidTypesRmls = ActiveJob.Machine.Configuration.NoneEmptyIdsPacks.Where(x => !x.IsEmpty).OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + + _activeJobDbContext.ProcessParametersTablesGroups.Where(x => x.RmlGuid == SelectedRML.Guid).Include(x => x.ProcessParametersTables).ToList(); + RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); var selectedHistory = RmlProcessParametersTableGroup; @@ -1334,11 +1367,26 @@ namespace Tango.MachineStudio.Developer.ViewModels RmlProcessParametersTableGroup.ProcessParametersTables = RmlProcessParametersTableGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).ToObservableCollection(); } - GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); + GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); _selectedGroupHistory = selectedHistory; - RaisePropertyChangedAuto(nameof(SelectedGroupHistory)); + InvokeUI(() => + { + RaisePropertyChanged(nameof(SelectedGroupHistory)); + RaisePropertyChanged(nameof(RmlProcessParametersTableGroup)); + }); + } + } + + private async void OnSelectedRMLChanged() + { + using (_notification.PushTaskItem("Loading RML...")) + { + await Task.Factory.StartNew(() => + { + InvalidateLiquidFactorsAndProcessTables(); + }); } } @@ -1417,62 +1465,86 @@ namespace Tango.MachineStudio.Developer.ViewModels /// <summary> /// Loads the selected job. /// </summary> - private void LoadSelectedJob() + private async void LoadSelectedJob() { if (SelectedMachineJob != null) { using (_notification.PushTaskItem("Loading job details...")) { - LogManager.Log(String.Format("Loading job {0}...", SelectedMachineJob.Name)); - SelectedSegments = new ObservableCollection<Segment>(); - SelectedBrushStops = new ObservableCollection<BrushStop>(); - SelectedRML = null; - SelectedSegment = null; - SelectedGroupHistory = null; - SelectedBrushStop = null; - SelectedProcessParametersTable = null; - RmlProcessParametersTableGroup = null; + await Task.Factory.StartNew(() => + { + _disable_gamut_check = true; + LogManager.Log(String.Format("Loading job {0}...", SelectedMachineJob.Name)); + SelectedSegments = new ObservableCollection<Segment>(); + SelectedBrushStops = new ObservableCollection<BrushStop>(); + SelectedRML = null; + SelectedSegment = null; + SelectedGroupHistory = null; + SelectedBrushStop = null; + SelectedProcessParametersTable = null; + RmlProcessParametersTableGroup = null; - _blockInvalidateCommands = false; + _blockInvalidateCommands = false; - LogManager.Log("Creating active job DB context..."); - _activeJobDbContext = ObservablesContext.CreateDefault(); - _activeJobDbContext.Configuration.LazyLoadingEnabled = true; + LogManager.Log("Creating active job DB context..."); + _activeJobDbContext = ObservablesContext.CreateDefault(); + _activeJobDbContext.Configuration.LazyLoadingEnabled = false; - LogManager.Log("Initializing available color spaces, RMLs & Winding methods..."); - var processParamsGroups = _activeJobDbContext.ProcessParametersTablesGroups.ToList(); - var processParams = _activeJobDbContext.ProcessParametersTables.ToList(); - ColorSpaces = _activeJobDbContext.ColorSpaces.ToObservableCollection(); - Rmls = _activeJobDbContext.Rmls.ToObservableCollection(); - WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection(); - SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection(); + LogManager.Log("Initializing available color spaces, RMLs & Winding methods..."); + //var processParamsGroups = _activeJobDbContext.ProcessParametersTablesGroups.ToList(); + //var processParams = _activeJobDbContext.ProcessParametersTables.ToList(); - LogManager.Log("Setting active job..."); - _activeJob = _activeJobDbContext.Jobs.SingleOrDefault(x => x.Guid == SelectedMachineJob.Guid); + ColorSpaces = _activeJobDbContext.ColorSpaces.ToObservableCollection(); + Rmls = _activeJobDbContext.Rmls.ToObservableCollection(); + WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection(); + SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection(); - _selectedRML = ActiveJob.Rml; + LogManager.Log("Setting active job..."); + ActiveJob = _activeJobDbContext.Jobs.Include(x => x.Rml).Include(x => x.Segments).Include(x => x.Segments.Select(y => y.BrushStops)).SingleOrDefault(x => x.Guid == SelectedMachineJob.Guid); - LogManager.Log("Setting selected segment..."); - _selectedSegment = ActiveJob.Segments.FirstOrDefault(); + _activeJobDbContext.Ccts.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList(); + _activeJobDbContext.Cats.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList(); + _activeJobDbContext.Machines.SingleOrDefault(x => x.Guid == ActiveJob.MachineGuid); + _activeJobDbContext.Configurations.SingleOrDefault(x => x.Guid == ActiveJob.Machine.ConfigurationGuid); - ActiveJob.LengthChanged -= ActiveJob_LengthChanged; - ActiveJob.LengthChanged += ActiveJob_LengthChanged; + _activeJobDbContext.LiquidTypesRmls.ToList(); - ActiveJob = _activeJob; + _activeJobDbContext.IdsPackFormulas.ToList(); + _activeJobDbContext.LiquidTypes.ToList(); + _activeJobDbContext.MidTankTypes.ToList(); + _activeJobDbContext.DispenserTypes.ToList(); - SelectedRML = _selectedRML; - SelectedSegment = _selectedSegment; + _activeJobDbContext.IdsPacks.Where(x => x.ConfigurationGuid == ActiveJob.Machine.ConfigurationGuid).ToList(); - UpdateEstimatedDuration(); - _blockInvalidateCommands = false; - InvalidateRelayCommands(); + + LogManager.Log("Setting selected segment..."); + _selectedSegment = ActiveJob.Segments.FirstOrDefault(); + + ActiveJob.LengthChanged -= ActiveJob_LengthChanged; + ActiveJob.LengthChanged += ActiveJob_LengthChanged; + + _selectedRML = ActiveJob.Rml; + InvalidateLiquidFactorsAndProcessTables(); + RaisePropertyChanged(nameof(SelectedRML)); + + UpdateEstimatedDuration(); + + _blockInvalidateCommands = false; + InvalidateRelayCommands(); + + _disable_gamut_check = false; + }); + + SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); + SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); + + SelectedSegment = _selectedSegment; UIHelper.DoEvents(); _navigation.NavigateTo(DeveloperNavigationView.JobView); - } } } @@ -1480,20 +1552,43 @@ namespace Tango.MachineStudio.Developer.ViewModels /// <summary> /// Saves the active job. /// </summary> - private void SaveActiveJob() + private async void SaveActiveJob() { if (ActiveJob != null) { using (_notification.PushTaskItem("Saving job details...")) { - LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name)); - ActiveJob.LastUpdated = DateTime.UtcNow; - ActiveJob.Rml = SelectedRML; - ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds; + await Task.Factory.StartNew(() => + { + LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name)); + ActiveJob.LastUpdated = DateTime.UtcNow; + ActiveJob.Rml = SelectedRML; + ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds; + _activeJobDbContext.SaveChanges(); + + _machineDbContext.Entry(SelectedMachineJob).Reload(); + - _activeJobDbContext.SaveChanges(); - ReloadMachine(); - SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == ActiveJob.Guid); + _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load(); + + foreach (var segment in SelectedMachineJob.Segments.ToList()) + { + _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load(); + + foreach (var brushStop in segment.BrushStops.ToList()) + { + _machineDbContext.Entry(brushStop).Reload(); + } + + _machineDbContext.Entry(segment).Reload(); + } + + InvokeUI(() => + { + SelectedMachineJob.Segments = SelectedMachineJob.Segments; + }); + + }); } } } @@ -1527,19 +1622,51 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods - private void ReloadMachine() + private async void LoadMachine() { - LogManager.Log("Reloading selected machine..."); - _machineDbContext.Dispose(); - _machineDbContext = ObservablesContext.CreateDefault(); - _machineDbContext.Configuration.LazyLoadingEnabled = true; - String machineGuid = _selectedMachine.Guid; - Machines = _machineDbContext.Machines.ToObservableCollection(); - _selectedMachine = Machines.SingleOrDefault(x => x.Guid == machineGuid); - RaisePropertyChanged(nameof(SelectedMachine)); + try + { + LogManager.Log("Loading selected machine..."); + + IsLoading = true; + + using (_notification.PushTaskItem("Loading selected machine...")) + { + await _machineDbContext.Jobs.Where(x => x.MachineGuid == SelectedMachine.Guid).Include(x => x.User).Include(x => x.User.Contact).LoadAsync(); + await _machineDbContext.Configurations.SingleOrDefaultAsync(x => x.Guid == SelectedMachine.ConfigurationGuid); + + await _machineDbContext.ColorSpaces.LoadAsync(); + + SelectedMachine.Configuration.IdsPacks.EnableCrossThreadOperations(); + + await _machineDbContext.IdsPacks.OrderBy(x => x.PackIndex).Where(x => x.ConfigurationGuid == SelectedMachine.ConfigurationGuid). + Include(x => x.CartridgeType). + Include(x => x.DispenserType). + Include(x => x.LiquidType). + Include(x => x.IdsPackFormula). + Include(x => x.MidTankType).LoadAsync(); + + RaisePropertyChanged(nameof(SelectedMachine)); - JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); - JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); + JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + } + + IsLoading = false; + + foreach (var job in SelectedMachine.Jobs.OrderByDescending(x => x.LastUpdated)) + { + if (IsLoading) break; + job.Segments.EnableCrossThreadOperations(); + await _machineDbContext.Segments.Where(x => x.JobGuid == job.Guid).Include(x => x.BrushStops).OrderBy(x => x.SegmentIndex).LoadAsync(); + } + } + catch (Exception ex) + { + LogManager.Log(ex); + _notification.ShowError("An error occurred while trying to load the selected machine."); + IsLoading = false; + } } private void UpdateEstimatedDuration() @@ -1557,7 +1684,7 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Setting segment brush stops liquid volumes..."); foreach (var stop in segment.BrushStops) { - stop.SetLiquidVolumes(SelectedMachine.Configuration, SelectedRML, SelectedProcessParametersTable); + stop.SetLiquidVolumes(ActiveJob.Machine.Configuration, SelectedRML, SelectedProcessParametersTable); } } } @@ -1713,14 +1840,15 @@ namespace Tango.MachineStudio.Developer.ViewModels newJob.Rml = _machineDbContext.Rmls.FirstOrDefault(); newJob.WindingMethod = _machineDbContext.WindingMethods.FirstOrDefault(); newJob.SpoolType = _machineDbContext.SpoolTypes.FirstOrDefault(); + newJob.ColorSpace = _machineDbContext.ColorSpaces.FirstOrDefault(); newJob.Machine = SelectedMachine; SelectedMachine.Jobs.Add(newJob); + newJob.AddSolidSegment(); LogManager.Log("Saving selected machine to database..."); await SelectedMachine.SaveAsync(_machineDbContext); SelectedMachineJob = newJob; LoadSelectedJob(); - AddSegment(); } } } @@ -1769,7 +1897,7 @@ namespace Tango.MachineStudio.Developer.ViewModels stop.OffsetPercent = 100; stop.Segment = SelectedSegment; - stop.ColorSpace = _activeJobDbContext.ColorSpaces.FirstOrDefault(); + stop.ColorSpace = ColorSpaces.FirstOrDefault(); stop.Color = Colors.Black; stop.SetLiquidVolumes(SelectedMachine.Configuration, SelectedRML, SelectedProcessParametersTable); SelectedSegment.BrushStops.Add(stop); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 1b96b27ce..368f615a0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -11,11 +11,9 @@ xmlns:hive="clr-namespace:Tango.Hive;assembly=Tango.Hive" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:techViews="clr-namespace:Tango.MachineStudio.Technician.Views;assembly=Tango.MachineStudio.Technician" xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" xmlns:dispensing="clr-namespace:Tango.BL.Dispensing;assembly=Tango.BL" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" - xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views.DBViews;assembly=Tango.MachineStudio.DB" xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:designer="clr-namespace:Tango.MachineStudio.MachineDesigner.Views;assembly=Tango.MachineStudio.MachineDesigner" diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index bb17a502d..2942d36af 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -64,7 +64,7 @@ namespace Tango.MachineStudio.Developer.Views if (_vm != null && _vm.ActiveJob != null) { List<Segment> segments = new List<Segment>(); - foreach (var s in _vm.ActiveJob.Segments) + foreach (var s in _vm.ActiveJob.Segments.OrderBy(x => x.SegmentIndex)) { segments.Add(s); 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 c151b62bc..71e8f6b11 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 @@ -6,6 +6,7 @@ xmlns:global="clr-namespace:Tango.MachineStudio.Developer" xmlns:designer="clr-namespace:Tango.MachineStudio.MachineDesigner.Views;assembly=Tango.MachineStudio.MachineDesigner" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:localConverters="clr-namespace:Tango.MachineStudio.Developer.Converters" xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" @@ -13,6 +14,7 @@ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" x:Name="control" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -23,6 +25,7 @@ <localConverters:MillisecondsToTimeSpanConverter x:Key="MillisecondsToTimeSpanConverter" /> <converters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter" /> <converters:MathOperatorConverter x:Key="MathOperatorConverter" /> + <converters:BooleanInverseConverter x:Key="BooleanInverseConverter" /> </UserControl.Resources> <Grid> @@ -36,20 +39,20 @@ <StackPanel> <TextBlock Margin="40 20" FontSize="30" FontWeight="SemiBold" FontStyle="Italic">TARGET MACHINE</TextBlock> - <DockPanel Margin="40 0 40 0"> + <DockPanel Margin="40 0 40 0" IsEnabled="{Binding IsLoading,Converter={StaticResource BooleanInverseConverter}}"> <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> - <ComboBox ItemsSource="{Binding Machines}" FontSize="20" SelectedItem="{Binding SelectedMachine}" materialDesign:HintAssist.Hint="Serial Number"> - <ComboBox.ItemTemplate> + <autoComplete:AutoCompleteTextBox Provider="{Binding MachinesProvider}" FontSize="20" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number" DisplayMember="SerialNumber"> + <autoComplete:AutoCompleteTextBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding SerialNumber}" FontWeight="Bold" FontStyle="Italic"></TextBlock> <TextBlock FontSize="11" Text="{Binding Name}" Foreground="Gray"></TextBlock> </StackPanel> </DataTemplate> - </ComboBox.ItemTemplate> - </ComboBox> + </autoComplete:AutoCompleteTextBox.ItemTemplate> + </autoComplete:AutoCompleteTextBox> </DockPanel> <designer:MachineView Width="600" IsHitTestVisible="False" Margin="0 40 0 0" DataContext="{Binding SelectedMachine}" /> <Button Command="{Binding EditMachineCommand}" HorizontalAlignment="Right" Margin="0 10 20 20" Style="{StaticResource MaterialDesignFlatButton}"> @@ -127,141 +130,139 @@ </Grid> <Grid Margin="0 20 0 0"> - <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}}"> - <Setter Property="BorderThickness" Value="0"/> - <Setter Property="FocusVisualStyle" Value="{x:Null}"/> - <Setter Property="VerticalContentAlignment" Value="Center"></Setter> - </Style> - </DataGrid.CellStyle> - <DataGrid.Columns> - <DataGridTemplateColumn> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate DataType="{x:Type observables:Job}"> - <ContentControl> - <ContentControl.Style> - <Style TargetType="ContentControl"> - <Setter Property="Content"> - <Setter.Value> - <Image Source="../Images/rgb.png" Width="40" Margin="5"></Image> - </Setter.Value> - </Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding HasEmbroideryFile}" Value="True"> - <Setter Property="Content"> - <Setter.Value> - <Button ToolTip="Press to display the attached embroidery file information" Style="{StaticResource emptyButton}" Cursor="Hand" Command="{Binding DataContext.DisplayJobEmbroideryFileCommand, Source={x:Reference control}}" CommandParameter="{Binding}"> - <Image Source="../Images/job-emb.png" Width="40" Margin="5"></Image> - </Button> - </Setter.Value> - </Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </ContentControl.Style> - </ContentControl> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="NAME" CanUserSort="True" SortMemberPath="Name"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock Text="{Binding Name}" VerticalAlignment="Center" FontSize="14"></TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="CREATION DATE" Width="150" CanUserSort="True" SortMemberPath="CreationDate"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock Text="{Binding CreationDate,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" VerticalAlignment="Center" FontSize="14"></TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="LAST MODIFIED" Width="150" CanUserSort="True" SortMemberPath="LastUpdated"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" VerticalAlignment="Center" FontSize="14"></TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="LAST RUN" Width="150" CanUserSort="True" SortMemberPath="LastRun"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock Text="{Binding LastRun,Converter={StaticResource DateTimeUTCToShortDateTimeConverter},FallbackValue='Never',TargetNullValue='Never'}" VerticalAlignment="Center" FontSize="14"></TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="USER" Width="100" CanUserSort="True" SortMemberPath="User"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock Text="{Binding User.Contact.FirstName}" VerticalAlignment="Center" FontSize="14"></TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="LENGTH" Width="100" CanUserSort="True" SortMemberPath="Length"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock VerticalAlignment="Center" FontSize="14"> - <Run Text="{Binding Length,Mode=OneWay,StringFormat=N2}"></Run> - <Run Text="m" Foreground="Gray"></Run> - </TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Header="DURATION" Width="100" CanUserSort="True" SortMemberPath="EstimatedDurationMili"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <TextBlock VerticalAlignment="Center" FontSize="14"> - <Run Text="{Binding EstimatedDurationMili,Converter={StaticResource MillisecondsToTimeSpanConverter},Mode=OneWay,StringFormat=hh\\:mm\\:ss,TargetNullValue='Unknown'}"></Run> - </TextBlock> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTemplateColumn Width="1*" Header="SEGMENTS" CanUserSort="True" SortMemberPath="Segments.Count"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <StackPanel Orientation="Horizontal"> - <ItemsControl HorizontalAlignment="Right" ItemsSource="{Binding Segments}"> - <ItemsControl.ItemsPanel> - <ItemsPanelTemplate> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" MaxWidth="110"> - - </StackPanel> - </ItemsPanelTemplate> - </ItemsControl.ItemsPanel> - <ItemsControl.ItemTemplate> - <DataTemplate> - <Border Width="25" Height="25" Margin="10 0 0 0" BorderThickness="1" BorderBrush="DimGray" CornerRadius="3"> - <Border.Background> - <MultiBinding Converter="{StaticResource SegmentToBrushConverterMulti}"> - <Binding Path="."></Binding> - </MultiBinding> - </Border.Background> - </Border> - </DataTemplate> - </ItemsControl.ItemTemplate> - </ItemsControl> - <StackPanel Orientation="Horizontal" Margin="0 0 0 0" VerticalAlignment="Center"> - <StackPanel.Style> - <Style TargetType="StackPanel"> - <Setter Property="Visibility" Value="Collapsed"></Setter> + <commonControls:LoadingPanel IsLoading="{Binding IsLoading}"> + <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}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate DataType="{x:Type observables:Job}"> + <ContentControl> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content"> + <Setter.Value> + <Image Source="../Images/rgb.png" Width="40" Margin="5"></Image> + </Setter.Value> + </Setter> <Style.Triggers> - <DataTrigger Binding="{Binding Segments.Count,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter=3}" Value="True"> - <Setter Property="Visibility" Value="Visible"></Setter> + <DataTrigger Binding="{Binding HasEmbroideryFile}" Value="True"> + <Setter Property="Content"> + <Setter.Value> + <Button ToolTip="Press to display the attached embroidery file information" Style="{StaticResource emptyButton}" Cursor="Hand" Command="{Binding DataContext.DisplayJobEmbroideryFileCommand, Source={x:Reference control}}" CommandParameter="{Binding}"> + <Image Source="../Images/job-emb.png" Width="40" Margin="5"></Image> + </Button> + </Setter.Value> + </Setter> </DataTrigger> </Style.Triggers> </Style> - </StackPanel.Style> - <materialDesign:PackIcon Kind="Plus" Width="18" Height="18" VerticalAlignment="Center" /> - <TextBlock Margin="0 -3 0 0" Text="{Binding Segments.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-3'}" FontSize="16" VerticalAlignment="Center" FontWeight="SemiBold" FontStyle="Italic"></TextBlock> + </ContentControl.Style> + </ContentControl> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="NAME" CanUserSort="True" SortMemberPath="Name"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center" FontSize="14"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="CREATION DATE" Width="150" CanUserSort="True" SortMemberPath="CreationDate"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding CreationDate,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" VerticalAlignment="Center" FontSize="14"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="LAST MODIFIED" Width="150" CanUserSort="True" SortMemberPath="LastUpdated"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" VerticalAlignment="Center" FontSize="14"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="LAST RUN" Width="150" CanUserSort="True" SortMemberPath="LastRun"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding LastRun,Converter={StaticResource DateTimeUTCToShortDateTimeConverter},FallbackValue='Never',TargetNullValue='Never'}" VerticalAlignment="Center" FontSize="14"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="USER" Width="100" CanUserSort="True" SortMemberPath="User"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding User.Contact.FirstName}" VerticalAlignment="Center" FontSize="14"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="LENGTH" Width="100" CanUserSort="True" SortMemberPath="Length"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center" FontSize="14"> + <Run Text="{Binding Length,Mode=OneWay,StringFormat=N2}"></Run> + <Run Text="m" Foreground="Gray"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="DURATION" Width="100" CanUserSort="True" SortMemberPath="EstimatedDurationMili"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock VerticalAlignment="Center" FontSize="14"> + <Run Text="{Binding EstimatedDurationMili,Converter={StaticResource MillisecondsToTimeSpanConverter},Mode=OneWay,StringFormat=hh\\:mm\\:ss,TargetNullValue='Unknown'}"></Run> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Width="1*" Header="SEGMENTS" CanUserSort="True" SortMemberPath="Segments.Count"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <StackPanel Orientation="Horizontal"> + <ItemsControl HorizontalAlignment="Right" ItemsSource="{Binding Segments}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" MaxWidth="110"> + + </StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Border Width="25" Height="25" Margin="10 0 0 0" BorderThickness="1" BorderBrush="DimGray" CornerRadius="3" Background="{Binding SegmentBrush}"> + + </Border> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + <StackPanel Orientation="Horizontal" Margin="0 0 0 0" VerticalAlignment="Center"> + <StackPanel.Style> + <Style TargetType="StackPanel"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Segments.Count,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter=3}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </StackPanel.Style> + <materialDesign:PackIcon Kind="Plus" Width="18" Height="18" VerticalAlignment="Center" /> + <TextBlock Margin="0 -3 0 0" Text="{Binding Segments.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-3'}" FontSize="16" VerticalAlignment="Center" FontWeight="SemiBold" FontStyle="Italic"></TextBlock> + </StackPanel> </StackPanel> - </StackPanel> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - </DataGrid.Columns> - </controls:MultiSelectDataGrid> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </controls:MultiSelectDataGrid> + </commonControls:LoadingPanel> </Grid> </DockPanel> |
