public void TestCalculateContrastRatio_WhiteBlue()
        {
            var value = ColorContrastViewModel
                        .CalculateContrastRatio(Colors.White, Color.FromRgb(0, 0, 255));

            Assert.AreEqual(8.6, Math.Round(value, 1));
        }
        public void TestCalculateContrastRatio_WhiteRed()
        {
            var value = ColorContrastViewModel
                        .CalculateContrastRatio(Colors.White, Color.FromRgb(255, 0, 0));

            Assert.AreEqual(4.0, Math.Round(value, 1));
        }
        public void TestCalculateContrastRatio_GreenWhite()
        {
            var value = ColorContrastViewModel
                        .CalculateContrastRatio(Color.FromRgb(0, 255, 0), Colors.White);

            Assert.AreEqual(1.4, Math.Round(value, 1));
        }
        public void TestPassLargeText_WhiteRed()
        {
            ColorContrastViewModel vm = new ColorContrastViewModel();

            vm.FirstColor  = Colors.White;
            vm.SecondColor = Color.FromRgb(255, 0, 0);
            Assert.IsTrue(vm.PassLargeText);
        }
        public void TestPassLargeText_WhiteBlack()
        {
            ColorContrastViewModel vm = new ColorContrastViewModel();

            vm.FirstColor  = Colors.White;
            vm.SecondColor = Colors.Black;
            Assert.IsTrue(vm.PassLargeText);
        }
        public void TestPassLargeText_WhiteWhite()
        {
            ColorContrastViewModel vm = new ColorContrastViewModel();

            vm.FirstColor  = Colors.White;
            vm.SecondColor = Colors.White;
            Assert.IsFalse(vm.PassLargeText);
        }
Exemplo n.º 7
0
        public ColorContrast()
        {
            InitializeComponent();
            this.ContrastVM = new ColorContrastViewModel();

            // When user interacts with color chooser, reset selected element, hide pixel locations, and
            //  begin recording if eyedropper action is selected
            this.firstChooser.ColorChangerInvoked  += Chooser_ColorPickerClicked;
            this.secondChooser.ColorChangerInvoked += Chooser_ColorPickerClicked;

            // initial colors
            this.ContrastVM.FirstColor  = System.Windows.Media.Colors.Black;
            this.ContrastVM.SecondColor = System.Windows.Media.Colors.White;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="vm">VM of which to update with selected colors</param>
        /// <param name="first">Should FirstColor in the VM be updated</param>
        /// <param name="second">Should SecondColor in the VM be updated</param>
        /// <param name="closed">This will be called on eyedropper closing</param>
        public GlobalEyedropperWindow(ColorContrastViewModel vm, bool first, bool second, Action <object, EventArgs> closed)
        {
            InitializeComponent();
            onClose         = closed;
            ccVM            = vm;
            selectingFirst  = first;
            selectingSecond = second;
            radius          = Convert.ToInt32(Height / 2);

            InitializeRenderTransform();
            CaptureScreenshot();
            InitializeUpdateTimer();
            UpdatePos();
        }
 public void TestCalculateContrastRatio_WhiteWhite()
 {
     Assert.AreEqual(1.0, ColorContrastViewModel
                     .CalculateContrastRatio(Colors.White, Colors.White));
 }
        public void TestGetRelativeLuminance_Black()
        {
            double lumBlack = ColorContrastViewModel.GetRelativeLuminance(Colors.Black);

            Assert.AreEqual(0.0, lumBlack);
        }
        public void TestGetRelativeLuminance_White()
        {
            double lumWhite = ColorContrastViewModel.GetRelativeLuminance(Colors.White);

            Assert.AreEqual(1.0, lumWhite);
        }
        public ColorContrastPage()
        {
            InitializeComponent();

            BindingContext = _viewModel = new ColorContrastViewModel();
        }