UControl_Init.cs 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MeasureData;
  11. using System.Configuration;
  12. using FileManager;
  13. using System.IO;
  14. using System.Runtime.InteropServices;
  15. //20201029:注释
  16. //初始化窗口管理的是参数,包括,测量文件使用的参数,配置文件中的参数(默认参数),或者保存成参数文件。
  17. //初始化窗口中显示的参数是测量文件在使用的参数。
  18. //点击确认,对当前修改的参数保存到测量文件中去。
  19. //点击保存默认设置,当前修改的参数保存到AppConfig中,下次打开时作为默认值打开。
  20. //点击保存成配置文件,将以文件的形式将参数保存在文件中
  21. //参数又分为两种类型,客户操作可见的类型,在AppConfig中参数,
  22. //客户操作的参数,可以每次都针对测量进行修改
  23. //这类参数包括:
  24. //是否是倾斜的样品台
  25. //是否仅拍照
  26. //是否使用PT
  27. //PT加工文件
  28. //FIB加工文件
  29. //样品名称
  30. //厂商
  31. //拉直操作的放大倍数
  32. //定位的电压
  33. //定位的放大倍数
  34. //拍照的电压
  35. //拍照的放大倍数
  36. //AppConfig中的参数,通常不需要修改,每次修改要在配置文件中修改,要重新启动程序
  37. //这类参数包括:
  38. //四组对焦参数
  39. //Z轴的移动距离
  40. //各个参数需要有一系列的默认值,并且各个值可以修改,删除
  41. namespace HOZProject
  42. {
  43. public partial class UControl_Init : UserControl
  44. {
  45. #region 成员变量
  46. //可供选择的各个参数的值列表
  47. String[] sT;//样品类型列表
  48. String[] firms;//厂商列表
  49. String[] WPZD;//拍照电压列表
  50. String[] WPZF;//拍照放大倍数列表
  51. String[] WQGD;//定位电压列表
  52. String[] WQGF;//定位电压放大倍数列表
  53. String[] WLZ;//拉直电压列表
  54. String[] WFIB;//FIB电压列表
  55. //配置文件
  56. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  57. //依附与主工作窗口
  58. private FormHOZMain formHOZMain;
  59. public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
  60. //模板路径
  61. private string readConfigPath;
  62. public string ReadConfigPath { get => readConfigPath; set => readConfigPath = value; }
  63. //模板文件默认路径
  64. private string m_TemplateFilePath;
  65. #endregion
  66. #region 构造方法
  67. public UControl_Init(FormHOZMain formHOZ)
  68. {
  69. InitializeComponent();
  70. FormHOZMainObject = formHOZ;
  71. }
  72. #endregion
  73. #region 窗体加载
  74. private void UControl_Init_Load(object sender, EventArgs e)
  75. {
  76. //从配置文件中读取一系列的信息
  77. //ReloadConfig();
  78. if (!chkFIBAdjust.Checked)
  79. {
  80. chkFIBAtuoAdjust.Checked = false;
  81. chkFIBAtuoAdjust.Visible = false;
  82. }
  83. if (chkFIBAtuoAdjust.Checked)
  84. {
  85. label4.Visible = false;
  86. tbBrightness.Visible = false;
  87. label7.Visible = false;
  88. label5.Visible = false;
  89. tbContrast.Visible = false;
  90. label8.Visible = false;
  91. }
  92. else
  93. {
  94. label4.Visible = true;
  95. tbBrightness.Visible = true;
  96. label7.Visible = true;
  97. label5.Visible = true;
  98. tbContrast.Visible = true;
  99. label8.Visible = true;
  100. }
  101. }
  102. #endregion
  103. #region 关闭窗体
  104. private void btnClose_Click(object sender, EventArgs e)
  105. {
  106. //按照当前的值,更新测量文件的参数
  107. SaveMeasureFile();
  108. Form fParent = this.ParentForm;
  109. fParent.Close();
  110. }
  111. #endregion
  112. #region 加载切孔文件,生成切孔列表
  113. private void btnCutHoleFile_Click(object sender, EventArgs e)
  114. {
  115. try
  116. {
  117. if (FormHOZMainObject.m_MeasureFile == null)
  118. {
  119. MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  120. }
  121. else
  122. {
  123. if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
  124. {
  125. MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  126. }
  127. else
  128. {
  129. List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  130. //文件路径
  131. string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
  132. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  133. //显示导入的切孔数量
  134. lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
  135. tbCutHoleFilePath.Text = CutHoleFilePath;
  136. //保存测量文件
  137. if (Directory.Exists(FormHOZMainObject.m_MeasureFile.FilePath))
  138. {
  139. FormHOZMainObject.m_MeasureFile.Save();
  140. }
  141. }
  142. }
  143. }
  144. catch (Exception ex)
  145. {
  146. LogManager.LogError(ex.Message);
  147. }
  148. }
  149. private void pbCutHoleFile_Click(object sender, EventArgs e)
  150. {
  151. }
  152. #endregion
  153. #region 根据一个切孔文件,自动计算其他切孔信息
  154. /// <summary>
  155. /// 根据一个切孔,自动计算其他切孔信息
  156. /// </summary>
  157. /// <param name="sender"></param>
  158. /// <param name="e"></param>
  159. ///
  160. private void btnCutHoleAuto_Click(object sender, EventArgs e)
  161. {
  162. try
  163. {
  164. if (FormHOZMainObject.m_MeasureFile == null)
  165. {
  166. MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  167. }
  168. else
  169. {
  170. if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
  171. {
  172. MessageBox.Show("导入切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  173. }
  174. else
  175. {
  176. List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  177. if (ListCutHole != null)
  178. {
  179. if (ListCutHole.Count > 0)
  180. {
  181. //根据切孔文件的一个切孔,自动计算其他切孔位置
  182. float centerX = 65;
  183. float centerY = 65;
  184. float firstX = ListCutHole[0].Position.X;
  185. float firstY = ListCutHole[0].Position.Y;
  186. //距离
  187. float distance = Convert.ToSingle(config.AppSettings.Settings["distance"].Value.ToString());
  188. //矩阵 4*4
  189. int rag = Convert.ToInt32(config.AppSettings.Settings["rag"].Value.ToString());
  190. List<PointF> cutHolePoint = new List<PointF>();
  191. //根据一个切孔点计算其他切孔信息
  192. cutHolePoint = AnalysisPosition(centerX, centerY, firstX, firstY, distance, rag);
  193. if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromAnalysisPosition(cutHolePoint))
  194. {
  195. MessageBox.Show("生成切孔失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  196. }
  197. else
  198. {
  199. //文件路径
  200. string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
  201. //重新获取切孔列表信息
  202. ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  203. //创建切孔列表信息
  204. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  205. //显示导入的切孔数量
  206. lblCutHoleCount.Text = string.Format("成功生成{0}个切孔", ListCutHole.Count);
  207. tbCutHoleFilePath.Text = CutHoleFilePath;
  208. }
  209. }
  210. }
  211. //保存测量文件
  212. if (FormHOZMainObject.IsSave)
  213. {
  214. FormHOZMainObject.m_MeasureFile.Save();
  215. }
  216. }
  217. }
  218. }
  219. catch (Exception ex)
  220. {
  221. LogManager.LogError(ex.Message);
  222. }
  223. }
  224. private void pbCutHoleAuto_Click(object sender, EventArgs e)
  225. {
  226. }
  227. /// <summary>
  228. /// 分析点坐标
  229. /// </summary>
  230. /// <param name="centerX">中心点X轴坐标</param>
  231. /// <param name="centerY">中心点Y轴坐标</param>
  232. /// <param name="firstX">第一个点X轴坐标</param>
  233. /// <param name="firstY">第一个点Y轴坐标</param>
  234. /// <param name="distance">点与点的距离</param>
  235. /// <param name="rag">行、列数</param>
  236. /// <param name="ptsx">计算生成所有X轴坐标</param>
  237. /// <param name="ptsy">计算生成所有Y轴坐标</param>
  238. public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY, float distance, int rag)
  239. {
  240. //求样品1的水平角度
  241. double angle = 0;
  242. //清空所有点信息
  243. List<float> ptsx = new List<float>();
  244. List<float> ptsy = new List<float>();
  245. //将第一个点加入到点信息中
  246. ptsx.Add(firstX);
  247. ptsy.Add(firstY);
  248. //计算第一个点与X轴的交角度数
  249. angle = Math.Atan2(ptsy[0] - centerY, centerX - ptsx[0]) * 180 / Math.PI;
  250. //这里是求与第一个点横向排列的其他点的移动角度
  251. //就是按45度向左向右移动的度
  252. angle = 45 - angle;
  253. angle = angle * Math.PI / 180;
  254. float tx = 0;
  255. float ty = 0;
  256. for (int j = 0; j < rag; j++)
  257. {
  258. //计算每行第一个点的坐标
  259. if (j > 0)
  260. {
  261. tx = (float)(distance * j * Math.Sin(angle));
  262. ty = (float)(distance * j * Math.Cos(angle));
  263. ptsx.Add(tx + ptsx[0]);
  264. ptsy.Add(ptsy[0] - ty);
  265. }
  266. //计算每行其他点的坐标
  267. for (int i = 1; i < rag; i++)
  268. {
  269. tx = (float)(distance * i * Math.Cos(angle));
  270. ty = (float)(distance * i * Math.Sin(angle));
  271. ptsx.Add(tx + ptsx[j * rag]);
  272. ptsy.Add(ty + ptsy[j * rag]);
  273. }
  274. }
  275. List<PointF> pts = new List<PointF>();
  276. for (int i = 0; i < ptsx.Count; i++)
  277. {
  278. //增加的点
  279. PointF pf = new PointF();
  280. pf.X = ptsx[i];
  281. pf.Y = ptsy[i];
  282. pts.Add(pf);
  283. }
  284. return pts;
  285. }
  286. #endregion
  287. #region 加载PT模板文件
  288. private void btnPTTemplateFile_Click(object sender, EventArgs e)
  289. {
  290. string FilePathName;
  291. string fileNameWithoutExtension;
  292. //新建一个文件对话框
  293. OpenFileDialog pOpenFileDialog = new OpenFileDialog();
  294. //设置对话框标题
  295. pOpenFileDialog.Title = "选择模板文件";
  296. //默认目录
  297. pOpenFileDialog.InitialDirectory= @"\\192.168.1.101\fib auto\FIB Recipe\";
  298. //设置打开文件类型
  299. pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
  300. ////监测文件是否存在
  301. //pOpenFileDialog.CheckFileExists = true;
  302. //文件打开后执行以下程序
  303. if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
  304. {
  305. FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
  306. fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
  307. this.txtWPTF.Text = FilePathName;
  308. }
  309. }
  310. private void pbTemplateFile_Click(object sender, EventArgs e)
  311. {
  312. }
  313. #endregion
  314. #region 加载FIB模板文件
  315. private void btnFIBTemplateFile_Click(object sender, EventArgs e)
  316. {
  317. string FilePathName;
  318. string fileNameWithoutExtension;
  319. //新建一个文件对话框
  320. OpenFileDialog pOpenFileDialog = new OpenFileDialog();
  321. //设置对话框标题
  322. pOpenFileDialog.Title = "选择模板文件";
  323. //默认目录
  324. pOpenFileDialog.InitialDirectory = @"\\192.168.1.101\fib auto\FIB Recipe\";
  325. //设置打开文件类型
  326. pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
  327. ////监测文件是否存在
  328. //pOpenFileDialog.CheckFileExists = true;
  329. //文件打开后执行以下程序
  330. if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
  331. {
  332. FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
  333. fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
  334. this.txtWFIBF.Text = FilePathName;
  335. }
  336. }
  337. private void pbFIBTemplateFile_Click(object sender, EventArgs e)
  338. {
  339. }
  340. #endregion
  341. #region 创建与读取样品参数、配置文件
  342. private void btnCreateConfig_Click(object sender, EventArgs e)
  343. {
  344. SaveTemplateFile();
  345. }
  346. /// <summary>
  347. /// 获取测量参数,初始化窗体中的控件信息
  348. /// </summary>
  349. /// <returns></returns>
  350. public MeasureParam GetMeasureParamInfo()
  351. {
  352. //从当前界面内获取参数
  353. MeasureParam cfm = new MeasureParam();
  354. cfm.Is_Photograph = chkWIsP.Checked;//是否仅拍照
  355. cfm.PT = chkWPT.Checked;//是否有PT
  356. cfm.Title = chkWqxkc.Checked;//是否倾斜样品台
  357. cfm.EDS = chkEDS.Checked;
  358. cfm.EDSZ = Convert.ToSingle(txtEDSZ.Text)/1000;
  359. cfm.EDSV = Convert.ToSingle(cbbEDSV.Text);
  360. cfm.EDSA = Convert.ToSingle(cbbEDSA.Text)/1000000000;
  361. //自动对焦模式
  362. //cfm.FocusMode = chkManul.Checked;
  363. cfm.PTTemp = txtWPTF.Text;//PT文件路径
  364. cfm.FIBTemp = txtWFIBF.Text;//FIB文件路径
  365. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);//来自放大倍数
  366. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);//定位的放大倍数
  367. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);//定位的放大电压
  368. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);//拍照的放大倍数
  369. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);//拍照的电压
  370. //cfm.FIB_Magnification = Convert.ToSingle(cbbWFIB.Text);//FIB的放大倍数
  371. //亮度对比度
  372. cfm.FIBDo = chkFIBAdjust.Checked;
  373. cfm.FIBAutoBC = chkFIBAtuoAdjust.Checked;
  374. cfm.FIBB = Convert.ToSingle(tbBrightness.Text);
  375. cfm.FIBC = Convert.ToSingle(tbContrast.Text);
  376. //放大倍数挡位
  377. cfm.MagComp = Convert.ToBoolean(chkGearSwitch.Checked);
  378. cfm.MagRange1 = Convert.ToSingle(tbGear1to2.Text);
  379. cfm.MagRange2 = Convert.ToSingle(tbGear2to3.Text);
  380. cfm.MagRange3 = Convert.ToSingle(tbGear3to4.Text);
  381. cfm.MagCompX1 = Convert.ToSingle(tbGear1to2_Xdeviation.Text);
  382. cfm.MagCompX2 = Convert.ToSingle(tbGear2to3_Xdeviation.Text);
  383. cfm.MagCompX3 = Convert.ToSingle(tbGear3to4_Xdeviation.Text);
  384. cfm.MagCompY1 = Convert.ToSingle(tbGear1to2_Ydeviation.Text);
  385. cfm.MagCompY2 = Convert.ToSingle(tbGear2to3_Ydeviation.Text);
  386. cfm.MagCompY3 = Convert.ToSingle(tbGear3to4_Ydeviation.Text);
  387. cfm.ScanRotCor = Convert.ToSingle(txtScanRotCur.Text);
  388. cfm.PixelSizeCor = Convert.ToSingle(txtYPSCur.Text);
  389. if (cbbWXZ.SelectedIndex == 0)//校正角度
  390. {
  391. cfm.Correction_Angle = 36;
  392. }
  393. else
  394. {
  395. cfm.Correction_Angle = 54;
  396. }
  397. cfm.SampleName = cbbWYP.Text;//样品类型
  398. cfm.Firm = cbbWCS.Text;//厂商类型
  399. return cfm;
  400. }
  401. public void SaveTemplateFile()
  402. {
  403. //获取当前文件的参数
  404. MeasureParam cfm = FormHOZMainObject.m_MeasureFile.MParam;
  405. //根据界面显示内容更新参数
  406. cfm.Is_Photograph = chkWIsP.Checked;
  407. cfm.PT = chkWPT.Checked;
  408. cfm.Title = chkWqxkc.Checked;//是否倾斜样品台
  409. cfm.EDS = chkEDS.Checked;
  410. //自动对焦模式
  411. //cfm.FocusMode = chkManul.Checked;
  412. cfm.PTTemp = txtWPTF.Text;
  413. cfm.FIBTemp = txtWFIBF.Text;
  414. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
  415. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
  416. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
  417. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
  418. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
  419. //cfm.FIB_Magnification = Convert.ToSingle(cbbWFIB.Text);
  420. if (cbbWXZ.SelectedIndex == 0)
  421. {
  422. cfm.Correction_Angle = 36;
  423. }
  424. else
  425. {
  426. cfm.Correction_Angle = 54;
  427. }
  428. cfm.SampleName = cbbWYP.Text;
  429. cfm.Firm = cbbWCS.Text;
  430. //保存配置文件中的参数
  431. cfm.ZDistance = Convert.ToSingle(ConfigurationManager.AppSettings["ZDistance"].ToString());
  432. cfm.AutoFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_UP"].ToString());
  433. cfm.AutoFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Down"].ToString());
  434. cfm.AutoFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Step"].ToString());
  435. cfm.AutoFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Range"].ToString());
  436. cfm.AutoFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_FStep"].ToString());
  437. cfm.FIBFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_UP"].ToString());
  438. cfm.FIBFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Down"].ToString());
  439. cfm.FIBFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Step"].ToString());
  440. cfm.FIBFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Range"].ToString());
  441. cfm.FIBFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_FStep"].ToString());
  442. cfm.AutoStigX.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_UP"].ToString());
  443. cfm.AutoStigX.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Down"].ToString());
  444. cfm.AutoStigX.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Step"].ToString());
  445. cfm.AutoStigX.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Range"].ToString());
  446. cfm.AutoStigX.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_FStep"].ToString());
  447. cfm.AutoStigY.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_UP"].ToString());
  448. cfm.AutoStigY.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Down"].ToString());
  449. cfm.AutoStigY.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Step"].ToString());
  450. cfm.AutoStigY.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Range"].ToString());
  451. cfm.AutoStigY.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_FStep"].ToString());
  452. ConfigFile cf = new ConfigFile(cfm);
  453. m_TemplateFilePath = ConfigurationManager.AppSettings["TemplateFilePath"].ToString();
  454. //如果路径不存在,要求选择一个路径
  455. if (!Directory.Exists(m_TemplateFilePath))
  456. {
  457. //创建路径
  458. //Directory.CreateDirectory(m_TemplateFilePath);
  459. FolderBrowserDialog dialog = new FolderBrowserDialog();
  460. dialog.Description = "请选择文件路径";
  461. //dialog.RootFolder = Environment.SpecialFolder.Programs;
  462. if (dialog.ShowDialog() == DialogResult.OK)
  463. {
  464. m_TemplateFilePath = dialog.SelectedPath;
  465. config.AppSettings.Settings["TemplateFilePath"].Value = m_TemplateFilePath;
  466. config.Save(ConfigurationSaveMode.Modified);
  467. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  468. }
  469. }
  470. SaveFileDialog saveFileDialog = new SaveFileDialog();
  471. //设置默认打开路径(绝对路径)
  472. saveFileDialog.InitialDirectory = m_TemplateFilePath;
  473. saveFileDialog.Filter = "样品参数文件|*.cfg";
  474. if (saveFileDialog.ShowDialog() == DialogResult.OK)
  475. {
  476. cf.Save(saveFileDialog.FileName);
  477. }
  478. else
  479. {
  480. return;
  481. }
  482. //编辑Config文件
  483. EditConfig();
  484. }
  485. /// <summary>
  486. /// 编辑confing 文件信息
  487. /// </summary>
  488. public bool EditConfig()
  489. {
  490. try
  491. {
  492. //设置数据源信息
  493. //样品类型
  494. List<String> _sT = sT.ToList();
  495. if ((_sT.IndexOf(cbbWYP.Text) < 0)
  496. || (!_sT.Contains(cbbWYP.Text)))
  497. {
  498. _sT.Add(cbbWYP.Text);
  499. string wsT = string.Join(",", _sT.ToArray());
  500. config.AppSettings.Settings["Sample_Type"].Value = wsT;
  501. }
  502. //厂商
  503. List<String> _firms = firms.ToList();
  504. if ((_firms.IndexOf(cbbWCS.Text) < 0)
  505. || (!_firms.Contains(cbbWCS.Text)))
  506. {
  507. _firms.Add(cbbWCS.Text);
  508. string wFirms = string.Join(",", _firms.ToArray());
  509. config.AppSettings.Settings["Firm"].Value = wFirms;
  510. }
  511. //拍照电压
  512. List<String> _WPZD = WPZD.ToList();
  513. if ((_WPZD.IndexOf(cbbWPZD.Text) < 0)
  514. || (!_WPZD.Contains(cbbWPZD.Text)))
  515. {
  516. _WPZD.Add(cbbWPZD.Text);
  517. string wWPZD = string.Join(",", _WPZD.ToArray());
  518. config.AppSettings.Settings["WPZD"].Value = wWPZD;
  519. }
  520. //拍照放大位数
  521. List<String> _WPZF = WPZF.ToList();
  522. if ((_WPZF.IndexOf(cbbWPZF.Text) < 0)
  523. || (!_WPZF.Contains(cbbWPZF.Text)))
  524. {
  525. _WPZF.Add(cbbWPZF.Text);
  526. string wWPZF = string.Join(",", _WPZF.ToArray());
  527. config.AppSettings.Settings["WPZF"].Value = wWPZF;
  528. }
  529. //定位切割电压
  530. List<String> _WQGD = WQGD.ToList();
  531. if ((_WQGD.IndexOf(cbbWQGD.Text) < 0)
  532. || (!_WQGD.Contains(cbbWQGD.Text)))
  533. {
  534. _WQGD.Add(cbbWQGD.Text);
  535. string wWQGD = string.Join(",", _WQGD.ToArray());
  536. config.AppSettings.Settings["WQGD"].Value = wWQGD;
  537. }
  538. //定位切割放大位数
  539. List<String> _WQGF = WQGF.ToList();
  540. if ((_WQGF.IndexOf(cbbWQGF.Text) < 0)
  541. || (!_WQGF.Contains(cbbWQGF.Text)))
  542. {
  543. _WQGF.Add(cbbWQGF.Text);
  544. string wWQGF = string.Join(",", _WQGF.ToArray());
  545. config.AppSettings.Settings["WQGF"].Value = wWQGF;
  546. }
  547. //拉直操作放大位数
  548. List<String> _WLZ = WLZ.ToList();
  549. if ((_WLZ.IndexOf(cbbWLZ.Text) < 0)
  550. || (!_WLZ.Contains(cbbWLZ.Text)))
  551. {
  552. _WLZ.Add(cbbWLZ.Text);
  553. string wWLZ = string.Join(",", _WLZ.ToArray());
  554. config.AppSettings.Settings["WLZ"].Value = wWLZ;
  555. }
  556. //ScanRotate修正
  557. config.AppSettings.Settings["ScanRotCur"].Value = txtScanRotCur.Text;
  558. config.AppSettings.Settings["PixelSize_Y_Cur"].Value = txtYPSCur.Text;
  559. //FIB放大位数
  560. //List<String> _WFIB = WFIB.ToList();
  561. //if ((_WFIB.IndexOf(cbbWFIB.Text) < 0)
  562. // ||(!_WFIB.Contains(cbbWFIB.Text)))
  563. //{
  564. // _WFIB.Add(cbbWFIB.Text);
  565. // string wWFIB = string.Join(",", _WFIB.ToArray());
  566. // config.AppSettings.Settings["WFIB"].Value = wWFIB;
  567. //}
  568. MeasureParam cfm = new MeasureParam();
  569. cfm = FormHOZMainObject.m_MeasureFile.MParam;
  570. cfm.Is_Photograph = chkWIsP.Checked;
  571. cfm.FocusMode = Convert.ToInt32(config.AppSettings.Settings["Focus_Mode"].Value);
  572. cfm.PT = chkWPT.Checked;
  573. //EDS
  574. cfm.EDS = chkEDS.Checked;
  575. config.AppSettings.Settings["Is_EDS"].Value = chkEDS.Checked.ToString();
  576. cfm.EDSZ = Convert.ToSingle(txtEDSZ.Text)/1000;
  577. config.AppSettings.Settings["EDS_Z"].Value = txtEDSZ.Text;
  578. cfm.EDSV = Convert.ToSingle(cbbEDSV.Text);
  579. config.AppSettings.Settings["EDS_V"].Value = cbbEDSV.Text;
  580. cfm.EDSA = Convert.ToSingle(cbbEDSA.Text) / 1000000000;
  581. config.AppSettings.Settings["EDS_A"].Value = cbbEDSA.Text;
  582. //自动对焦模式
  583. //cfm.FocusMode = chkManul.Checked;
  584. cfm.PTTemp = txtWPTF.Text;
  585. cfm.FIBTemp = txtWFIBF.Text;
  586. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
  587. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
  588. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
  589. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
  590. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
  591. //cfm.FIB_Magnification = Convert.ToSingle(cbbWFIB.Text);
  592. //亮度对比度
  593. cfm.FIBDo = chkFIBAdjust.Checked;
  594. cfm.FIBAutoBC = chkFIBAtuoAdjust.Checked;
  595. cfm.FIBB = Convert.ToSingle(tbBrightness.Text);
  596. cfm.FIBC = Convert.ToSingle(tbContrast.Text);
  597. //放大倍数挡位
  598. cfm.MagComp = Convert.ToBoolean(chkGearSwitch.Checked);
  599. cfm.MagRange1 = Convert.ToSingle(tbGear1to2.Text);
  600. cfm.MagRange2 = Convert.ToSingle(tbGear2to3.Text);
  601. cfm.MagRange3 = Convert.ToSingle(tbGear3to4.Text);
  602. cfm.MagCompX1 = Convert.ToSingle(tbGear1to2_Xdeviation.Text);
  603. cfm.MagCompX2 = Convert.ToSingle(tbGear2to3_Xdeviation.Text);
  604. cfm.MagCompX3 = Convert.ToSingle(tbGear3to4_Xdeviation.Text);
  605. cfm.MagCompY1 = Convert.ToSingle(tbGear1to2_Ydeviation.Text);
  606. cfm.MagCompY2 = Convert.ToSingle(tbGear2to3_Ydeviation.Text);
  607. cfm.MagCompY3 = Convert.ToSingle(tbGear3to4_Ydeviation.Text);
  608. //倾斜观测
  609. cfm.Title = chkWqxkc.Checked;
  610. //移动Z轴大小
  611. cfm.PixelSizeCor = Convert.ToSingle(txtYPSCur.Text);
  612. if (cbbWXZ.SelectedIndex == 0)
  613. {
  614. cfm.Correction_Angle = 36;
  615. }
  616. else
  617. {
  618. cfm.Correction_Angle = 54;
  619. }
  620. cfm.SampleName = cbbWYP.Text;
  621. cfm.Firm = cbbWCS.Text;
  622. //设置配置文件默认值
  623. config.AppSettings.Settings["Is_FIBDo"].Value = cfm.FIBDo.ToString();
  624. config.AppSettings.Settings["Is_FIBAutoBc"].Value = cfm.FIBAutoBC.ToString();
  625. config.AppSettings.Settings["FIBB"].Value = cfm.FIBB.ToString();
  626. config.AppSettings.Settings["FIBC"].Value = cfm.FIBC.ToString();
  627. config.AppSettings.Settings["MagComp"].Value = cfm.MagComp.ToString();
  628. config.AppSettings.Settings["MagRange1"].Value = cfm.MagRange1.ToString();
  629. config.AppSettings.Settings["MagRange2"].Value = cfm.MagRange2.ToString();
  630. config.AppSettings.Settings["MagRange3"].Value = cfm.MagRange3.ToString();
  631. config.AppSettings.Settings["MagCompX1"].Value = cfm.MagCompX1.ToString();
  632. config.AppSettings.Settings["MagCompX2"].Value = cfm.MagCompX2.ToString();
  633. config.AppSettings.Settings["MagCompX3"].Value = cfm.MagCompX3.ToString();
  634. config.AppSettings.Settings["MagCompY1"].Value = cfm.MagCompY1.ToString();
  635. config.AppSettings.Settings["MagCompY2"].Value = cfm.MagCompY2.ToString();
  636. config.AppSettings.Settings["MagCompY3"].Value = cfm.MagCompY3.ToString();
  637. config.AppSettings.Settings["Is_Photograph"].Value = cfm.Is_Photograph.ToString();
  638. config.AppSettings.Settings["PT_Depostion"].Value = cfm.PT.ToString();
  639. config.AppSettings.Settings["PT_ELYFile"].Value = cfm.PTTemp;
  640. config.AppSettings.Settings["FIB_ELYFile"].Value = cfm.FIBTemp;
  641. config.AppSettings.Settings["Stretch_Magnification"].Value = cfm.Stretch_Magnification.ToString();
  642. config.AppSettings.Settings["Location_Magnification"].Value = cfm.Location_Magnification.ToString();
  643. config.AppSettings.Settings["Location_Voltage"].Value = cfm.Location_Voltage.ToString();
  644. config.AppSettings.Settings["Photograph_Magnification"].Value = cfm.Photograph_Magnification.ToString();
  645. config.AppSettings.Settings["Photograph_Voltage"].Value = cfm.Photograph_Voltage.ToString();
  646. config.AppSettings.Settings["Correction_Angle"].Value = cfm.Correction_Angle.ToString();
  647. config.AppSettings.Settings["SampleName"].Value = cfm.SampleName;
  648. config.AppSettings.Settings["Firms"].Value = cfm.Firm;
  649. config.AppSettings.Settings["FIB_Magnification"].Value = cfm.FIB_Magnification.ToString();
  650. config.AppSettings.Settings["Is_Title"].Value = cfm.Title.ToString();
  651. config.AppSettings.Settings["ZDistance"].Value = cfm.ZDistance.ToString();
  652. config.Save(ConfigurationSaveMode.Modified);
  653. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  654. return true;
  655. }
  656. catch (Exception ex)
  657. {
  658. LogManager.LogError(ex.Message);
  659. return false;
  660. }
  661. }
  662. /// <summary>
  663. /// 删除config文件节点中内容信息
  664. /// </summary>
  665. public bool DelConfigNodeContentInfo(string delControlName, string selName)
  666. {
  667. try
  668. {
  669. switch (delControlName)
  670. {
  671. case "WYP":
  672. //样品类型
  673. List<String> _sT = sT.ToList();
  674. _sT.Remove(selName);
  675. string wsT = string.Join(",", _sT.ToArray());
  676. config.AppSettings.Settings["Sample_Type"].Value = wsT;
  677. break;
  678. case "WCS":
  679. //厂商
  680. List<String> _firms = firms.ToList();
  681. _firms.Remove(selName);
  682. string wFirms = string.Join(",", _firms.ToArray());
  683. config.AppSettings.Settings["Firm"].Value = wFirms;
  684. break;
  685. case "WPZD":
  686. //拍照电压
  687. List<String> _WPZD = WPZD.ToList();
  688. _WPZD.Remove(selName);
  689. string wWPZD = string.Join(",", _WPZD.ToArray());
  690. config.AppSettings.Settings["WPZD"].Value = wWPZD;
  691. break;
  692. case "WPZF":
  693. //拍照放大位数
  694. List<String> _WPZF = WPZF.ToList();
  695. _WPZF.Remove(selName);
  696. string wWPZF = string.Join(",", _WPZF.ToArray());
  697. config.AppSettings.Settings["WPZF"].Value = wWPZF;
  698. break;
  699. case "WQGD"://定位切割电压
  700. List<String> _WQGD = WQGD.ToList();
  701. _WQGD.Remove(selName);
  702. string wWQGD = string.Join(",", _WQGD.ToArray());
  703. config.AppSettings.Settings["WQGD"].Value = wWQGD;
  704. break;
  705. case "WQGF": //定位切割放大位数
  706. List<String> _WQGF = WQGF.ToList();
  707. _WQGF.Remove(selName);
  708. string wWQGF = string.Join(",", _WQGF.ToArray());
  709. config.AppSettings.Settings["WQGF"].Value = wWQGF;
  710. break;
  711. case "WLZ":
  712. //拉直操作放大位数
  713. List<String> _WLZ = WLZ.ToList();
  714. _WLZ.Remove(selName);
  715. string wWLZ = string.Join(",", _WLZ.ToArray());
  716. config.AppSettings.Settings["WLZ"].Value = wWLZ;
  717. break;
  718. case "WFIB":
  719. //FIB放大倍数
  720. List<String> _WFIB = WFIB.ToList();
  721. _WFIB.Remove(selName);
  722. string wWFIB = string.Join(",", _WFIB.ToArray());
  723. config.AppSettings.Settings["WFIB"].Value = wWFIB;
  724. break;
  725. }
  726. config.Save(ConfigurationSaveMode.Modified);
  727. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  728. return true;
  729. }
  730. catch (Exception ex)
  731. {
  732. LogManager.LogError(ex.Message);
  733. return true;
  734. }
  735. }
  736. /// <summary>
  737. /// 绑定下拉菜单
  738. /// </summary>
  739. /// <param name="cb"></param>
  740. /// <param name="strGroup"></param>
  741. private void BindComboxData(ComboBox cb, string[] strGroup)
  742. {
  743. for (int i = 0; i < strGroup.Length; i++)
  744. {
  745. if (!strGroup[i].Equals(""))
  746. {
  747. cb.Items.Add(strGroup[i]);
  748. }
  749. }
  750. }
  751. /// <summary>
  752. /// 读取Config文件信息
  753. /// </summary>
  754. public void ReloadConfig()
  755. {
  756. cbbWYP.Items.Clear();
  757. cbbWCS.Items.Clear();
  758. cbbWPZD.Items.Clear();
  759. cbbWPZF.Items.Clear();
  760. cbbWQGD.Items.Clear();
  761. cbbWQGF.Items.Clear();
  762. cbbWLZ.Items.Clear();
  763. //cbbWFIB.Items.Clear();
  764. txtYPSCur.Text = config.AppSettings.Settings["PixelSize_Y_Cur"].Value.ToString();
  765. m_TemplateFilePath = config.AppSettings.Settings["TemplateFilePath"].Value.ToString();
  766. string sample_Type = config.AppSettings.Settings["Sample_Type"].Value.ToString();
  767. string firm = config.AppSettings.Settings["Firm"].Value.ToString();
  768. string WPZDTemp = config.AppSettings.Settings["WPZD"].Value.ToString();
  769. string WPZFTemp = config.AppSettings.Settings["WPZF"].Value.ToString();
  770. string WQGDTemp = config.AppSettings.Settings["WQGD"].Value.ToString();
  771. string WQGFTemp = config.AppSettings.Settings["WQGF"].Value.ToString();
  772. string WLZTemp = config.AppSettings.Settings["WLZ"].Value.ToString();
  773. string WFIBTemp = config.AppSettings.Settings["WFIB"].Value.ToString();
  774. //string ZZDistance = config.AppSettings.Settings["ZDistance"].Value.ToString();
  775. string ScanRotCur = config.AppSettings.Settings["ScanRotCur"].Value.ToString();
  776. //样品类型
  777. sT = sample_Type.Split(',');
  778. BindComboxData(cbbWYP, sT);
  779. //厂商
  780. firms = firm.Split(',');
  781. BindComboxData(cbbWCS, firms);
  782. //拍照电压
  783. WPZD = WPZDTemp.Split(',');
  784. BindComboxData(cbbWPZD, WPZD);
  785. //拍照放大位数
  786. WPZF = WPZFTemp.Split(',');
  787. BindComboxData(cbbWPZF, WPZF);
  788. //定位切割电压
  789. WQGD = WQGDTemp.Split(',');
  790. BindComboxData(cbbWQGD, WQGD);
  791. //定位切割放大位数
  792. WQGF = WQGFTemp.Split(',');
  793. BindComboxData(cbbWQGF, WQGF);
  794. //拉直操作放大位数
  795. WLZ = WLZTemp.Split(',');
  796. BindComboxData(cbbWLZ, WLZ);
  797. //FIB放大倍数
  798. //WFIB = WFIBTemp.Split(',');
  799. //BindComboxData(cbbWFIB, WFIB);
  800. txtScanRotCur.Text = ScanRotCur;
  801. //FIB亮度对比度调节
  802. chkFIBAdjust.Checked = Convert.ToBoolean(config.AppSettings.Settings["Is_FIBDo"].Value);
  803. //FIB亮度对比度自动调节
  804. chkFIBAtuoAdjust.Checked = Convert.ToBoolean(config.AppSettings.Settings["Is_FIBAutoBc"].Value);
  805. tbBrightness.Text = config.AppSettings.Settings["FIBB"].Value;
  806. tbContrast.Text = config.AppSettings.Settings["FIBC"].Value;
  807. //放大倍数挡位切换
  808. chkGearSwitch.Checked = Convert.ToBoolean(config.AppSettings.Settings["MagComp"].Value);
  809. tbGear1to2.Text = config.AppSettings.Settings["MagRange1"].Value;
  810. tbGear2to3.Text = config.AppSettings.Settings["MagRange2"].Value;
  811. tbGear3to4.Text = config.AppSettings.Settings["MagRange3"].Value;
  812. tbGear1to2_Xdeviation.Text= config.AppSettings.Settings["MagCompX1"].Value;
  813. tbGear2to3_Xdeviation.Text= config.AppSettings.Settings["MagCompX2"].Value;
  814. tbGear3to4_Xdeviation.Text= config.AppSettings.Settings["MagCompX3"].Value;
  815. tbGear1to2_Ydeviation.Text= config.AppSettings.Settings["MagCompY1"].Value;
  816. tbGear2to3_Ydeviation.Text= config.AppSettings.Settings["MagCompY2"].Value;
  817. tbGear3to4_Ydeviation.Text= config.AppSettings.Settings["MagCompY3"].Value;
  818. //设置配置文件默认值
  819. chkWIsP.Checked=Convert.ToBoolean(config.AppSettings.Settings["Is_Photograph"].Value);
  820. chkWPT.Checked = Convert.ToBoolean(config.AppSettings.Settings["PT_Depostion"].Value);
  821. //倾斜观测
  822. chkWqxkc.Checked = Convert.ToBoolean(config.AppSettings.Settings["Is_Title"].Value);
  823. //移动Z轴大小
  824. txtYPSCur.Text = config.AppSettings.Settings["PixelSize_Y_Cur"].Value;
  825. //自动对焦模式
  826. //chkManul.Checked = Convert.ToBoolean(config.AppSettings.Settings["Focus_Mode"].Value);
  827. txtWPTF.Text = config.AppSettings.Settings["PT_ELYFile"].Value;
  828. txtWFIBF.Text = config.AppSettings.Settings["FIB_ELYFile"].Value;
  829. cbbWLZ.Text = config.AppSettings.Settings["Stretch_Magnification"].Value;
  830. cbbWQGF.Text = config.AppSettings.Settings["Location_Magnification"].Value;
  831. cbbWQGD.Text = config.AppSettings.Settings["Location_Voltage"].Value;
  832. cbbWPZF.Text = config.AppSettings.Settings["Photograph_Magnification"].Value;
  833. cbbWPZD.Text = config.AppSettings.Settings["Photograph_Voltage"].Value;
  834. //cbbWFIB.Text = config.AppSettings.Settings["FIB_Magnification"].Value;
  835. string Correction_Angle = config.AppSettings.Settings["Correction_Angle"].Value;
  836. //if (Convert.ToBoolean(config.AppSettings.Settings["Is_Title"].Value))
  837. //{
  838. // cbbYDZZDX.Visible = true;
  839. // label3.Visible = true;
  840. //}
  841. //else
  842. //{
  843. // cbbYDZZDX.Visible = false;
  844. // label3.Visible = false;
  845. //}
  846. if (Correction_Angle == "36")
  847. {
  848. cbbWXZ.SelectedIndex = 0;
  849. }
  850. else
  851. {
  852. cbbWXZ.SelectedIndex = 1;
  853. }
  854. cbbWYP.Text = config.AppSettings.Settings["SampleName"].Value;
  855. cbbWCS.Text = config.AppSettings.Settings["Firms"].Value;
  856. //能谱和能谱Z轴移动位置
  857. chkEDS.Checked = Convert.ToBoolean(config.AppSettings.Settings["Is_EDS"].Value);
  858. txtEDSZ.Text = Convert.ToString(config.AppSettings.Settings["EDS_Z"].Value);
  859. cbbEDSV.Text = Convert.ToString(config.AppSettings.Settings["EDS_V"].Value);
  860. cbbEDSA.Text = Convert.ToString(config.AppSettings.Settings["EDS_A"].Value);
  861. }
  862. /// <summary>
  863. /// 根据所选路径,读取模板文件
  864. /// </summary>
  865. public void ReadConfigInfo()
  866. {
  867. if (!ReadConfigPath.Equals(""))
  868. {
  869. ReloadConfig();
  870. ConfigFile cfm = new ConfigFile(FormHOZMainObject.m_MeasureFile.MParam);
  871. cfm.Read(ReadConfigPath);
  872. chkWIsP.Checked = cfm.m_Config.Is_Photograph;
  873. chkWPT.Checked = cfm.m_Config.PT;
  874. //自动对焦模式
  875. //cfm.FocusMode = chkManul.Checked;
  876. txtWPTF.Text = cfm.m_Config.PTTemp;
  877. txtWFIBF.Text = cfm.m_Config.FIBTemp;
  878. cbbWLZ.Text = cfm.m_Config.Stretch_Magnification.ToString();
  879. cbbWQGF.Text = cfm.m_Config.Location_Magnification.ToString();
  880. cbbWQGD.Text = cfm.m_Config.Location_Voltage.ToString();
  881. cbbWPZF.Text = cfm.m_Config.Photograph_Magnification.ToString();
  882. cbbWPZD.Text = cfm.m_Config.Photograph_Voltage.ToString();
  883. //cbbWFIB.Text = cfm.m_Config.FIB_Magnification.ToString();
  884. string Correction_Angle = cfm.m_Config.Correction_Angle.ToString();
  885. if (Correction_Angle == "36")
  886. {
  887. cbbWXZ.SelectedIndex = 0;
  888. }
  889. else
  890. {
  891. cbbWXZ.SelectedIndex = 1;
  892. }
  893. cbbWYP.Text = cfm.m_Config.SampleName;
  894. cbbWCS.Text = cfm.m_Config.Firm;
  895. }
  896. }
  897. /// <summary>
  898. /// 修改配置文件默认值
  899. /// </summary>
  900. /// <param name="sender"></param>
  901. /// <param name="e"></param>
  902. private void btnSaveDefalutPara_Click(object sender, EventArgs e)
  903. {
  904. if (EditConfig())
  905. {
  906. MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  907. }
  908. //增加一个测量文件的参数修改
  909. SaveMeasureFile();
  910. }
  911. #endregion
  912. #region 删除下拉菜单选择项
  913. private void DelComboBoxItem_Click(object sender, EventArgs e)
  914. {
  915. if (MessageBox.Show("是否删除所选项信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  916. {
  917. PictureBox pbDel = (PictureBox)sender;
  918. string ctrlName = pbDel.Name.Substring(5, pbDel.Name.Length - 5);
  919. if (DelComboBoxItem(ctrlName))
  920. {
  921. //重新加载
  922. ReloadConfig();
  923. }
  924. }
  925. }
  926. /// <summary>
  927. /// 删除下拉菜单选择项
  928. /// </summary>
  929. public bool DelComboBoxItem(string controlName)
  930. {
  931. string delName = controlName;
  932. foreach (Control item in this.Controls)
  933. {
  934. if (item is ComboBox)
  935. {
  936. if (item.Name.Contains(delName))
  937. {
  938. ComboBox cb = (ComboBox)item;
  939. return DelConfigNodeContentInfo(delName, cb.Text);
  940. }
  941. }
  942. }
  943. return false;
  944. }
  945. #endregion
  946. #region 根据是否仅拍照,进行逻辑判断
  947. private void chkWIsP_CheckedChanged(object sender, EventArgs e)
  948. {
  949. if (chkWIsP.Checked)
  950. {
  951. chkWqxkc.Checked = false;
  952. chkWqxkc.Visible = false;
  953. chkWPT.Checked = false;
  954. chkWPT.Visible = false;
  955. label61.Visible = false;
  956. label59.Visible = false;
  957. txtWFIBF.Visible = false;
  958. txtWPTF.Visible = false;
  959. btnPTTemplateFile.Visible = false;
  960. btnFIBTemplateFile.Visible = false;
  961. label58.Visible = false;
  962. cbbWXZ.Visible = false;
  963. chkEDS.Visible = false;
  964. label18.Visible = false;
  965. label19.Visible = false;
  966. txtEDSZ.Visible = false;
  967. //cbbWFIB.Visible = false;
  968. //pbDelWFIB.Visible = false;
  969. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.Photo;
  970. }
  971. else
  972. {
  973. chkWqxkc.Visible = true;
  974. chkWPT.Visible = true;
  975. label61.Visible = true;
  976. label59.Visible = true;
  977. txtWFIBF.Visible = true;
  978. txtWPTF.Visible = true;
  979. btnPTTemplateFile.Visible = true;
  980. btnFIBTemplateFile.Visible = true;
  981. label58.Visible = true;
  982. cbbWXZ.Visible = true;
  983. chkEDS.Visible = true;
  984. //label2.Visible = true;
  985. //cbbWFIB.Visible = true;
  986. //pbDelWFIB.Visible = true;
  987. label18.Visible = true;
  988. label19.Visible = true;
  989. txtEDSZ.Visible = true;
  990. if (!chkWPT.Checked)
  991. {
  992. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
  993. }
  994. }
  995. CreateCutHoleList();
  996. }
  997. #endregion
  998. #region 从配置文件中读取测量参数
  999. public MeasureParam GetMeasureParam()
  1000. {
  1001. MeasureParam cfm = new MeasureParam();
  1002. //设置配置文件默认值
  1003. bool bResult = false;
  1004. bool.TryParse(config.AppSettings.Settings["Is_Photograph"].Value, out bResult);
  1005. cfm.Is_Photograph = bResult;
  1006. bool.TryParse(config.AppSettings.Settings["PT_Depostion"].Value, out bResult);
  1007. cfm.PT = bResult;
  1008. cfm.PTTemp = config.AppSettings.Settings["PT_ELYFile"].Value;
  1009. cfm.FIBTemp = config.AppSettings.Settings["FIB_ELYFile"].Value;
  1010. float fResult = (float)0.0;
  1011. float.TryParse(config.AppSettings.Settings["Stretch_Magnification"].Value, out fResult);
  1012. cfm.Stretch_Magnification = fResult;
  1013. float.TryParse(config.AppSettings.Settings["Location_Magnification"].Value, out fResult);
  1014. cfm.Location_Magnification = fResult;
  1015. float.TryParse(config.AppSettings.Settings["Location_Voltage"].Value, out fResult);
  1016. cfm.Location_Voltage = fResult;
  1017. float.TryParse(config.AppSettings.Settings["Photograph_Magnification"].Value, out fResult);
  1018. cfm.Photograph_Magnification = fResult;
  1019. float.TryParse(config.AppSettings.Settings["Photograph_Voltage"].Value, out fResult);
  1020. cfm.Photograph_Voltage = fResult;
  1021. float.TryParse(config.AppSettings.Settings["Correction_Angle"].Value, out fResult);
  1022. cfm.Correction_Angle = fResult;
  1023. cfm.SampleName = config.AppSettings.Settings["SampleName"].Value;
  1024. cfm.Firm = config.AppSettings.Settings["Firms"].Value;
  1025. cfm.AutoFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_UP"].ToString());
  1026. cfm.AutoFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Down"].ToString());
  1027. cfm.AutoFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Step"].ToString());
  1028. cfm.AutoFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Range"].ToString());
  1029. cfm.AutoFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_FStep"].ToString());
  1030. cfm.FIBFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_UP"].ToString());
  1031. cfm.FIBFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Down"].ToString());
  1032. cfm.FIBFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Step"].ToString());
  1033. cfm.FIBFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Range"].ToString());
  1034. cfm.FIBFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_FStep"].ToString());
  1035. cfm.AutoStigX.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_UP"].ToString());
  1036. cfm.AutoStigX.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Down"].ToString());
  1037. cfm.AutoStigX.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Step"].ToString());
  1038. cfm.AutoStigX.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Range"].ToString());
  1039. cfm.AutoStigX.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_FStep"].ToString());
  1040. cfm.AutoStigY.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_UP"].ToString());
  1041. cfm.AutoStigY.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Down"].ToString());
  1042. cfm.AutoStigY.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Step"].ToString());
  1043. cfm.AutoStigY.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Range"].ToString());
  1044. cfm.AutoStigY.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_FStep"].ToString());
  1045. bool.TryParse(config.AppSettings.Settings["Is_Title"].Value, out bResult);
  1046. cfm.Title = bResult;
  1047. bool.TryParse(config.AppSettings.Settings["Is_EDS"].Value, out bResult);
  1048. cfm.EDS = bResult;
  1049. float.TryParse(config.AppSettings.Settings["ZDistance"].Value, out fResult);
  1050. cfm.ZDistance = fResult;
  1051. //add by sun 2020-12-15 增加不同样品扫描速度参数,每大类样品3种扫描速度
  1052. //cfm.ScanSpeedNormal = ConfigurationManager.AppSettings["ScanSpeedNormal_"+cfm.SampleName].ToString();
  1053. //cfm.ScanSpeedFocus = ConfigurationManager.AppSettings["ScanSpeedFocus_" + cfm.SampleName].ToString();
  1054. //cfm.ScanSpeedHigh = ConfigurationManager.AppSettings["ScanSpeedHigh_" + cfm.SampleName].ToString();
  1055. LogManager.AddHardwareLog("==========参数测试==" + cfm.SampleName+"======="+ config.AppSettings.Settings["ScanSpeedNormal_0"].Value, true);
  1056. //add by sun 2020-12-15 增加不同样品扫描速度参数,每大类样品3种扫描速度 end
  1057. return cfm;
  1058. }
  1059. #endregion
  1060. #region 创建切孔列表
  1061. private void CreateCutHoleList()
  1062. {
  1063. List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  1064. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  1065. }
  1066. #endregion
  1067. #region 设置流程类型
  1068. private void chkWPT_CheckedChanged(object sender, EventArgs e)
  1069. {
  1070. if (chkWPT.Checked)
  1071. {
  1072. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.PT;
  1073. }
  1074. else
  1075. {
  1076. if (!chkWIsP.Checked)
  1077. {
  1078. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
  1079. }
  1080. }
  1081. CreateCutHoleList();
  1082. }
  1083. #endregion
  1084. #region 关闭按钮 鼠标操作事件
  1085. private void pbClose_MouseEnter(object sender, EventArgs e)
  1086. {
  1087. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_2_;
  1088. }
  1089. private void pbClose_MouseLeave(object sender, EventArgs e)
  1090. {
  1091. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_2_;
  1092. }
  1093. #endregion
  1094. #region 输入限制只能是数字
  1095. private void textBox_KeyPress(string text, object sender, KeyPressEventArgs e)
  1096. {
  1097. //判断按键是不是要输入的类型。
  1098. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
  1099. e.Handled = true;
  1100. //小数点的处理。
  1101. if ((int)e.KeyChar == 46) //小数点
  1102. {
  1103. if (text.Length <= 0)
  1104. e.Handled = true; //小数点不能在第一位
  1105. else
  1106. {
  1107. float f;
  1108. float oldf;
  1109. bool b1 = false, b2 = false;
  1110. b1 = float.TryParse(text, out oldf);
  1111. b2 = float.TryParse(text + e.KeyChar.ToString(), out f);
  1112. if (b2 == false)
  1113. {
  1114. if (b1 == true)
  1115. e.Handled = true;
  1116. else
  1117. e.Handled = false;
  1118. }
  1119. }
  1120. }
  1121. }
  1122. private void ComboBox_KeyPress(string text, object sender, KeyPressEventArgs e)
  1123. {
  1124. //允许输入数字、小数点、删除键和负号
  1125. if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != (char)('-'))
  1126. {
  1127. MessageBox.Show("请输入正确的数字");
  1128. text = "";
  1129. e.Handled = true;
  1130. }
  1131. if (e.KeyChar == (char)('-'))
  1132. {
  1133. if (text != "")
  1134. {
  1135. MessageBox.Show("请输入正确的数字");
  1136. text = "";
  1137. e.Handled = true;
  1138. }
  1139. }
  1140. //小数点只能输入一次
  1141. if (e.KeyChar == (char)('.') && ((ComboBox)sender).Text.IndexOf('.') != -1)
  1142. {
  1143. MessageBox.Show("请输入正确的数字");
  1144. text = "";
  1145. e.Handled = true;
  1146. }
  1147. //第一位不能为小数点
  1148. if (e.KeyChar == (char)('.') && ((ComboBox)sender).Text == "")
  1149. {
  1150. MessageBox.Show("请输入正确的数字");
  1151. text = "";
  1152. e.Handled = true;
  1153. }
  1154. //第一位是0,第二位必须为小数点
  1155. if (e.KeyChar != (char)('.') && ((ComboBox)sender).Text == "0")
  1156. {
  1157. MessageBox.Show("请输入正确的数字");
  1158. text = "";
  1159. e.Handled = true;
  1160. }
  1161. //第一位是负号,第二位不能为小数点
  1162. if (((ComboBox)sender).Text == "-" && e.KeyChar == (char)('.'))
  1163. {
  1164. MessageBox.Show("请输入正确的数字");
  1165. text = "";
  1166. e.Handled = true;
  1167. }
  1168. }
  1169. private void cbbWPZD_KeyPress(object sender, KeyPressEventArgs e)
  1170. {
  1171. ComboBox_KeyPress(cbbWPZD.Text, sender, e);
  1172. }
  1173. private void cbbWPZF_KeyPress(object sender, KeyPressEventArgs e)
  1174. {
  1175. ComboBox_KeyPress(cbbWPZF.Text, sender, e);
  1176. }
  1177. private void cbbWQGD_KeyPress(object sender, KeyPressEventArgs e)
  1178. {
  1179. ComboBox_KeyPress(cbbWQGD.Text, sender, e);
  1180. }
  1181. private void cbbWQGF_KeyPress(object sender, KeyPressEventArgs e)
  1182. {
  1183. ComboBox_KeyPress(cbbWQGF.Text, sender, e);
  1184. }
  1185. private void cbbWLZ_KeyPress(object sender, KeyPressEventArgs e)
  1186. {
  1187. ComboBox_KeyPress(cbbWLZ.Text, sender, e);
  1188. }
  1189. #endregion
  1190. #region Z轴的保护范围
  1191. private void chkWqxkc_CheckedChanged(object sender, EventArgs e)
  1192. {
  1193. //if (chkWqxkc.Checked)
  1194. //{
  1195. // label3.Visible = true;
  1196. // cbbYDZZDX.Visible = true;
  1197. //}
  1198. //else
  1199. //{
  1200. // label3.Visible = false;
  1201. // cbbYDZZDX.Visible = false;
  1202. //}
  1203. }
  1204. private void txtYPSCur_TextChanged(object sender, EventArgs e)
  1205. {
  1206. if (txtYPSCur.Text!="")
  1207. {
  1208. if (Convert.ToSingle(txtYPSCur.Text)>5)
  1209. {
  1210. MessageBox.Show("数值最大为5");
  1211. txtYPSCur.Text = "5";
  1212. }
  1213. }
  1214. else
  1215. {
  1216. txtYPSCur.Text = "1";
  1217. }
  1218. }
  1219. private void txtYPSCur_KeyPress(object sender, KeyPressEventArgs e)
  1220. {
  1221. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
  1222. {
  1223. e.Handled = true;
  1224. }
  1225. }
  1226. #endregion
  1227. #region 参数确认
  1228. private void SaveMeasureFile()
  1229. {
  1230. //界面上的参数
  1231. FormHOZMainObject.m_MeasureFile.MParam = GetMeasureParamInfo();
  1232. //配置文件中的参数
  1233. FormHOZMainObject.m_MeasureFile.MParam.ZDistance = Convert.ToSingle(ConfigurationManager.AppSettings["ZDistance"].ToString());
  1234. FormHOZMainObject.m_MeasureFile.MParam.AutoFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_UP"].ToString());
  1235. FormHOZMainObject.m_MeasureFile.MParam.AutoFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Down"].ToString());
  1236. FormHOZMainObject.m_MeasureFile.MParam.AutoFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Step"].ToString());
  1237. FormHOZMainObject.m_MeasureFile.MParam.AutoFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Range"].ToString());
  1238. FormHOZMainObject.m_MeasureFile.MParam.AutoFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_FStep"].ToString());
  1239. FormHOZMainObject.m_MeasureFile.MParam.FIBFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_UP"].ToString());
  1240. FormHOZMainObject.m_MeasureFile.MParam.FIBFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Down"].ToString());
  1241. FormHOZMainObject.m_MeasureFile.MParam.FIBFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Step"].ToString());
  1242. FormHOZMainObject.m_MeasureFile.MParam.FIBFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Range"].ToString());
  1243. FormHOZMainObject.m_MeasureFile.MParam.FIBFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_FStep"].ToString());
  1244. FormHOZMainObject.m_MeasureFile.MParam.AutoStigX.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_UP"].ToString());
  1245. FormHOZMainObject.m_MeasureFile.MParam.AutoStigX.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Down"].ToString());
  1246. FormHOZMainObject.m_MeasureFile.MParam.AutoStigX.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Step"].ToString());
  1247. FormHOZMainObject.m_MeasureFile.MParam.AutoStigX.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Range"].ToString());
  1248. FormHOZMainObject.m_MeasureFile.MParam.AutoStigX.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_FStep"].ToString());
  1249. FormHOZMainObject.m_MeasureFile.MParam.AutoStigY.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_UP"].ToString());
  1250. FormHOZMainObject.m_MeasureFile.MParam.AutoStigY.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Down"].ToString());
  1251. FormHOZMainObject.m_MeasureFile.MParam.AutoStigY.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Step"].ToString());
  1252. FormHOZMainObject.m_MeasureFile.MParam.AutoStigY.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Range"].ToString());
  1253. FormHOZMainObject.m_MeasureFile.MParam.AutoStigY.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_FStep"].ToString());
  1254. FormHOZMainObject.m_MeasureFile.IsModified = true;
  1255. FormHOZMainObject.m_MeasureFile.MParam.ScanRotCor = Convert.ToSingle(ConfigurationManager.AppSettings["ScanRotCur"].ToString());
  1256. FormHOZMainObject.m_MeasureFile.MParam.PixelSizeCor = Convert.ToSingle(ConfigurationManager.AppSettings["PixelSize_Y_Cur"].ToString());
  1257. FormHOZMainObject.m_MeasureFile.MParam.EDS = Convert.ToBoolean(ConfigurationManager.AppSettings["Is_EDS"].ToString());
  1258. FormHOZMainObject.m_MeasureFile.MParam.EDSZ = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_Z"].ToString()) / 1000;
  1259. FormHOZMainObject.m_MeasureFile.MParam.EDSV = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_V"].ToString());
  1260. FormHOZMainObject.m_MeasureFile.MParam.EDSA = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_A"].ToString()) / 1000000000;
  1261. FormHOZMainObject.m_MeasureFile.MParam.RedcueX = Convert.ToInt32(ConfigurationManager.AppSettings["RedcueX"].ToString());
  1262. FormHOZMainObject.m_MeasureFile.MParam.RedcueY = Convert.ToInt32(ConfigurationManager.AppSettings["RedcueY"].ToString());
  1263. FormHOZMainObject.m_MeasureFile.MParam.RedcueW = Convert.ToInt32(ConfigurationManager.AppSettings["RedcueW"].ToString());
  1264. FormHOZMainObject.m_MeasureFile.MParam.RedcueH = Convert.ToInt32(ConfigurationManager.AppSettings["RedcueH"].ToString());
  1265. if (Directory.Exists(FormHOZMainObject.m_MeasureFile.FilePath))//如果已经存在硬盘上要重新保存文件
  1266. {
  1267. FormHOZMainObject.m_MeasureFile.Save();
  1268. }
  1269. }
  1270. private void button1_Click(object sender, EventArgs e)
  1271. {
  1272. //保存测量文件的参数
  1273. SaveMeasureFile();
  1274. }
  1275. #endregion
  1276. private void chkFIBAdjust_CheckedChanged(object sender, EventArgs e)
  1277. {
  1278. if (!chkFIBAdjust.Checked)
  1279. {
  1280. chkFIBAtuoAdjust.Checked = false;
  1281. chkFIBAtuoAdjust.Visible = false;
  1282. }
  1283. else
  1284. {
  1285. chkFIBAtuoAdjust.Visible = true;
  1286. }
  1287. if (chkFIBAtuoAdjust.Checked)
  1288. {
  1289. label4.Visible = false;
  1290. tbBrightness.Visible = false;
  1291. label7.Visible = false;
  1292. label5.Visible = false;
  1293. tbContrast.Visible = false;
  1294. label8.Visible = false;
  1295. }
  1296. else
  1297. {
  1298. label4.Visible = true;
  1299. tbBrightness.Visible = true;
  1300. label7.Visible = true;
  1301. label5.Visible = true;
  1302. tbContrast.Visible = true;
  1303. label8.Visible = true;
  1304. }
  1305. }
  1306. private void chkFIBAtuoAdjust_CheckedChanged(object sender, EventArgs e)
  1307. {
  1308. if (chkFIBAtuoAdjust.Checked)
  1309. {
  1310. label4.Visible = false;
  1311. tbBrightness.Visible = false;
  1312. label7.Visible = false;
  1313. label5.Visible = false;
  1314. tbContrast.Visible = false;
  1315. label8.Visible = false;
  1316. }
  1317. else
  1318. {
  1319. label4.Visible = true;
  1320. tbBrightness.Visible = true;
  1321. label7.Visible = true;
  1322. label5.Visible = true;
  1323. tbContrast.Visible = true;
  1324. label8.Visible = true;
  1325. }
  1326. }
  1327. private void tbBrightness_KeyPress(object sender, KeyPressEventArgs e)
  1328. {
  1329. textBox_KeyPress(tbBrightness.Text, sender, e);
  1330. }
  1331. private void tbContrast_KeyPress(object sender, KeyPressEventArgs e)
  1332. {
  1333. textBox_KeyPress(tbContrast.Text, sender, e);
  1334. }
  1335. private void tbGear1to2_KeyPress(object sender, KeyPressEventArgs e)
  1336. {
  1337. textBox_KeyPress(tbGear1to2.Text, sender, e);
  1338. }
  1339. private void tbGear2to3_KeyPress(object sender, KeyPressEventArgs e)
  1340. {
  1341. textBox_KeyPress(tbGear2to3.Text, sender, e);
  1342. }
  1343. private void tbGear3to4_KeyPress(object sender, KeyPressEventArgs e)
  1344. {
  1345. textBox_KeyPress(tbGear3to4.Text, sender, e);
  1346. }
  1347. private void tbGear1to2_Xdeviation_KeyPress(object sender, KeyPressEventArgs e)
  1348. {
  1349. textBox_KeyPress(tbGear1to2.Text, sender, e);
  1350. }
  1351. private void tbGear2to3_Xdeviation_KeyPress(object sender, KeyPressEventArgs e)
  1352. {
  1353. textBox_KeyPress(tbGear2to3.Text, sender, e);
  1354. }
  1355. private void tbGear3to4_Xdeviation_KeyPress(object sender, KeyPressEventArgs e)
  1356. {
  1357. textBox_KeyPress(tbGear3to4.Text, sender, e);
  1358. }
  1359. private void tbGear1to2_Ydeviation_KeyPress(object sender, KeyPressEventArgs e)
  1360. {
  1361. textBox_KeyPress(tbGear1to2.Text, sender, e);
  1362. }
  1363. private void tbGear2to3_Ydeviation_KeyPress(object sender, KeyPressEventArgs e)
  1364. {
  1365. textBox_KeyPress(tbGear2to3.Text, sender, e);
  1366. }
  1367. private void tbGear3to4_Ydeviation_KeyPress(object sender, KeyPressEventArgs e)
  1368. {
  1369. textBox_KeyPress(tbGear3to4.Text, sender, e);
  1370. }
  1371. private void tbContrast_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
  1372. {
  1373. }
  1374. private void tbContrast_KeyPress_1(object sender, KeyPressEventArgs e)
  1375. {
  1376. }
  1377. private void tbContrast_TextChanged(object sender, EventArgs e)
  1378. {
  1379. if(Convert.ToInt32(tbContrast.Text)>100|| Convert.ToInt32(tbContrast.Text)<0)
  1380. {
  1381. tbContrast.Text="0";
  1382. }
  1383. }
  1384. private void tbBrightness_TextChanged(object sender, EventArgs e)
  1385. {
  1386. if (Convert.ToInt32(tbBrightness.Text) > 100 || Convert.ToInt32(tbBrightness.Text) < 0)
  1387. {
  1388. tbBrightness.Text = "0";
  1389. }
  1390. }
  1391. private void btnHandSavePoints_Click(object sender, EventArgs e)
  1392. {
  1393. UserControls.FormExportPoints uCExport = new UserControls.FormExportPoints();
  1394. uCExport.ShowDialog();
  1395. List<CutHole> ListCutHole = uCExport.ListCutHole;
  1396. //文件路径
  1397. //string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
  1398. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  1399. FormHOZMainObject.m_MeasureFile.ListCutHole = ListCutHole;
  1400. //显示导入的切孔数量
  1401. lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
  1402. //tbCutHoleFilePath.Text = CutHoleFilePath;
  1403. //保存测量文件
  1404. if (Directory.Exists(FormHOZMainObject.m_MeasureFile.FilePath))
  1405. {
  1406. FormHOZMainObject.m_MeasureFile.Save();
  1407. }
  1408. }
  1409. }
  1410. }