コード例 #1
0
        private void ComboboxType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.IsLoaded)
            {
                if (this.IsSolidType())
                {
                    this.SetControlVisible(ColorFillType.Solid);
                }
                else
                {
                    this.SetControlVisible(ColorFillType.Gradient);
                    GradientEditor1.SwitchToGradient();
                }
            }
            else
            {
                RoutedEventHandler handler = default(RoutedEventHandler);
                handler = (a, b) =>
                {
                    this.Loaded -= handler;
                    ComboboxType_SelectionChanged(sender, e);
                };

                this.Loaded += handler;
            }
        }
コード例 #2
0
        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            Byte A = Convert.ToByte(OpacitySlider.Value * 255 / 100);

            System.Windows.Media.Color Color16 = (ColorPanelShow.Fill as SolidColorBrush).Color;
            System.Windows.Media.Color Color32 = System.Windows.Media.Color.FromArgb(A, Color16.R, Color16.G, Color16.B);
            ColorPanelShow.Fill = new SolidColorBrush(Color32);
            if (!this.IsSolidType())
            {
                GradientEditor1.SetAlpha(A);
            }
        }
コード例 #3
0
        private void StackPanel_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Border targetBox = e.OriginalSource as Border;

            if (targetBox == null)
            {
                if (this.IsSolidType())
                {
                    Byte CurAlpha = Convert.ToByte(OpacitySlider.Value * 255 / 100);
                    var  c        = _currentColor.ToColor();
                    c.A = CurAlpha;
                    ColorPanelShow.Fill = new SolidColorBrush(c);
                    //Initial color-32 information
                    string szARGB = ColorPanelShow.Fill.ToString();
                    string szRGB  = @"#" + szARGB.Substring(3, szARGB.Length - 3);
                    ColorInfoShow.Text = szRGB;
                }
                else
                {
                    GradientEditor1.RecoverHoverColor();
                    var c = GradientEditor1.SelectedColor;
                    ColorPanelShow.Fill = new SolidColorBrush(c);
                    //Initial color-32 information
                    string szARGB = ColorPanelShow.Fill.ToString();
                    string szRGB  = @"#" + szARGB.Substring(3, szARGB.Length - 3);
                    ColorInfoShow.Text = szRGB;
                }
                return;
            }
            //set color show panel
            System.Windows.Media.Color Color16 = (targetBox.Background as SolidColorBrush).Color;
            Byte A = Convert.ToByte(OpacitySlider.Value * 255 / 100);

            System.Windows.Media.Color Color32 = System.Windows.Media.Color.FromArgb(A, Color16.R, Color16.G, Color16.B);
            ColorPanelShow.Fill = new SolidColorBrush(Color32);

            //set color-32 information
            string sARGB = targetBox.Background.ToString();
            string sRGB  = @"#" + sARGB.Substring(3, sARGB.Length - 3);

            ColorInfoShow.Text = sRGB;

            if (!this.IsSolidType())
            {
                GradientEditor1.SetHoverColor(Color32);
            }
        }
コード例 #4
0
 private void TransparentButton_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (this.IsSolidType())
     {
         Byte A = Convert.ToByte(OpacitySlider.Value * 255 / 100);
         var  c = _currentColor.ToColor();
         c.A = A;
         ColorPanelShow.Fill = new SolidColorBrush(c);
         //Initial color-32 information
         string sARGB = ColorPanelShow.Fill.ToString();
         string sRGB  = @"#" + sARGB.Substring(3, sARGB.Length - 3);
         ColorInfoShow.Text = sRGB;
     }
     else
     {
         GradientEditor1.RecoverHoverColor();
         var c = GradientEditor1.SelectedColor;
         ColorPanelShow.Fill = new SolidColorBrush(c);
         //Initial color-32 information
         string szARGB = ColorPanelShow.Fill.ToString();
         string szRGB  = @"#" + szARGB.Substring(3, szARGB.Length - 3);
         ColorInfoShow.Text = szRGB;
     }
 }