FormHOZMain.cs 57 KB

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