Example #1
0
        public Table(String handHistoryFilePath, Window window, PokerClient pokerClient, PlayerDatabase playerDatabase)
        {
            this.handHistoryFilePath = handHistoryFilePath;
            this.window = window;
            this.pokerClient = pokerClient;
            this.playerDatabase = playerDatabase;
            this.Game = PokerGame.Unknown;
            this.maxSeatingCapacity = 0; // We don't know yet
            this.TableId = String.Empty; // We don't know yet
            this.GameID = String.Empty; // We don't know yet
            this.currentHeroName = String.Empty;
            this.currentHeroSeat = 0;
            this.gameType = pokerClient.GetPokerGameTypeFromWindowTitle(WindowTitle);
            this.statistics = new TableStatistics(this); // We don't know what specific kind
            this.Hud = new Hud(this);
            this.visualRecognitionManager = null; // Not all tables have a visual recognition manager
            this.displayWindow = PokerMuck.TableDisplayWindow.CreateForTable(this);

            // By default we use the universal parser
            handHistoryParser = new UniversalHHParser(pokerClient, System.IO.Path.GetFileName(handHistoryFilePath));

            // But as soon as we find what kind of game we're using, we're going to update our parser */
            ((UniversalHHParser)handHistoryParser).GameDiscovered += new UniversalHHParser.GameDiscoveredHandler(handHistoryParser_GameDiscovered);

            playerList = new List<Player>(10); //Usually no more than 10 players per table

            // Init hand history monitor
            hhMonitor = new HHMonitor(handHistoryFilePath, this);
            hhMonitor.StartMonitoring();
        }
 public TimedScreenshotTaker(int msInterval, Window window)
 {
     this.scrTaker = new ScreenshotTaker();
     this.msInterval = msInterval;
     this.window = window;
     this.running = false;
 }
        public VisualRecognitionManager(Table table, IVisualRecognitionManagerHandler handler)
        {
            Trace.Assert(table.Game != PokerGame.Unknown, "Cannot create a visual recognition manager without knowing the game of the table");
            Trace.Assert(table.WindowRect != Rectangle.Empty, "Cannot create a visual recognition manager without knowing the window rect");

            this.table = table;
            this.handler = handler;
            this.colorMap = ColorMap.Create(table.Game);
            this.recognitionMap = new VisualRecognitionMap(table.VisualRecognitionMapLocation, colorMap);
            this.matcher = new VisualMatcher(Globals.UserSettings.CurrentPokerClient);
            this.tableWindow = new Window(table.WindowTitle);

            this.timedScreenshotTaker = new TimedScreenshotTaker(REFRESH_TIME, tableWindow);
            this.timedScreenshotTaker.ScreenshotTaken += new TimedScreenshotTaker.ScreenshotTakenHandler(timedScreenshotTaker_ScreenshotTaken);
            this.timedScreenshotTaker.Start();
        }
Example #4
0
        /* @param size: if different than window size, resizes the window before taking the screenshot
         *    note that this is different than resizing a bitmap, we are literally changing the window size */
        public Bitmap Take(Window window, bool clientOnly, Size size, Mode mode)
        {
            // We cannot use this method if the window is minimized
            if (window.Minimized) return null;

            Size originalWindowSize = window.Size;
            bool needResize = !originalWindowSize.Equals(size);

            try
            {
                if (needResize)
                {
                    // If we are taking the client only, we don't need the extra repaint
                    window.Resize(size, clientOnly ? false : true);
                }

                Rectangle screenshotRect = clientOnly ? window.ClientRectangle : window.Rectangle;

                Bitmap result = new Bitmap(screenshotRect.Width, screenshotRect.Height, PixelFormat.Format24bppRgb);

                if (mode == Mode.PrintWindow)
                {
                    GetScreenshotUsingPrintWindow(window, clientOnly, result);
                }
                else if (mode == Mode.PrintScreen)
                {
                    GetScreenshotUsingPrintScreen(window, clientOnly, result);
                }

                // Restore original dimension
                if (needResize)
                {
                    window.Resize(originalWindowSize, true); // OK, repaint now!
                }

                return result;
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to take screenshot of " + window.Title + ": " + e.Message);
                return null;
            }
        }
Example #5
0
 private void GetScreenshotUsingPrintWindow(Window window, bool clientOnly, Bitmap buffer)
 {
     Graphics g = Graphics.FromImage(buffer);
     IntPtr hdc = g.GetHdc();
     uint nFlags = (clientOnly ? WM_PRINTCLIENTONLY : 0);
     PrintWindow(window.Handle, hdc, nFlags);
     g.ReleaseHdc(hdc);
 }
Example #6
0
 private void GetScreenshotUsingPrintScreen(Window window, bool clientOnly, Bitmap buffer)
 {
     Rectangle bounds = clientOnly ? window.ClientRectangle : window.Rectangle;
     using (Graphics g = Graphics.FromImage(buffer))
     {
         g.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size);
     }
 }
Example #7
0
        public Bitmap Take(Window window, bool clientOnly, Mode mode = Mode.PrintScreen)
        {
            Rectangle rect = window.Rectangle;
            Size winSize = new Size(rect.Width, rect.Height);

            return Take(window, clientOnly, winSize, mode);
        }