protected virtual void OnExchangeItemCheckedChanged(object sender, ItemClickEventArgs e) { BarCheckItem item = sender as BarCheckItem; Exchange exchange = item.Tag as Exchange; if (item.Checked) { exchange.Connect(); item.Caption = exchange.Name + " <color=green>Connected</color>"; Form exchangeForm = GetExchangeForm(exchange); exchangeForm.Tag = item; exchangeForm.FormClosed += OnExchangeFormClosed; exchangeForm.Show(); } else { exchange.Disconnect(); item.Caption = exchange.Name; if (TickersForms.ContainsKey(exchange)) { Form exchangeForm = TickersForms[exchange]; exchangeForm.FormClosed -= OnExchangeFormClosed; if (!exchangeForm.IsDisposed) { exchangeForm.Close(); } exchangeForm.Tag = null; TickersForms.Remove(exchange); } } }