Beispiel #1
0
        public Form1()
        {
            InitializeComponent();
            InitializeContext();

            dtform = new DeckTrackerForm();
            dtform.Show();
            dtform.Hide();

            LoginWithDefaultIfPresent();
            HideWindow();
            Resize      += Form_Resize_Event;
            FormClosing += Form_Closing_Event;
        }
Beispiel #2
0
        private async void GameTick(object TimerState)
        {
            await GameAPI.UpdateState();

            if (GameAPI.EnteredGame())
            {
                _GameTimer?.Change(_InGameInterval, _InGameInterval);
                if (dtform.InvokeRequired)
                {
                    dtform.Invoke((MethodInvoker) delegate
                    {
                        dtform.Show();
                        Debug.WriteLine("Showing list");
                    });
                }
                else
                {
                    Invoke((MethodInvoker) delegate
                    {
                        dtform.Show();
                        Debug.WriteLine("Showing list");
                    });
                }
            }

            if (GameAPI.IsInGame())
            {
                GameAPI.ActiveGameTime += _InGameInterval;
                if (dtform.InvokeRequired)
                {
                    dtform.Invoke((MethodInvoker) delegate
                    {
                        if (!dtform.Visible)
                        {
                            if (dtform.IsDisposed)
                            {
                                dtform = new DeckTrackerForm();
                                dtform.Reset();
                            }

                            dtform.Show();
                        }
                        dtform.SetDeck(GameAPI.LastActiveDeck);
                        dtform.UpdateState(GameAPI.LastBoardState);
                    });
                }
                else
                {
                    Invoke((MethodInvoker) delegate
                    {
                        if (!dtform.Visible)
                        {
                            if (dtform.IsDisposed)
                            {
                                dtform = new DeckTrackerForm();
                                dtform.Reset();
                            }

                            dtform.Show();
                        }
                        dtform.SetDeck(GameAPI.LastActiveDeck);
                        dtform.UpdateState(GameAPI.LastBoardState);
                    });
                }
            }

            if (GameAPI.QuitGame() || GameAPI.IsOffline())
            {
                _GameTimer?.Change(_NotIngameInterval, _NotIngameInterval);
            }

            if (GameAPI.IsInMenu())
            {
                _GameTimer?.Change(_NotIngameInterval, _NotIngameInterval);

                if (dtform.InvokeRequired)
                {
                    dtform.Invoke((MethodInvoker) delegate
                    {
                        if (dtform.Visible)
                        {
                            dtform.Hide();
                            dtform.Reset();
                            Debug.WriteLine("Closing List");
                        }
                    });
                }
                else
                {
                    Invoke((MethodInvoker) delegate
                    {
                        if (dtform.Visible)
                        {
                            dtform.Hide();
                            dtform.Reset();
                            Debug.WriteLine("Closing List");
                        }
                    });
                }
            }

            if (GameAPI.IsOffline())
            {
                GameConnectionLabel.Invoke((MethodInvoker) delegate
                {
                    GameConnectionLabel.Text = "Unable to connect. Is the game running?";
                });
            }
            else
            {
                if (GameConnectionLabel.Text != "Connected!")
                {
                    GameConnectionLabel.Invoke((MethodInvoker) delegate
                    {
                        GameConnectionLabel.Text = "Connected!";
                    });
                }
            }
        }