/// <summary> /// Event manager of the create button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreate_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(this.txtStructureName.Text)) { MessageBox.Show("The structure name is empty, fix that!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { if (this.CreateStructure()) { this.CreateParameterFromForm("2nd", myStructure, this.chkSecondParam, this.cmbSecondParamType, this.txtSecondParamName, this.txtSecondParamLength); this.CreateParameterFromForm("3rd", myStructure, this.chkThirdParam, this.cmbThirdParamType, this.txtThirdParamName, this.txtThirdParamLength); this.CreateParameterFromForm("4th", myStructure, this.chkFourthParam, this.cmbFourthParamType, this.txtFourthParamName, this.txtFourthParamLength); this.CreateParameterFromForm("5th", myStructure, this.chkFifthParam, this.cmbFifthParamType, this.txtFifthParamName, this.txtFifthParamLength); this.CreateParameterFromForm("6th", myStructure, this.chkSixthParam, this.cmbSixthParamType, this.txtSixthParamName, this.txtSixthParamLength); if (!Directory.Exists(PathOfFiles)) { Directory.CreateDirectory(PathOfFiles); } this.CreateFiles(PathOfFiles, myStructure, this.packsDone, this.fullPackSize); this.PlayMusic(this.successSound); FrmSuccess fs = new FrmSuccess("your desktop 'C_Files' directory") { Location = this.Location }; fs.ShowDialog(); this.LockForm(this.locked); this.ClearTextBoxes(); myStructure.ListParamaters.Clear(); } } catch (Exception ex) { try { this.PlayMusic(this.errorSound); frmException fe = new frmException(ex) { Location = this.Location }; fe.ShowDialog(); } catch (NoSoundFoundException ns) { frmException fe = new frmException(ns) { Location = this.Location }; fe.ShowDialog(); } } } }
/// <summary> /// Event manager of the create button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreate_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txtStructureName.Text)) { MessageBox.Show("The structure name is empty, fix that!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { if (CreateStructure()) { if (chkSecondParam.Checked) { Parameter secondPa = new Parameter(); if (!String.IsNullOrWhiteSpace(txtSecondParamName.Text) && !String.IsNullOrWhiteSpace(txtSecondParamLenght.Text)) { secondPa = CreateParameter(myStructure, secondPa, txtSecondParamName.Text, cmbSecondParamType.SelectedItem.ToString(), txtSecondParamLenght.Text); if (!(myStructure + secondPa)) { MessageBox.Show($"An Error has occurred adding the 2nd parameter: {secondPa.NameParameter}!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { throw new EmptyFieldException("You have at least one field Empty."); } } if (chkThirdParam.Checked) { Parameter ThirdPa = new Parameter(); if (!String.IsNullOrWhiteSpace(txtThirdParamName.Text) && !String.IsNullOrWhiteSpace(txtThirdParamLenght.Text)) { ThirdPa = CreateParameter(myStructure, ThirdPa, txtThirdParamName.Text, cmbThirdParamType.SelectedItem.ToString(), txtThirdParamLenght.Text); if (!(myStructure + ThirdPa)) { MessageBox.Show($"An Error has occurred adding the 3rd parameter: {ThirdPa.NameParameter}!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { throw new EmptyFieldException("You have at least one field Empty."); } } if (chkFourthParam.Checked) { Parameter fourthPa = new Parameter(); if (!String.IsNullOrWhiteSpace(txtFourthParamName.Text) && !String.IsNullOrWhiteSpace(txtFourthParamLenght.Text)) { fourthPa = CreateParameter(myStructure, fourthPa, txtFourthParamName.Text, cmbFourthParamType.SelectedItem.ToString(), txtFourthParamLenght.Text); if (!(myStructure + fourthPa)) { MessageBox.Show($"An Error has occurred adding the 4th parameter: {fourthPa.NameParameter}!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { throw new EmptyFieldException("You have at least one field Empty."); } } CreateFiles(myStructure, packsDone, fullPackSize); MyPlayer(successSound); FrmSuccess fs = new FrmSuccess { Location = this.Location }; fs.ShowDialog(); myStructure.ListParamaters.Clear(); } } catch (Exception ex) { try { MyPlayer(errorSound); frmException fe = new frmException(ex) { Location = this.Location }; fe.ShowDialog(); } catch (NoSoundFoundException ns) { frmException fe = new frmException(ns) { Location = this.Location }; fe.ShowDialog(); } } } }