private void ResultOnColourChanged(PaletteEntryViewModel vm) { if (vm.IsNew && Value.Contains(vm.Value)) { return; // Don't want to overwrite any existing values. } Value.MapValue(vm.Value, vm.Colour); // Doesn't matter if it's new or not, MapValue should overwrite the existing colour. }
private void OnAdd() { var value = Value.MaxValue + 1d; var vm = new PaletteEntryViewModel(value, Colors.White); Value.MapValue(vm.Value, vm.Colour); Subscribe(vm); entries.Add(vm); }
private void ResultOnDelete(PaletteEntryViewModel paletteEntryViewModel) { if (!paletteEntryViewModel.IsNew) { Value.RemoveValue(paletteEntryViewModel.Value); } entries.Remove(paletteEntryViewModel); Unsubscribe(paletteEntryViewModel); }
public PaletteListViewModel(IConfigurableValue value) : base(value) { entries = new ObservableCollection <PaletteEntryViewModel>(Value.GetMap().Select(x => { var result = new PaletteEntryViewModel(x.Item1, x.Item2); Subscribe(result); return(result); })); }
private void ResultOnValueChanged(PaletteEntryViewModel vm) { if (vm.IsNew || Value.Contains(vm.Value)) { return; } if (vm.IsNew) { Value.MapValue(vm.Value, vm.Colour); } else { Value.RemapValue(vm.OriginalValue, vm.Value); } }
private void Unsubscribe(PaletteEntryViewModel vm) { vm.ValueChanged -= ResultOnValueChanged; vm.ColourChanged -= ResultOnColourChanged; vm.Delete -= ResultOnDelete; }