public ChatTab AddNewTab(ChatTabPageSetting settings) { ChatOptionsPanel panel; DXListBoxItem item = new DXListBoxItem { Parent = ListBox, Item = panel = new ChatOptionsPanel { Parent = this, Visible = false, Location = new Point(ListBox.Location.X + ListBox.Size.Width + 5, ListBox.Location.Y), LocalCheckBox = { Checked = true }, WhisperCheckBox = { Checked = true }, GroupCheckBox = { Checked = true }, GuildCheckBox = { Checked = true }, ShoutCheckBox = { Checked = true }, GlobalCheckBox = { Checked = true }, ObserverCheckBox = { Checked = true }, HintCheckBox = { Checked = true }, SystemCheckBox = { Checked = true }, GainsCheckBox = { Checked = true }, AlertCheckBox = { Checked = true }, }, }; item.SelectedChanged += (o, e) => panel.Visible = item.Selected; DXTabControl tabControl = new DXTabControl { // PassThrough = false, Size = new Size(200, 200), Parent = GameScene.Game, Movable = true, }; ChatTab tab = new ChatTab { Parent = tabControl, Panel = panel, Opacity = 0.5F, AllowResize = true, TabButton = { Movable = true, AllowDragOut = true, Label = { Text = $"Window {ListBox.Controls.Count - 1}" } } }; tab.Settings = settings; tabControl.MouseWheel += (o, e1) => (tabControl.SelectedTab as ChatTab)?.ScrollBar.DoMouseWheel(o, e1); panel.TransparentCheckBox.CheckedChanged += (o, e1) => tab.TransparencyChanged(); panel.AlertCheckBox.CheckedChanged += (o, e1) => tab.AlertIcon.Visible = false; panel.Size = new Size(ClientArea.Width - panel.Location.X, ClientArea.Height); panel.TextChanged += (o1, e1) => { item.Label.Text = panel.Text; tab.TabButton.Label.Text = panel.Text; }; panel.Text = $"Window {ListBox.Controls.Count - 1}"; panel.RemoveButton.MouseClick += (o1, e1) => { DXListBoxItem nextItem = null; bool found = false; foreach (DXControl control in ListBox.Controls) { if (!(control is DXListBoxItem)) { continue; } if (control == item) { found = true; continue; } nextItem = control as DXListBoxItem; if (found) { break; } } ListBox.SelectedItem = nextItem; item.Dispose(); panel.Dispose(); ListBox.UpdateItems(); tabControl = tab.Parent as DXTabControl; tab.Dispose(); if (tabControl?.Controls.Count == 0) { tabControl.Dispose(); } }; ListBox.SelectedItem = item; return(tab); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { Tabs.Remove(this); if (Panel != null) { if (!Panel.IsDisposed) { Panel.Dispose(); } Panel = null; } if (TextPanel != null) { if (!TextPanel.IsDisposed) { TextPanel.Dispose(); } TextPanel = null; } if (ScrollBar != null) { if (!ScrollBar.IsDisposed) { ScrollBar.Dispose(); } ScrollBar = null; } if (History != null) { for (int i = 0; i < History.Count; i++) { if (History[i] != null) { if (!History[i].IsDisposed) { History[i].Dispose(); } History[i] = null; } } History.Clear(); History = null; } if (AlertIcon != null) { if (!AlertIcon.IsDisposed) { AlertIcon.Dispose(); } AlertIcon = null; } } }