aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2022-02-08 12:48:14 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2022-02-08 12:48:14 +0200
commit199aa2eb46bf1625d0bbc8b98efe35d158cff9be (patch)
tree28393fc49d347530a4e36777ec0bec9ea47b7bdd /Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs
parentb10afe316e91d0600cd1f668f86767883cce4bb9 (diff)
downloadTango-199aa2eb46bf1625d0bbc8b98efe35d158cff9be.tar.gz
Tango-199aa2eb46bf1625d0bbc8b98efe35d158cff9be.zip
Implement MyColors in PPC
Related Work Items: #4558
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml176
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs389
2 files changed, 501 insertions, 64 deletions
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 abe89b0d7..7880e8639 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
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Tango.PPC.Jobs.Dialogs"
xmlns:vm="clr-namespace:Tango.PPC.Jobs.Dialogs"
+ xmlns:models="clr-namespace:Tango.PPC.Jobs.Models"
xmlns:controls="clr-namespace:Tango.PPC.Jobs.Controls"
xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
@@ -14,9 +15,8 @@
mc:Ignorable="d"
Background="{StaticResource TangoMidBackgroundBrush}"
d:DesignHeight="1280" d:DesignWidth="800" Width="750" Height="1200"
- d:DataContext="{d:DesignInstance Type=vm:ColorSelectionViewVM, IsDesignTimeCreatable=False}">
+ d:DataContext="{d:DesignInstance Type=vm:ColorSelectionViewVM, IsDesignTimeCreatable=False}" x:Name="colorSelectionView">
<UserControl.Resources>
-
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/Styles.xaml" />
@@ -26,6 +26,32 @@
<sharedConverters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<sharedConverters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" />
<sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter"/>
+ <BitmapImage x:Key="Close_mycolorsdlg" UriSource="../Images/ColorSelection/close_mycolorsdlg.png" />
+ <BitmapImage x:Key="Add_group_mycolors" UriSource="../Images/ColorSelection/add_group.png" />
+
+ <Style TargetType="{x:Type ListBox}" x:Key="ListBoxVerticalScroll" BasedOn="{StaticResource BlankListBox}">
+ <Setter Property="BorderThickness" Value="0"></Setter>
+ <Setter Property="VirtualizingPanel.ScrollUnit" Value="Pixel"></Setter>
+ <Setter Property="ItemsPanel">
+ <Setter.Value>
+ <ItemsPanelTemplate>
+ <VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel" />
+ </ItemsPanelTemplate>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type ListBox}">
+ <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
+ <touch:TouchScrollViewer CanContentScroll="True" Padding="{TemplateBinding Padding}" Focusable="False"
+ Style="{StaticResource TouchVerticalScrollViewer}">
+ <ItemsPresenter />
+ </touch:TouchScrollViewer>
+ </Border>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
<DataTemplate x:Key="brushColorPanel">
<Grid Height="180" Margin="93 10 0 0" HorizontalAlignment="Stretch">
@@ -109,17 +135,17 @@
</Grid>
<Canvas Grid.Column="1" Width="28" Height="28" VerticalAlignment="Top" HorizontalAlignment="Left">
- <touch:TouchButton Canvas.Left="0" Canvas.Top="0" x:Name="addmyColors" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0">
+ <touch:TouchToggleButton Canvas.Left="0" Canvas.Top="0" x:Name="addColorToGroup" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Command="{Binding SaveMyColorsCommand}">
<Border Height="26" Width="28" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left">
<Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/ColorSelection/Heart.png"/>
</Border>
- </touch:TouchButton>
+ </touch:TouchToggleButton>
</Canvas>
</Grid>
</DataTemplate>
<DataTemplate x:Key="myColorsBtn">
- <touch:TouchButton x:Name="myColors" Margin="40 2 0 0" HorizontalAlignment="Left" FontWeight="Normal" FontSize="{StaticResource TangoDefaultFontSize}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Padding="10" Background="Transparent" BorderThickness="0">
+ <touch:TouchButton x:Name="myColors" Margin="40 2 0 0" HorizontalAlignment="Left" FontWeight="Normal" FontSize="{StaticResource TangoDefaultFontSize}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Padding="10" Background="Transparent" BorderThickness="0" Command="{Binding OpenMyColorsCommand}">
<Border Height="48" Width="160" CornerRadius="24" BorderThickness="0.8" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<Image Margin="14 0 0 0" Stretch="Fill" Width="18" Height="17" RenderOptions.BitmapScalingMode="Fant" Source="../Images/ColorSelection/Red_heart.png"></Image>
@@ -159,6 +185,92 @@
</Grid>
</Grid>
</DataTemplate>
+
+ <DataTemplate x:Key="ColorLibrary_Template" DataType="{x:Type models:ColorLibrary}">
+ <DockPanel Margin="40 0 20 20">
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Visibility="{Binding EditColorsGroupMode , Converter={StaticResource BooleanToVisibilityInverseConverter}}">
+ <TextBlock Text="{Binding Name}" Height="30" Margin="0 10 0 0" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Foreground="{StaticResource TangoBlackInkBrush}" ></TextBlock>
+ <touch:TouchIconButton Margin="20 0 0 0" VerticalAlignment="Center" Foreground="{StaticResource TangoBlackInkBrush}" Height="16.5" Icon="PencilAltSolid" Command="{Binding DataContext.EditColorsLibraryCommand, ElementName=colorSelectionView}" CommandParameter="{Binding }" />
+ </StackPanel>
+ <DockPanel DockPanel.Dock="Top" Visibility="{Binding EditColorsGroupMode , Converter={StaticResource BooleanToVisibilityConverter}}">
+ <touch:TouchIconButton DockPanel.Dock="Right" Icon="TrashAltRegular" Width="16" Height="16.5" Margin="0 0 35 1" EnableDropShadow="False" Foreground="{StaticResource TangoBlackInkBrush}" Command="{Binding DataContext.DeleteGroupCommand , ElementName=colorSelectionView}" />
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
+ <touch:TouchTextBox Text="{Binding Name}" MinWidth="100" Margin="0 0 0 0" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Foreground="{StaticResource TangoBlackInkBrush}" ></touch:TouchTextBox>
+ <touch:TouchIconButton Margin="20 0 0 0" VerticalAlignment="Center" Foreground="{StaticResource TangoPrimaryAccentBrush}" Height="16.5" Icon="PencilAltSolid" Command="{Binding DataContext.EditColorsLibraryCommand, ElementName=colorSelectionView}" CommandParameter="{Binding }" />
+ </StackPanel>
+ </DockPanel>
+ <Rectangle DockPanel.Dock="Bottom" Margin="0 10 0 0" Height="1" Stroke="{StaticResource TangoDividerBrush}" VerticalAlignment="Bottom" />
+ <ItemsControl Margin="0 12 0 0" x:Name="colorLibraryList" Width="580" DockPanel.Dock="Bottom" Height="Auto" Background="Transparent" ItemsSource="{Binding ColorList}" ScrollViewer.HorizontalScrollBarVisibility="Visible" BorderThickness="0" Padding="0" ScrollViewer.VerticalScrollBarVisibility="Hidden">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <WrapPanel Orientation="Horizontal" />
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate DataType="{ x:Type models:FavoriteColor}">
+ <Grid Margin="0 0 34 0" HorizontalAlignment="Left" VerticalAlignment="Top">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="65"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+ <Border Background="{Binding Brush}" Width="65" Height="65" CornerRadius="10" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" HorizontalAlignment="Left" Visibility="{Binding DataContext.EditColorsGroupMode , ElementName=colorLibraryList , Converter={StaticResource BooleanToVisibilityInverseConverter}}">
+ <touch:TouchButton Width="65" Height="65" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding DataContext.SelectColorCommand , ElementName=colorSelectionView}" CommandParameter="{Binding }" />
+ </Border>
+ <Border Background="{Binding Brush}" Width="65" Height="65" CornerRadius="10" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" BorderThickness="2" HorizontalAlignment="Left" Visibility="{Binding DataContext.EditColorsGroupMode , ElementName=colorLibraryList, Converter={StaticResource BooleanToVisibilityConverter}}">
+ <touch:TouchButton Width="65" Height="65" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding DataContext.DeleteColorCommand , ElementName=colorSelectionView}" CommandParameter="{Binding }" >
+ <Border Height="26" Width="28" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left">
+ <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/ColorSelection/delete_color.png" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+ </Border>
+ </touch:TouchButton>
+ </Border>
+ <!--<Border Background="{Binding Color}" Width="65" Height="65" CornerRadius="6"></Border>-->
+ <TextBlock Grid.Row="1" Margin="3 12 0 10" MaxWidth="70" Text="{Binding Name}" FontSize="{StaticResource TangoSmallFontSizeBar}"></TextBlock>
+ </Grid>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+
+ </DockPanel>
+ </DataTemplate>
+
+ <DataTemplate x:Key="saveMyColorsDlg">
+ <Canvas Margin="200 50 100 0" Visibility="{Binding SaveMyColorMode, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}}" >
+ <Border x:Name="LABPopupGroups" Width="280" Background="Transparent" Height="Auto" MinHeight="100" MaxHeight="450">
+ <Grid MinWidth="260" >
+ <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="12" BorderThickness="0" Padding="10" MinHeight="100">
+ <Border.Effect>
+ <DropShadowEffect Opacity="0.5" ShadowDepth="6" Color="Silver" BlurRadius="10" Direction="270"/>
+ </Border.Effect>
+ <StackPanel Orientation="Vertical">
+ <ListBox HorizontalAlignment="Stretch" MaxHeight="350" Margin="14 10 14 10" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}"
+ ScrollViewer.VerticalScrollBarVisibility="Visible" >
+ <ListBox.ItemsPanel>
+ <ItemsPanelTemplate>
+ <WrapPanel Orientation="Vertical" />
+ </ItemsPanelTemplate>
+ </ListBox.ItemsPanel>
+ <ListBox.ItemTemplate>
+ <DataTemplate DataType="{x:Type models:ColorLibrary}">
+ <touch:TouchButton Command="{Binding DataContext.AddColorToLibraryCommand, ElementName=colorSelectionView}" Style="{StaticResource TangoFlatButton}" CommandParameter="{Binding }" Background="Transparent">
+ <TextBlock Text="{Binding Name}" FontSize="{StaticResource TangoButtonFontSize}"></TextBlock>
+ </touch:TouchButton>
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
+ <Rectangle Height="1" HorizontalAlignment="Stretch" Fill="{StaticResource TangoDividerBrush}"></Rectangle>
+ <StackPanel Orientation="Horizontal" Height="60" Margin="20 10 0 0">
+ <touch:TouchTextBox x:Name="LABnewGroup" FontSize="{StaticResource TangoButtonFontSize}" Width="180" VerticalAlignment="Top" HorizontalAlignment="Left" Text="{Binding NewGroupName, Mode=TwoWay,UpdateSourceTrigger=LostFocus}"></touch:TouchTextBox>
+ <touch:TouchButton Background="Transparent" Style="{StaticResource TangoFlatButton}" Command="{Binding AddNewGroupAndColorCommand}" CommandParameter="{Binding ElementName=LABnewGroup, Path=Text}" HorizontalAlignment="Right" Content="OK" Margin="20 0 0 0">
+ </touch:TouchButton>
+ </StackPanel>
+ </StackPanel>
+ </Border>
+ </Grid>
+ </Border>
+ </Canvas>
+ </DataTemplate>
+
+
</ResourceDictionary>
</UserControl.Resources>
<Grid HorizontalAlignment="Stretch">
@@ -238,8 +350,6 @@
</touch:TouchNavigationLinks>
<Grid Grid.Row="1" x:Name="HSBGrid" >
-
-
<Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='HSB'}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -253,13 +363,12 @@
<ContentControl Name="segmentContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/>
<Grid Grid.Row="2" Margin="80 0 93 0">
-
<touch:TouchColorPickerHSBControl x:Name="HSBPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0 0 0 0" MinWidth="200" BorderBrush="{StaticResource TangoKeyboardKeyDarkTextBrush}"
H="{Binding SelectedBrushStop.Hue, Mode=TwoWay}" S="{Binding SelectedBrushStop.Saturation, Mode=TwoWay}" B="{Binding SelectedBrushStop.Brightness, Mode=TwoWay}"
/>
</Grid>
-
+ <ContentControl Grid.Row="1" Grid.RowSpan="2" ContentTemplate="{StaticResource saveMyColorsDlg}" Content="{Binding}"/>
<ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/>
</Grid>
@@ -288,6 +397,7 @@
/>
</Grid>
+ <ContentControl Grid.Row="1" Grid.RowSpan="2" ContentTemplate="{StaticResource saveMyColorsDlg}" Content="{Binding}"/>
<ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/>
</Grid>
@@ -313,7 +423,7 @@
/>
</Grid>
-
+ <ContentControl Grid.Row="1" Grid.RowSpan="2" ContentTemplate="{StaticResource saveMyColorsDlg}" Content="{Binding}"/>
<ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/>
</Grid>
@@ -344,7 +454,7 @@
MaxKeyValue="{Binding MaxBlackValue, UpdateSourceTrigger=PropertyChanged}"
/>
</Grid>
-
+ <ContentControl Grid.Row="1" Grid.RowSpan="2" ContentTemplate="{StaticResource saveMyColorsDlg}" Content="{Binding}"/>
<ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/>
</Grid>
@@ -384,5 +494,49 @@
</Grid>
</Grid>
</Border>
+ <Border x:Name="MyColors" Visibility="{Binding MyColorsMode, Converter={StaticResource BooleanToVisibilityConverter}}" >
+ <Grid>
+ <Grid.Background>
+ <SolidColorBrush Color="{StaticResource TangoDisabledBackgroundColor}" Opacity="0.9" />
+ </Grid.Background>
+ <Border Margin="72 151 69 125" CornerRadius="20" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <Border.Effect>
+ <DropShadowEffect Opacity="0.5" ShadowDepth="6" Color="Silver" BlurRadius="10" Direction="270"/>
+ </Border.Effect>
+ <Grid>
+ <DockPanel >
+ <Grid DockPanel.Dock="Bottom" Height="137">
+ <Rectangle Height="1" Stroke="{StaticResource TangoDividerBrush}" HorizontalAlignment="Stretch"/>
+ <Grid Margin="48 50 0 0" >
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="1*"/>
+ </Grid.ColumnDefinitions>
+ <touch:TouchImageButton HorizontalAlignment="Left" Width="28" Height="38" Margin="0 20 23 0" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{ Binding AddGroupCommand}" Image="{StaticResource Add_group_mycolors}"/>
+ <TextBlock Grid.Column="1" Margin="20 20 0 0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="SemiBold" Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}">Add Group</TextBlock>
+ <DockPanel Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Column="1" Margin=" 20 0 0 20">
+ <touch:TouchTextBox DockPanel.Dock="Left" Margin="0 0 80 0" x:Name="newGroupNametext" MinWidth="200" Height="Auto" Text="{Binding NewGroupName, Mode=TwoWay,UpdateSourceTrigger=LostFocus}"></touch:TouchTextBox>
+ <touch:TouchButton DockPanel.Dock="Right" Width="160" Height="40" CornerRadius="20" Background="Transparent" EnableDropShadow="False" TextElement.Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" HorizontalAlignment="Right" Margin="10 26 20 0" VerticalAlignment="Bottom"
+ BorderThickness="1" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Command="{Binding AddNewGroupCommand}" CommandParameter="{Binding ElementName=newGroupNametext, Path=Text}">Add</touch:TouchButton>
+
+ </DockPanel>
+ </Grid>
+ </Grid>
+ <DockPanel x:Name="headerPanel" Height="122" DockPanel.Dock="Top">
+ <Rectangle DockPanel.Dock="Bottom" Margin="43 0 63 10" Height="1" Stroke="{StaticResource TangoDividerBrush}" VerticalAlignment="Bottom"/>
+ <TextBlock DockPanel.Dock="Left" Margin="43 53 0 28" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">My Colors</TextBlock>
+ <touch:TouchImageButton DockPanel.Dock="Top" Width="32" Height="32" Image="{StaticResource Close_mycolorsdlg}" HorizontalAlignment="Right" Margin="0 20 23 0" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding CloseMyColorsCommand}"/>
+ </DockPanel>
+ <Grid>
+ <ListBox x:Name="listLibraries" Grid.Row="1" Margin="10 0 10 60" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}"
+ ScrollViewer.VerticalScrollBarVisibility="Visible" Width="560" ItemTemplate="{StaticResource ColorLibrary_Template}">
+ </ListBox>
+ </Grid>
+ </DockPanel>
+ </Grid>
+ </Border>
+
+ </Grid>
+ </Border>
</Grid>
</UserControl>
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 0412cb64a..8ca9791f5 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
@@ -1,5 +1,7 @@
-using System;
+using ColorMine.ColorSpaces;
+using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
@@ -8,10 +10,13 @@ using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.ColorConversion;
using Tango.Core.Commands;
+using Tango.Core.DI;
using Tango.Core.Threading;
using Tango.PPC.Common;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.Common.Notifications;
using Tango.PPC.Jobs.Models;
+using Tango.PPC.Jobs.MyColors;
using Tango.PPC.Jobs.NavigationObjects;
using Tango.PPC.Jobs.ViewContracts;
using Tango.SharedUI;
@@ -46,10 +51,10 @@ namespace Tango.PPC.Jobs.Dialogs
public bool IsEditingMode { get; set; }
}
-
private ActionTimer _volumeConversionTimer;
private IColorConverter _converter;
-
+ [TangoInject]
+ public INotificationProvider NotificationProvider { get; set; }
#region Properties
@@ -74,7 +79,7 @@ namespace Tango.PPC.Jobs.Dialogs
get { return _selectedColorTabIndex; }
set
{
- if(_selectedColorTabIndex != value)
+ if (_selectedColorTabIndex != value)
{
_selectedColorTabIndex = value;
RaisePropertyChangedAuto();
@@ -117,7 +122,8 @@ namespace Tango.PPC.Jobs.Dialogs
///
public ColorTab SelectedColorTab
{
- get {
+ get
+ {
return _selectedColorTab;
}
set
@@ -125,38 +131,38 @@ namespace Tango.PPC.Jobs.Dialogs
if (_selectedColorTab != value)
{
_selectedColorTab = value;
- switch (SelectedColorTab)
- {
- case ColorTab.HSB:
- {
- SelectedColorTabIndex = 0;
- break;
- }
- case ColorTab.CIELab:
- {
- SelectedColorTabIndex = 1;
- break;
- }
- case ColorTab.RGB:
- {
- SelectedColorTabIndex = 2;
- break;
- }
- case ColorTab.Volume:
- {
- SelectedColorTabIndex = 3;
- break;
- }
- case ColorTab.Catalog:
- {
- SelectedColorTabIndex = 4;
- break;
- }
- }
-
OnSelectedtabChanged();
RaisePropertyChangedAuto();
}
+ switch (_selectedColorTab)
+ {
+ case ColorTab.HSB:
+ {
+ SelectedColorTabIndex = 0;
+ break;
+ }
+ case ColorTab.CIELab:
+ {
+ SelectedColorTabIndex = 1;
+ break;
+ }
+ case ColorTab.RGB:
+ {
+ SelectedColorTabIndex = 2;
+ break;
+ }
+ case ColorTab.Volume:
+ {
+ SelectedColorTabIndex = 3;
+ break;
+ }
+ case ColorTab.Catalog:
+ {
+ SelectedColorTabIndex = 4;
+ break;
+ }
+ }
+
}
}
@@ -203,7 +209,7 @@ namespace Tango.PPC.Jobs.Dialogs
}
}
}
-
+
public double MaxCyanValue
{
get
@@ -242,11 +248,13 @@ namespace Tango.PPC.Jobs.Dialogs
public List<ColorCatalog> Catalogs
{
get { return _catalogs; }
- set {
+ set
+ {
_catalogs = value;
- RaisePropertyChangedAuto(); }
+ RaisePropertyChangedAuto();
+ }
}
-
+
private ColorCatalog _selectedCatalog;
public ColorCatalog SelectedCatalog
{
@@ -279,13 +287,113 @@ namespace Tango.PPC.Jobs.Dialogs
set { _collectionFilter = value; RaisePropertyChangedAuto(); }
}
- private void OnFilterChanged()
+ private bool _MyColorsMode;
+
+ public bool MyColorsMode
{
- if(CollectionFilter != null)
- {
- CollectionFilter.RaiseFilterChanged();
+ get { return _MyColorsMode; }
+ set
+ {
+ _MyColorsMode = value;
+ OnMyColorModeChanged();
+ RaisePropertyChangedAuto();
}
}
+
+ private ObservableCollection<ColorLibrary> _libraries;
+ public ObservableCollection<ColorLibrary> Libraries
+ {
+ get { return _libraries; }
+ set { _libraries = value; RaisePropertyChangedAuto(); }
+ }
+
+
+ private ColorLibrary SelectedColorLibrary { get; set; }
+
+ private FavoriteColor _selectedColor;
+
+ public FavoriteColor SelectedColor
+ {
+ get { return _selectedColor; }
+ set { _selectedColor = value; }
+ }
+
+ private bool _editColorsGroupMode;
+
+ public bool EditColorsGroupMode
+ {
+ get { return _editColorsGroupMode; }
+ set
+ {
+ _editColorsGroupMode = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool _addGroupMode;
+
+ public bool AddGroupMode
+ {
+ get { return _addGroupMode; }
+ set
+ {
+ _addGroupMode = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private String _newGroupName;
+ public String NewGroupName
+ {
+ get { return _newGroupName; }
+ set
+ {
+ if (_newGroupName != value)
+ {
+ _newGroupName = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+ }
+
+ private bool _saveMyColorMode;
+ /// <summary>
+ /// Gets or sets a value indicating whether open Save my colors control.
+ /// </summary>
+ public bool SaveMyColorMode
+ {
+ get { return _saveMyColorMode; }
+ set
+ {
+ _saveMyColorMode = value;
+ OnSaveMyColorModeChanged();
+ RaisePropertyChangedAuto();
+ }
+ }
+
+
+ #endregion
+
+ #region commands
+ /// <summary>
+ /// Gets or sets the save my colors command.
+ /// </summary>
+ public RelayCommand SaveMyColorsCommand { get; set; }
+ public RelayCommand<string> AddNewGroupCommand { get; set; }
+ public RelayCommand<string> AddNewGroupAndColorCommand { get; set; }
+ public RelayCommand<ColorLibrary> AddColorToLibraryCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the open my colors command.
+ /// </summary>
+ public RelayCommand OpenMyColorsCommand { get; set; }
+ public RelayCommand CloseMyColorsCommand { get; set; }
+ public RelayCommand AddGroupCommand { get; set; }
+ public RelayCommand DeleteGroupCommand { get; set; }
+ public RelayCommand<FavoriteColor> SelectColorCommand { get; set; }
+ public RelayCommand<ColorLibrary> EditColorsLibraryCommand { get; set; }
+ public RelayCommand<FavoriteColor> DeleteColorCommand { get; set; }
+
#endregion
public ColorSelectionViewVM()
@@ -314,29 +422,46 @@ namespace Tango.PPC.Jobs.Dialogs
return true;
}
});
+
+ SaveMyColorsCommand = new RelayCommand(SaveMyColors);
+ OpenMyColorsCommand = new RelayCommand(() => { MyColorsMode = true; });
+ CloseMyColorsCommand = new RelayCommand(() => { MyColorsMode = false; });
+ SelectColorCommand = new RelayCommand<FavoriteColor>(SelectColor);
+ AddGroupCommand = new RelayCommand(AddGroup);
+ AddNewGroupCommand = new RelayCommand<string>(AddNewGroup);
+ AddNewGroupAndColorCommand = new RelayCommand<string>(AddNewGroupAndColor);
+ AddColorToLibraryCommand = new RelayCommand<ColorLibrary>(AddColorToLibrary);
+ DeleteGroupCommand = new RelayCommand(DeleteGroup);
+ EditColorsLibraryCommand = new RelayCommand<ColorLibrary>(EditColorsLibrary);
+ DeleteColorCommand = new RelayCommand<FavoriteColor>(DeleteColor);
+ MyColorsMode = false;
+ EditColorsGroupMode = false;
+ SaveMyColorMode = false;
}
+ #region Show and Selection tab
+
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;
- if(SelectedBrushStop.ColorSpace == ColorSpaces.Volume)
+ if (SelectedBrushStop.ColorSpace == ColorSpaces.Volume)
SelectedColorTab = ColorTab.Volume;
if (SelectedBrushStop.ColorSpace == ColorSpaces.LAB)
{
SelectedColorTab = ColorTab.CIELab;
- }
- else if(SelectedBrushStop.ColorSpace == ColorSpaces.Catalog)
+ }
+ else if (SelectedBrushStop.ColorSpace == ColorSpaces.Catalog)
{
SelectedColorTab = ColorTab.Catalog;
if (SelectedBrushStop.ColorCatalogsItem != null)
@@ -347,7 +472,7 @@ namespace Tango.PPC.Jobs.Dialogs
{
SelectedCatalog = Catalogs.FirstOrDefault();
}
- }
+ }
else if (SelectedBrushStop.ColorSpace == ColorSpaces.HSB)
SelectedColorTab = ColorTab.HSB;
else if (SelectedBrushStop.ColorSpace == ColorSpaces.RGB)
@@ -365,6 +490,8 @@ namespace Tango.PPC.Jobs.Dialogs
OKCommand.RaiseCanExecuteChanged();
SelectedBrushStop.LiquidVolumesOutOfRangeChanged -= OnLiquidVolumesOutOfRangeChanged;
SelectedBrushStop.LiquidVolumesOutOfRangeChanged += OnLiquidVolumesOutOfRangeChanged;
+
+ Libraries = MyColorsEngine.Default.GetAll().ToObservableCollection();
}
private void OnSelectedtabChanged()
@@ -415,7 +542,7 @@ namespace Tango.PPC.Jobs.Dialogs
}
}
- protected void OnColorSelectionItemChanged( object sender, EventArgs args)
+ protected void OnColorSelectionItemChanged(object sender, EventArgs args)
{
if (SelectedBrushStop.ColorCatalogsItem != null)
{
@@ -425,9 +552,20 @@ namespace Tango.PPC.Jobs.Dialogs
else
SelectedCatalog = Catalogs.FirstOrDefault();
}
-
+
+ #endregion
+
#region Methods
+ private void OnFilterChanged()
+ {
+ if (CollectionFilter != null)
+ {
+ CollectionFilter.RaiseFilterChanged();
+ }
+ }
+
+
private double GetMaxCMYKValueOrDefault(LiquidTypes type)
{
if (SelectedBrushStop != null && SelectedBrushStop.SegmentModel != null && SelectedBrushStop.SegmentModel.Job != null && SelectedBrushStop.SegmentModel.Job.Rml != null)
@@ -454,7 +592,7 @@ namespace Tango.PPC.Jobs.Dialogs
private void OnLiquidVolumesOutOfRangeChanged(object sender, EventArgs e)
{
-
+
OKCommand.RaiseCanExecuteChanged();
}
@@ -472,9 +610,154 @@ namespace Tango.PPC.Jobs.Dialogs
protected override bool CanOK()
{
- return SelectedBrushStop!= null && !SelectedBrushStop.LiquidVolumesOutOfRange;
+ return SelectedBrushStop != null && !SelectedBrushStop.LiquidVolumesOutOfRange;
+ }
+
+ #endregion
+
+ #region MyColors
+
+ private void SaveMyColors()
+ {
+ SaveMyColorMode = !SaveMyColorMode;
+ }
+
+ private void OnSaveMyColorModeChanged()
+ {
+ NewGroupName = "";
+ }
+ private void OnMyColorModeChanged()
+ {
+ NewGroupName = "";
+ AddGroupMode = false;
+ }
+ /// <summary>
+ /// Adds the new group in Save My Colors list.
+ /// </summary>
+ /// <param name="name">The name of the new Library.</param>
+ private void AddNewGroup(string name)
+ {
+ if (!String.IsNullOrEmpty(name))
+ {
+ Libraries.Add(MyColorsEngine.Default.AddLibrary(name));
+ NewGroupName = "";
+ }
+ }
+
+ private void AddNewGroupAndColor(string name)
+ {
+ if (!String.IsNullOrEmpty(name))
+ {
+ var library = MyColorsEngine.Default.AddLibrary(name);
+ Libraries.Add(library);
+ AddColorToLibrary(library);
+ }
+ NewGroupName = "";
+ SaveMyColorMode = false;
}
+ /// <summary>
+ /// Adds the selected color to library in Save my Colors.
+ /// </summary>
+ private void AddColorToLibrary(ColorLibrary obj)
+ {
+ FavoriteColor newcolor = new FavoriteColor();
+ newcolor.ColorSpace = SelectedBrushStop.ColorSpace;
+ newcolor.Color = SelectedBrushStop.Color;
+ newcolor.Red = SelectedBrushStop.Red;
+ newcolor.Green = SelectedBrushStop.Green;
+ newcolor.Blue = SelectedBrushStop.Blue;
+ newcolor.Cyan = SelectedBrushStop.Cyan;
+ newcolor.Magenta = SelectedBrushStop.Magenta;
+ newcolor.Yellow = SelectedBrushStop.Yellow;
+ newcolor.Black = SelectedBrushStop.Black;
+ newcolor.L = SelectedBrushStop.L;
+ newcolor.A = SelectedBrushStop.A;
+ newcolor.B = SelectedBrushStop.B;
+ newcolor.Hue = SelectedBrushStop.Hue;
+ newcolor.Saturation = SelectedBrushStop.Saturation;
+ newcolor.Brightness = SelectedBrushStop.Brightness;
+ newcolor.RmlGuid = SelectedBrushStop.SegmentModel.Job.Rml.Guid;
+ newcolor.Name = String.Format("#{0:X2}{1:X2}{2:X2}", newcolor.Red, newcolor.Green, newcolor.Blue);
+
+ obj.AddToLibrary(newcolor);
+ SaveMyColorMode = false;
+ }
+
+ private void SelectColor(FavoriteColor favoriteColor)
+ {
+ SelectedColor = favoriteColor;
+ MyColorsMode = false;
+
+ //test RML?
+ SelectedBrushStop.SetMyColor(favoriteColor);
+ RaisePropertyChanged(nameof(SelectedBrushStop));
+ ColorTab tab = SelectedColorTab;
+ switch (SelectedBrushStop.ColorSpace)
+ {
+ case ColorSpaces.HSB:
+ SelectedColorTab = ColorTab.HSB;
+ SelectedBrushStop.OnBrushStopFieldValueChanged();
+ break;
+ case ColorSpaces.Volume:
+ {
+ SelectedColorTab = ColorTab.Volume;
+ if(favoriteColor.RmlGuid != SelectedBrushStop.SegmentModel.Job.Rml.Guid)
+ NotificationProvider.ShowInfo("The color may be different from the selected.");
+ }
+ break;
+ case ColorSpaces.LAB:
+ SelectedColorTab = ColorTab.CIELab;
+ SelectedBrushStop.OnBrushStopFieldValueChanged();
+ break;
+ case ColorSpaces.RGB:
+ SelectedColorTab = ColorTab.RGB;
+ SelectedBrushStop.OnBrushStopFieldValueChanged();
+ break;
+ case ColorSpaces.Catalog:
+ SelectedColorTab = ColorTab.Catalog;
+ SelectedBrushStop.OnBrushStopFieldValueChanged();
+ break;
+ }
+ }
+
+ private void AddGroup()
+ {
+ AddGroupMode = !AddGroupMode;
+ }
+
+ private void EditColorsLibrary(ColorLibrary library)
+ {
+ if (EditColorsGroupMode)
+ {
+ SelectedColorLibrary.EditColorsGroupMode = false;
+ EditColorsGroupMode = false;
+ }
+ else
+ {
+ EditColorsGroupMode = true;
+ SelectedColorLibrary = library;
+ SelectedColorLibrary.EditColorsGroupMode = true;
+ }
+ }
+
+ private void DeleteColor(FavoriteColor favoriteColor)
+ {
+ if (favoriteColor != null && SelectedColorLibrary != null)
+ {
+ SelectedColorLibrary.RemoveFromLibrary(favoriteColor);
+ }
+ }
+
+ private void DeleteGroup()
+ {
+ if (SelectedColorLibrary != null)
+ {
+ //message
+ Libraries.Remove(SelectedColorLibrary);
+ SelectedColorLibrary.Delete();
+ }
+ }
#endregion
}