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 parameter: {secondPa.NameParameter}!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } 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 parameter: {ThirdPa.NameParameter}!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } 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 parameter: {fourthPa.NameParameter}!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } CreateFiles(myStructure, packsDone, fullPackSize); MessageBox.Show($"Structure {myStructure.FinalStructureName} Created Successfully, Congratulations!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { frmException fe = new frmException(ex); fe.Location = this.Location; fe.ShowDialog(); } } }
/// <summary> /// Clear all the unlocked textBox and set its length to 1. /// </summary> private void ClearTextBoxes() { try { if (this.textBoxes.Count > 0) { foreach (TextBox item in this.textBoxes) { item.Text = ""; } this.textBoxes.Clear(); } if (this.textChars.Count > 0) { foreach (TextBox item in this.textChars) { item.Text = "1"; } this.textChars.Clear(); } } catch (Exception e) { frmException fe = new frmException(e) { Location = this.Location }; fe.ShowDialog(); } }
private void StructureBuilder_Load(object sender, EventArgs e) { this.Hide(); FrmWelcome welcome = new FrmWelcome(); welcome.ShowDialog(); grpSecondParam.Enabled = false; grpThirdParam.Enabled = false; grpFourthParam.Enabled = false; chkThirdParam.Enabled = false; chkFourthParam.Enabled = false; btnCreate.Enabled = false; cmbFirstParamType.SelectedIndex = 0; cmbSecondParamType.SelectedIndex = 0; cmbThirdParamType.SelectedIndex = 0; cmbFourthParamType.SelectedIndex = 0; lblNewVersion.Text = appVersion; try { MyPlayer(loginSound); } catch (NoSoundFoundException ns) { frmException fe = new frmException(ns) { Location = this.Location }; fe.ShowDialog(); } }
/// <summary> /// EventHandler of the lock button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLock_Click(object sender, EventArgs e) { try { if (!locked) { MyPlayer(lockOnSound); locked = !locked; btnLock.ImageIndex = 1; grpAllComponents.Enabled = false; btnCreate.Enabled = true; } else { MyPlayer(lockOffSound); locked = !locked; btnLock.ImageIndex = 0; grpAllComponents.Enabled = true; btnCreate.Enabled = false; } } catch (NoSoundFoundException ns) { frmException fe = new frmException(ns) { Location = this.Location }; fe.ShowDialog(); } }
/// <summary> /// EventHandler of the lock button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLock_Click(object sender, EventArgs e) { try { this.LockForm(this.locked); } 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(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> /// EventHandler of Load Form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StructureBuilder_Load(object sender, EventArgs e) { this.Hide(); try { this.FormInitialState(); this.lblNewVersion.Text = this.appVersion; FrmWelcome welcome = new FrmWelcome(); if (welcome.ShowDialog() == DialogResult.OK) { this.PlayMusic(this.loginSound); } } 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(); } } } }