RemoveError.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace AGV_WPF
  10. {
  11. public partial class RemoveError : Form
  12. {
  13. public List<Button> listCreateBtns = new List<Button>();
  14. public RemoveError()
  15. {
  16. InitializeComponent();
  17. }
  18. private void RemoveError_Load(object sender, EventArgs e)
  19. {
  20. }
  21. public void InitView(Dictionary<int, int> AGVIDWithPosByCheckPos, Dictionary<int, int> AGVIDWithRouteByCheckPos, Dictionary<int, string> checkPosDic)
  22. {
  23. for (int i = groupBox1.Controls.Count-1; i >=0; i--)
  24. {
  25. if (groupBox1.Controls[i].Name != label1.Name && groupBox1.Controls[i].Name != button1.Name)
  26. {
  27. groupBox1.Controls.RemoveAt(i);
  28. }
  29. }
  30. listCreateBtns.Clear();
  31. if (AGVIDWithPosByCheckPos.Count > 0)
  32. {
  33. List<int> listAGV = AGVIDWithPosByCheckPos.Keys.ToList();
  34. int index = 0;
  35. foreach (int agvNum in listAGV)
  36. {
  37. if (AGVIDWithPosByCheckPos.ContainsKey(agvNum)&&AGVIDWithRouteByCheckPos.ContainsKey(agvNum))
  38. {
  39. Label label = new Label();
  40. string str = "AGV编号:" + agvNum + ",目的地标:" + AGVIDWithPosByCheckPos[agvNum] + ",目的路线:"+ AGVIDWithRouteByCheckPos[agvNum];
  41. label.Text = str;
  42. label.Font = label2.Font;
  43. label.AutoSize=true;
  44. label.Location = new Point(label2.Location.X,label2.Location.Y+index*(label.Height+30));
  45. groupBox1.Controls.Add(label);
  46. Button btn = new Button();
  47. btn.Text = "解除";
  48. btn.Font = btn.Font;
  49. btn.Tag = agvNum;
  50. btn.Location = new Point(label.Location.X + label.Width + 30, label.Location.Y - 5);
  51. groupBox1.Controls.Add(btn);
  52. listCreateBtns.Add(btn);
  53. ++index;
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }