Example #1
0
        public static bool WaveformUpdateMenu(TreeNode currentNode)
        {
            //先将setupStr保存在一个字符串setupStrTemp中
            string setupStrTemp = MainWindow.setupStr;
            //将waveinfo文件中的内容保存在字符串waveAllInfoTemp中
            string waveformParStrTemp = FileOperation.ReadFile(MainWindow.waveinfoFilePath);

            //将info文件的内容保存到字符串allNodesInfoTemp中
            string waveformNodeInfoTemp     = FileOperation.ReadFile(MainWindow.nodeInfoFullPath);
            int    initialWaveformNodeSite  = waveformNodeInfoTemp.IndexOf(SetupContent.waveFormStr1 + " " + currentNode.Text + "\r\n");
            int    initialWaveformBlockSite = MainWindow.setupStr.IndexOf(SetupContent.waveFormStr1 + " " + currentNode.Text + "\r\n");

            NewWaveformWindow wfw = new NewWaveformWindow();

            //向窗体中的控件填写以前的内容
            WaveformDataRecoverOfProjectTree.AlterationWavePar(currentNode, waveformParStrTemp, wfw);
            //int siteOfUpdateWave = setupStr.IndexOf(SetupContent.waveFormStr1 + " " + currentNode.Text);

            //保存波形编号的那一行
            string initWaveformNum = GetWaveformNumLine(currentNode.Text, MainWindow.setupStr);

            //先删除需要更改的波形,否则同名的波形不能写到setup文件中
            if (!(WaveformDelOfSetupAndInfo(currentNode) && WaveformDelOfWaveInfo(currentNode)))
            {
                MessageBox.Show("文件被破坏,导致错误,原工程不可再用!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            MainWindow.creatSuccMesDisp = false;
            MainWindow.newFuncSign      = false;
            wfw.Text = "更改波形";

            //新建波形窗口可见,只能用showDialog()
            wfw.ShowDialog();
            //判断在新建波形窗口中单击的是哪个按钮
            switch (wfw.DialogResult)
            {
            case DialogResult.OK:
                //删除单击确定按钮后新添加的波形结点
                //在新建波形窗口中单击确定按钮后,会在工程树波形结点的最后添加更改的波形,将其的名字赋给选中的结点,
                //再将确定按钮增加的波形删除掉
                if (MainWindow.IsReturnMidwayInNewProcess)
                {
                    //myEventArgs e = new myEventArgs( setupStrTemp, waveformParStrTemp, waveformNodeInfoTemp);
                    //wfw.newsinusoidcancel_button2.Click -= new System.EventHandler(wfw.newSinusoidCancel_button2_Click);
                    //wfw.newsinusoidcancel_button2.Click +=e.A ;
                    //wfw.ShowDialog();

                    FileOperation.WriteFile(setupStrTemp, MainWindow.mProjectFullName, false);
                    MainWindow.setupStr = setupStrTemp;
                    FileOperation.WriteFile(waveformParStrTemp, MainWindow.waveinfoFilePath, false);
                    FileOperation.WriteFile(waveformNodeInfoTemp, MainWindow.nodeInfoFullPath, false);



                    MainWindow.IsReturnMidwayInNewProcess = false;
                    return(false);
                }
                //if (cancelOfUpdate)
                //{
                //    return true;
                //}
                if (!setupStrRecoverInitWaveformNum(currentNode, initWaveformNum, initialWaveformBlockSite, initialWaveformNodeSite))
                {
                    MessageBox.Show("程序内部发生错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    FileOperation.WriteFile(setupStrTemp, MainWindow.mProjectFullName, false);
                    MainWindow.setupStr = setupStrTemp;
                    FileOperation.WriteFile(waveformParStrTemp, MainWindow.waveinfoFilePath, false);
                    FileOperation.WriteFile(waveformNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                    return(false);
                }
                MainWindow.staticTreeView.SelectedNode.Text = MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[1].LastNode.Text;
                MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[1].LastNode.Remove();
                return(true);

            default:
                FileOperation.WriteFile(setupStrTemp, MainWindow.mProjectFullName, false);
                MainWindow.setupStr = setupStrTemp;
                FileOperation.WriteFile(waveformParStrTemp, MainWindow.waveinfoFilePath, false);
                FileOperation.WriteFile(waveformNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                //b= false;
                return(false);
            }
            //return b;
        }
Example #2
0
        //根据波形类型的不同,调出不同的窗口
        public static void AlterationWavePar(TreeNode currentNode, string allWaveformInfoStr, NewWaveformWindow wfw)
        {
            string waveTypeStr = GetTypeOfWave(currentNode, allWaveformInfoStr);

            switch (waveTypeStr)
            {
            case "正弦波<Sinusoid>":
                if (!GetLastParOfSinusoid(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "升余弦<Raised cosine>":
                if (!GetLastParOfRaisedCosine(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "根号升余弦<Root raised cosine>":
                if (!GetLastParOfRootRaisedCosine(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "高斯信号<Gaussian>":
                if (!GetLastParOfGaussian(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "离散高斯信号<Gaussian derivative>":
                if (!GetLastParOfGaussianDerivative(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "布莱曼波<Blackman>":
                if (!GetLastParOfBlackman(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "线性调频波<Chirp>":
                if (!GetLastParOfChirp(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "海明波<Hamming>":
                if (!GetLastParOfHamming(currentNode, allWaveformInfoStr, wfw))
                {
                    MessageBox.Show("程序内部产生错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;
            }
        }
Example #3
0
 private void NewWaveform_ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     f1 = OpenNewForm <NewWaveformWindow>(f1);
 }
Example #4
0
        private static bool GetLastParOfHamming(TreeNode currentNode, string allWaveformInfoStr, NewWaveformWindow wfw)
        {
            bool b = false;

            try
            {
                string   waveBlockStr = GetBlockOfWave(currentNode, allWaveformInfoStr);
                char[]   sep          = { '\r', '\r', '\r', '\r' };
                string[] partStr      = waveBlockStr.Split(sep);
                wfw.newhammingname_textBox32.Text  = currentNode.Text;
                wfw.newhammingsave_button24.Text   = "更新";
                wfw.newhammingcancel_button16.Text = "取消";
                wfw.comboBox1.Enabled = false;
                wfw.newhammingsave_button24.Enabled = false;
                //wfw.newhammingname_textBox32.ReadOnly = true;
                wfw.comboBox1.SelectedItem = "海明波<Hamming>";
                wfw.newhammingcarrierfrequency_textBox33.Text = partStr[2].Trim('\n');
                wfw.newhammingplusewidth_textBox34.Text       = partStr[3].Trim('\n');
                wfw.newhammingphase_textBox35.Text            = partStr[4].Trim('\n');
                b = true;
            }
            catch (Exception e)
            {
                LogFileManager.ObjLog.fatal(e.Message, e);
            }
            return(b);
        }
Example #5
0
        private static bool GetLastParOfChirp(TreeNode currentNode, string allWaveformInfoStr, NewWaveformWindow wfw)
        {
            bool b = false;

            try
            {
                //NewWaveformWindow wfw = new NewWaveformWindow();
                //wfw.Show();
                string   waveBlockStr = GetBlockOfWave(currentNode, allWaveformInfoStr);
                char[]   sep          = { '\r', '\r', '\r', '\r', '\r', '\r', '\r' };
                string[] partStr      = waveBlockStr.Split(sep);
                wfw.newchripname_textBox26.Text   = currentNode.Text;
                wfw.newchripsave_button23.Text    = "更新";
                wfw.newchripcancel_button14.Text  = "取消";
                wfw.comboBox1.Enabled             = false;
                wfw.newchripsave_button23.Enabled = false;
                //wfw.newchripname_textBox26.ReadOnly = true;
                //combox控件中的选中项是正弦波<Sinusoid>,将调出它所对应的panel
                wfw.comboBox1.SelectedItem = "线性调频波<Chirp>";
                wfw.newchripcarrierfrequency_textBox27.Text           = partStr[2].Trim('\n');
                wfw.newchripplusewidth_textBox28.Text                 = partStr[3].Trim('\n');
                wfw.newchriprolloff_textBox29.Text                    = partStr[4].Trim('\n');
                wfw.newchripfrequencyvariation_comboBox2.SelectedItem = partStr[5].Trim('\n');
                wfw.newchripstartfrequency_textBox30.Text             = partStr[6].Trim('\n');
                wfw.newchripstopfrequency_textBox31.Text              = partStr[7].Trim('\n');
                b = true;
            }
            catch (Exception e)
            {
                LogFileManager.ObjLog.fatal(e.Message, e);
            }
            return(b);
        }
Example #6
0
        private static bool GetLastParOfGaussianDerivative(TreeNode currentNode, string allWaveformInfoStr, NewWaveformWindow wfw)
        {
            bool b = false;

            try
            {
                string   waveBlockStr = GetBlockOfWave(currentNode, allWaveformInfoStr);
                char[]   sep          = { '\r', '\r', '\r' };
                string[] partStr      = waveBlockStr.Split(sep);
                wfw.newgaussianderivativename_textBox19.Text  = currentNode.Text;
                wfw.newgaussianderivativesave_button21.Text   = "更新";
                wfw.newgaussianderivativecancel_button10.Text = "取消";
                wfw.comboBox1.Enabled = false;
                wfw.newgaussianderivativesave_button21.Enabled = false;
                //wfw.newgaussianderivativename_textBox19.ReadOnly = true;
                wfw.comboBox1.SelectedItem = "离散高斯信号<Gaussian derivative>";
                wfw.newGaussianDerivativeCarrierFrenquency_textBox20.Text = partStr[2].Trim('\n');
                wfw.newGaussianDerivativeBandWidth_textBox21.Text         = partStr[3].Trim('\n');
                b = true;
            }
            catch (Exception e)
            {
                LogFileManager.ObjLog.fatal(e.Message, e);
            }
            return(b);
        }
Example #7
0
        private static bool GetLastParOfRootRaisedCosine(TreeNode currentNode, string allWaveformInfoStr, NewWaveformWindow wfw)
        {
            bool b = false;

            try
            {
                string   waveBlockStr = GetBlockOfWave(currentNode, allWaveformInfoStr);
                char[]   sep          = { '\r', '\r', '\r', '\r', '\r' };
                string[] partStr      = waveBlockStr.Split(sep);
                wfw.newrootraisedcosinename_textBox10.Text = currentNode.Text;
                wfw.newrootraisedcosinesave_button19.Text  = "更新";
                wfw.newrootraisedcosinecancel_button6.Text = "取消";
                wfw.comboBox1.Enabled = false;
                wfw.newrootraisedcosinesave_button19.Enabled = false;
                //wfw.newrootraisedcosinename_textBox10.ReadOnly = true;
                wfw.comboBox1.SelectedItem = "根号升余弦<Root raised cosine>";
                wfw.newrootraisedcosinecarrierfrequency_textBox11.Text = partStr[2].Trim('\n');
                wfw.newrootraisedcosineplusewidth_textBox12.Text       = partStr[3].Trim('\n');
                wfw.newrootraisedcosinephase_textBox13.Text            = partStr[4].Trim('\n');
                wfw.newrootraisedcosinerolloff_textBox14.Text          = partStr[5].Trim('\n');
                b = true;
            }
            catch (Exception e)
            {
                LogFileManager.ObjLog.fatal(e.Message, e);
            }
            return(b);
        }
Example #8
0
        //将waveinfo中相应块的内容写到控件中
        private static bool GetLastParOfSinusoid(TreeNode currentNode, string allWaveformInfoStr, NewWaveformWindow wfw)
        {
            bool b = false;

            try
            {
                string   waveBlockStr = GetBlockOfWave(currentNode, allWaveformInfoStr);
                char[]   sep          = { '\r', '\r', '\r', '\r' };
                string[] partStr      = waveBlockStr.Split(sep);
                wfw.newsinusoidname_textBox1.Text  = currentNode.Text;
                wfw.newsinusoidsave_button17.Text  = "更新";
                wfw.newsinusoidcancel_button2.Text = "取消";
                wfw.comboBox1.Enabled = false;
                wfw.newsinusoidsave_button17.Enabled = false;
                //wfw.newsinusoidname_textBox1.ReadOnly = true;
                //combox控件中的选中项是正弦波<Sinusoid>,将调出它所对应的panel
                wfw.comboBox1.SelectedItem = "正弦波<Sinusoid>";
                wfw.newsinusoidcarrierfrequency_textBox2.Text  = partStr[2].Trim('\n');
                wfw.newsinusoideffectivebandwith_textBox3.Text = partStr[3].Trim('\n');
                wfw.newsinusoidphase_textBox4.Text             = partStr[4].Trim('\n');
                b = true;
            }
            catch (Exception e)
            {
                LogFileManager.ObjLog.fatal(e.Message, e);
            }
            return(b);
        }