コード例 #1
0
ファイル: DisGKResult.cs プロジェクト: algz/AFA
        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pointYCollection"></param>
        /// <param name="isRunRoto">是否运行求解器</param>
        public DisGKResult(TabPage page, Dictionary<int, PointPairList> pointYCollection, bool isRunRoto = true)
        {
            InitializeComponent();

            this.page = page;
            this.currenGKPath = Common.prjName + Path.DirectorySeparatorChar + this.page.Text + Path.DirectorySeparatorChar;
            this.myPane = this.zedGraphControl1.GraphPane;

            //设置图标标题和x、y轴标题
            this.myPane.Title.Text = "计算监控";
            this.myPane.XAxis.Title.Text = "迭代步数";

            //更改标题的字体
            //FontSpec myFont = new FontSpec("宋体", 20, Color.Red, false, false, false);

            //this.myPane.Title.FontSpec = myFont;
            //this.myPane.XAxis.Title.FontSpec = myFont;
            //this.myPane.YAxis.Title.FontSpec = myFont;

            //设置网格线可见
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            //设置网格线颜色
            myPane.XAxis.MajorGrid.Color = Color.Chocolate;
            myPane.YAxis.MajorGrid.Color = Color.Chocolate;

            //设置网格线形式
            myPane.XAxis.MajorGrid.DashOff = 1;
            myPane.YAxis.MajorGrid.DashOff = 1;
            myPane.XAxis.MajorGrid.DashOn = 4;
            myPane.YAxis.MajorGrid.DashOn = 4;

            //初始化图形
            if (pointYCollection == null||pointYCollection.Count==0)
            {
                this.myCurve = this.myPane.AddCurve("数据", new PointPairList(), Color.Red, SymbolType.None);
            }
            else
            {
                this.pointYCollection = pointYCollection;
                this.myCurve = this.myPane.AddCurve("数据", pointYCollection[0], Color.Red, SymbolType.None);
            }

            //监控显示(默认值)
            this.cmbDisType.SelectedIndex = 0;
            this.cmbType = 0;

            this.labGK.Text = this.page.Text;

            DisGKResult.CheckForIllegalCrossThreadCalls = false;
            this.mainForm = (MainForm)this.ParentForm;

            //当前工况
            this.currentGK = (sGK)MainForm.GKNode.Nodes[this.page.Text].Tag;

            //this.baseLine = Convert.ToInt64(this.currentGK.maxIterateNum);

            if (pointYCollection == null && isRunRoto)
            {
                Thread thread = new Thread(loadData);
                thread.IsBackground = true;
                thread.Start();
            }
            else if(pointYCollection.Count!=0)
            {
                try
                {
                    SyswareDataObject sdo = new SyswareDataObject();
                    if (SyswareDataObjectUtil.loadFresultData(sdo, Common.GKPath))
                    {
                        loadDataGridView(sdo.children[0].children);
                    }
                    else
                    {
                        MessageBox.Show("文件加载失败");
                    }

                }
                catch (Exception e)
                {
                    MessageBox.Show("文件格式错误.详细:"+e.Message);
                }

            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: algz/AFA
        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;
                }
            }
        }
コード例 #3
0
ファイル: DisGKResult.cs プロジェクト: algz/AFA
 /// <summary>
 /// 停止计算
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void stopCalculateBtn_Click(object sender, EventArgs e)
 {
     if (this.process != null && !this.process.HasExited)
     {
         this.process.Kill();
         MessageBox.Show("工况("+this.page.Text+")停止计算");
     }
     SyswareDataObject sdo = new SyswareDataObject();
     if (SyswareDataObjectUtil.loadFresultData(sdo, this.currenGKPath))
     {
         loadDataGridView(sdo.children[0].children);
     }
 }