FormHOZMain.cs 56 KB

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