private void ColorChanged() { ColorAdapter existingColor = ColorSourceList .FirstOrDefault( caSource => caSource.A == _alphaValue && caSource.B == BlueValue && caSource.G == GreenValue && caSource.R == RedValue); ColorName = existingColor != null ? existingColor.Name : String.Empty; Color col = Color.FromArgb(AlphaValue, RedValue, GreenValue, BlueValue); string colName = GetColorName(col); var cc = new ColorAdapter(col, colName != string.Empty ? colName : ColorName); CurrentColor = cc; }
public ColorPadViewModel() { ColorSourceList = new ObservableCollection <ColorAdapter>(); SelectedColorsList = new ObservableCollection <ColorAdapter>(); SelectedColorsList.CollectionChanged += SelectedColorsListCollectionChanged; PropertyInfo[] items = typeof(Colors).GetProperties(); foreach (PropertyInfo c in items) { var col = (Color)c.GetValue(c, null); string colName = GetColorName(col); var ca = new ColorAdapter(col, colName); ColorSourceList.Add(ca); } PropertyChanged += ColorPadViewModelPropertyChanged; _addColor = new RelayCommand(ExecuteAddColor, CanExecuteAddcolor); }