Exemplo n.º 1
0
 private void btnReset_Click(object sender, RoutedEventArgs e)
 {
     tb1.Text = _defaultSettings;
     SaveSettings(tb1.Text);
     _todLookup          = MainMain.BuildTimeOfDayLookup(tb1.Text);
     btnReload.IsEnabled = false;
 }
Exemplo n.º 2
0
        private void image1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                int x = (int)e.GetPosition((IInputElement)sender).X;
                int y = (int)(255 - e.GetPosition((IInputElement)sender).Y);
                this.Title = string.Format("{0},{1}", x, y);

                var array =
                    sender == image1 ? _transformR :
                    sender == image2 ? _transformG :
                    _transformB;

                var bmp =
                    sender == image1 ? wbmapR :
                    sender == image2 ? wbmapG :
                    wbmapB;

                var color =
                    sender == image1 ? Colors.Red :
                    sender == image2 ? Colors.Green :
                    Colors.Blue;

                array[x] = y;
                bmp.update(array, color);

                MainMain.CustomRamp(_transformR, _transformG, _transformB);
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();


            _multiplier = (slider1.Maximum - slider1.Minimum) / (slider2.Maximum - slider2.Minimum);
            _offset     = slider2.Minimum - (slider1.Minimum / _multiplier);


            _timer.Tick += t_Elapsed;
            _timer.Start();


            tb1.Text            = LoadSettings();
            _todLookup          = MainMain.BuildTimeOfDayLookup(tb1.Text);
            btnReload.IsEnabled = false;

            _finishedLoading = true;
        }
Exemplo n.º 4
0
        private void apply()
        {
            string methodName = (string)cboMethod.SelectedItem;

            if (methodName == null)
            {
                return;                     // nothing selected
            }
            int[] sliderValues = new[] { (int)slider1.Value, (int)slider2.Value, (int)slider3.Value, (int)slider4.Value };

            var values = _posterise.ApplyMethod(methodName, sliderValues);

            _transformR = values.Red;
            _transformG = values.Green;
            _transformB = values.Blue;

            wbmapR.update(_transformR, Colors.Red);
            wbmapG.update(_transformG, Colors.Green);
            wbmapB.update(_transformB, Colors.Blue);

            MainMain.CustomRamp(_transformR, _transformG, _transformB);
        }
Exemplo n.º 5
0
        private void update()
        {
            if (!_finishedLoading)
            {
                return;
            }

            double red, green, blue;
            double intensity = (slider1.Value - slider1.Minimum) / (slider1.Maximum - slider1.Minimum);

            lblIntensity.Content = intensity.ToString("N2");
            if (Method1.IsChecked)
            {
                MainMain.Method1(slider1.Value, out red, out green, out blue);
            }
            else if (Method2.IsChecked)
            {
                MainMain.Method2(slider1.Value, out red, out green, out blue);
            }
            else if (Method3.IsChecked)
            {
                MainMain.Method3(intensity, out red, out green, out blue);
            }
            else if (Method4.IsChecked)
            {
                MainMain.Method4(intensity, out red, out green, out blue);
            }
            else if (Method5.IsChecked)
            {
                MainMain.Method5(intensity, out red, out green, out blue);
            }
            else
            {
                throw new Exception("Unknown method");
            }

            var rrrr = (float)Math.Round(red / 255, 4);
            var gggg = (float)Math.Round(green / 255, 4);
            var bbbb = (float)Math.Round(blue / 255, 4);

            // BEGIN brightness
            rrrr = rrrr * (float)(slider2.Value / 100);
            gggg = gggg * (float)(slider2.Value / 100);
            bbbb = bbbb * (float)(slider2.Value / 100);
            // END brightness

            try
            {
                MainMain.SetGamma(
                    Convert.ToDouble(rrrr),
                    Convert.ToDouble(gggg),
                    Convert.ToDouble(bbbb),
                    chkPosterise.IsChecked == null || chkPosterise.IsChecked == true
                    );
                lblRGB.Content   = string.Format("{0:N3}\t{1:N3}\t{2:N3}", rrrr, gggg, bbbb);
                lblError.Content = "";
            }
            catch (Exception ex)
            {
                lblRGB.Content   = "";
                lblError.Content = ex.Message;
            }
        }