예제 #1
0
        private void ProcessSuspendWorker_DoWork(object sender, DoWorkEventArgs args)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                ProcessHandler.SuspendProcess();

                if (soundCuesTTS)
                {
                    soundHandler.speech.SpeakAsync("GTA suspended, one moment.");
                }

                for (int i = 0; i < 10; i++)
                {
                    if (soundCuesBeep)
                    {
                        soundHandler.PlayBeep(false);
                        Thread.Sleep(900); // sound will take 100ms
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                    worker.ReportProgress((i + 1) * 10);
                }

                ProcessHandler.ResumeProcess();

                if (soundCuesTTS)
                {
                    soundHandler.speech.SpeakAsync("GTA resumed.");
                }
                else if (soundCuesBeep)
                {
                    soundHandler.PlayBeep(true);
                }

                Thread.Sleep(500);
            }
            catch (Exception e)
            {
                if (e is IndexOutOfRangeException)
                {
                    MessageBox.Show("A process could not be found. Is GTA running?", "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Something went wrong. " +
                                    "Please make an issue on the Github " +
                                    "repository and include this error " +
                                    "message as a screenshot. Exception: " +
                                    e.Message, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
 private void ProcessDestroyWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     ProcessHandler.KillGTASocialClubProcess();
     if (soundCuesTTS)
     {
         soundHandler.speech.SpeakAsync("GTA processes destroyed.");
     }
     else if (soundCuesBeep)
     {
         soundHandler.PlayBeep(true);
     }
     Thread.Sleep(5000); // stops it from triggering again
 }
예제 #3
0
        public MainWindow(string[] args)
        {
            InitializeComponent();
            notifyIcon.Visible = false;

            // check if GTA process is running
            if (args.Length > 0) // high iq arg handler
            {
                foreach (string arg in args)
                {
                    switch (arg)
                    {
                    case "/nocheck":     // don't perform check for process
                        processCheckFlag = false;
                        break;

                    case "/hide":     // start in systray
                        notifyIcon.Visible = true;
                        this.WindowState   = FormWindowState.Minimized;
                        this.Hide();
                        this.Visible       = false; // for some reason Hide() doesn't always work
                        this.ShowInTaskbar = false;
                        break;

                    default:
                        break;
                    }
                }
            }

            if (processCheckFlag)
            {
                ProcessHandler.CheckProcess();
            }

            KeybindHandler.RegisterHotkeys(this);
            InitialiseBackgroundWorkers();

            balloonStatus = true;
        }