コード例 #1
0
        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;
        }
コード例 #2
0
        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);
        }