Beispiel #1
0
        public void RemoveTab(TabPage page)
        {
            var index = _tabPages.FindIndex(x => x.Item2 == page);

            if (index == -1)
            {
                throw new ArgumentException("\"child\" is not a child of this control.");
            }

            var ctab = page as ColumnTabPage;

            if (ctab != null)
            {
                foreach (ChatControl c in ctab.Columns.SelectMany(x => x.Widgets).Where(w => w is ChatControl))
                {
                    TwitchChannel.RemoveChannel(c.ChannelName);
                }
            }

            Controls.Remove(_tabPages[index].Item1);
            _tabPages.RemoveAt(index);

            Controls.Remove(page);

            if (index < _tabPages.Count)
            {
                Select(_tabPages[index].Item2);
            }
            else if (_tabPages.Count > 0)
            {
                Select(_tabPages[index - 1].Item2);
            }
            else
            {
                var p = new ColumnTabPage();
                AddTab(p);
            }
        }
Beispiel #2
0
        // ctor
        public ChatControl()
        {
            MessagePadding = new Padding(12, 8 + TopMenuBarHeight, 16 + SystemInformation.VerticalScrollBarWidth, 8);

            _scroll.Location = new Point(Width - SystemInformation.VerticalScrollBarWidth, TopMenuBarHeight);
            _scroll.Size     = new Size(SystemInformation.VerticalScrollBarWidth, Height - TopMenuBarHeight - 2);
            _scroll.Anchor   = AnchorStyles.None; // AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top;

            Input = new ChatInputControl(this)
            {
                Width    = 600 - 2,
                Location = new Point(0, Height - 32)
            };

            Input.VisibleChanged += (s, e) =>
            {
                updateMessageBounds();
                Invalidate();
            };

            Input.SizeChanged += (s, e) =>
            {
                Input.Location = new Point(1, Height - Input.Height - 1);

                updateMessageBounds();
                Invalidate();
            };

            Input.Anchor = AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left;

            Controls.Add(Input);

            Fonts.FontChanged         += Fonts_FontChanged;
            Net.CurrentChannelChanged += Net_CurrentChannelChanged;

            Disposed += (s, e) =>
            {
                Fonts.FontChanged         -= Fonts_FontChanged;
                Net.CurrentChannelChanged -= Net_CurrentChannelChanged;

                TwitchChannel.RemoveChannel(ActualChannelName);
            };

            //Font = Fonts.GdiMedium;
            Font = new Font("Segoe UI", 9.5f);

            var header = _header = new ChatControlHeader(this);

            header.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            header.Width    = Width - 2;
            header.Location = new Point(1, 0);
            Controls.Add(header);

            GotFocus += (s, e) =>
            {
                Input.Logic.ClearSelection();
                Input.Invalidate();
                header.Invalidate();
            };
            LostFocus += (s, e) =>
            {
                header.Invalidate();
                Input.Invalidate();
            };
        }