Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSuggestColors(object sender, EventArgs e)
        {
            Color forwardColor, backwardColor;

            ColorBuilder.SuggestColors(data.ReferenceColor1, data.ReferenceColor2, out forwardColor, out backwardColor);

            data.ForwardColor  = forwardColor;
            data.BackwardColor = backwardColor;
            data.AutoColors    = false;

            dataBindingSource.ResetCurrentItem();
        }
Ejemplo n.º 2
0
        public void CB_SuggestColorsTest_01()
        {
            Color ref1 = Color.Brown, ref2 = Color.GreenYellow;
            Color fc, bc;

            for (int i = 0; i < 20; i++)
            {
                ColorBuilder.SuggestColors(ref1, ref2, out fc, out bc);

                Assert.IsTrue(ref1.GetSaturation() <= bc.GetSaturation(), "backward color saturation too low");
                Assert.IsTrue(bc.GetSaturation() <= ref2.GetSaturation(), "backward color saturation too high");
                Assert.IsTrue(ref1.GetBrightness() <= bc.GetBrightness(), "backward color brightness too low");
                Assert.IsTrue(bc.GetBrightness() <= ref2.GetBrightness(), "backward color brightness too high");

                Assert.IsTrue(ref1.GetSaturation() <= fc.GetSaturation(), "forward color saturation too low");
                Assert.IsTrue(fc.GetSaturation() <= ref2.GetSaturation(), "forward color saturation too high");
                Assert.IsTrue(ref1.GetBrightness() <= fc.GetBrightness(), "forward color brightness too low");
                Assert.IsTrue(fc.GetBrightness() <= ref2.GetBrightness(), "forward color brightness too high");

                Assert.IsTrue(bc.GetSaturation() <= fc.GetSaturation(), "saturation not ordered");
                Assert.IsTrue(bc.GetBrightness() <= fc.GetBrightness(), "brightness not ordered");
            }
        }