FormHOZMain.cs 57 KB

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