Interaction logic for WindowBigBlind.xaml
Inheritance: System.Windows.Window
Exemple #1
0
        public TableHud(Table table)
        {
            #region Init Windows

            Methods.UiInvoke(() =>
            {
                Table = table;
                WindowTimer = new WindowTimer(Table);
                WindowTimer.Opacity = 0;
                WindowTimer.Show();
                for (int i = 0; i < 10; i++)
                {
                    WindowsBigBlind[i] = new WindowBigBlind(Table, i);
                    WindowsBigBlind[i].Opacity = 0;
                    WindowsBigBlind[i].Show();
                }
            });

            #endregion

            _thread = new Thread(() =>
            {
                try
                {
                    while (true)
                    {
                        #region Calculate Timer / BigBlinds

                        string title = Table.Title, className = Table.ClassName;
                        long tournamentNumber;
                        decimal sb, bb, ante;

                        string timerValue = null;
                        bool timerVisibility = false;
                        decimal[] bbValue = new decimal[10];
                        bool[] bbVisibility = new bool[10];
                        bool[] bbIsHero = new bool[10];
                        string[] bbTooltip = new string[10];

                        var success = GetInfo(title, out sb, out bb, out ante, out tournamentNumber);
                        if (success)
                        {
                            var tournament = App.HandHistoryManager.GetTournament(tournamentNumber);
                            if (tournament != null)
                            {
                                TableSize = tournament.GetLastHandTableSize();
                                GetContentTimer(title, className, tournament, sb, bb, out timerValue, out timerVisibility);
                                GetContentBigBlind(tournament, sb, bb, ante, out bbValue, out bbVisibility, out bbIsHero, out bbTooltip);
                            }
                        }

                        #endregion

                        #region Update Timer / BigBlinds

                        Methods.UiInvoke(() =>
                        {
                            try // to eliminate that stupid UpdateView null reference problem..
                            {
                                // Update View
                                WindowTimer.UpdateView(timerValue, PokerType != null ? PokerType.Name : "Unknown");
                                for (int i = 0; i < 10; i++)
                                {
                                    WindowsBigBlind[i].UpdateView(i, bbValue[i], bbTooltip[i], bbIsHero[i]);
                                }

                                // Ensure visibility
                                WindowTimer.EnsureVisibility(timerVisibility);
                                for (int i = 0; i < 10; i++)
                                {
                                    WindowsBigBlind[i].EnsureVisibility(bbVisibility[i] && ((!bbIsHero[i] && Config.HudBigBlindShowForOpponents) || (bbIsHero[i] && Config.HudBigBlindShowForHero)));
                                }
                            }
                            catch
                            {
                            }
                        });

                        #endregion

                        Thread.Sleep(500);
                    }
                }
            #if (DEBUG)
                catch (ThreadInterruptedException)
                {
                }
            #else
                catch (Exception e)
                {
                    if (!(e is ThreadInterruptedException))
                    {
                        Methods.DisplayException(e, App.WindowMain, WindowStartupLocation.CenterOwner);
                    }
                }
            #endif
                finally
                {
                    #region Dispose Windows

                    Methods.UiInvoke(() =>
                    {
                        WindowTimer.Close();
                        for (int i = 0; i < 10; i++)
                        {
                            WindowsBigBlind[i].Close();
                        }
                    });

                    #endregion
                }
            });
            _thread.Start();
        }
Exemple #2
0
        public TableHud(Table table)
        {
            #region Init Windows

            Methods.UiInvoke(() =>
            {
                Table               = table;
                WindowTimer         = new WindowTimer(Table);
                WindowTimer.Opacity = 0;
                WindowTimer.Show();
                for (int i = 0; i < 10; i++)
                {
                    WindowsBigBlind[i]         = new WindowBigBlind(Table, i);
                    WindowsBigBlind[i].Opacity = 0;
                    WindowsBigBlind[i].Show();
                }
            });

            #endregion

            _thread = new Thread(() =>
            {
                try
                {
                    while (true)
                    {
                        #region Calculate Timer / BigBlinds

                        string title = Table.Title, className = Table.ClassName;
                        long tournamentNumber;
                        decimal sb, bb, ante;

                        string timerValue    = null;
                        bool timerVisibility = false;
                        decimal[] bbValue    = new decimal[10];
                        bool[] bbVisibility  = new bool[10];
                        bool[] bbIsHero      = new bool[10];
                        string[] bbTooltip   = new string[10];

                        var success = GetInfo(title, out sb, out bb, out ante, out tournamentNumber);
                        if (success)
                        {
                            var tournament = App.HandHistoryManager.GetTournament(tournamentNumber);
                            if (tournament != null)
                            {
                                TableSize = tournament.GetLastHandTableSize();
                                GetContentTimer(title, className, tournament, sb, bb, out timerValue, out timerVisibility);
                                GetContentBigBlind(tournament, sb, bb, ante, out bbValue, out bbVisibility, out bbIsHero, out bbTooltip);
                            }
                        }

                        #endregion

                        #region Update Timer / BigBlinds

                        Methods.UiInvoke(() =>
                        {
                            try // to eliminate that stupid UpdateView null reference problem..
                            {
                                // Update View
                                WindowTimer.UpdateView(timerValue, PokerType != null ? PokerType.Name : "Unknown");
                                for (int i = 0; i < 10; i++)
                                {
                                    WindowsBigBlind[i].UpdateView(i, bbValue[i], bbTooltip[i], bbIsHero[i]);
                                }

                                // Ensure visibility
                                WindowTimer.EnsureVisibility(timerVisibility);
                                for (int i = 0; i < 10; i++)
                                {
                                    WindowsBigBlind[i].EnsureVisibility(bbVisibility[i] && ((!bbIsHero[i] && Config.HudBigBlindShowForOpponents) || (bbIsHero[i] && Config.HudBigBlindShowForHero)));
                                }
                            }
                            catch
                            {
                            }
                        });

                        #endregion

                        Thread.Sleep(500);
                    }
                }
#if (DEBUG)
                catch (ThreadInterruptedException)
                {
                }
#else
                catch (Exception e)
                {
                    if (!(e is ThreadInterruptedException))
                    {
                        Methods.DisplayException(e, App.WindowMain, WindowStartupLocation.CenterOwner);
                    }
                }
#endif
                finally
                {
                    #region Dispose Windows

                    Methods.UiInvoke(() =>
                    {
                        WindowTimer.Close();
                        for (int i = 0; i < 10; i++)
                        {
                            WindowsBigBlind[i].Close();
                        }
                    });

                    #endregion
                }
            });
            _thread.Start();
        }