123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using MeasureData;
- using System.Configuration;
- using FileManager;
- using System.IO;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- //20201029:注释
- //初始化窗口管理的是参数,包括,测量文件使用的参数,配置文件中的参数(默认参数),或者保存成参数文件。
- //初始化窗口中显示的参数是测量文件在使用的参数。
- //点击确认,对当前修改的参数保存到测量文件中去。
- //点击保存默认设置,当前修改的参数保存到AppConfig中,下次打开时作为默认值打开。
- //点击保存成配置文件,将以文件的形式将参数保存在文件中
- //参数又分为两种类型,客户操作可见的类型,在AppConfig中参数,
- //客户操作的参数,可以每次都针对测量进行修改
- //这类参数包括:
- //是否是倾斜的样品台
- //是否仅拍照
- //是否使用PT
- //PT加工文件
- //FIB加工文件
- //样品名称
- //厂商
- //拉直操作的放大倍数
- //定位的电压
- //定位的放大倍数
- //拍照的电压
- //拍照的放大倍数
- //AppConfig中的参数,通常不需要修改,每次修改要在配置文件中修改,要重新启动程序
- //这类参数包括:
- //四组对焦参数
- //Z轴的移动距离
- //各个参数需要有一系列的默认值,并且各个值可以修改,删除
- namespace HOZProject
- {
- public partial class UControl_Init : UserControl
- {
- #region 成员变量
- //可供选择的各个参数的值列表
- String[] sT;//样品类型列表
- String[] firms;//厂商列表
- String[] WPZD;//拍照电压列表
- String[] WPZF;//拍照放大倍数列表
- String[] WQGD;//定位电压列表
- String[] WQGF;//定位电压放大倍数列表
- String[] WLZ;//拉直电压列表
- String[] WFIB;//FIB电压列表
- //配置文件
- Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
- //依附与主工作窗口
- private FormHOZMain formHOZMain;
- public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
-
- //模板路径
- private string readConfigPath;
- public string ReadConfigPath { get => readConfigPath; set => readConfigPath = value; }
-
- //模板文件默认路径
- private string m_TemplateFilePath;
- #endregion
- #region 构造方法
- public UControl_Init(FormHOZMain formHOZ)
- {
- InitializeComponent();
- FormHOZMainObject = formHOZ;
- }
- #endregion
- #region 窗体加载
- private void UControl_Init_Load(object sender, EventArgs e)
- {
- //从配置文件中读取一系列的信息
- cbbWYP.Items.Clear();
- DirectoryInfo TheFolder = new DirectoryInfo(System.Environment.CurrentDirectory + "\\SampleTemplate");
- foreach (FileInfo fi in TheFolder.GetFiles())//遍历文件夹下所有文件
- {
- cbbWYP.Items.Add(fi.Name);
- }
- SetTypel();
- }
- #endregion
- #region 关闭窗体
- private void btnClose_Click(object sender, EventArgs e)
- {
- //按照当前的值,更新测量文件的参数
- SaveMeasureFile();
- Form fParent = this.ParentForm;
- fParent.Close();
- }
- #endregion
- #region 加载切孔文件,生成切孔列表
- private void btnCutHoleFile_Click(object sender, EventArgs e)
- {
- try
- {
- if (FormHOZMainObject.m_MeasureFile == null)
- {
- MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
- {
- MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
- //文件路径
- string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
- FormHOZMainObject.CreateCutHoleList(ListCutHole);
- //显示导入的切孔数量
- lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
- tbCutHoleFilePath.Text = CutHoleFilePath;
- //保存测量文件
- if (Directory.Exists(FormHOZMainObject.m_MeasureFile.FilePath))
- {
- FormHOZMainObject.m_MeasureFile.Save();
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogManager.LogError(ex.Message);
- }
- }
- private void pbCutHoleFile_Click(object sender, EventArgs e)
- {
-
- }
- #endregion
- #region 根据一个切孔文件,自动计算其他切孔信息
- /// <summary>
- /// 根据一个切孔,自动计算其他切孔信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- ///
- private void btnCutHoleAuto_Click(object sender, EventArgs e)
- {
- try
- {
- if (FormHOZMainObject.m_MeasureFile == null)
- {
- MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
- {
- MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
- if (ListCutHole != null)
- {
- if (ListCutHole.Count > 0)
- {
- //根据切孔文件的一个切孔,自动计算其他切孔位置
- float centerX = 65;
- float centerY = 65;
- float firstX = ListCutHole[0].Position.X;
- float firstY = ListCutHole[0].Position.Y;
- //距离
- float distance = Convert.ToSingle(config.AppSettings.Settings["distance"].Value.ToString());
- //矩阵 4*4
- int rag = Convert.ToInt32(config.AppSettings.Settings["rag"].Value.ToString());
- List<PointF> cutHolePoint = new List<PointF>();
- //根据一个切孔点计算其他切孔信息
- cutHolePoint = AnalysisPosition(centerX, centerY, firstX, firstY, distance, rag);
- if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromAnalysisPosition(cutHolePoint))
- {
- MessageBox.Show("生成切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- //文件路径
- string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
- //重新获取切孔列表信息
- ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
- //创建切孔列表信息
- FormHOZMainObject.CreateCutHoleList(ListCutHole);
- //显示导入的切孔数量
- lblCutHoleCount.Text = string.Format("成功生成{0}个切孔", ListCutHole.Count);
- tbCutHoleFilePath.Text = CutHoleFilePath;
- }
- }
- }
- //保存测量文件
- if (FormHOZMainObject.IsSave)
- {
- FormHOZMainObject.m_MeasureFile.Save();
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogManager.LogError(ex.Message);
- }
- }
- private void pbCutHoleAuto_Click(object sender, EventArgs e)
- {
-
- }
- /// <summary>
- /// 分析点坐标
- /// </summary>
- /// <param name="centerX">中心点X轴坐标</param>
- /// <param name="centerY">中心点Y轴坐标</param>
- /// <param name="firstX">第一个点X轴坐标</param>
- /// <param name="firstY">第一个点Y轴坐标</param>
- /// <param name="distance">点与点的距离</param>
- /// <param name="rag">行、列数</param>
- /// <param name="ptsx">计算生成所有X轴坐标</param>
- /// <param name="ptsy">计算生成所有Y轴坐标</param>
- public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY, float distance, int rag)
- {
- //求样品1的水平角度
- double angle = 0;
- //清空所有点信息
- List<float> ptsx = new List<float>();
- List<float> ptsy = new List<float>();
- //将第一个点加入到点信息中
- ptsx.Add(firstX);
- ptsy.Add(firstY);
- //计算第一个点与X轴的交角度数
- angle = Math.Atan2(ptsy[0] - centerY, centerX - ptsx[0]) * 180 / Math.PI;
- //这里是求与第一个点横向排列的其他点的移动角度
- //就是按45度向左向右移动的度
- angle = 45 - angle;
- angle = angle * Math.PI / 180;
- float tx = 0;
- float ty = 0;
- for (int j = 0; j < rag; j++)
- {
- //计算每行第一个点的坐标
- if (j > 0)
- {
- tx = (float)(distance * j * Math.Sin(angle));
- ty = (float)(distance * j * Math.Cos(angle));
- ptsx.Add(tx + ptsx[0]);
- ptsy.Add(ptsy[0] - ty);
- }
- //计算每行其他点的坐标
- for (int i = 1; i < rag; i++)
- {
- tx = (float)(distance * i * Math.Cos(angle));
- ty = (float)(distance * i * Math.Sin(angle));
- ptsx.Add(tx + ptsx[j * rag]);
- ptsy.Add(ty + ptsy[j * rag]);
- }
- }
- List<PointF> pts = new List<PointF>();
- for (int i = 0; i < ptsx.Count; i++)
- {
- //增加的点
- PointF pf = new PointF();
- pf.X = ptsx[i];
- pf.Y = ptsy[i];
- pts.Add(pf);
- }
- return pts;
- }
- #endregion
- #region 加载PT模板文件
- private void btnPTTemplateFile_Click(object sender, EventArgs e)
- {
- string FilePathName;
- string fileNameWithoutExtension;
- //新建一个文件对话框
- OpenFileDialog pOpenFileDialog = new OpenFileDialog();
- //设置对话框标题
- pOpenFileDialog.Title = "选择模板文件";
- //默认目录
- pOpenFileDialog.InitialDirectory= @"\\192.168.1.101\fib auto\FIB Recipe\";
- //设置打开文件类型
- pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
- ////监测文件是否存在
- //pOpenFileDialog.CheckFileExists = true;
- //文件打开后执行以下程序
- if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
- {
- FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
- fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
- this.txtWPTF.Text = FilePathName;
- }
- }
- private void pbTemplateFile_Click(object sender, EventArgs e)
- {
-
- }
- #endregion
- #region 加载FIB模板文件
- private void btnFIBTemplateFile_Click(object sender, EventArgs e)
- {
- string FilePathName;
- string fileNameWithoutExtension;
- //新建一个文件对话框
- OpenFileDialog pOpenFileDialog = new OpenFileDialog();
- //设置对话框标题
- pOpenFileDialog.Title = "选择模板文件";
- //默认目录
- pOpenFileDialog.InitialDirectory = @"\\192.168.1.101\fib auto\FIB Recipe\";
- //设置打开文件类型
- pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
- ////监测文件是否存在
- //pOpenFileDialog.CheckFileExists = true;
- //文件打开后执行以下程序
- if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
- {
- FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
- fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
- this.txtWFIBF.Text = FilePathName;
- }
- }
- private void pbFIBTemplateFile_Click(object sender, EventArgs e)
- {
-
- }
- #endregion
- #region 创建与读取样品参数、配置文件
- private void btnEditConfig_Click(object sender, EventArgs e)
- {
- DirectoryInfo TheFolder = new DirectoryInfo(System.Environment.CurrentDirectory + "\\SampleTemplate");
- Process pro = Process.Start(@"C:\Windows\notepad.exe", TheFolder.ToString()+ "\\" + cbbWYP.Text);//打开程序B
-
- }
- /// <summary>
- /// 获取测量参数,初始化窗体中的控件信息
- /// </summary>
- /// <returns></returns>
- public MeasureParam GetMeasureParamInfo()
- {
- //从当前界面内获取参数
- MeasureParam m_param = new MeasureParam();
- m_param.Is_Photograph = chkWIsP.Checked;//是否仅拍照
- m_param.PT = chkWPT.Checked;//是否有PT
- m_param.Tilt = chkWqxkc.Checked;//是否倾斜样品台
- m_param.EDS = chkEDS.Checked;
- m_param.EDSZ = Convert.ToSingle(txtEDSZ.Text)/1000;
- m_param.EDSV = Convert.ToSingle(cbbEDSV.Text);
- m_param.EDSA = Convert.ToSingle(cbbEDSA.Text)/1000000000;
- m_param.EDSParam.XrayCollectMode = Convert.ToInt16(cboXrayMode.Text);
- //自动对焦模式
- //cfm.FocusMode = chkManul.Checked;
- m_param.PTTemp = txtWPTF.Text;//PT文件路径
- m_param.FIBTemp = txtWFIBF.Text;//FIB文件路径
- m_param.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);//来自放大倍数
- m_param.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);//定位的放大倍数
- m_param.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);//定位的放大电压
- m_param.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);//拍照的放大倍数
- m_param.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);//拍照的电压
- //cfm.FIB_Magnification = Convert.ToSingle(cbbWFIB.Text);//FIB的放大倍数
-
- m_param.ScanRotCor = Convert.ToSingle(txtScanRotCur.Text);
- m_param.PixelSizeCor = Convert.ToSingle(txtYPSCur.Text);
- if (cbbWXZ.SelectedIndex == 0)//校正角度
- {
- m_param.Correction_Angle = 36;
- }
- else
- {
- m_param.Correction_Angle = 54;
- }
- m_param.SampleName = cbbWYP.Text;//样品类型
- m_param.Firm = cbbWCS.Text;//厂商类型
- return m_param;
- }
- public void SaveTemplateFile()
- {
- //获取当前文件的参数
- MeasureParam cfm = FormHOZMainObject.m_MeasureFile.MParam;
-
- //根据界面显示内容更新参数
- cfm.Is_Photograph = chkWIsP.Checked;
- cfm.PT = chkWPT.Checked;
- cfm.Tilt = chkWqxkc.Checked;//是否倾斜样品台
- cfm.EDS = chkEDS.Checked;
- //自动对焦模式
- //cfm.FocusMode = chkManul.Checked;
- cfm.PTTemp = txtWPTF.Text;
- cfm.FIBTemp = txtWFIBF.Text;
- cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
- cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
- cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
- cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
- cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
- //cfm.FIB_Magnification = Convert.ToSingle(cbbWFIB.Text);
- if (cbbWXZ.SelectedIndex == 0)
- {
- cfm.Correction_Angle = 36;
- }
- else
- {
- cfm.Correction_Angle = 54;
- }
- cfm.SampleName = cbbWYP.Text;
- cfm.Firm = cbbWCS.Text;
- //保存配置文件中的参数
- cfm.ZDistance = Convert.ToSingle(ConfigurationManager.AppSettings["ZDistance"].ToString());
- //cfm.AutoFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_UP"].ToString());
- //cfm.AutoFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Down"].ToString());
- //cfm.AutoFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Step"].ToString());
- //cfm.AutoFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Range"].ToString());
- //cfm.AutoFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_FStep"].ToString());
- //cfm.FIBFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_UP"].ToString());
- //cfm.FIBFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Down"].ToString());
- //cfm.FIBFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Step"].ToString());
- //cfm.FIBFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Range"].ToString());
- //cfm.FIBFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_FStep"].ToString());
- //cfm.AutoStigX.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_UP"].ToString());
- //cfm.AutoStigX.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Down"].ToString());
- //cfm.AutoStigX.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Step"].ToString());
- //cfm.AutoStigX.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Range"].ToString());
- //cfm.AutoStigX.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_FStep"].ToString());
- //cfm.AutoStigY.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_UP"].ToString());
- //cfm.AutoStigY.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Down"].ToString());
- //cfm.AutoStigY.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Step"].ToString());
- //cfm.AutoStigY.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Range"].ToString());
- //cfm.AutoStigY.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_FStep"].ToString());
- ConfigFile cf = new ConfigFile(cfm);
- m_TemplateFilePath = ConfigurationManager.AppSettings["TemplateFilePath"].ToString();
- //如果路径不存在,要求选择一个路径
- if (!Directory.Exists(m_TemplateFilePath))
- {
- //创建路径
- //Directory.CreateDirectory(m_TemplateFilePath);
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "请选择文件路径";
- //dialog.RootFolder = Environment.SpecialFolder.Programs;
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- m_TemplateFilePath = dialog.SelectedPath;
- config.AppSettings.Settings["TemplateFilePath"].Value = m_TemplateFilePath;
- config.Save(ConfigurationSaveMode.Modified);
- ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
- }
- }
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- //设置默认打开路径(绝对路径)
- saveFileDialog.InitialDirectory = m_TemplateFilePath;
- saveFileDialog.Filter = "样品参数文件|*.cfg";
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- cf.Save(saveFileDialog.FileName);
- }
- else
- {
- return;
- }
- //编辑Config文件
- EditConfig();
- }
- /// <summary>
- /// 编辑confing 文件信息
- /// </summary>
- public bool EditConfig()
- {
- try
- {
- //设置数据源信息
- //样品类型
- List<String> _sT = sT.ToList();
- if ((_sT.IndexOf(cbbWYP.Text) < 0)
- || (!_sT.Contains(cbbWYP.Text)))
- {
- _sT.Add(cbbWYP.Text);
- string wsT = string.Join(",", _sT.ToArray());
- config.AppSettings.Settings["Sample_Type"].Value = wsT;
- }
- //厂商
- List<String> _firms = firms.ToList();
- if ((_firms.IndexOf(cbbWCS.Text) < 0)
- || (!_firms.Contains(cbbWCS.Text)))
- {
- _firms.Add(cbbWCS.Text);
- string wFirms = string.Join(",", _firms.ToArray());
- config.AppSettings.Settings["Firm"].Value = wFirms;
- }
- //拍照电压
- List<String> _WPZD = WPZD.ToList();
- if ((_WPZD.IndexOf(cbbWPZD.Text) < 0)
- || (!_WPZD.Contains(cbbWPZD.Text)))
- {
- _WPZD.Add(cbbWPZD.Text);
- string wWPZD = string.Join(",", _WPZD.ToArray());
- config.AppSettings.Settings["WPZD"].Value = wWPZD;
- }
- //拍照放大位数
- List<String> _WPZF = WPZF.ToList();
- if ((_WPZF.IndexOf(cbbWPZF.Text) < 0)
- || (!_WPZF.Contains(cbbWPZF.Text)))
- {
- _WPZF.Add(cbbWPZF.Text);
- string wWPZF = string.Join(",", _WPZF.ToArray());
- config.AppSettings.Settings["WPZF"].Value = wWPZF;
- }
- //定位切割电压
- List<String> _WQGD = WQGD.ToList();
- if ((_WQGD.IndexOf(cbbWQGD.Text) < 0)
- || (!_WQGD.Contains(cbbWQGD.Text)))
- {
- _WQGD.Add(cbbWQGD.Text);
- string wWQGD = string.Join(",", _WQGD.ToArray());
- config.AppSettings.Settings["WQGD"].Value = wWQGD;
- }
- //定位切割放大位数
- List<String> _WQGF = WQGF.ToList();
- if ((_WQGF.IndexOf(cbbWQGF.Text) < 0)
- || (!_WQGF.Contains(cbbWQGF.Text)))
- {
- _WQGF.Add(cbbWQGF.Text);
- string wWQGF = string.Join(",", _WQGF.ToArray());
- config.AppSettings.Settings["WQGF"].Value = wWQGF;
- }
- //拉直操作放大位数
- List<String> _WLZ = WLZ.ToList();
- if ((_WLZ.IndexOf(cbbWLZ.Text) < 0)
- || (!_WLZ.Contains(cbbWLZ.Text)))
- {
- _WLZ.Add(cbbWLZ.Text);
- string wWLZ = string.Join(",", _WLZ.ToArray());
- config.AppSettings.Settings["WLZ"].Value = wWLZ;
- }
- //ScanRotate修正
- config.AppSettings.Settings["ScanRotCur"].Value = txtScanRotCur.Text;
- config.AppSettings.Settings["PixelSize_Y_Cur"].Value = txtYPSCur.Text;
- //FIB放大位数
- //List<String> _WFIB = WFIB.ToList();
- //if ((_WFIB.IndexOf(cbbWFIB.Text) < 0)
- // ||(!_WFIB.Contains(cbbWFIB.Text)))
- //{
- // _WFIB.Add(cbbWFIB.Text);
- // string wWFIB = string.Join(",", _WFIB.ToArray());
- // config.AppSettings.Settings["WFIB"].Value = wWFIB;
- //}
- MeasureParam m_Prm = new MeasureParam();
- //m_Prm = FormHOZMainObject.m_MeasureFile.MParam;
- m_Prm.Is_Photograph = chkWIsP.Checked;
- m_Prm.FocusMode = Convert.ToInt32(config.AppSettings.Settings["Focus_Mode"].Value);
- m_Prm.PT = chkWPT.Checked;
- //EDS
- m_Prm.EDS = chkEDS.Checked;
- config.AppSettings.Settings["Is_EDS"].Value = chkEDS.Checked.ToString();
- m_Prm.EDSZ = Convert.ToSingle(txtEDSZ.Text)/1000;
- config.AppSettings.Settings["EDS_Z"].Value = txtEDSZ.Text;
- m_Prm.EDSV = Convert.ToSingle(cbbEDSV.Text);
- config.AppSettings.Settings["EDS_V"].Value = cbbEDSV.Text;
- m_Prm.EDSA = Convert.ToSingle(cbbEDSA.Text) / 1000000000;
- config.AppSettings.Settings["EDS_A"].Value = cbbEDSA.Text;
- m_Prm.EDSParam.XrayCollectMode = Convert.ToInt16(cboXrayMode.Text);
- config.AppSettings.Settings["EDS_XrayMode"].Value = cboXrayMode.Text;
- //自动对焦模式
- //cfm.FocusMode = chkManul.Checked;
- m_Prm.PTTemp = txtWPTF.Text;
- m_Prm.FIBTemp = txtWFIBF.Text;
- m_Prm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
- m_Prm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
- m_Prm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
- m_Prm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
- m_Prm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
- //cfm.FIB_Magnification = Convert.ToSingle(cbbWFIB.Text);
-
- //倾斜观测
- m_Prm.Tilt = chkWqxkc.Checked;
- //移动Z轴大小
- m_Prm.PixelSizeCor = Convert.ToSingle(txtYPSCur.Text);
- if (cbbWXZ.SelectedIndex == 0)
- {
- m_Prm.Correction_Angle = 36;
- }
- else
- {
- m_Prm.Correction_Angle = 54;
- }
- m_Prm.SampleName = cbbWYP.Text;
- m_Prm.Firm = cbbWCS.Text;
- ////设置配置文件默认值
- //config.AppSettings.Settings["Is_FIBDo"].Value = m_Prm.FIBDo.ToString();
- //config.AppSettings.Settings["Is_FIBAutoBc"].Value = m_Prm.FIBAutoBC.ToString();
- //config.AppSettings.Settings["FIBB"].Value = m_Prm.FIBB.ToString();
- //config.AppSettings.Settings["FIBC"].Value = m_Prm.FIBC.ToString();
- //config.AppSettings.Settings["MagComp"].Value = m_Prm.MagComp.ToString();
- //config.AppSettings.Settings["MagRange1"].Value = m_Prm.MagRange1.ToString();
- //config.AppSettings.Settings["MagRange2"].Value = m_Prm.MagRange2.ToString();
- //config.AppSettings.Settings["MagRange3"].Value = m_Prm.MagRange3.ToString();
- //config.AppSettings.Settings["MagCompX1"].Value = m_Prm.MagCompX1.ToString();
- //config.AppSettings.Settings["MagCompX2"].Value = m_Prm.MagCompX2.ToString();
- //config.AppSettings.Settings["MagCompX3"].Value = m_Prm.MagCompX3.ToString();
- //config.AppSettings.Settings["MagCompY1"].Value = m_Prm.MagCompY1.ToString();
- //config.AppSettings.Settings["MagCompY2"].Value = m_Prm.MagCompY2.ToString();
- //config.AppSettings.Settings["MagCompY3"].Value = m_Prm.MagCompY3.ToString();
- config.AppSettings.Settings["Is_Photograph"].Value = m_Prm.Is_Photograph.ToString();
- config.AppSettings.Settings["PT_Depostion"].Value = m_Prm.PT.ToString();
- config.AppSettings.Settings["PT_ELYFile"].Value = m_Prm.PTTemp;
- config.AppSettings.Settings["FIB_ELYFile"].Value = m_Prm.FIBTemp;
- config.AppSettings.Settings["Stretch_Magnification"].Value = m_Prm.Stretch_Magnification.ToString();
- config.AppSettings.Settings["Location_Magnification"].Value = m_Prm.Location_Magnification.ToString();
- config.AppSettings.Settings["Location_Voltage"].Value = m_Prm.Location_Voltage.ToString();
- config.AppSettings.Settings["Photograph_Magnification"].Value = m_Prm.Photograph_Magnification.ToString();
- config.AppSettings.Settings["Photograph_Voltage"].Value = m_Prm.Photograph_Voltage.ToString();
- config.AppSettings.Settings["Correction_Angle"].Value = m_Prm.Correction_Angle.ToString();
- config.AppSettings.Settings["SampleName"].Value = m_Prm.SampleName;
- config.AppSettings.Settings["Firms"].Value = m_Prm.Firm;
- config.AppSettings.Settings["FIB_Magnification"].Value = m_Prm.FIB_Magnification.ToString();
- config.AppSettings.Settings["Is_Title"].Value = m_Prm.Tilt.ToString();
- config.AppSettings.Settings["ZDistance"].Value = m_Prm.ZDistance.ToString();
- config.Save(ConfigurationSaveMode.Modified);
- ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
- return true;
- }
- catch (Exception ex)
- {
- LogManager.LogError(ex.Message);
- return false;
- }
- }
-
- /// <summary>
- /// 绑定下拉菜单
- /// </summary>
- /// <param name="cb"></param>
- /// <param name="strGroup"></param>
- private void BindComboxData(ComboBox cb, string[] strGroup)
- {
- for (int i = 0; i < strGroup.Length; i++)
- {
- if (!strGroup[i].Equals(""))
- {
- cb.Items.Add(strGroup[i]);
- }
- }
- }
- /// <summary>
- /// 读取Config文件信息
- /// </summary>
- public void ReloadConfig()
- {
- cbbWYP.Items.Clear();
- cbbWCS.Items.Clear();
- cbbWPZD.Items.Clear();
- cbbWPZF.Items.Clear();
- cbbWQGD.Items.Clear();
- cbbWQGF.Items.Clear();
- cbbWLZ.Items.Clear();
- //cbbWFIB.Items.Clear();
- txtYPSCur.Text = config.AppSettings.Settings["PixelSize_Y_Cur"].Value.ToString();
- m_TemplateFilePath = config.AppSettings.Settings["TemplateFilePath"].Value.ToString();
- string sample_Type = config.AppSettings.Settings["Sample_Type"].Value.ToString();
- string firm = config.AppSettings.Settings["Firm"].Value.ToString();
- string WPZDTemp = config.AppSettings.Settings["WPZD"].Value.ToString();
- string WPZFTemp = config.AppSettings.Settings["WPZF"].Value.ToString();
- string WQGDTemp = config.AppSettings.Settings["WQGD"].Value.ToString();
- string WQGFTemp = config.AppSettings.Settings["WQGF"].Value.ToString();
- string WLZTemp = config.AppSettings.Settings["WLZ"].Value.ToString();
- string WFIBTemp = config.AppSettings.Settings["WFIB"].Value.ToString();
- //string ZZDistance = config.AppSettings.Settings["ZDistance"].Value.ToString();
- string ScanRotCur = config.AppSettings.Settings["ScanRotCur"].Value.ToString();
-
- //样品类型
- sT = sample_Type.Split(',');
- BindComboxData(cbbWYP, sT);
- //厂商
- firms = firm.Split(',');
- BindComboxData(cbbWCS, firms);
- //拍照电压
- WPZD = WPZDTemp.Split(',');
- BindComboxData(cbbWPZD, WPZD);
- //拍照放大位数
- WPZF = WPZFTemp.Split(',');
- BindComboxData(cbbWPZF, WPZF);
- //定位切割电压
- WQGD = WQGDTemp.Split(',');
- BindComboxData(cbbWQGD, WQGD);
- //定位切割放大位数
- WQGF = WQGFTemp.Split(',');
- BindComboxData(cbbWQGF, WQGF);
- //拉直操作放大位数
- WLZ = WLZTemp.Split(',');
- BindComboxData(cbbWLZ, WLZ);
- //FIB放大倍数
- //WFIB = WFIBTemp.Split(',');
- //BindComboxData(cbbWFIB, WFIB);
- txtScanRotCur.Text = ScanRotCur;
-
- //设置配置文件默认值
- chkWIsP.Checked=Convert.ToBoolean(config.AppSettings.Settings["Is_Photograph"].Value);
- chkWPT.Checked = Convert.ToBoolean(config.AppSettings.Settings["PT_Depostion"].Value);
- //倾斜观测
- chkWqxkc.Checked = Convert.ToBoolean(config.AppSettings.Settings["Is_Title"].Value);
- //移动Z轴大小
- txtYPSCur.Text = config.AppSettings.Settings["PixelSize_Y_Cur"].Value;
- //自动对焦模式
- //chkManul.Checked = Convert.ToBoolean(config.AppSettings.Settings["Focus_Mode"].Value);
- txtWPTF.Text = config.AppSettings.Settings["PT_ELYFile"].Value;
- txtWFIBF.Text = config.AppSettings.Settings["FIB_ELYFile"].Value;
- cbbWLZ.Text = config.AppSettings.Settings["Stretch_Magnification"].Value;
- cbbWQGF.Text = config.AppSettings.Settings["Location_Magnification"].Value;
- cbbWQGD.Text = config.AppSettings.Settings["Location_Voltage"].Value;
- cbbWPZF.Text = config.AppSettings.Settings["Photograph_Magnification"].Value;
- cbbWPZD.Text = config.AppSettings.Settings["Photograph_Voltage"].Value;
- //cbbWFIB.Text = config.AppSettings.Settings["FIB_Magnification"].Value;
- string Correction_Angle = config.AppSettings.Settings["Correction_Angle"].Value;
-
- if (Correction_Angle == "36")
- {
- cbbWXZ.SelectedIndex = 0;
- }
- else
- {
- cbbWXZ.SelectedIndex = 1;
- }
- cbbWYP.Text = config.AppSettings.Settings["SampleName"].Value;
- cbbWCS.Text = config.AppSettings.Settings["Firms"].Value;
- //能谱和能谱Z轴移动位置
- chkEDS.Checked = Convert.ToBoolean(config.AppSettings.Settings["Is_EDS"].Value);
- txtEDSZ.Text = Convert.ToString(config.AppSettings.Settings["EDS_Z"].Value);
- cbbEDSV.Text = Convert.ToString(config.AppSettings.Settings["EDS_V"].Value);
- cbbEDSA.Text = Convert.ToString(config.AppSettings.Settings["EDS_A"].Value);
- cboXrayMode.Text = Convert.ToString(config.AppSettings.Settings["EDS_XrayMode"].Value);
- }
- /// <summary>
- /// 根据所选路径,读取模板文件
- /// </summary>
- public void ReadConfigInfo()
- {
- if (!ReadConfigPath.Equals(""))
- {
- ReloadConfig();
- ConfigFile cfm = new ConfigFile(FormHOZMainObject.m_MeasureFile.MParam);
- cfm.Read(ReadConfigPath);
- chkWIsP.Checked = cfm.m_Config.Is_Photograph;
- chkWPT.Checked = cfm.m_Config.PT;
- //自动对焦模式
- //cfm.FocusMode = chkManul.Checked;
- txtWPTF.Text = cfm.m_Config.PTTemp;
- txtWFIBF.Text = cfm.m_Config.FIBTemp;
- cbbWLZ.Text = cfm.m_Config.Stretch_Magnification.ToString();
- cbbWQGF.Text = cfm.m_Config.Location_Magnification.ToString();
- cbbWQGD.Text = cfm.m_Config.Location_Voltage.ToString();
- cbbWPZF.Text = cfm.m_Config.Photograph_Magnification.ToString();
- cbbWPZD.Text = cfm.m_Config.Photograph_Voltage.ToString();
- //cbbWFIB.Text = cfm.m_Config.FIB_Magnification.ToString();
- string Correction_Angle = cfm.m_Config.Correction_Angle.ToString();
- if (Correction_Angle == "36")
- {
- cbbWXZ.SelectedIndex = 0;
- }
- else
- {
- cbbWXZ.SelectedIndex = 1;
- }
- cbbWYP.Text = cfm.m_Config.SampleName;
- cbbWCS.Text = cfm.m_Config.Firm;
- }
- }
- /// <summary>
- /// 修改配置文件默认值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSaveDefalutPara_Click(object sender, EventArgs e)
- {
- if(chkWPT.Checked)
- {
- if (txtWPTF.Text=="")
- {
- MessageBox.Show("PT文件路径不能为空");
- return;
- }
- }
- if(txtWFIBF.Text=="")
- {
- MessageBox.Show("FIB文件路径不能为空");
- return;
- }
- if (EditConfig())
- {
- //MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- formHOZMain.Saveclick();
- }
- //增加一个测量文件的参数修改
- SaveMeasureFile();
- Form fParent = this.ParentForm;
- fParent.Close();
- }
- #endregion
- #region 删除下拉菜单选择项
-
- #endregion
- #region 根据是否仅拍照,进行逻辑判断
- private void chkWIsP_CheckedChanged(object sender, EventArgs e)
- {
- if (chkWIsP.Checked)
- {
- chkWqxkc.Checked = false;
- chkWqxkc.Visible = false;
- chkWPT.Checked = false;
- chkWPT.Visible = false;
- label61.Visible = false;
- label59.Visible = false;
- txtWFIBF.Visible = false;
- txtWPTF.Visible = false;
- btnPTTemplateFile.Visible = false;
- btnFIBTemplateFile.Visible = false;
- label58.Visible = false;
- cbbWXZ.Visible = false;
- chkEDS.Visible = false;
- label18.Visible = false;
- label19.Visible = false;
- txtEDSZ.Visible = false;
- //cbbWFIB.Visible = false;
- //pbDelWFIB.Visible = false;
- FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.Photo;
- }
- else
- {
- chkWqxkc.Visible = true;
- chkWPT.Visible = true;
- label61.Visible = true;
- label59.Visible = true;
- txtWFIBF.Visible = true;
- txtWPTF.Visible = true;
- btnPTTemplateFile.Visible = true;
- btnFIBTemplateFile.Visible = true;
- label58.Visible = true;
- cbbWXZ.Visible = true;
- chkEDS.Visible = true;
- //label2.Visible = true;
- //cbbWFIB.Visible = true;
- //pbDelWFIB.Visible = true;
- label18.Visible = true;
- label19.Visible = true;
- txtEDSZ.Visible = true;
- if (!chkWPT.Checked)
- {
- FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
- }
- }
- CreateCutHoleList();
- }
- #endregion
- #region 从配置文件中读取测量参数
- public MeasureParam GetMeasureParam()
- {
- MeasureParam cfm = new MeasureParam();
- //设置配置文件默认值
- bool bResult = false;
- bool.TryParse(config.AppSettings.Settings["Is_Photograph"].Value, out bResult);
- cfm.Is_Photograph = bResult;
- bool.TryParse(config.AppSettings.Settings["PT_Depostion"].Value, out bResult);
- cfm.PT = bResult;
- cfm.PTTemp = config.AppSettings.Settings["PT_ELYFile"].Value;
- cfm.FIBTemp = config.AppSettings.Settings["FIB_ELYFile"].Value;
- float fResult = (float)0.0;
- float.TryParse(config.AppSettings.Settings["Stretch_Magnification"].Value, out fResult);
- cfm.Stretch_Magnification = fResult;
- float.TryParse(config.AppSettings.Settings["Location_Magnification"].Value, out fResult);
- cfm.Location_Magnification = fResult;
- float.TryParse(config.AppSettings.Settings["Location_Voltage"].Value, out fResult);
- cfm.Location_Voltage = fResult;
- float.TryParse(config.AppSettings.Settings["Photograph_Magnification"].Value, out fResult);
- cfm.Photograph_Magnification = fResult;
- float.TryParse(config.AppSettings.Settings["Photograph_Voltage"].Value, out fResult);
- cfm.Photograph_Voltage = fResult;
- float.TryParse(config.AppSettings.Settings["Correction_Angle"].Value, out fResult);
- cfm.Correction_Angle = fResult;
- cfm.SampleName = config.AppSettings.Settings["SampleName"].Value;
- cfm.Firm = config.AppSettings.Settings["Firms"].Value;
- //cfm.AutoFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_UP"].ToString());
- //cfm.AutoFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Down"].ToString());
- //cfm.AutoFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Step"].ToString());
- //cfm.AutoFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Range"].ToString());
- //cfm.AutoFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_FStep"].ToString());
- //cfm.FIBFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_UP"].ToString());
- //cfm.FIBFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Down"].ToString());
- //cfm.FIBFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Step"].ToString());
- //cfm.FIBFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Range"].ToString());
- //cfm.FIBFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_FStep"].ToString());
- //cfm.AutoStigX.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_UP"].ToString());
- //cfm.AutoStigX.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Down"].ToString());
- //cfm.AutoStigX.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Step"].ToString());
- //cfm.AutoStigX.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Range"].ToString());
- //cfm.AutoStigX.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_FStep"].ToString());
- //cfm.AutoStigY.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_UP"].ToString());
- //cfm.AutoStigY.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Down"].ToString());
- //cfm.AutoStigY.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Step"].ToString());
- //cfm.AutoStigY.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Range"].ToString());
- //cfm.AutoStigY.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_FStep"].ToString());
- bool.TryParse(config.AppSettings.Settings["Is_Title"].Value, out bResult);
- cfm.Tilt = bResult;
- bool.TryParse(config.AppSettings.Settings["Is_EDS"].Value, out bResult);
- cfm.EDS = bResult;
- float.TryParse(config.AppSettings.Settings["ZDistance"].Value, out fResult);
- cfm.ZDistance = fResult;
- //add by sun 2020-12-15 增加不同样品扫描速度参数,每大类样品3种扫描速度
- //cfm.ScanSpeedNormal = ConfigurationManager.AppSettings["ScanSpeedNormal_"+cfm.SampleName].ToString();
- //cfm.ScanSpeedFocus = ConfigurationManager.AppSettings["ScanSpeedFocus_" + cfm.SampleName].ToString();
- //cfm.ScanSpeedHigh = ConfigurationManager.AppSettings["ScanSpeedHigh_" + cfm.SampleName].ToString();
- //LogManager.AddHardwareLog("==========参数测试==" + cfm.SampleName+"======="+ config.AppSettings.Settings["ScanSpeedNormal_0"].Value, true);
- //add by sun 2020-12-15 增加不同样品扫描速度参数,每大类样品3种扫描速度 end
- return cfm;
- }
- #endregion
- #region 创建切孔列表
- private void CreateCutHoleList()
- {
- List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
- FormHOZMainObject.CreateCutHoleList(ListCutHole);
- }
- #endregion
- #region 设置流程类型
- private void chkWPT_CheckedChanged(object sender, EventArgs e)
- {
- if (chkWPT.Checked)
- {
- FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.PT;
- }
- else
- {
- if (!chkWIsP.Checked)
- {
- FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
- }
- }
- CreateCutHoleList();
- }
- #endregion
- #region 关闭按钮 鼠标操作事件
- private void pbClose_MouseEnter(object sender, EventArgs e)
- {
- pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_2_;
- }
- private void pbClose_MouseLeave(object sender, EventArgs e)
- {
- pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_2_;
- }
- #endregion
- #region 输入限制只能是数字
- private void textBox_KeyPress(string text, object sender, KeyPressEventArgs e)
- {
- //判断按键是不是要输入的类型。
- if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
- e.Handled = true;
- //小数点的处理。
- if ((int)e.KeyChar == 46) //小数点
- {
- if (text.Length <= 0)
- e.Handled = true; //小数点不能在第一位
- else
- {
- float f;
- float oldf;
- bool b1 = false, b2 = false;
- b1 = float.TryParse(text, out oldf);
- b2 = float.TryParse(text + e.KeyChar.ToString(), out f);
- if (b2 == false)
- {
- if (b1 == true)
- e.Handled = true;
- else
- e.Handled = false;
- }
- }
- }
- }
- private void ComboBox_KeyPress(string text, object sender, KeyPressEventArgs e)
- {
- //允许输入数字、小数点、删除键和负号
- if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != (char)('-'))
- {
- MessageBox.Show("请输入正确的数字");
- text = "";
- e.Handled = true;
- }
- if (e.KeyChar == (char)('-'))
- {
- if (text != "")
- {
- MessageBox.Show("请输入正确的数字");
- text = "";
- e.Handled = true;
- }
- }
- //小数点只能输入一次
- if (e.KeyChar == (char)('.') && ((ComboBox)sender).Text.IndexOf('.') != -1)
- {
- MessageBox.Show("请输入正确的数字");
- text = "";
- e.Handled = true;
- }
- //第一位不能为小数点
- if (e.KeyChar == (char)('.') && ((ComboBox)sender).Text == "")
- {
- MessageBox.Show("请输入正确的数字");
- text = "";
- e.Handled = true;
- }
- //第一位是0,第二位必须为小数点
- if (e.KeyChar != (char)('.') && ((ComboBox)sender).Text == "0")
- {
- MessageBox.Show("请输入正确的数字");
- text = "";
- e.Handled = true;
- }
- //第一位是负号,第二位不能为小数点
- if (((ComboBox)sender).Text == "-" && e.KeyChar == (char)('.'))
- {
- MessageBox.Show("请输入正确的数字");
- text = "";
- e.Handled = true;
- }
- }
- private void cbbWPZD_KeyPress(object sender, KeyPressEventArgs e)
- {
- ComboBox_KeyPress(cbbWPZD.Text, sender, e);
- }
- private void cbbWPZF_KeyPress(object sender, KeyPressEventArgs e)
- {
- ComboBox_KeyPress(cbbWPZF.Text, sender, e);
- }
- private void cbbWQGD_KeyPress(object sender, KeyPressEventArgs e)
- {
- ComboBox_KeyPress(cbbWQGD.Text, sender, e);
- }
- private void cbbWQGF_KeyPress(object sender, KeyPressEventArgs e)
- {
- ComboBox_KeyPress(cbbWQGF.Text, sender, e);
- }
- private void cbbWLZ_KeyPress(object sender, KeyPressEventArgs e)
- {
- ComboBox_KeyPress(cbbWLZ.Text, sender, e);
- }
- #endregion
- #region Z轴的保护范围
- private void chkWqxkc_CheckedChanged(object sender, EventArgs e)
- {
- //if (chkWqxkc.Checked)
- //{
- // label3.Visible = true;
- // cbbYDZZDX.Visible = true;
- //}
- //else
- //{
- // label3.Visible = false;
- // cbbYDZZDX.Visible = false;
- //}
- }
- private void txtYPSCur_TextChanged(object sender, EventArgs e)
- {
- if (txtYPSCur.Text!="")
- {
- if (Convert.ToSingle(txtYPSCur.Text)>5)
- {
- MessageBox.Show("数值最大为5");
- txtYPSCur.Text = "5";
- }
- }
- else
- {
- txtYPSCur.Text = "1";
- }
-
- }
- private void txtYPSCur_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
- {
- e.Handled = true;
- }
- }
- #endregion
-
- #region 参数确认
- private void SaveMeasureFile()
- {
- //界面上的参数
- FormHOZMainObject.m_MeasureFile.MParam = GetMeasureParamInfo();
- //配置文件中的参数
- FormHOZMainObject.m_MeasureFile.MParam.ZDistance = Convert.ToSingle(ConfigurationManager.AppSettings["ZDistance"].ToString());
- FormHOZMainObject.m_MeasureFile.IsModified = true;
- FormHOZMainObject.m_MeasureFile.MParam.ScanRotCor = Convert.ToSingle(ConfigurationManager.AppSettings["ScanRotCur"].ToString());
- FormHOZMainObject.m_MeasureFile.MParam.PixelSizeCor = Convert.ToSingle(ConfigurationManager.AppSettings["PixelSize_Y_Cur"].ToString());
- FormHOZMainObject.m_MeasureFile.MParam.EDS = Convert.ToBoolean(ConfigurationManager.AppSettings["Is_EDS"].ToString());
- FormHOZMainObject.m_MeasureFile.MParam.EDSZ = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_Z"].ToString()) / 1000;
- FormHOZMainObject.m_MeasureFile.MParam.EDSV = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_V"].ToString());
- FormHOZMainObject.m_MeasureFile.MParam.EDSA = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_A"].ToString()) / 1000000000;
- FormHOZMainObject.m_MeasureFile.MParam.EDSParam.XrayCollectMode =Convert.ToInt16( ConfigurationManager.AppSettings["EDS_XrayMode"].ToString());
- if (Directory.Exists(FormHOZMainObject.m_MeasureFile.FilePath))//如果已经存在硬盘上要重新保存文件
- {
- FormHOZMainObject.m_MeasureFile.Save();
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //保存测量文件的参数
- SaveMeasureFile();
- }
- #endregion
-
-
- private void btnHandSavePoints_Click(object sender, EventArgs e)
- {
- UserControls.FormExportPoints uCExport = new UserControls.FormExportPoints();
- uCExport.ShowDialog();
- List<CutHole> ListCutHole = uCExport.ListCutHole;
- //文件路径
- //string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
- FormHOZMainObject.CreateCutHoleList(ListCutHole);
- FormHOZMainObject.m_MeasureFile.ListCutHole = ListCutHole;
- //显示导入的切孔数量
- lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
- //tbCutHoleFilePath.Text = CutHoleFilePath;
- //保存测量文件
- if (Directory.Exists(FormHOZMainObject.m_MeasureFile.FilePath))
- {
- FormHOZMainObject.m_MeasureFile.Save();
- }
- }
-
- private void cbbWYP_SelectedIndexChanged(object sender, EventArgs e)
- {
- SetTypel();
- }
- private void SetTypel()
- {
- if (cbbWYP.Text == "0")
- {
- //cbbWCS.Text = FormHOZMainObject.m_MeasureFile.MParam.VendorType0;//厂商
- cbbWLZ.Text = FormHOZMainObject.m_MeasureFile.MParam.StraightenTimesType0;//拉直放大倍数
- cbbWQGD.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningVoltageeType0;//定位电压
- cbbWQGF.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningTimesType0;//定位放大倍数
- cbbWPZD.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoVoltageeType0;//拍照电压
- cbbWPZF.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoTimesType0;//拍照放大倍数
- cbbEDSV.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMVoltageeType0;//能谱电压值
- cbbEDSA.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMCurrentType0;//能谱电流值
- label4.Text = "0-AA Hole";
- }
- else
- if (cbbWYP.Text == "1")
- {
- //cbbWCS.Text = FormHOZMainObject.m_MeasureFile.MParam.VendorType1;//厂商
- cbbWLZ.Text = FormHOZMainObject.m_MeasureFile.MParam.StraightenTimesType1;//拉直放大倍数
- cbbWQGD.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningVoltageeType1;//定位电压
- cbbWQGF.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningTimesType1;//定位放大倍数
- cbbWPZD.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoVoltageeType1;//拍照电压
- cbbWPZF.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoTimesType1;//拍照放大倍数
- cbbEDSV.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMVoltageeType1;//能谱电压值
- cbbEDSA.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMCurrentType1;//能谱电流值
- label4.Text = "1-AA区";
- }
- else
- if (cbbWYP.Text == "2")
- {
- //cbbWCS.Text = FormHOZMainObject.m_MeasureFile.MParam.VendorType2;//厂商
- cbbWLZ.Text = FormHOZMainObject.m_MeasureFile.MParam.StraightenTimesType2;//拉直放大倍数
- cbbWQGD.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningVoltageeType2;//定位电压
- cbbWQGF.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningTimesType2;//定位放大倍数
- cbbWPZD.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoVoltageeType2;//拍照电压
- cbbWPZF.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoTimesType2;//拍照放大倍数
- cbbEDSV.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMVoltageeType2;//能谱电压值
- cbbEDSA.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMCurrentType2;//能谱电流值
- label4.Text = "2-Pad bending";
- }
- else
- if (cbbWYP.Text == "3")
- {
- //cbbWCS.Text = FormHOZMainObject.m_MeasureFile.MParam.VendorType3;//厂商
- cbbWLZ.Text = FormHOZMainObject.m_MeasureFile.MParam.StraightenTimesType3;//拉直放大倍数
- cbbWQGD.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningVoltageeType3;//定位电压
- cbbWQGF.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningTimesType3;//定位放大倍数
- cbbWPZD.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoVoltageeType3;//拍照电压
- cbbWPZF.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoTimesType3;//拍照放大倍数
- cbbEDSV.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMVoltageeType3;//能谱电压值
- cbbEDSA.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMCurrentType3;//能谱电流值
- label4.Text = "3-DDIC";
- }
- else
- if (cbbWYP.Text == "4")
- {
- //cbbWCS.Text = FormHOZMainObject.m_MeasureFile.MParam.VendorType3;//厂商
- cbbWLZ.Text = FormHOZMainObject.m_MeasureFile.MParam.StraightenTimesType4;//拉直放大倍数
- cbbWQGD.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningVoltageeType4;//定位电压
- cbbWQGF.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningTimesType4;//定位放大倍数
- cbbWPZD.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoVoltageeType4;//拍照电压
- cbbWPZF.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoTimesType4;//拍照放大倍数
- cbbEDSV.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMVoltageeType4;//能谱电压值
- cbbEDSA.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMCurrentType4;//能谱电流值
- label4.Text = "4-射频IC-1";
- }
- else
- if (cbbWYP.Text == "5")
- {
- //cbbWCS.Text = FormHOZMainObject.m_MeasureFile.MParam.VendorType3;//厂商
- cbbWLZ.Text = FormHOZMainObject.m_MeasureFile.MParam.StraightenTimesType5;//拉直放大倍数
- cbbWQGD.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningVoltageeType5;//定位电压
- cbbWQGF.Text = FormHOZMainObject.m_MeasureFile.MParam.PositioningTimesType5;//定位放大倍数
- cbbWPZD.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoVoltageeType5;//拍照电压
- cbbWPZF.Text = FormHOZMainObject.m_MeasureFile.MParam.PhotoTimesType5;//拍照放大倍数
- cbbEDSV.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMVoltageeType5;//能谱电压值
- cbbEDSA.Text = FormHOZMainObject.m_MeasureFile.MParam.SEMCurrentType5;//能谱电流值
- label4.Text = "5-射频IC-1";
- }
- }
- }
- }
|