예제 #1
0
        private void buttonExLook_Click(object sender, EventArgs e)
        {
            CustomControls.MethodOpenFileDialog controlex = new CustomControls.MethodOpenFileDialog();
            controlex.StartLocation               = AddonWindowLocation.Right;
            controlex.DefaultViewMode             = FolderViewMode.Details;
            controlex.OpenDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\AppleLabJ" + "\\Method";
            controlex.OpenDialog.AddExtension     = true;
            controlex.OpenDialog.Filter           = "试验方法文件(*.dat)|*.dat";
            controlex.ShowDialog(this);



            if (controlex.OpenDialog.FileName == null)
            {
                return;
            }
            else
            {
                string fileName = controlex.OpenDialog.FileName;

                if (fileName == "")
                {
                    return;
                }
                else
                {
                    UserControl常规1.txtmethodname.Text = Path.GetFileNameWithoutExtension(fileName);
                    UserControl常规1.txtmethodpath.Text = Path.GetDirectoryName(fileName);

                    if (CComLibrary.GlobeVal.filesave == null)
                    {
                        CComLibrary.GlobeVal.filesave = new CComLibrary.FileStruct();
                    }
                    CComLibrary.GlobeVal.filesave = CComLibrary.GlobeVal.filesave.DeSerializeNow(fileName);


                    CComLibrary.GlobeVal.currentfilesavename = fileName;
                    UserControl常规1.Open_method();
                    ClsStaticStation.m_Global.mycls.initchannel();


                    ((FormMainLab)Application.OpenForms["FormMainLab"]).InitKey();
                    ((FormMainLab)Application.OpenForms["FormMainLab"]).InitMeter();
                }
            }

            controlex.Dispose();
        }
예제 #2
0
        private void btnexopen_Click(object sender, EventArgs e)
        {
            CustomControls.MethodOpenFileDialog controlex = new CustomControls.MethodOpenFileDialog();
            controlex.StartLocation               = AddonWindowLocation.Right;
            controlex.DefaultViewMode             = FolderViewMode.Details;
            controlex.OpenDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\AppleLabJ" + "\\Method";
            controlex.OpenDialog.AddExtension     = true;
            controlex.OpenDialog.Filter           = "试验方法文件(*.dat)|*.dat";
            controlex.ShowDialog(this);
            if (controlex.OpenDialog.FileName == null)
            {
                return;
            }
            else
            {
                string fileName = controlex.OpenDialog.FileName;

                if (fileName == "")
                {
                    return;
                }
                else
                {
                    this.OpenTheMethodSilently(fileName);
                }

                ClsStaticStation.m_Global.mycls.initchannel();
                ((FormMainLab)Application.OpenForms["FormMainLab"]).InitKey();
                ((FormMainLab)Application.OpenForms["FormMainLab"]).InitMeter();

                string f = System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device\\" + GlobeVal.selcontroller.ToString().Trim() + "\\para\\方法.dat";

                if (System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device") == false)
                {
                    System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device");
                }

                if (System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device\\" + GlobeVal.selcontroller.ToString().Trim()) == false)
                {
                    System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device\\" + GlobeVal.selcontroller.ToString().Trim());
                }

                if (System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device\\" + GlobeVal.selcontroller.ToString().Trim() + "\\para") == false)
                {
                    System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ\\device\\" + GlobeVal.selcontroller.ToString().Trim() + "\\para");
                }
                GlobeVal.mmethodfilename = f;



                CComLibrary.GlobeVal.filesave.SerializeNow(GlobeVal.mmethodfilename);



                GlobeVal.userControltest1.changeUI();

                // btnexopen.Visible = false;

                // buttonExNext.Visible = true;
            }
            controlex.Dispose();
        }
        private void btnelook_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 2)
            {
                CustomControls.MethodOpenFileDialog controlex = new CustomControls.MethodOpenFileDialog();
                controlex.StartLocation               = AddonWindowLocation.Right;
                controlex.DefaultViewMode             = FolderViewMode.Details;
                controlex.OpenDialog.InitialDirectory = lblpath.Text;
                controlex.OpenDialog.AddExtension     = true;
                controlex.OpenDialog.Filter           = "样品文件(*.spe)|*.spe";
                controlex.ShowDialog(this);

                if (controlex.OpenDialog.FileName == null)
                {
                    return;
                }
                else
                {
                    string fileName = controlex.OpenDialog.FileName;
                    gfilename = fileName;
                    if (fileName == "")
                    {
                        return;
                    }
                    else
                    {
                        this.txtsample.Text     = Path.GetFileNameWithoutExtension(fileName);
                        this.txtsamplepath.Text = Path.GetDirectoryName(fileName);

                        if (CComLibrary.GlobeVal.filesave == null)
                        {
                            CComLibrary.GlobeVal.filesave = new CComLibrary.FileStruct();
                        }
                        CComLibrary.GlobeVal.filesave = CComLibrary.GlobeVal.filesave.DeSerializeNow(fileName);

                        CComLibrary.GlobeVal.currentfilesavename = fileName;


                        GlobeVal.putlistboxitem(listBox2);


                        ListViewItem lv = new ListViewItem();
                        lv.Text = this.txtsample.Text;


                        lv.SubItems.Add(ClsStaticStation.m_Global.mycls.TestkindList[CComLibrary.GlobeVal.filesave.methodkind]);
                        lv.SubItems.Add(System.IO.File.GetLastWriteTime(fileName).ToLongDateString() + " " + System.IO.File.GetLastWriteTime(fileName).ToLongTimeString());
                        lv.SubItems.Add(Path.GetDirectoryName(fileName));

                        if (listView2.Items.Count > 0)
                        {
                            if (this.txtsample.Text == listView2.Items[0].Text)
                            {
                                listView2.Items.RemoveAt(0);
                            }

                            if (listView2.Items.Count >= 20)
                            {
                                listView2.Items.RemoveAt(19);
                            }
                        }
                        listView2.Items.Insert(0, lv);



                        for (int i = 0; i < listView2.Items.Count; i++)
                        {
                            GlobeVal.myglobefile.RecentSampleFilename[i]     = listView2.Items[i].Text;
                            GlobeVal.myglobefile.RecentSampleFilenameKind[i] = listView2.Items[i].SubItems[1].Text;
                            GlobeVal.myglobefile.RecentSampleFilePath[i]     = listView2.Items[i].SubItems[3].Text;
                        }

                        for (int i = listView2.Items.Count; i < 20; i++)
                        {
                            GlobeVal.myglobefile.RecentSampleFilename[i]     = "";
                            GlobeVal.myglobefile.RecentSampleFilenameKind[i] = "";
                            GlobeVal.myglobefile.RecentSampleFilePath[i]     = "";
                        }

                        ClsStaticStation.m_Global.mycls.initchannel();
                        ((FormMainLab)Application.OpenForms["FormMainLab"]).InitKey();
                        ((FormMainLab)Application.OpenForms["FormMainLab"]).InitMeter();

                        //lblmethodkind.Text = ClsStaticStation.m_Global.mycls.TestkindList[CComLibrary.GlobeVal.filesave.methodkind];
                        //lblmethod.Text = this.txtmethod.Text;
                    }
                }

                controlex.Dispose();
            }
            if (tabControl1.SelectedIndex == 1)
            {
                this.folderBrowserDialog1.SelectedPath = lblpath.Text;
                this.folderBrowserDialog1.ShowDialog();

                lblpath.Text = this.folderBrowserDialog1.SelectedPath;

                GlobeVal.myglobefile.SamplePath = lblpath.Text;
            }
            if (tabControl1.SelectedIndex == 0)
            {
                CustomControls.MethodOpenFileDialog controlex = new CustomControls.MethodOpenFileDialog();
                controlex.StartLocation               = AddonWindowLocation.Right;
                controlex.DefaultViewMode             = FolderViewMode.Details;
                controlex.OpenDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\AppleLabJ" + "\\Method";
                controlex.OpenDialog.AddExtension     = true;
                controlex.OpenDialog.Filter           = "试验方法文件(*.dat)|*.dat";
                controlex.ShowDialog(this);



                if (controlex.OpenDialog.FileName == null)
                {
                    return;
                }
                else
                {
                    string fileName = controlex.OpenDialog.FileName;
                    gfilename = fileName;

                    if (fileName == "")
                    {
                        return;
                    }
                    else
                    {
                        this.txtmethod.Text = Path.GetFileNameWithoutExtension(fileName);
                        this.txtpath.Text   = Path.GetDirectoryName(fileName);

                        if (CComLibrary.GlobeVal.filesave == null)
                        {
                            CComLibrary.GlobeVal.filesave = new CComLibrary.FileStruct();
                        }
                        CComLibrary.GlobeVal.filesave = CComLibrary.GlobeVal.filesave.DeSerializeNow(fileName);

                        CComLibrary.GlobeVal.currentfilesavename = fileName;

                        GlobeVal.putlistboxitem(listBox1);


                        ListViewItem lv = new ListViewItem();
                        lv.Text = this.txtmethod.Text;


                        lv.SubItems.Add(ClsStaticStation.m_Global.mycls.TestkindList[CComLibrary.GlobeVal.filesave.methodkind]);
                        lv.SubItems.Add(System.IO.File.GetLastWriteTime(fileName).ToLongDateString() + " " + System.IO.File.GetLastWriteTime(fileName).ToLongTimeString());


                        if (listView1.Items.Count > 0)
                        {
                            if (this.txtmethod.Text == listView1.Items[0].Text)
                            {
                                listView1.Items.RemoveAt(0);
                            }
                        }

                        if (listView1.Items.Count >= 20)
                        {
                            listView1.Items.RemoveAt(19);
                        }
                        listView1.Items.Insert(0, lv);



                        for (int i = 0; i < listView1.Items.Count; i++)
                        {
                            GlobeVal.myglobefile.RecentFilename[i]     = listView1.Items[i].Text;
                            GlobeVal.myglobefile.RecentFilenameKind[i] = listView1.Items[i].SubItems[1].Text;
                        }

                        for (int i = listView1.Items.Count; i < 20; i++)
                        {
                            GlobeVal.myglobefile.RecentFilename[i]     = "";
                            GlobeVal.myglobefile.RecentFilenameKind[i] = "";
                        }

                        ClsStaticStation.m_Global.mycls.initchannel();
                        ((FormMainLab)Application.OpenForms["FormMainLab"]).InitKey();
                        ((FormMainLab)Application.OpenForms["FormMainLab"]).InitMeter();

                        lblmethodkind.Text = ClsStaticStation.m_Global.mycls.TestkindList[CComLibrary.GlobeVal.filesave.methodkind];
                        lblmethod.Text     = this.txtmethod.Text;
                    }
                }

                controlex.Dispose();
            }
        }
예제 #4
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            CustomControls.MethodOpenFileDialog controlex = new CustomControls.MethodOpenFileDialog();
            controlex.StartLocation               = AddonWindowLocation.Right;
            controlex.DefaultViewMode             = FolderViewMode.Details;
            controlex.OpenDialog.InitialDirectory = "c:\\data\\";
            controlex.OpenDialog.AddExtension     = true;
            controlex.OpenDialog.Filter           = "试验方法文件(*.spe)|*.spe";
            controlex.ShowDialog(this);
            if (controlex.OpenDialog.FileName == null)
            {
                return;
            }
            else
            {
                string fileName = controlex.OpenDialog.FileName;

                if (fileName == "")
                {
                    return;
                }
                else
                {
                }



                CComLibrary.GlobeVal.filesave = CComLibrary.GlobeVal.filesave.DeSerializeNow(fileName);


                Init();

                userControlRawdata1.Init();
                userControlRawdata1.dataGridView1.Rows.Clear();

                fileName = Path.GetFileNameWithoutExtension(fileName) + "-1.txt";

                userControlGraph1.userGraph1.scatterGraph1.YAxes[0].Mode = NationalInstruments.UI.AxisMode.AutoScaleLoose;
                userControlGraph1.userGraph1.scatterGraph1.XAxes[0].Mode = NationalInstruments.UI.AxisMode.AutoScaleLoose;
                bool     firstread  = false;
                string   firstline  = "";
                string   secondline = "";
                int      i          = 0;
                bool     r          = true;
                char[]   sp;
                char[]   sp1;
                string[] ww;
                string[] ww1;
                int      xchsel = 0;
                int      ychsel = 0;

                double x = 0;
                double y = 0;

                sp  = new char[2];
                sp1 = new char[2];

                sp[0] = Convert.ToChar(" ");


                xchsel = 0;
                ychsel = 0;



                userControlGraph1.userGraph1.scatterGraph1.Plots[0].ClearData();
                StreamReader m_streamReader = new StreamReader(fileName, System.Text.Encoding.Default);
                try
                {
                    //使用StreamReader类来读取文件
                    m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                    // 从数据流中读取每一行,直到文件的最后一行,并在richTextBox1中显示出内容

                    string strLine = m_streamReader.ReadLine();
                    firstline  = strLine;
                    strLine    = m_streamReader.ReadLine();
                    secondline = strLine;
                    strLine    = m_streamReader.ReadLine();


                    ww  = firstline.Split(sp);
                    ww1 = secondline.Split(sp);
                    userControlGraph1.userGraph1.scatterGraph1.XAxes[0].Caption = ww[xchsel] + "[" + ww1[xchsel] + "]";
                    userControlGraph1.userGraph1.scatterGraph1.YAxes[0].Caption = ww[ychsel] + "[" + ww1[ychsel] + "]";


                    while (r == true)
                    {
                        ww = strLine.Split(sp);


                        userControlRawdata1.dataGridView1.Rows.Add(ww);


                        x = Convert.ToDouble(ww[xchsel]);
                        y = Convert.ToDouble(ww[ychsel]);

                        userControlGraph1.userGraph1.scatterGraph1.Plots[0].PlotXYAppend(x, y);

                        strLine = m_streamReader.ReadLine();

                        if (strLine == null)
                        {
                            r = false;
                        }

                        i = i + 1;
                    }
                    //关闭此StreamReader对象
                    m_streamReader.Close();


                    // legend.Items[curvescount - 1].Text = fileName;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                firstread = true;

                UserControlSpe1.setspe(1, CComLibrary.TestStatus.tested);
                UserControlSpe1.setinput();
            }
        }