diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-11-10 12:46:06 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-11-10 12:46:06 +0200 |
| commit | a74ecac5d1980775f10d719fe8ae93b0695eee72 (patch) | |
| tree | 4c92ccf9f2c57a24d8b8fd24d7db02d42b6f6a61 /Software/Visual_Studio | |
| parent | 3007971a75b018daab6e4dc72bbe6ab1191cff25 (diff) | |
| download | Tango-a74ecac5d1980775f10d719fe8ae93b0695eee72.tar.gz Tango-a74ecac5d1980775f10d719fe8ae93b0695eee72.zip | |
PPC. ColorSelection tool. Added Catalogs.
Related Work Items: #4558
Diffstat (limited to 'Software/Visual_Studio')
18 files changed, 934 insertions, 592 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml index dff1202d8..97a0da9e7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml @@ -11,17 +11,9 @@ d:DesignHeight="500" d:DesignWidth="300"> <Grid> <Grid.RowDefinitions> - <RowDefinition Height="80"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> - - <Grid> - <touch:TouchNavigationLinks FontSize="{StaticResource TangoTitleFontSize}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Filter,Mode=TwoWay}"> - <sys:String>CATALOG</sys:String> - <sys:String>RECENT</sys:String> - </touch:TouchNavigationLinks> - </Grid> - - <controls:TwineCatalogControl x:Name="catalogControl" Grid.Row="1" DataContext="{Binding RelativeSource={RelativeSource AncestorType=local:TwineCatalogViewer},Path=Catalog,Mode=TwoWay}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=local:TwineCatalogViewer},Path=SelectedItem,Mode=TwoWay}" /> + <controls:TwineCatalogControl x:Name="catalogControl" DataContext="{Binding RelativeSource={RelativeSource AncestorType=local:TwineCatalogViewer},Path=Catalog,Mode=TwoWay}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=local:TwineCatalogViewer},Path=SelectedItem,Mode=TwoWay}" + CollectionFilter ="{Binding RelativeSource={RelativeSource AncestorType=local:TwineCatalogViewer},Path=CollectionFilter,Mode=TwoWay}"/> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs index 929e9cd76..a0b9e62c8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.BL.Entities; +using Tango.Touch.Components; namespace Tango.PPC.Jobs.Controls { @@ -70,6 +71,17 @@ namespace Tango.PPC.Jobs.Controls DependencyProperty.Register("Filter", typeof(String), typeof(TwineCatalogViewer), new PropertyMetadata(null,(d,e) => (d as TwineCatalogViewer).OnFilterChanged())); /// <summary> + /// Gets or sets the collection filter. + /// </summary> + public ICollectionFilter CollectionFilter + { + get { return (ICollectionFilter)GetValue(CollectionFilterProperty); } + set { SetValue(CollectionFilterProperty, value); } + } + public static readonly DependencyProperty CollectionFilterProperty = + DependencyProperty.Register("CollectionFilter", typeof(ICollectionFilter), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + + /// <summary> /// Called when the filter has been changed /// </summary> private void OnFilterChanged() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml index 854667024..a2c33cb75 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml @@ -9,9 +9,11 @@ xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:converters="clr-namespace:Tango.PPC.Jobs.Converters" + xmlns:commonControls="clr-namespace:Tango.PPC.Common.Controls;assembly=Tango.PPC.Common" xmlns:global="clr-namespace:Tango.PPC.Jobs" mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="800" Width="750" Height="1200" Background="{StaticResource TangoPrimaryBackgroundBrush}" + Background="{StaticResource TangoMidBackgroundBrush}" + d:DesignHeight="1280" d:DesignWidth="800" Width="780" Height="1200" d:DataContext="{d:DesignInstance Type=vm:ColorSelectionViewVM, IsDesignTimeCreatable=False}"> <UserControl.Resources> @@ -128,7 +130,7 @@ </DataTemplate> <DataTemplate x:Key="bottomPanel" > - <Grid Grid.Row="3" VerticalAlignment="Stretch" Margin="60 30 30 40"> + <Grid VerticalAlignment="Stretch" Margin="60 30 30 40"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="1*"/> @@ -139,29 +141,62 @@ <Rectangle Margin="0 10 20 0" Stroke="{StaticResource TangoDarkForegroundBrush}" Height="1" VerticalAlignment="Bottom"/> </StackPanel> - <Grid DockPanel.Dock="Bottom" Grid.Row="2"> - <touch:TouchButton HorizontalAlignment="Left" CornerRadius="25" Command="{Binding CloseCommand}" Style="{StaticResource TangoHollowButton}" Width="200" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> - <touch:TouchButton HorizontalAlignment="Right" CornerRadius="25" Command="{Binding OKCommand}" Style="{StaticResource TangoHollowButton}" Width="200" Height="50" VerticalAlignment="Bottom">CONFIRM</touch:TouchButton> + <Grid Grid.Row="2"> + <touch:TouchButton HorizontalAlignment="Center" CornerRadius="25" Command="{Binding OKCommand}" Width="200" Height="50" VerticalAlignment="Bottom" Background="{StaticResource TangoMidAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}" ShadowDepth="0">OK</touch:TouchButton> </Grid> </Grid> </DataTemplate> </ResourceDictionary> </UserControl.Resources> - <Grid> - <Border Background="#E5E5E5"> - <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <Grid HorizontalAlignment="Stretch"> + <Border > + <Grid > <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> - <Border.Effect> - <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> - </Border.Effect> - <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Color Selection Tool</TextBlock> + + <Grid> + <Border BorderThickness="0 0 1 0" BorderBrush="{StaticResource TangoDividerBrush}" Margin="30 0 0 0"> + <touch:TouchButton HorizontalAlignment="Left" Command="{Binding CloseCommand}" Background="Transparent" Height="37" Width="37" EnableDropShadow="False"> + <Canvas x:Name="canvas" Width="24" Height="24" RenderTransformOrigin="0.5,0.5" Background="Transparent"> + <Canvas.RenderTransform> + <TransformGroup> + <ScaleTransform ScaleX="2" ScaleY="2"/> + <SkewTransform/> + <RotateTransform Angle="-180"/> + <TranslateTransform/> + </TransformGroup> + </Canvas.RenderTransform> + <Rectangle x:Name="rectangle" Fill="{StaticResource TangoPrimaryAccentBrush}" Height="2" Canvas.Left="3" RadiusY="0" RadiusX="0" Canvas.Top="6" Width="18" RenderTransformOrigin="0.5,0.5"> + <Rectangle.RenderTransform> + <TransformGroup> + <ScaleTransform ScaleX="0.581"/> + <SkewTransform/> + <RotateTransform Angle="45"/> + <TranslateTransform X="4.875" Y="1.875"/> + </TransformGroup> + </Rectangle.RenderTransform> + </Rectangle> + <Rectangle x:Name="rectangle2" Fill="{StaticResource TangoPrimaryAccentBrush}" Height="2" Canvas.Left="3" RadiusY="0" RadiusX="0" Canvas.Top="16" Width="18" RenderTransformOrigin="0.5,0.5"> + <Rectangle.RenderTransform> + <TransformGroup> + <ScaleTransform ScaleX="0.581"/> + <SkewTransform/> + <RotateTransform Angle="-45"/> + <TranslateTransform X="4.832" Y="-2.082"/> + </TransformGroup> + </Rectangle.RenderTransform> + </Rectangle> + </Canvas> + </touch:TouchButton> + </Border> + <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Color Selection Tool</TextBlock> + </Grid> </Border> - <Grid Grid.Row="1"> + <Grid Grid.Row="1" Background="{StaticResource TangoPrimaryBackgroundBrush}" Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="100"/> <RowDefinition Height="1*"/> @@ -191,7 +226,7 @@ <Grid Grid.Row="1" x:Name="HSBGrid" > - + <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='HSB'}"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> @@ -299,8 +334,36 @@ <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> </Grid> - - <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='Catalog'}"> + + <Grid x:Name="catalogsGrid" Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='Catalog'}"> + <!--Catalog--> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + <ContentControl Name="myCatalogsColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> + <DockPanel Grid.Row="1" Margin="0 0 50 0"> + <Grid DockPanel.Dock="Top" HorizontalAlignment="Stretch" Margin="0 0 0 20"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <Grid VerticalAlignment="Center" HorizontalAlignment="Left" Margin="60 5 0 0" DockPanel.Dock="Left" Width="200"> + <DockPanel> + <touch:TouchIcon DockPanel.Dock="Left" Foreground="{StaticResource TangoGrayBrush}" Width="20" Height="20" VerticalAlignment="Bottom" Icon="Magnify" /> + <touch:TouchTextBox Margin="5 0 0 0" Width="300" Text="{Binding Filter,Mode=TwoWay}" ></touch:TouchTextBox> + </DockPanel> + </Grid> + <touch:TouchComboBox Margin="0 5 60 0" Grid.Column="1" Width="200" HorizontalContentAlignment="Right" ItemsSource="{Binding Catalogs}" SelectedItem="{Binding SelectedCatalog}" DisplayMemberPath="Name" Title="Twine Catalog"/> + </Grid> + + <!--<commonControls:TwineCatalogControl Margin="0 30 0 0 " DataContext="{Binding SelectedCatalog, Mode=TwoWay}" SelectedItem="{Binding DataContext.ColorCatalogsItem, Mode=TwoWay, ElementName=catalogsGrid, UpdateSourceTrigger=PropertyChanged, Delay=500}" />--> + <controls:TwineCatalogViewer Margin="80 0 0 0 " Catalog="{Binding SelectedCatalog, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedBrushStop.ColorCatalogsItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> + </DockPanel> + <Grid Grid.Row="2" Margin="60 27 30 40"> + <touch:TouchButton HorizontalAlignment="Center" CornerRadius="25" Command="{Binding OKCommand}" Width="200" Height="50" VerticalAlignment="Bottom" Background="{StaticResource TangoMidAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}" ShadowDepth="0">OK</touch:TouchButton> + </Grid> </Grid> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs index 5516cf47f..60a3f5039 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs @@ -60,5 +60,10 @@ namespace Tango.PPC.Jobs.Dialogs } } } + + private void TwineCatalogControl_Loaded(object sender, RoutedEventArgs e) + { + + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs index 83128a374..17fd92ecc 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.ColorConversion; using Tango.Core.Commands; @@ -14,6 +15,7 @@ using Tango.PPC.Jobs.Models; using Tango.PPC.Jobs.NavigationObjects; using Tango.PPC.Jobs.ViewContracts; using Tango.SharedUI; +using Tango.Touch.Components; namespace Tango.PPC.Jobs.Dialogs { @@ -37,6 +39,7 @@ namespace Tango.PPC.Jobs.Dialogs { public SegmentModel SelectedSegment { get; set; } public BrushStopModel BrushStopForEdit { get; set; } + public List<ColorCatalog> Catalogs { get; set; } /// <summary> /// True when first brush is open for editing /// </summary> @@ -232,6 +235,52 @@ namespace Tango.PPC.Jobs.Dialogs public DialogObject DialogEditObject { get; set; } + private List<ColorCatalog> _catalogs; + public List<ColorCatalog> Catalogs + { + get { return _catalogs; } + set { _catalogs = value; + RaisePropertyChangedAuto(); } + } + + private ColorCatalog _selectedCatalog; + public ColorCatalog SelectedCatalog + { + get { return _selectedCatalog; } + set + { + if (_selectedCatalog != value) + { + _selectedCatalog = value; + RaisePropertyChangedAuto(); + } + } + } + + private String _filter; + /// <summary> + /// Gets or sets the search filter. + /// </summary> + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private ICollectionFilter _collectionFilter; + public ICollectionFilter CollectionFilter + { + get { return _collectionFilter; } + set { _collectionFilter = value; RaisePropertyChangedAuto(); } + } + + private void OnFilterChanged() + { + + CollectionFilter.RaiseFilterChanged(); + // View.ScrollToTop(); + + } #endregion public ColorSelectionViewVM() @@ -239,27 +288,73 @@ namespace Tango.PPC.Jobs.Dialogs SelectedColorTab = ColorTab.RGB; _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); _converter = new DefaultColorConverter(); + CollectionFilter = new DefaultCollectionFilter(); + CollectionFilter.RegisterFilter(item => + { + var colorCatalogsItem = item as ColorCatalogsItem; + + if (colorCatalogsItem != null) + { + if (String.IsNullOrEmpty(Filter)) + { + return true; + } + else + { + return (colorCatalogsItem.Name.ToLower().Contains(Filter.ToLower())); + } + } + else + { + return true; + } + }); } public override void OnShow() { + Catalogs = DialogEditObject.Catalogs; base.OnShow(); - + SegmentIndex = DialogEditObject.SelectedSegment.SegmentIndex; IsEditMode = DialogEditObject.IsEditingMode; if (DialogEditObject.IsEditingMode) { InitialBrushStop = DialogEditObject.BrushStopForEdit; + SelectedBrushStop = InitialBrushStop.Clone(); SelectedBrushStop.ColorSpace = InitialBrushStop.ColorSpace; - - SelectedColorTab = (ColorTab)SelectedBrushStop.ColorSpace; + if(SelectedBrushStop.ColorSpace == ColorSpaces.Volume) + SelectedColorTab = ColorTab.Volume; + if (SelectedBrushStop.ColorSpace == ColorSpaces.LAB) + SelectedColorTab = ColorTab.CIELab; + if (SelectedBrushStop.ColorSpace == ColorSpaces.Catalog) + { + SelectedColorTab = ColorTab.Catalog; + if (SelectedBrushStop.ColorCatalogsItem != null) + { + SelectedCatalog = SelectedBrushStop.ColorCatalogsItem.ColorCatalogsGroup.ColorCatalog; + } + else + { + SelectedCatalog = Catalogs.FirstOrDefault(); + } + } + + if (SelectedBrushStop.ColorSpace == ColorSpaces.HSB) + SelectedColorTab = ColorTab.HSB; + if (SelectedBrushStop.ColorSpace == ColorSpaces.RGB) + SelectedColorTab = ColorTab.RGB; } else { SelectedBrushStop = DialogEditObject.BrushStopForEdit; SelectedColorTab = ColorTab.RGB; + SelectedCatalog = Catalogs.FirstOrDefault(); } + SelectedBrushStop.ColorCatalogsItemChanged -= OnColorSelectionItemChanged; + SelectedBrushStop.ColorCatalogsItemChanged += OnColorSelectionItemChanged; + UpdateVolumesMaxValues(); } @@ -300,9 +395,28 @@ namespace Tango.PPC.Jobs.Dialogs } return; } + case ColorTab.Catalog: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.ConvertColorToCatalogs(DialogEditObject.Catalogs); + } + return; + } } } + protected void OnColorSelectionItemChanged( object sender, EventArgs args) + { + if (SelectedBrushStop.ColorCatalogsItem != null) + { + SelectedCatalog = SelectedBrushStop.ColorCatalogsItem.ColorCatalogsGroup.ColorCatalog; + } + + else + SelectedCatalog = Catalogs.FirstOrDefault(); + } + #region Methods private double GetMaxCMYKValueOrDefault(LiquidTypes type) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml index ddcd556ba..7dc654bec 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml @@ -9,7 +9,7 @@ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" mc:Ignorable="d" - Background="{StaticResource TangoMidBackgroundBrush}" d:DesignHeight="861" d:DesignWidth="662" Width="800" Height="1200" d:DataContext="{d:DesignInstance Type=local:JobCreationViewVM, IsDesignTimeCreatable=False}"> + Background="{StaticResource TangoMidBackgroundBrush}" d:DesignHeight="861" d:DesignWidth="662" Width="790" Height="1200" d:DataContext="{d:DesignInstance Type=local:JobCreationViewVM, IsDesignTimeCreatable=False}" HorizontalAlignment="Center"> <UserControl.Resources> <converters:JobTypeToImageConverter x:Key="JobTypeToImageConverter" /> @@ -73,6 +73,7 @@ <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> </Grid.RowDefinitions> @@ -137,6 +138,16 @@ <touch:TouchButton CornerRadius="25" Command="{Binding DuplicateCommand}" Width="180" Height="48" VerticalAlignment="Center" HorizontalAlignment="Right" Background="{StaticResource TangoPrimaryAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}">Duplicate</touch:TouchButton> </Grid> + <Grid Grid.Row="3" Margin="0 70 0 0" HorizontalAlignment="Stretch" Visibility="{Binding ShowDuplicate, Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Save Job As PDF" FontWeight="Normal" FontSize="{StaticResource TangoDialogFontSize}" Width="Auto"/> + <touch:TouchButton CornerRadius="25" Command="{Binding DuplicateCommand}" Width="180" Height="48" VerticalAlignment="Center" HorizontalAlignment="Right" Background="{StaticResource TangoPrimaryAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}"> + + <StackPanel> + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Export" FontWeight="Normal" FontSize="{StaticResource TangoDialogFontSize}" Width="Auto"/> + </StackPanel> + </touch:TouchButton> + + </Grid> </Grid> </DockPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/repeat.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/repeat.png Binary files differnew file mode 100644 index 000000000..2ab076ad6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/repeat.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/job_export.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/job_export.png Binary files differnew file mode 100644 index 000000000..8251d97ae --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/job_export.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs index 3447cec8e..8cafd369d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs @@ -31,7 +31,7 @@ namespace Tango.PPC.Jobs.Models private ActionTimer _volumeConversionTimer; private IColorConverter _converter; public const double MAX_INK_UPTAKE = 400; - + public event EventHandler ColorCatalogsItemChanged; #region Property @@ -411,8 +411,8 @@ namespace Tango.PPC.Jobs.Models } } } + protected ColorCatalogsItem _colorcatalogsitem; - public virtual ColorCatalogsItem ColorCatalogsItem { get @@ -425,11 +425,30 @@ namespace Tango.PPC.Jobs.Models if (_colorcatalogsitem != value) { _colorcatalogsitem = value; + OnColorCatalogsItemChanged(); + RaisePropertyChangedAuto(); } } } - + + /// <summary> + /// Gets or sets the color catalog. + /// </summary> + /// <value> + /// The color catalog. + /// </value> + public virtual ColorCatalog ColorCatalog + { + get + { + if(ColorCatalogsItem != null && ColorCatalogsItem.ColorCatalogsGroup!= null) + return ColorCatalogsItem.ColorCatalogsGroup.ColorCatalog; + + return null; + } + } + private System.Windows.Media.Color _color; public System.Windows.Media.Color Color { @@ -527,6 +546,31 @@ namespace Tango.PPC.Jobs.Models _displayedColor = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); Color = Colors.White; ColorSpace = ColorSpaces.RGB; + ColorCatalogsItem = null; + PreventPropertyUpdate = false; + } + + public BrushStopModel(BrushStop brushStop, SegmentModel segmentModel) + { + SegmentModel = segmentModel; + OffsetPercent = brushStop.OffsetPercent; + Color = brushStop.Color; + DisplayedColor = brushStop.Color; + ColorSpace = brushStop.ColorSpace.Space; + ColorCatalogsItem = brushStop.ColorCatalogsItem; + StopIndex = brushStop.StopIndex; + + PreventPropertyUpdate = true; + Cyan = brushStop.Cyan; + Magenta = brushStop.Magenta; + Yellow = brushStop.Yellow; + Black = brushStop.Black; + Red = brushStop.Red; + Green = brushStop.Green; + Blue = brushStop.Blue; + L = brushStop.L; + A = brushStop.A; + B = brushStop.B; PreventPropertyUpdate = false; } @@ -536,16 +580,9 @@ namespace Tango.PPC.Jobs.Models /// </summary> public void InitColor() { - if (ColorSpace == ColorSpaces.Catalog) + if (ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) { - if (ColorCatalogsItem != null) - { - Color = Color.FromRgb((byte)ColorCatalogsItem.Red, (byte)ColorCatalogsItem.Green, (byte)ColorCatalogsItem.Blue); - } - else - { - Color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); - } + Color = Color.FromRgb((byte)ColorCatalogsItem.Red, (byte)ColorCatalogsItem.Green, (byte)ColorCatalogsItem.Blue); } else { @@ -722,6 +759,22 @@ namespace Tango.PPC.Jobs.Models OnBrushStopFieldValueChanged(); } + private void OnColorCatalogsItemChanged() + { + ColorSpace = ColorSpaces.Catalog; + if (_colorcatalogsitem != null) + { + _red = (int)_colorcatalogsitem.Red; + _green = (int)_colorcatalogsitem.Green; + _blue = (int)_colorcatalogsitem.Blue; + InitColor(); + DisplayedColor = Color; + } + if (ColorCatalogsItemChanged != null) + { + ColorCatalogsItemChanged.Invoke(this, new EventArgs()); + } + } private void OnOffsetPercentChanged() { //lenth? @@ -746,6 +799,10 @@ namespace Tango.PPC.Jobs.Models Rgb rgb = new Rgb(hsb.ToRgb()); return rgb; } + if(ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) + { + return new Rgb(ColorCatalogsItem.Red, ColorCatalogsItem.Green, ColorCatalogsItem.Blue); + } return new Rgb(Red, Green, Blue); } @@ -788,6 +845,11 @@ namespace Tango.PPC.Jobs.Models Rgb rgb = new Rgb(Red, Green, Blue); hsb = new Hsb(rgb.To<Hsb>()); } + else if(ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) + { + Rgb rgb = new Rgb(ColorCatalogsItem.Red, ColorCatalogsItem.Green, ColorCatalogsItem.Blue); + hsb = new Hsb(rgb.To<Hsb>()); + } if (hsb != null) { _hue = hsb.H; @@ -875,6 +937,10 @@ namespace Tango.PPC.Jobs.Models Rgb rgb = new Rgb(Red, Green, Blue); lab = new Lab(rgb.To<Lab>()); } + else if (ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) + { + lab = new Lab(ColorCatalogsItem.L, ColorCatalogsItem.A, ColorCatalogsItem.B); + } if(lab != null) { _l = lab.L; @@ -892,6 +958,24 @@ namespace Tango.PPC.Jobs.Models { if (ColorSpace != ColorSpaces.Volume) { + + if (ColorSpace == ColorSpaces.Catalog) + { + if(ColorCatalogsItem != null) + { + _cyan =ColorCatalogsItem.Cyan; + _magenta = ColorCatalogsItem.Magenta; + _yellow = ColorCatalogsItem.Yellow; + _black = ColorCatalogsItem.Black; + RaisePropertyChanged(nameof(Cyan)); + RaisePropertyChanged(nameof(Yellow)); + RaisePropertyChanged(nameof(Magenta)); + RaisePropertyChanged(nameof(Black)); + IsOutOfGamut = false; + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); + } + return; + } ColorSpaces colorSpace = ColorSpace; if (ColorSpace == ColorSpaces.HSB) { @@ -924,6 +1008,19 @@ namespace Tango.PPC.Jobs.Models } } } + + public void ConvertColorToCatalogs(List<ColorCatalog> catalogs) + { + if (ColorSpace != ColorSpaces.Catalog) + { + if (DisplayedColor == null) + DisplayedColor = Color; + var closestItem = catalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(DisplayedColor); + + ColorCatalogsItem = closestItem; + RaisePropertyChanged(nameof(ColorCatalog)); + } + } public void RaiseOffsetChanged() { @@ -931,6 +1028,11 @@ namespace Tango.PPC.Jobs.Models RaisePropertyChanged(nameof(OffsetMeters)); } + public void RaiseColorCatalogsItemChanged() + { + RaisePropertyChanged(nameof(ColorCatalogsItem)); + } + #endregion #region color converters diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs index 0a47c4c69..d72986b0f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs @@ -426,6 +426,7 @@ namespace Tango.PPC.Jobs.Models brushStop.StopIndex = 1; brushStop.OffsetPercent = 0; brushStop.Position = BrushStopModel.PositionStatus.First; + brushStop.IsOutOfGamut = false; BrushStops.Add(brushStop); BrushStopModel colorbrushStop = firstBrush.Clone(); @@ -438,6 +439,7 @@ namespace Tango.PPC.Jobs.Models middleBrushStop.StopIndex = 3; middleBrushStop.Position = BrushStopModel.PositionStatus.Middle; middleBrushStop.OffsetPercent = 50; + middleBrushStop.IsOutOfGamut = false; middleBrushStop.Color = BrushStopModel.GetRelativeRGB(firstBrush.Color, secondBrush.Color, 0, 1, 0.5); middleBrushStop.DisplayedColor = BrushStopModel.GetRelativeRGB(firstBrush.DisplayedColor, secondBrush.DisplayedColor, 0, 1, 0.5); BrushStops.Add(middleBrushStop); @@ -458,6 +460,7 @@ namespace Tango.PPC.Jobs.Models BrushStopModel lastSecondBrushStop = secondBrush.Clone(); lastSecondBrushStop.StopIndex = 5; lastSecondBrushStop.OffsetPercent = 100; + lastSecondBrushStop.IsOutOfGamut = false; lastSecondBrushStop.Position = BrushStopModel.PositionStatus.Last; ; BrushStops.Add(lastSecondBrushStop); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index deb0e5cc9..e428dd8b9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -597,10 +597,16 @@ <ItemGroup> <Resource Include="Images\JobView\add_gap.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\JobView\repeat.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\NewJob\job_export.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index 948b0b9c8..9cb6c3189 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -61,6 +61,7 @@ namespace Tango.PPC.Jobs.ViewModels private IColorConverter _converter; private string _current_job_string; private bool startingJob = false; + private List<ColorCatalog> _catalogs; #region Properties @@ -71,9 +72,11 @@ namespace Tango.PPC.Jobs.ViewModels public Job Job { get { return _job; } - set { + set + { _job = value; - RaisePropertyChangedAuto(); } + RaisePropertyChangedAuto(); + } } private JobModel _jobModel; @@ -81,8 +84,11 @@ namespace Tango.PPC.Jobs.ViewModels public JobModel JobModel { get { return _jobModel; } - set { _jobModel = value; - RaisePropertyChangedAuto(); } + set + { + _jobModel = value; + RaisePropertyChangedAuto(); + } } @@ -99,7 +105,7 @@ namespace Tango.PPC.Jobs.ViewModels RaisePropertyChangedAuto(); } } - + private List<ColorSpace> _colorSpaces; /// <summary> /// Gets or sets the available color spaces. @@ -185,34 +191,34 @@ namespace Tango.PPC.Jobs.ViewModels set { _approvalFineTuneItems = value; RaisePropertyChangedAuto(); } } - private bool _isFineTuneExpanded; - /// <summary> - /// Gets or sets a value indicating whether the fine tuning region is expanded. - /// </summary> - public bool IsFineTuneExpanded - { - get { return _isFineTuneExpanded; } - set - { - _isFineTuneExpanded = value; - RaisePropertyChangedAuto(); + //private bool _isFineTuneExpanded; + ///// <summary> + ///// Gets or sets a value indicating whether the fine tuning region is expanded. + ///// </summary> + //public bool IsFineTuneExpanded + //{ + // get { return _isFineTuneExpanded; } + // set + // { + // _isFineTuneExpanded = value; + // RaisePropertyChangedAuto(); - if (_isFineTuneExpanded) - { - SyncFineTuneItemsToBrushStops(); - } - } - } + // if (_isFineTuneExpanded) + // { + // SyncFineTuneItemsToBrushStops(); + // } + // } + //} - private bool _isJobDetailsExpanded; - /// <summary> - /// Gets or sets a value indicating whether the job details area is expanded. - /// </summary> - public bool IsJobDetailsExpanded - { - get { return _isJobDetailsExpanded; } - set { _isJobDetailsExpanded = value; RaisePropertyChangedAuto(); } - } + //private bool _isJobDetailsExpanded; + ///// <summary> + ///// Gets or sets a value indicating whether the job details area is expanded. + ///// </summary> + //public bool IsJobDetailsExpanded + //{ + // get { return _isJobDetailsExpanded; } + // set { _isJobDetailsExpanded = value; RaisePropertyChangedAuto(); } + //} /// <summary> /// Gets or sets the twine catalog automatic complete provider. @@ -245,11 +251,13 @@ namespace Tango.PPC.Jobs.ViewModels public bool IsFullMode { get { return _isFullMode; } - set { _isFullMode = value; + set + { + _isFullMode = value; RaisePropertyChangedAuto(); } } - + #endregion #region Commands @@ -264,7 +272,7 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand<SegmentModel> UndoLastColorCommand { get; set; } - + /// <summary> /// Gets or sets the remove segment command. /// </summary> @@ -286,11 +294,6 @@ namespace Tango.PPC.Jobs.ViewModels public RelayCommand<BrushStopModel> EditColorCommand { get; set; } /// <summary> - /// Gets or sets the save job command. - /// </summary> - public RelayCommand SaveJobCommand { get; set; } - - /// <summary> /// Gets or sets the replace brush stop command. /// </summary> public RelayCommand<BrushStop> ReplaceBrushStopCommand { get; set; } @@ -301,59 +304,10 @@ namespace Tango.PPC.Jobs.ViewModels //public RelayCommand<BrushStop> OpenCatalogCommand { get; set; } /// <summary> - /// Gets or sets the increase decrease samples to dye command. - /// </summary> - public RelayCommand<String> IncreaseDecreaseSamplesToDyeCommand { get; set; } - - /// <summary> - /// Gets or sets the start sample dye command. - /// </summary> - public RelayCommand StartSampleDyeCommand { get; set; } - - /// <summary> /// Gets or sets the dye command. /// </summary> public RelayCommand DyeCommand { get; set; } - /// <summary> - /// Gets or sets the approve sample command. - /// </summary> - public RelayCommand ApproveSampleCommand { get; set; } - - /// <summary> - /// Gets or sets the repeat sample dye command. - /// </summary> - public RelayCommand RepeatSampleDyeCommand { get; set; } - - /// <summary> - /// Gets or sets another sample command. - /// </summary> - public RelayCommand AnotherSampleCommand { get; set; } - - /// <summary> - /// Gets or sets the invoke fine tuning palette command. - /// </summary> - public RelayCommand<FineTuneItem> InvokeFineTuningPaletteCommand { get; set; } - - /// <summary> - /// Gets or sets the reset fine tuning command. - /// </summary> - public RelayCommand ResetFineTuningCommand { get; set; } - - /// <summary> - /// Gets or sets the start fine tuning command. - /// </summary> - public RelayCommand StartFineTuningCommand { get; set; } - - /// <summary> - /// Gets or sets the approve fine tuning command. - /// </summary> - public RelayCommand ApproveFineTuningCommand { get; set; } - - /// <summary> - /// Gets or sets the repeat fine tuning command. - /// </summary> - public RelayCommand RepeatFineTuningCommand { get; set; } /// <summary> /// Gets or sets the export embroidery command. @@ -365,7 +319,7 @@ namespace Tango.PPC.Jobs.ViewModels public RelayCommand RepeatUnitsCommand { get; set; } public RelayCommand JobModeSwitchCommand { get; set; } - + #endregion #region collapsed mode commands @@ -429,45 +383,11 @@ namespace Tango.PPC.Jobs.ViewModels RemoveSegmentCommand = new RelayCommand<SegmentModel>(RemoveSegment); DuplicateSegmentCommand = new RelayCommand<SegmentModel>(DuplicateSegment); - //SegmentDroppedCommand = new RelayCommand<DropEventArgs>((e) => - //{ - // DragAndDropSegment( - // (e.Draggable as FrameworkElement).DataContext as Segment, - // (e.Droppable as FrameworkElement).DataContext as Segment); - //}); - AddColorCommand = new RelayCommand<SegmentModel>(AddColor); EditColorCommand = new RelayCommand<BrushStopModel>(EditColor); - //SaveJobCommand = new RelayCommand(() => SaveJob()); - //ReplaceBrushStopCommand = new RelayCommand<BrushStop>(InvokeColorAdjustmentForBrushStop); - IncreaseDecreaseSamplesToDyeCommand = new RelayCommand<string>((x) => - { - if (x == "+") - { - Job.SampleUnitsOrMeters++; - } - else - { - Job.SampleUnitsOrMeters--; - } - }); - - //_check_gamut_thread = new Thread(CheckGamutThreadMethod); - //_check_gamut_thread.IsBackground = true; - - StartSampleDyeCommand = new RelayCommand(StartSampleDye, CanStartJob); DyeCommand = new RelayCommand(StartJob, CanStartJob); - ApproveSampleCommand = new RelayCommand(ApproveSampleDye); - RepeatSampleDyeCommand = new RelayCommand(RepeatSampleDye); - AnotherSampleCommand = new RelayCommand(DyeAnotherSample); - InvokeFineTuningPaletteCommand = new RelayCommand<FineTuneItem>(InvokeFineTuningPalette); - ResetFineTuningCommand = new RelayCommand(() => ResetFineTuning(true)); - StartFineTuningCommand = new RelayCommand(StartFineTuning, () => FineTuneItems.Any(x => x.IsSelected) && CanStartJob()); - RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); - ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); - //OpenCatalogCommand = new RelayCommand<BrushStop>(OpenCatalog); ExportEmbroideryCommand = new RelayCommand(ExportEmbroidery); RepeatUnitsCommand = new RelayCommand(RepeatUnits); @@ -479,9 +399,9 @@ namespace Tango.PPC.Jobs.ViewModels RepeateSegmentCommand = new RelayCommand(RepeateSegment); PasteCommand = new RelayCommand(Paste); CopyCommand = new RelayCommand(Copy); - UndoCommand = new RelayCommand(Undo,(x)=> { return false; }); + UndoCommand = new RelayCommand(Undo, (x) => { return false; }); RedoCommand = new RelayCommand(Redo, (x) => { return false; }); - + IsFullMode = true; } @@ -489,6 +409,50 @@ namespace Tango.PPC.Jobs.ViewModels #region Job Management + public void AddGradientBrushes(Segment segment, BrushStop firstBrush, BrushStop secondBrush) + { + if (segment == null) + return; + + firstBrush.BestMatchR = firstBrush.Color.R; + firstBrush.BestMatchG = firstBrush.Color.G; + firstBrush.BestMatchB = firstBrush.Color.B; + + BrushStop brushStop = firstBrush.CloneBrush(); + brushStop.StopIndex = 1; + brushStop.OffsetPercent = 0; + brushStop.IsOutOfGamut = false; + segment.BrushStops.Add(brushStop); + + BrushStop firstbrushStop = firstBrush.CloneBrush(); + firstbrushStop.StopIndex = 2; + firstbrushStop.OffsetPercent = 0; + segment.BrushStops.Add(firstbrushStop); + + secondBrush.BestMatchR = secondBrush.Color.R; + secondBrush.BestMatchG = secondBrush.Color.G; + secondBrush.BestMatchB = secondBrush.Color.B; + + + BrushStop middleBrushStop = firstBrush.CloneBrush(); + middleBrushStop.StopIndex = 3; + middleBrushStop.OffsetPercent = 50;//secondBrush.OffsetPercent; + middleBrushStop.IsOutOfGamut = false; + middleBrushStop.Color = BrushStopModel.GetRelativeRGB(firstBrush.Color, secondBrush.Color, 0, 1, 0.5); + segment.BrushStops.Add(middleBrushStop); + + BrushStop secondbrushStop = secondBrush.CloneBrush(); + secondbrushStop.StopIndex = 4; + secondbrushStop.OffsetPercent = 100; + segment.BrushStops.Add(secondbrushStop); + + BrushStop lastSecondBrushStop = secondBrush.CloneBrush(); + lastSecondBrushStop.StopIndex = 5; + lastSecondBrushStop.OffsetPercent = 100; + lastSecondBrushStop.IsOutOfGamut = false; + segment.BrushStops.Add(lastSecondBrushStop); + } + /// <summary> /// Loads the job. /// </summary> @@ -534,6 +498,13 @@ namespace Tango.PPC.Jobs.ViewModels _db = ObservablesContext.CreateDefault(); + _catalogs = await new CatalogsCollectionBuilder(_db) + .SetAll() + .WithGroups() + .WithItems() + .ForSite(MachineProvider.Machine.SiteGuid) + .BuildListAsync(); + Job = await new JobBuilder(_db).Set(_job_to_load.Guid) .WithConfiguration() .WithUser() @@ -541,11 +512,47 @@ namespace Tango.PPC.Jobs.ViewModels .WithBrushStops() .BuildAsync(); - if (Job.Version == 1) - { - //Modify Job... - } - + //Modify old Job... + //if (Job.Version == 1) + //{ + // var segments = Job.Segments; + // Job.Segments = new SynchronizedObservableCollection<Segment>(); + // int segindex = 1; + + // foreach (var segm in segments) + // { + // if (!segm.IsInterSegment && segm.BrushStops.Count > 1) + // { + // var brushes = segm.BrushStops; + // Segment currentSegment = segm; + // double lengthOfOldSegment = segm.Length; + // for (int index = 0; index < (brushes.Count - 1); index++) + // { + + // currentSegment = new Segment(); + // currentSegment.Guid = System.Guid.NewGuid().ToString(); + // currentSegment.Name = segm.Name; + // currentSegment.Job = Job; + + // currentSegment.SegmentIndex = segindex++; + // currentSegment.BrushStops = new SynchronizedObservableCollection<BrushStop>(); + + // brushes[index].Segment = currentSegment; + // brushes[index + 1].Segment = currentSegment; + // currentSegment.Length = (lengthOfOldSegment * (brushes[index + 1].OffsetPercent - brushes[index].OffsetPercent) / 100d) ; + // AddGradientBrushes(currentSegment, brushes[index], brushes[index + 1]); + // Job.Segments.Add(currentSegment); + // } + + // } + // else + // { + // segm.SegmentIndex = segindex++; + // Job.Segments.Add(segm); + // } + // } + //} + Job.NameChanged -= Job_NameChanged; Job.NameChanged += Job_NameChanged; @@ -570,7 +577,7 @@ namespace Tango.PPC.Jobs.ViewModels await LoadRML(_selectedRML); - + ///NEW CODE Save to MODEL var jobModel = new JobModel(ColorSpaces) { @@ -585,51 +592,65 @@ namespace Tango.PPC.Jobs.ViewModels User = Job.User, Machine = Job.Machine }; - - foreach( var segm in Job.Segments) + + foreach (var segm in Job.Segments) { - SegmentModel segmentModel = new SegmentModel(jobModel, segm.Guid) + if (Job.Version == 1 && segm.BrushStops.Count > 1) { - Name = segm.Name, - Length = segm.Length, - SegmentIndex = segm.SegmentIndex, - IsInterSegment = segm.IsInterSegment, - EnableInterSegment = false, - Job = jobModel - }; - - foreach ( var brushStop in segm.BrushStops) + int segmentindex = 1; + + var brushes = segm.BrushStops; + Segment currentSegment = segm; + double lengthOfOldSegment = segm.Length; + for (int index = 0; index < (brushes.Count - 1); index++) + { + SegmentModel csegmentModel = new SegmentModel(jobModel, segm.Guid) + { + Name = segm.Name, + Length = segm.Length, + SegmentIndex = segm.SegmentIndex, + IsInterSegment = segm.IsInterSegment, + EnableInterSegment = false, + Job = jobModel + }; + + csegmentModel.SegmentIndex = segmentindex++; + + brushes[index].Segment = currentSegment; + brushes[index + 1].Segment = currentSegment; + csegmentModel.Length = (lengthOfOldSegment * (brushes[index + 1].OffsetPercent - brushes[index].OffsetPercent) / 100d); + BrushStopModel brushStopModelFirst = new BrushStopModel(brushes[index], csegmentModel); + BrushStopModel brushStopModelSecond = new BrushStopModel(brushes[index + 1], csegmentModel); + csegmentModel.CreateGradientBrushes(brushStopModelFirst, brushStopModelSecond); + + jobModel.Segments.Add(csegmentModel); + } + } + else { - BrushStopModel brushStopModel = new BrushStopModel(segmentModel) + SegmentModel segmentModel = new SegmentModel(jobModel, segm.Guid) { - SegmentModel = segmentModel, - Cyan = brushStop.Cyan, - Magenta = brushStop.Magenta, - Yellow = brushStop.Yellow, - Black = brushStop.Black, - Red = brushStop.Red, - Green = brushStop.Green, - Blue = brushStop.Blue, - L = brushStop.L, - A = brushStop.A, - B = brushStop.B, - OffsetPercent = brushStop.OffsetPercent, - Color = brushStop.Color, - DisplayedColor = brushStop.Color, - ColorSpace = brushStop.ColorSpace.Space, - ColorCatalogsItem = brushStop.ColorCatalogsItem, - StopIndex = brushStop.StopIndex + Name = segm.Name, + Length = segm.Length, + SegmentIndex = segm.SegmentIndex, + IsInterSegment = segm.IsInterSegment, + EnableInterSegment = false, + Job = jobModel }; - segmentModel.BrushStops.Add(brushStopModel); - // AddBrushStop(segmentModel, brushStopModel); + foreach (var brushStop in segm.BrushStops) + { + BrushStopModel brushStopModel = new BrushStopModel(brushStop, segmentModel); + segmentModel.BrushStops.Add(brushStopModel); + } + + ArrangeBrushStopsPosition(segmentModel); + jobModel.Segments.Add(segmentModel); } - ArrangeBrushStopsPosition(segmentModel); - jobModel.Segments.Add(segmentModel); } JobModel = jobModel; SegmentsCollectionView = CollectionViewSource.GetDefaultView(JobModel.Segments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(SegmentModel.SegmentIndex), ListSortDirection.Ascending)); - + /// _job_to_load = null; @@ -641,10 +662,10 @@ namespace Tango.PPC.Jobs.ViewModels Job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.Unspecified; } - if (_job_to_load_intent == JobNavigationIntent.NewJob) - { - IsJobDetailsExpanded = true; - } + //if (_job_to_load_intent == JobNavigationIntent.NewJob) + //{ + // IsJobDetailsExpanded = true; + //} LogManager.Log($"Job editing state = '{Job.JobEditingState}'."); @@ -660,10 +681,8 @@ namespace Tango.PPC.Jobs.ViewModels } ValidateBrushStops(); - + DyeCommand.RaiseCanExecuteChanged(); - StartSampleDyeCommand.RaiseCanExecuteChanged(); - StartFineTuningCommand.RaiseCanExecuteChanged(); } catch (Exception ex) { @@ -689,61 +708,7 @@ namespace Tango.PPC.Jobs.ViewModels base.OnBeforeNavigatedFrom(); //Save... } - - /// <summary> - /// Saves the job. - /// </summary> - private async void SaveJob(bool displayNotification = true) - { - try - { - if (Job.Validate(_db)) - { - LogManager.Log("Saving job..."); - - if (!String.IsNullOrWhiteSpace(CustomersFilter)) - { - if (!Customers.Exists(x => x.Name == CustomersFilter)) - { - var newCustomer = new Customer() - { - OrganizationGuid = MachineProvider.Machine.OrganizationGuid, - Name = CustomersFilter, - }; - - _db.Customers.Add(newCustomer); - - Job.Customer = newCustomer; - } - } - - Job.LastUpdated = DateTime.UtcNow; - Job.Version = 2; - Job.IsSynchronized = false; - Job.JobStatus = BL.Enumerations.JobStatuses.Draft; - Job.MarkModified(_db); - await _db.SaveChangesAsync(); - _current_job_string = Job.ToJobFileWhenLoaded().ToString(); - if (displayNotification) - { - await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); - } - - RaiseMessage(new JobSavedMessage() { Job = Job }); - } - else - { - await NotificationProvider.ShowError($"Error saving job. {Job.ValidationErrors.FirstOrDefault()}"); - } - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error saving job '{Job.Name}'."); - await NotificationProvider.ShowError("An error occurred while trying to save the job."); - } - } - /// <summary> /// Starts the job. /// </summary> @@ -756,6 +721,7 @@ namespace Tango.PPC.Jobs.ViewModels Debug.WriteLine("Job Starting..."); startingJob = true; LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); + await Save(); var handler = await PrintingManager.Print(Job, _db); await NavigationManager.NavigateTo<JobsV2Module>(nameof(JobProgressView)); startingJob = false; @@ -786,7 +752,9 @@ namespace Tango.PPC.Jobs.ViewModels { try { - return Job != null && Job.Validate(_db) && !Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent && !x.IsWhite).ToList().Exists(x => x.IsOutOfGamut || (x.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume && x.IsLiquidVolumesOutOfRange)); + var test = JobModel != null && !Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent && !x.IsWhite).ToList().Exists(x => x.IsOutOfGamut); + //return Job != null && Job.Validate(_db) && !Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent && !x.IsWhite).ToList().Exists(x => x.IsOutOfGamut || (x.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume && x.IsLiquidVolumesOutOfRange)); + return JobModel != null && !JobModel.Segments.SelectMany(x => x.BrushStops).Where(x => x.Position == BrushStopModel.PositionStatus.FirstColor || x.Position == BrushStopModel.PositionStatus.SecondColor).ToList().Exists(x => x.IsOutOfGamut); } catch (Exception ex) { @@ -800,14 +768,14 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Editing the job details."); - JobCreationViewVM vm = new JobCreationViewVM( _spoolTypes.ToList(),_rmls.ToList(), JobModel.InterSegmentLength, true ); + JobCreationViewVM vm = new JobCreationViewVM(_spoolTypes.ToList(), _rmls.ToList(), JobModel.InterSegmentLength, true); vm.JobName = JobModel.Name; vm.SelectedRML = JobModel.Rml; vm.SelectedSpoolType = JobModel.SpoolType; vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); if (!vm.DialogResult) return; - if(vm.IsDuplicate) + if (vm.IsDuplicate) { //Duplicate new job /* @@ -881,9 +849,9 @@ namespace Tango.PPC.Jobs.ViewModels .WithLiquidFactors() .WithSpools() .BuildAsync(); - if(JobModel != null) + if (JobModel != null) JobModel.Rml = Job.Rml; - + GetLubricationLevel(); await SetSpoolTension(rml); @@ -904,8 +872,6 @@ namespace Tango.PPC.Jobs.ViewModels } } DyeCommand.RaiseCanExecuteChanged(); - StartSampleDyeCommand.RaiseCanExecuteChanged(); - StartFineTuningCommand.RaiseCanExecuteChanged(); NotificationProvider.ReleaseGlobalBusyMessage(); } //if (updateVolumes) @@ -941,7 +907,7 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Adding new segment..."); - + var s = JobModel.AddNewSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); ArrangeSegmentsIndixes(); return s; @@ -953,7 +919,7 @@ namespace Tango.PPC.Jobs.ViewModels return null; } } - + /// <summary> /// Called when a segment has been dragged and dropped into another segment. /// </summary> @@ -1010,7 +976,7 @@ namespace Tango.PPC.Jobs.ViewModels } } - + /// <summary> /// Duplicates the segment. /// </summary> @@ -1018,9 +984,9 @@ namespace Tango.PPC.Jobs.ViewModels { SegmentModel newSegmentModel = segment.Clone(); newSegmentModel.SegmentIndex = segment.SegmentIndex + 1; - + newSegmentModel.RaiseSegmentBrushChanged(); - + if (JobModel.Segments.Count == segment.SegmentIndex) JobModel.Segments.Add(newSegmentModel); else @@ -1045,7 +1011,7 @@ namespace Tango.PPC.Jobs.ViewModels #endregion #region Brush Stops Management - + /// <summary> /// Opens the twine catalog for the specified brush stop. /// </summary> @@ -1081,7 +1047,7 @@ namespace Tango.PPC.Jobs.ViewModels private void ArrangeBrushStopsPosition(SegmentModel segment) { - if(segment.BrushStops.Count == 1) + if (segment.BrushStops.Count == 1) { segment.BrushStops.FirstOrDefault().Position = BrushStopModel.PositionStatus.FirstColor; } @@ -1113,6 +1079,7 @@ namespace Tango.PPC.Jobs.ViewModels SelectedSegment = segment, BrushStopForEdit = new BrushStopModel(segment), IsEditingMode = false, + Catalogs = _catalogs } }); @@ -1122,7 +1089,6 @@ namespace Tango.PPC.Jobs.ViewModels DyeCommand.RaiseCanExecuteChanged(); } // SetSegmentLiquidVolumes(segment); - //RegisterJobBrushStopsEvents(); } /// <summary> @@ -1130,6 +1096,11 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> private async void EditColor(BrushStopModel brushStop) { + if (brushStop == null) + { + await NotificationProvider.ShowError("The edit brush is null!"); + return; + } SegmentModel segment = brushStop.SegmentModel; LogManager.Log($"Edit brush stop."); @@ -1140,6 +1111,7 @@ namespace Tango.PPC.Jobs.ViewModels SelectedSegment = segment, BrushStopForEdit = brushStop, IsEditingMode = true, + Catalogs = _catalogs } }); @@ -1158,7 +1130,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (newBrushStop == null || segment == null) return; - Segment s = new Segment(); + //SolidColor if (segment.BrushStops.Count == 0) { @@ -1166,7 +1138,7 @@ namespace Tango.PPC.Jobs.ViewModels segment.BrushStops.Add(newBrushStop); } //Add Second BrushStop - else if(segment.BrushStops.Count == 1)// add gradient + else if (segment.BrushStops.Count == 1)// add gradient { BrushStopModel currentBrushStop = segment.BrushStops[0]; segment.CreateGradientBrushes(segment.BrushStops[0], newBrushStop); @@ -1175,7 +1147,7 @@ namespace Tango.PPC.Jobs.ViewModels else //Create new Segment and Add BrushStop { await NotificationProvider.ShowInfo("Please note that gradient segment is now split into two gradients."); - + SegmentModel newSegmentModel = segment.Clone(); var length = segment.Length / 2; newSegmentModel.Length = length; @@ -1220,57 +1192,23 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Starts a sample dye. /// </summary> - private async void StartSampleDye() - { - try - { - LogManager.Log("Sample dye command pressed..."); - - await PrintingManager.PrintSample(Job, _db); - - await NavigationManager.NavigateTo<JobsV2Module>(nameof(JobProgressView)); - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error executing sample dye for job {Job.Name}."); - await NotificationProvider.ShowError(ex.Message); - } - } - - /// <summary> - /// Sets the job status back to not approved. - /// </summary> - private void RepeatSampleDye() - { - LogManager.Log("Repeat sample dye command pressed..."); - Job.JobEditingState = BL.Enumerations.EditingStates.Default; - Job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.Unspecified; - } - - /// <summary> - /// Approves the sample dye. - /// </summary> - private void ApproveSampleDye() - { - LogManager.Log("Approve sample dye command pressed..."); - - Job.JobEditingState = BL.Enumerations.EditingStates.Default; - Job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.Approved; + //private async void StartSampleDye() + //{ + // try + // { + // LogManager.Log("Sample dye command pressed..."); - Job.SampleDyeApproveDate = DateTime.UtcNow; - SaveJob(false); - } + // await PrintingManager.PrintSample(Job, _db); - /// <summary> - /// Dyes another sample. - /// </summary> - private void DyeAnotherSample() - { - LogManager.Log("Dye another sample dye command pressed..."); + // await NavigationManager.NavigateTo<JobsV2Module>(nameof(JobProgressView)); + // } + // catch (Exception ex) + // { + // LogManager.Log(ex, $"Error executing sample dye for job {Job.Name}."); + // await NotificationProvider.ShowError(ex.Message); + // } + //} - Job.JobEditingState = BL.Enumerations.EditingStates.Default; - Job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.Unspecified; - } #endregion @@ -1279,167 +1217,78 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Synchronizes the fine tune items to brush stops. /// </summary> - private async void SyncFineTuneItemsToBrushStops(bool displayBusy = false) - { - try - { - if (Job != null) - { - if (_jobs_fine_tune_items.ContainsKey(Job.Guid)) - { - FineTuneItems = _jobs_fine_tune_items[Job.Guid].ToObservableCollection(); - } - else - { - if (displayBusy) - { - NotificationProvider.SetGlobalBusyMessage("Generating suggestions..."); - } - - FineTuneItems.Clear(); - - foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent).Where(x => x.ColorSpace.Space == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace.Space == BL.Enumerations.ColorSpaces.LAB).DistinctBy(x => x.Color)) - { - var conversionoutput = await _converter.ConvertAsync(stop, true); - FineTuneItem item = new FineTuneItem(conversionoutput); - item.BrushStop = stop; - item.BrushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.Color == stop.Color).ToList(); - item.SelectedSuggestion = item.Suggestions.GetCenterSuggestion(); - item.SelectedChanged += () => StartFineTuningCommand.RaiseCanExecuteChanged(); - FineTuneItems.Add(item); - } - - _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); + //private async void SyncFineTuneItemsToBrushStops(bool displayBusy = false) + //{ + // try + // { + // if (Job != null) + // { + // if (_jobs_fine_tune_items.ContainsKey(Job.Guid)) + // { + // FineTuneItems = _jobs_fine_tune_items[Job.Guid].ToObservableCollection(); + // } + // else + // { + // if (displayBusy) + // { + // NotificationProvider.SetGlobalBusyMessage("Generating suggestions..."); + // } - NotificationProvider.ReleaseGlobalBusyMessage(); - } + // FineTuneItems.Clear(); - ApprovalFineTuneItems = FineTuneItems.Where(x => x.IsSelected).ToObservableCollection(); + // foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent).Where(x => x.ColorSpace.Space == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace.Space == BL.Enumerations.ColorSpaces.LAB).DistinctBy(x => x.Color)) + // { + // var conversionoutput = await _converter.ConvertAsync(stop, true); + // FineTuneItem item = new FineTuneItem(conversionoutput); + // item.BrushStop = stop; + // item.BrushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.Color == stop.Color).ToList(); + // item.SelectedSuggestion = item.Suggestions.GetCenterSuggestion(); + // item.SelectedChanged += () => StartFineTuningCommand.RaiseCanExecuteChanged(); + // FineTuneItems.Add(item); + // } - StartFineTuningCommand.RaiseCanExecuteChanged(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error while trying to synchronize fine tuning items with brush stops."); - } - finally - { - NotificationProvider.ReleaseGlobalBusyMessage(); - } - } + // _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); - /// <summary> - /// Invokes the fine tuning palette dialog. - /// </summary> - /// <param name="fineTuneItem">The fine tune item.</param> - private async void InvokeFineTuningPalette(FineTuneItem fineTuneItem) - { - LogManager.Log("Invoke fine tuning palette command pressed..."); + // NotificationProvider.ReleaseGlobalBusyMessage(); + // } - try - { - FineTuningPaletteViewVM vm = new FineTuningPaletteViewVM(fineTuneItem, Job); - await NotificationProvider.ShowDialog(vm); + // ApprovalFineTuneItems = FineTuneItems.Where(x => x.IsSelected).ToObservableCollection(); - if (vm.DialogResult) - { - fineTuneItem.Suggestions = vm.Suggestions; - fineTuneItem.SelectedSuggestion = vm.SelectedSuggestion; - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error invoking the fine tunning palette"); - await NotificationProvider.ShowError("An error occurred while trying to display the fine tunning palette."); - } - finally - { - NotificationProvider.ReleaseGlobalBusyMessage(); - } - } - - /// <summary> - /// Resets the fine tuning. - /// </summary> - private void ResetFineTuning(bool displayBusy = false) - { - if (Job != null && _jobs_fine_tune_items.ContainsKey(Job.Guid)) - { - _jobs_fine_tune_items.Remove(Job.Guid); - } - - SyncFineTuneItemsToBrushStops(displayBusy); - } + // StartFineTuningCommand.RaiseCanExecuteChanged(); + // } + // } + // catch (Exception ex) + // { + // LogManager.Log(ex, "Error while trying to synchronize fine tuning items with brush stops."); + // } + // finally + // { + // NotificationProvider.ReleaseGlobalBusyMessage(); + // } + //} /// <summary> /// Starts the fine tuning. /// </summary> - private async void StartFineTuning() - { - try - { - LogManager.Log("Start fine tunning job command pressed..."); - - _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); - - await PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); - - await NavigationManager.NavigateTo<JobsV2Module>(nameof(JobProgressView)); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error executing fine tuning job."); - await NotificationProvider.ShowError(ex.Message); - } - } - - /// <summary> - /// Approves the fine tuning. - /// </summary> - private void ApproveFineTuning() - { - LogManager.Log("Approve fine tuning command pressed."); - - Job.JobEditingState = BL.Enumerations.EditingStates.Default; - Job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.Approved; - - foreach (var item in ApprovalFineTuneItems) - { - foreach (var stop in item.BrushStops) - { - stop.Color = item.SelectedSuggestion.Color; - } - } - - - Job.FineTuningApproveDate = DateTime.UtcNow; - SaveJob(false); - - if (_jobs_fine_tune_items.ContainsKey(Job.Guid)) - { - _jobs_fine_tune_items.Remove(Job.Guid); - } - - SyncFineTuneItemsToBrushStops(); - } - - /// <summary> - /// Repeats the fine tuning. - /// </summary> - private void RepeatFineTuning() - { - LogManager.Log("Repeat fine tuning command pressed."); + //private async void StartFineTuning() + //{ + // try + // { + // LogManager.Log("Start fine tunning job command pressed..."); - Job.JobEditingState = BL.Enumerations.EditingStates.Default; - Job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.Unspecified; - } + // _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); - #endregion + // await PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); - #region Out Of Gamut Check Thread + // await NavigationManager.NavigateTo<JobsV2Module>(nameof(JobProgressView)); + // } + // catch (Exception ex) + // { + // LogManager.Log(ex, "Error executing fine tuning job."); + // await NotificationProvider.ShowError(ex.Message); + // } + //} - #endregion #region Lubrication Level @@ -1598,7 +1447,7 @@ namespace Tango.PPC.Jobs.ViewModels #endregion #region collapsed mode - + private void JobModeSwitch() { IsFullMode = !IsFullMode; @@ -1613,7 +1462,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (false == JobModel.Segments.ToList().Any(x => x.IsSelected)) return; - + for (int firstIndex = 0, lastIndex = JobModel.Segments.Count - 1; firstIndex < lastIndex; firstIndex++) { if (JobModel.Segments[firstIndex].IsSelected) @@ -1633,7 +1482,7 @@ namespace Tango.PPC.Jobs.ViewModels private async void DeleteSegment() { if (false == JobModel.Segments.ToList().Any(x => x.IsSelected)) - return; + return; if (JobModel.Segments.Count > 1) { @@ -1641,7 +1490,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (await NotificationProvider.ShowQuestion("Are you sure you want to remove these selected segments?")) { - foreach( var segment in JobModel.Segments.Where(i => i.IsSelected).ToList()) + foreach (var segment in JobModel.Segments.Where(i => i.IsSelected).ToList()) { JobModel.Segments.Remove(segment); } @@ -1663,7 +1512,7 @@ namespace Tango.PPC.Jobs.ViewModels private void RepeateSegment() { - + } private void Paste() @@ -1693,75 +1542,79 @@ namespace Tango.PPC.Jobs.ViewModels { if (JobModel == null) return; - var colorSpaces = await _db.ColorSpaces.ToListAsync(); + var colorSpaces = await _db.ColorSpaces.ToListAsync(); - Job.ColorSpace = colorSpaces.FirstOrDefault(); + Job.ColorSpace = colorSpaces.FirstOrDefault(); + Job.Version = 2; - var oldSegments = Job.Segments.ToList(); + var oldSegments = Job.Segments.ToList(); - foreach (var segment in Job.Segments.ToList()) + foreach (var segment in Job.Segments.ToList()) + { + segment.BrushStops.ToList().ForEach(x => { - foreach (var stop in segment.BrushStops.ToList()) - { - _db.BrushStops.Remove(stop); - } + _db.BrushStops.Remove(x); + }); - _db.Segments.Remove(segment); - } + _db.Segments.Remove(segment); + } - Job.Segments.Clear(); - - foreach (var segment in JobModel.Segments.OrderBy(x => x.SegmentIndex).ToList()) - { - var dbSegment = new Segment(); - dbSegment.Name = "Standard Segment"; - - dbSegment.Job = Job; - dbSegment.SegmentIndex = segment.SegmentIndex; - dbSegment.Length = segment.Length; + Job.Segments.Clear(); - _db.Segments.Add(dbSegment); + foreach (var segment in JobModel.Segments.OrderBy(x => x.SegmentIndex).ToList()) + { + var dbSegment = new Segment(); + dbSegment.Guid = System.Guid.NewGuid().ToString(); + dbSegment.Name = "Standard Segment"; - foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).ToList()) - { - var dbStop = new BrushStop(); - dbStop.Segment = dbSegment; - _db.BrushStops.Add(dbStop); + dbSegment.Job = Job; + dbSegment.SegmentIndex = segment.SegmentIndex; + dbSegment.Length = segment.Length; - dbStop.ColorSpace = colorSpaces.FirstOrDefault(x => x.Code == (int)stop.ColorSpace); - dbStop.Red = stop.Red; - dbStop.Green = stop.Green; - dbStop.Blue = stop.Blue; - dbStop.L = stop.L; - dbStop.A = stop.A; - dbStop.B = stop.B; - dbStop.Cyan = stop.Cyan; - dbStop.Magenta = stop.Magenta; - dbStop.Yellow = stop.Yellow; - dbStop.Black = stop.Black; - dbStop.BestMatchR = stop.DisplayedColor.R; - dbStop.BestMatchG = stop.DisplayedColor.G; - dbStop.BestMatchB = stop.DisplayedColor.B; - - dbStop.OffsetPercent = stop.OffsetPercent; - dbStop.StopIndex = stop.StopIndex; - dbStop.IsOutOfGamut = stop.IsOutOfGamut; + _db.Segments.Add(dbSegment); - - dbStop.SetVolume(LiquidTypes.Cyan, stop.Cyan); - dbStop.SetVolume(LiquidTypes.Magenta, stop.Magenta); - dbStop.SetVolume(LiquidTypes.Yellow, stop.Yellow); - dbStop.SetVolume(LiquidTypes.Black, stop.Black); - } + foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).ToList()) + { + var dbStop = new BrushStop(); + dbStop.Segment = dbSegment; + _db.BrushStops.Add(dbStop); + + dbStop.ColorSpace = colorSpaces.FirstOrDefault(x => x.Code == (int)stop.ColorSpace); + dbStop.Red = stop.Red; + dbStop.Green = stop.Green; + dbStop.Blue = stop.Blue; + dbStop.L = stop.L; + dbStop.A = stop.A; + dbStop.B = stop.B; + dbStop.Cyan = stop.Cyan; + dbStop.Magenta = stop.Magenta; + dbStop.Yellow = stop.Yellow; + dbStop.Black = stop.Black; + dbStop.BestMatchR = stop.DisplayedColor.R; + dbStop.BestMatchG = stop.DisplayedColor.G; + dbStop.BestMatchB = stop.DisplayedColor.B; + + dbStop.OffsetPercent = stop.OffsetPercent; + dbStop.StopIndex = stop.StopIndex; + dbStop.IsOutOfGamut = stop.IsOutOfGamut; + + dbStop.SetVolume(LiquidTypes.Cyan, stop.Cyan); + dbStop.SetVolume(LiquidTypes.Magenta, stop.Magenta); + dbStop.SetVolume(LiquidTypes.Yellow, stop.Yellow); + dbStop.SetVolume(LiquidTypes.Black, stop.Black); + + dbStop.ColorCatalog = stop.ColorCatalog; + dbStop.ColorCatalogsItem = stop.ColorCatalogsItem; } - Job.LastUpdated = DateTime.UtcNow; - Job.IsSynchronized = false; - Job.JobStatus = BL.Enumerations.JobStatuses.Draft; - //_current_job_string = Job.ToJobFileWhenLoaded().ToString(); - RaiseMessage(new JobSavedMessage() { Job = Job }); - - await _db.SaveChangesAsync(); - + } + Job.LastUpdated = DateTime.UtcNow; + Job.IsSynchronized = false; + Job.JobStatus = BL.Enumerations.JobStatuses.Draft; + //_current_job_string = Job.ToJobFileWhenLoaded().ToString(); + RaiseMessage(new JobSavedMessage() { Job = Job }); + + await _db.SaveChangesAsync(); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml index 4b12a003e..6d867c2b5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -144,6 +144,23 @@ </UniformGrid> </DataTemplate> + <DataTemplate x:Key="CATALOG_Template" DataType="{x:Type entities:BrushStop}"> + <UniformGrid Rows="1" Columns="2" Height="30" MinWidth="150"> + <StackPanel Orientation="Horizontal" Margin="10 0 0 0"> + <TextBlock Text="Catalog:" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> + <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" MinWidth="42" MaxWidth="130"> + <TextBlock Padding="4 0 4 0" FontSize="{StaticResource TangoSmallFontSize}" Text="{Binding ColorCatalog.Name}" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> + </Border> + </StackPanel> + <StackPanel Orientation="Horizontal" Margin="10 0 0 0"> + <TextBlock Text="Color:" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> + <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" MinWidth="42"> + <TextBlock Padding="4 0 4 0" FontSize="{StaticResource TangoSmallFontSize}" Text="{Binding ColorCatalogsItem.Name}" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> + </Border> + </StackPanel> + </UniformGrid> + </DataTemplate> + <DataTemplate x:Key="Segment_Template" DataType="{x:Type entities:Segment}"> <Grid Height="430" Margin="57 15 57 0"> <Grid.RowDefinitions> @@ -247,6 +264,9 @@ <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="LAB"> <Setter Property="ContentTemplate" Value="{StaticResource LAB_Template}" /> </DataTrigger> + <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="Catalog"> + <Setter Property="ContentTemplate" Value="{StaticResource CATALOG_Template}" /> + </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> @@ -275,6 +295,9 @@ <DataTrigger Binding="{Binding SecondBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="LAB"> <Setter Property="ContentTemplate" Value="{StaticResource LAB_Template}" /> </DataTrigger> + <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="Catalog"> + <Setter Property="ContentTemplate" Value="{StaticResource CATALOG_Template}" /> + </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> @@ -311,10 +334,11 @@ </Border> <DockPanel Margin="0 20 0 0" Grid.Row="1"> + <Grid Visibility="Collapsed"> <touch:TouchButton x:Name="deletegap" DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding DeleteGapCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityConverter}}"> <TextBlock Margin="10 2 0 0" FontSize="{StaticResource TangoButtonFontSize}" VerticalAlignment="Center">Delete Gap</TextBlock> </touch:TouchButton> - <touch:TouchButton x:Name="addGap" DockPanel.Dock="Right" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding AddGapCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <touch:TouchButton x:Name="addGap" DockPanel.Dock="Right" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding AddGapCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityInverseConverter}}"> <StackPanel Orientation="Horizontal"> <Border Height="35" Width="35" BorderThickness="0" Background="Transparent" HorizontalAlignment="Left"> <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/add_gap.png"/> @@ -322,6 +346,7 @@ <TextBlock Margin="10 2 0 0" FontSize="{StaticResource TangoButtonFontSize}" VerticalAlignment="Center">Add Gap</TextBlock> </StackPanel> </touch:TouchButton> + </Grid> <touch:TouchButton DockPanel.Dock="Left" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding DataContext.AddNewSegmentCommand, ElementName=listSegments}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0"> <StackPanel Orientation="Horizontal"> <Border Height="35" Width="35" BorderThickness="0" Background="Transparent" HorizontalAlignment="Left"> @@ -463,11 +488,11 @@ <DropShadowEffect Opacity="0.5" ShadowDepth="6" Color="Silver" BlurRadius="10" Direction="270"/> </Border.Effect> <UniformGrid Columns="6" Rows="1" DockPanel.Dock="Left" HorizontalAlignment="Stretch" > - <touch:TouchButton Margin="0 0 0 0" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding InsertWhiteGapCommand}" > + <touch:TouchButton Margin="0 0 0 0" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding RepeateSegmentCommand}" > <Border Padding="4" BorderThickness="0" Background="Transparent" HorizontalAlignment="Left"> <StackPanel Orientation="Vertical" VerticalAlignment="Center"> - <Image Width="20" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/white_gap.png"/> - <TextBlock FontWeight="Medium" Margin="0 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource TangoSmallFontSizeBar}" Foreground="{StaticResource TangoMidAccentBrush}">WG</TextBlock> + <Image Width="20" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/repeat.png"/> + <TextBlock FontWeight="Medium" Margin="0 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource TangoSmallFontSizeBar}" Foreground="{StaticResource TangoMidAccentBrush}">Repeat</TextBlock> </StackPanel> </Border> </touch:TouchButton> @@ -562,14 +587,14 @@ <!--Border x:Name="borderDockFloat" Height="10" Margin="0 0 0 0" BorderBrush="Transparent" > <DockPanel x:Name="dockEdit" LastChildFill="False" Height="10" Width="50" HorizontalAlignment="Right" RenderTransformOrigin="0.58,2.08"/> </Border> --> - <ListBox x:Name="listSegments" Margin="10 0 10 0" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource Segment_Template}" Style="{StaticResource SegmentsListBox}" + <ListBox x:Name="listSegments" Margin="10 0 10 40" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource Segment_Template}" Style="{StaticResource SegmentsListBox}" ScrollViewer.VerticalScrollBarVisibility="Visible" Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityConverter}}" /> <ListBox x:Name="collapsedListSegments" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource CollapsedSegment_Template}" Style="{StaticResource SegmentsListBox}" ScrollViewer.VerticalScrollBarVisibility="Visible" - Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}"/> + Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}" Margin=" 0 0 0 40"/> <!--<StackPanel x:Name="stackOutput" Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"/>--> @@ -594,13 +619,24 @@ <!--<touch:TouchDropShadowBorder Grid.Row="3" Margin="10 0 10 15" CornerRadius="0" BorderThickness="0" Padding="0" >--> <Border Grid.Row="3" Margin="10 0 10 15" BorderThickness="0"> - <touch:TouchExpander Grid.Row="3" Margin="15 0 15 0 " IsExpanded="True" FontSize="{StaticResource TangoTitleFontSize}" BorderThickness="0" Style="{StaticResource TouchRoundedExpander}"> + <touch:TouchExpander x:Name="summaryExpander" IsExpanded="True" Grid.Row="3" Margin="15 0 15 0 " FontSize="{StaticResource TangoTitleFontSize}" BorderThickness="0" Style="{StaticResource TouchRoundedExpander}"> <touch:TouchExpander.Header> <DockPanel > <touch:TouchButton DockPanel.Dock="Right" Margin="0 0 20 0" HorizontalAlignment="Right" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding RepeatUnitsCommand}" > <Border CornerRadius="20" Width="130" Height="40" BorderThickness="1" BorderBrush="{StaticResource TangoDarkForegroundBrush}"> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}">Repeat Job</TextBlock> </Border> + <touch:TouchButton.Style> + <Style TargetType="{x:Type touch:TouchButton}"> + <Setter Property="Visibility" Value="Collapsed"/> + <Style.Triggers> + <DataTrigger Binding="{Binding Path=IsExpanded ,RelativeSource={RelativeSource Mode =FindAncestor,AncestorType={x:Type touch:TouchExpander}}}" Value="True"> + <Setter Property="Visibility" Value="Visible"/> + <Setter Property="Background" Value="red"/> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> </touch:TouchButton> <StackPanel DockPanel.Dock="Left" Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"> <Image Source="../Images/JobView/job-summary.png" Width="39" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml index c4d047d39..7a8b2908d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml @@ -17,9 +17,9 @@ <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> - <touch:LightTouchScrollViewer x:Name="scrollViewer" ScrollBarVisibility="Collapsed"> + <touch:LightTouchScrollViewer x:Name="scrollViewer" ScrollBarVisibility="Collapsed" > <!--<Border Background="White">--> - <local:TwineCatalogRenderer x:Name="renderer" Groups="{Binding ColorCatalogsGroups}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=SelectedItem,Mode=TwoWay}"></local:TwineCatalogRenderer> + <local:TwineCatalogRenderer x:Name="renderer" Groups="{Binding ColorCatalogsGroups}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={ x:Type local:TwineCatalogControl}},Path=SelectedItem,Mode=TwoWay }"></local:TwineCatalogRenderer> <!--</Border>--> </touch:LightTouchScrollViewer> @@ -93,7 +93,7 @@ </touch:TouchListBox.ItemTemplate> </touch:TouchListBox>--> - <Grid Grid.Column="1"> + <Grid Grid.Column="1" Margin="10 60 0 20"> <!--<Rectangle Stroke="{StaticResource TangoDividerBrush}" HorizontalAlignment="Left" />--> <Grid> <Grid.ColumnDefinitions> @@ -130,8 +130,8 @@ </ItemsControl> </Border> - <Grid Grid.Column="1"> - <touch:TouchSlider x:Name="slider" ValueChanged="TouchSlider_ValueChanged" IsSnapToTickEnabled="True" Minimum="0" Maximum="{Binding ColorCatalogsGroups.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-1'}" Orientation="Vertical" Width="40" Height="Auto" IsSelectionRangeEnabled="False"> + <Grid Grid.Column="1" > + <touch:TouchSlider x:Name="slider" ValueChanged="TouchSlider_ValueChanged" IsSnapToTickEnabled="True" Minimum="0" Maximum="{Binding ColorCatalogsGroups.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-1'}" Orientation="Vertical" Width="40" Height="Auto" IsSelectionRangeEnabled="False"> <touch:TouchSlider.ThumbTemplate> <ControlTemplate> <touch:TouchIcon Foreground="{Binding RelativeSource={RelativeSource AncestorType=touch:TouchSlider},Path=Foreground}" Width="40" Height="40" Icon="Water" Angle="-90" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs index 6ef7d92e8..22a0f4825 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.BL.Entities; +using Tango.Touch.Components; using Tango.Touch.Controls; namespace Tango.PPC.Common.Controls @@ -27,6 +28,7 @@ namespace Tango.PPC.Common.Controls private ColorCatalog _catalog; private bool _preventChange; private double _lastScrollPosition = 0; + private bool _findInProcess = false; /// <summary> /// Gets or sets the selected catalog item. @@ -37,7 +39,35 @@ namespace Tango.PPC.Common.Controls set { SetValue(SelectedItemProperty, value); } } public static readonly DependencyProperty SelectedItemProperty = - DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogControl), new PropertyMetadata(null)); + DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnSelectedItemPropertyChanged))); + + + private static void OnSelectedItemPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + TwineCatalogControl twineCatalogControl = (TwineCatalogControl)d; + if(e.OldValue != e.NewValue) + { + twineCatalogControl.SelectedItemPropertyChanged(); + } + } + + /// <summary> + /// Gets or sets the collection filter. + /// </summary> + public ICollectionFilter CollectionFilter + { + get { return (ICollectionFilter)GetValue(CollectionFilterProperty); } + set { SetValue(CollectionFilterProperty, value); } + } + public static readonly DependencyProperty CollectionFilterProperty = + DependencyProperty.Register("CollectionFilter", typeof(ICollectionFilter), typeof(TwineCatalogControl), new PropertyMetadata(null, (d, e) => (d as TwineCatalogControl).OnCollectionFilterChanged())); + + + public void SelectedItemPropertyChanged() + { + // if(renderer.SelectedItem != this.SelectedItem) + // renderer.SelectedItem = this.SelectedItem; + } /// <summary> /// Initializes a new instance of the <see cref="TwineCatalogControl"/> class. @@ -100,7 +130,7 @@ namespace Tango.PPC.Common.Controls if (!_preventChange) { - if (_catalog != null) + if (_catalog != null && scrollViewer != null) { _preventChange = true; var group = _catalog.ColorCatalogsGroupsOrdered.ElementAt(_catalog.ColorCatalogsGroupsOrdered.Count - 1 - (int)e.NewValue); @@ -114,5 +144,27 @@ namespace Tango.PPC.Common.Controls slider.Foreground = new SolidColorBrush(_catalog.ColorCatalogsGroupsOrdered.ElementAt(_catalog.ColorCatalogsGroupsOrdered.Count - 1 - (int)e.NewValue).Color); } } + + private void OnCollectionFilterChanged() + { + if (_findInProcess) + return; + if (CollectionFilter != null) + { + CollectionFilter.FilterChanged -= CollectionFilter_FilterChanged; + CollectionFilter.FilterChanged += CollectionFilter_FilterChanged; + } + } + + private void CollectionFilter_FilterChanged(object sender, EventArgs e) + { + _findInProcess = true; + //if (CollectionFilter != null ) + //{ + // row.Visibility = CollectionFilter.Filter(row.DataContext) ? Visibility.Visible : Visibility.Collapsed; + // display = row.Visibility == Visibility.Visible; + //} + _findInProcess = false; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs index a3b65d17a..1f9a42561 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs @@ -9,6 +9,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Imaging; using Tango.BL.Entities; using Tango.Touch.Controls; @@ -21,6 +22,7 @@ namespace Tango.PPC.Common.Controls public DrawingVisual Visual { get; set; } public ColorCatalogsItem Item { get; set; } public double PositionY { get; set; } + public Rect ImageRect { get; set; } } private class GroupContainer @@ -40,14 +42,19 @@ namespace Tango.PPC.Common.Controls private readonly VisualCollection _children; private List<ItemContainer> _catalogItems; private List<GroupContainer> _groupItems; - private double ellipseWidth = 60; - private double ellipseHeight = 60; - private double textHeight = 30; - private double ellipseMargin = 20; - private double textMargin = 5; - private double groupMargin = 60; + private double ellipseWidth = 70; + private double ellipseHeight = 70; + private double textHeight = 20; + private double ellipseMarginX = 18; + private double ellipseMarginY = 50; + private double textMargin = 8; + private double groupMargin = 50; private bool selectedFromClick; private LightTouchScrollViewer _scrollViewer; + private BitmapSource _myColorBitmap; + private double imageWidth = 24; + private double imageHeight = 22; + private Point _lastMouseClickPoint; public IEnumerable<ColorCatalogsGroup> Groups { @@ -92,6 +99,7 @@ namespace Tango.PPC.Common.Controls this.PreviewMouseUp += TwineCatalogRenderer_MouseLeftButtonUp; this.Loaded += TwineCatalogRenderer_Loaded; + _myColorBitmap = new BitmapImage(new Uri($"pack://application:,,,/Tango.PPC.JobsV2;component/Images/ColorSelection/Heart.png", UriKind.Absolute)); } private void TwineCatalogRenderer_Loaded(object sender, RoutedEventArgs e) @@ -136,12 +144,12 @@ namespace Tango.PPC.Common.Controls { // Retreive the coordinates of the mouse button event. Point pt = e.GetPosition((UIElement)this); - + _lastMouseClickPoint = pt; // Initiate the hit test by setting up a hit test result callback method. VisualTreeHelper.HitTest(this, null, HitTestCallback, new PointHitTestParameters(pt)); } } - + // If a child visual object is hit, toggle its opacity to visually indicate a hit. public HitTestResultBehavior HitTestCallback(HitTestResult result) { @@ -152,9 +160,13 @@ namespace Tango.PPC.Common.Controls if (visual != null) { var container = _catalogItems.SingleOrDefault(x => x.Visual == visual); - + if (container != null && container.Item is ColorCatalogsItem) { + if (container.ImageRect.Contains(_lastMouseClickPoint)) + { + // clicked on image + } selectedFromClick = true; SelectedItem = container.Item; selectedFromClick = false; @@ -176,8 +188,9 @@ namespace Tango.PPC.Common.Controls (newItem.Visual.Transform as ScaleTransform).ScaleX = 1.3; (newItem.Visual.Transform as ScaleTransform).ScaleY = 1.3; - if (!selectedFromClick) + if (!selectedFromClick && _scrollViewer != null) { + _scrollViewer.ScrollToPosition(newItem.PositionY - _scrollViewer.ActualHeight / 2); } } @@ -189,7 +202,7 @@ namespace Tango.PPC.Common.Controls } } - private ItemContainer AddCatalogItem(DrawingVisual visual, ColorCatalogsItem item, double y) + private ItemContainer AddCatalogItem(DrawingVisual visual, ColorCatalogsItem item, double y, Rect imageRect) { _children.Add(visual); @@ -198,6 +211,7 @@ namespace Tango.PPC.Common.Controls Visual = visual, Item = item, PositionY = y, + ImageRect = imageRect }; _catalogItems.Add(container); @@ -238,40 +252,49 @@ namespace Tango.PPC.Common.Controls var groupContainer = AddGroupItem(CreateGroup(group.Name, position_y), group, position_y); - position_y += ellipseMargin; + position_y += ellipseMarginX; foreach (var item in group.ColorCatalogsItems.OrderBy(x => x.ItemIndex)) { - double x = position_x + ellipseMargin; + double x = position_x + ellipseMarginX; if (x + ellipseWidth > ActualWidth) { position_x = 0; - position_y += (ellipseHeight + ellipseMargin + textMargin + textHeight); + position_y += (ellipseHeight + ellipseMarginY + textMargin + textHeight); } - - var itemContainer = AddCatalogItem(CreateItem(item, position_x + ellipseMargin, position_y + ellipseMargin), item, position_y + ellipseMargin); + Rect imageRect = new Rect(new Point(position_x + ellipseWidth, position_y + ellipseMarginY/2 + 2), new Size( imageWidth, imageHeight)); + var itemContainer = AddCatalogItem(CreateItem(item, position_x + ellipseMarginX, position_y + ellipseMarginY, imageRect), item, position_y + ellipseMarginY, imageRect); groupContainer.Items.Add(itemContainer); - position_x += ellipseWidth + ellipseMargin; + position_x += ellipseWidth + ellipseMarginX; } - position_y += (ellipseHeight + ellipseMargin + textMargin + textHeight + groupMargin); + position_y += (ellipseHeight + ellipseMarginY + textMargin + textHeight + groupMargin); } Height = position_y; } + + UpdateLayout(); + if (SelectedItem != null) + { + OnSelectedItemChanged( null, SelectedItem); + } + //InvalidateVisual(); } - private DrawingVisual CreateItem(ColorCatalogsItem item, double x, double y) + private DrawingVisual CreateItem(ColorCatalogsItem item, double x, double y, Rect imageRect) { DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); + + drawingContext.DrawImage(_myColorBitmap, imageRect); drawingContext.DrawEllipse(new SolidColorBrush(item.Color), null, new Point(x + ellipseWidth / 2, y + ellipseHeight / 2), ellipseWidth / 2, ellipseHeight / 2); - + var formattedText = new FormattedText(item.Name, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, @@ -279,7 +302,7 @@ namespace Tango.PPC.Common.Controls 16, Foreground); - formattedText.MaxTextWidth = ellipseWidth + ellipseMargin; + formattedText.MaxTextWidth = ellipseWidth + ellipseMarginX; drawingContext.DrawText(formattedText, new Point((x + (ellipseWidth / 2)) - (formattedText.Width / 2), y + ellipseHeight + textMargin)); @@ -313,12 +336,13 @@ namespace Tango.PPC.Common.Controls CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Flexo"), - 25, + 23, Foreground); //formattedText.SetFontWeight(FontWeights.SemiBold); - drawingContext.DrawText(formattedText, new Point((ActualWidth / 2) - (formattedText.Width / 2), y)); + // drawingContext.DrawText(formattedText, new Point((ActualWidth / 2) - (formattedText.Width / 2), y)); + drawingContext.DrawText(formattedText, new Point(ellipseMarginX, y)); drawingContext.Close(); @@ -338,5 +362,6 @@ namespace Tango.PPC.Common.Controls return _children[index]; } + } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index 2081e7c14..89ce78b16 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -177,6 +177,32 @@ namespace Tango.BL.Entities { get { + byte r = 0; + byte g = 0; + byte b = 0; + + if (Segment != null && Segment.Job != null) + { + if (Segment.Job.Version < 2) + { + r = (byte)Red; + g = (byte)Green; + b = (byte)Blue; + } + else + { + r = (byte)BestMatchR; + g = (byte)BestMatchG; + b = (byte)BestMatchB; + } + } + else + { + r = (byte)Red; + g = (byte)Green; + b = (byte)Blue; + } + if (ColorSpace != null && BrushColorSpace == ColorSpaces.Catalog) { if (ColorCatalogsItem != null) @@ -185,12 +211,12 @@ namespace Tango.BL.Entities } else { - return Color.FromRgb((byte)_bestmatchr, (byte)_bestmatchg, (byte)_bestmatchb); + return Color.FromRgb(r, g, b); } } else { - return Color.FromRgb((byte)_bestmatchr, (byte)_bestmatchg, (byte)_bestmatchb); + return Color.FromRgb(r, g, b); } } set @@ -789,6 +815,46 @@ namespace Tango.BL.Entities return cloned; } + public BrushStop CloneBrush() + { + //BrushStop cloned = new BrushStop(); + BrushStop cloned = base.Clone(); + cloned.StopIndex = StopIndex; + cloned.ColorSpace = this.ColorSpace; + cloned.Red = this.Red; + cloned.Green = this.Green; + cloned.Blue = this.Blue; + cloned.L = this.L; + cloned.A = this.A; + cloned.B = this.B; + cloned.Cyan = this.Cyan; + cloned.Magenta = this.Magenta; + cloned.Yellow = this.Yellow; + cloned.Black = this.Black; + cloned.Color = this.Color; + cloned.BestMatchR = this.BestMatchR; + cloned.BestMatchG = this.BestMatchG; + cloned.BestMatchB = this.BestMatchB; + + + cloned.ColorCatalogGuid = this.ColorCatalogGuid; + cloned.ColorCatalogsItem = this.ColorCatalogsItem; + cloned.ColorSpace = this.ColorSpace; + cloned.OffsetMeters = this.OffsetMeters; + cloned.OffsetPercent = this.OffsetPercent; + cloned.IsOutOfGamut = this.IsOutOfGamut; + cloned.OutOfGamutChecked = this.OutOfGamutChecked; + cloned.IsTransparent = this.IsTransparent; + cloned.Segment = this.Segment; + cloned.Corrected = this.Corrected; + if (LiquidVolumes != null && LiquidVolumes.Count > 0) + { + cloned.LiquidVolumes = LiquidVolumes.Select(x => x.Clone(cloned)).ToObservableCollection(); + } + + return cloned; + } + /// <summary> /// Creates a cloned version of this brush stop including all its liquid volumes. /// </summary> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs index 1993e8cae..137ef6e42 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs @@ -144,14 +144,16 @@ namespace Tango.Touch.Controls if (CurrentComboBox != null) { await Task.Delay(100); - - if (CurrentComboBox.SelectedItem != null) - { - _combobox_list.ScrollToItem(CurrentComboBox.SelectedItem); - } - else + if (CurrentComboBox != null) { - _combobox_list.ScrollViewer.ScrollToTop(); + if (CurrentComboBox.SelectedItem != null) + { + _combobox_list.ScrollToItem(CurrentComboBox.SelectedItem); + } + else + { + _combobox_list.ScrollViewer.ScrollToTop(); + } } } } |
