示例#1
0
        /// <summary>
        /// Start SeatingScript
        /// </summary>
        /// <param name="button">ScanButton from table where scripts will start running (necessary to update GUI)</param>
        public void startSeating(ScanButton button)
        {
            // Init
            int              tableSize = getTableSize(button);
            IntPtr           pointer   = button.TableHandle;
            GraphicPositions graphics  = new GraphicPositions();

            // Chefk if emulator has preset size, if not => Resize
            SessionHandler.checkEmulatorSize(pointer);

            // Retrieve avatar rectangles for specific tablesize (avatar positions are seating buttons if nobody sits)
            Dictionary <string, Rectangle>[] positions       = graphics.getGraphicPositions(tableSize);
            Dictionary <string, Rectangle>   avatarPositions = positions[1];
            List <Rectangle> avaPosi = avatarPositions.Values.ToList();

            // BackgroundWorker needs Pointer of Table and positions of avatar rectangles to check
            // Construct parameters passed to Worker-Thread
            object[] parameters = new object[2];
            parameters[0] = pointer;
            parameters[1] = avaPosi;

            activeWorkers[pointer] = worker;
            worker.RunWorkerAsync(parameters);
            worker.scanButton = button;

            // Update ScanButton text
            button.Text = GlobalSettings.SeatingScript.StopSeatingScriptLabel;

            // Remove Click Events from ScanButton, otherwise it Scans the table before stopping the seating script
            RemoveClickEvent(button);

            // Set EventHandler on Click to Stopping SeatingScript instead of Scanning Table
            button.Click += ButtonStopSeatingScript_Click;
        }
        /// <summary>
        /// Retrieves avatar for specific seatname (Cropping to relevant part)
        /// </summary>
        /// <param name="screen">Tablescreenshot</param>
        /// <param name="seatname">Seatname in focus</param>
        /// <param name="numberOfSeats">Tablesize (pick correct positions)</param>
        /// <returns>Avatar Image</returns>
        public static Bitmap getSingleAvatar(Bitmap screen, string seatname, int numberOfSeats) // Return new avatar/Update avatar
        {
            GraphicPositions graphics = new GraphicPositions();

            Dictionary <string, Rectangle>[] positions = graphics.getGraphicPositions(numberOfSeats);
            Rectangle singleAvatar = positions[1][seatname];

            return(Screenshot.CropImage(screen, singleAvatar));
        }
        /// <summary>
        /// Initialize with info provided
        /// </summary>
        /// <param name="ocrEngine">TesseractEngine Instance</param>
        /// <param name="screen">TableScreenshot</param>
        /// <param name="seats">Stack of Seats which will get analyzed (f.e. only unlocked seats)</param>
        /// <param name="numberOfSeats">Tablesize (important for picking correct positions)</param>
        public ScreenshotAnalyzer(TesseractEngine ocrEngine, Bitmap screen, Stack <string> seats, int numberOfSeats)
        {
            screenshot = screen;
            tableSize  = numberOfSeats;
            GraphicPositions graphics = new GraphicPositions();

            // 0 = positions of nickname rectangles for tablesize
            // 1 = positions of avatar rectangles for tablesize
            Dictionary <string, Rectangle>[] positions = graphics.getGraphicPositions(tableSize);
            nicknamePositions = positions[0];
            avatarPositions   = positions[1];

            // Construct raw info from provided Seat-Stack
            rawInfo = constructRawSeatinfo(seats);
            // Perform OCR
            rawInfo = runOpticalCharacterRecognition(ocrEngine, rawInfo);
        }