Пример #1
0
        private static bool FuzzyMatch(int x, int y, uint color)
        {
            if (color == PixelColor.SpecialColorForPredicator)
            {
                return(DetectSpecialState(x, y));
            }

            Point newPos = ScreenUtility.Convert(new Point(x, y));

            Console.WriteLine("<{0}, {1}> -> <{2}, {3}>", x, y, newPos.X, newPos.Y);
            if (ScreenUtility.IsFullScreen)
            {
                Point[] points = new Point[]
                {
                    new Point(newPos.X - 1, newPos.Y),
                    new Point(newPos.X, newPos.Y),
                    new Point(newPos.X + 1, newPos.Y),
                    new Point(newPos.X, newPos.Y - 1),
                    new Point(newPos.X, newPos.Y + 1),
                };

                foreach (var point in points)
                {
                    if (color == PixelColor.SpecialColorForDetectingChange ||
                        color == PixelColor.SpecialColorForDetectingUnchange)
                    {
                        if (DetectChangeOrNotChange(point.X, point.Y, color))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        uint trueColor = GetPixelColor(point.X, point.Y);

                        if (trueColor == color)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            else
            {
                if (color == PixelColor.SpecialColorForDetectingChange ||
                    color == PixelColor.SpecialColorForDetectingUnchange)
                {
                    return(DetectChangeOrNotChange(x, y, color));
                }
                else
                {
                    return(color == GetPixelColor(x, y));
                }
            }
        }