コード例 #1
0
        public RawSeatInfoDebugDisplay(string tableName, Dictionary <string, RawSeatInfo> input)
        {
            Form debug = new Form {
                Size = new System.Drawing.Size(400, 800), Text = "Debug for: " + tableName
            };

            Label      seatLabel;
            Label      nickLabel;
            PictureBox nicknameBox;
            PictureBox avatarBox;

            for (int i = 0; i < input.Count; i++)
            {
                string      seat = input.ElementAt(i).Key;
                RawSeatInfo rsi  = input.ElementAt(i).Value;
                Console.WriteLine(seat);

                seatLabel = new Label {
                    Text = seat, Width = 100, Height = 25, Left = 5, Top = i * 100
                };
                seatLabel.Show();

                nickLabel = new Label {
                    Text = rsi.nicknameSTRING, Width = 100, Height = 25, Left = 105, Top = i * 100
                };
                nickLabel.Show();

                avatarBox = new PictureBox {
                    Image = rsi.avatar, Width = 62, Height = 62, Left = 250, Top = i * 100
                };
                avatarBox.Show();

                nicknameBox = new PictureBox {
                    Image = rsi.nicknameBMP, Width = 120, Height = 23, Left = 105, Top = nickLabel.Top + 30
                };
                nicknameBox.Show();

                debug.Controls.Add(seatLabel);
                debug.Controls.Add(nickLabel);
                debug.Controls.Add(nicknameBox);
                debug.Controls.Add(avatarBox);
            }
            debug.Show();
        }
コード例 #2
0
        /// <summary>
        /// Triggers Tablescan where all info will be gathered and retrieve information will get separated into Data and GUI Parts
        /// </summary>
        /// <param name="button">ScanButton of table in focus</param>
        public static void scan(ScanButton button)
        {
            IntPtr handle = button.TableHandle;

            if (handle.Equals(IntPtr.Zero))
            {
                throw new Exception("Can't scan Zero Pointer");
            }

            // Get TableSize and check if supported by toolbox
            int tableSize = int.Parse(button.scanComboBox.SelectedItem.ToString());

            if (!GlobalSettings.General.SupportedTableSizes.Contains(tableSize))
            {
                throw new Exception("Unsupported Tablesize: " + tableSize);
            }

            // Init TableData with tablesize
            TableData table = new TableData(tableSize);

            // Retrieve Screenshot for table
            Bitmap screenshot = Screenshot.CaptureApplication(handle);

            // Checks if tablesize between scans has changed
            // If changed, means that we have to perform a completely new table (and get rid of locked seats and stuff)
            bool tableHasSameNumberOfSeats = true;

            // Table was scanned before
            if (tableSessions.ContainsKey(handle))
            {
                table = tableSessions[handle];

                // if tableSize from sessions is different than new one => start over with a new table since selection has changed (we sit on a new table)
                if (!table.getTableSize().Equals(tableSize))
                {
                    table                     = new TableData(tableSize);
                    table.tablename           = button.TableName;
                    table.tablePointer        = handle;
                    tableSessions[handle]     = table;
                    table.scanButton          = button;
                    tableHasSameNumberOfSeats = false;
                }
            }
            else // New Table aka First Scan of a table
            {
                table.tablename       = button.TableName;
                table.tablePointer    = handle;
                tableSessions[handle] = table;
                table.scanButton      = button;
            }

            // Get all unlocked Seats, as they are the only ones that should be scanned/updated from scratch
            Stack <string> scanTheseSeats = table.getUnlockedSeats();

            // Analyze those seats from screenshot
            ScreenshotAnalyzer scAnalyze = new ScreenshotAnalyzer(engine, screenshot, scanTheseSeats, tableSize);

            // Retrieve usable (aka string) information from the scan
            Dictionary <string, RawSeatInfo> unlockedSeatsInformation = scAnalyze.getRawSeatInfo();

            // Update/Set Retrieved info in TableData
            foreach (KeyValuePair <string, RawSeatInfo> kvp in unlockedSeatsInformation)
            {
                string      seat = kvp.Key;
                RawSeatInfo rsi  = kvp.Value;
                table.setNickname(seat, rsi.nicknameSTRING);
                table.setAvatar(seat, rsi.avatar);
            }

            // Run Button Creation at this point
            if (buttonInventory.ContainsKey(table.tablename))
            {
                if (tableHasSameNumberOfSeats) // Same table as before (probably)
                {
                    buttonInventory[table.tablename].removeUnlockedButtons(scanTheseSeats);
                    buttonInventory[table.tablename].updateButtons(table, false);
                }
                else // if there is a new table size than scan before => new table/remove all old buttons from display
                {
                    buttonInventory[table.tablename].removeAllButtons();
                    tableHasSameNumberOfSeats        = true;
                    buttonInventory[table.tablename] = new PlayerButtonHandler(table);
                }
            }
            else
            {
                buttonInventory[table.tablename] = new PlayerButtonHandler(table);
            }
        }