예제 #1
0
        public static bool LaunchGame(string gwPath, string args, bool forced)
        {
            bool success = false;

            if (!forced)
            {
                //check to see if this copy is already started
                if (IsCopyRunning(gwPath))
                {
                    MessageBox.Show(gwPath + " is already running, please launch a different copy.",
                                    Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(success);
                }
            }

            Process gw = new Process();

            gw.StartInfo.FileName         = gwPath;
            gw.StartInfo.Arguments        = args;
            gw.StartInfo.WorkingDirectory = Directory.GetParent(gwPath).FullName;
            gw.StartInfo.UseShellExecute  = true;

            try
            {
                //set new gw path
                RegistryManager.SetGWRegPath(gwPath);

                //clear mutex to allow for another gw launch
                HandleManager.ClearMutex();

                //attempt to start gw process
                gw.Start();

                success = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error launching: " + gwPath + "!\n" + e.Message,
                                Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(success);
        }
예제 #2
0
        public static bool LaunchGame(string gwPath, string args, bool forced)
        {
            bool success = false;

            if (!forced)
            {
                //check to see if this copy is already started
                if (IsCopyRunning(gwPath))
                {
                    string errorString = gwPath + " is already running, please launch a different copy";
                    //var response = MessageBox.Show(errorString,
                    //Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //if (response == System.Windows.Forms.DialogResult.OK)
                    //{
                    //    System.Windows.Forms.Clipboard.SetDataObject(errorString, true);
                    //}
                    var notification = new NotifyIcon();
                    notification.Visible        = true;
                    notification.Icon           = System.Drawing.SystemIcons.Error;
                    notification.BalloonTipText = errorString;

                    // Display for 5 seconds.
                    notification.ShowBalloonTip(3000);
                    return(success);
                }
            }

            Process gw = new Process();

            gw.StartInfo.FileName         = gwPath;
            gw.StartInfo.Arguments        = args;
            gw.StartInfo.WorkingDirectory = Directory.GetParent(gwPath).FullName;
            gw.StartInfo.UseShellExecute  = true;

            try
            {
                //set new gw path
                RegistryManager.SetGWRegPath(gwPath);

                //clear mutex to allow for another gw launch
                HandleManager.ClearMutex();

                //attempt to start gw process
                gw.Start();

                success = true;
            }
            catch (Exception e)
            {
                string errorString = "Error launching: " + gwPath + "!\n" + e.Message + "trace: " + e.ToString();
                //var response = MessageBox.Show(errorString,
                //Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //if (response == System.Windows.Forms.DialogResult.OK)
                //{
                //    System.Windows.Forms.Clipboard.SetDataObject(errorString, true);
                //}
                exceptionNotification = new NotifyIcon
                {
                    Visible        = true,
                    Icon           = System.Drawing.SystemIcons.Error,
                    BalloonTipText = errorString
                };



                // Display for 5 seconds.
                exceptionNotification.ShowBalloonTip(3000);
                exceptionNotification.Dispose();
                writeLog(errorString);
            }

            gw.Dispose();
            GC.Collect();
            return(success);
        }
예제 #3
0
 private void startTexModButton_Click(object sender, EventArgs e)
 {
     RegistryManager.SetGWRegPath(GetSelectedInstall());
     HandleManager.ClearMutex();
     StartTexMod();
 }
예제 #4
0
 private void killMutexButton_Click(object sender, EventArgs e)
 {
     HandleManager.ClearMutex();
 }