예제 #1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCode.Text.Trim()))
            {
                Tasks.MessageForm.Show(Resources.Error, Resources.GGCodeEmpty, Resources.sign_error);
                return;
            }

            if (FGame != null)
            {
                var tmpPath = TempHelpers.getUniqueTempPath();
                try
                {
                    var lGame = FGame.CopyTo(tmpPath);
                    (lGame as NesApplication).GameGenie = textBoxCode.Text;
                    lGame.Save();
                    (lGame as ISupportsGameGenie).ApplyGameGenie();
                }
                catch (GameGenieFormatException)
                {
                    Tasks.MessageForm.Show(Resources.Error, string.Format(Resources.GameGenieFormatError, textBoxCode.Text, FGame.Name), Resources.sign_error);
                    return;
                }
                catch (GameGenieNotFoundException)
                {
                    Tasks.MessageForm.Show(Resources.Error, string.Format(Resources.GameGenieNotFound, textBoxCode.Text, FGame.Name), Resources.sign_error);
                    return;
                }
                finally
                {
                    if (Directory.Exists(tmpPath))
                    {
                        Directory.Delete(tmpPath, true);
                    }
                }
            }

            if (string.IsNullOrEmpty(textBoxDescription.Text.Trim()))
            {
                Tasks.MessageForm.Show(Resources.Error, Resources.GGDescriptionEmpty, Resources.sign_error);
                return;
            }
            textBoxCode.Text = textBoxCode.Text.ToUpper().Trim();
            DialogResult     = System.Windows.Forms.DialogResult.OK;
        }
예제 #2
0
 public static int InstallDriver()
 {
     try
     {
         int exitCode = 0;
         TempHelpers.doWithTempFolder((string temp) =>
         {
             var fileName = Path.Combine(Path.Combine(Program.BaseDirectoryInternal, "driver"), "classic_driver.exe");
             var process  = new Process();
             process.StartInfo.FileName         = fileName;
             process.StartInfo.WorkingDirectory = temp;
             process.StartInfo.Verb             = "runas";
             process.Start();
             process.WaitForExit();
             exitCode = process.ExitCode;
         });
         return(exitCode);
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.ToString());
         return(-1);
     }
 }