FormHOZMain.cs 56 KB

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