From 858a2b114f78c87883510e3627874c7632f81177 Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 18 Feb 2018 09:23:15 +0200 Subject: Developer redesign.. --- .../Views/MachineJobSelectionView.xaml | 202 +++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml') 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 new file mode 100644 index 000000000..998ba474d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + TARGET MACHINE + + + + + + + + + + + + + + + + + + + + + + + MACHINE JOBS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.3.1 From 95b4e14bc4e06ffb94199f5ec4e0d2d9bebceeff Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 18 Feb 2018 18:48:16 +0200 Subject: Working on new developer module. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.DataCapture.csproj | 1 + .../Tango.MachineStudio.DataCapture/app.config | 11 ++ .../Tango.MachineStudio.Developer.csproj | 3 + .../ViewModels/MainViewVM.cs | 151 +++++++++++++++++++-- .../Views/JobView.xaml | 13 +- .../Views/MachineJobSelectionView.xaml | 13 +- .../Tango.MachineStudio.Developer/packages.config | 1 + .../Tango.CodeGeneration/EntityCodeFile.cs | 2 + .../Templates/EntityCodeFile.cshtml | 4 + .../Visual_Studio/Tango.Core/IParameterized.cs | 2 + .../Observables/Entities/ActionType.cs | 2 + .../Observables/Entities/Address.cs | 2 + .../Entities/ApplicationDisplayPanelVersion.cs | 2 + .../Entities/ApplicationFirmwareVersion.cs | 2 + .../Observables/Entities/ApplicationOsVersion.cs | 2 + .../Observables/Entities/ApplicationVersion.cs | 2 + .../Observables/Entities/BrushStop.cs | 9 ++ .../Observables/Entities/CartridgeType.cs | 2 + .../Tango.Integration/Observables/Entities/Cat.cs | 8 ++ .../Tango.Integration/Observables/Entities/Cct.cs | 5 + .../Observables/Entities/ColorSpace.cs | 2 + .../Observables/Entities/Configuration.cs | 23 ++++ .../Observables/Entities/Contact.cs | 2 + .../Observables/Entities/DispenserType.cs | 2 + .../Entities/EmbeddedFirmwareVersion.cs | 2 + .../Entities/EmbeddedSoftwareVersion.cs | 2 + .../Observables/Entities/EventType.cs | 2 + .../Observables/Entities/EventTypesAction.cs | 8 ++ .../Observables/Entities/FiberShape.cs | 2 + .../Observables/Entities/FiberSynth.cs | 2 + .../Observables/Entities/HardwareVersion.cs | 2 + .../Observables/Entities/IdsPack.cs | 20 +++ .../Observables/Entities/IdsPackFormula.cs | 2 + .../Tango.Integration/Observables/Entities/Job.cs | 14 ++ .../Observables/Entities/JobRun.cs | 5 + .../Observables/Entities/LinearMassDensityUnit.cs | 2 + .../Observables/Entities/LiquidType.cs | 2 + .../Observables/Entities/LiquidTypesRml.cs | 8 ++ .../Observables/Entities/Machine.cs | 11 ++ .../Observables/Entities/MachineVersion.cs | 5 + .../Observables/Entities/MachinesConfiguration.cs | 8 ++ .../Observables/Entities/MachinesEvent.cs | 11 ++ .../Observables/Entities/MediaColor.cs | 2 + .../Observables/Entities/MediaCondition.cs | 2 + .../Observables/Entities/MediaMaterial.cs | 2 + .../Observables/Entities/MediaPurpos.cs | 2 + .../Observables/Entities/MidTankType.cs | 2 + .../Observables/Entities/Organization.cs | 8 ++ .../Observables/Entities/Permission.cs | 2 + .../Observables/Entities/ProcessParametersTable.cs | 5 + .../Entities/ProcessParametersTablesGroup.cs | 5 + .../Tango.Integration/Observables/Entities/Rml.cs | 23 ++++ .../Tango.Integration/Observables/Entities/Role.cs | 2 + .../Observables/Entities/RolesPermission.cs | 8 ++ .../Observables/Entities/Segment.cs | 5 + .../Observables/Entities/SyncConfiguration.cs | 2 + .../Observables/Entities/TechDispenser.cs | 2 + .../Observables/Entities/TechIo.cs | 2 + .../Observables/Entities/TechMonitor.cs | 2 + .../Observables/Entities/TechMotor.cs | 2 + .../Observables/Entities/TechValf.cs | 2 + .../Tango.Integration/Observables/Entities/User.cs | 11 ++ .../Observables/Entities/UsersRole.cs | 8 ++ .../Observables/Entities/WindingMethod.cs | 2 + .../Observables/IObservableEntity.cs | 12 ++ .../Observables/ObservableEntity.cs | 33 ++++- .../Tango.Integration/Printing/BrushStop.cs | 21 +++ .../Tango.Integration/Printing/Job.cs | 22 ++- .../Tango.Integration/Printing/LiquidVolume.cs | 20 ++- .../Tango.Integration/Printing/Segment.cs | 32 ++++- .../Tango.Integration/Tango.Integration.csproj | 3 + .../Tango.Integration/packages.config | 1 + .../Tango.SharedUI/Controls/MultiSelectDataGrid.cs | 37 +++++ .../Tango.SharedUI/Controls/MultiSelectListBox.cs | 38 ++++++ .../Tango.SharedUI/Tango.SharedUI.csproj | 2 + .../ObservablesGenerator.cs | 1 + 78 files changed, 663 insertions(+), 34 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/app.config create mode 100644 Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectListBox.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 0484aed80..0e6d30aef 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 0a2fb21b2..cb15dbe51 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj index 8936a66db..d97f540b1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj @@ -118,6 +118,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/app.config new file mode 100644 index 000000000..cacd4cd77 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file 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 086d6cd91..eae234a8b 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 @@ -31,6 +31,9 @@ 4 + + ..\..\..\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll 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 7a1c94504..5c5531063 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 @@ -34,6 +34,8 @@ using Tango.MachineStudio.Common.Video; using Tango.Integration.Services; using Tango.MachineStudio.Developer.Navigation; using System.Data.Entity; +using Tango.MachineStudio.Common.Authentication; +using DeepEqual.Syntax; namespace Tango.MachineStudio.Developer.ViewModels { @@ -52,18 +54,24 @@ namespace Tango.MachineStudio.Developer.ViewModels private ObservablesContext _dbJobContext; private Job _jobFromList; private bool _blockInvalidateCommands; + private IAuthenticationProvider _authentication; #region Properties private ObservableCollection _colorSpaces; - + /// + /// Gets or sets the color spaces. + /// public ObservableCollection ColorSpaces { get { return _colorSpaces; } set { _colorSpaces = value; RaisePropertyChangedAuto(); } } - private ObservableCollection _rmls; + private ObservableCollection _rmls; + /// + /// Gets or sets the RMLS. + /// public ObservableCollection Rmls { get { return _rmls; } @@ -172,6 +180,16 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + private ObservableCollection _selectedJobs; + /// + /// Gets or sets the selected jobs. + /// + public ObservableCollection SelectedJobs + { + get { return _selectedJobs; } + set { _selectedJobs = value; RaisePropertyChangedAuto(); } + } + private Segment _selectedSegment; /// /// Gets or sets the job selected segment. @@ -182,6 +200,16 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _selectedSegment = value; RaisePropertyChangedAuto(); OnSelectedSegmentChanged(); } } + private ObservableCollection _selectedSegments; + /// + /// Gets or sets the selected segments. + /// + public ObservableCollection SelectedSegments + { + get { return _selectedSegments; } + set { _selectedSegments = value; RaisePropertyChangedAuto(); } + } + private BrushStop _selectedBrushStop; /// /// Gets or sets the selected segment selected brush stop. @@ -192,6 +220,16 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _selectedBrushStop = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _selectedBrushStops; + /// + /// Gets or sets the selected brush stops. + /// + public ObservableCollection SelectedBrushStops + { + get { return _selectedBrushStops; } + set { _selectedBrushStops = value; RaisePropertyChangedAuto(); } + } + private Rml _selectedRML; /// /// Gets or sets the selected RML. @@ -457,6 +495,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand LoadJobCommand { get; set; } + /// + /// Gets or sets the duplicate job command. + /// + public RelayCommand DuplicateJobCommand { get; set; } + #endregion #region Constructors @@ -482,8 +525,12 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation) : this(view) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view) { + SelectedJobs = new ObservableCollection(); + + _authentication = authentication; + _notification = notificationProvider; _navigation = navigation; ApplicationManager = applicationManager; @@ -509,6 +556,7 @@ namespace Tango.MachineStudio.Developer.ViewModels CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); ExitFullScreenCommand = new RelayCommand(ExitFullScreen); LoadJobCommand = new RelayCommand(LoadJob, () => SelectedJob != null); + DuplicateJobCommand = new RelayCommand(DuplicateJob, () => SelectedJob != null); ToggleCameraCommand = new RelayCommand(ToggleCamera); @@ -547,6 +595,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private void SelectedMachine_Saved(object sender, EventArgs e) { InvalidateLiquidFactorsAndProcessTables(); + SelectedMachine.Reload(); } /// @@ -640,14 +689,43 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods + private async void DuplicateJob() + { + if (SelectedJobs.Count > 0) + { + using (_notification.PushTaskItem("Cloning selected jobs...")) + { + int index = SelectedMachine.Jobs.Max(x => x.JobIndex); + + foreach (var job in SelectedJobs) + { + var cloned = job.Clone(); + cloned.JobIndex = ++index; + SelectedMachine.Jobs.Add(cloned); + } + + await SelectedMachine.SaveAsync(); + } + } + } + private async void LoadJob() { if (SelectedJob != null) { + SelectedSegments = new ObservableCollection(); + SelectedBrushStops = new ObservableCollection(); + SelectedRML = null; + SelectedSegment = null; + SelectedGroupHistory = null; + SelectedBrushStop = null; + SelectedProcessParametersTable = null; + RmlProcessParametersTableGroup = null; + using (_notification.PushTaskItem("Loading job details...")) { - await Task.Factory.StartNew(() => - { + //await Task.Factory.StartNew(() => + //{ _blockInvalidateCommands = false; _dbJobContext = ObservablesContext.CreateDefault(); @@ -675,7 +753,7 @@ namespace Tango.MachineStudio.Developer.ViewModels InvalidateRelayCommands(); InvokeUI(() => _navigation.NavigateTo(DeveloperNavigationView.JobView)); - }); + //}); } } } @@ -688,15 +766,45 @@ namespace Tango.MachineStudio.Developer.ViewModels { SelectedJob.LastUpdated = DateTime.UtcNow; SelectedJob.Rml = SelectedRML; - await SelectedJob.SaveAsync(); + await SelectedJob.SaveAsync(_dbJobContext); + _jobFromList = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SelectedJob.Guid); await _jobFromList.Reload(); + + foreach (var segment in _jobFromList.Segments) + { + await segment.Reload(); + + foreach (var stop in segment.BrushStops) + { + await stop.Reload(); + } + } } } } private void DiscardJob() { - if (_notification.ShowQuestion("This will discard the current job changes. Are you sue?")) + //bool jobModified = !SelectedJob.WithDeepEqual(_jobFromList) + // .IgnoreSourceProperty(x => x.Machine) + // .IgnoreSourceProperty(x => x.JobRuns) + // .IgnoreSourceProperty(x => x.Parameters) + // .IgnoreSourceProperty(x => x.Rml) + // .IgnoreSourceProperty(x => x.User) + // .IgnoreSourceProperty(x => x.Segments) + // .Compare(); + + bool jobModified = !SelectedJob.CompareUsingJson(_jobFromList); + + if (jobModified) + { + if (_notification.ShowQuestion("This will discard the current job changes. Are you sue?")) + { + _dbJobContext.Dispose(); + _navigation.NavigateTo(DeveloperNavigationView.MachineJobSelectionView); + } + } + else { _dbJobContext.Dispose(); _navigation.NavigateTo(DeveloperNavigationView.MachineJobSelectionView); @@ -1012,11 +1120,18 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Removes the selected job. /// - private void RemoveJob() + private async void RemoveJob() { if (SelectedMachine != null && SelectedJob != null) { - SelectedMachine.Jobs.Remove(SelectedJob); + if (_notification.ShowQuestion("Are you sure you want to delete the selected jobs?")) + { + SelectedJobs.ToList().ForEach(x => + { + x.DefferedDelete(); + }); + await SelectedMachine.SaveAsync(); + } } } @@ -1027,11 +1142,19 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedMachine != null) { - SelectedMachine.Jobs.Add(new Job(DateTime.UtcNow) + String jobName = _notification.ShowTextInput("Please provide a job name", "Name"); + + if (!String.IsNullOrWhiteSpace(jobName)) { - Name = "Untitled Job", - CreationDate = DateTime.UtcNow, - }); + Job newJob = new Job(); + newJob.Name = jobName; + newJob.CreationDate = DateTime.UtcNow; + newJob.User = _authentication.CurrentUser; + newJob.Rml = Adapter.Rmls.FirstOrDefault(); + + SelectedJob = newJob; + LoadJob(); + } } } 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 b6455175e..35a30e91e 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 @@ -14,6 +14,7 @@ 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" xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" xmlns:localConverters="clr-namespace:Tango.MachineStudio.Developer.Converters" @@ -230,7 +231,7 @@ - - - - - + # @@ -333,13 +287,12 @@ - - + + - @@ -378,11 +331,11 @@ - + - + @@ -394,7 +347,7 @@ Name - + @@ -404,7 +357,7 @@ Winding Method - + @@ -415,8 +368,8 @@ Inter Segment - - + + @@ -428,7 +381,7 @@ Lubrication - + @@ -441,7 +394,7 @@ - + @@ -619,7 +572,7 @@ - + - + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 7e0ef2eb5..cd4fc1aeb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -185,6 +185,10 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote + + {b112d89a-a106-41ae-a0c1-4abc84c477f5} + Tango.DragAndDrop + {de2f2b86-025b-4f26-83a4-38bd48224ed5} Tango.Editors diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs index d7161953f..948be3c4a 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs @@ -41,5 +41,18 @@ public static class ObservableCollectionExtensions collection[index1] = collection[index2]; collection[index2] = tmp; } + + /// + /// Removes the dragged element and inserts it after the dropped element position. + /// + /// + /// The collection. + /// The dragged element. + /// The dropped element. + public static void DragAndDrop(this ObservableCollection collection, T dragged, T dropped) + { + collection.Remove(dragged); + collection.Insert(collection.IndexOf(dropped), dragged); + } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs index eb16d150d..15fb521ba 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs @@ -54,12 +54,12 @@ namespace Tango.Integration.Observables /// /// Attaches this observable to the proper DbSet. /// - void Attach(); + void Attach(ObservablesContext context = null); /// /// Detaches this observable from the proper DbSet. /// - void Detach(); + void Detach(ObservablesContext context = null); /// /// Saves the changes on this entity to database asynchronously. @@ -76,12 +76,12 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database. /// - void Delete(); + void Delete(ObservablesContext context = null); /// /// Deletes this entity without saving changes to data base. /// - void DefferedDelete(); + void DefferedDelete(ObservablesContext context = null); /// /// Deletes this entity from the database. diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs index d5b218453..f92d9dfa0 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs @@ -44,6 +44,7 @@ namespace Tango.Integration.Observables /// Gets or sets the entity identifier. /// [Column("ID")] + [JsonIgnore] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public Int32 ID { @@ -57,6 +58,7 @@ namespace Tango.Integration.Observables /// [Key] [Column("GUID")] + [JsonIgnore] public String Guid { get { return _guid; } @@ -121,17 +123,17 @@ namespace Tango.Integration.Observables /// /// Attaches this entity to the proper DbSet. /// - public virtual void Attach() + public virtual void Attach(ObservablesContext context = null) { - GetDbSet().Add(this as T); + GetDbSet(context).Add(this as T); } /// /// Detaches this observable from the proper DbSet. /// - public virtual void Detach() + public virtual void Detach(ObservablesContext context = null) { - GetDbSet().Remove(this as T); + GetDbSet(context).Remove(this as T); } /// @@ -150,15 +152,15 @@ namespace Tango.Integration.Observables /// Reloads this observable entity. /// /// - public Task Reload() + public Task Reload(ObservablesContext context) { - return ObservablesEntitiesAdapter.Instance.Context.Entry(this).ReloadAsync(); + return context.Entry(this).ReloadAsync(); } /// /// Deletes this entity from the database /// - public virtual void Delete() + public virtual void Delete(ObservablesContext context = null) { var delProp = this.GetType().GetProperty("Deleted"); @@ -169,7 +171,7 @@ namespace Tango.Integration.Observables } else { - GetDbSet().Remove(this as T); + GetDbSet(context).Remove(this as T); Save(); } } @@ -177,9 +179,9 @@ namespace Tango.Integration.Observables /// /// Deletes this entity without saving changes to data base. /// - public virtual void DefferedDelete() + public virtual void DefferedDelete(ObservablesContext context = null) { - GetDbSet().Remove(this as T); + GetDbSet(context).Remove(this as T); } /// @@ -193,17 +195,15 @@ namespace Tango.Integration.Observables }); } - /// - /// Gets the observable database set. - /// - /// - public DbSet GetDbSet() + public DbSet GetDbSet(ObservablesContext context) { + context = context != null ? context : ObservablesEntitiesAdapter.Instance.Context; + String tabelName = this.GetType().Name.PluralizeMVC(); var p = typeof(ObservablesContext).GetProperty(tabelName); if (p != null) { - var set1 = p.GetValue(ObservablesEntitiesAdapter.Instance.Context) as DbSet; + var set1 = p.GetValue(context) as DbSet; return set1; } else @@ -212,7 +212,7 @@ namespace Tango.Integration.Observables p = typeof(ObservablesContext).GetProperty(tabelName); if (p != null) { - var set2 = p.GetValue(ObservablesEntitiesAdapter.Instance.Context) as DbSet; + var set2 = p.GetValue(context) as DbSet; return set2; } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs index c60102671..3622169c9 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs @@ -8,21 +8,21 @@ namespace Tango.Integration.Observables { public partial class Configuration { - public override void DefferedDelete() + public override void DefferedDelete(ObservablesContext context = null) { - IdsPacks.ToList().ForEach(x => x.DefferedDelete()); + IdsPacks.ToList().ForEach(x => x.DefferedDelete(context)); var machine_configurations = ObservablesEntitiesAdapter.Instance.MachinesConfigurations.Where(x => x.Configuration == this); - MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete()); - base.DefferedDelete(); + MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete(context)); + base.DefferedDelete(context); IdsPacks.Clear(); } - public override void Delete() + public override void Delete(ObservablesContext context = null) { - IdsPacks.ToList().ForEach(x => x.DefferedDelete()); + IdsPacks.ToList().ForEach(x => x.DefferedDelete(context)); var machine_configurations = ObservablesEntitiesAdapter.Instance.MachinesConfigurations.Where(x => x.Configuration == this); - MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete()); - base.Delete(); + MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete(context)); + base.Delete(context); IdsPacks.Clear(); } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs index 850003e60..bb26acc39 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs @@ -12,7 +12,7 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database /// - public override void Delete() + public override void Delete(ObservablesContext context = null) { foreach (var machine_config in MachinesConfigurations) { diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs index c7d1f8321..18799b7ed 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs @@ -8,7 +8,7 @@ namespace Tango.Integration.Observables { public partial class MachineVersion { - public override void Delete() + public override void Delete(ObservablesContext context = null) { this.DefaultConfiguration.Delete(); base.Delete(); diff --git a/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs b/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs index ebc77e615..ae8aa0e37 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs @@ -37,7 +37,6 @@ namespace Tango.Integration.Observables set { _liquidVolumes = value; RaisePropertyChangedAuto(); } } - private Color _color; /// /// Gets or sets the brush stop color. /// @@ -45,13 +44,12 @@ namespace Tango.Integration.Observables [JsonIgnore] public Color Color { - get { return _color; } + get { return Color.FromRgb((byte)_red, (byte)_green,(byte)_blue); } set { - _color = value; - _red = _color.R; - _green = _color.G; - _blue = _color.B; + _red = value.R; + _green = value.G; + _blue = value.B; RaisePropertyChanged(nameof(Color)); } } @@ -62,7 +60,7 @@ namespace Tango.Integration.Observables [NotMapped] public int Index { - get { return Segment.BrushStops.IndexOf(this); } + get { return StopIndex; } } /// @@ -72,7 +70,7 @@ namespace Tango.Integration.Observables [JsonIgnore] public bool IsFirst { - get { return Segment.BrushStops.IndexOf(this) == 0; } + get { return StopIndex == 0; } } /// @@ -82,7 +80,7 @@ namespace Tango.Integration.Observables [JsonIgnore] public bool IsLast { - get { return Segment.BrushStops.IndexOf(this) == Segment.BrushStops.Count - 1; } + get { return StopIndex == Segment.BrushStops.Count - 1; } } /// @@ -146,6 +144,16 @@ namespace Tango.Integration.Observables } } + public void SetStopIndex(int index) + { + _stopindex = index; + } + + public void RaiseStopIndex() + { + StopIndex = _stopindex; + } + #endregion #region Override Methods @@ -229,8 +237,6 @@ namespace Tango.Integration.Observables _l = lab.L; _a = lab.A; _b = lab.B; - - _color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); } #endregion diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs index 1cc4865f2..49c5fbdae 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs @@ -124,7 +124,7 @@ namespace Tango.Integration.Observables { for (int i = 0; i < Segments.Count; i++) { - Segments[i].SegmentIndex = i; + Segments[i].SegmentIndex = i + 1; for (int j = 0; j < Segments[i].BrushStops.Count; j++) { @@ -146,11 +146,11 @@ namespace Tango.Integration.Observables return cloned; } - public override void DefferedDelete() + public override void DefferedDelete(ObservablesContext context = null) { - Segments.ToList().ForEach(x => x.DefferedDelete()); + Segments.ToList().ForEach(x => x.DefferedDelete(context)); Segments.Clear(); - base.DefferedDelete(); + base.DefferedDelete(context); } #endregion diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs b/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs index 6213240ed..d3e50ec37 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs @@ -68,11 +68,11 @@ namespace Tango.Integration.Observables return cloned; } - public override void DefferedDelete() + public override void DefferedDelete(ObservablesContext context = null) { - BrushStops.ToList().ForEach(x => x.DefferedDelete()); + BrushStops.ToList().ForEach(x => x.DefferedDelete(context)); BrushStops.Clear(); - base.DefferedDelete(); + base.DefferedDelete(context); } } } -- cgit v1.3.1 From a794a5d088b425d7b41f87d7c3a43b904249e11e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 19 Feb 2018 17:52:10 +0200 Subject: Working on developer module... --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.Developer.csproj | 7 - .../ViewModelLocator.cs | 2 +- .../ViewModels/MainViewVM.cs | 251 +-- .../Views/JobView.xaml | 2 +- .../Views/JobView.xaml.cs | 8 - .../Views/MachineJobSelectionView.xaml | 4 +- .../Views/MainView.xaml | 2246 -------------------- .../Views/MainView.xaml.cs | 162 -- .../Observables/IObservableEntity.cs | 18 +- .../Observables/ObservableEntity.cs | 30 +- .../Observables/Partials/Machine.cs | 4 +- .../Observables/Partials/Segment.cs | 4 +- .../Tango.Integration/Printing/Job.cs | 4 +- 15 files changed, 68 insertions(+), 2674 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 89b9bb6e2..24b24abfc 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 064ee4ca7..54bf7ba0d 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 eae234a8b..f986219e2 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 @@ -136,9 +136,6 @@ MachineJobSelectionView.xaml - - MainView.xaml - GlobalVersionInfo.cs @@ -165,10 +162,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile 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 415643e3f..b397f1912 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Developer { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - SimpleIoc.Default.Register(() => MainView.Self); + //SimpleIoc.Default.Register(() => MainView.Self); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); } 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 c8a6aa89f..199183c12 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 @@ -45,14 +45,12 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Represents the developer module main view, view model. /// /// - public class MainViewVM : ViewModel, IShutdownRequestBlocker + public class MainViewVM : ViewModel, IShutdownRequestBlocker { private static object _syncLock = new object(); private INotificationProvider _notification; private TimeSpan _runningJobEstimatedDuration; - private Dictionary _controllers; - private int _fullScreenGraphIndex; private JobHandler _jobHandler; private DeveloperNavigationManager _navigation; private ObservablesContext _dbJobContext; @@ -62,6 +60,16 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Properties + private ObservableCollection _machines; + /// + /// Gets or sets the machines. + /// + public ObservableCollection Machines + { + get { return _machines; } + set { _machines = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection _colorSpaces; /// /// Gets or sets the color spaces. @@ -82,6 +90,15 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _rmls = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _windingMethods; + + public ObservableCollection WindingMethods + { + get { return _windingMethods; } + set { _windingMethods = value; RaisePropertyChangedAuto(); } + } + + /// /// Gets or sets the application manager. /// @@ -92,11 +109,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public IVideoCaptureProvider VideoCaptureProvider { get; set; } - /// - /// Gets or sets observable entites database the adapter. - /// - public ObservablesEntitiesAdapter Adapter { get; set; } - protected Machine _selectedMachine; /// /// Gets or sets the selected machine. @@ -286,26 +298,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _isSideBarOpened = value; RaisePropertyChangedAuto(); } } - private ObservableCollection _availableGraphs; - /// - /// Gets or sets the available sensors. - /// - public ObservableCollection AvailableGraphs - { - get { return _availableGraphs; } - set { _availableGraphs = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection _graphs; - /// - /// Gets or sets the collection of displayed graph controls. - /// - public ObservableCollection Graphs - { - get { return _graphs; } - set { _graphs = value; RaisePropertyChangedAuto(); } - } - private TimeSpan _estimatedDuration; /// /// Gets or sets the estimated duration for the selected job. @@ -556,16 +548,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand CloseJobCompletionStatusCommand { get; set; } - /// - /// Gets or sets the toggle camera command. - /// - public RelayCommand ToggleCameraCommand { get; set; } - - /// - /// Gets or sets the exit full screen command. - /// - public RelayCommand ExitFullScreenCommand { get; set; } - /// /// Gets or sets the load job command. /// @@ -593,16 +575,9 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Initializes a new instance of the class. /// - public MainViewVM(IMainView view) : base(view, true) + public MainViewVM() : base() { - if (!this.DesignMode) - { - Adapter = ObservablesEntitiesAdapter.Instance; - AvailableGraphs = Adapter.TechMonitors.ToObservableCollection(); - } - Graphs = new ObservableCollection(); - _controllers = new Dictionary(); } /// @@ -611,8 +586,13 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this() { + using (var db = ObservablesContext.CreateDefault()) + { + Machines = db.Machines.ToObservableCollection(); + } + _machineDBContext = ObservablesContext.CreateDefault(); SelectedJobs = new ObservableCollection(); @@ -623,7 +603,6 @@ namespace Tango.MachineStudio.Developer.ViewModels _navigation = navigation; ApplicationManager = applicationManager; VideoCaptureProvider = videoCaptureProvider; - diagnosticsFrameProvider.FrameReceived += DiagnosticsFrameProvider_FrameReceived; //Initialize Commands... EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); @@ -642,14 +621,11 @@ namespace Tango.MachineStudio.Developer.ViewModels StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); - ExitFullScreenCommand = new RelayCommand(ExitFullScreen); LoadJobCommand = new RelayCommand(LoadJob, () => SelectedMachineJob != null); DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null); DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null); DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null); - ToggleCameraCommand = new RelayCommand(ToggleCamera); - ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } @@ -657,16 +633,6 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Event Handlers - /// - /// Handles the diagnostics provider frame received event. - /// - /// The sender. - /// The response. - private void DiagnosticsFrameProvider_FrameReceived(object sender, PushDiagnosticsResponse response) - { - PopulateDiagnosticsData(response); - } - /// /// Handles the application manager connected machine changes event. /// @@ -835,6 +801,7 @@ namespace Tango.MachineStudio.Developer.ViewModels ColorSpaces = _dbJobContext.ColorSpaces.ToObservableCollection(); Rmls = _dbJobContext.Rmls.ToObservableCollection(); + WindingMethods = _dbJobContext.WindingMethods.ToObservableCollection(); _activeJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedMachineJob.Guid); @@ -896,59 +863,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - private void ClearGraphs() - { - _controllers.ToList().ForEach(x => x.Value.Clear()); - } - - private void PopulateDiagnosticsData(PushDiagnosticsResponse data) - { - foreach (var prop in data.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) - { - GraphControllerBase controller = null; - - if (_controllers.TryGetValue(prop.Name, out controller)) - { - if (controller is GraphController) - { - double[] arr = Enumerable.ToArray(prop.GetValue(data) as IEnumerable); - (controller as GraphController).PushData(arr); - } - else - { - DoubleArray[] arrayOfDoubles = Enumerable.ToArray(prop.GetValue(data) as IEnumerable); - (controller as GraphMultiController).PushData(arrayOfDoubles.Select(x => x.Data.ToList()).ToList()); - } - } - } - } - - private void ExitFullScreen() - { - if (FullScreenGraph != null) - { - FullScreenGraph.EnableToolBar = true; - Graphs.Insert(_fullScreenGraphIndex, FullScreenGraph); - FullScreenGraph = null; - } - } - - private void StartFullScreenGraph(IRealTimeGraph graph) - { - graph.EnableToolBar = false; - _fullScreenGraphIndex = Graphs.IndexOf(graph); - Graphs.Remove(graph); - FullScreenGraph = graph; - } - - private void ToggleCamera(CaptureDevice captureDevice) - { - if (captureDevice.Device != null) - { - captureDevice.IsStarted = !captureDevice.IsStarted; - } - } - private void CloseJobCompletionStatusBar() { _navigation.NavigateTo(DeveloperNavigationView.JobView); @@ -1138,15 +1052,9 @@ namespace Tango.MachineStudio.Developer.ViewModels g.Active = false; } - //String machineGuid = SelectedMachine.Guid; - //String rmlGuid = SelectedRML.Guid; - SelectedRML.ProcessParametersTablesGroups.Add(group); await SelectedRML.SaveAsync(); - //SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == machineGuid); - //SelectedRML = Adapter.Rmls.SingleOrDefault(x => x.Guid == rmlGuid); - InvalidateLiquidFactorsAndProcessTables(); } } @@ -1329,8 +1237,8 @@ namespace Tango.MachineStudio.Developer.ViewModels newJob.Name = jobName; newJob.CreationDate = DateTime.UtcNow; newJob.User = _authentication.CurrentUser; - newJob.Rml = Adapter.Rmls.FirstOrDefault(); - newJob.WindingMethod = Adapter.WindingMethods.FirstOrDefault(); + newJob.Rml = _machineDBContext.Rmls.FirstOrDefault(); + newJob.WindingMethod = _machineDBContext.WindingMethods.FirstOrDefault(); newJob.Machine = SelectedMachine; SelectedMachine.Jobs.Add(newJob); @@ -1462,68 +1370,6 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Public Methods - /// - /// Add sensor graph from available sensors to displayed graphs. - /// - /// The sensor. - public void OnDropAvailableGraph(TechMonitor sensor) - { - if (Graphs.Count < 8) - { - IRealTimeGraph graphControl = null; - GraphControllerBase controller = null; - - if (!sensor.MultiChannel) - { - graphControl = new RealTimeGraphControl(); - controller = new GraphController(); - graphControl.Controller = controller; - } - else - { - graphControl = new RealTimeGraphMultiControl(); - controller = new GraphMultiController(); - - for (int i = 0; i < sensor.ChannelCount; i++) - { - var randomColor = new SolidColorBrush(Core.Helpers.ColorHelper.GetRandomColor()); - - (controller as GraphMultiController).AddSeries(new DataYSeries() - { - Name = sensor.Description.First().ToString() + (i + 1), - UseFillAndStroke = true, - Stroke = randomColor - }); - } - - graphControl.Controller = controller; - } - - graphControl.Tag = sensor; - graphControl.SensorName = sensor.Description; - graphControl.SensorUnits = sensor.Units; - graphControl.InnerGraph.Minimum = sensor.Min; - graphControl.InnerGraph.Maximum = sensor.Max; - graphControl.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(sensor.PointsPerFrame); - graphControl.GraphRemoveButtonPressed += (sender, _) => - { - RemoveGraph(sender as IRealTimeGraph); - }; - graphControl.GraphFullScreenButtonPressed += (sender, _) => - { - StartFullScreenGraph(sender as IRealTimeGraph); - }; - Graphs.Add(graphControl); - AvailableGraphs.Remove(sensor); - - _controllers.Add(sensor.Name, controller); - } - else - { - _notification.ShowInfo("The maximum number of real-time graphs is eight. Please remove a graph to add another."); - } - } - /// /// Switch the brush stop position in the segment. /// @@ -1536,19 +1382,6 @@ namespace Tango.MachineStudio.Developer.ViewModels ArrangeBrushStopsIndices(); } - /// - /// Removes the graph. - /// - /// The graph. - public void RemoveGraph(IRealTimeGraph graph) - { - var sensor = graph.Tag as TechMonitor; - _controllers.Remove(sensor.Name); - graph.InnerGraph.Dispose(); - Graphs.Remove(graph); - AvailableGraphs.Insert(0, sensor); - } - #endregion #region IShutdownRequestBlocker @@ -1575,20 +1408,20 @@ namespace Tango.MachineStudio.Developer.ViewModels #region IMainView - protected override void OnViewAttached() - { - base.OnViewAttached(); + //protected override void OnViewAttached() + //{ + // base.OnViewAttached(); - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) - { - SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); - } + // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) + // //{ + // // SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); + // //} - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) - { - ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); - } - } + // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) + // //{ + // // ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); + // //} + //} #endregion } 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 cf7af21d9..69f0fed5c 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 @@ -357,7 +357,7 @@ Winding Method - + 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 41886357b..27ea3cae8 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 @@ -82,14 +82,6 @@ namespace Tango.MachineStudio.Developer.Views } } - private void OnDropAvailableGraph(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is TechMonitor) - { - _vm.OnDropAvailableGraph(e.Draggable.DataContext as TechMonitor); - } - } - private void Offset_Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { UpdateGradientBrushDisplay(); 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 8881e4f57..c07ddb95b 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 @@ -31,7 +31,7 @@ TARGET MACHINE - + @@ -84,7 +84,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Completed Successfully - - - - - - - - - - - - - - - - - - - - - - - Job Failed To Complete - - - - - - - - - - - - - - - - - - - - - - - - - Job Aborted By User - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HISTORY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SELECT MACHINE & MEDIA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MACHINE JOBS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name - - - - - - - - - - Winding Method - - - - - - - - - - Inter Segment - - - - - - - - - - - - - Lubrication - - - - - - - - - - - - Description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SEGMENTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name - - - - - - - - - Length - - - - - - - - - - - - - - - - - - - - - - - - - - - SEGMENT BRUSH - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Color Space - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ESTIMATED DURATION: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - USB CAMERAS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AVAILABLE GRAPHS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DRAG & DROP GRAPHS - - - - - - - - - - - - - - - - - - - - Display Graphs - - - - - - - - - - - - - - - - - Job Status - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LIQUID FACTORS ( Max Nanolitter/CM ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SELECT MACHINE & MEDIA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press - 'Escape' - to exit full screen mode - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs deleted file mode 100644 index 2bd36e449..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Tango.Integration.Observables; -using Tango.DragAndDrop; -using Tango.MachineStudio.Developer.Converters; -using Tango.MachineStudio.Developer.ViewModels; -using System.Windows.Threading; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Developer.Views -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class MainView : UserControl, IMainView - { - public static MainView Self { get; set; } - - private MainViewVM _vm; - private DispatcherTimer _jobBrushTimer; - - public DraggingSurface DraggingSurface - { - get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } - set { SetValue(DraggingSurfaceProperty, value); } - } - public static readonly DependencyProperty DraggingSurfaceProperty = - DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); - - public event EventHandler ViewAttached; - - public MainView() - { - Self = this; - - InitializeComponent(); - - DraggingSurface = draggingSurface; - this.Loaded += (x, y) => - { - _vm = DataContext as MainViewVM; - ViewAttached?.Invoke(this, this); - }; - - chkGraphs.Checked += (x, y) => - { - graphRowDefinition.Height = new GridLength(440, GridUnitType.Pixel); - //listCameras.Width = 240; - //dockCameras.Width = 270; - //dockCameras.Height = 600; - }; - chkGraphs.Unchecked += (x, y) => - { - graphRowDefinition.Height = new GridLength(80, GridUnitType.Pixel); - //listCameras.Width = double.NaN; - //dockCameras.Width = 330; - //dockCameras.Height = 850; - }; - - _jobBrushTimer = new DispatcherTimer(); - _jobBrushTimer.Interval = TimeSpan.FromSeconds(1); - _jobBrushTimer.Tick += _jobBrushTimer_Tick; - _jobBrushTimer.Start(); - } - - private void _jobBrushTimer_Tick(object sender, EventArgs e) - { - if (_vm != null && _vm.ActiveJob != null) - { - List segments = new List(); - foreach (var s in _vm.ActiveJob.Segments) - { - segments.Add(s); - - if (_vm.ActiveJob.EnableInterSegment && _vm.ActiveJob.Segments.IndexOf(s) != _vm.ActiveJob.Segments.Count - 1) - { - segments.Add(new Segment() - { - Length = _vm.ActiveJob.InterSegmentLength, - BrushStops = new System.Collections.ObjectModel.ObservableCollection() - { - new BrushStop() - { - Color = Colors.White, - } - }, - }); - } - } - - jobBrushList.ItemsSource = segments; - } - } - - private void OnDropAvailableGraph(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is TechMonitor) - { - _vm.OnDropAvailableGraph(e.Draggable.DataContext as TechMonitor); - } - } - - private void Offset_Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - UpdateGradientBrushDisplay(); - } - - private void UpdateGradientBrushDisplay() - { - if (_vm.SelectedSegment != null) - { - SegmentToGradientStopsConverter converter = new SegmentToGradientStopsConverter(); - GradientStopCollection stops = converter.Convert(_vm.SelectedSegment, null, null, null) as GradientStopCollection; - gradientBrush.GradientStops = stops; - } - else - { - gradientBrush.GradientStops = new GradientStopCollection(); - } - } - - private void OnBrushStopBorderDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is BrushStop) - { - _vm.OnDropBrushStop(e.Draggable.DataContext as BrushStop, e.Droppable.DataContext as BrushStop); - } - } - - private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - UpdateGradientBrushDisplay(); - } - - private void OnJobStartClick(object sender, RoutedEventArgs e) - { - - } - - private void HiveColorPickerControl_SelectedColorChanged(object sender, Color e) - { - UpdateGradientBrushDisplay(); - } - - private void Popup_MouseDown(object sender, MouseButtonEventArgs e) - { - e.Handled = true; - } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs index 15fb521ba..cd046ac2b 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs @@ -43,13 +43,7 @@ namespace Tango.Integration.Observables /// /// Saves the changes on this entity to database. /// - void Save(); - - /// - /// Saves the changes on this entity to database using the specified context. - /// - /// The context. - void Save(DbContext context); + void Save(ObservablesContext context = null); /// /// Attaches this observable to the proper DbSet. @@ -65,13 +59,7 @@ namespace Tango.Integration.Observables /// Saves the changes on this entity to database asynchronously. /// /// - Task SaveAsync(); - - /// - /// Saves the changes on this entity to database asynchronously. - /// - /// - Task SaveAsync(DbContext context); + Task SaveAsync(ObservablesContext context = null); /// /// Deletes this entity from the database. @@ -86,6 +74,6 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database. /// - Task DeleteAsync(); + Task DeleteAsync(ObservablesContext context = null); } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs index f92d9dfa0..e18193586 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs @@ -114,9 +114,16 @@ namespace Tango.Integration.Observables /// /// Saves the changes on this entity to database. /// - public virtual void Save() + public virtual void Save(ObservablesContext context = null) { - ObservablesEntitiesAdapter.Instance.SaveChanges(); + if (context == null) + { + ObservablesEntitiesAdapter.Instance.SaveChanges(); + } + else + { + context.SaveChanges(); + } OnSaved(); } @@ -140,11 +147,11 @@ namespace Tango.Integration.Observables /// Saves the changes on this entity to database asynchronously. /// /// - public Task SaveAsync() + public Task SaveAsync(ObservablesContext context = null) { return Task.Factory.StartNew(() => { - Save(); + Save(context); }); } @@ -187,11 +194,11 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database /// - public Task DeleteAsync() + public Task DeleteAsync(ObservablesContext context = null) { return Task.Factory.StartNew(() => { - Delete(); + Delete(context); }); } @@ -254,17 +261,6 @@ namespace Tango.Integration.Observables return (this as T).CloneEntity() as T; } - public void Save(DbContext context) - { - context.SaveChanges(); - OnSaved(); - } - - public Task SaveAsync(DbContext context) - { - return Task.Factory.StartNew(() => Save(context)); - } - public bool CompareUsingJson(T entity) { String me = JsonConvert.SerializeObject(this); diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs index bb26acc39..1669230d6 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs @@ -23,7 +23,7 @@ namespace Tango.Integration.Observables base.Delete(); } - public override void Save() + public override void Save(ObservablesContext context = null) { foreach (var job in Jobs) { @@ -48,7 +48,7 @@ namespace Tango.Integration.Observables } } - base.Save(); + base.Save(context); } } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs index c83c34870..71a15b90c 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs @@ -10,14 +10,14 @@ namespace Tango.Integration.Observables { public partial class Segment { - public override void Save() + public override void Save(ObservablesContext context = null) { for (int i = 0; i < BrushStops.Count; i++) { BrushStops[i].StopIndex = i; } - base.Save(); + base.Save(context); } } } diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs index 49c5fbdae..29155be53 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs @@ -120,7 +120,7 @@ namespace Tango.Integration.Observables /// /// Saves the changes on this entity to database. /// - public override void Save() + public override void Save(ObservablesContext context = null) { for (int i = 0; i < Segments.Count; i++) { @@ -132,7 +132,7 @@ namespace Tango.Integration.Observables } } - base.Save(); + base.Save(context); } public override Job Clone() -- cgit v1.3.1 From 160ec4042539e69a7494bcde5c893c6dffcbf1b6 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 19 Feb 2018 19:09:12 +0200 Subject: Working on developer module.. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../ViewModels/DbTableViewModel.cs | 8 +- .../DeveloperModule.cs | 2 +- .../Navigation/DeveloperNavigationManager.cs | 2 +- .../Tango.MachineStudio.Developer.csproj | 6 +- .../ViewModelLocator.cs | 2 +- .../ViewModels/MainViewVM.cs | 76 ++-- .../Views/DeveloperView.xaml | 414 --------------------- .../Views/DeveloperView.xaml.cs | 31 -- .../Views/JobView.xaml | 2 +- .../Views/MachineJobSelectionView.xaml | 30 +- .../Views/MainView.xaml | 414 +++++++++++++++++++++ .../Views/MainView.xaml.cs | 44 +++ .../ViewModels/MainViewVM.cs | 12 +- .../Observables/IObservableEntity.cs | 14 +- .../Observables/ObservableEntity.cs | 27 +- .../Observables/Partials/Configuration.cs | 4 +- .../Observables/Partials/Machine.cs | 10 +- .../Observables/Partials/MachineVersion.cs | 6 +- .../Observables/Partials/Segment.cs | 2 +- .../Tango.Integration/Printing/Job.cs | 4 +- .../Tango.Integration/Printing/Segment.cs | 2 +- .../Tango.SharedUI/Controls/MultiSelectDataGrid.cs | 11 +- .../DateTimeUTCToShortDateTimeConverter.cs | 11 +- .../Tango.UnitTesting/ColorLib_TST.cs | 4 +- 26 files changed, 595 insertions(+), 543 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 24b24abfc..ff1de2760 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 54bf7ba0d..661db54aa 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs index a05df573c..62f768b9d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -158,7 +158,7 @@ namespace Tango.MachineStudio.DB.ViewModels { try { - await SelectedEntity.DeleteAsync(); + await SelectedEntity.DeleteAsync(Adapter.Context); } catch (Exception ex) { @@ -220,18 +220,18 @@ namespace Tango.MachineStudio.DB.ViewModels { if (mode == DialogOpenMode.Adding) { - entity.Attach(); + entity.Attach(Adapter.Context); } try { - await entity.SaveAsync(); + await entity.SaveAsync(Adapter.Context); } catch (DbUpdateException ex) { if (mode == DialogOpenMode.Adding) { - entity.Detach(); + entity.Detach(Adapter.Context); } Adapter.Invalidate(); _notification.ShowError("Could not save entity." + Environment.NewLine + ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : ex.InnerException.Message); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index 17c08adc4..6cdda4bc8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -36,7 +36,7 @@ namespace Tango.MachineStudio.Developer /// /// Gets the module entry point view. /// - public override FrameworkElement MainView => new DeveloperView(); + public override FrameworkElement MainView => new MainView(); /// /// Gets the permission required to see and load this module. diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs index 297caf2dc..5be50231d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs @@ -12,7 +12,7 @@ namespace Tango.MachineStudio.Developer.Navigation { public void NavigateTo(DeveloperNavigationView view) { - DeveloperView.Instance.TransitionControl.AutoNavigate(view.ToString()); + MainView.Instance.TransitionControl.AutoNavigate(view.ToString()); } } } 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 3253fc551..91a9602be 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 @@ -124,8 +124,8 @@ - - DeveloperView.xaml + + MainView.xaml @@ -148,7 +148,7 @@ MSBuild:Compile Designer - + Designer MSBuild:Compile 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 b397f1912..c5ed7d385 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Developer { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - //SimpleIoc.Default.Register(() => MainView.Self); + SimpleIoc.Default.Register(() => MainView.Instance); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); } 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 199183c12..62b742390 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 @@ -45,7 +45,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Represents the developer module main view, view model. /// /// - public class MainViewVM : ViewModel, IShutdownRequestBlocker + public class MainViewVM : ViewModel, IShutdownRequestBlocker, IShutdownListener { private static object _syncLock = new object(); @@ -464,6 +464,14 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + private String _jobFilter; + + public String JobFilter + { + get { return _jobFilter; } + set { _jobFilter = value; RaisePropertyChangedAuto(); OnJobFilterChanged(); } + } + #endregion #region Commands @@ -575,7 +583,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Initializes a new instance of the class. /// - public MainViewVM() : base() + public MainViewVM(IMainView view) : base(view, true) { } @@ -586,16 +594,22 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this() + public MainViewVM(IMainView view, IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view) { - using (var db = ObservablesContext.CreateDefault()) + SelectedJobs = new ObservableCollection(); + + _machineDBContext = ObservablesContext.CreateDefault(); + + if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) { - Machines = db.Machines.ToObservableCollection(); + SelectedMachine = _machineDBContext.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); } - _machineDBContext = ObservablesContext.CreateDefault(); + if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) + { + SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); + } - SelectedJobs = new ObservableCollection(); _authentication = authentication; @@ -748,7 +762,6 @@ namespace Tango.MachineStudio.Developer.ViewModels ReloadMachine(); JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); - InvalidateLiquidFactorsAndProcessTables(); } } @@ -757,7 +770,8 @@ namespace Tango.MachineStudio.Developer.ViewModels _machineDBContext.Dispose(); _machineDBContext = ObservablesContext.CreateDefault(); _machineDBContext.Configuration.LazyLoadingEnabled = true; - _selectedMachine = _machineDBContext.Machines.SingleOrDefault(x => x.Guid == _selectedMachine.Guid); + Machines = _machineDBContext.Machines.ToObservableCollection(); + _selectedMachine = Machines.SingleOrDefault(x => x.Guid == _selectedMachine.Guid); RaisePropertyChanged(nameof(SelectedMachine)); JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); @@ -768,6 +782,17 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods + private void OnJobFilterChanged() + { + JobsCollectionView.Filter = (job) => + { + Job j = job as Job; + return String.IsNullOrWhiteSpace(JobFilter) + || + j.Name.ToLower().Contains(JobFilter.ToLower()); + }; + } + private void OnActiveJobChanged() { if (ActiveJob != null) @@ -998,7 +1023,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { using (_notification.PushTaskItem("Saving Liquid Factors...")) { - await SelectedRML.SaveAsync(); + await SelectedRML.SaveAsync(_dbJobContext); InvalidateLiquidFactorsAndProcessTables(); } } @@ -1053,7 +1078,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } SelectedRML.ProcessParametersTablesGroups.Add(group); - await SelectedRML.SaveAsync(); + await SelectedRML.SaveAsync(_dbJobContext); InvalidateLiquidFactorsAndProcessTables(); } @@ -1398,30 +1423,27 @@ namespace Tango.MachineStudio.Developer.ViewModels return Task.FromResult(false); } - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = ActiveJob != null ? ActiveJob.Guid : null; - return Task.FromResult(true); } #endregion - #region IMainView + #region IShutdownListener + + public void OnShuttingDown() + { + SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + } - //protected override void OnViewAttached() - //{ - // base.OnViewAttached(); + #endregion - // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) - // //{ - // // SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); - // //} + #region IMainView - // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) - // //{ - // // ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); - // //} - //} + protected override void OnViewAttached() + { + base.OnViewAttached(); + } #endregion } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml deleted file mode 100644 index 276f6c99a..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml +++ /dev/null @@ -1,414 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Transparent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Completed Successfully - - - - - - - - - - - - - - - - - - - - - - - Job Failed To Complete - - - - - - - - - - - - - - - - - - - - - - - - - Job Aborted By User - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs deleted file mode 100644 index dfa7a2441..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Developer.Views -{ - /// - /// Interaction logic for DeveloperView.xaml - /// - public partial class DeveloperView : UserControl - { - public static DeveloperView Instance { get; set; } - - public DeveloperView() - { - InitializeComponent(); - Instance = this; - } - } -} 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 580e2438b..4467b1f28 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 @@ -852,7 +852,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Job Completed Successfully + + + + + + + + + + + + + + + + + + + + + + + Job Failed To Complete + + + + + + + + + + + + + + + + + + + + + + + + + Job Aborted By User + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs new file mode 100644 index 000000000..ab181e8dc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Developer.Views +{ + /// + /// Interaction logic for DeveloperView.xaml + /// + public partial class MainView : UserControl, IMainView + { + private bool _loaded; + public static MainView Instance { get; set; } + + public MainView() + { + InitializeComponent(); + Instance = this; + + Loaded += (x, y) => + { + if (!_loaded) + { + _loaded = true; + ViewAttached?.Invoke(this, this); + } + }; + } + + public event EventHandler ViewAttached; + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index cedbcf9a6..6fbd5852d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -529,7 +529,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels Configuration = Configuration, Machine = Machine, }); - await Machine.SaveAsync(); + await Machine.SaveAsync(Adapter.Context); Machine = Adapter.Machines.SingleOrDefault(x => x.Guid == Machine.Guid); Configuration = Machine.Configuration.CloneConfiguration(); @@ -558,12 +558,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } else { - machine.Configuration.DefferedDelete(); + machine.Configuration.DefferedDelete(Adapter.Context); } machine.Configuration = Configuration; - await machine.SaveAsync(); + await machine.SaveAsync(Adapter.Context); Machine = Adapter.Machines.SingleOrDefault(x => x.Guid == machine.Guid); Configuration = Machine.Configuration.CloneConfiguration(); @@ -624,7 +624,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { vm.SelectedVersion.DefaultConfiguration = Configuration.CloneConfiguration(); vm.SelectedVersion.DefaultConfigurationGuid = vm.SelectedVersion.DefaultConfiguration.Guid; - await vm.SelectedVersion.SaveAsync(); + await vm.SelectedVersion.SaveAsync(Adapter.Context); } else { @@ -634,7 +634,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels newVersion.DefaultConfiguration = Configuration.CloneConfiguration(); newVersion.DefaultConfigurationGuid = newVersion.DefaultConfiguration.Guid; - await newVersion.SaveAsync(); + await newVersion.SaveAsync(Adapter.Context); } } } @@ -662,7 +662,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (module is MachineDesignerModule) { - SelectedMachine = args as Machine; + SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == (args as Machine).Guid); } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs index cd046ac2b..600258b84 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs @@ -43,37 +43,37 @@ namespace Tango.Integration.Observables /// /// Saves the changes on this entity to database. /// - void Save(ObservablesContext context = null); + void Save(ObservablesContext context); /// /// Attaches this observable to the proper DbSet. /// - void Attach(ObservablesContext context = null); + void Attach(ObservablesContext context); /// /// Detaches this observable from the proper DbSet. /// - void Detach(ObservablesContext context = null); + void Detach(ObservablesContext context); /// /// Saves the changes on this entity to database asynchronously. /// /// - Task SaveAsync(ObservablesContext context = null); + Task SaveAsync(ObservablesContext context); /// /// Deletes this entity from the database. /// - void Delete(ObservablesContext context = null); + void Delete(ObservablesContext context); /// /// Deletes this entity without saving changes to data base. /// - void DefferedDelete(ObservablesContext context = null); + void DefferedDelete(ObservablesContext context); /// /// Deletes this entity from the database. /// - Task DeleteAsync(ObservablesContext context = null); + Task DeleteAsync(ObservablesContext context); } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs index d379945f3..3f05dffd3 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs @@ -114,9 +114,9 @@ namespace Tango.Integration.Observables /// /// Saves the changes on this entity to database. /// - public virtual void Save(ObservablesContext context = null) + public virtual void Save(ObservablesContext context) { - if (context == null) + if (context == ObservablesEntitiesAdapter.Instance.Context) { ObservablesEntitiesAdapter.Instance.SaveChanges(); } @@ -130,7 +130,7 @@ namespace Tango.Integration.Observables /// /// Attaches this entity to the proper DbSet. /// - public virtual void Attach(ObservablesContext context = null) + public virtual void Attach(ObservablesContext context) { GetDbSet(context).Add(this as T); } @@ -138,7 +138,7 @@ namespace Tango.Integration.Observables /// /// Detaches this observable from the proper DbSet. /// - public virtual void Detach(ObservablesContext context = null) + public virtual void Detach(ObservablesContext context) { GetDbSet(context).Remove(this as T); } @@ -147,7 +147,7 @@ namespace Tango.Integration.Observables /// Saves the changes on this entity to database asynchronously. /// /// - public Task SaveAsync(ObservablesContext context = null) + public Task SaveAsync(ObservablesContext context) { return Task.Factory.StartNew(() => { @@ -167,26 +167,26 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database /// - public virtual void Delete(ObservablesContext context = null) + public virtual void Delete(ObservablesContext context) { var delProp = this.GetType().GetProperty("Deleted"); if (delProp != null) { delProp.SetValue(this, true); - Save(); + Save(context); } else { GetDbSet(context).Remove(this as T); - Save(); + Save(context); } } /// /// Deletes this entity without saving changes to data base. /// - public virtual void DefferedDelete(ObservablesContext context = null) + public virtual void DefferedDelete(ObservablesContext context) { GetDbSet(context).Remove(this as T); } @@ -194,7 +194,7 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database /// - public Task DeleteAsync(ObservablesContext context = null) + public Task DeleteAsync(ObservablesContext context) { return Task.Factory.StartNew(() => { @@ -204,8 +204,6 @@ namespace Tango.Integration.Observables public DbSet GetDbSet(ObservablesContext context) { - context = GetContextOrDefault(context); - String tabelName = this.GetType().Name.PluralizeMVC(); var p = typeof(ObservablesContext).GetProperty(tabelName); if (p != null) @@ -268,11 +266,6 @@ namespace Tango.Integration.Observables return me == other; } - private ObservablesContext GetContextOrDefault(ObservablesContext context) - { - return context != null ? context : ObservablesEntitiesAdapter.Instance.Context; - } - #region Operator Overloading //public static bool operator ==(ObservableEntity observable1, ObservableEntity observable2) diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs index fa489ded2..a5ddb0d14 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs @@ -8,7 +8,7 @@ namespace Tango.Integration.Observables { public partial class Configuration { - public override void DefferedDelete(ObservablesContext context = null) + public override void DefferedDelete(ObservablesContext context) { IdsPacks.ToList().ForEach(x => x.DefferedDelete(context)); var machine_configurations = context.MachinesConfigurations.Where(x => x.Configuration == this); @@ -17,7 +17,7 @@ namespace Tango.Integration.Observables IdsPacks.Clear(); } - public override void Delete(ObservablesContext context = null) + public override void Delete(ObservablesContext context) { IdsPacks.ToList().ForEach(x => x.DefferedDelete(context)); var machine_configurations = context.MachinesConfigurations.Where(x => x.Configuration == this); diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs index 1669230d6..3026ff168 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs @@ -12,18 +12,18 @@ namespace Tango.Integration.Observables /// /// Deletes this entity from the database /// - public override void Delete(ObservablesContext context = null) + public override void Delete(ObservablesContext context) { foreach (var machine_config in MachinesConfigurations) { - machine_config.Delete(); - machine_config.Configuration.Delete(); + machine_config.Delete(context); + machine_config.Configuration.Delete(context); } - base.Delete(); + base.Delete(context); } - public override void Save(ObservablesContext context = null) + public override void Save(ObservablesContext context) { foreach (var job in Jobs) { diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs index 4bd242c1b..73a6a8a4f 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs @@ -8,10 +8,10 @@ namespace Tango.Integration.Observables { public partial class MachineVersion { - public override void Delete(ObservablesContext context = null) + public override void Delete(ObservablesContext context) { - this.DefaultConfiguration.Delete(); - base.Delete(); + this.DefaultConfiguration.Delete(context); + base.Delete(context); } } } diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs index 71a15b90c..eda1613ed 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Segment.cs @@ -10,7 +10,7 @@ namespace Tango.Integration.Observables { public partial class Segment { - public override void Save(ObservablesContext context = null) + public override void Save(ObservablesContext context) { for (int i = 0; i < BrushStops.Count; i++) { diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs index 29155be53..b80af84b8 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs @@ -120,7 +120,7 @@ namespace Tango.Integration.Observables /// /// Saves the changes on this entity to database. /// - public override void Save(ObservablesContext context = null) + public override void Save(ObservablesContext context) { for (int i = 0; i < Segments.Count; i++) { @@ -146,7 +146,7 @@ namespace Tango.Integration.Observables return cloned; } - public override void DefferedDelete(ObservablesContext context = null) + public override void DefferedDelete(ObservablesContext context) { Segments.ToList().ForEach(x => x.DefferedDelete(context)); Segments.Clear(); diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs b/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs index d3e50ec37..999ef247b 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs @@ -68,7 +68,7 @@ namespace Tango.Integration.Observables return cloned; } - public override void DefferedDelete(ObservablesContext context = null) + public override void DefferedDelete(ObservablesContext context) { BrushStops.ToList().ForEach(x => x.DefferedDelete(context)); BrushStops.Clear(); diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs index 0f3032e01..8f54a2ce4 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs @@ -26,11 +26,14 @@ namespace Tango.SharedUI.Controls { base.OnSelectionChanged(e); - SelectedItemsList.Clear(); - - foreach (var item in SelectedItems) + if (SelectedItemsList != null) { - SelectedItemsList.Add(item); + SelectedItemsList.Clear(); + + foreach (var item in SelectedItems) + { + SelectedItemsList.Add(item); + } } } } diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUTCToShortDateTimeConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUTCToShortDateTimeConverter.cs index 7c51139e0..5e02ec718 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUTCToShortDateTimeConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUTCToShortDateTimeConverter.cs @@ -12,9 +12,16 @@ namespace Tango.SharedUI.Converters { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - DateTime date = (DateTime)value; + if (value != null) + { + DateTime date = (DateTime)value; - return date.ToLocalTime().ToString("MM/dd/yy HH:mm"); + return date.ToLocalTime().ToString("MM/dd/yy HH:mm"); + } + else + { + return null; + } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Software/Visual_Studio/Tango.UnitTesting/ColorLib_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/ColorLib_TST.cs index f4940cdac..af875547f 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/ColorLib_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/ColorLib_TST.cs @@ -53,7 +53,7 @@ namespace Tango.UnitTesting Assert.IsNotNull(rml); - List factors = configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == RML.Guid).ToList(); + List factors = configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == rml.Guid).ToList(); foreach (var idsPack in configuration.IdsPacks.OrderBy(x => x.PackIndex)) { @@ -109,7 +109,7 @@ namespace Tango.UnitTesting Assert.IsNotNull(rml); - List factors = configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == RML.Guid).ToList(); + List factors = configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == rml.Guid).ToList(); foreach (var idsPack in configuration.IdsPacks.OrderBy(x => x.PackIndex)) { -- cgit v1.3.1