FormHOZMain.cs 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. using FileManager;
  2. using MeasureData;
  3. using MeasureThread;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Configuration;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Drawing.Drawing2D;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Runtime.InteropServices;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. using static MeasureThread.ThreadStatusEventArgs;
  18. namespace HOZProject
  19. {
  20. public partial class FormHOZMain : Form
  21. {
  22. #region 控制窗体可以调整大小用
  23. const int HTLEFT = 10;
  24. const int HTRIGHT = 11;
  25. const int HTTOP = 12;
  26. const int HTTOPLEFT = 13;
  27. const int HTTOPRIGHT = 14;
  28. const int HTBOTTOM = 15;
  29. const int HTBOTTOMLEFT = 0x10;
  30. const int HTBOTTOMRIGHT = 17;
  31. protected override void WndProc(ref Message m)
  32. {
  33. switch (m.Msg)
  34. {
  35. case 0x0084:
  36. base.WndProc(ref m);
  37. Point vPoint = new Point((int)m.LParam & 0xFFFF,
  38. (int)m.LParam >> 16 & 0xFFFF);
  39. vPoint = PointToClient(vPoint);
  40. if (vPoint.X <= 5)
  41. if (vPoint.Y <= 5)
  42. m.Result = (IntPtr)HTTOPLEFT;
  43. else if (vPoint.Y >= ClientSize.Height - 5)
  44. m.Result = (IntPtr)HTBOTTOMLEFT;
  45. else m.Result = (IntPtr)HTLEFT;
  46. else if (vPoint.X >= ClientSize.Width - 5)
  47. if (vPoint.Y <= 5)
  48. m.Result = (IntPtr)HTTOPRIGHT;
  49. else if (vPoint.Y >= ClientSize.Height - 5)
  50. m.Result = (IntPtr)HTBOTTOMRIGHT;
  51. else m.Result = (IntPtr)HTRIGHT;
  52. else if (vPoint.Y <= 5)
  53. m.Result = (IntPtr)HTTOP;
  54. else if (vPoint.Y >= ClientSize.Height - 5)
  55. m.Result = (IntPtr)HTBOTTOM;
  56. break;
  57. case 0x0201://鼠标左键按下的消息
  58. m.Msg = 0x00A1;//更改消息为非客户区按下鼠标
  59. m.LParam = IntPtr.Zero;//默认值
  60. m.WParam = new IntPtr(2);//鼠标放在标题栏内
  61. base.WndProc(ref m);
  62. break;
  63. default:
  64. base.WndProc(ref m);
  65. break;
  66. }
  67. }
  68. #endregion
  69. #region 成员变量
  70. private NLog.Logger log;
  71. /// <summary>
  72. /// 控制闪烁
  73. /// </summary>
  74. public static bool ControlFlicker;//控制流程闪烁
  75. public BackgroundWorker m_BackgroundWorker;// 申明后台对象
  76. /// <summary>
  77. /// 测量文件
  78. /// </summary>
  79. public MeasureFile m_MeasureFile;
  80. /// 测量线程
  81. public Measure m_Ms;
  82. /// <summary>
  83. /// 显示日志窗体
  84. /// </summary>
  85. Form m_FormLog = null;
  86. /// <summary>
  87. /// 显示实例化窗体
  88. /// </summary>
  89. FormMove m_FormInit = null;
  90. /// <summary>
  91. /// 是否已保存
  92. /// </summary>
  93. public bool IsSave = false;
  94. /// <summary>
  95. /// 初始化用户控件
  96. /// </summary>
  97. UControl_Init uControl_Init = null;
  98. /// <summary>
  99. /// 日志用户控件
  100. /// </summary>
  101. UControl_Log ucLog = null;
  102. //流程控制
  103. public int m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
  104. //是否关闭窗体标识
  105. public bool IsClose = false;
  106. OTSMeasureOutputNlog logwin;
  107. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  108. #endregion
  109. #region 构造函数
  110. public FormHOZMain()
  111. {
  112. InitializeComponent();
  113. //在线程操作过程中,可以设置控件属性
  114. Control.CheckForIllegalCrossThreadCalls = false;
  115. m_BackgroundWorker = new BackgroundWorker(); // 实例化后台对象
  116. m_BackgroundWorker.WorkerReportsProgress = true; // 设置可以通告进度
  117. m_BackgroundWorker.WorkerSupportsCancellation = true; // 设置可以取消
  118. m_BackgroundWorker.DoWork += new DoWorkEventHandler(DoWork);
  119. m_BackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(UpdateProgress);
  120. m_BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedWork);
  121. //LogManager.InitManulLog();
  122. }
  123. #endregion
  124. #region 测量线程
  125. void DoWork(object sender, DoWorkEventArgs e)
  126. {
  127. try
  128. {
  129. m_Ms = new Measure(ConfigurationManager.AppSettings["WebServerIP"].ToString(),
  130. ConfigurationManager.AppSettings["WebServerPort"].ToString(),
  131. ConfigurationManager.AppSettings["WebServerUrl"].ToString());
  132. m_MeasureFile.MParam.AutoFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_UP"].ToString());
  133. m_MeasureFile.MParam.AutoFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Down"].ToString());
  134. m_MeasureFile.MParam.AutoFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Step"].ToString());
  135. m_MeasureFile.MParam.AutoFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_Range"].ToString());
  136. m_MeasureFile.MParam.AutoFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["Focus_FStep"].ToString());
  137. m_MeasureFile.MParam.FIBFocus.UP = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_UP"].ToString());
  138. m_MeasureFile.MParam.FIBFocus.Down = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Down"].ToString());
  139. m_MeasureFile.MParam.FIBFocus.Step = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Step"].ToString());
  140. m_MeasureFile.MParam.FIBFocus.Range = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_Range"].ToString());
  141. m_MeasureFile.MParam.FIBFocus.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["FIB_FStep"].ToString());
  142. m_MeasureFile.MParam.AutoStigX.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_UP"].ToString());
  143. m_MeasureFile.MParam.AutoStigX.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Down"].ToString());
  144. m_MeasureFile.MParam.AutoStigX.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Step"].ToString());
  145. m_MeasureFile.MParam.AutoStigX.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_Range"].ToString());
  146. m_MeasureFile.MParam.AutoStigX.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigX_FStep"].ToString());
  147. m_MeasureFile.MParam.AutoStigY.UP = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_UP"].ToString());
  148. m_MeasureFile.MParam.AutoStigY.Down = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Down"].ToString());
  149. m_MeasureFile.MParam.AutoStigY.Step = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Step"].ToString());
  150. m_MeasureFile.MParam.AutoStigY.Range = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_Range"].ToString());
  151. m_MeasureFile.MParam.AutoStigY.fStep = Convert.ToSingle(ConfigurationManager.AppSettings["StigY_FStep"].ToString());
  152. m_MeasureFile.MParam.FIBDo= Convert.ToBoolean(ConfigurationManager.AppSettings["Is_FIBDo"]);
  153. m_MeasureFile.MParam.FIBAutoBC = Convert.ToBoolean(ConfigurationManager.AppSettings["Is_FIBAutoBc"]);
  154. m_MeasureFile.MParam.FIBB = Convert.ToSingle(ConfigurationManager.AppSettings["FIBB"]);
  155. m_MeasureFile.MParam.FIBC = Convert.ToSingle(ConfigurationManager.AppSettings["FIBC"]);
  156. m_MeasureFile.MParam.MagComp = Convert.ToBoolean(ConfigurationManager.AppSettings["MagComp"]);
  157. m_MeasureFile.MParam.MagRange1 = Convert.ToSingle(ConfigurationManager.AppSettings["MagRange1"]);
  158. m_MeasureFile.MParam.MagRange2 = Convert.ToSingle(ConfigurationManager.AppSettings["MagRange2"]);
  159. m_MeasureFile.MParam.MagRange3 = Convert.ToSingle(ConfigurationManager.AppSettings["MagRange3"]);
  160. m_MeasureFile.MParam.MagCompX1 = Convert.ToSingle(ConfigurationManager.AppSettings["MagCompX1"]);
  161. m_MeasureFile.MParam.MagCompX2 = Convert.ToSingle(ConfigurationManager.AppSettings["MagCompX2"]);
  162. m_MeasureFile.MParam.MagCompX3 = Convert.ToSingle(ConfigurationManager.AppSettings["MagCompX3"]);
  163. m_MeasureFile.MParam.MagCompY1 = Convert.ToSingle(ConfigurationManager.AppSettings["MagCompY1"]);
  164. m_MeasureFile.MParam.MagCompY2 = Convert.ToSingle(ConfigurationManager.AppSettings["MagCompY2"]);
  165. m_MeasureFile.MParam.MagCompY3 = Convert.ToSingle(ConfigurationManager.AppSettings["MagCompY3"]);
  166. m_Ms.X_Min = Convert.ToSingle(ConfigurationManager.AppSettings["X_Min"]);
  167. m_Ms.X_Max = Convert.ToSingle(ConfigurationManager.AppSettings["X_Max"]);
  168. m_Ms.Y_Min = Convert.ToSingle(ConfigurationManager.AppSettings["Y_Min"]);
  169. m_Ms.Y_Max = Convert.ToSingle(ConfigurationManager.AppSettings["Y_Max"]);
  170. m_Ms.Z_Min = Convert.ToSingle(ConfigurationManager.AppSettings["Z_Min"]);
  171. m_Ms.Z_Max = Convert.ToSingle(ConfigurationManager.AppSettings["Z_Max"]);
  172. m_Ms.T_Min = Convert.ToSingle(ConfigurationManager.AppSettings["T_Min"]);
  173. m_Ms.T_Max = Convert.ToSingle(ConfigurationManager.AppSettings["T_Max"]);
  174. m_Ms.R_Min = Convert.ToSingle(ConfigurationManager.AppSettings["R_Min"]);
  175. m_Ms.R_Max = Convert.ToSingle(ConfigurationManager.AppSettings["R_Max"]);
  176. m_Ms.M_Min = Convert.ToSingle(ConfigurationManager.AppSettings["M_Min"]);
  177. m_Ms.M_Max = Convert.ToSingle(ConfigurationManager.AppSettings["M_Max"]);
  178. //人工干预
  179. m_Ms.hand_intervene = Convert.ToInt32(ConfigurationManager.AppSettings["Hand_Intervene"]);
  180. //SmartSEM远程路径
  181. m_Ms.RemoteELYPath = ConfigurationManager.AppSettings["RemoteELYPath"];
  182. m_Ms.RemoteMLFPath = ConfigurationManager.AppSettings["RemoteMLFPath"];
  183. //Z轴移动距离
  184. m_MeasureFile.MParam.ZDistance= Convert.ToSingle(ConfigurationManager.AppSettings["ZDistance"]);
  185. //add by sun 2020-12-15 增加不同样品扫描速度参数
  186. m_MeasureFile.MParam.ScanSpeedNormal = Convert.ToString(ConfigurationManager.AppSettings["ScanSpeedNormal_" + m_MeasureFile.MParam.SampleName]);
  187. m_MeasureFile.MParam.ScanSpeedFocus = Convert.ToString(ConfigurationManager.AppSettings["ScanSpeedFocus_" + m_MeasureFile.MParam.SampleName]);
  188. m_MeasureFile.MParam.ScanSpeedHigh = Convert.ToString(ConfigurationManager.AppSettings["ScanSpeedHigh_" + m_MeasureFile.MParam.SampleName]);
  189. //log.Info("==============="+ ConfigurationManager.AppSettings["ScanSpeedNormal_3"] + "========="+ m_MeasureFile.MParam.SampleName, true);
  190. //add by sun 2020-12-15 增加不同样品扫描速度参数 end
  191. //add by sun 2020-12-17 增加调试时是否切割开关
  192. m_MeasureFile.MParam.IsCutingForDebug = Convert.ToBoolean(ConfigurationManager.AppSettings["IsCutingForDebug"]);
  193. //add by sun 2020-12-17 增加调试时是否切割开关 end
  194. // add by zjx 2020-12-18 为了测试只做能谱部分
  195. m_MeasureFile.MParam.IsonlyEDSForDebug = Convert.ToBoolean(ConfigurationManager.AppSettings["IsonlyEDSForDebug"]);
  196. // add by zjx 2020-12-18 为了测试只做能谱部分 end
  197. m_Ms.InitMeas(m_MeasureFile);
  198. //注册事件
  199. m_Ms.SendThreadStatus += new ThreadStatusHandler(displayMessage);
  200. //注册事件
  201. m_Ms.SendCutHolesStatus += new CutHolesStatusHandler(displayCutHoleMessage);
  202. //设置控件操作
  203. SetWinControlMeasureState(false);
  204. //自动测量的全过程
  205. m_Ms.DoMeasure();
  206. }
  207. catch (Exception ex)
  208. {
  209. log.Error(ex.ToString(),false);
  210. }
  211. }
  212. public void displayMessage(object sender, ThreadStatusEventArgs e)
  213. {
  214. //主界面显示内容
  215. this.BeginInvoke((Action)delegate
  216. {
  217. this.listmsg.Items.Add(e.HoleName +"_" + e.Time.ToString() + "_"+ e.Message + "_" + e.State );
  218. //显示流程中对应编号的内容
  219. MeasureMsgManage.ShowMsgContent(this, e);
  220. AddLogListInfo(e);
  221. });
  222. }
  223. public void displayCutHoleMessage(object sender, CutHolesStatusEventArgs e)
  224. {
  225. //主界面显示内容
  226. this.BeginInvoke((Action)delegate
  227. {
  228. //修改切孔状态
  229. ChangeCutHoleState(e.HoleName.ToString(), Convert.ToInt32(e.State));
  230. });
  231. }
  232. void UpdateProgress(object sender, ProgressChangedEventArgs e)
  233. {
  234. }
  235. void CompletedWork(object sender, RunWorkerCompletedEventArgs e)
  236. {
  237. ControlFlicker = false;
  238. //设置控件操作
  239. MessageBox.Show("测量已完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  240. SetWinControlMeasureState(true);
  241. pbStop.Visible = false;
  242. pbStart.Visible = true;
  243. //UControl_ParaInfo uControl_ParaInfo=new UControl_ParaInfo()
  244. UControl_ParaInfo uControl_ParaInfo = new UControl_ParaInfo(this);
  245. uControl_ParaInfo.pbMeasure.Value = 100;
  246. uControl_ParaInfo.lblCompletedAmount.Text = "100%";
  247. }
  248. #endregion
  249. #region 窗体加载
  250. private void FormHOZMain_Load(object sender, EventArgs e)
  251. {
  252. //加载控件的点击事件
  253. this.Click += new EventHandler(FormHOZMain_Click);
  254. plFill.Click += new EventHandler(FormHOZMain_Click);
  255. plTop.Click += new EventHandler(FormHOZMain_Click);
  256. plLeft.Click += new EventHandler(FormHOZMain_Click);
  257. plLeftContent.Click += new EventHandler(FormHOZMain_Click);
  258. pbImage.Click += new EventHandler(FormHOZMain_Click);
  259. //加载窗口移动事件
  260. this.MouseDown += new MouseEventHandler(FormHOZMain_MouseDown);
  261. this.plTop.MouseDown += new MouseEventHandler(FormHOZMain_MouseDown);
  262. //新建
  263. NewCreate();
  264. //实例初始化窗体对象
  265. if (uControl_Init == null)
  266. {
  267. uControl_Init = new UControl_Init(this);
  268. uControl_Init.ReloadConfig();
  269. }
  270. logwin = new OTSMeasureOutputNlog();
  271. logwin.Show();
  272. logwin.Height = this.Height;
  273. logwin.Left = this.Left - logwin.Width;
  274. logwin.Top = this.Top;
  275. NLog.Config.LoggingRule lr = NLog.LogManager.Configuration.LoggingRules.FirstOrDefault(
  276. r => r.Targets.Any(
  277. t => "control" == t.Name
  278. )
  279. );
  280. if (lr != null)
  281. {
  282. }
  283. log = NLog.LogManager.GetCurrentClassLogger();
  284. ConfigurationParameter();
  285. this.Left= this.Location.X + logwin.Width / 2;
  286. }
  287. #endregion
  288. #region 创建切孔列表信息
  289. /// <summary>
  290. /// 创建切孔列表信息
  291. /// </summary>
  292. /// <param name="ListCutHole"></param>
  293. public void CreateCutHoleList(List<CutHole> ListCutHole)
  294. {
  295. //清空左侧Panel中的切孔控件
  296. ClearPanelControls();
  297. for (int i = ListCutHole.Count - 1; i >= 0; i--)
  298. {
  299. UControl_CutHole ucCutHole = new UControl_CutHole(this);
  300. ucCutHole.Dock = DockStyle.Top;
  301. ucCutHole.CutHoleName = ListCutHole[i].HoleName;
  302. //显示切孔参数信息
  303. if (ucCutHole.UControl_ParaInfo == null)
  304. {
  305. ucCutHole.UControl_ParaInfo = new UControl_ParaInfo(this);
  306. }
  307. plPrarInfo.Width = ucCutHole.UControl_ParaInfo.Width;
  308. plPrarInfo.Height = ucCutHole.UControl_ParaInfo.Height;
  309. //设置当前样品的参数信息
  310. string CutHoleName = ListCutHole[i].HoleName;
  311. ucCutHole.UControl_ParaInfo.Name = CutHoleName;
  312. ucCutHole.UControl_ParaInfo.CutHoleName = CutHoleName;
  313. ucCutHole.UControl_ParaInfo.Position = ListCutHole[i].Position;
  314. ucCutHole.UControl_ParaInfo.StartTime = ListCutHole[i].START.ToString();
  315. ucCutHole.UControl_ParaInfo.EndTime = ListCutHole[i].END.ToString();
  316. int state = (int)ListCutHole[i].STATE;
  317. ucCutHole.UControl_ParaInfo.State = state;
  318. ucCutHole.UControl_ParaInfo.IsSwitch = ListCutHole[i].SWITCH;
  319. ucCutHole.UControl_ParaInfo.ShowParaInfo();
  320. this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  321. plPrarInfo.Controls.Add(ucCutHole.UControl_ParaInfo);
  322. plLeftContent.Controls.Add(ucCutHole);
  323. ChangeCutHoleState(CutHoleName, state);
  324. }
  325. plPrarInfo.Visible = false;
  326. }
  327. #endregion
  328. #region 隐藏处理层
  329. //隐藏处理层
  330. private void FormHOZMain_Click(object sender, EventArgs e)
  331. {
  332. if (plPrarInfo.Visible)
  333. {
  334. plPrarInfo.Visible = false;
  335. }
  336. }
  337. #endregion
  338. #region 设置控件在线程过程中的编辑状态
  339. /// <summary>
  340. /// 设置控件在线程过程中的编辑状态
  341. /// </summary>
  342. /// <param name="cState"></param>
  343. public void SetWinControlMeasureState(bool cState)
  344. {
  345. pbNew.Enabled = cState;
  346. pbOpen.Enabled = cState;
  347. pbSave.Enabled = cState;
  348. pbInit.Enabled = cState;
  349. pbImportTemplateFile.Enabled = cState;
  350. //pbLog.Enabled = cState;
  351. pbStart.Enabled = cState;
  352. pbStop.Enabled = !cState;
  353. //设置切孔是否执行
  354. foreach (Control item in plPrarInfo.Controls)
  355. {
  356. if (item is UserControl)
  357. {
  358. UControl_ParaInfo ucParaInfo = (UControl_ParaInfo)item;
  359. ucParaInfo.CkIsSwitch.Enabled = cState;
  360. }
  361. }
  362. }
  363. #endregion
  364. #region 窗体中 线程开始 停止 最大化 最小化 关闭 按钮事件
  365. private void pbMin_MouseEnter(object sender, EventArgs e)
  366. {
  367. this.pbMin.BackgroundImage = global::HOZProject.Properties.Resources.Min_2_;
  368. }
  369. private void pbMin_MouseLeave(object sender, EventArgs e)
  370. {
  371. this.pbMin.BackgroundImage = global::HOZProject.Properties.Resources.Min_2_;
  372. }
  373. private void pbMax_MouseEnter(object sender, EventArgs e)
  374. {
  375. this.pbMax.BackgroundImage = global::HOZProject.Properties.Resources.Max_2_;
  376. }
  377. private void pbMax_MouseLeave(object sender, EventArgs e)
  378. {
  379. this.pbMax.BackgroundImage = global::HOZProject.Properties.Resources.Max_2_;
  380. }
  381. private void pbClose_MouseEnter(object sender, EventArgs e)
  382. {
  383. this.pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_2_;
  384. }
  385. private void pbClose_MouseLeave(object sender, EventArgs e)
  386. {
  387. this.pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_2_;
  388. }
  389. private void pbStart_MouseEnter(object sender, EventArgs e)
  390. {
  391. //this.pbStart.BackgroundImage = global::HOZProject.Properties.Resources.StartMove;
  392. }
  393. private void pbStart_MouseLeave(object sender, EventArgs e)
  394. {
  395. //this.pbStart.BackgroundImage = global::HOZProject.Properties.Resources.Start_3_;
  396. }
  397. private void pbStop_MouseEnter(object sender, EventArgs e)
  398. {
  399. //this.pbStop.BackgroundImage = global::HOZProject.Properties.Resources.StopMove;
  400. }
  401. private void pbStop_MouseLeave(object sender, EventArgs e)
  402. {
  403. //this.pbStop.BackgroundImage = global::HOZProject.Properties.Resources.Stop;
  404. }
  405. private void pbClose_Click(object sender, EventArgs e)
  406. {
  407. try
  408. {
  409. if (m_Ms != null)
  410. {
  411. if (m_BackgroundWorker.IsBusy)
  412. {
  413. if (MessageBox.Show("当前测量正在运行,是否关闭此窗体?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  414. {
  415. //线程停止变量
  416. m_Ms.key_stop = true;
  417. IsClose = true;
  418. lblStateMessage.Text = "正在关闭窗体...请等待";
  419. pbClose.Enabled = false;
  420. ControlFlicker = false;
  421. }
  422. return;
  423. }
  424. }
  425. if (MessageBox.Show("是否关闭此窗体?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  426. {
  427. m_MeasureFile.Save();
  428. this.Close();
  429. }
  430. }
  431. catch (Exception ex)
  432. {
  433. log.Error(ex.Message);
  434. }
  435. }
  436. private void pbMin_Click(object sender, EventArgs e)
  437. {
  438. this.WindowState = FormWindowState.Minimized;
  439. }
  440. private void pbMax_Click(object sender, EventArgs e)
  441. {
  442. if (this.WindowState == FormWindowState.Maximized)
  443. {
  444. this.WindowState = FormWindowState.Normal;
  445. }
  446. else
  447. {
  448. this.WindowState = FormWindowState.Maximized;
  449. }
  450. //窗体据中
  451. this.StartPosition = FormStartPosition.CenterScreen;
  452. }
  453. #endregion
  454. #region 新建、保存、打开、初始化、导入配置、查看日志
  455. private void pbNew_Click(object sender, EventArgs e)
  456. {
  457. NewCreate();
  458. }
  459. private void NewCreate()
  460. {
  461. m_MeasureFile = new MeasureFile();
  462. if (!m_MeasureFile.New())
  463. {
  464. return;
  465. }
  466. else
  467. {
  468. //清空内容容器中的控件
  469. ClearPanelControls();
  470. }
  471. //实例初始化窗体对象
  472. if (uControl_Init == null)
  473. {
  474. uControl_Init = new UControl_Init(this);
  475. uControl_Init.ReloadConfig();
  476. }
  477. m_MeasureFile.MParam = uControl_Init.GetMeasureParam();
  478. }
  479. private void pbSave_Click(object sender, EventArgs e)
  480. {
  481. Saveclick();
  482. //if (m_MeasureFile == null)
  483. //{
  484. // MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  485. //}
  486. //else
  487. //{
  488. // //保存测量文件
  489. // if (m_MeasureFile.SaveAs())
  490. // {
  491. // //获取测量文件所在路径
  492. // string savePath = m_MeasureFile.FilePath;
  493. // //数据库名称
  494. // string dbFileName = "MeasureFile.db";
  495. // //要复制的文件路径
  496. // string pLocalFilePath = Application.StartupPath +"\\"+dbFileName;
  497. // string pSaveFilePath = savePath + "\\" + dbFileName;//指定存储的路径
  498. // if (File.Exists(pLocalFilePath))//必须判断要复制的文件是否存在
  499. // {
  500. // //三个参数分别是源文件路径,存储路径,若存储路径有相同文件是否替换
  501. // File.Copy(pLocalFilePath, pSaveFilePath, true);
  502. // }
  503. // //将初始化中的参数,配置到测量参数中
  504. // m_MeasureFile.MParam = uControl_Init.GetMeasureParamInfo();
  505. // //设置已保存状态
  506. // IsSave = true;
  507. // }
  508. //}
  509. }
  510. public void Saveclick()
  511. {
  512. if (m_MeasureFile == null)
  513. {
  514. MessageBox.Show("请新建一个测量文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  515. }
  516. else
  517. {
  518. //保存测量文件
  519. if (m_MeasureFile.SaveAs())
  520. {
  521. //获取测量文件所在路径
  522. string savePath = m_MeasureFile.FilePath;
  523. //数据库名称
  524. string dbFileName = "MeasureDB.db";
  525. //要复制的文件路径
  526. string pLocalFilePath = Application.StartupPath + "\\" + dbFileName;
  527. string pSaveFilePath = savePath + "\\" + dbFileName;//指定存储的路径
  528. if (File.Exists(pLocalFilePath))//必须判断要复制的文件是否存在
  529. {
  530. //三个参数分别是源文件路径,存储路径,若存储路径有相同文件是否替换
  531. //File.Copy(pLocalFilePath, pSaveFilePath, true);
  532. }
  533. //将初始化中的参数,配置到测量参数中
  534. m_MeasureFile.MParam = uControl_Init.GetMeasureParamInfo();
  535. //设置已保存状态
  536. IsSave = true;
  537. }
  538. }
  539. }
  540. private void pbOpen_Click(object sender, EventArgs e)
  541. {
  542. try
  543. {
  544. //打开默认路径
  545. OpenFileDialog openFileDialog = new OpenFileDialog();
  546. //设置筛选文件格式
  547. openFileDialog.Filter = "测量文件(*.msf)|*.msf";
  548. if (openFileDialog.ShowDialog() == DialogResult.OK)
  549. {
  550. //读取文件
  551. string measureFileNamePath = openFileDialog.FileName;
  552. m_MeasureFile.FileName = measureFileNamePath;
  553. m_MeasureFile.Open();
  554. List<CutHole> ListCutHole = m_MeasureFile.ListCutHole;
  555. //文件路径
  556. string CutHoleFilePath = m_MeasureFile.CutHoleFilePath;
  557. CreateCutHoleList(ListCutHole);
  558. ////保存测量文件
  559. //m_MeasureFile.Save();
  560. //设置已保存状态
  561. IsSave = true;
  562. }
  563. }
  564. catch (Exception ex)
  565. {
  566. log.Error(ex.Message);
  567. }
  568. }
  569. private void pbInit_Click(object sender, EventArgs e)
  570. {
  571. if (uControl_Init == null)
  572. {
  573. uControl_Init = new UControl_Init(this);
  574. uControl_Init.ReloadConfig();
  575. }
  576. if (m_FormInit == null)
  577. {
  578. m_FormInit = new FormMove();
  579. }
  580. m_FormInit.StartPosition = FormStartPosition.CenterScreen;
  581. m_FormInit.FormBorderStyle = FormBorderStyle.None;
  582. m_FormInit.Width = uControl_Init.Width + 2;
  583. m_FormInit.Height = uControl_Init.Height + 2;
  584. if (m_FormInit.Controls.Count == 0)
  585. {
  586. uControl_Init.Location = new Point(1,1);
  587. m_FormInit.Controls.Add(uControl_Init);
  588. }
  589. m_FormInit.ShowDialog();
  590. ConfigurationParameter();
  591. m_FormInit.Left = this.Left;
  592. }
  593. private void pictureBox1_Click(object sender, EventArgs e)
  594. {
  595. //if (UControl_ZoomIn == null)
  596. //{
  597. // UControl_ZoomIn = new UControl_ZoomIn(this);
  598. // UControl_ZoomIn.ReloadConfig();
  599. //}
  600. //if (m_FormZoomIn == null)
  601. //{
  602. // m_FormZoomIn = new FormZoomIn();
  603. //}
  604. //m_FormZoomIn.StartPosition = FormStartPosition.CenterScreen;
  605. //m_FormZoomIn.FormBorderStyle = FormBorderStyle.None;
  606. //m_FormZoomIn.Width = UControl_ZoomIn.Width + 4;
  607. //m_FormZoomIn.Height = UControl_ZoomIn.Height + 4;
  608. //if (m_FormZoomIn.Controls.Count == 0)
  609. //{
  610. // UControl_ZoomIn.Location = new Point(2, 2);
  611. // m_FormZoomIn.Controls.Add(UControl_ZoomIn);
  612. //}
  613. //m_FormZoomIn.ShowDialog();
  614. }
  615. private void pbImportTemplateFile_Click(object sender, EventArgs e)
  616. {
  617. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  618. string m_TemplateFilePath = config.AppSettings.Settings["TemplateFilePath"].Value.ToString();
  619. //判断保存的路径是否存在
  620. if (!Directory.Exists(m_TemplateFilePath))
  621. {
  622. ////创建路径
  623. //Directory.CreateDirectory(m_TemplateFilePath);
  624. FolderBrowserDialog dialog = new FolderBrowserDialog();
  625. dialog.Description = "请选择文件路径";
  626. //dialog.RootFolder = Environment.SpecialFolder.Programs;
  627. if (dialog.ShowDialog() == DialogResult.OK)
  628. {
  629. m_TemplateFilePath = dialog.SelectedPath;
  630. config.AppSettings.Settings["TemplateFilePath"].Value = m_TemplateFilePath;
  631. config.Save(ConfigurationSaveMode.Modified);
  632. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  633. }
  634. }
  635. //打开默认路径
  636. OpenFileDialog openFileDialog = new OpenFileDialog();
  637. //设置默认打开路径(绝对路径)
  638. openFileDialog.InitialDirectory = m_TemplateFilePath;
  639. openFileDialog.Filter = "样品参数文件|*.cfg";
  640. if (openFileDialog.ShowDialog() == DialogResult.OK)
  641. {
  642. if (uControl_Init == null)
  643. {
  644. uControl_Init = new UControl_Init(this);
  645. }
  646. //设置选择的模板文件
  647. uControl_Init.ReadConfigPath = openFileDialog.FileName;
  648. //获取文件
  649. uControl_Init.ReadConfigInfo();
  650. }
  651. }
  652. private void pbLog_Click(object sender, EventArgs e)
  653. {
  654. m_FormLog = new Form();
  655. m_FormLog.StartPosition = FormStartPosition.CenterScreen;
  656. if (ucLog == null)
  657. {
  658. ucLog = new UControl_Log();
  659. }
  660. m_FormLog.FormBorderStyle = FormBorderStyle.None;
  661. m_FormLog.Width = ucLog.Width;
  662. m_FormLog.Height = ucLog.Height;
  663. ucLog.Name = "UControl_Log";
  664. //获取日志信息
  665. if (listmsg.Items.Count>0)
  666. {
  667. string[] strLog = new string[listmsg.Items.Count];
  668. for (int i = 0; i < listmsg.Items.Count; i++)
  669. {
  670. //赋值给数组
  671. strLog[i] = listmsg.Items[i].ToString();
  672. }
  673. ucLog.ShowProcessLogInfo(strLog);
  674. }
  675. m_FormLog.Controls.Add(ucLog);
  676. m_FormLog.ShowDialog();
  677. }
  678. //显示日志
  679. private void AddLogListInfo(ThreadStatusEventArgs e)
  680. {
  681. if (m_FormLog != null)
  682. {
  683. foreach (Control item in m_FormLog.Controls)
  684. {
  685. if (item is UserControl)
  686. {
  687. if (item.Name == "UControl_Log")
  688. {
  689. ucLog = (UControl_Log)item;
  690. //获取日志信息
  691. if (listmsg.Items.Count > 0)
  692. {
  693. string[] strLog = new string[listmsg.Items.Count];
  694. for (int i = 0; i < listmsg.Items.Count; i++)
  695. {
  696. //赋值给数组
  697. strLog[i] = listmsg.Items[i].ToString();
  698. }
  699. ucLog.ShowProcessLogInfo(strLog);
  700. }
  701. }
  702. }
  703. }
  704. }
  705. }
  706. #endregion
  707. #region 修改切孔状态
  708. /// <summary>
  709. /// 修改切孔状态
  710. /// </summary>
  711. /// <param name="cutHoleCode"></param>
  712. /// <param name="States"></param>
  713. public void ChangeCutHoleState(string CutHoleName, int States)
  714. {
  715. foreach (Control item in plLeftContent.Controls)
  716. {
  717. if (item is UserControl)
  718. {
  719. UControl_CutHole cutHole = (UControl_CutHole)item;
  720. if (cutHole.CutHoleName == CutHoleName)
  721. {
  722. Button btnCutHole = (Button)cutHole.Controls.Find("btnCutHole", false)[0];
  723. switch (States)
  724. {
  725. //运行中
  726. case (int)ThreadState.InProcess:
  727. //btnCutHole.BackColor = Color.Yellow;
  728. btnCutHole.BackgroundImage = Properties.Resources.CutHole_Yellow_2_;
  729. btnCutHole.BackgroundImageLayout = ImageLayout.Center;
  730. ChangeCutHoleMeasureState(CutHoleName, States);
  731. ControlFlicker = true;
  732. break;
  733. //等待
  734. case (int)ThreadState.Waiting:
  735. //btnCutHole.BackColor = Color.Yellow;
  736. btnCutHole.BackgroundImage = Properties.Resources.CutHole_Yellow_2_;
  737. btnCutHole.BackgroundImageLayout = ImageLayout.Center;
  738. ChangeCutHoleMeasureState(CutHoleName, States);
  739. break;
  740. //准备
  741. case (int)ThreadState.Ready:
  742. //btnCutHole.BackColor = Color.White;
  743. btnCutHole.BackgroundImage = Properties.Resources.CutHole_Gray_2_;
  744. btnCutHole.BackgroundImageLayout = ImageLayout.Center;
  745. ChangeCutHoleMeasureState(CutHoleName, States);
  746. break;
  747. //失败
  748. case (int)ThreadState.Failed:
  749. //btnCutHole.BackColor = Color.Red;
  750. btnCutHole.BackgroundImage = Properties.Resources.CutHole_Red_2_;
  751. btnCutHole.BackgroundImageLayout = ImageLayout.Center;
  752. ChangeCutHoleMeasureState(CutHoleName, States);
  753. ControlFlicker = false;
  754. break;
  755. //完成
  756. case (int)ThreadState.Success:
  757. //btnCutHole.BackColor = Color.GreenYellow;
  758. btnCutHole.BackgroundImage = Properties.Resources.CutHole_Green_2_;
  759. btnCutHole.BackgroundImageLayout = ImageLayout.Center;
  760. //修改切孔状态
  761. ChangeCutHoleMeasureState(CutHoleName, States);
  762. ControlFlicker = false;
  763. break;
  764. }
  765. break;
  766. }
  767. }
  768. }
  769. }
  770. #endregion
  771. #region 修改切孔状态
  772. public void ChangeCutHoleMeasureState(string CutHoleName, int States)
  773. {
  774. if (plPrarInfo.Controls.Count > 0)
  775. {
  776. foreach (Control item in plPrarInfo.Controls)
  777. {
  778. if (item is UserControl)
  779. {
  780. if (item.Name == CutHoleName)
  781. {
  782. UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
  783. //获取切孔列表
  784. List<CutHole> aCutHole = m_MeasureFile.ListCutHole;
  785. foreach (CutHole cutHoleItem in aCutHole)
  786. {
  787. if (cutHoleItem.HoleName == CutHoleName)
  788. {
  789. //设置开始时间与结束时间
  790. uControl_ParaInfo.StartTime = cutHoleItem.START.ToString();
  791. uControl_ParaInfo.EndTime = cutHoleItem.END.ToString();
  792. uControl_ParaInfo.ShowTime();
  793. break;
  794. }
  795. }
  796. switch (States)
  797. {
  798. //准备
  799. case (int)ThreadState.Ready:
  800. //修改切孔状态
  801. uControl_ParaInfo.lblShowState.Text = "准备";
  802. break;
  803. //等待
  804. case (int)ThreadState.Waiting:
  805. //修改切孔状态
  806. uControl_ParaInfo.lblShowState.Text = "等待";
  807. break;
  808. //进行中
  809. case (int)ThreadState.InProcess:
  810. //修改切孔状态
  811. uControl_ParaInfo.lblShowState.Text = "进行中";
  812. break;
  813. //完成
  814. case (int)ThreadState.Success:
  815. //修改切孔状态
  816. uControl_ParaInfo.lblShowState.Text = "完成";
  817. break;
  818. //失败
  819. case (int)ThreadState.Failed:
  820. uControl_ParaInfo.lblShowState.Text = "失败";
  821. uControl_ParaInfo.pbMeasure.Value = 100;
  822. uControl_ParaInfo.lblCompletedAmount.Text = "100%";
  823. break;
  824. }
  825. break;
  826. }
  827. }
  828. }
  829. }
  830. }
  831. #endregion
  832. #region 拖动无窗体的控件
  833. [DllImport("user32.dll")]//拖动无窗体的控件
  834. public static extern bool ReleaseCapture();
  835. [DllImport("user32.dll")]
  836. public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
  837. public const int WM_SYSCOMMAND = 0x0112;
  838. public const int SC_MOVE = 0xF010;
  839. public const int HTCAPTION = 0x0002;
  840. private void FormHOZMain_MouseDown(object sender, MouseEventArgs e)
  841. {
  842. if (this.WindowState == FormWindowState.Normal)
  843. {
  844. //拖动窗体
  845. ReleaseCapture();
  846. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  847. }
  848. }
  849. #endregion
  850. #region 开始、结束线程事件
  851. private void pbStart_Click(object sender, EventArgs e)
  852. {
  853. if (plLeftContent.Controls.Count==0)
  854. {
  855. MessageBox.Show("请添加切孔信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  856. return;
  857. }
  858. if (IsSave)
  859. {
  860. if (m_BackgroundWorker.IsBusy)
  861. {
  862. MessageBox.Show("线程已经运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  863. return;
  864. }
  865. if (MessageBox.Show("是否开始测量!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  866. {
  867. log.Info("开始", true);
  868. m_BackgroundWorker.RunWorkerAsync(this);
  869. pbStop.Visible = true;
  870. pbStart.Visible = false;
  871. }
  872. }
  873. else
  874. {
  875. MessageBox.Show("请保存当前测量文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  876. return;
  877. }
  878. }
  879. private void pbStop_Click(object sender, EventArgs e)
  880. {
  881. if (m_Ms != null)
  882. {
  883. if (MessageBox.Show("是否停止当前测量?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
  884. {
  885. ControlFlicker = false;
  886. //线程停止变量
  887. m_Ms.key_stop = true;
  888. }
  889. }
  890. }
  891. #endregion
  892. #region 清空内容容器中的控件
  893. /// <summary>
  894. /// 清空内容容器中的控件
  895. /// </summary>
  896. private void ClearPanelControls()
  897. {
  898. //清空内容容器中的控件
  899. plLeftContent.Controls.Clear();
  900. plPrarInfo.Controls.Clear();
  901. }
  902. /// <summary>
  903. /// 清空日志控件内容
  904. /// </summary>
  905. private void ClearContrlsContent()
  906. {
  907. try
  908. {
  909. if (ucLog != null)
  910. {
  911. if (ucLog.dgvLog != null)
  912. {
  913. if (ucLog.dgvLog.Rows.Count > 0)
  914. {
  915. ucLog.dgvLog.Rows.Clear();
  916. }
  917. }
  918. }
  919. if (listmsg != null)
  920. {
  921. if (listmsg.Items.Count > 0)
  922. {
  923. listmsg.Items.Clear();
  924. }
  925. }
  926. }
  927. catch (Exception ex)
  928. {
  929. log.Error(ex.Message);
  930. }
  931. }
  932. #endregion
  933. #region 测试修改切孔中流程状态
  934. private void button1_Click(object sender, EventArgs e)
  935. {
  936. if (plPrarInfo.Controls.Count > 0)
  937. {
  938. string name = textBox1.Text;
  939. string code = textBox2.Text;
  940. bool state = Convert.ToBoolean(comboBox1.Text);
  941. foreach (Control item in plPrarInfo.Controls)
  942. {
  943. if (item is UserControl)
  944. {
  945. if (item.Name == name)
  946. {
  947. UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
  948. TimeLineItem[] ParaItem = uControl_ParaInfo.TlItem;
  949. foreach (TimeLineItem tlItem in ParaItem)
  950. {
  951. if (tlItem.Code == code)
  952. {
  953. tlItem.State = Convert.ToInt32(state);
  954. break;
  955. }
  956. }
  957. uControl_ParaInfo.TimeLineInvalidate();
  958. break;
  959. }
  960. }
  961. }
  962. }
  963. }
  964. #endregion
  965. private void FormHOZMain_Resize(object sender, EventArgs e)
  966. {
  967. plMain.Left = 2;
  968. plMain.Top = 2;
  969. plMain.Width = this.Width - 4;
  970. plMain.Height = this.Height - 4;
  971. plFill.Width = plMain.Width - plLeft.Width - 4;
  972. plFill.Height = plMain.Height - plTop.Height - 4;
  973. plFill.Left = plLeft.Width + 4;
  974. plFill.Top = plTop.Height + 4;
  975. if(this.WindowState!= FormWindowState.Maximized)
  976. {
  977. plPrarInfo.Height = 505;
  978. foreach (Control item in plPrarInfo.Controls)
  979. {
  980. if (item is UserControl)
  981. {
  982. if(item.Height>505)
  983. {
  984. item.Height = 505;
  985. }
  986. }
  987. }
  988. }
  989. }
  990. private void FormHOZMain_Paint(object sender, PaintEventArgs e)
  991. {
  992. }
  993. private void ConfigurationParameter()
  994. {
  995. #region 初始化参数的默认值
  996. // add by zjx 2020-12-20 厂商参数
  997. //m_MeasureFile.MParam.VendorType0 = Convert.ToString(ConfigurationManager.AppSettings["VendorType0"]);
  998. //m_MeasureFile.MParam.VendorType1 = Convert.ToString(ConfigurationManager.AppSettings["VendorType1"]);
  999. //m_MeasureFile.MParam.VendorType2 = Convert.ToString(ConfigurationManager.AppSettings["VendorType2"]);
  1000. //m_MeasureFile.MParam.VendorType3 = Convert.ToString(ConfigurationManager.AppSettings["VendorType3"]);
  1001. // add by zjx 2020-12-20 厂商参数 end
  1002. // add by zjx 2020-12-21 校正角度
  1003. m_MeasureFile.MParam.CorrectionType0 = Convert.ToString(ConfigurationManager.AppSettings["CorrectionType0"]);
  1004. m_MeasureFile.MParam.CorrectionType1 = Convert.ToString(ConfigurationManager.AppSettings["CorrectionType1"]);
  1005. m_MeasureFile.MParam.CorrectionType2 = Convert.ToString(ConfigurationManager.AppSettings["CorrectionType2"]);
  1006. m_MeasureFile.MParam.CorrectionType3 = Convert.ToString(ConfigurationManager.AppSettings["CorrectionType3"]);
  1007. // add by zjx 2020-12-21 校正角度 end
  1008. // add by zjx 2020-12-21 拉直操作放大倍数
  1009. m_MeasureFile.MParam.StraightenTimesType0 = Convert.ToString(ConfigurationManager.AppSettings["StraightenTimesType0"]);
  1010. m_MeasureFile.MParam.StraightenTimesType1 = Convert.ToString(ConfigurationManager.AppSettings["StraightenTimesType1"]);
  1011. m_MeasureFile.MParam.StraightenTimesType2 = Convert.ToString(ConfigurationManager.AppSettings["StraightenTimesType2"]);
  1012. m_MeasureFile.MParam.StraightenTimesType3 = Convert.ToString(ConfigurationManager.AppSettings["StraightenTimesType3"]);
  1013. // add by zjx 2020-12-21 拉直操作放大倍数 end
  1014. // add by zjx 2020-12-21 定位电压
  1015. m_MeasureFile.MParam.PositioningVoltageeType0 = Convert.ToString(ConfigurationManager.AppSettings["PositioningVoltageeType0"]);
  1016. m_MeasureFile.MParam.PositioningVoltageeType1 = Convert.ToString(ConfigurationManager.AppSettings["PositioningVoltageeType1"]);
  1017. m_MeasureFile.MParam.PositioningVoltageeType2 = Convert.ToString(ConfigurationManager.AppSettings["PositioningVoltageeType2"]);
  1018. m_MeasureFile.MParam.PositioningVoltageeType3 = Convert.ToString(ConfigurationManager.AppSettings["PositioningVoltageeType3"]);
  1019. // add by zjx 2020-12-21 定位电压 end
  1020. // add by zjx 2020-12-21 定位放大倍数
  1021. m_MeasureFile.MParam.PositioningTimesType0 = Convert.ToString(ConfigurationManager.AppSettings["PositioningTimesType0"]);
  1022. m_MeasureFile.MParam.PositioningTimesType1 = Convert.ToString(ConfigurationManager.AppSettings["PositioningTimesType1"]);
  1023. m_MeasureFile.MParam.PositioningTimesType2 = Convert.ToString(ConfigurationManager.AppSettings["PositioningTimesType2"]);
  1024. m_MeasureFile.MParam.PositioningTimesType3 = Convert.ToString(ConfigurationManager.AppSettings["PositioningTimesType3"]);
  1025. // add by zjx 2020-12-21 定位放大倍数 end
  1026. // add by zjx 2020-12-21 拍照电压
  1027. m_MeasureFile.MParam.PhotoVoltageeType0 = Convert.ToString(ConfigurationManager.AppSettings["PhotoVoltageeType0"]);
  1028. m_MeasureFile.MParam.PhotoVoltageeType1 = Convert.ToString(ConfigurationManager.AppSettings["PhotoVoltageeType1"]);
  1029. m_MeasureFile.MParam.PhotoVoltageeType2 = Convert.ToString(ConfigurationManager.AppSettings["PhotoVoltageeType2"]);
  1030. m_MeasureFile.MParam.PhotoVoltageeType3 = Convert.ToString(ConfigurationManager.AppSettings["PhotoVoltageeType3"]);
  1031. // add by zjx 2020-12-21 拍照电压 end
  1032. // add by zjx 2020-12-21 拍照放大倍数
  1033. m_MeasureFile.MParam.PhotoTimesType0 = Convert.ToString(ConfigurationManager.AppSettings["PhotoTimesType0"]);
  1034. m_MeasureFile.MParam.PhotoTimesType1 = Convert.ToString(ConfigurationManager.AppSettings["PhotoTimesType1"]);
  1035. m_MeasureFile.MParam.PhotoTimesType2 = Convert.ToString(ConfigurationManager.AppSettings["PhotoTimesType2"]);
  1036. m_MeasureFile.MParam.PhotoTimesType3 = Convert.ToString(ConfigurationManager.AppSettings["PhotoTimesType3"]);
  1037. // add by zjx 2020-12-21 拍照放大倍数 end
  1038. // add by zjx 2020-12-21 ScanRotate修正参数
  1039. m_MeasureFile.MParam.ScanRotateType0 = Convert.ToString(ConfigurationManager.AppSettings["ScanRotateType0"]);
  1040. m_MeasureFile.MParam.ScanRotateType1 = Convert.ToString(ConfigurationManager.AppSettings["ScanRotateType1"]);
  1041. m_MeasureFile.MParam.ScanRotateType2 = Convert.ToString(ConfigurationManager.AppSettings["ScanRotateType2"]);
  1042. m_MeasureFile.MParam.ScanRotateType3 = Convert.ToString(ConfigurationManager.AppSettings["ScanRotateType3"]);
  1043. // add by zjx 2020-12-21 ScanRotate修正参数 end
  1044. // add by zjx 2020-12-21 Y轴方向PixelSize修正值
  1045. m_MeasureFile.MParam.PixelSizeType0 = Convert.ToString(ConfigurationManager.AppSettings["PixelSizeType0"]);
  1046. m_MeasureFile.MParam.PixelSizeType1 = Convert.ToString(ConfigurationManager.AppSettings["PixelSizeType1"]);
  1047. m_MeasureFile.MParam.PixelSizeType2 = Convert.ToString(ConfigurationManager.AppSettings["PixelSizeType2"]);
  1048. m_MeasureFile.MParam.PixelSizeType3 = Convert.ToString(ConfigurationManager.AppSettings["PixelSizeType3"]);
  1049. // add by zjx 2020-12-21 Y轴方向PixelSize修正值 end
  1050. // add by zjx 2020-12-21 能谱Z轴移动位置
  1051. m_MeasureFile.MParam.SEMAxis_ZType0 = Convert.ToString(ConfigurationManager.AppSettings["SEMAxis_ZType0"]);
  1052. m_MeasureFile.MParam.SEMAxis_ZType1 = Convert.ToString(ConfigurationManager.AppSettings["SEMAxis_ZType1"]);
  1053. m_MeasureFile.MParam.SEMAxis_ZType2 = Convert.ToString(ConfigurationManager.AppSettings["SEMAxis_ZType2"]);
  1054. m_MeasureFile.MParam.SEMAxis_ZType3 = Convert.ToString(ConfigurationManager.AppSettings["SEMAxis_ZType3"]);
  1055. // add by zjx 2020-12-21 能谱Z轴移动位置 end
  1056. // add by zjx 2020-12-21 能谱电压值
  1057. m_MeasureFile.MParam.SEMVoltageeType0 = Convert.ToString(ConfigurationManager.AppSettings["SEMVoltageeType0"]);
  1058. m_MeasureFile.MParam.SEMVoltageeType1 = Convert.ToString(ConfigurationManager.AppSettings["SEMVoltageeType1"]);
  1059. m_MeasureFile.MParam.SEMVoltageeType2 = Convert.ToString(ConfigurationManager.AppSettings["SEMVoltageeType2"]);
  1060. m_MeasureFile.MParam.SEMVoltageeType3 = Convert.ToString(ConfigurationManager.AppSettings["SEMVoltageeType3"]);
  1061. // add by zjx 2020-12-21 能谱电压值 end
  1062. // add by zjx 2020-12-21 能谱电流值
  1063. m_MeasureFile.MParam.SEMCurrentType0 = Convert.ToString(ConfigurationManager.AppSettings["SEMCurrentType0"]);
  1064. m_MeasureFile.MParam.SEMCurrentType1 = Convert.ToString(ConfigurationManager.AppSettings["SEMCurrentType1"]);
  1065. m_MeasureFile.MParam.SEMCurrentType2 = Convert.ToString(ConfigurationManager.AppSettings["SEMCurrentType2"]);
  1066. m_MeasureFile.MParam.SEMCurrentType3 = Convert.ToString(ConfigurationManager.AppSettings["SEMCurrentType3"]);
  1067. // add by zjx 2020-12-21 能谱电流值 end
  1068. #endregion
  1069. }
  1070. private void FormHOZMain_FormClosing(object sender, FormClosingEventArgs e)
  1071. {
  1072. if (m_Ms != null)
  1073. {
  1074. if (m_Ms.iExtender != null)
  1075. {
  1076. m_Ms.iExtender.CloseExtender();
  1077. }
  1078. }
  1079. }
  1080. private void FormHOZMain_LocationChanged(object sender, EventArgs e)
  1081. {
  1082. if (logwin != null)
  1083. {
  1084. logwin.Left = this.Left-logwin.Width;
  1085. logwin.Top = this.Top;
  1086. }
  1087. }
  1088. }
  1089. }