diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-02-08 12:48:14 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-02-08 12:48:14 +0200 |
| commit | 199aa2eb46bf1625d0bbc8b98efe35d158cff9be (patch) | |
| tree | 28393fc49d347530a4e36777ec0bec9ea47b7bdd | |
| parent | b10afe316e91d0600cd1f668f86767883cce4bb9 (diff) | |
| download | Tango-199aa2eb46bf1625d0bbc8b98efe35d158cff9be.tar.gz Tango-199aa2eb46bf1625d0bbc8b98efe35d158cff9be.zip | |
Implement MyColors in PPC
Related Work Items: #4558
20 files changed, 945 insertions, 77 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 } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png Binary files differnew file mode 100644 index 000000000..afb4b72eb --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png Binary files differnew file mode 100644 index 000000000..a993805ee --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.png Binary files differnew file mode 100644 index 000000000..3b4c00e79 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.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 2033fac48..8a071f126 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 @@ -668,7 +668,7 @@ namespace Tango.PPC.Jobs.Models } /// <summary> - /// Sets the new color. + /// Sets the new color from MyColors. /// </summary> public void SetNewColor( BrushStopModel newBrushStop) { @@ -794,6 +794,33 @@ namespace Tango.PPC.Jobs.Models return color; } + public void SetMyColor(FavoriteColor favoriteColor) + { + Color = favoriteColor.Color; + BestMatchColor = favoriteColor.Color; + ColorSpace = favoriteColor.ColorSpace; + // _colorcatalogsitem = favoriteColor.ColorCatalogsItem; + + PreventPropertyUpdate = true; + + Cyan = favoriteColor.Cyan; + Magenta = favoriteColor.Magenta; + Yellow = favoriteColor.Yellow; + Black = favoriteColor.Black; + + Red = favoriteColor.Red; + Green = favoriteColor.Green; + Blue = favoriteColor.Blue; + L = favoriteColor.L; + A = favoriteColor.A; + B = favoriteColor.B; + BestMatchL = favoriteColor.L; + BestMatchA = favoriteColor.A; + BestMatchB = favoriteColor.B; + PreventPropertyUpdate = false; + LiquidVolumesOutOfRange = false; + } + #endregion #region changes diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs new file mode 100644 index 000000000..511a90e15 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs @@ -0,0 +1,83 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.PPC.Jobs.MyColors; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Models +{ + public class ColorLibrary: ExtendedObject + { + private ObservableCollection<FavoriteColor> _colorList; + public ObservableCollection<FavoriteColor> ColorList + { + get { return _colorList; } + set { _colorList = value; } + } + + [BsonId] + public Int32 ID { get; set; } + + private string _name; + public string Name + { + get { return _name; } + set { _name = value; } + } + + private bool _editColorsGroupMode; + [BsonIgnore] + public bool EditColorsGroupMode + { + get { return _editColorsGroupMode; } + set { _editColorsGroupMode = value; RaisePropertyChangedAuto(); } + } + + + public ColorLibrary() + { + _colorList = new ObservableCollection<FavoriteColor>(); + EditColorsGroupMode = false; + } + + public void Loading() + { + //loading form database + } + + public void AddToLibrary(FavoriteColor color) + { + ColorList.Add(color); + RaisePropertyChanged(nameof(ColorList)); + + Task.Factory.StartNew(() => + { + MyColorsEngine.Default.UpdateLibrary(this); + }); + } + + public void RemoveFromLibrary(FavoriteColor color) + { + ColorList.Remove(color); + RaisePropertyChanged(nameof(ColorList)); + + Task.Factory.StartNew(() => + { + MyColorsEngine.Default.UpdateLibrary(this); + }); + } + + public void Delete() + { + Task.Factory.StartNew(() => + { + MyColorsEngine.Default.Delete(this); + }); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs new file mode 100644 index 000000000..43d41539e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.BL.Enumerations; +using Tango.SharedUI; +using System.Windows; +using ColorMine.ColorSpaces; +using Tango.Core; +using LiteDB; + +namespace Tango.PPC.Jobs.Models +{ + public class FavoriteColor : ExtendedObject + { + + #region Properties + + [BsonId] + public Int32 ID { get; set; } + + private string _name; + + public string Name + { + get { return _name; } + set + { + _name = value; + RaisePropertyChangedAuto(); + } + } + + public String RmlGuid { get; set; } + + public ColorSpaces ColorSpace { get; set; } + + public Double Cyan { get; set; } + + public Double Magenta { get; set; } + + public Double Yellow { get; set; } + + public Double Black { get; set; } + + public Int32 Red { get; set; } + + public Int32 Green { get; set; } + + public Int32 Blue { get; set; } + + public Double L { get; set; } + + public Double A { get; set; } + + public Double B { get; set; } + + public double Hue { get; set; } + + public double Saturation { get; set; } + + public double Brightness { get; set; } + + public int BestMatchR { get; set; } + + public int BestMatchG { get; set; } + + public int BestMatchB { get; set; } + + [BsonIgnore] + public Color Color + { + get + { + return Color.FromRgb((byte)BestMatchR, (byte)BestMatchG, (byte)BestMatchB); + } + set + { + BestMatchR = value.R; + BestMatchG = value.G; + BestMatchB = value.B; + RaisePropertyChangedAuto(); + } + } + + [BsonIgnore] + public SolidColorBrush Brush + { + get { return new SolidColorBrush(Color); } + } + + #endregion + + public FavoriteColor() + { + Hue = Saturation = 0; + Brightness = 100; + L = 100; + A = B = 0; + + Red = Green = Blue = 255; + Cyan = Magenta = Yellow = Black = 0; + Color = Colors.White; + ColorSpace = ColorSpaces.Volume; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs index 0106d82c4..bc6997120 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs @@ -11,7 +11,7 @@ using Tango.SharedUI; namespace Tango.PPC.Jobs.Models { - public class JobModel : ViewModel + public class JobModel : ExtendedObject { private bool _preventChange; 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 3b4644a8d..b65d7e156 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 @@ -18,7 +18,7 @@ using Tango.PPC.Jobs.UndoRedoCommands; namespace Tango.PPC.Jobs.Models { - public class SegmentModel : ViewModel + public class SegmentModel : ExtendedObject { private double _lastLength; private LinearGradientBrush _brush; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs new file mode 100644 index 000000000..27dabc2e7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs @@ -0,0 +1,76 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Jobs.Models; + +namespace Tango.PPC.Jobs.MyColors +{ + public class MyColorsEngine : IDisposable + { + private LiteDatabase _db; + private ILiteCollection<ColorLibrary> _collection; + + private static Lazy<MyColorsEngine> _default = new Lazy<MyColorsEngine>(() => new MyColorsEngine()); + + public static MyColorsEngine Default + { + get + { + return _default.Value; + } + } + + private MyColorsEngine() + { + Init(); + } + + private void Init() + { + String dbFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Color Library"); + Directory.CreateDirectory(dbFolder); + _db = new LiteDatabase($"Filename={Path.Combine(dbFolder, "color_library.db")}"); + _collection = _db.GetCollection<ColorLibrary>("Libraries"); + } + + public void UpdateLibrary(ColorLibrary library) + { + _collection.Update(library); + } + + public ColorLibrary AddLibrary(String name) + { + ColorLibrary library = new ColorLibrary() { Name = name }; + _collection.Insert(library); + return library; + } + + public List<ColorLibrary> GetAll() + { + return _collection.FindAll().ToList(); + } + + ~MyColorsEngine() + { + Dispose(); + } + + public void Dispose() + { + try + { + _db?.Dispose(); + } + catch { } + } + + public void Delete(ColorLibrary library) + { + _collection.Delete(library.ID); + } + } +} 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 a38818ffb..8d90aabb2 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 @@ -43,10 +43,14 @@ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="LiteDB, Version=5.0.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> + <Reference Include="System.Runtime" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> @@ -262,8 +266,11 @@ <Compile Include="Messages\JobSelectedMessage.cs" /> <Compile Include="Messages\NavigatedToJobsModuleMessage.cs" /> <Compile Include="Models\BrushStopModel.cs" /> + <Compile Include="Models\ColorLibrary.cs" /> + <Compile Include="Models\FavoriteColor.cs" /> <Compile Include="Models\JobModel.cs" /> <Compile Include="Models\SegmentModel.cs" /> + <Compile Include="MyColors\MyColorsEngine.cs" /> <Compile Include="NavigationObjects\JobNavigationObject.cs" /> <Compile Include="NavigationObjects\JobSummeryNavigationObject.cs" /> <Compile Include="NavigationObjects\TwineCatalogNavigationObject.cs" /> @@ -624,6 +631,15 @@ <ItemGroup> <Resource Include="Images\NewJob\job_export.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\ColorSelection\delete_color.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\ColorSelection\close_mycolorsdlg.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\ColorSelection\add_group.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config index 4cf1b4859..7631e246f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config @@ -4,4 +4,5 @@ <package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net46" /> <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" /> <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" /> + <package id="LiteDB" version="5.0.4" targetFramework="net461" /> </packages>
\ No newline at end of file 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 9b865c18b..3af921f7d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs @@ -52,7 +52,7 @@ namespace Tango.PPC.Common.Controls private double groupMargin = 50; private bool selectedFromClick; private LightTouchScrollViewer _scrollViewer; - private BitmapSource _myColorBitmap; + // private BitmapSource _myColorBitmap; private double imageWidth = 24; private double imageHeight = 22; private Point _lastMouseClickPoint; @@ -100,7 +100,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)); + // _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) @@ -292,7 +292,7 @@ namespace Tango.PPC.Common.Controls DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); - drawingContext.DrawImage(_myColorBitmap, imageRect); + // drawingContext.DrawImage(_myColorBitmap, imageRect); drawingContext.DrawEllipse(new SolidColorBrush(item.Color), null, new Point(x + ellipseWidth / 2, y + ellipseHeight / 2), ellipseWidth / 2, ellipseHeight / 2); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index bb0a694cf..780941f66 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -19,6 +19,7 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchCheckBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchExpander.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchNumericUpDownControl.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchScrollViewer.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchExpander.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchNativeListBox.xaml" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml index bb1890e7f..432f2b58b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -58,10 +58,32 @@ <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" - HorizontalScrollBarVisibility="Hidden"> + <touch:TouchScrollViewer CanContentScroll="True" Padding="{TemplateBinding Padding}" Focusable="False" HorizontalScrollBarVisibility="Hidden"> + <ItemsPresenter /> + </touch:TouchScrollViewer> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <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> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />--> </requestedPrivileges> </security> </trustInfo> diff --git a/Software/Visual_Studio/Tango.Touch/Styles/TouchScrollViewer.xaml b/Software/Visual_Studio/Tango.Touch/Styles/TouchScrollViewer.xaml new file mode 100644 index 000000000..cd37a5b6a --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Styles/TouchScrollViewer.xaml @@ -0,0 +1,91 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="clr-namespace:Tango.Touch.Controls" + xmlns:components="clr-namespace:Tango.Touch.Components" + xmlns:local="clr-namespace:Tango.Touch.Styles"> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + <ResourceDictionary Source="../Resources/Fonts.xaml" /> + <ResourceDictionary> + <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> + </ResourceDictionary> + </ResourceDictionary.MergedDictionaries> + <Style x:Key="TouchScrollBarThumb" TargetType="{x:Type Thumb}"> + <Setter Property="OverridesDefaultStyle" Value="true"/> + <Setter Property="IsTabStop" Value="false"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type Thumb}"> + <Border Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}" CornerRadius="5" Background="#90000000" /> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style x:Key="TouchScrollBar" TargetType="{x:Type ScrollBar}"> + <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/> + <Setter Property="Stylus.IsFlicksEnabled" Value="false"/> + <Setter Property="Background" Value="#33000000"/> + <Setter Property="BorderBrush" Value="#33000000"/> + <Setter Property="Foreground" Value="Gray"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="Width" Value="5"/> + <Setter Property="MinWidth" Value="5"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ScrollBar}"> + <Grid x:Name="Bg" SnapsToDevicePixels="true" Background="{TemplateBinding Background}"> + <Border BorderBrush="{TemplateBinding BorderBrush}" HorizontalAlignment="Right" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Row="1"/> + <Track x:Name="PART_Track" IsDirectionReversed="true" HorizontalAlignment="Right" Width="5" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1"> + <Track.Thumb> + <Thumb Style="{StaticResource TouchScrollBarThumb}"></Thumb> + </Track.Thumb> + </Track> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style x:Key="TouchVerticalScrollViewer" TargetType="{x:Type controls:TouchScrollViewer}"> + <Setter Property="HorizontalScrollBarVisibility" Value="Disabled"></Setter> + <Setter Property="PanningMode" Value="VerticalOnly"></Setter> + <Setter Property="VerticalScrollBarVisibility" Value="Visible"></Setter> + <Setter Property="Focusable" Value="False"></Setter> + <Setter Property="CanContentScroll" Value="true"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type controls:TouchScrollViewer}"> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + + <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Visibility="Hidden"/> + <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.Row="1"/> + <ScrollBar Opacity="0" Grid.Row="1" x:Name="PART_VerticalScrollBar" Style="{StaticResource TouchScrollBar}" HorizontalAlignment="Right" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/> + </Grid> + + <ControlTemplate.Triggers> + <EventTrigger RoutedEvent="ScrollViewer.ScrollChanged"> + <EventTrigger.Actions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity" Duration="00:00:03" FillBehavior="Stop"> + <EasingDoubleKeyFrame KeyTime="00:00:0.2" Value="1"></EasingDoubleKeyFrame> + <DiscreteDoubleKeyFrame KeyTime="00:00:2.5" Value="1"></DiscreteDoubleKeyFrame> + <EasingDoubleKeyFrame KeyTime="00:00:03" Value="0"></EasingDoubleKeyFrame> + </DoubleAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </EventTrigger.Actions> + </EventTrigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index ae5ac91e3..58eb68e45 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -155,6 +155,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Styles\TouchScrollViewer.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="TouchColorPickerControls\MultiRangeSlider.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -488,7 +492,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index c2c6c0bc9..0a9ce1282 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -62,7 +62,8 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchCheckBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchExpander.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchNumericUpDownControl.xaml"/> - + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchScrollViewer.xaml"/> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchPanel.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchColorPickerSlider.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchColorPickerControl.xaml"/> |
