private double Probe(uint[] rgb)
        {
            if (_tune[rgb[0], rgb[1], rgb[2]] == 0)
            {
                Vcp.Gain.Red.CheckedValue   = rgb[0];
                Vcp.Gain.Green.CheckedValue = rgb[1];
                Vcp.Gain.Blue.CheckedValue  = rgb[2];

                Thread.Sleep(500);

                ArgyllProbe probe = new ArgyllProbe(true);
                if (!probe.Installed)
                {
                    PleaseInstall();
                    return(0);
                }
                if (probe.SpotRead())
                {
                    _tune[rgb[0], rgb[1], rgb[2]] = probe.ProbedColor.DeltaE00();
                }

                //return color.DeltaE00();
            }
            return(_tune[rgb[0], rgb[1], rgb[2]]);
        }
        public void ProbeLowLuminance()
        {
            var probe = new ArgyllProbe();

            if (!probe.Installed)
            {
                PleaseInstall();
                return;
            }


            new Thread(() =>
            {
                MonitorLevel level = Vcp.Brightness;
                //LineSeries _line = new LineSeries();

                //Curve.PlotModel.Series.Add(_line);

                uint max = Vcp.Gain.Red.Max;
                uint min = Vcp.Gain.Red.Min;

                double old  = Model.ProbeLut().Luminance;
                level.Value = 0;

                for (uint i = max; i >= min; i--)
                {
                    TuneWhitePoint(i);

                    Tune t = Lut.Current;

                    if (probe.SpotRead())
                    {
                        t.Y = probe.ProbedColor.xyY.Y;
                        t.x = probe.ProbedColor.xyY.x;
                        t.y = probe.ProbedColor.xyY.y;
                    }

                    Lut.RemoveLowBrightness(i);
                    Lut.Add(t);

                    //_line.Points.Add(new DataPoint(i, t.Y));
                    //Curve.Refresh();

                    if (t.MinGain <= min)
                    {
                        break;
                    }
                }

                Model.ProbeLut().Luminance = old;
            }
                       ).Start();
            return;
        }
        private void Probe(ArgyllProbe probe, Color c, MonitorLevel level)
        {
            //LineSeries line = new LineSeries {Color = c};


            //Curve.PlotModel.Series.Add(line);

            for (uint i = level.Min; i <= level.Max; i++)
            {
                level.CheckedValue = i;

                if (probe.SpotRead())
                {
                    //line.Points.Add(new DataPoint(i, probe.ProbedColor.Lab.L));
                    //Curve.Refresh();
                }
            }
        }
        public void Probe()
        {
            var probe = new ArgyllProbe();

            if (!probe.Installed)
            {
                PleaseInstall();
                return;
            }
            //Vcp.Brightness.SetToMax();
            //Vcp.Contrast.SetToMax();
            uint red   = Vcp.Gain.Red.Value;
            uint green = Vcp.Gain.Green.Value;
            uint blue  = Vcp.Gain.Blue.Value;

            //Vcp.Brightness.SetToMax();
            //Vcp.Contrast.SetToMax();
            //Vcp.Gain.Red.SetToMax();
            //Vcp.Gain.Green.SetToMax();
            //Vcp.Gain.Blue.SetToMax();
            new Thread(() =>
            {
                Vcp.Gain.Red.SetToMax();
                Vcp.Gain.Green.SetToMin();
                Vcp.Gain.Blue.SetToMin();
                Probe(probe, Colors.Red, Vcp.Contrast);

                Vcp.Gain.Red.SetToMin();
                Vcp.Gain.Green.SetToMax();
                Vcp.Gain.Blue.SetToMin();
                Probe(probe, Colors.Green, Vcp.Contrast);

                Vcp.Gain.Red.SetToMin();
                Vcp.Gain.Green.SetToMin();
                Vcp.Gain.Blue.SetToMax();
                Probe(probe, Colors.Blue, Vcp.Contrast);

                Vcp.Gain.Red.Value   = red;
                Vcp.Gain.Green.Value = green;
                Vcp.Gain.Blue.Value  = blue;
            }
                       ).Start();
            return;

            new Thread(() => {
                for (uint channel = 0; channel < 3; channel++)
                {
                    MonitorLevel level = Vcp.Gain.Channel(channel);
                    //LineSeries line = new LineSeries();

                    switch (channel)
                    {
                    case 0:
                        //line.Color = OxyColors.Red;
                        break;

                    case 1:
                        //line.Color = OxyColors.Green;
                        break;

                    case 2:
                        //line.Color = OxyColors.Blue;
                        break;
                    }

                    //    Curve.PlotModel.Series.Add(line);

                    uint max = level.Value;

                    for (uint i = 32; i <= max; i++)
                    {
                        level.Value = i; Thread.Sleep(1000);

                        if (probe.SpotRead())
                        {
                            //line.Points.Add(new DataPoint(i,probe.ProbedColor.DeltaE00()));
                            //Curve.Refresh();
                        }
                    }

                    double min  = double.MaxValue;
                    uint minIdx = level.Value;
                    //foreach (DataPoint dp in line.Points)
                    //{
                    //    if (dp.Y < min)
                    //    {
                    //        min = dp.Y;
                    //        minIdx = (uint)dp.X;
                    //    }
                    //}

                    level.Value = minIdx;
                }
            }
                       ).Start();
        }
        private void ProbeLuminance()
        {
            var probe = new ArgyllProbe();

            if (!probe.Installed)
            {
                PleaseInstall();
                return;
            }


            new Thread(() =>
            {
                MonitorLevel level = Vcp.Brightness;
                //LineSeries _line = new LineSeries();

                //_line.Color = OxyColors.Red;

                //Curve.PlotModel.Series.Add(_line);

                for (uint i = level.Min; i <= level.Max; i++)
                {
                    level.Value = i;

                    TuneWhitePoint();

                    Tune t = Lut.Current;
                    if (probe.SpotRead())
                    {
                        t.Y = probe.ProbedColor.xyY.Y;
                        t.x = probe.ProbedColor.xyY.x;
                        t.y = probe.ProbedColor.xyY.y;
                    }

                    Lut.RemoveBrightness(t.Brightness);
                    Lut.Add(t);

                    //_line.Points.Add(new DataPoint(i, t.Y));
                    //Curve.Refresh();
                }
            }
                       ).Start();
            return;

            new Thread(() => {
                for (uint channel = 0; channel < 3; channel++)
                {
                    MonitorLevel level = Vcp.Gain.Channel(channel);
                    //LineSeries line = new LineSeries();

                    switch (channel)
                    {
                    case 0:
                        //line.Color = OxyColors.Red;
                        break;

                    case 1:
                        //line.Color = OxyColors.Green;
                        break;

                    case 2:
                        //line.Color = OxyColors.Blue;
                        break;
                    }

                    //  Curve.PlotModel.Series.Add(line);

                    uint max = level.Value;

                    for (uint i = 32; i <= max; i++)
                    {
                        level.Value = i; Thread.Sleep(1000);
                        probe.SpotRead();
                        ProbedColor color = probe.ProbedColor;

                        //line.Points.Add(new DataPoint(i, color.DeltaE00()));
                        //Curve.Refresh();
                    }

                    double min  = double.MaxValue;
                    uint minIdx = level.Value;
                    //foreach (DataPoint dp in line.Points)
                    //{
                    //    if (dp.Y < min)
                    //    {
                    //        min = dp.Y;
                    //        minIdx = (uint)dp.X;
                    //    }
                    //}

                    level.Value = minIdx;
                }
            }
                       ).Start();
        }