private void tsOpen_Click(object sender, EventArgs e) { OpenFileDialog oDlg = new OpenFileDialog(); oDlg.Title = "打开文件"; oDlg.InitialDirectory = Common.startupFolder; oDlg.Filter = "prj files(*.prj)|*.prj"; if (oDlg.ShowDialog() == DialogResult.OK) { this.m_strPrjFile = oDlg.FileName; Common.prjName = oDlg.FileName.Replace("\\" + oDlg.SafeFileName, ""); InitTree(); string str = oDlg.FileName; str = str.Substring(str.LastIndexOf("\\") + 1); this.Text = "全机气动布局---" + str; this.tsSave.Enabled = true; this.tsSaveAs.Enabled = true; string fileName = oDlg.FileName; OpenFile(fileName); GKNode.Expand(); WGNode.Nodes.Clear(); string strMsh = fileName.Substring(0, fileName.LastIndexOf("\\") + 1) + "rotorwing_gambit.msh"; if (File.Exists(strMsh)) { AFATreeNode node = null; node = new AFATreeNode("rotorwing_gambit.msh", TreeNodeType.nodeWGCase); WGNode.Nodes.Add(node); WGNode.Expand(); Common.MESHLOCATION = strMsh; //this.meshDisControl1.MeshDis(strMsh); object[] objs = new object[2]; objs[0] = this.meshDisControl1; objs[1] = strMsh; LoadingForm f = new LoadingForm(objs, this.openFileCallBack); f.ShowDialog(this); this.showGKBtn.Enabled = true; this.showGKBtn.Checked = true; } //打开计算结果页面 for (int i = 0; i < GKNode.Nodes.Count; i++) { TreeNode node = GKNode.Nodes[i]; Common.GKPath = Common.prjName + Path.DirectorySeparatorChar + node.Text + Path.DirectorySeparatorChar; string GKPath = Common.GKPath; if (!Directory.Exists(GKPath)) { continue; } sGK data = (sGK)node.Tag; tabControl1.TabPages.RemoveByKey(node.Text); //foreach (TabPage page in tabControl1.TabPages) //{ // if (node.Text == page.Text) // { // tabControl1.TabPages.Remove(page); // } //} TabPage m_tabPage = new TabPage(); m_tabPage.Name = node.Text;// "tPage" + i; m_tabPage.Tag = node.Text;//MainForm.GKNode.Nodes[i].Text; m_tabPage.Text = node.Text;//MainForm.GKNode.Nodes[i].Text; m_tabPage.UseVisualStyleBackColor = true; this.tabControl1.Controls.Add(m_tabPage); this.tabControl1.SelectedTab = m_tabPage; //this.tabControl1.TabPages[this.tabControl1.TabPages.Count-1]; //mainForm.Controls.Find("tabControl1", true)[0].Controls.Add(m_tabPage); #region 加载上次运行图画 Dictionary<int, PointPairList> pointYCollection = new Dictionary<int, PointPairList>(); string[] arr = new string[5]; SyswareDataObject sdo = new SyswareDataObject(); try { if (SyswareDataObjectUtil.loadFresultData(sdo, GKPath, false, true)) { sdo = sdo.children[0]; foreach (SyswareDataObject tem in sdo.children) { arr[0] = tem.children[0].value; arr[1] = tem.children[1].value; arr[2] = tem.children[2].children[2].value; arr[3] = tem.children[2].children[0].value; arr[4] = tem.children[3].children[0].children[2].value; for (int j = 1; j < arr.Length; j++) { double axisY = 0.0; try { axisY = double.Parse(arr[j], System.Globalization.NumberStyles.Any); } catch { axisY = 0.0; } if (!pointYCollection.ContainsKey(j - 1)) { pointYCollection.Add(j - 1, new PointPairList()); } pointYCollection[j - 1].Add(Convert.ToDouble(arr[0]), Convert.ToDouble(axisY)); } } } else { MessageBox.Show("文件加载失败"); } } catch (Exception ex) { MessageBox.Show("文件格式错误.详细:" + ex.Message); return; } DisGKResult disGKResult1 = new DisGKResult(m_tabPage, pointYCollection, false); disGKResult1.drawGraph(arr); #endregion m_tabPage.Controls.Add(disGKResult1); disGKResult1.Dock = DockStyle.Fill; disGKResult1.Name = "disGKResult" + i; } } }
private void openFileCallBack(object obj,LoadingForm form) { try { object[] objs=(object[])obj; string fileName = objs[1].ToString(); //MethodInvoker mi = new MethodInvoker(form.setLoadingText); //this.BeginInvoke(mi); MethodParamInvoker mpi = new MethodParamInvoker(form.setLoadingText); this.BeginInvoke(mpi, "加载.Mesh文件."); MeshDisControl meshDisControl = (MeshDisControl)objs[0]; //form.loadingText = "加载.Mesh文件."; meshDisControl.MeshDis(fileName.ToString()); } catch (Exception e) { MessageBox.Show("openFileCallBack:"+e.Message); } }