diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-07-17 15:44:17 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-07-17 15:44:17 +0300 |
| commit | 316552019c43e27114669a7f3e6138902c9d8220 (patch) | |
| tree | 8b0f8ff0645f721718e60ff1cc9c0c76f2537ebc /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer | |
| parent | af99264e5ca64bcb0173f2586c2295fc0cb21d75 (diff) | |
| parent | f4aad3bc7f9d4c457805a233f969938ef341b22c (diff) | |
| download | Tango-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')
6 files changed, 188 insertions, 14 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 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 - - } } 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 fc62c0128..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> @@ -1085,7 +1129,7 @@ <Grid Margin="0 -18 0 0"> <Border VerticalAlignment="Center" Height="55" Margin="30 0 40 0" ClipToBounds="False"> <Grid ClipToBounds="False"> - <ItemsControl x:Name="jobBrushList" ClipToBounds="False"> + <ItemsControl x:Name="jobBrushList" ClipToBounds="False" Margin="40 0 50 0"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" ClipToBounds="False"></StackPanel> @@ -1129,7 +1173,7 @@ </ItemsControl.ItemTemplate> </ItemsControl> - <StackPanel Margin="-20 -5 0 0" HorizontalAlignment="Left"> + <StackPanel Margin="-30 -5 0 0" HorizontalAlignment="Left"> <TextBlock FontSize="12" Foreground="Black"> <Run Text="0"></Run> <Run Foreground="Gray" FontSize="10" Text="m"></Run> @@ -1149,7 +1193,7 @@ </materialDesign:PackIcon> </StackPanel> - <Border BorderBrush="Gainsboro" BorderThickness="1" VerticalAlignment="Bottom" Height="20"> + <Border BorderBrush="Gainsboro" BorderThickness="1" VerticalAlignment="Bottom" Height="20" Margin="40 0 50 0"> </Border> </Grid> 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.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index 2ece5c76b..fd3b2289d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -110,7 +110,7 @@ <Border Margin="0 10 0 0" VerticalAlignment="Bottom" Width="1200" BorderBrush="#404040" BorderThickness="0" ClipToBounds="False"> <Grid ClipToBounds="False" > - <ItemsControl ClipToBounds="False" x:Name="runningJobBrushList" ItemsSource="{Binding RunningJobSegments}"> + <ItemsControl ClipToBounds="False" x:Name="runningJobBrushList" ItemsSource="{Binding RunningJobSegments}" Margin="0 0 60 0"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" ClipToBounds="False"></StackPanel> @@ -179,7 +179,7 @@ </Canvas> </StackPanel> - <Rectangle HorizontalAlignment="Right" Stroke="White" Margin="0 35 0 25"></Rectangle> + <Rectangle HorizontalAlignment="Right" Stroke="White" Margin="0 35 0 25" ></Rectangle> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> @@ -195,7 +195,7 @@ </materialDesign:PackIcon> </StackPanel> - <StackPanel Margin="0 -5 -40 0" HorizontalAlignment="Right"> + <StackPanel Margin="0 -5 -70 0" HorizontalAlignment="Right"> <TextBlock FontSize="14"> <Run Text="{Binding RunningJob.Length,Mode=OneWay,StringFormat=N2}"></Run> <Run FontSize="13" Text="m"></Run> @@ -207,7 +207,7 @@ </materialDesign:PackIcon> </StackPanel> - <Border BorderBrush="#404040" BorderThickness="1" VerticalAlignment="Center" Height="30" Margin="0 11 0 0"> + <Border BorderBrush="#404040" BorderThickness="1" VerticalAlignment="Center" Height="30" Margin="0 11 60 0"> </Border> |
