Exemplo n.º 1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string value1;
            string value2;
            string value3;
            string value4;
            string value5;
            string value6;
            string value7;

            NavigationContext.QueryString.TryGetValue("val1", out value1);
            NavigationContext.QueryString.TryGetValue("val2", out value2);
            NavigationContext.QueryString.TryGetValue("val3", out value3);
            NavigationContext.QueryString.TryGetValue("val4", out value4);
            NavigationContext.QueryString.TryGetValue("val5", out value5);
            NavigationContext.QueryString.TryGetValue("val6", out value6);
            NavigationContext.QueryString.TryGetValue("val7", out value7);

            _originalRed   = byte.Parse(value1);
            _originalGreen = byte.Parse(value2);
            _originalBlue  = byte.Parse(value3);
            _sliderRed     = byte.Parse(value4);
            _sliderGreen   = byte.Parse(value5);
            _sliderBlue    = byte.Parse(value6);

            _hintsUsed = int.Parse(value7);

            OriginalRectangle.Fill = new SolidColorBrush(Color.FromArgb(255, _originalRed, _originalGreen, _originalBlue));
            PlayerRectangle.Fill   = new SolidColorBrush(Color.FromArgb(255, _sliderRed, _sliderGreen, _sliderBlue));

            OriginalRed.Text   = _originalRed.ToString();
            OriginalGreen.Text = _originalGreen.ToString();
            OriginalBlue.Text  = _originalBlue.ToString();

            PlayerRed.Text   = _sliderRed.ToString();
            PlayerGreen.Text = _sliderGreen.ToString();
            PlayerBlue.Text  = _sliderBlue.ToString();

            var difference = ColorManipulator.CIELab2000(
                ColorManipulator.RGBtoLab(_originalRed, _originalGreen, _originalBlue),
                ColorManipulator.RGBtoLab(_sliderRed, _sliderGreen, _sliderBlue)
                );

            ResultText.Text = difference.ToString("F2", CultureInfo.InvariantCulture);

            gradeText.Text = ColorManipulator.Grade(difference);

            hintsTextBlock.Text = _hintsUsed.ToString();
        }
Exemplo n.º 2
0
        private void SliderValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            var slider = sender as Slider;

            if (slider != null)
            {
                slider.Value = Math.Round(e.NewValue);
            }

            drawRectangle.Fill = new SolidColorBrush(Color.FromArgb(255, Convert.ToByte(redSlider.Value), Convert.ToByte(greenSlider.Value), Convert.ToByte(blueSlider.Value)));

            var diff = ColorManipulator.CIELab2000(
                ColorManipulator.RGBtoLab(_originalRed, _originalGreen, _originalBlue),
                ColorManipulator.RGBtoLab(Convert.ToByte(redSlider.Value), Convert.ToByte(greenSlider.Value),
                                          Convert.ToByte(blueSlider.Value))
                );
            //arrowIndicator.Value = diff;
        }
Exemplo n.º 3
0
        private void GradeButtonClick(object sender, RoutedEventArgs e)
        {
            //make buttons visible
            MakeButtonsVisible(Visibility.Collapsed);

            //make sliders enabled;
            MakeSlidersEnabled(false);

            CheckButton.IsEnabled = false;

            GradeText.Text = ColorManipulator.Grade(
                ColorManipulator.CIELab2000(
                    ColorManipulator.RGBtoLab(_originalRed, _originalGreen, _originalBlue),
                    ColorManipulator.RGBtoLab(Convert.ToByte(redSlider.Value), Convert.ToByte(greenSlider.Value), Convert.ToByte(blueSlider.Value))
                    )
                );

            GradeCloseButton.Visibility = Visibility.Visible;

            GradeButton.IsEnabled = false;
            _hintsUsed++;
        }