private void RemoveAllControls() { Controls.Remove(readerControl); if (readerControl != null) { readerControl.Stop(); } readerControl = null; Controls.Remove(logControl); logControl = null; Controls.Remove(stockInControl); // 尝试注销config control的read tags监听事件 try { stockInControl.ReadTagsClicked -= stockInControl_ReadTagsClicked; } // 但是如果没有注册过,注销可能失败,不影响程序正常使用,故不处理异常 catch (Exception ex) { } stockInControl = null; Controls.Remove(configControl); configControl = null; }
private void AddLogControl() { if (logControl == null) { logControl = new LogControl(); logControl.Dock = DockStyle.Fill; logControl.Name = "logger"; Controls.Add(logControl); } }