diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-16 20:01:10 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-16 20:01:10 +0300 |
| commit | 69bbedacee151090d5d0b6665b3a1614e65f1997 (patch) | |
| tree | 9f4197b563edb7153de1e0077d0b937686c29d30 /Software/Visual_Studio | |
| parent | 13e34402f91fae6229b2d9719ddb48ced1d37fbf (diff) | |
| download | Tango-69bbedacee151090d5d0b6665b3a1614e65f1997.tar.gz Tango-69bbedacee151090d5d0b6665b3a1614e65f1997.zip | |
Added color conversion to Machine Studio.
Fixed issue with segments cloning.
Diffstat (limited to 'Software/Visual_Studio')
14 files changed, 211 insertions, 13 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png Binary files differnew file mode 100644 index 000000000..6c089d44e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png 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 f8f121dff..46396c791 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 @@ -224,6 +224,10 @@ <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project> <Name>Tango.DragAndDrop</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Hive\Tango.Hive.csproj"> + <Project>{942134ac-6ea2-4500-8f22-0f739b70a05f}</Project> + <Name>Tango.Hive</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> @@ -349,5 +353,8 @@ <ItemGroup> <Resource Include="Images\repeat.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\arrow-long-right.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file 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 b4e588700..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); } @@ -1836,7 +1937,5 @@ namespace Tango.MachineStudio.Developer.ViewModels } #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 b4deb72a9..e350f966b 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 @@ -5,7 +5,10 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorConversion="clr-namespace:Tango.BL.ColorConversion;assembly=Tango.BL" + xmlns:hive="clr-namespace:Tango.Hive;assembly=Tango.Hive" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:techViews="clr-namespace:Tango.MachineStudio.Technician.Views;assembly=Tango.MachineStudio.Technician" @@ -66,6 +69,7 @@ <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> <converters:IsNotConverter x:Key="IsNotConverter" /> + <converters:ObjectToObjectTypeConverter x:Key="ObjectToObjectTypeConverter" /> <ObjectDataProvider x:Key="dispenserDivisions" MethodName="GetValues" ObjectType="{x:Type sys:Enum}"> @@ -136,7 +140,7 @@ <Setter.Value> <ControlTemplate> <Grid> - <ToggleButton Cursor="Hand" x:Name="PopupButton" BorderThickness="0" Height="30" Background="Transparent" Foreground="{StaticResource AccentColorBrush}" VerticalAlignment="Center" Margin="30 0 0 0" IsChecked="{Binding ElementName=Popup, Path=IsOpen}"> + <ToggleButton Cursor="Hand" x:Name="PopupButton" Checked="PopupButton_Checked" Unchecked="PopupButton_Unchecked" BorderThickness="0" Height="30" Background="Transparent" Foreground="{StaticResource AccentColorBrush}" VerticalAlignment="Center" Margin="30 0 0 0" IsChecked="{Binding ElementName=Popup, Path=IsOpen}"> <ToggleButton.Style> <Style TargetType="ToggleButton" BasedOn="{StaticResource emptyToggleButton}"> <Style.Triggers> @@ -163,7 +167,47 @@ </Border.Effect> <Grid> <Grid Margin="10"> - <commonControls:HiveColorPickerControl SelectedHiveColorChanged="HiveColorPickerControl_SelectedColorChanged" SelectedColor="{Binding Color,Mode=OneWay}" SelectedHiveColor="{Binding Color,Mode=OneWayToSource}" DemoMode="True" /> + <DockPanel> + <DockPanel> + <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center">SOURCE</TextBlock> + <Viewbox Width="300" Height="180" VerticalAlignment="Center" Stretch="Fill"> + <colorPicker:ColorCanvas SelectedColor="{Binding Color,Mode=TwoWay}" SelectedColorChanged="ColorCanvas_SelectedColorChanged" Background="Transparent" BorderThickness="0" Height="150" Width="230" ></colorPicker:ColorCanvas> + </Viewbox> + </DockPanel> + <Image DockPanel.Dock="Left" Source="../Images/arrow-long-right.png" VerticalAlignment="Center" Width="30" Margin="10 0"></Image> + + <DockPanel> + <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center">SUGGESTIONS</TextBlock> + <hive:HexList VerticalAlignment="Center" Margin="0 10 0 0" Width="220" Height="270" UseHexItemHasContainer="True" Grid.Column="2" Grid.Row="1" RowCount="6" ColumnCount="5" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.HiveSuggestions}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.SelectedSuggestion,Mode=TwoWay}"> + <hive:HexList.ItemContainerStyle> + <Style TargetType="hive:HexItem" BasedOn="{StaticResource {x:Type hive:HexItem}}"> + <Setter Property="Background" Value="{Binding Brush}"></Setter> + <Setter Property="Grid.Column" Value="0"></Setter> + <Setter Property="Grid.Row" Value="0"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="BorderThickness" Value="1"></Setter> + + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=DataContext,Converter={StaticResource ObjectToObjectTypeConverter}}" Value="{x:Type colorConversion:ColorConversionSuggestion}"> + <Setter Property="Grid.Column" Value="{Binding Column}"></Setter> + <Setter Property="Grid.Row" Value="{Binding Row}"></Setter> + <Setter Property="Background" Value="{Binding Brush}"></Setter> + </DataTrigger> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="BorderThickness" Value="2"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </hive:HexList.ItemContainerStyle> + + <hive:HexList.ItemTemplate> + <DataTemplate> + + </DataTemplate> + </hive:HexList.ItemTemplate> + </hive:HexList> + </DockPanel> + </DockPanel> </Grid> </Grid> </Border> 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 b48e91f31..bb17a502d 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 @@ -242,5 +242,28 @@ namespace Tango.MachineStudio.Developer.Views editor.ParameterizedObject = draggedItem.ParameterizedObject; } } + + private void PopupButton_Checked(object sender, RoutedEventArgs e) + { + _vm.OnHivePopupOpened(); + } + + private void BrushPicker_ColorChanged(object sender, BrushPicker.ColorChangedEventArgs e) + { + + } + + private void ColorCanvas_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color?> e) + { + if (e.NewValue.HasValue) + { + _vm.OnSelectedBrushColorChanged((Color)e.NewValue); + } + } + + private void PopupButton_Unchecked(object sender, RoutedEventArgs e) + { + _vm.OnHivePopupClosed(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs index 2bb96c1e5..2b12b1670 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs @@ -173,6 +173,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedLog != null) { _notification.ShowModalDialog<LogDetailsViewVM, ApplicationLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); + SelectedLog = null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs index ba18cbdb1..1895dd230 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs @@ -175,6 +175,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedLog != null) { _notification.ShowModalDialog<LogDetailsViewVM, EmbeddedLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); + SelectedLog = null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs index c4f391c55..98fcf12db 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -181,6 +181,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted) { _notification.ShowModalDialog<EventDetailsViewVM, EventDetailsView>(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { }); + SelectedEvent = null; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 77fad1fc6..96715dc20 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -15,6 +15,8 @@ namespace Tango.MachineStudio.Common /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> public abstract class StudioViewModelInternal : ViewModel, IStudioViewModel { + public bool IsVisible { get; private set; } + /// <summary> /// Gets or sets a value indicating whether this view model studio module is currently loaded. /// </summary> @@ -42,6 +44,7 @@ namespace Tango.MachineStudio.Common /// </summary> public virtual void OnNavigatedFrom() { + IsVisible = false; IsModuleLoaded = false; } @@ -50,6 +53,7 @@ namespace Tango.MachineStudio.Common /// </summary> public virtual void OnNavigatedTo() { + IsVisible = true; IsModuleLoaded = true; } @@ -88,6 +92,8 @@ namespace Tango.MachineStudio.Common /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> public abstract class StudioViewModel<Module> : ViewModel, IStudioViewModel where Module : IStudioModule { + public bool IsVisible { get; private set; } + /// <summary> /// Gets or sets a value indicating whether this view model studio module is currently loaded. /// </summary> @@ -115,6 +121,7 @@ namespace Tango.MachineStudio.Common /// </summary> public virtual void OnNavigatedFrom() { + IsVisible = false; IsModuleLoaded = false; } @@ -123,6 +130,7 @@ namespace Tango.MachineStudio.Common /// </summary> public virtual void OnNavigatedTo() { + IsVisible = true; IsModuleLoaded = true; } @@ -149,7 +157,7 @@ namespace Tango.MachineStudio.Common /// </summary> public virtual void OnApplicationStarted() { - + } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index a112fbafb..4e5321cc7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Mon 07/16/2018 15:39:26.63 +Mon 07/16/2018 19:59:53.31 diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs index e5144386a..29e517695 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs @@ -267,6 +267,11 @@ namespace Tango.BL.Entities cloned.WindingMethod = WindingMethod; cloned.Segments = Segments.Select(x => x.Clone(cloned)).ToObservableCollection(); + foreach (var segment in cloned.Segments) + { + segment.JobGuid = cloned.Guid; + segment.Job = cloned; + } return cloned; } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs index 4b7c11272..634047f24 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs @@ -137,6 +137,12 @@ namespace Tango.BL.Entities cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToObservableCollection(); + foreach (var stop in cloned.BrushStops) + { + stop.SegmentGuid = cloned.Guid; + stop.Segment = cloned; + } + return cloned; } diff --git a/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs b/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs index 5c834dcdf..d3bd2e372 100644 --- a/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs +++ b/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs @@ -553,10 +553,13 @@ namespace Tango.BrushPicker c.G = color.G; c.B = color.B; + if (e.OldValue != e.NewValue) + { + c.RaiseColorChangedEvent((Color)e.NewValue); + } + c._RGBSetInternally = false; } - - c.RaiseColorChangedEvent((Color)e.NewValue); } } diff --git a/Software/Visual_Studio/Versioning/MachineStudio.cs b/Software/Visual_Studio/Versioning/MachineStudio.cs index 072b392db..6aac33a9c 100644 --- a/Software/Visual_Studio/Versioning/MachineStudio.cs +++ b/Software/Visual_Studio/Versioning/MachineStudio.cs @@ -9,5 +9,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © Twine LTD 2017")] [assembly: AssemblyTrademark("Twine LTD")] -[assembly: AssemblyVersion("1.0.0.14")] -[assembly: AssemblyFileVersion("1.0.0.14")] +[assembly: AssemblyVersion("1.0.0.15")] +[assembly: AssemblyFileVersion("1.0.0.15")] |
