Beispiel #1
0
        // ----------------------
        void ChangeSelection(enPropertyTarget propertyTarget, ColorOption colorOption, bool newValue)
        {
            if (newValue == false)
            {
                if (((propertyTarget == enPropertyTarget.BackgroundColor) && (BackgroundColorOption == colorOption)) ||
                    ((propertyTarget == enPropertyTarget.TextColor) && (TextColorOption == colorOption)))
                {
                    // Can't deselect the current item, as we don't know what else to select instead
                    colorOption.OnPropertyChanged("BackgroundSelected");
                }
                else
                {
                    colorOption.SetSelected(propertyTarget, false);
                }
            }
            else if ((propertyTarget == enPropertyTarget.BackgroundColor) && (colorOption == TextColorOption))
            {
                // Text and Background cannot be the same
                //TODO: Show message?
                colorOption.OnPropertyChanged("BackgroundSelected");
            }
            else if ((propertyTarget == enPropertyTarget.TextColor) && (colorOption == BackgroundColorOption))
            {
                // Text and Background cannot be the same
                //TODO: Show message?
                colorOption.OnPropertyChanged("TextSelected");
            }
            else
            {
                foreach (var item in _colorOptions)
                {
                    if (item != colorOption)
                    {
                        item.SetSelected(propertyTarget, false);
                    }
                }
                colorOption.SetSelected(propertyTarget, true);

                if (propertyTarget == enPropertyTarget.BackgroundColor)
                {
                    BackgroundColorOption = colorOption;
                }
                else if (propertyTarget == enPropertyTarget.TextColor)
                {
                    TextColorOption = colorOption;
                }
            }
        }
Beispiel #2
0
        void InitColorOptions()
        {
            // ---------------------- Fill in _colorOptions

            List <ColorOption> list = new List <ColorOption>();

            foreach (var item in NamedColor.All)
            {
                ColorOption colorOption = new ColorOption(this, item);

                list.Add(colorOption);
            }

            var list2 = list.OrderBy(x => x.NamedColor.Name);

            _colorOptions.Clear();
            _colorOptions.AddRange(list2);


            // ---------------------- Create the Jump Points

            Dictionary <string, JumpPoint> dict = new Dictionary <string, JumpPoint>();

            foreach (var item in list2)
            {
                string cName = item.NamedColor.Name;
                string key   = cName.Substring(0, 1);

                if (!dict.ContainsKey(key))
                {
                    dict.Add(key, new JumpPoint(key, item));
                }
            }

            List <JumpPoint> jumps = new List <JumpPoint>();

            foreach (var item in dict)
            {
                jumps.Add(item.Value);
            }

            _jumpPoints.Clear();
            _jumpPoints.AddRange(jumps);

            OnPropertyChanged("ColorOptions");
            OnPropertyChanged("JumpPoints");

            // ----------------------
            if (Application.Current.Resources.ContainsKey(_backgroundColorKey))
            {
                Color color = (Color)Application.Current.Resources[_backgroundColorKey];
                BackgroundColorOption = FindColorOption(_colorOptions, color);
                if (_backgroundColorOption != null)
                {
                    _backgroundColorOption.SetSelected(enPropertyTarget.BackgroundColor, true);
                }
            }

            if (Application.Current.Resources.ContainsKey(_textColorKey))
            {
                Color color = (Color)Application.Current.Resources[_textColorKey];
                _textColorOption = FindColorOption(_colorOptions, color);
                if (_textColorOption != null)
                {
                    _textColorOption.SetSelected(enPropertyTarget.TextColor, true);
                }
            }
        }