예제 #1
0
        //删除接收机时要更新setup文件中接收机的数目
        private static bool ReceiverUpdateOfSetup()
        {
            bool   b          = false;
            string rxFilePath = MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx";
            string rxFileStr  = FileOperation.ReadFile(rxFilePath);

            try
            {
                //如果接收机全部被删除
                if (rxFileStr.Length <= 0)//删除后
                {
                    File.Delete(rxFilePath);

                    int start = MainWindow.setupStr.IndexOf(SetupContent.receiverOfSetupStr0 + "\r\n");
                    int end   = MainWindow.setupStr.IndexOf(SetupContent.receiverOfSetupStr3 + "\r\n") + (SetupContent.receiverOfSetupStr3 + "\r\n").Length;
                    MainWindow.setupStr = MainWindow.setupStr.Remove(start, end - start);
                    FileOperation.WriteFile(MainWindow.setupStr, MainWindow.mProjectFullName, false);
                }
                //接收机没有全部被删除
                else
                {
                    string receiverCountStr     = StringFound.FoundBackStr("\nFirstAvailableRxNumber", MainWindow.setupStr, true);
                    string receiverCountLineOld = "\nFirstAvailableRxNumber " + receiverCountStr + "\r\n";
                    int    receiverCount        = int.Parse(receiverCountStr);
                    receiverCount = receiverCount - 1;
                    string receiverCountLineNew = "\nFirstAvailableRxNumber " + receiverCount.ToString() + "\r\n";
                    MainWindow.setupStr = MainWindow.setupStr.Replace(receiverCountLineOld, receiverCountLineNew);
                    FileOperation.WriteFile(MainWindow.setupStr, MainWindow.mProjectFullName, false);
                }
                b = true;
            }
            catch (Exception e)
            {
                LogFileManager.ObjLog.fatal(e.Message, e);
            }
            return(b);
        }
예제 #2
0
        //单击更改时执行此函数
        public static bool TransmitterUpdateMenu(TreeNode currentNode)
        {
            //bool b = false;
            string trFilePath = MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".tx";
            //将Tr文件中的字符串保护起来
            string trFileStrTemp = FileOperation.ReadFile(trFilePath);

            //将辐射源在tr文件中的位置保护起来
            int initialTransmitterBlockSite = trFileStrTemp.IndexOf(SetupContent.transmitterStr1OfTr + " " + currentNode.Text + "\r\n");
            //tx文件中原来辐射源的编号也要保存下来
            string initTransmitterNum = GetTransmitterNumLine(currentNode.Text, trFileStrTemp);
            //保存info文件中的所有字符串
            string transmitterNodeInfoTemp = FileOperation.ReadFile(MainWindow.nodeInfoFullPath);
            //保存辐射源在info文件中的位置信息
            int initialTransmitterNodeSite = transmitterNodeInfoTemp.IndexOf(SetupContent.transmitterStr1Ofsetup + " " + currentNode.Text + "\r\n");
            //保存waveinfo文件中有关辐射源的信息
            string transmitterParStrTemp = FileOperation.ReadFile(MainWindow.waveinfoFilePath);

            NewTransmitterWindow newTransmitterWin = new NewTransmitterWindow();

            //将原来辐射源设置的参数信息恢复到窗口中
            if (!TransmitterDataRecoverOfProjectTreeView.RecoverTransmitterParOfWin(currentNode, transmitterParStrTemp, newTransmitterWin))
            {
                MessageBox.Show("程序运行发生错误, 更改失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                FileOperation.RecoverOldRevision(trFileStrTemp, trFilePath, transmitterParStrTemp, transmitterNodeInfoTemp);
                return(false);
            }

            //TransmitterDataRecoverOfProjectTreeView.RecoverTransmitterParOfWin(currentNode, transmitterParStrTemp, newTransmitterWin);
            //在单击确定之前应先删除需更改的辐射源的全部信息
            if (!(TransmitterDelOfTrAndInfoFile(currentNode) && TransmitterDelOfWaveInfo(currentNode) && TransmitterUpdateOfSetup()))
            {
                MessageBox.Show("程序运行发生错误, 工程文件可能被破坏,更改失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                FileOperation.RecoverOldRevision(trFileStrTemp, trFilePath, transmitterParStrTemp, transmitterNodeInfoTemp);
                return(false);
            }

            MainWindow.creatSuccMesDisp = false;
            MainWindow.newFuncSign      = false;
            newTransmitterWin.Text      = "更改辐射源";
            newTransmitterWin.ShowDialog();
            switch (newTransmitterWin.DialogResult)
            {
            case DialogResult.OK:
                //如果在更改过程中出现了中途返回的情况,则应把原来的信息写到相应的文件中
                if (MainWindow.IsReturnMidwayInNewProcess)
                {
                    //FileOperation.WriteFile(trFileStrTemp , trFilePath , false);
                    //FileOperation.WriteFile(transmitterParStrTemp, MainWindow.waveinfoFilePath, false);
                    //FileOperation.WriteFile(transmitterNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                    FileOperation.RecoverOldRevision(trFileStrTemp, trFilePath, transmitterParStrTemp, transmitterNodeInfoTemp);

                    //将”全局变量“置为初始值
                    MainWindow.IsReturnMidwayInNewProcess = false;
                    return(false);
                }
                if (!trStrRecoverInitTransmitterNum(initTransmitterNum, initialTransmitterBlockSite, initialTransmitterNodeSite))
                {
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[3].LastNode.Remove();

                    MessageBox.Show("程序运行发生错误,更改操作失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    //FileOperation.WriteFile(trFileStrTemp, trFilePath, false);
                    //FileOperation.WriteFile(transmitterParStrTemp, MainWindow.waveinfoFilePath, false);
                    //FileOperation.WriteFile(transmitterNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                    FileOperation.RecoverOldRevision(trFileStrTemp, trFilePath, transmitterParStrTemp, transmitterNodeInfoTemp);
                    return(false);
                }

                MainWindow.staticTreeView.SelectedNode.Text = MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[3].LastNode.Text;
                MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[3].LastNode.Remove();
                return(true);

            //break;
            default:
                //FileOperation.WriteFile(trFileStrTemp , trFilePath , false);
                //FileOperation.WriteFile(transmitterParStrTemp, MainWindow.waveinfoFilePath, false);
                //FileOperation.WriteFile(transmitterNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                FileOperation.RecoverOldRevision(trFileStrTemp, trFilePath, transmitterParStrTemp, transmitterNodeInfoTemp);
                return(false);
                //break;
            }
            //return b;
        }
예제 #3
0
        private void newTerrainWindowOk_button1_Click(object sender, EventArgs e)
        {
            addTerrain = client.iGetTer((string)newTerrainName_comboBox1.SelectedItem);
            LogFileManager.ObjLog.info((string)newTerrainName_comboBox1.SelectedItem);
            //确保先创建工程。否则插入数据将会出错
            if (MainWindow.mProjectFullName == null)
            {
                MessageBox.Show("请先创建一个工程之后再从本地添加地形!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            else
            {
                //必须先选择地形,再单击确定
                if ((string)newTerrainName_comboBox1.SelectedItem != "")
                {
                    string t = addTerrain.path;
                    //将经纬度存储到.setup.info文件中
                    FileOperation.WriteLineFile(SetupContent.longitudeIndeStr + " " + addTerrain.originX, MainWindow.nodeInfoFullPath, true);
                    FileOperation.WriteLineFile(SetupContent.latitudeIndeStr + " " + addTerrain.originY, MainWindow.nodeInfoFullPath, true);
                    if (File.Exists(t) == false)
                    {
                        MessageBox.Show("数据库中已不存在此地图", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //查找begin_<project>后面的字符串temp
                    string temp = StringFound.FoundBackStr("begin_<project>", MainWindow.setupStr, true);
                    if (temp == null)
                    {
                        MessageBox.Show("程序内部发生错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        //查找begin_<project>后面的字符串temp
                        string nodeNamesStr = FileOperation.ReadFile(MainWindow.nodeInfoFullPath);
                        //若信息文件中已经添加了地形,再次添加时要从setup文件先删除原来的地形,从从工程树中删除原来的地形
                        if (nodeNamesStr.LastIndexOf("<terrain>") != -1)
                        {
                            DialogResult result = MessageBox.Show("您确定要替换原来添加的地形吗?", "提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                            if (result == DialogResult.OK)
                            {
                                if (!TerrainOperation.DeleteTerrain(nodeNamesStr))
                                {
                                    MessageBox.Show("对不起,程序内部发生错误,删除失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                MessageBox.Show("前一个地图已被替换", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                return;
                            }
                        }

                        //向全局字符串setupStr插入<global>段
                        int    startPosiGlobal = MainWindow.setupStr.IndexOf("begin_<project>") + 15 + temp.Length + 3;
                        string globalStr       = SetupContent.terrainGlobalFixedStr1 + newTerrainLongtitude_textBox2.Text + "\r\n"
                                                 + SetupContent.terrainGlobalFixedStr2 + newTerrainLatitude_textBox3.Text + "\r\n"
                                                 + SetupContent.terrainGlobalFixedStr3 + "\r\n";
                        MainWindow.setupStr = MainWindow.setupStr.Insert(startPosiGlobal, globalStr);
                        ////向全局字符串插入<studyarea>段  其中zmin zmax及地图顶点先设为默认值
                        int    startPosiStudyArea = MainWindow.setupStr.IndexOf("FirstAvailableStudyAreaNumber") + 33;
                        string studyAreaStr       = SetupContent.terrainStudyAreaStr1 + "\r\n"
                                                    + SetupContent.terrainStudyAreaStr2 + newTerrainLongtitude_textBox2.Text + "\r\n"
                                                    + SetupContent.terrainGlobalFixedStr2 + newTerrainLatitude_textBox3.Text + "\r\n"
                                                    + SetupContent.terrainStudyAreaStr3 + addTerrain.Zmin.ToString() + "\r\n"
                                                    + SetupContent.terrainStudyAreaStr4 + addTerrain.Zmax.ToString() + "\r\n"
                                                    + SetupContent.terrainStudyAreaStr5 + "\r\n"
                                                    + addTerrain.Vertex1X + " " + addTerrain.Vertex1Y + " " + addTerrain.Vertex1Z + "\r\n"
                                                    + addTerrain.Vertex2X + " " + addTerrain.Vertex2Y + " " + addTerrain.Vertex2Z + "\r\n"
                                                    + addTerrain.Vertex3X + " " + addTerrain.Vertex3Y + " " + addTerrain.Vertex3Z + "\r\n"
                                                    + addTerrain.Vertex4X + " " + addTerrain.Vertex4Y + " " + addTerrain.Vertex4Z + "\r\n"
                                                    + SetupContent.terrainStudyAreaStr6 + "\r\n";
                        MainWindow.setupStr = MainWindow.setupStr.Insert(startPosiStudyArea, studyAreaStr);
                        //向全局字符串插入<feature>段
                        int    startPosiFeature = MainWindow.setupStr.IndexOf("end_<studyarea>") + 17;
                        string featureStr       = SetupContent.terrainFeatureFixedStr1 + "\r\n"
                                                  + SetupContent.terrainFeatureFixedStr2 + "0" + "\r\n"
                                                  + SetupContent.terrainFeatureFixedStr3 + "\r\n"
                                                  + SetupContent.terrainFeatureFixedStr4
                                                  + MainWindow.projectRealPath + "\\" + (string)newTerrainName_comboBox1.SelectedItem + "\r\n"
                                                  + SetupContent.terrainFeatureFixedStr5 + "\r\n";
                        MainWindow.setupStr = MainWindow.setupStr.Insert(startPosiFeature, featureStr);



                        string terFileName = t.Substring(t.LastIndexOf('\\') + 1, t.Length - 1 - t.LastIndexOf('\\'));
                        //将ter文件拷贝到工程目录下
                        FileCopyUI.FileCopy(addTerrain.path, MainWindow.projectRealPath + "\\" + terFileName);
                        FileCopyUI.FileCopy(addTerrain.path + ".terinfo", MainWindow.projectRealPath + "\\" + terFileName + ".terinfo");

                        string terainStr = FileOperation.ReadFile(MainWindow.nodeInfoFullPath);
                        if (terainStr.IndexOf(SetupContent.terrainIndeStr) != -1)
                        {
                            terainStr = terainStr.Remove(terainStr.IndexOf(SetupContent.terrainIndeStr), SetupContent.terrainIndeStr.Length + 2);
                            FileOperation.WriteFile(terainStr, MainWindow.nodeInfoFullPath, false);
                        }
                        //将工程树的节点信息写到.info文件中
                        FileOperation.WriteLineFile(SetupContent.terrainIndeStr + " " + terFileName, MainWindow.nodeInfoFullPath, true);
                        FileOperation.WriteFile(MainWindow.setupStr, MainWindow.mProjectFullName, false);
                        MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[0].Nodes.Add(terFileName);
                    }
                }
            }
            this.Close();
        }
예제 #4
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LogFileManager.ObjLog.info("Begin");
            if (mProjectFullName != null)
            {
                DialogResult result = MessageBox.Show("您是否要打开一个新的工程?若是则原工程将被关闭。", "提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (DialogResult.OK == result)
                {
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Remove();
                }
                else
                {
                    MainWindow.mProjectFullName = null;  //王佳修改
                    MainWindow.setupStr         = null;
                    return;
                }
            }
            openProject.Filter = "setup文件(*.setup)|*.setup|所有文件|*.*";
            DialogResult dr = openProject.ShowDialog();

            if (dr == DialogResult.OK)
            {
                //在新建一个工程时,又打开这个工程则什么也不做 否则执行下面的操作
                if (mProjectFullName != openProject.FileName)
                {
                    setupStr = FileOperation.ReadFile(openProject.FileName);
                    //.setup文件的包括路径的名字
                    mProjectFullName = openProject.FileName;
                    //.setup.info文件的包含路径的名字
                    nodeInfoFullPath  = openProject.FileName + ".info";
                    transInfoFullPath = openProject.FileName + ".transinfo";

                    relationOfAntAndWavePath = openProject.FileName + ".match";
                    waveinfoFilePath         = openProject.FileName + ".waveinfo";

                    //工程的路径 不包括文件
                    MainWindow.projectRealPath = openProject.FileName.Substring(0, openProject.FileName.LastIndexOf("\\"));
                    staticTreeView.Nodes.Clear();
                    //从信息文件中找出工程树中工程的名字将其加载到工程树中
                    string nodeNamesStr   = FileOperation.ReadFile(nodeInfoFullPath);
                    string projectNameStr = StringFound.FoundBackStr(SetupContent.projectIndeStr, nodeNamesStr, true);
                    MainWindow.onlyProjectName = projectNameStr;
                    longitudeStr = StringFound.FoundBackStr(SetupContent.longitudeIndeStr, nodeNamesStr, true);
                    latitudeStr  = StringFound.FoundBackStr(SetupContent.latitudeIndeStr, nodeNamesStr, true);


                    staticTreeView.Nodes.Add("工程名字");
                    staticTreeView.Nodes[0].Nodes.Add(projectNameStr);
                    staticTreeView.Nodes[0].Nodes[0].Nodes.Add("地形");
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes.Add("波形");
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes.Add("天线");
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes.Add("辐射源");
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes.Add("接收机");
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes.Add("点状分布");
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes.Add("区域分布");

                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes.Add("仿真结果设定");


                    ArrayList nodeNamesArr = new ArrayList();
                    //向工程树中添加波形节点
                    nodeNamesArr = ProjectTreeMatchString.MatchStr(nodeNamesStr, SetupContent.waveIndeStr, SetupContent.waveIndeStr.Length);
                    foreach (string s in nodeNamesArr)
                    {
                        staticTreeView.Nodes[0].Nodes[0].Nodes[1].Nodes.Add(s);
                    }
                    //向工程树中添加地形节点
                    nodeNamesArr = ProjectTreeMatchString.MatchStr(nodeNamesStr, SetupContent.terrainIndeStr, SetupContent.terrainIndeStr.Length);
                    foreach (string s in nodeNamesArr)
                    {
                        staticTreeView.Nodes[0].Nodes[0].Nodes[0].Nodes.Add(s);
                    }
                    //向工程树种添加天线结点
                    nodeNamesArr = ProjectTreeMatchString.MatchStr(nodeNamesStr, SetupContent.antennaIndeStr, SetupContent.antennaIndeStr.Length);
                    foreach (string s in nodeNamesArr)
                    {
                        staticTreeView.Nodes[0].Nodes[0].Nodes[2].Nodes.Add(s);
                    }
                    //向工程树种添加辐射源结点
                    nodeNamesArr = ProjectTreeMatchString.MatchStr(nodeNamesStr, SetupContent.transmitterIndeStr, SetupContent.transmitterIndeStr.Length);
                    foreach (string s in nodeNamesArr)
                    {
                        staticTreeView.Nodes[0].Nodes[0].Nodes[3].Nodes.Add(s);
                    }
                    //向工程树种添加点状接收机
                    nodeNamesArr = ProjectTreeMatchString.MatchStr(nodeNamesStr, SetupContent.pointReceiverIndeStr, SetupContent.pointReceiverIndeStr.Length);
                    foreach (string s in nodeNamesArr)
                    {
                        staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[0].Nodes.Add(s);
                    }
                    //向工程树种添加线状接收机
                    nodeNamesArr = ProjectTreeMatchString.MatchStr(nodeNamesStr, SetupContent.gridReceiverIndeStr, SetupContent.gridReceiverIndeStr.Length);
                    foreach (string s in nodeNamesArr)
                    {
                        staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[1].Nodes.Add(s);
                    }
                    //向工程树中加载结果设定的相应信息
                    string pathsResultStr = StringFound.FoundBackStr(SetupContent.resultSetIndeStr1, nodeNamesStr, false);
                    //若结果设定中的复选框被选中
                    if (GetResultSetStr(pathsResultStr))
                    {
                        //将复选框的状态保存到结果设定窗口中
                        PathsCheck.Checked = true;
                        //在工程树中加载结果设定结点中加载相应的信息
                        staticTreeView.Nodes[0].Nodes[0].Nodes[5].Nodes.Add(SetupContent.resultSetOfTreeIndeStr1);
                    }
                    string pathlossResultStr = StringFound.FoundBackStr(SetupContent.resultSetIndeStr2, nodeNamesStr, false);
                    if (GetResultSetStr(pathlossResultStr))
                    {
                        PathlossCheck.Checked = true;
                        staticTreeView.Nodes[0].Nodes[0].Nodes[5].Nodes.Add(SetupContent.resultSetOfTreeIndeStr2);
                    }
                    string eFieldResultStr = StringFound.FoundBackStr(SetupContent.resultSetIndeStr3, nodeNamesStr, false);
                    if (GetResultSetStr(eFieldResultStr))
                    {
                        EFieldCheck.Checked = true;
                        staticTreeView.Nodes[0].Nodes[0].Nodes[5].Nodes.Add(SetupContent.resultSetOfTreeIndeStr3);
                    }
                    string eFieldTotalResultStr = StringFound.FoundBackStr(SetupContent.resultSetIndeStr4, nodeNamesStr, false);
                    if (GetResultSetStr(eFieldTotalResultStr))
                    {
                        EFieldTotalCheck.Checked = true;
                        staticTreeView.Nodes[0].Nodes[0].Nodes[5].Nodes.Add(SetupContent.resultSetOfTreeIndeStr4);
                    }
                    string powerResultStr = StringFound.FoundBackStr(SetupContent.resultSetIndeStr5, nodeNamesStr, false);
                    if (GetResultSetStr(powerResultStr))
                    {
                        PowerCheck.Checked = true;
                        staticTreeView.Nodes[0].Nodes[0].Nodes[5].Nodes.Add(SetupContent.resultSetOfTreeIndeStr5);
                    }

                    //判断用户是否关闭WI
                    Process pro = null;
                    try
                    {
                        pro = Process.GetProcessById(wiProcessID);
                    }
                    catch (ArgumentException)
                    {
                        //如果ID所对应的WI进程已被关闭,则再重新开启WI
                        Process wiProcess = Process.Start(exePath, openProject.FileName);
                        this.WindowState = FormWindowState.Normal;
                        this.Activate();
                        MainWindow.wiProcessID = wiProcess.Id;
                        return;
                    }
                    if (pro == null)
                    {
                        //如果WI进程还存在,则先将其关闭再打开重新加载工程
                        pro.Kill();
                    }
                    else
                    {
                        Process wiProcess = Process.Start(exePath, openProject.FileName);
                        //Process wiProcess = Process.Start(exePath, openProject.FileName);

                        this.WindowState = FormWindowState.Normal;
                        //this.TopMost = true;
                        this.Activate();
                        this.WindowState = FormWindowState.Maximized;

                        MainWindow.wiProcessID = wiProcess.Id;
                    }
                }
                else
                {
                    MessageBox.Show("该工程已经打开!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                mProjectFullName = null;
            }
        }
예제 #5
0
        private void addTransmitterOk_button1_Click(object sender, EventArgs e)
        {
            client       = new ServiceReference1.Service1Client();
            matchAntenna = new ServiceReference1.Antenna();
            string matchAntennaName = null;

            if (MainWindow.mProjectFullName == null)
            {
                this.Close();
                return;
            }
            //判断添加辐射源之前是否添加了地形
            if (!ConditionIsAll(MainWindow.nodeInfoFullPath))
            {
                MessageBox.Show("请先添加地形之后再添加辐射源!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            //判断工程波形中是否添加波形
            if (addTransmitterWaveformName_comboBox1.Items.Count > 0)
            {
                if (addTransmitterWaveformName_comboBox1.SelectedItem == null)
                {
                    MessageBox.Show("辐射源未设置波形", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MainWindow.IsReturnMidwayInNewProcess = true;
                    return;
                }
            }
            else
            {
                MessageBox.Show("请先在工程中添加波形!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (addTransmitterName_comboBox4.SelectedItem == null || addTransmitterCoordinateSystem_comboBox1.SelectedItem == null || addTransmitterLongitude_textBox2.Text == "" || addTransmitterLatitude_textBox3.Text == "" || addTransimtterReferencePlane_comboBox2.SelectedItem == null || addTransmitterInputPower_textBox11.Text == "" || addTransmitterAntennaName_textBox1.Text == "" || addTransmitterWaveformName_comboBox1.SelectedItem == null || addTransmitterAntennaRotateX_textBox7.Text == "" || addTransmitterAntennaRotateY_textBox6.Text == "" || addTransmitterAntennaRotateZ_textBox5.Text == "")
            {
                MessageBox.Show("窗口中有未设置的信息", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (!BoudingLimition.IsScienceFigure(addTransmitterInputPower_textBox11.Text))
            {
                MessageBox.Show("发射功率值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (double.Parse(addTransmitterInputPower_textBox11.Text) < 0.000)
            {
                MessageBox.Show("发射功率值需大于0.000", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (!BoudingLimition.IsScienceFigure(addTransmitterAntennaRotateX_textBox7.Text))
            {
                MessageBox.Show("天线关于X轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (!BoudingLimition.IsScienceFigure(addTransmitterAntennaRotateY_textBox6.Text))
            {
                MessageBox.Show("天线关于Y轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (!BoudingLimition.IsScienceFigure(addTransmitterAntennaRotateZ_textBox5.Text))
            {
                MessageBox.Show("天线关于Z轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (BoudingLimition.RotationLimition(addTransmitterAntennaRotateX_textBox7))
            {
                MessageBox.Show("天线关于X轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (BoudingLimition.RotationLimition(addTransmitterAntennaRotateY_textBox6))
            {
                MessageBox.Show("天线关于Y轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            if (BoudingLimition.RotationLimition(addTransmitterAntennaRotateZ_textBox5))
            {
                MessageBox.Show("天线关于Z轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            //判断是否存在.tx文件
            if (File.Exists(MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".tx"))
            {
                WaveformWriting transm = new WaveformWriting(FileOperation.ReadFile(MainWindow.nodeInfoFullPath));
                //注意 新建的辐射源个数不能超过1000
                string[] transmitterNames = new string[1000];
                //判断是否存在重名的辐射源
                transmitterNames = transm.waveformNames(SetupContent.transmitterIndeStr);
                if (transm.judge((string)addTransmitterName_comboBox4.SelectedItem, transmitterNames))
                {
                    MessageBox.Show("此辐射源已存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            //将数据库中与辐射源匹配的天线写入setupStr中
            try
            {
                matchAntenna = client.iGetAntenna(addTransmitterAntennaName_textBox1.Text);
                //与辐射源匹配的天线名称
                matchAntennaName = matchAntenna.Name + "_DB" + (string)addTransmitterName_comboBox4.SelectedItem;

                //准备好插入的内容
                string[] AntennaStr = new string[8];
                AntennaStr[0] = SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n";
                AntennaStr[1] = matchAntenna.Type + "\r\n";
                AntennaStr[3] = "power_threshold " + matchAntenna.RecieveThrehold + "\r\n";
                AntennaStr[4] = "cable_loss " + matchAntenna.TransmissionLoss + "\r\n";
                AntennaStr[5] = "VSWR " + matchAntenna.VSWR + "\r\n";
                AntennaStr[6] = "temperature " + matchAntenna.Temperature + "\r\n";
                switch (matchAntenna.Type)
                {
                case "type HalfWaveDipole":
                {
                    AntennaStr[2] = "polarization " + matchAntenna.Polarization + "\r\n";
                    AntennaStr[7] = SetupContent.antennaStr2 + "\r\n" + SetupContent.antennaStr3 + "\r\n";

                    //将天线信息存储到.waveinfo文件中
                    string antennaInfoStr = SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n"
                                            + Translate.KeyWordsDictionary_DB(matchAntenna.Type) + "\r\n"
                                            //+ (string)addTransmitterWaveformName_comboBox1.SelectedItem + "\r\n"
                                            + matchAntenna.MaxGain + "\r\n"
                                            + matchAntenna.Polarization + "\r\n"
                                            + matchAntenna.RecieveThrehold + "\r\n"
                                            + matchAntenna.TransmissionLoss + "\r\n"
                                            + matchAntenna.VSWR + "\r\n"
                                            + matchAntenna.Temperature + "\r\n"
                                            + "END" + SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n";
                    FileOperation.WriteFile(antennaInfoStr, MainWindow.waveinfoFilePath, true);
                }
                break;

                case "type linear_monopole":
                {
                    AntennaStr[2] = "";
                    AntennaStr[7] = SetupContent.antennaStr2 + "\r\n" + "length " + matchAntenna.Length + "\r\n" + SetupContent.antennaStr3 + "\r\n";

                    //将单极天线的参数按相应的顺序记录到waveinfo文件中
                    string antennaInfoStr = SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n"
                                            + Translate.KeyWordsDictionary_DB(matchAntenna.Type) + "\r\n"
                                            + (string)addTransmitterWaveformName_comboBox1.SelectedItem + "\r\n"
                                            + matchAntenna.Length + "\r\n"
                                            + matchAntenna.MaxGain + "\r\n"
                                            + matchAntenna.RecieveThrehold + "\r\n"
                                            + matchAntenna.TransmissionLoss + "\r\n"
                                            + matchAntenna.VSWR + "\r\n"
                                            + matchAntenna.Temperature + "\r\n"
                                            + "END" + SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n";
                    FileOperation.WriteFile(antennaInfoStr, MainWindow.waveinfoFilePath, true);
                }
                break;

                case "type Helical":
                {
                    AntennaStr[2] = "polarization " + matchAntenna.Polarization + "\r\n";
                    AntennaStr[7] = SetupContent.antennaStr2 + "\r\n"
                                    + "radius " + matchAntenna.Radius + "\r\n"
                                    + "length " + matchAntenna.Length + "\r\n"
                                    + "pitch " + matchAntenna.Pitch + "\r\n"
                                    + SetupContent.antennaStr3 + "\r\n";

                    string antennaInfoStr = SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n"
                                            + Translate.KeyWordsDictionary_DB(matchAntenna.Type) + "\r\n"
                                            + (string)addTransmitterWaveformName_comboBox1.SelectedItem + "\r\n"
                                            + matchAntenna.Polarization + "\r\n"
                                            + matchAntenna.MaxGain + "\r\n"
                                            + matchAntenna.Radius + "\r\n"
                                            + matchAntenna.Length + "\r\n"
                                            + matchAntenna.Pitch + "\r\n"
                                            + matchAntenna.RecieveThrehold + "\r\n"
                                            + matchAntenna.TransmissionLoss + "\r\n"
                                            + matchAntenna.VSWR + "\r\n"
                                            + matchAntenna.Temperature + "\r\n"
                                            + "END" + SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n";
                    FileOperation.WriteFile(antennaInfoStr, MainWindow.waveinfoFilePath, true);
                }
                break;

                case "type ParabolicReflector":
                {
                    AntennaStr[2] = "polarization " + matchAntenna.Polarization + "\r\n";
                    AntennaStr[7] = SetupContent.antennaStr2 + "\r\n"
                                    + "radius " + matchAntenna.Radius + "\r\n"
                                    + "blockageradius " + matchAntenna.BlockageRadius + "\r\n"
                                    + "EFieldDistribution " + matchAntenna.ApertureDistribution + "\r\n"
                                    + "EdgeTaper " + matchAntenna.EdgeTeper + "\r\n"
                                    + SetupContent.antennaStr3 + "\r\n";
                    //将抛物线天线相应的参数按控件顺序记录到waveinfo文件中
                    string antennaInfoStr = SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n"
                                            + Translate.KeyWordsDictionary_DB(matchAntenna.Type) + "\r\n"
                                            + (string)addTransmitterWaveformName_comboBox1.SelectedItem + "\r\n"
                                            + matchAntenna.Polarization + "\r\n"
                                            + matchAntenna.Radius + "\r\n"
                                            + matchAntenna.BlockageRadius + "\r\n"
                                            + matchAntenna.ApertureDistribution + "\r\n"
                                            + matchAntenna.EdgeTeper + "\r\n"
                                            + matchAntenna.RecieveThrehold + "\r\n"
                                            + matchAntenna.TransmissionLoss + "\r\n"
                                            + matchAntenna.VSWR + "\r\n"
                                            + matchAntenna.Temperature + "\r\n"
                                            + "END" + SetupContent.antennaStr1 + " " + matchAntennaName + "\r\n";
                    FileOperation.WriteFile(antennaInfoStr, MainWindow.waveinfoFilePath, true);
                }
                break;

                case "对数周期天线":
                {
                }
                break;

                default:
                    break;
                }
                WaveformWriting Annt = new WaveformWriting(MainWindow.setupStr);
                MainWindow.setupStr = Annt.InsertAntenna8(AntennaStr, (string)addTransmitterWaveformName_comboBox1.SelectedItem, SetupContent.antennaStr3, SetupContent.waveFormStr3);
                //将与辐射源匹配的天线添加到工程树子节点
                MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[2].Nodes.Add(matchAntennaName);
                //将天线的信息存储到.setup.info文件中
                FileOperation.WriteLineFile(SetupContent.antennaIndeStr + " " + matchAntennaName, MainWindow.nodeInfoFullPath, true);
            }
            catch (System.TimeoutException ex)
            {
                MessageBox.Show(ex.Message);
                LogFileManager.ObjLog.fatal(ex.Message, ex);
                client.Abort();
            }
            catch (FaultException <WcfException> ex)
            {
                MessageBox.Show(ex.Detail.message);
                LogFileManager.ObjLog.fatal(ex.Message, ex);
                client.Abort();
            }
            catch (CommunicationException ex)
            {
                MessageBox.Show(ex.Message);
                LogFileManager.ObjLog.fatal(ex.Message, ex);
                client.Abort();
            }
            catch (Exception exm)
            {
                MessageBox.Show(exm.Message);
                LogFileManager.ObjLog.fatal(exm.Message, exm);
                client.Abort();
            }

            string transmitterCount = GetTransmitterNum(MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".tx", SetupContent.transmitterStr2OfTr);
            string sourceStr        = FileOperation.ReadFile(MainWindow.waveinfoFilePath);

            string trFileStr = SetupContent.transmitterStr1OfTr + " " + (string)addTransmitterName_comboBox4.SelectedItem + "\r\n"
                               + SetupContent.transmitterStr2OfTr + transmitterCount + "\r\n"
                               + SetupContent.transmitterStr3OfTr + "\r\n" + SetupContent.transmitterStr4OfTr + "\r\n"
                               + SetupContent.transmitterStr5OfTr + "\r\n" + SetupContent.transmitterStr6OfTr + "\r\n"
                               + SetupContent.transmitterStr7OfTr + "\r\n" + SetupContent.transmitterStr8OfTr + "\r\n"
                               + SetupContent.transmitterStr9OfTr + "\r\n" + SetupContent.transmitterStr10OfTr + "\r\n"
                               + SetupContent.transmitterStr11OfTr + "\r\n"
                               + SetupContent.transmitterStr12OfTr + MainWindow.longitudeStr + "\r\n"
                               + SetupContent.transmitterStr13OfTr + MainWindow.latitudeStr + "\r\n"
                               + SetupContent.transmitterStr14OfTr + "\r\n"
                               + Translate.KeyWordsDictionary(addTransimtterReferencePlane_comboBox2) + "\r\n"
                               + SetupContent.transmitterStr15OfTr + "\r\n"
                               + SetupContent.transmitterStr16OfTr + "\r\n"
                               //+ SetupContent.transmitterStr17OfTr + "\r\n"
                               + GetAntennaStr(MainWindow.transInfoFullPath, matchAntennaName)
                               + SetupContent.transmitterStr18OfTr + addTransmitterAntennaRotateX_textBox7.Text + "\r\n"
                               + SetupContent.transmitterStr19OfTr + addTransmitterAntennaRotateY_textBox6.Text + "\r\n"
                               + SetupContent.transmitterStr20OfTr + addTransmitterAntennaRotateZ_textBox5.Text + "\r\n"
                               + SetupContent.transmitterStr21OfTr + addTransmitterInputPower_textBox11.Text + "\r\n"
                               + SetupContent.transmitterStr22OfTr + "\r\n"
                               + SetupContent.transmitterStr23OfTr + "\r\n"
                               + SetupContent.transmitterStr24OfTr + " "
                               + WaveformNodeOfConMenu.GetWaveformNumLine((string)addTransmitterWaveformName_comboBox1.SelectedItem, sourceStr) + "MHZ" + "\r\n";

            FileOperation.WriteFile(trFileStr, MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".tx", true);
            //写到setup文件中
            string sourceStrOfTr = FileOperation.ReadFile(MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".tx");
            //找出辐射源的个数
            int transmitCount = WaveformWriting.GetCountOfMatchStr("begin_<points>", sourceStrOfTr);

            //如果已经存在了transmitter块,则先删除
            if (MainWindow.setupStr.LastIndexOf("end_<transmitter>") != -1)
            {
                MainWindow.setupStr = MainWindow.setupStr.Remove(MainWindow.setupStr.IndexOf("begin_<transmitter>"), MainWindow.setupStr.IndexOf("end_<transmitter>") - MainWindow.setupStr.IndexOf("begin_<transmitter>") + 19);
            }
            //将.tx路径信息插入到全局字符串setupStr中
            int    insertSiteOfTr = MainWindow.setupStr.LastIndexOf("end_<feature>") + 15;//15是end_<feature>\r\n后的第一个字符
            string insertStr      = SetupContent.transmitterStr1Ofsetup + "\r\n" + SetupContent.transmitterStr2Ofsetup
                                    + MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".tx" + "\r\n"
                                    + SetupContent.transmitterStr3Ofsetup + transmitCount.ToString() + "\r\n"
                                    + SetupContent.transmitterStr4Ofsetup + "\r\n";

            MainWindow.setupStr = MainWindow.setupStr.Insert(insertSiteOfTr, insertStr);
            FileOperation.WriteFile(MainWindow.setupStr, MainWindow.mProjectFullName, false);



            //向工程树中添加结点信息
            MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[3].Nodes.Add((string)addTransmitterName_comboBox4.SelectedItem);
            //将辐射源的信息存储到.setup.info文件中
            FileOperation.WriteLineFile(SetupContent.transmitterIndeStr + " " + (string)addTransmitterName_comboBox4.SelectedItem, MainWindow.nodeInfoFullPath, true);
            //将辐射源和天线的匹配关系记录到.match文件中
            FileOperation.WriteLineFile(SetupContent.transmitterIndeStr + " " + (string)addTransmitterName_comboBox4.SelectedItem + "*" + matchAntennaName, MainWindow.relationOfAntAndWavePath, true);

            //将辐射源的信息存储到.waveinfo文件中
            string transmitterInfoStr = SetupContent.transmitterStr1Ofsetup + " " + (string)addTransmitterName_comboBox4.SelectedItem + "\r\n"
                                        + addTransimtterReferencePlane_comboBox2.Text + "\r\n"
                                        + addTransmitterInputPower_textBox11.Text + "\r\n"
                                        + matchAntennaName + "\r\n"
                                        + (string)addTransmitterWaveformName_comboBox1.SelectedItem + "\r\n"
                                        + addTransmitterAntennaRotateX_textBox7.Text + "\r\n"
                                        + addTransmitterAntennaRotateY_textBox6.Text + "\r\n"
                                        + addTransmitterAntennaRotateZ_textBox5.Text + "\r\n"
                                        + "END" + SetupContent.transmitterStr1Ofsetup + " " + (string)addTransmitterName_comboBox4.SelectedItem + "\r\n";

            FileOperation.WriteFile(transmitterInfoStr, MainWindow.waveinfoFilePath, true);
            if (MainWindow.creatSuccMesDisp)
            {
                MessageBox.Show("辐射源" + (string)addTransmitterName_comboBox4.SelectedItem + "创建成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #6
0
        //单击更改时执行此方法
        public static bool ReceiverUpdateMenu(TreeNode currentNode)
        {
            //bool b = false;
            string rxFilePath = MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx";
            //保存Tr文件中的字符串
            string rxFileStrTemp = FileOperation.ReadFile(rxFilePath);
            string indStr        = null;

            switch (currentNode.Parent.Text)
            {
            case "点状分布":
                indStr = SetupContent.pointReceiverOfRxStr0;
                break;

            case "区域分布":
                indStr = SetupContent.gridReceiverOfRxStr0;
                break;
            }

            //将接收机在rx文件中的位置保护起来
            int initialReceiverBlockSite = rxFileStrTemp.IndexOf(indStr + " " + currentNode.Text + "\r\n");
            //rx文件中原来接收机的编号也要保存下来
            string initReceiverNum = GetReceiverNumLine(indStr, currentNode.Text, rxFileStrTemp);
            //保存info文件中的所有字符串
            string receiverNodeInfoTemp = FileOperation.ReadFile(MainWindow.nodeInfoFullPath);
            //保存接收机在info文件中的位置信息
            int initialReceiverNodeSite = receiverNodeInfoTemp.IndexOf(indStr + " " + currentNode.Text + "\r\n");
            //保存waveinfo文件中有关接收机的信息
            string receiverParStrTemp = FileOperation.ReadFile(MainWindow.waveinfoFilePath);

            NewReceiverWindow newReceiverWin = new NewReceiverWindow();

            //将接收机原来的参数信息装载到窗口中
            if (!ReceiverDataRecoverOfProjectTreeView.RecoverReceiverParOfWin(currentNode, receiverParStrTemp, newReceiverWin))
            {
                MessageBox.Show("程序内部发生错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                FileOperation.RecoverOldRevision(rxFileStrTemp, rxFilePath, receiverParStrTemp, receiverNodeInfoTemp);
                return(false);
            }
            //ReceiverDataRecoverOfProjectTreeView.RecoverReceiverParOfWin(currentNode, receiverParStrTemp, newReceiverWin);
            //在单击确定按钮之前应将需更改的接收机的信息从各个文件中删除
            if (!(ReceiverDelOfRxAndInfoFile(currentNode) && ReceiverDelOfWaveInfo(currentNode) && ReceiverUpdateOfSetup()))
            {
                MessageBox.Show("程序内部发生错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                FileOperation.RecoverOldRevision(rxFileStrTemp, rxFilePath, receiverParStrTemp, receiverNodeInfoTemp);
                return(false);
            }

            MainWindow.creatSuccMesDisp = false;
            MainWindow.newFuncSign      = false;
            newReceiverWin.Text         = "更改接收机";
            newReceiverWin.ShowDialog();
            switch (newReceiverWin.DialogResult)
            {
            case DialogResult.OK:
                if (MainWindow.IsReturnMidwayInNewProcess)
                {
                    //FileOperation.WriteFile(rxFileStrTemp, rxFilePath, false);
                    //FileOperation.WriteFile(receiverParStrTemp, MainWindow.waveinfoFilePath, false);
                    //FileOperation.WriteFile(receiverNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                    FileOperation.RecoverOldRevision(rxFileStrTemp, rxFilePath, receiverParStrTemp, receiverNodeInfoTemp);
                    MainWindow.IsReturnMidwayInNewProcess = false;
                    return(false);
                }
                if (!rxStrRecoverInitReceiverNum(currentNode, initReceiverNum, initialReceiverBlockSite, initialReceiverNodeSite))
                {
                    if (currentNode.Parent.Text.Equals("点状分布"))
                    {
                        MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[0].LastNode.Remove();
                    }
                    else
                    {
                        MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[1].LastNode.Remove();
                    }


                    MessageBox.Show("程序内部发生错误,更改操作失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    FileOperation.RecoverOldRevision(rxFileStrTemp, rxFilePath, receiverParStrTemp, receiverNodeInfoTemp);
                    //FileOperation.WriteFile(rxFileStrTemp, rxFilePath, false);
                    //FileOperation.WriteFile(receiverParStrTemp, MainWindow.waveinfoFilePath, false);
                    //FileOperation.WriteFile(receiverNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                    return(false);
                }
                switch (currentNode.Parent.Text)
                {
                case "点状分布":
                    MainWindow.staticTreeView.SelectedNode.Text = MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[0].LastNode.Text;
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[0].LastNode.Remove();
                    break;

                case "区域分布":
                    MainWindow.staticTreeView.SelectedNode.Text = MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[1].LastNode.Text;
                    MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[1].LastNode.Remove();
                    break;
                }
                return(true);

            //break;
            default:
                FileOperation.RecoverOldRevision(rxFileStrTemp, rxFilePath, receiverParStrTemp, receiverNodeInfoTemp);
                //FileOperation.WriteFile(rxFileStrTemp, rxFilePath, false);

                //FileOperation.WriteFile(receiverParStrTemp, MainWindow.waveinfoFilePath, false);
                //FileOperation.WriteFile(receiverNodeInfoTemp, MainWindow.nodeInfoFullPath, false);
                return(false);
                //break;
            }
            //b = true;
            //return b;
        }
예제 #7
0
        //删除rx文件和info文件中接收机的相关信息
        private static bool ReceiverDelOfRxAndInfoFile(TreeNode currentNode)
        {
            bool   b          = false;
            string rxFilePath = MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx";
            string rxFileStr  = FileOperation.ReadFile(rxFilePath);

            string beginStr = null;
            string endStr   = null;

            if (currentNode.NextNode != null)
            {
                switch (currentNode.Parent.Text)
                {
                case "点状分布":
                    beginStr = SetupContent.pointReceiverOfRxStr0 + " " + currentNode.Text + "\r\n";
                    endStr   = SetupContent.pointReceiverOfRxStr0 + " " + currentNode.NextNode.Text + "\r\n";
                    break;

                case "区域分布":
                    beginStr = SetupContent.gridReceiverOfRxStr0 + " " + currentNode.Text + "\r\n";
                    endStr   = SetupContent.gridReceiverOfRxStr0 + " " + currentNode.NextNode.Text + "\r\n";
                    break;
                }
                int start = rxFileStr.IndexOf(beginStr);
                //只能用LastIndexOf(nextNodeStr) 因为当删除的接收机结点是树中同一级的最后一个时,只能查找end串
                int end = rxFileStr.LastIndexOf(endStr);
                rxFileStr = rxFileStr.Remove(start, end - start);
            }
            else
            {
                switch (currentNode.Parent.Text)
                {
                case "点状分布":
                    beginStr = SetupContent.pointReceiverOfRxStr0 + " " + currentNode.Text + "\r\n";
                    endStr   = SetupContent.transmitterStr24OfTr + "\r\n";
                    break;

                case "区域分布":
                    beginStr = SetupContent.gridReceiverOfRxStr0 + " " + currentNode.Text + "\r\n";
                    endStr   = SetupContent.gridReceiverOfRxStr11 + "\r\n";
                    break;
                }
                int start = rxFileStr.IndexOf(beginStr);
                //只能用LastIndexOf(nextNodeStr) 因为当删除的接收机结点是树中同一级的最后一个时,只能查找end串
                int end = rxFileStr.LastIndexOf(endStr) + endStr.Length;
                rxFileStr = rxFileStr.Remove(start, end - start);
            }
            //删除后保存到rx文件中
            FileOperation.WriteFile(rxFileStr, rxFilePath, false);

            //还要从.info文件中将波形的信息删除
            try
            {
                string infoStr = FileOperation.ReadFile(MainWindow.nodeInfoFullPath);
                infoStr = infoStr.Remove(infoStr.IndexOf(beginStr), beginStr.Length);
                FileOperation.WriteFile(infoStr, MainWindow.nodeInfoFullPath, false);
                b = true;
            }
            catch (Exception e)
            {
                //LogFileManager.ObjLog.fatal(e.Message, e);
                b = false;
                throw e;
            }
            return(b);
        }
예제 #8
0
        private void newReceiverOk_button1_Click(object sender, EventArgs e)
        {
            if (!File.Exists(MainWindow.mProjectFullName))
            {
                this.Close();
                return;
            }
            if (!NewTransmitterWindow.ConditionIsAll(MainWindow.nodeInfoFullPath))
            {
                MessageBox.Show("请先创建天线和添加波形之后再新建接收机!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                this.Close();
                return;
            }
            if (newRceiverType_comboBox1.SelectedItem == null)
            {
                MessageBox.Show("窗口中有未设置的信息,请您设置完整", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MainWindow.IsReturnMidwayInNewProcess = true;
                return;
            }
            else
            {
                string newRceiverType = null;
                newRceiverType = (string)(newRceiverType_comboBox1.SelectedItem);
                switch (newRceiverType)
                {
                case "点状<Points>":
                {
                    if (newReceiverName_textBox2.Text == "" || newReceiverlongitude_textBox1.Text == "" || newReceiverLatitude_textBox3.Text == "" || newReceiverReferencePlane_comboBox2.SelectedItem == null || newReceiverAntennaName_comboBox3.SelectedItem == null || newReceiverAntennaHeight_textBox1.Text == "" || newReceiverAntennaRotationX_textBox4.Text == "" || newReceiverAntennaRotationY_textBox6.Text == "" || newReceiverAntennaRotationXZ_textBox5.Text == "")
                    {
                        MessageBox.Show("窗口中有未设置的信息,请您设置完整", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaRotationX_textBox4.Text))
                    {
                        MessageBox.Show("天线关于X轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaRotationY_textBox6.Text))
                    {
                        MessageBox.Show("天线关于Y轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaRotationXZ_textBox5.Text))
                    {
                        MessageBox.Show("天线关于Z轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaRotationX_textBox4))
                    {
                        MessageBox.Show("天线关于X轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaRotationY_textBox6))
                    {
                        MessageBox.Show("天线关于Y轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaRotationXZ_textBox5))
                    {
                        MessageBox.Show("天线关于Z轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                }
                break;

                case "区域状<XYgrid>":
                {
                    if (newReceiverName_textBox2.Text == "" || newReceiverlongitude_textBox1.Text == "" || newReceiverLatitude_textBox3.Text == "" || newReceiverReferencePlane_comboBox2.SelectedItem == null || newReceiverAntennaName_comboBox3.SelectedItem == null || newReceiverAntennaHeight_textBox1.Text == "" || newReceiverSpace_textBox1.Text == "" || newReceiverAntennaRotationX_textBox4.Text == "" || newReceiverAntennaRotationY_textBox6.Text == "" || newReceiverAntennaRotationXZ_textBox5.Text == "")
                    {
                        MessageBox.Show("窗口中有未设置的信息,请您设置完整", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }

                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaHeight_textBox1.Text))
                    {
                        MessageBox.Show("天线位置关于Z轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaHeight_textBox1))
                    {
                        MessageBox.Show("天线位置关于Z轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverSpace_textBox1.Text))
                    {
                        MessageBox.Show("接收机间隔值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (double.Parse(newReceiverSpace_textBox1.Text) < 0.000)
                    {
                        MessageBox.Show("接收机间隔值需大于0.000", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaRotationX_textBox4.Text))
                    {
                        MessageBox.Show("天线关于X轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaRotationY_textBox6.Text))
                    {
                        MessageBox.Show("天线关于Y轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (!BoudingLimition.IsScienceFigure(newReceiverAntennaRotationXZ_textBox5.Text))
                    {
                        MessageBox.Show("天线关于Z轴旋转角度值输入必须是实数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaRotationX_textBox4))
                    {
                        MessageBox.Show("天线关于X轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaRotationY_textBox6))
                    {
                        MessageBox.Show("天线关于Y轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                    if (BoudingLimition.RotationLimition(newReceiverAntennaRotationXZ_textBox5))
                    {
                        MessageBox.Show("天线关于Z轴旋转角度值需在0度至360度之间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MainWindow.IsReturnMidwayInNewProcess = true;
                        return;
                    }
                }
                break;

                default:
                    break;
                }
            }
            //先判断是否存在.rx文件
            if (File.Exists(MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx"))
            {
                WaveformWriting receiverm = new WaveformWriting(FileOperation.ReadFile(MainWindow.nodeInfoFullPath));
                //注意 新建的天线个数不能超过1000
                string[] pointReceiverNames = new string[2000];
                string[] gridReceiverNames  = new string[2000];
                //判断是否存在重名的接收机
                pointReceiverNames = receiverm.waveformNames(SetupContent.transmitterStr1OfTr);
                gridReceiverNames  = receiverm.waveformNames(SetupContent.gridReceiverOfRxStr0);
                if (receiverm.judge(newReceiverName_textBox2.Text, pointReceiverNames) || receiverm.judge(newReceiverName_textBox2.Text, gridReceiverNames))
                {
                    MessageBox.Show("此接收机已存在, 请您换个接收机名称!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MainWindow.IsReturnMidwayInNewProcess = true;
                    return;
                }
            }
            string receiverNum = NewTransmitterWindow.GetTransmitterNum(MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx", SetupContent.gridReceiverOfRxStr1);

            string rxFileStr = null;
            string hasSpace  = "";
            string startStr  = null;

            if (((string)newRceiverType_comboBox1.SelectedItem).Equals("区域状<XYgrid>"))
            {
                rxFileStr = Translate.KeyWordsDictionary(newRceiverType_comboBox1) + newReceiverName_textBox2.Text + "\r\n"
                            + SetupContent.gridReceiverOfRxStr1 + receiverNum + "\r\n"
                            + SetupContent.gridReceiverOfRxStr2 + "\r\n"
                            + SetupContent.gridReceiverOfRxStr3 + MainWindow.longitudeStr + "\r\n"
                            + SetupContent.gridReceiverOfRxStr4 + MainWindow.latitudeStr + "\r\n"
                            + SetupContent.gridReceiverOfRxStr5 + "\r\n"
                            + Translate.KeyWordsDictionary(newReceiverReferencePlane_comboBox2) + "\r\n"
                            + SetupContent.gridReceiverOfRxStr6 + "\r\n"
                            + SetupContent.gridReceiverOfRxStr7 + "\r\n"
                            + SetupContent.gridReceiverOfRxStr8 + newReceiverSpace_textBox1.Text + "\r\n"
                            + SetupContent.gridReceiverOfRxStr9 + "\r\n"
                            + SetupContent.gridpointReceiverOfRxStr0 + newReceiverAntennaHeight_textBox1.Text + "\r\n"
                            + NewTransmitterWindow.GetAntennaStr(MainWindow.transInfoFullPath, newReceiverAntennaName_comboBox3)
                            + SetupContent.gridpointReceiverOfRxStr1 + newReceiverAntennaRotationX_textBox4.Text + "\r\n"
                            + SetupContent.gridpointReceiverOfRxStr2 + newReceiverAntennaRotationY_textBox6.Text + "\r\n"
                            + SetupContent.gridpointReceiverOfRxStr3 + newReceiverAntennaRotationXZ_textBox5.Text + "\r\n"
                            + SetupContent.gridReceiverOfRxStr10 + "\r\n";
                MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[1].Nodes.Add(newReceiverName_textBox2.Text);
                FileOperation.WriteLineFile(SetupContent.gridReceiverIndeStr + " " + newReceiverName_textBox2.Text, MainWindow.nodeInfoFullPath, true);

                hasSpace = newReceiverSpace_textBox1.Text;
                startStr = SetupContent.gridReceiverOfRxStr0 + " " + newReceiverName_textBox2.Text + "\r\n";
                FileOperation.WriteLineFile(SetupContent.gridReceiverOfRxStr0 + " " + newReceiverName_textBox2.Text + "#" + newReceiverAntennaName_comboBox3.SelectedItem, MainWindow.relationOfAntAndWavePath, true);
            }
            else
            {
                rxFileStr = Translate.KeyWordsDictionary(newRceiverType_comboBox1) + newReceiverName_textBox2.Text + "\r\n"
                            + SetupContent.pointReceiverOfRxStr1 + receiverNum + "\r\n"
                            + SetupContent.pointReceiverOfRxStr2 + "\r\n"
                            + SetupContent.pointReceiverOfRxStr3 + "\r\n"
                            + SetupContent.gridReceiverOfRxStr3 + MainWindow.longitudeStr + "\r\n"
                            + SetupContent.gridReceiverOfRxStr4 + MainWindow.latitudeStr + "\r\n"
                            + SetupContent.pointReceiverOfRxStr4 + "\r\n"
                            + Translate.KeyWordsDictionary(newReceiverReferencePlane_comboBox2) + "\r\n"
                            + SetupContent.pointReceiverOfRxStr5 + "\r\n"
                            + SetupContent.gridpointReceiverOfRxStr0 + newReceiverAntennaHeight_textBox1.Text + "\r\n"
                            + NewTransmitterWindow.GetAntennaStr(MainWindow.transInfoFullPath, newReceiverAntennaName_comboBox3)
                            + SetupContent.gridpointReceiverOfRxStr1 + newReceiverAntennaRotationX_textBox4.Text + "\r\n"
                            + SetupContent.gridpointReceiverOfRxStr2 + newReceiverAntennaRotationY_textBox6.Text + "\r\n"
                            + SetupContent.gridpointReceiverOfRxStr3 + newReceiverAntennaRotationXZ_textBox5.Text + "\r\n"
                            + SetupContent.pointReceiverOfRxStr6 + "\r\n";
                MainWindow.staticTreeView.Nodes[0].Nodes[0].Nodes[4].Nodes[0].Nodes.Add(newReceiverName_textBox2.Text);
                FileOperation.WriteLineFile(SetupContent.pointReceiverIndeStr + " " + newReceiverName_textBox2.Text, MainWindow.nodeInfoFullPath, true);

                FileOperation.WriteLineFile(SetupContent.transmitterStr1OfTr + " " + newReceiverName_textBox2.Text + "#" + newReceiverAntennaName_comboBox3.SelectedItem, MainWindow.relationOfAntAndWavePath, true);

                startStr = SetupContent.pointReceiverOfRxStr0 + " " + newReceiverName_textBox2.Text + "\r\n";
            }

            string rxInfoStr = startStr
                               + newRceiverType_comboBox1.Text + "\r\n"
                               + newReceiverReferencePlane_comboBox2.Text + "\r\n"
                               + newReceiverAntennaName_comboBox3.Text + "\r\n"
                               + newReceiverAntennaHeight_textBox1.Text + "\r\n"
                               //+ newReceiverSpace_textBox1.Text + "\r\n"
                               + hasSpace + "\r\n"
                               + newReceiverAntennaRotationX_textBox4.Text + "\r\n"
                               + newReceiverAntennaRotationY_textBox6.Text + "\r\n"
                               + newReceiverAntennaRotationXZ_textBox5.Text + "\r\n"
                               + "END" + startStr;

            FileOperation.WriteFile(rxInfoStr, MainWindow.waveinfoFilePath, true);

            //FileOperation.WriteFile(SetupContent.receiverOfSetupStr0 + " " + newReceiverName_textBox2.Text + "#" + newReceiverAntennaName_comboBox3.SelectedItem+"\r\n" , MainWindow.relationOfAntAndWavePath, true);

            FileOperation.WriteFile(rxFileStr, MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx", true);
            //写到setup文件中
            string sourceStrOfRx = FileOperation.ReadFile(MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx");
            //找出天线的个数
            int receiverCount = WaveformWriting.GetCountOfMatchStr("begin_<grid>", sourceStrOfRx) + WaveformWriting.GetCountOfMatchStr("begin_<points>", sourceStrOfRx) - 1;

            //如果已经存在了receiverr块,则先删除
            if (MainWindow.setupStr.LastIndexOf("end_<receiver>") != -1)
            {
                MainWindow.setupStr = MainWindow.setupStr.Remove(MainWindow.setupStr.IndexOf("begin_<receiver>"), MainWindow.setupStr.IndexOf("end_<receiver>") - MainWindow.setupStr.IndexOf("begin_<receiver>") + 16);
            }

            int insertSiteOfRec = 0;

            if (MainWindow.setupStr.LastIndexOf("end_<transmitter>") != -1)
            {
                insertSiteOfRec = MainWindow.setupStr.LastIndexOf("end_<transmitter>") + 2 + "end_<transmitter>".Length;
            }
            else
            {
                insertSiteOfRec = MainWindow.setupStr.LastIndexOf("end_<feature>") + "end_<feature>".Length + 2;
            }
            string insertStr = SetupContent.receiverOfSetupStr0 + "\r\n"
                               + SetupContent.receiverOfSetupStr1 + MainWindow.projectRealPath + "\\" + MainWindow.onlyProjectName + ".rx" + "\r\n"
                               + SetupContent.receiverOfSetupStr2 + receiverCount.ToString() + "\r\n"
                               + SetupContent.receiverOfSetupStr3 + "\r\n";

            MainWindow.setupStr = MainWindow.setupStr.Insert(insertSiteOfRec, insertStr);
            FileOperation.WriteFile(MainWindow.setupStr, MainWindow.mProjectFullName, false);
            if (MainWindow.creatSuccMesDisp)
            {
                MessageBox.Show("\"" + newReceiverName_textBox2.Text + "\"接收机创建成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //MessageBox.Show("对接收机" + newReceiverName_textBox2.Text + "操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }