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/MachineStudio/Modules/Tango.MachineStudio.Developer | |
| 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/MachineStudio/Modules/Tango.MachineStudio.Developer')
5 files changed, 180 insertions, 7 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(); + } } } |
