Esempio n. 1
0
        private void TrySetupAutostart()
        {
            if (ProcessHooker.HasExited()) // Make sure we are hooked
            {
                ProcessHooker.HookProcess();
            }

            if (ProcessHooker.HasExited())
            {
                MessageBox.Show("The game needs to be running!", "Error");

                buttonAutoStart.Enabled = Config.Instance().IsTwitchMode&& twitch?.Client != null && twitch.Client.IsConnected;
                buttonAutoStart.Text    = "Auto-Start";

                if (!Config.Instance().ContinueTimer)
                {
                    SetEnabled(false);

                    elapsedCount = 0;
                    stopwatch.Reset();

                    buttonMainToggle.Enabled   = true;
                    buttonTwitchToggle.Enabled = twitch?.Client != null && twitch.Client.IsConnected;
                }
                return;
            }

            ProcessHooker.AttachExitedMethod((sender, e) => buttonAutoStart.Invoke(new Action(() =>
            {
                buttonAutoStart.Enabled = Config.Instance().IsTwitchMode&& twitch?.Client != null && twitch.Client.IsConnected;
                buttonAutoStart.Text    = "Auto-Start";

                if (!Config.Instance().ContinueTimer)
                {
                    SetEnabled(false);

                    elapsedCount = 0;
                    stopwatch.Reset();

                    buttonMainToggle.Enabled   = true;
                    buttonTwitchToggle.Enabled = twitch?.Client != null && twitch.Client.IsConnected;
                }

                ProcessHooker.CloseProcess();
            })));

            buttonAutoStart.Enabled = false;
            buttonAutoStart.Text    = "Waiting...";

            Config.Instance().Enabled = false;
            autoStartTimer.Start();
            buttonMainToggle.Enabled   = false;
            buttonTwitchToggle.Enabled = twitch?.Client != null && twitch.Client.IsConnected;
        }
Esempio n. 2
0
        private void TrySetupAutostart()
        {
            if (ProcessHooker.HasExited()) // Make sure we are hookedtr
            {
                ProcessHooker.HookProcess();
            }

            if (ProcessHooker.HasExited())
            {
                buttonAutoStart.Enabled = true;
                buttonAutoStart.Text    = "Auto-Start";

                if (!Config.Instance.ContinueTimer)
                {
                    SetEnabled(false);

                    elapsedCount = 0;
                    Stopwatch.Reset();

                    buttonMainToggle.Enabled = true;
                }
                return;
            }

            ProcessHooker.AttachExitedMethod((sender, e) => buttonAutoStart.Invoke(new Action(() =>
            {
                buttonAutoStart.Enabled = true;
                buttonAutoStart.Text    = "Auto-Start";

                if (!Config.Instance.ContinueTimer)
                {
                    SetEnabled(false);

                    elapsedCount = 0;
                    Stopwatch.Reset();

                    buttonMainToggle.Enabled = true;
                }

                ProcessHooker.CloseProcess();
            })));

            buttonAutoStart.Enabled = false;
            buttonAutoStart.Text    = "Waiting...";

            Config.Instance.Enabled = false;
            AutoStartTimer.Start();
            buttonMainToggle.Enabled = false;
        }