aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/FineTuningPaletteViewVM.cs
blob: d9554575e1d5113b1be9f01fb29d6911684a0f42 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.ColorConversion;
using Tango.BL.Entities;
using Tango.PPC.Jobs.Models;
using Tango.SharedUI;

namespace Tango.PPC.Jobs.Dialogs
{
    public class FineTuningPaletteViewVM : DialogViewVM
    {
        private Job _job;
        private bool _prevent_change;

        private List<ColorConversionSuggestion> _suggestions;
        public List<ColorConversionSuggestion> Suggestions
        {
            get { return _suggestions; }
            set { _suggestions = value; RaisePropertyChangedAuto(); }
        }

        private List<ColorConversionSuggestion> _hiveSuggestions;
        public List<ColorConversionSuggestion> HiveSuggestions
        {
            get { return _hiveSuggestions; }
            set { _hiveSuggestions = value; RaisePropertyChangedAuto(); }
        }

        private ColorConversionSuggestion _selectedHiveSuggestion;
        public ColorConversionSuggestion SelectedHiveSuggestion
        {
            get { return _selectedHiveSuggestion; }
            set { _selectedHiveSuggestion = value; RaisePropertyChangedAuto(); OnSelectedHiveSuggestionChanged(); }
        }

        private ColorConversionSuggestion _selectedSuggestion;
        public ColorConversionSuggestion SelectedSuggestion
        {
            get { return _selectedSuggestion; }
            set { _selectedSuggestion = value; RaisePropertyChangedAuto(); }
        }

        public FineTuningPaletteViewVM()
        {
            Suggestions = new List<ColorConversionSuggestion>();
            HiveSuggestions = new List<ColorConversionSuggestion>();
        }

        private void OnSelectedHiveSuggestionChanged()
        {
            if (!_prevent_change)
            {
                Suggestions = TangoColorConverter.CreateTrippletSuggestions(TangoColorConverter.GetSuggestions(_job, SelectedHiveSuggestion.Color));
                SelectedSuggestion = Suggestions[Suggestions.Count / 2];
            }
        }

        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;
        }
    }
}