Пример #1
0
        public void CreateDefaultWindows()
        {
            GameScene.Game.ChatTextBox.Dispose();

            GameScene.Game.ChatTextBox = new ChatTextBox
            {
                Parent = GameScene.Game,
            };

            ChatTab tab = AddNewTab(null);

            tab.CurrentTabControl.Size     = new Size(GameScene.Game.ChatTextBox.Size.Width, 150);
            tab.CurrentTabControl.Location = new Point(GameScene.Game.ChatTextBox.Location.X, GameScene.Game.ChatTextBox.Location.Y - 150);

            tab.Panel.Text = $"Chat {ListBox.Controls.Count - 1}";
        }
Пример #2
0
        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);
        }