ZMForm.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using IntelligentControlForsx.Template;
  11. using IntelligentControlForsx.MyControls.zm;
  12. using IntelligentControlForsx.Service;
  13. namespace IntelligentControlForsx.ChildForms
  14. {
  15. public partial class ZMForm : TemplateForm
  16. {
  17. ZMControl zmControl = null;
  18. string currentStationID = "";
  19. public ZMForm()
  20. {
  21. InitializeComponent();
  22. Init();
  23. SetStyle(ControlStyles.UserPaint, true);
  24. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.  
  25. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲  
  26. this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  27. this.UpdateStyles();
  28. }
  29. private void Init()
  30. {
  31. if (currentStationID == NavService.Instance.StationId)
  32. {
  33. return;
  34. }
  35. this.Controls.Clear();// 要么clear掉,要么放在字典中隐藏
  36. switch (NavService.Instance.StationId)
  37. {
  38. case "NSS_FDC"://牛首山
  39. {
  40. zmControl = new ZM_NSS();
  41. this.Text = "牛首山总貌";
  42. }
  43. break;
  44. case "SBQ_FDC"://石板泉
  45. {
  46. zmControl = new ZM_SBQ();
  47. this.Text = "石板泉总貌";
  48. }
  49. break;
  50. case "MHS_FDC"://麻黄山
  51. {
  52. zmControl = new ZM_MHS();
  53. this.Text = "麻黄山总貌";
  54. }
  55. break;
  56. case "QS_FDC"://青山
  57. {
  58. zmControl = new ZM_QS();
  59. this.Text = "青山总貌";
  60. }
  61. break;
  62. case "XS_FDC"://香山
  63. {
  64. zmControl = new ZM_XS();
  65. this.Text = "香山总貌";
  66. }
  67. break;
  68. default:
  69. {
  70. currentStationID = "";
  71. return;
  72. }
  73. }
  74. currentStationID = NavService.Instance.StationId;
  75. //
  76. // 总貌图控件配置
  77. //
  78. this.zmControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(67)))), ((int)(((byte)(139)))));
  79. this.zmControl.ForeColor = System.Drawing.Color.Black;
  80. this.zmControl.Location = new System.Drawing.Point(0, 0);
  81. this.zmControl.Name = "mhsZM";
  82. this.zmControl.Size = new System.Drawing.Size(1920, 960);
  83. this.zmControl.TabIndex = 0;
  84. this.Controls.Add(this.zmControl);
  85. }
  86. public override void Active()
  87. {
  88. this.SuspendLayout();
  89. Init();
  90. this.ResumeLayout(false);
  91. this.Show();
  92. this.zmControl.Active();
  93. }
  94. public override void DeActive()
  95. {
  96. this.Hide();
  97. this.zmControl.DeActive();
  98. }
  99. public override void SelectedStationChanged(string stationId)
  100. {
  101. NavService.Instance.StationId = stationId;
  102. if (currentStationID == NavService.Instance.StationId)
  103. {
  104. return;
  105. }
  106. this.Hide();
  107. this.zmControl.DeActive();
  108. Active();
  109. }
  110. }
  111. }