コード例 #1
0
 public ColorPicker()
 {
     DefaultStyleKey = typeof(ColorPicker);
     m_selectedHue = 0;
     m_colorSpace = new ColorSpace();
     this.Width = this.Height = 200;
     this.LayoutUpdated += new EventHandler(ColorPicker_LayoutUpdated);
 }
コード例 #2
0
 public void RgbHsvConversion()
 {
     ColorSpace cs = new ColorSpace();
     for(int r = 0; r<255; r+=5)
         for(int g=0; g<255; g+=5)
             for(int b=0; b<255; b+=5)
             {
                 Color c1 = Color.FromArgb(255, (byte)r, (byte)g, (byte)b);
                 HSV tmpHSL = cs.ConvertRgbToHsv(c1);
                 Color c2 = cs.ConvertHsvToRgb(tmpHSL.Hue, tmpHSL.Saturation, tmpHSL.Value);
                 Assert.AreEqual(c1.R, c2.R);
                 Assert.AreEqual(c1.G, c2.G);
                 Assert.AreEqual(c1.B, c2.B);
                 Assert.AreEqual(c1.A, c2.A);
             }
 }
コード例 #3
0
 /// <summary>
 /// Create a new instance of the ColorPicker control.
 /// </summary>
 public ColorPicker()
 {
     DefaultStyleKey = typeof(ColorPicker);
     m_colorSpace    = new ColorSpace();
 }
コード例 #4
0
 /// <summary>
 /// Create a new instance of the ColorPicker control.
 /// </summary>
 public ColorPicker()
 {
     DefaultStyleKey = typeof(ColorPicker);
     m_colorSpace = new ColorSpace();
 }
コード例 #5
0
        private void UpdateVisuals()
        {
            if (m_hueMonitor == null)
                return;

            Color c = this.SelectedColor;
            ColorSpace cs = new ColorSpace();
            HSV hsv = cs.ConvertRgbToHsv(c);

            m_huePos = (hsv.Hue/360*m_hueMonitor.Height);
            m_sampleY = -1*(hsv.Value-1)*m_colorSample.Height;
            m_sampleX = hsv.Saturation*m_colorSample.Width;
            if(!double.IsNaN(m_huePos))
                UpdateHueSelection();
            UpdateSatValSelection();
        }