FormHOZMain.cs 56 KB

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