From a0e25846735104f09a18647220db59804977e73a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 8 Apr 2018 17:48:58 +0300 Subject: Fixed issue with "Application Started" event. Fixed issue with segment indexing after emb import. --- .../ViewModels/MainViewVM.cs | 2 +- .../EventLogging/DefaultEventLogger.cs | 29 +++++++++++-------- .../Tango.MachineStudio.UI/App.xaml.cs | 6 ---- .../ViewModels/LoadingViewVM.cs | 4 +++ .../Tango.BL/EntitiesExtensions/Machine.cs | 2 +- .../Tango.BL/EntitiesExtensions/MediaColor.cs | 33 ++++++++++++++++++++++ .../Tango.BL/ExtensionMethods/MediaColor.cs | 33 ---------------------- Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 2 +- 8 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs delete mode 100644 Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs (limited to 'Software/Visual_Studio') 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 63994f592..7891f96b7 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 @@ -1752,7 +1752,7 @@ namespace Tango.MachineStudio.Developer.ViewModels segment.Length = totalLength; segment.Name = "Embroidery Segment"; - segment.SegmentIndex = vm.Paths.IndexOf(path) + 2; + segment.SegmentIndex = vm.Paths.IndexOf(path); if (path.Brush is SolidColorBrush) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs index 91aa049e9..f3ae1002b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs @@ -78,21 +78,28 @@ namespace Tango.MachineStudio.Common.EventLogging { if (!_isInitialized) { - _db = ObservablesContext.CreateDefault(); - _db.Configuration.LazyLoadingEnabled = false; + try + { + _db = ObservablesContext.CreateDefault(); + _db.Configuration.LazyLoadingEnabled = false; - _db.ActionTypes.ToList(); - _db.EventTypesActions.ToList(); - _db.EventTypesCategories.ToList(); - _db.EventTypesGroups.ToList(); - _db.EventTypes.ToList(); + _db.ActionTypes.ToList(); + _db.EventTypesActions.ToList(); + _db.EventTypesCategories.ToList(); + _db.EventTypesGroups.ToList(); + _db.EventTypes.ToList(); - foreach (var type in _db.EventTypes) + foreach (var type in _db.EventTypes) + { + _eventTypesGuids.Add((EventTypes)type.Code, type); + } + + _isInitialized = true; + } + catch { - _eventTypesGuids.Add((EventTypes)type.Code, type); + _isInitialized = false; } - - _isInitialized = true; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index 8b3233ab1..76c7b3e58 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -50,12 +50,6 @@ namespace Tango.MachineStudio.UI exceptionTrapper = new WpfGlobalExceptionTrapper(); exceptionTrapper.Initialize(this); exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed; - - var eventLogger = ServiceLocator.Current.GetInstance(); - if (eventLogger != null) - { - eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); - } } #region Global Exception Trapping diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 5776cadc2..512341f7e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -14,6 +14,7 @@ using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; using Tango.BL; using Tango.MachineStudio.Common.EventLogging; +using Tango.BL.Enumerations; namespace Tango.MachineStudio.UI.ViewModels { @@ -66,6 +67,9 @@ namespace Tango.MachineStudio.UI.ViewModels try { ObservablesEntitiesAdapter.Instance.Initialize(); + + _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + InvokeUI(() => { _studioModuleLoader.LoadModules(); diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs index e00715795..ff32ba02f 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs @@ -31,7 +31,7 @@ namespace Tango.BL.Entities foreach (var segment in job.Segments) { - segment.SegmentIndex = job.Segments.IndexOf(segment); + //segment.SegmentIndex = job.Segments.IndexOf(segment); foreach (var stop in segment.BrushStops) { diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs new file mode 100644 index 000000000..e4a312775 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs @@ -0,0 +1,33 @@ +using ColorMine.ColorSpaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.BL.Entities +{ + public partial class MediaColor + { + private Color _color; + + public Color Color + { + get { return _color; } + set { _color = value; RaisePropertyChangedAuto(); } + } + + protected override void RaisePropertyChanged(string propName) + { + base.RaisePropertyChanged(propName); + + if (propName == nameof(L) || propName == nameof(A) || propName == nameof(B)) + { + Lab lab = new Lab(L, A, B); + var rgb = lab.To(); + Color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs b/Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs deleted file mode 100644 index e4a312775..000000000 --- a/Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs +++ /dev/null @@ -1,33 +0,0 @@ -using ColorMine.ColorSpaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media; - -namespace Tango.BL.Entities -{ - public partial class MediaColor - { - private Color _color; - - public Color Color - { - get { return _color; } - set { _color = value; RaisePropertyChangedAuto(); } - } - - protected override void RaisePropertyChanged(string propName) - { - base.RaisePropertyChanged(propName); - - if (propName == nameof(L) || propName == nameof(A) || propName == nameof(B)) - { - Lab lab = new Lab(L, A, B); - var rgb = lab.To(); - Color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); - } - } - } -} diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index d56324d8f..04c1b0a6b 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -97,7 +97,7 @@ - + -- cgit v1.3.1