private void testbtn_Click(object sender, EventArgs e) { try { amp = Convert.ToDouble(ampBox.Text); if (amp >= 0.1 && amp <= 1) { AmpValidate.SetError(ampBox, ""); } else { AmpValidate.SetError(ampBox, "范围有误!(0.1 - 1)"); MessageBox.Show(" 幅度设置错误", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception myEx) { AmpValidate.SetError(ampBox, "格式有误!(0.1 - 1)"); ampBox.Focus(); } if (radioButton1.Checked) { CosineWave wavedata = new CosineWave(); try { wavedata.Set(Convert.ToDouble(textBox3.Text), Math.PI, Convert.ToInt32(comboBox1.Text), amp, Convert.ToDouble(lenBox.Text)); wavedata.amp = Convert.ToDouble(ampBox.Text); wavedata.Genarate(); wavedata.SaveFile(Createfilename("single", "wav")); MessageBox.Show(" 文件已保存", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception myEx) { MessageBox.Show(myEx.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { wavedata.Dispose(); } } if (radioButton2.Checked) { ChirpWave wavedata = new ChirpWave(); try { wavedata.Set(Convert.ToDouble(textBox2.Text), Convert.ToDouble(textBox4.Text), Convert.ToInt32(comboBox2.Text), Convert.ToDouble(textBox6.Text), amp); wavedata.Genarate(); wavedata.SaveFile(Createfilename("chirp", "wav")); MessageBox.Show(" 文件已保存", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception myEx) { MessageBox.Show(myEx.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { wavedata.Dispose(); } } }