OTSSolutionWindow.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using OTS.WinFormsUI.Docking;
  6. using System.Runtime.InteropServices;
  7. using System.IO;
  8. using System.Collections;
  9. using OTSDataType;
  10. namespace OTSMeasureApp
  11. {
  12. public partial class OTSSolutionWindow : DockContent
  13. {
  14. public String m_DefaultSolutionName = "未加载样品名";
  15. public String m_DefaultSampleName = "样品";
  16. public OTSIncAMeasureAppForm m_MeasureAppForm = null;
  17. public OTSDisplayTreeBase m_TreeViewBase = null;
  18. //工作样品节点
  19. public TreeNode m_WorkSampleNode = null;
  20. // 设置工作样品是否成功
  21. public bool m_bSetWorkSampleFlag = false;
  22. public List<OTSSampleVisualPropertyInfo> m_TreeSampleInfoList = new List<OTSSampleVisualPropertyInfo>(); //保存Treeview所有样品节点信息
  23. //当前工作样品名
  24. public String m_WorkSampleName = "";
  25. //工作样品属性参数
  26. public CTreeSampleParam m_WorkSampleParam = new CTreeSampleParam();
  27. //国际化
  28. OTSCommon.Language lan;
  29. Hashtable table;
  30. NLog.Logger log;
  31. public OTSSolutionWindow(OTSIncAMeasureAppForm MeasureAppForm)
  32. {
  33. InitializeComponent();
  34. m_MeasureAppForm = MeasureAppForm;
  35. m_TreeViewBase = new OTSDisplayTreeBase(this);
  36. //国际化
  37. lan = new OTSCommon.Language(this);
  38. table = lan.GetNameTable(this.Name);
  39. m_DefaultSolutionName = table["m_defaultsolutionname"].ToString();
  40. m_DefaultSampleName = table["m_defaultsamplename"].ToString();
  41. }
  42. private void OTSSolutionWindow_Load(object sender, EventArgs e)
  43. {
  44. //TreeView可编辑状态。
  45. treeView1.LabelEdit = true;
  46. this.treeView1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
  47. log = NLog.LogManager.GetCurrentClassLogger();
  48. }
  49. public void Rev_SoluWindow_SampleSortOrder_Event()
  50. {
  51. m_TreeViewBase.SortTreeNodeList();
  52. }
  53. public void DisplayExistSampleFile(List<CTreeSampleParam> TSampleParamList, CTreeSampleParam WorkSampleParam)
  54. {
  55. this.m_TreeViewBase.DisplayTreeViewData(TSampleParamList, WorkSampleParam);
  56. }
  57. public void SwitchSample(string sNewWorkSample)
  58. {
  59. m_TreeViewBase.SwitchWorkSample(sNewWorkSample);
  60. }
  61. public void AddSampleMeasure(CTreeSampleParam TSampleParam)
  62. {
  63. m_WorkSampleParam = TSampleParam;
  64. m_TreeViewBase.DisplayWorkSampleTree(m_WorkSampleParam);
  65. }
  66. public void DeletCurrentSampleNode()
  67. {
  68. treeView1.Nodes.Remove(m_WorkSampleNode); //移除当前工作样品
  69. }
  70. public void DisplaySample(string sDeletSName)
  71. {
  72. if ("" == sDeletSName)
  73. {
  74. return;
  75. }
  76. //重新获取Treeview上的工作样品节点
  77. this.m_TreeViewBase.GetTreeWorkSampleNode(sDeletSName);
  78. //设置工作样品焦点
  79. this.m_TreeViewBase.ReSetWorkSampleFoucs();
  80. }
  81. public void Rev_MeasureApp_CheckboxStatuChange_Event(string sSampleName, bool bCheckBoxStatu)
  82. {
  83. m_TreeViewBase.SetSampleCheckboxStatu(sSampleName, bCheckBoxStatu);
  84. }
  85. public void Rev_MeasureApp_EditEditSample_Event(string sSampleOldName, string sSampleNewName)
  86. {
  87. if (sSampleNewName == "") //修改的样品新名称为空,则说明不允许修改
  88. {
  89. return;
  90. }
  91. m_TreeViewBase.EditTreeNodeSampleName(sSampleOldName, sSampleNewName);
  92. }
  93. bool bChangeNodeTextFlag = false;
  94. private void ChangeNodeText(TreeNode node, string sOldSName, string sNewSName)
  95. {
  96. // result.Add(node.Text);
  97. if (node.IsSelected)
  98. {
  99. if (node.Text == sOldSName)
  100. {
  101. node.Text = sNewSName;
  102. node.Text = " ";
  103. bChangeNodeTextFlag = true;
  104. }
  105. return;
  106. }
  107. if (node.Nodes.Count != 0)
  108. {
  109. for (int i = 0; i < node.Nodes.Count; i++)
  110. {
  111. if (!bChangeNodeTextFlag)
  112. {
  113. ChangeNodeText(node.Nodes[i], sOldSName, sNewSName);
  114. }
  115. }
  116. }
  117. }
  118. //删除测量样品
  119. string csCheckNodeName = "";
  120. public void DeleteNode_Click(object sender, EventArgs e)
  121. {
  122. if (m_bSetWorkSampleFlag) //设置工作样品成功,并可以删除当前工作样品
  123. {
  124. string sDeleteSampleName = table["message1"].ToString();
  125. sDeleteSampleName += m_WorkSampleNode.Text;
  126. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Tip", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  127. {
  128. //删除样品成功
  129. m_MeasureAppForm.DeleteSample(m_WorkSampleNode.Text);
  130. //选择节点
  131. m_WorkSampleName = m_MeasureAppForm.m_ProjParam.GetWorkSampleName();
  132. m_TreeViewBase.GetTreeWorkSampleNode(m_WorkSampleName);
  133. //删除时重新初始化结果窗体结果
  134. m_MeasureAppForm.m_MeasureResultWindow.SetInit();
  135. }
  136. }
  137. }
  138. //sOldSName: 修改样品的原名称
  139. //sNewSName: 修改样品的新名称
  140. private void GetNodeText(TreeNode node)
  141. {
  142. if (node.Checked)
  143. {
  144. csCheckNodeName = node.Text;
  145. return;
  146. }
  147. if (node.Nodes.Count != 0)
  148. {
  149. for (int i = 0; i < node.Nodes.Count; i++)
  150. {
  151. if (csCheckNodeName == "")
  152. {
  153. GetNodeText(node.Nodes[i]);
  154. }
  155. }
  156. }
  157. }
  158. //左键
  159. private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
  160. {
  161. //鼠标选中
  162. if (e.Action == TreeViewAction.ByMouse || e.Action == TreeViewAction.ByKeyboard)
  163. {
  164. if (e.Node.IsSelected)
  165. {
  166. //判断的选中的CHECKBOX和焦点都在当前被选择的节点上,切换当前工作样品
  167. m_WorkSampleNode = e.Node;
  168. treeView1.SelectedNode = e.Node; //当前被选中
  169. // OTSSolutionWindow窗口给MeasureApp窗口发送改变工作样品请求
  170. treeView1.Refresh();
  171. string sWorkName = m_MeasureAppForm.m_ProjParam.GetWorkSampleName();
  172. if ("" != sWorkName && (sWorkName != e.Node.Text))
  173. {
  174. SwitchSample(e.Node.Text);
  175. }
  176. }
  177. }
  178. }
  179. //当Checkbox的状态发生变化时,响应事件
  180. private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
  181. {
  182. if (e.Action == TreeViewAction.ByMouse || e.Action == TreeViewAction.ByKeyboard)
  183. {
  184. // 切换工作样品
  185. string sWorkName = m_MeasureAppForm.m_ProjParam.GetWorkSampleName();
  186. if ("" != sWorkName && (sWorkName != e.Node.Text))
  187. {
  188. m_MeasureAppForm.SwitchWSample(e.Node.Text);
  189. }
  190. m_MeasureAppForm.SoluWindowCheckBoxStatuChange(e.Node.Text, e.Node.Checked);
  191. }
  192. }
  193. private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
  194. {
  195. e.DrawDefault = true;
  196. }
  197. [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)]
  198. private struct TVITEM
  199. {
  200. public int mask;
  201. public IntPtr hItem;
  202. public int state;
  203. public int stateMask;
  204. [MarshalAs(UnmanagedType.LPTStr)]
  205. public string lpszText;
  206. public int cchTextMax;
  207. public int iImage;
  208. public int iSelectedImage; public int cChildren; public IntPtr lParam;
  209. }
  210. //只选择子类的复选框
  211. //需要将样品测量参数编辑锁的属性 CheckOnClick 设置为True
  212. private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  213. {
  214. NodeMouseClick(e);
  215. }
  216. protected void NodeMouseClick(TreeNodeMouseClickEventArgs e)
  217. {
  218. TreeNode tn = (TreeNode)e.Node;
  219. m_MeasureAppForm.SwitchWSample(tn.Text);
  220. //切换工作样品,通知Grid更新工作样品属性值
  221. m_bSetWorkSampleFlag = true;
  222. m_WorkSampleNode = tn;
  223. if (e.Button == MouseButtons.Right)//判断按下鼠标右键
  224. {
  225. Point ClickPoint = new Point(e.X, e.Y);
  226. TreeNode CurrentNode = treeView1.GetNodeAt(ClickPoint);
  227. bool bLockStatu = false;
  228. //获取样品节点的测量参数锁状态
  229. if (!m_TreeViewBase.GetSampleNodeLockStatu(ref bLockStatu))
  230. {
  231. log.Error("(OTSSolutionWindow.treeView1_NodeMouseClick ) m_TreeViewBase.GetSampleNodeLockStatu(m_WorkSampleNode, ref bLockStatu) = false Failed !");
  232. }
  233. //SampleParaLock.Checked = bLockStatu;
  234. //显示清除测量数据
  235. COTSSample cSample = m_MeasureAppForm.m_ProjParam.GetWorkSample();
  236. if (cSample.GetName() == tn.Text)
  237. {
  238. ClearMeasureData.Visible = false;
  239. }
  240. CurrentNode.ContextMenuStrip = RightClickCheckContextMenuStrip;
  241. }
  242. //通过样品名称获取
  243. m_MeasureAppForm.m_MeasureResultWindow.UpdateResultInfoBySampleName(m_WorkSampleNode.Text);
  244. }
  245. //Treeview增加测量样品节点
  246. public void toolStripMenuItem1_AddNode_Click(object sender, EventArgs e)
  247. {
  248. m_MeasureAppForm.SoluwindowReqAddSample();
  249. }
  250. private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
  251. {
  252. if (null == e.Node.Parent)
  253. {
  254. e.CancelEdit = true;
  255. return;
  256. }
  257. //修改样品名称
  258. String csNewSampleName = e.Label; //获取新文本
  259. string csOldSampleName = e.Node.Text;//获取原来的文本
  260. if (null == csNewSampleName) //没有修改样品名 或者 样品名为空
  261. {
  262. e.CancelEdit = true;
  263. return;
  264. }
  265. //样品名为空
  266. if ("" == csNewSampleName)
  267. {
  268. e.CancelEdit = true;
  269. return;
  270. }
  271. string csNSName = csNewSampleName;
  272. //去除字符串首尾空格
  273. csNSName = csNSName.Trim();
  274. if (0 == csNSName.Length)
  275. {
  276. e.CancelEdit = true;
  277. return;
  278. }
  279. if (!m_MeasureAppForm.EditWorkSampleName(csOldSampleName, csNSName))
  280. {
  281. e.CancelEdit = true;
  282. }
  283. else
  284. {
  285. if (" " == csNewSampleName.Substring(0, 1) || " " == csNewSampleName.Substring(csNewSampleName.Length - 1, 1))
  286. {
  287. e.CancelEdit = true;
  288. Rev_MeasureApp_EditEditSample_Event(csOldSampleName, csNSName);
  289. }
  290. else
  291. {
  292. e.Node.EndEdit(false);
  293. }
  294. }
  295. }
  296. //控制显示右键系统菜单
  297. bool IsShowSysContextMenu = true;
  298. //修改选定的样品名的名字
  299. private void treeView1_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
  300. {
  301. if (null == e.Node.Parent)
  302. {
  303. e.Node.EndEdit(false);
  304. e.CancelEdit = true;
  305. return;
  306. }
  307. //限制鼠标右键显示
  308. IsShowSysContextMenu = false;
  309. }
  310. private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
  311. {
  312. if (null != e.Node.Parent)
  313. {
  314. e.Node.BeginEdit(); //进入修改状态
  315. return;
  316. }
  317. //禁止修改UTILITYED
  318. e.Node.EndEdit(false);
  319. }
  320. // 清除样品测量数据
  321. private void ClearSampleMeasureData_Click(object sender, EventArgs e)
  322. {
  323. if (m_bSetWorkSampleFlag) //设置工作样品成功,并可以删除当前工作样品
  324. {
  325. string sDeleteSampleName = table["message1"].ToString();
  326. sDeleteSampleName += m_WorkSampleNode.Text;
  327. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Tip", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  328. {
  329. //1.删除样品测量信息
  330. string mPathName = m_MeasureAppForm.m_ProjParam.GetResultData().GetPathName();
  331. string smPathName = mPathName.Substring(0, mPathName.LastIndexOf("\\"))+"\\" + m_WorkSampleNode.Text;
  332. if (DeleteFile(smPathName))
  333. {
  334. var sam= m_MeasureAppForm.m_ProjParam.GetResultData().GetSampleByName(m_WorkSampleNode.Text);
  335. sam.GetMsrStatus().ClearCompletedFieldsInfo();
  336. sam.ClearFields();
  337. sam.GetMsrStatus().SetStatus(OTS_MSR_SAMPLE_STATUS.UNMEASURED);
  338. //保存测量文件
  339. m_MeasureAppForm.m_ProjParam.GetResultData().Save();
  340. //重新打开文件
  341. }
  342. }
  343. }
  344. MessageBox.Show("The sample data has been cleared!");
  345. ClearMeasureData.Visible = false;
  346. }
  347. /// <summary>
  348. /// 根据路径删除文件
  349. /// </summary>
  350. /// <param name="path"></param>
  351. public bool DeleteFile(string path)
  352. {
  353. try
  354. {
  355. //去除文件夹和子文件的只读属性
  356. //去除文件夹的只读属性
  357. System.IO.DirectoryInfo fileInfo = new DirectoryInfo(path);
  358. fileInfo.Attributes = FileAttributes.Normal & FileAttributes.Directory;
  359. //去除文件的只读属性
  360. System.IO.File.SetAttributes(path, System.IO.FileAttributes.Normal);
  361. //判断文件夹是否还存在
  362. if (Directory.Exists(path))
  363. {
  364. foreach (string f in Directory.GetFileSystemEntries(path))
  365. {
  366. if (File.Exists(f))
  367. {
  368. using (FileStream fileStream = new FileStream(f, FileMode.Open, FileAccess.ReadWrite,FileShare.Delete))
  369. {
  370. int byteLength = (int)fileStream.Length;
  371. byte[] fileBytes = new byte[byteLength];
  372. fileStream.Read(fileBytes, 0, byteLength);
  373. //文件流关闭,文件解除锁定
  374. fileStream.Close();
  375. //如果有子文件删除文件
  376. File.SetAttributes(f, FileAttributes.Normal);
  377. File.Delete(f);
  378. }
  379. }
  380. else
  381. {
  382. //循环递归删除子文件夹
  383. DeleteFile(f);
  384. }
  385. }
  386. }
  387. return true;
  388. }
  389. catch (Exception ex) // 异常处理
  390. {
  391. return false;
  392. }
  393. }
  394. //设置样品参数锁
  395. //private void SampleParaLock_Click(object sender, EventArgs e)
  396. //{
  397. // m_TreeViewBase.SetSampleParaLockStatu();
  398. //}
  399. private void treeView1_MouseDown(object sender, MouseEventArgs e)
  400. {
  401. if (e.Button == MouseButtons.Right)
  402. {
  403. if (!IsShowSysContextMenu)
  404. {
  405. return;
  406. }
  407. }
  408. }
  409. // treeView1_ItemDrag treeView1_ItemDrag treeView1_DragDrop ,treeView1_DragOver 四个事件函数是实现节点鼠标拖动移动的。另外需要将 Treeview控件属性 AllowDrop 设置为True
  410. private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
  411. {
  412. // Move the dragged node when the left mouse button is used.
  413. if (e.Button == MouseButtons.Left)
  414. {
  415. DoDragDrop(e.Item, DragDropEffects.Move);
  416. }
  417. // Copy the dragged node when the right mouse button is used.
  418. else if (e.Button == MouseButtons.Right)
  419. {
  420. DoDragDrop(e.Item, DragDropEffects.Copy);
  421. }
  422. }
  423. private void treeView1_DragEnter(object sender, DragEventArgs e)
  424. {
  425. e.Effect = e.AllowedEffect;
  426. }
  427. private void treeView1_DragDrop(object sender, DragEventArgs e)
  428. {
  429. //获得拖放中的节点
  430. TreeNode moveNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
  431. //设置拖动节点为工作样品节点
  432. string sWSampleName = moveNode.Text;
  433. if ("" == sWSampleName)
  434. {
  435. log.Error("(OTSSolutionWindow.treeView1_DragDrop ) moveNode.Text = null Failed !");
  436. return;
  437. }
  438. //将拖动样品设置为工作样品
  439. if (!m_MeasureAppForm.m_ProjParam.SetWorkSample(moveNode.Text))
  440. {
  441. log.Error("(OTSSolutionWindow.treeView1_DragDrop ) m_MeasureAppForm.SetWorkSample(moveNode.Text) = false Failed !");
  442. return;
  443. }
  444. //m_MeasureAppForm.m_EventFun.Send_SwithcWSample_SoluWindowReqMeasureApp_Event_Fun(moveNode.Text);
  445. SwitchSample(moveNode.Text);
  446. //根据鼠标坐标确定要移动到的目标节点
  447. Point pt;
  448. TreeNode targeNode;
  449. pt = ((TreeView)(sender)).PointToClient(new Point(e.X, e.Y));
  450. targeNode = this.treeView1.GetNodeAt(pt);
  451. //如果未获取到节点信息 则return
  452. if (targeNode == null)
  453. {
  454. treeView1.SelectedNode = moveNode;
  455. //m_MeasureAppForm.m_EventFun.Send_SwithcWSample_SoluWindowReqMeasureApp_Event_Fun(moveNode.Text);
  456. SwitchSample(moveNode.Text);
  457. return;
  458. }
  459. //如果目标节点无子节点则添加为同级节点,反之添加到下级节点的未端
  460. TreeNode NewMoveNode = (TreeNode)moveNode.Clone();
  461. if (targeNode != null)
  462. {
  463. if (targeNode.Nodes.Count == 0)
  464. {
  465. if (moveNode.Index > targeNode.Index)
  466. {
  467. treeView1.Nodes.Insert(targeNode.Index, NewMoveNode);
  468. }
  469. else
  470. {
  471. if (targeNode.Index + 1 == treeView1.Nodes.Count)
  472. {
  473. treeView1.Nodes.Add(NewMoveNode);
  474. }
  475. else
  476. {
  477. treeView1.Nodes.Insert(targeNode.Index+1, NewMoveNode);
  478. }
  479. }
  480. }
  481. else
  482. {
  483. // targeNode.Nodes.Insert(targeNode.Nodes.Count, NewMoveNode);
  484. return;
  485. }
  486. //更新当前拖动的节点选择
  487. treeView1.SelectedNode = NewMoveNode;
  488. //展开目标节点,便于显示拖放效果
  489. targeNode.Expand();
  490. //移除拖放的节点
  491. moveNode.Remove();
  492. }
  493. else
  494. {
  495. if (moveNode.Parent != null)
  496. {
  497. moveNode.Parent.Nodes.Add(NewMoveNode);
  498. //移除拖放的节点
  499. moveNode.Remove();
  500. }
  501. }
  502. //节点位置移动后,TreeNodeList里的节点位置也应该发生变动
  503. // m_TreeViewBase.SortTreeNodeList();
  504. Rev_SoluWindow_SampleSortOrder_Event();
  505. }
  506. // Select the node under the mouse pointer to indicate the
  507. // expected drop location.
  508. private void treeView1_DragOver(object sender, DragEventArgs e)
  509. {
  510. //获得拖放中的节点
  511. //TreeNode moveNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
  512. // Retrieve the client coordinates of the mouse position.
  513. Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
  514. // Select the node at the mouse position.
  515. treeView1.SelectedNode = treeView1.GetNodeAt(targetPoint);
  516. // m_MeasureAppForm.m_EventFun.Send_SwithcWSample_SoluWindowReqMeasureApp_Event_Fun(moveNode.Text);
  517. }
  518. //拖动窗口移动响应事件
  519. private void OTSSolutionWindow_Move(object sender, EventArgs e)
  520. {
  521. }
  522. private void OTSSolutionWindow_Paint(object sender, PaintEventArgs e)
  523. {
  524. m_TreeViewBase.ReSetWorkSampleFoucs();
  525. }
  526. protected override void WndProc(ref Message m)
  527. {
  528. if (m.Msg != 0x007B)
  529. {
  530. base.WndProc(ref m);
  531. }
  532. }
  533. private void OTSSolutionWindow_SizeChanged(object sender, EventArgs e)
  534. {
  535. treeView1.Width = this.Width;
  536. }
  537. /// <summary>
  538. /// 屏蔽TreeView方向键
  539. /// </summary>
  540. /// <param name="sender"></param>
  541. /// <param name="e"></param>
  542. private void treeView1_KeyDown(object sender, KeyEventArgs e)
  543. {
  544. try
  545. {
  546. TreeView tv = (TreeView)sender;
  547. //获取子节点的总数
  548. int nodeAllCount = treeView1.Nodes[0].Nodes.Count;
  549. //当前选择节点的索引位置
  550. int currentNodeIndex = 0;
  551. currentNodeIndex = tv.SelectedNode.Index;
  552. switch (e.KeyCode)
  553. {
  554. case Keys.Up:
  555. if (currentNodeIndex == 0)
  556. {
  557. e.Handled = true;
  558. }
  559. else
  560. {
  561. for (int i = 0; i < treeView1.Nodes[0].Nodes.Count; i++)
  562. {
  563. if (i == currentNodeIndex)
  564. {
  565. treeView1.SelectedNode = treeView1.Nodes[0].Nodes[currentNodeIndex];
  566. //通过样品名称获取
  567. m_MeasureAppForm.m_MeasureResultWindow.UpdateResultInfoBySampleName(treeView1.Nodes[0].Nodes[currentNodeIndex - 1].Text);
  568. break;
  569. }
  570. }
  571. }
  572. break;
  573. case Keys.Down:
  574. if (nodeAllCount == currentNodeIndex + 1)
  575. {
  576. e.Handled = true;
  577. }
  578. else
  579. {
  580. for (int i = 0; i < treeView1.Nodes[0].Nodes.Count; i++)
  581. {
  582. if (i == currentNodeIndex)
  583. {
  584. treeView1.SelectedNode = treeView1.Nodes[0].Nodes[currentNodeIndex];
  585. //通过样品名称获取
  586. m_MeasureAppForm.m_MeasureResultWindow.UpdateResultInfoBySampleName(treeView1.Nodes[0].Nodes[currentNodeIndex + 1].Text);
  587. break;
  588. }
  589. }
  590. }
  591. break;
  592. case Keys.Left:
  593. e.Handled = true;
  594. break;
  595. case Keys.Right:
  596. e.Handled = true;
  597. break;
  598. }
  599. m_MeasureAppForm.m_SamplepaceWindow.OTSSamplespaceWindow_KeyDown(sender, e);
  600. }
  601. catch (Exception)
  602. {
  603. }
  604. }
  605. private void treeView1_KeyUp(object sender, KeyEventArgs e)
  606. {
  607. m_MeasureAppForm.m_SamplepaceWindow.KeyUps();
  608. }
  609. private void reClassifyToolStripMenuItem_Click(object sender, EventArgs e)
  610. {
  611. }
  612. }
  613. }