using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using IntelligentControlForsx.Template; using IntelligentControlForsx.MyControls.zm; using IntelligentControlForsx.Service; namespace IntelligentControlForsx.ChildForms { public partial class ZMForm : TemplateForm { ZMControl zmControl = null; string currentStationID = ""; public ZMForm() { InitializeComponent(); Init(); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.   SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲   this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles(); } private void Init() { if (currentStationID == NavService.Instance.StationId) { return; } this.Controls.Clear();// 要么clear掉,要么放在字典中隐藏 switch (NavService.Instance.StationId) { case "NSS_FDC"://牛首山 { zmControl = new ZM_NSS(); this.Text = "牛首山总貌"; } break; case "SBQ_FDC"://石板泉 { zmControl = new ZM_SBQ(); this.Text = "石板泉总貌"; } break; case "MHS_FDC"://麻黄山 { zmControl = new ZM_MHS(); this.Text = "麻黄山总貌"; } break; case "QS_FDC"://青山 { zmControl = new ZM_QS(); this.Text = "青山总貌"; } break; case "XS_FDC"://香山 { zmControl = new ZM_XS(); this.Text = "香山总貌"; } break; default: { currentStationID = ""; return; } } currentStationID = NavService.Instance.StationId; // // 总貌图控件配置 // this.zmControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(67)))), ((int)(((byte)(139))))); this.zmControl.ForeColor = System.Drawing.Color.Black; this.zmControl.Location = new System.Drawing.Point(0, 0); this.zmControl.Name = "mhsZM"; this.zmControl.Size = new System.Drawing.Size(1920, 960); this.zmControl.TabIndex = 0; this.Controls.Add(this.zmControl); } public override void Active() { this.SuspendLayout(); Init(); this.ResumeLayout(false); this.Show(); this.zmControl.Active(); } public override void DeActive() { this.Hide(); this.zmControl.DeActive(); } public override void SelectedStationChanged(string stationId) { NavService.Instance.StationId = stationId; if (currentStationID == NavService.Instance.StationId) { return; } this.Hide(); this.zmControl.DeActive(); Active(); } } }