aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-07-17 15:44:17 +0300
committerAvi Levkovich <avi@twine-s.com>2018-07-17 15:44:17 +0300
commit316552019c43e27114669a7f3e6138902c9d8220 (patch)
tree8b0f8ff0645f721718e60ff1cc9c0c76f2537ebc /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
parentaf99264e5ca64bcb0173f2586c2295fc0cb21d75 (diff)
parentf4aad3bc7f9d4c457805a233f969938ef341b22c (diff)
downloadTango-316552019c43e27114669a7f3e6138902c9d8220.tar.gz
Tango-316552019c43e27114669a7f3e6138902c9d8220.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs110
1 files changed, 105 insertions, 5 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index dacbc89b1..ab74fcca8 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
@@ -38,6 +38,7 @@ using System.Threading;
using Tango.SharedUI.Helpers;
using Tango.Core.DI;
using Tango.MachineStudio.Common;
+using Tango.BL.ColorConversion;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -64,9 +65,32 @@ namespace Tango.MachineStudio.Developer.ViewModels
private DataCapture.ViewModels.MainViewVM _dataCaptureVM;
private bool _isRecording;
private DeveloperModuleSettings _settings;
+ private Thread _colorConversionThread;
+ private bool _hiveOpened;
+ private bool _color_changed_from_hive;
#region Properties
+ private List<ColorConversionSuggestion> _hiveSuggestions;
+ /// <summary>
+ /// Gets or sets the hive suggestions.
+ /// </summary>
+ public List<ColorConversionSuggestion> HiveSuggestions
+ {
+ get { return _hiveSuggestions; }
+ set { _hiveSuggestions = value; RaisePropertyChangedAuto(); }
+ }
+
+ private ColorConversionSuggestion _selectedSuggestion;
+ /// <summary>
+ /// Gets or sets the selected suggestion.
+ /// </summary>
+ public ColorConversionSuggestion SelectedSuggestion
+ {
+ get { return _selectedSuggestion; }
+ set { _selectedSuggestion = value; RaisePropertyChangedAuto(); OnSelectedSuggestionChanged(); }
+ }
+
private RunningJobStatus _runningJobStatus;
/// <summary>
/// Gets or sets the running job status.
@@ -670,6 +694,83 @@ namespace Tango.MachineStudio.Developer.ViewModels
ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
_eventLogger.NewLog += _eventLogger_NewLog;
+
+ _colorConversionThread = new Thread(ColorConversionThreadMethod);
+ _colorConversionThread.IsBackground = true;
+ _colorConversionThread.Start();
+ }
+
+ private void ColorConversionThreadMethod()
+ {
+ while (true)
+ {
+ if (IsVisible && ActiveJob != null)
+ {
+ var stops = ActiveJob.Segments.SelectMany(x => x.BrushStops);
+
+ foreach (var stop in stops)
+ {
+ if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32())
+ {
+ try
+ {
+ var output = TangoColorConverter.GetSuggestions(stop);
+ stop.Red = output.SingleCoordinates.Red;
+ stop.Green = output.SingleCoordinates.Green;
+ stop.Blue = output.SingleCoordinates.Blue;
+ }
+ catch { }
+ }
+ }
+ }
+
+ Thread.Sleep(500);
+ }
+ }
+
+ public void OnHivePopupOpened()
+ {
+ if (SelectedBrushStop != null)
+ {
+ _hiveOpened = true;
+ HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(TangoColorConverter.GetSuggestions(SelectedBrushStop));
+ }
+ }
+
+ private void OnSelectedSuggestionChanged()
+ {
+ if (SelectedSuggestion != null && SelectedBrushStop != null && _hiveOpened)
+ {
+ _color_changed_from_hive = true;
+ SelectedBrushStop.Color = SelectedSuggestion.Color;
+
+ var coords = SelectedSuggestion.Coordinates;
+
+ foreach (var liquid in coords.OutputLiquids)
+ {
+ var liquidVolume = SelectedBrushStop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == liquid.LiquidType.ToInt32());
+
+ if (liquidVolume != null)
+ {
+ liquidVolume.Volume = liquid.Volume;
+ }
+ }
+
+ _color_changed_from_hive = false;
+ }
+ }
+
+ public void OnSelectedBrushColorChanged(Color color)
+ {
+ if (!_color_changed_from_hive && _hiveOpened)
+ {
+ HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(TangoColorConverter.GetSuggestions(SelectedBrushStop));
+ }
+ }
+
+ public void OnHivePopupClosed()
+ {
+ _hiveOpened = false;
}
#endregion
@@ -1045,7 +1146,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
};
- _jobHandler.UnitCompleted += (x, unit) =>
+ _jobHandler.UnitCompleted += (x, unit) =>
{
_speech.SpeakInfo(String.Format("{0} Units Completed.", unit + 1));
_eventLogger.Log(String.Format("{0} Units Completed.", unit + 1));
@@ -1299,7 +1400,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <summary>
/// Saves the active job.
/// </summary>
- private async void SaveActiveJob()
+ private void SaveActiveJob()
{
if (ActiveJob != null)
{
@@ -1310,7 +1411,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
ActiveJob.Rml = SelectedRML;
ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds;
- await ActiveJob.SaveAsync(_activeJobDbContext);
+ _activeJobDbContext.SaveChanges();
ReloadMachine();
SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == ActiveJob.Guid);
}
@@ -1478,6 +1579,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
seg.SegmentIndex = 1;
}
+
ActiveJob.Segments.Add(seg);
SelectedSegment = seg;
AddBrushStop();
@@ -1835,7 +1937,5 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
#endregion
-
-
}
}