コード例 #1
0
        internal void DetectInputs()
        {
            if (contourCircles == null)
            {
                return;
            }

            var toRemove = new List <InfraredInput>();
            var contours = contourCircles;

            for (var i = 0; i < Inputs.Count; i++)
            {
                var  led   = Inputs[i];
                bool found = false;

                for (var j = 0; j < contours.Length; j++)
                {
                    var circle = contourCircles[j];
                    if (led.InRange(new Point((int)circle.Center.X * 2, (int)circle.Center.Y * 2)))
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    toRemove.Add(led);
                }
            }

            for (var i = 0; i < toRemove.Count; i++)
            {
                Inputs.Remove(toRemove[i]);
                if (InfraredInputRemoved != null)
                {
                    InfraredInputRemoved(this, new InfraredInputEventArgs(toRemove[i]));
                }
            }


            for (var i = 0; i < contours.Length; i++)
            {
                var  circle   = contours[i];
                bool ledFound = false;

                for (int j = 0; j < Inputs.Count; j++)
                {
                    var led = Inputs[j];
                    if (led.InRange(new Point((int)circle.Center.X * 2, (int)circle.Center.Y * 2)))
                    {
                        Inputs[j].Center = new Point((int)circle.Center.X * 2, (int)circle.Center.Y * 2);
                        ledFound         = true;

                        if (InfraredInputLocationChanged != null)
                        {
                            InfraredInputLocationChanged(this, new InfraredInputEventArgs(led));
                        }
                    }
                }
                if (!ledFound)
                {
                    var led = new InfraredInput(new Point((int)circle.Center.X * 2, (int)circle.Center.Y * 2));
                    Inputs.Add(led);
                    if (InfraredInputAdded != null)
                    {
                        InfraredInputAdded(this, new InfraredInputEventArgs(led));
                    }
                }
            }
        }
コード例 #2
0
 public InfraredInputEventArgs(InfraredInput led)
 {
     Led = led;
 }