aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/FineTuningPaletteViewVM.cs
blob: 2e16ac747efcfbe970e2ea2a53f1078693c8ad2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.ColorConversion;
using Tango.PPC.Common.Models;
using Tango.SharedUI;

namespace Tango.PPC.Jobs.Dialogs
{
    /// <summary>
    /// Represents the fine tuning pallet dialog ViewModel.
    /// </summary>
    /// <seealso cref="Tango.SharedUI.DialogViewVM" />
    public class FineTuningPaletteViewVM : DialogViewVM
    {
        private Job _job;
        private bool _prevent_change;
        private IColorConverter _converter;

        private List<ColorConversionSuggestion> _suggestions;
        /// <summary>
        /// Gets or sets the triplet suggestions.
        /// </summary>
        public List<ColorConversionSuggestion> Suggestions
        {
            get { return _suggestions; }
            set { _suggestions = value; RaisePropertyChangedAuto(); }
        }

        private List<ColorConversionSuggestion> _hiveSuggestions;
        /// <summary>
        /// Gets or sets the hive suggestions.
        /// </summary>
        public List<ColorConversionSuggestion> HiveSuggestions
        {
            get { return _hiveSuggestions; }
            set { _hiveSuggestions = value; RaisePropertyChangedAuto(); }
        }

        private ColorConversionSuggestion _selectedHiveSuggestion;
        /// <summary>
        /// Gets or sets the selected hive suggestion.
        /// </summary>
        public ColorConversionSuggestion SelectedHiveSuggestion
        {
            get { return _selectedHiveSuggestion; }
            set { _selectedHiveSuggestion = value; RaisePropertyChangedAuto(); OnSelectedHiveSuggestionChanged(); }
        }

        private ColorConversionSuggestion _selectedSuggestion;
        /// <summary>
        /// Gets or sets the selected triplet suggestion.
        /// </summary>
        public ColorConversionSuggestion SelectedSuggestion
        {
            get { return _selectedSuggestion; }
            set { _selectedSuggestion = value; RaisePropertyChangedAuto(); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="FineTuningPaletteViewVM"/> class.
        /// </summary>
        public FineTuningPaletteViewVM()
        {
            Suggestions = new List<ColorConversionSuggestion>();
            HiveSuggestions = new List<ColorConversionSuggestion>();

            _converter = new DefaultColorConverter();
        }

        /// <summary>
        /// Called when the selected hive suggestion has been changed
        /// </summary>
        private void OnSelectedHiveSuggestionChanged()
        {
            if (!_prevent_change)
            {
                Suggestions = _converter.Convert(_job, SelectedHiveSuggestion.Color, true).CreateTrippletSuggestions();
                SelectedSuggestion = Suggestions.GetCenterSuggestion();
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="FineTuningPaletteViewVM"/> class.
        /// </summary>
        /// <param name="fineTuneItem">The fine tune item.</param>
        /// <param name="job">The job.</param>
        public FineTuningPaletteViewVM(FineTuneItem fineTuneItem, Job job) : this()
        {
            _prevent_change = true;
            _job = job;
            Suggestions = fineTuneItem.Suggestions;
            HiveSuggestions = fineTuneItem.HiveSuggestions;
            SelectedHiveSuggestion = HiveSuggestions.GetCenterSuggestion();
            SelectedSuggestion = Suggestions[Suggestions.Count / 2];
            _prevent_change = false;
        }
    }
}
Resource BooleanToVisibilityConverter}}" Margin="0 0 30 0" Padding="20" Icon="Undo"> <touch:TouchIconButton.Style> <Style TargetType="touch:TouchIconButton" BasedOn="{StaticResource TangoRoundTouchIconButton}"> <Setter Property="IconAngle" Value="0"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding IsMultiSelecting}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="IconAngle" To="360" Duration="00:00:0.2"></DoubleAnimation> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="IconAngle" To="0" Duration="00:00:00"></DoubleAnimation> </Storyboard> </BeginStoryboard> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </touch:TouchIconButton.Style> </touch:TouchIconButton> <touch:TouchIconButton Command="{Binding ExportJobCommand}" Margin="0 0 30 0" Padding="20" Icon="HddRegular" Style="{StaticResource TangoRoundTouchIconButton}"></touch:TouchIconButton> <touch:TouchIconButton Command="{Binding CloneJobsCommand}" Margin="0 0 30 0" Padding="20" Icon="CopyRegular" Style="{StaticResource TangoRoundTouchIconButton}"></touch:TouchIconButton> <touch:TouchIconButton Command="{Binding DeleteJobsCommand}" Padding="20" Icon="TrashAltRegular" Style="{StaticResource TangoRoundTouchIconButton}"></touch:TouchIconButton> </StackPanel> <touch:TouchIconButton Command="{Binding AddJobCommand}" RenderTransformOrigin="0.5,0.5" Margin="0 -15 0 0" Padding="20" Height="80" Icon="Plus" HorizontalAlignment="Right"> <touch:TouchIconButton.Style> <Style TargetType="touch:TouchIconButton" BasedOn="{StaticResource TangoRoundTouchIconButton}"> <Setter Property="Opacity" Value="1"></Setter> <Setter Property="IsHitTestVisible" Value="True"></Setter> <Setter Property="RenderTransform"> <Setter.Value> <ScaleTransform ScaleX="1" ScaleY="1" /> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding IsMultiSelecting}" Value="True"> <Setter Property="IsHitTestVisible" Value="False"></Setter> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="00:00:0.2"></DoubleAnimation> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="0.5" Duration="00:00:0.2"></DoubleAnimation> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="0.5" Duration="00:00:0.2"></DoubleAnimation> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:0.2"></DoubleAnimation> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.2"></DoubleAnimation> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="00:00:0.2"></DoubleAnimation> </Storyboard> </BeginStoryboard> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </touch:TouchIconButton.Style> </touch:TouchIconButton> </Grid> <DockPanel> <touch:TouchNavigationLinks DockPanel.Dock="Left" x:Name="navigationLinks" SelectionChanged="TouchNavigationLinks_SelectionChanged" SelectedIndex="{Binding SelectedCategoryIndex,Mode=TwoWay}" IsEnabled="{Binding IsMultiSelecting,Converter={StaticResource BooleanInverseConverter}}" VerticalAlignment="Bottom" Margin="20" FontSize="{StaticResource TangoNavigationLinksFontSize}"> <TextBlock>DRAFT</TextBlock> <TextBlock>HISTORY</TextBlock> </touch:TouchNavigationLinks> <Grid VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0 5 0 0"> <DockPanel> <Rectangle Margin="0 0 20 0" HorizontalAlignment="Center" VerticalAlignment="Bottom" Stroke="{StaticResource TangoGrayBrush}" StrokeThickness="1" Height="25"></Rectangle> <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}" Watermark="find name, customer..."></touch:TouchTextBox> </DockPanel> </Grid> </DockPanel> <Grid Grid.Row="1" x:Name="moveGrid"> <touch:TouchLoadingPanel IsLoading="{Binding IsLoadingJobs}" Visibility="{Binding SelectedCategory,Converter={StaticResource JobsCategoryToVisibilityConverter},ConverterParameter='Draft'}"> <touch:LightTouchDataGrid CollectionFilter="{Binding CollectionFilter}" AnimateSorting="False" RenderOptions.EdgeMode="Unspecified" Style="{StaticResource TangoJobsGrid}" x:Name="dataGridJobs" SelectedItems="{Binding SelectedJobs}" IsMultiSelecting="{Binding IsMultiSelecting,Mode=TwoWay}" OnDragAndDropCommand="{Binding JobDragedDroppedCommand}" ItemsSource="{Binding DraftJobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> <touch:LightTouchDataGrid.Columns> <touch:LightTouchDataGridColumn Width="90"> <touch:LightTouchDataGridColumn.Header> <Image Source="../Images/warning.png" Width="24" /> </touch:LightTouchDataGridColumn.Header> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <Grid Margin="5 0 0 0" Width="40" Height="40"> <Image HorizontalAlignment="Left" VerticalAlignment="Top" Width="20"> <Image.Style> <Style TargetType="Image"> <Setter Property="Source" Value="../Images/sample_approved_small_gray.png"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding JobSampleDyeStatus}" Value="Approved"> <Setter Property="Source" Value="../Images/sample_approved_small.png"></Setter> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> <Image HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="20"> <Image.Style> <Style TargetType="Image"> <Setter Property="Source" Value="../Images/color_approved_small_gray.png"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding JobFineTuningStatus}" Value="Approved"> <Setter Property="Source" Value="../Images/color_approved_small.png"></Setter> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> </Grid> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="1*" Header="Name" SortMember="Name" HorizontalContentAlignment="Left"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding Name,Converter={StaticResource StringEllipsisConverter},ConverterParameter='40'}"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="117" Header="Length (m)" SortMember="Length"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding Length,StringFormat=0.0}"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Header="Colors" SortMember="Segments.Count" Width="85"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <Image Stretch="Fill" IsHitTestVisible="False" Source="{Binding Converter={StaticResource JobToPieImageConverter},ConverterParameter='25,25',IsAsync=True}" Width="25" Height="25" HorizontalAlignment="Left"></Image> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="100" Header="Updated" SortMember="LastUpdated"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateConverter}}"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn SortMember="JobIndex" SortDirection="{x:Null}" Width="78" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" DisplayChevron="False" ForcedSortDirection="Ascending"> <touch:LightTouchDataGridColumn.HeaderTemplate> <DataTemplate> <Border CornerRadius="0 5 5 0"> <Border.Style> <Style TargetType="Border"> <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding SortDirection}" Value="Ascending"> <Setter Property="Background" Value="{StaticResource TangoLowAccentBrush}"></Setter> </DataTrigger> </Style.Triggers> </Style> </Border.Style> <Grid> <Rectangle HorizontalAlignment="Left" StrokeThickness="2" Stroke="{StaticResource TangoColumnDividerBrush}" /> <Image Source="/Images/arrows.png" Width="28" /> </Grid> </Border> </DataTemplate> </touch:LightTouchDataGridColumn.HeaderTemplate> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <dragAndDrop:DragThumb IsEnabled="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.IsMultiSelecting,Converter={StaticResource BooleanInverseConverter}}" Background="Transparent" touchComponents:Ripple.PreventRipple="True" touchComponents:TransformationHelper.PreventTransform="True"> <dragAndDrop:DragThumb.Style> <Style TargetType="dragAndDrop:DragThumb"> <Setter Property="Visibility" Value="Collapsed"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=touch:LightTouchDataGridCell},Path=Column.SortDirection}" Value="Ascending"> <Setter Property="Visibility" Value="Visible"></Setter> </DataTrigger> </Style.Triggers> </Style> </dragAndDrop:DragThumb.Style> <StackPanel Width="30" IsHitTestVisible="False" VerticalAlignment="Center"> <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" /> <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" Margin="0 5 0 0" /> </StackPanel> </dragAndDrop:DragThumb> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> </touch:LightTouchDataGrid.Columns> </touch:LightTouchDataGrid> </touch:TouchLoadingPanel> <touch:TouchLoadingPanel IsLoading="{Binding IsLoadingJobs}" Visibility="{Binding SelectedCategory,Converter={StaticResource JobsCategoryToVisibilityConverter},ConverterParameter='History'}"> <touch:LightTouchDataGrid CollectionFilter="{Binding CollectionFilter}" AnimateSorting="False" EnableDragAndDrop="False" RenderOptions.EdgeMode="Unspecified" x:Name="dataGridJobsHistory" Style="{StaticResource TangoJobsGrid}" SelectedItems="{Binding SelectedJobs}" IsMultiSelecting="{Binding IsMultiSelecting,Mode=TwoWay}" ItemsSource="{Binding HistoryJobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> <touch:LightTouchDataGrid.Columns> <touch:LightTouchDataGridColumn Width="50"> <touch:LightTouchDataGridColumn.Header> <Image Source="../Images/warning.png" Width="24" /> </touch:LightTouchDataGridColumn.Header> <touch:LightTouchDataGridColumn.CellTemplate > <DataTemplate> <touch:TouchIcon Width="26" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" > <touch:TouchIcon.Style> <Style TargetType="touch:TouchIcon"> <Setter Property="Icon" Value="Check"></Setter> <Setter Property="Foreground" Value="{StaticResource TangoSuccessBrush}"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding JobStatus}" Value="Disrupted"> <Setter Property="Icon" Value="AlertCircleOutline"></Setter> <Setter Property="Foreground" Value="{StaticResource TangoWarningBrush}"></Setter> </DataTrigger> </Style.Triggers> </Style> </touch:TouchIcon.Style> </touch:TouchIcon> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="100" Header="Status" SortMember="JobStatus" HorizontalContentAlignment="Left"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding JobStatus,Converter={StaticResource EnumToDescriptionConverter}}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="1*" Header="Name" SortMember="Name" HorizontalContentAlignment="Left"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding Name,Converter={StaticResource StringEllipsisConverter},ConverterParameter='40'}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="117" Header="Length (m)" SortMember="Length"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding Length,StringFormat=0.0}"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Header="Colors" SortMember="Segments.Count" Width="85"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <Image Stretch="Fill" IsHitTestVisible="False" Source="{Binding Converter={StaticResource JobToPieImageConverter},ConverterParameter='25,25',IsAsync=True}" Width="25" Height="25" HorizontalAlignment="Left"></Image> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn Width="100" Header="Updated" SortMember="LastUpdated"> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> <TextBlock IsHitTestVisible="False" Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateConverter}}"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> </touch:LightTouchDataGrid.Columns> </touch:LightTouchDataGrid> </touch:TouchLoadingPanel> </Grid> </Grid> </Grid> </UserControl>