Beispiel #1
0
    /// <summary>
    ///   Handles the <see cref="Control.Click" /> event of the OK button.
    /// </summary>
    /// <remarks>
    ///   This ensures that the information is valid before creating the FOMod/Premade FOMod Pack.
    /// </remarks>
    /// <param name="sender">The object that raised the event.</param>
    /// <param name="e">A <see cref="EventArgs" /> describing the event arguments.</param>
    private void butOK_Click(object sender, EventArgs e)
    {
      switch (PerformValidation())
      {
        case ValidationState.Errors:
          MessageBox.Show(this, "You must correct the errors before saving.", "Error", MessageBoxButtons.OK,
                          MessageBoxIcon.Error);
          return;
        case ValidationState.Warnings:
          if (
            MessageBox.Show(this,
                            "There are warnings." + Environment.NewLine +
                            "Warnings can be ignored, but they can indicate missing information that you meant to enter." +
                            Environment.NewLine + "Would you like to continue?", "Warning", MessageBoxButtons.OKCancel,
                            MessageBoxIcon.Warning) == DialogResult.Cancel)
          {
            return;
          }
          break;
        case ValidationState.Passed:
          break;
        default:
          throw new InvalidEnumArgumentException("Unexpected value for ValidationState enum.");
      }

      var rmeReadme = redReadmeEditor.Readme;
      var fscScript = fseScriptEditor.Script;
      var xmlInfo = m_booInfoEntered ? fomod.SaveInfo(finInfo) : null;

      var crsOldCursor = Cursor;
      Cursor = Cursors.WaitCursor;
      var lstCopyInstructions = ffsFileStructure.GetCopyInstructions();
      Cursor = crsOldCursor;

      if (cbxFomod.Checked)
      {
        var fgnGenerator = new NewFomodBuilder();
        FomodPath = fgnGenerator.BuildFomod(tbxFomodFileName.Text, lstCopyInstructions, rmeReadme, xmlInfo,
                                            m_booInfoEntered, finInfo.Screenshot, fscScript);
        if (String.IsNullOrEmpty(FomodPath))
        {
          return;
        }
      }
      if (cbxPFP.Checked)
      {
        Settings.Default.pfpOutputPath = tbxPFPPath.Text;
        Settings.Default.Save();

        var strVersion = "1.0";
        var strMachineVersion = "1.0";
        var xmlInfoTmp = fomod.SaveInfo(finInfo);
        if (xmlInfoTmp != null)
        {
          var xndVersion = xmlInfoTmp.SelectSingleNode("/fomod/Version");
          if (xndVersion != null)
          {
            strVersion = xndVersion.InnerText;
            var xatVersion = xndVersion.Attributes["MachineVersion"];
            if (xatVersion != null)
            {
              strMachineVersion = xatVersion.Value;
            }
          }
        }
        var fpbPackBuilder = new PremadeFomodPackBuilder();
        var strPFPPAth = fpbPackBuilder.BuildPFP(tbxFomodFileName.Text, strVersion, strMachineVersion,
                                                 lstCopyInstructions, sdsDownloadLocations.DataSource, tbxHowTo.Text,
                                                 rmeReadme, xmlInfo, m_booInfoEntered, finInfo.Screenshot, fscScript,
                                                 tbxPFPPath.Text);
        if (String.IsNullOrEmpty(strPFPPAth))
        {
          return;
        }
      }
      DialogResult = DialogResult.OK;
    }
Beispiel #2
0
        /// <summary>
        ///   Handles the <see cref="Control.Click" /> event of the OK button.
        /// </summary>
        /// <remarks>
        ///   This ensures that the information is valid before creating the FOMod/Premade FOMod Pack.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="EventArgs" /> describing the event arguments.</param>
        private void butOK_Click(object sender, EventArgs e)
        {
            switch (PerformValidation())
            {
            case ValidationState.Errors:
                MessageBox.Show(this, "You must correct the errors before saving.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;

            case ValidationState.Warnings:
                if (
                    MessageBox.Show(this,
                                    "There are warnings." + Environment.NewLine +
                                    "Warnings can be ignored, but they can indicate missing information that you meant to enter." +
                                    Environment.NewLine + "Would you like to continue?", "Warning", MessageBoxButtons.OKCancel,
                                    MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    return;
                }
                break;

            case ValidationState.Passed:
                break;

            default:
                throw new InvalidEnumArgumentException("Unexpected value for ValidationState enum.");
            }

            var rmeReadme = redReadmeEditor.Readme;
            var fscScript = fseScriptEditor.Script;
            var xmlInfo   = m_booInfoEntered ? fomod.SaveInfo(finInfo) : null;

            var crsOldCursor = Cursor;

            Cursor = Cursors.WaitCursor;
            var lstCopyInstructions = ffsFileStructure.GetCopyInstructions();

            Cursor = crsOldCursor;

            if (cbxFomod.Checked)
            {
                var fgnGenerator = new NewFomodBuilder();
                FomodPath = fgnGenerator.BuildFomod(tbxFomodFileName.Text, lstCopyInstructions, rmeReadme, xmlInfo,
                                                    m_booInfoEntered, finInfo.Screenshot, fscScript);
                if (String.IsNullOrEmpty(FomodPath))
                {
                    return;
                }
            }
            if (cbxPFP.Checked)
            {
                Settings.Default.pfpOutputPath = tbxPFPPath.Text;
                Settings.Default.Save();

                var strVersion        = "1.0";
                var strMachineVersion = "1.0";
                var xmlInfoTmp        = fomod.SaveInfo(finInfo);
                if (xmlInfoTmp != null)
                {
                    var xndVersion = xmlInfoTmp.SelectSingleNode("/fomod/Version");
                    if (xndVersion != null)
                    {
                        strVersion = xndVersion.InnerText;
                        var xatVersion = xndVersion.Attributes["MachineVersion"];
                        if (xatVersion != null)
                        {
                            strMachineVersion = xatVersion.Value;
                        }
                    }
                }
                var fpbPackBuilder = new PremadeFomodPackBuilder();
                var strPFPPAth     = fpbPackBuilder.BuildPFP(tbxFomodFileName.Text, strVersion, strMachineVersion,
                                                             lstCopyInstructions, sdsDownloadLocations.DataSource, tbxHowTo.Text,
                                                             rmeReadme, xmlInfo, m_booInfoEntered, finInfo.Screenshot, fscScript,
                                                             tbxPFPPath.Text);
                if (String.IsNullOrEmpty(strPFPPAth))
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }