Exemple #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();
        }
Exemple #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();
            }
        }