Ejemplo n.º 1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCode.Text.Trim()))
            {
                MessageBox.Show(this, Resources.GGCodeEmpty, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (FGame != null)
            {
                var tmpPath = Path.Combine(Path.GetTempPath(), FGame.Code);
                try
                {
                    FGame.CopyTo(tmpPath);
                    var lGame = NesApplication.FromDirectory(tmpPath);
                    (lGame as NesApplication).GameGenie = textBoxCode.Text;
                    lGame.Save();
                    (lGame as ISupportsGameGenie).ApplyGameGenie();
                }
                catch (GameGenieFormatException)
                {
                    MessageBox.Show(this, string.Format(Resources.GameGenieFormatError, textBoxCode.Text, FGame.Name), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (GameGenieNotFoundException)
                {
                    MessageBox.Show(this, string.Format(Resources.GameGenieNotFound, textBoxCode.Text, FGame.Name), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                finally
                {
                    if (Directory.Exists(tmpPath))
                    {
                        Directory.Delete(tmpPath, true);
                    }
                }
            }

            if (string.IsNullOrEmpty(textBoxDescription.Text.Trim()))
            {
                MessageBox.Show(this, Resources.GGDescriptionEmpty, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            textBoxCode.Text = textBoxCode.Text.ToUpper().Trim();
            DialogResult     = System.Windows.Forms.DialogResult.OK;
        }
Ejemplo n.º 2
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;
        }