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 { /// /// Represents the fine tuning pallet dialog ViewModel. /// /// public class FineTuningPaletteViewVM : DialogViewVM { private Job _job; private bool _prevent_change; private IColorConverter _converter; private List _suggestions; /// /// Gets or sets the triplet suggestions. /// public List Suggestions { get { return _suggestions; } set { _suggestions = value; RaisePropertyChangedAuto(); } } private List _hiveSuggestions; /// /// Gets or sets the hive suggestions. /// public List HiveSuggestions { get { return _hiveSuggestions; } set { _hiveSuggestions = value; RaisePropertyChangedAuto(); } } private ColorConversionSuggestion _selectedHiveSuggestion; /// /// Gets or sets the selected hive suggestion. /// public ColorConversionSuggestion SelectedHiveSuggestion { get { return _selectedHiveSuggestion; } set { _selectedHiveSuggestion = value; RaisePropertyChangedAuto(); OnSelectedHiveSuggestionChanged(); } } private ColorConversionSuggestion _selectedSuggestion; /// /// Gets or sets the selected triplet suggestion. /// public ColorConversionSuggestion SelectedSuggestion { get { return _selectedSuggestion; } set { _selectedSuggestion = value; RaisePropertyChangedAuto(); } } /// /// Initializes a new instance of the class. /// public FineTuningPaletteViewVM() { Suggestions = new List(); HiveSuggestions = new List(); _converter = new DefaultColorConverter(); } /// /// Called when the selected hive suggestion has been changed /// private void OnSelectedHiveSuggestionChanged() { if (!_prevent_change) { Suggestions = _converter.Convert(_job, SelectedHiveSuggestion.Color, true).CreateTrippletSuggestions(); SelectedSuggestion = Suggestions.GetCenterSuggestion(); } } /// /// Initializes a new instance of the class. /// /// The fine tune item. /// The job. 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; } } }