/// <summary> /// Retrieves the found windows and saves them in pokerWindows arraylist /// </summary> /// <param name="hwnd"></param> /// <param name="lParam"></param> /// <returns></returns> private bool EnumWindowCallBack(int hwnd, int lParam) { int windowHandle = hwnd; StringBuilder sbc = new StringBuilder(256); Win32.GetClassName(hwnd, sbc, sbc.Capacity); string wndClass = sbc.ToString(); // Ugly Party & Stars check if (wndClass != "#32770" && !wndClass.StartsWith("Afx:400000:b:") && wndClass != "FTC_TableViewFull") { return(true); } StringBuilder sb = new StringBuilder(512); Win32.GetWindowText(windowHandle, sb, sb.Capacity); string wndTitle = sb.ToString(); // Is this a poker table? if (!pokerTables.ContainsKey(hwnd)) { if (TableFactory.IsPokerTable(wndClass, wndTitle, hwnd)) { // Create the table object PokerTable table = TableFactory.MakePokerTable(hwnd); // Set the identification color table.IdentificationColor = getVacantTableIDColor(); // Set event handlers table.Closed += new TableFactory.ClosedEventHandler(tableClosed); table.RequiresAction += new TableFactory.RequiresActionEventHandler(tableRequiresAction); table.NoLongerRequiresAction += new TableFactory.NoLongerRequiresActionEventHandler(tableNoLongerRequiresAction); table.SittingOut += new TableFactory.SittingOutEventHandler(tableSittingOut); // Add the table to the pokerTables table pokerTables.Add(hwnd, table); // Update table list updateTables(); } else { // Look for lobby if (wndTitle.StartsWith("PartyPoker.com: Poker Lobby") && !pokerLobbies.ContainsKey(hwnd)) { pokerLobbies.Add(hwnd, new PartyLobby(hwnd)); } } } return(true); }
private void cmbSite_SelectedIndexChanged(object sender, EventArgs e) { switch (cmbSite.SelectedItem.ToString()) { case "": FormBorderStyle = FormBorderStyle.FixedDialog; currentPokerSite = TableFactory.Site.Invalid; break; case "Party Poker": FormBorderStyle = FormBorderStyle.Sizable; MinimumSize = PartyTable.SpecialMinTableSize; MaximumSize = PartyTable.SpecialMaxTableSize; currentPokerSite = TableFactory.Site.Party; Settings.LastUsedPokerSiteEditQuadrant = "Party"; break; case "PokerStars": FormBorderStyle = FormBorderStyle.Sizable; MinimumSize = StarsTable.SpecialMinTableSize; MaximumSize = StarsTable.SpecialMaxTableSize; currentPokerSite = TableFactory.Site.Stars; Settings.LastUsedPokerSiteEditQuadrant = "Stars"; break; case "FTP": FormBorderStyle = FormBorderStyle.FixedDialog; currentPokerSite = TableFactory.Site.FTP; MinimumSize = FTPTable.SpecialMinTableSize; MaximumSize = FTPTable.SpecialMaxTableSize; Settings.LastUsedPokerSiteEditQuadrant = "FTP"; break; } if (Width > MaximumSize.Width) { Width = MaximumSize.Width; } else if (Width < MinimumSize.Width) { Width = MinimumSize.Width; } Height = Convert.ToInt32((double)Width * PokerTable.GetAspectRatio(Width, currentPokerSite)); EditQuadrant_ResizeEnd(sender, e); }
/// <summary> /// Creates a poker table /// </summary> /// <param name="handle"></param> /// <returns></returns> public static PokerTable MakePokerTable(int handle) { PokerTable result = null; switch (DetermineSite(handle)) { case Site.Party: return(new PartyTable(handle)); case Site.Stars: return(new StarsTable(handle)); case Site.FTP: return(new FTPTable(handle)); } return(result); }
/// <summary> /// Checks if a new table should be moved to the active spot /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void moveTables_Tick(object sender, System.EventArgs e) { // Check for lobby minimizing if (Settings.KeepLobbyMinimized) { foreach (PartyLobby lobby in pokerLobbies.Values) { lobby.MinimizeWindow(); } } // Check for lobby opening if (Settings.KeepLobbyOpened) { foreach (PartyLobby lobby in pokerLobbies.Values) { lobby.OpenWindow(); } } // Update tables try { foreach (PokerTable table in pokerTables.Values) { table.InvokeActionTick(); } } catch { } // Check if any tables are unpositioned, and if autoarrange is on if (Settings.AutoArrangeTables) { foreach (PokerTable table in pokerTables.Values) { if (!disabledTables.ContainsKey(table.Handle)) { if (table.Quadrant == 0 || (table.IsSittingOut && table.Quadrant != Settings.NonSeatedTableQuadrant && Settings.PlaceUnseatedTablesAtSpecialLocation) || (!table.IsSittingOut && table.Quadrant == Settings.NonSeatedTableQuadrant && Settings.PlaceUnseatedTablesAtSpecialLocation)) { // Don't arrange tables while SNG Opener is open if (!SuspendMovement) { if ((!table.IsSeated() || table.IsSittingOut) && Settings.PlaceUnseatedTablesAtSpecialLocation) { table.MoveToQuadrant(Settings.GetQuad(Settings.NonSeatedTableQuadrant), false); } else { moveTableToFreeQuadrant(table.Handle, 0); } } } } } } // If there isn't an active table righ now if (!pokerTables.ContainsKey(activeTable) && actionQueue.Count > 0) { // Get the first in line table PokerTable table = pokerTables[actionQueue[0]]; // Move any tables currently occupying the active location, unless it's the table that's now active if (Settings.MoveActiveTable && table.Quadrant != Settings.ActiveTableQuadrant) { removeTableFromActiveQuadrant(table.Quadrant); } // Remove it from the queue if (actionQueue.Count > 0) { actionQueue.RemoveAt(0); } // Move it to the active quadrant if (Settings.MoveActiveTable) { table.MoveToQuadrant(Settings.GetQuad(Settings.ActiveTableQuadrant), true); } // Update activeTable activeTable = table.Handle; // Log table activation Log.Write(table.Name); // Start forceActivation timer if (Settings.ForceActiveTableToBeTopmost) { tableOnTopTimer.Enabled = true; } // Move mouse to table if wanted if (Settings.MoveCursorToActiveTable) { // Get the current table position Point pos = table.GetPosition(); // Only move the mouse if it's outside the table area if (Cursor.Position.X < pos.X || Cursor.Position.X > pos.X + table.Width || Cursor.Position.Y < pos.Y || Cursor.Position.Y > pos.Y + table.Height) { table.MoveCursorToTable(); } } // Notify the table that it's been activated table.HasBeenActivated(); } }
// Fires when a key has been pressed, used in conjunction with keyboard controls private void MyKeyDown(object sender, KeyEventArgs e) { if (Settings.RequireNumLock) { if (!Win32.NumLock()) { return; } } if (Settings.RequireCapsLock) { if (!Win32.CapsLock()) { return; } } if (Settings.UseKeyboardControls) { string keyCode = GetKeyCode(e); // Do we have an active table? if (pokerTables.ContainsKey(activeTable)) { PokerTable table = (PokerTable)pokerTables[activeTable]; switch (keyCode) { case "back": string txt = table.GetRaiseValue(); if (txt.Length > 0) { table.SetRaiseValue(txt.Substring(0, txt.Length - 1)); } break; case "0": table.SetRaiseValue(table.GetRaiseValue() + "0"); break; case "1": table.SetRaiseValue(table.GetRaiseValue() + "1"); break; case "2": table.SetRaiseValue(table.GetRaiseValue() + "2"); break; case "3": table.SetRaiseValue(table.GetRaiseValue() + "3"); break; case "4": table.SetRaiseValue(table.GetRaiseValue() + "4"); break; case "5": table.SetRaiseValue(table.GetRaiseValue() + "5"); break; case "6": table.SetRaiseValue(table.GetRaiseValue() + "6"); break; case "7": table.SetRaiseValue(table.GetRaiseValue() + "7"); break; case "8": table.SetRaiseValue(table.GetRaiseValue() + "8"); break; case "9": table.SetRaiseValue(table.GetRaiseValue() + "9"); break; case ".": table.SetRaiseValue(table.GetRaiseValue() + "."); break; } // Check / call if (keyCode == Settings.CheckCallKeyCode) { table.CheckCall(); } // Bet / raise if (keyCode == Settings.BetRaiseKeyCode) { table.BetRaise(); } // Fold if (keyCode == Settings.FoldKeyCode) { table.Fold(); } // Auto push if (keyCode == Settings.AutoPushKeyCode) { table.AutoPush(); } // Move cursor to active table if (keyCode == Settings.MoveCursorToActiveTableKeyCode) { table.MoveCursorToTable(); } } // Generic keyboard control functions // Rearrange tables if (keyCode == Settings.RearrangeTablesKeyCode) { rearrangeTables(); } // Toggle force table to top if (keyCode == Settings.ForceActiveTableTopmostKeyCode) { Settings.ForceActiveTableToBeTopmost = !Settings.ForceActiveTableToBeTopmost; } // Toggle lobby opened/minimized if (keyCode == Settings.ToggleLobbyKeyCode) { if (Settings.KeepLobbyMinimized || (!Settings.KeepLobbyOpened)) { Settings.KeepLobbyMinimized = false; Settings.KeepLobbyOpened = true; } else if (Settings.KeepLobbyOpened) { Settings.KeepLobbyMinimized = true; Settings.KeepLobbyOpened = false; } } } }
/// <summary> /// Fires when a voice command has been received /// </summary> /// <param name="StreamNumber"></param> /// <param name="StreamPosition"></param> /// <param name="RecognitionType"></param> /// <param name="Result"></param> private void commandReceived(string command) { if (Settings.RequireNumLock) { if (!Win32.NumLock()) { return; } } if (Settings.RequireCapsLock) { if (!Win32.CapsLock()) { return; } } // Do we have an active table? if (pokerTables.ContainsKey(activeTable)) { PokerTable table = pokerTables[activeTable]; if (Settings.UseVoiceCommands) { switch (command) { case "Bet": case "Raise": table.BetRaise(); break; case "Call": case "Check": table.CheckCall(); break; case "Fold": table.Fold(); break; case "Zero": table.SetRaiseValue(table.GetRaiseValue() + "0"); break; case "One": table.SetRaiseValue(table.GetRaiseValue() + "1"); break; case "Two": table.SetRaiseValue(table.GetRaiseValue() + "2"); break; case "Three": table.SetRaiseValue(table.GetRaiseValue() + "3"); break; case "Four": table.SetRaiseValue(table.GetRaiseValue() + "4"); break; case "Five": table.SetRaiseValue(table.GetRaiseValue() + "5"); break; case "Six": table.SetRaiseValue(table.GetRaiseValue() + "6"); break; case "Seven": table.SetRaiseValue(table.GetRaiseValue() + "7"); break; case "Eight": table.SetRaiseValue(table.GetRaiseValue() + "8"); break; case "Nine": table.SetRaiseValue(table.GetRaiseValue() + "9"); break; case "Ten": table.SetRaiseValue(table.GetRaiseValue() + "10"); break; case "Twenty": table.SetRaiseValue(table.GetRaiseValue() + "20"); break; case "Thirty": table.SetRaiseValue(table.GetRaiseValue() + "30"); break; case "Fourty": table.SetRaiseValue(table.GetRaiseValue() + "40"); break; case "Fifty": table.SetRaiseValue(table.GetRaiseValue() + "50"); break; case "Sixty": table.SetRaiseValue(table.GetRaiseValue() + "60"); break; case "Seventy": table.SetRaiseValue(table.GetRaiseValue() + "70"); break; case "Eighty": table.SetRaiseValue(table.GetRaiseValue() + "80"); break; case "Ninety": table.SetRaiseValue(table.GetRaiseValue() + "90"); break; case "Hundred": table.SetRaiseValue(table.GetRaiseValue() + "00"); break; case "Thousand": table.SetRaiseValue(table.GetRaiseValue() + "000"); break; case "Point": table.SetRaiseValue(table.GetRaiseValue() + "."); break; case "Clear": table.SetRaiseValue(""); break; case "Eleven": table.SetRaiseValue(table.GetRaiseValue() + "11"); break; case "Twelve": table.SetRaiseValue(table.GetRaiseValue() + "12"); break; case "Thirteen": table.SetRaiseValue(table.GetRaiseValue() + "13"); break; case "Fourteen": table.SetRaiseValue(table.GetRaiseValue() + "14"); break; case "Fifteen": table.SetRaiseValue(table.GetRaiseValue() + "15"); break; case "Sixteen": table.SetRaiseValue(table.GetRaiseValue() + "16"); break; case "Seventeen": table.SetRaiseValue(table.GetRaiseValue() + "17"); break; case "Eighteen": table.SetRaiseValue(table.GetRaiseValue() + "18"); break; case "Nineteen": table.SetRaiseValue(table.GetRaiseValue() + "19"); break; case "Push": table.AutoPush(); break; } // Presets if (command == Settings.VCPreset1) { table.SetRaiseValue(Settings.VCPreset1Amount); return; } if (command == Settings.VCPreset2) { table.SetRaiseValue(Settings.VCPreset2Amount); return; } if (command == Settings.VCPreset3) { table.SetRaiseValue(Settings.VCPreset3Amount); return; } } } }
double aspect_ratio(int width) { return(PokerTable.GetAspectRatio(width, currentPokerSite)); }