Exemplo n.º 1
0
        /// <summary>
        ///     Creates a screen handler to get the changed parts of the screen since the last check.
        /// </summary>
        /// <param name="screen">A rectangle that represents which part of the screen will be handled.</param>
        /// <param name="hashOnlyCompare">
        ///     If true, pixel data will be checked only by its HashCode, otherwise it will be checked
        ///     with the implemented Equals method
        /// </param>
        public ScreenHandler(Rectangle screen, bool hashOnlyCompare)
        {
            if (hashOnlyCompare)
            {
                Comparator = new HashComparer();
            }
            else
            {
                Comparator = new FullComparer();
            }

            var rect = new Rectangle2(screen);

            Bounds = rect;

            //One of the most expensive operations, getting the screen capture. Should be used as less as possible
            var pixels = PixelGrabber.GrabPixels(PixelGrabber.CreateScreenCapture(screen));

            LastPixels = pixels;

            var minTHeight = Bounds.Height / 6;
            var minTWidth  = Bounds.Width / 8;

            current     = new QuadTree(rect, pixels /*, minTHeight, minTWidth*/);
            previous    = current;
            firstScreen = true;
        }
Exemplo n.º 2
0
        public PatternMatcher(PatternValue value)
        {
            _value = value;

            _fullStraightComparer = new FullStraightComparer(value);
            _fullComparer         = new FullComparer(value);
            _halfStraightComparer = new HalfStraightComparer(value);
            _halfComparer         = new HalfComparer(value);
        }