示例#1
0
        public ColorWindow()
        {
            InitializeComponent();

            NamedColor nc = NamedColor.SearchByName("White")[0];

            LineColor.Background = WheelColor.Background = new SolidColorBrush(nc.Color.GetWPFColor());

            if (nc != null)
            {
                WheelColorName.Content = nc.Name;
                LineColorName.Content  = nc.Name;
            }
            else
            {
                WheelColorName.Content = (nc.Color).ToString();
                LineColorName.Content  = (nc.Color).ToString();
            }
        }
示例#2
0
        private static void SelectedColorNamePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is ColorElement p)
            {
                string nv = (string)e.NewValue;
                string ov = (string)e.OldValue;

                if (ov != nv)
                {
                    if (string.IsNullOrEmpty(nv) || nv.StartsWith("#"))
                    {
                        p.SelectedNamedColors = new List <NamedColor>();
                    }
                    else
                    {
                        p.SelectedNamedColors = NamedColor.SearchByName(nv, true);
                    }
                }
            }
        }
示例#3
0
        private static void SelectedColorNamePropertyChanged(BindableObject d, object oldValue, object newValue)
        {
            if (d is ColorPicker p)
            {
                string nv = (string)newValue;
                string ov = (string)oldValue;

                if (ov != nv)
                {
                    if (string.IsNullOrEmpty(nv) || nv.StartsWith("#"))
                    {
                        p.SelectedNamedColors = new List <NamedColor>();
                    }
                    else
                    {
                        p.SelectedNamedColors = NamedColor.SearchByName(nv, true);
                    }
                }
            }
        }