⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xtabcontrol.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 4 页
字号:
                if (this.HoverIndex != index)
                {
                    if (this.HoverIndex >= 0)
                    {
                        XTabPage page2 = this.TabPages[this.HoverIndex];
                        if (page2 != null)
                        {
                            base.Invalidate(page2.TabRectangle);
                        }
                    }
                    this.HoverIndex = index;
                    base.Invalidate(tabByPoint.TabRectangle);
                    this.ShowTip(tabByPoint.Text);
                }
            }
            else if (this.HoverIndex >= 0)
            {
                XTabPage page3 = this.TabPages[this.HoverIndex];
                if (page3 != null)
                {
                    base.Invalidate(page3.TabRectangle);
                }
                this.HoverIndex = -1;
            }
            if (this.ScrollRectA.Contains(e.X, e.Y))
            {
                if (!this.MouseInRectA)
                {
                    this.MouseInRectA = true;
                    base.Invalidate(this.ScrollRectA);
                }
            }
            else if (this.MouseInRectA)
            {
                this.MouseInRectA = false;
                base.Invalidate(this.ScrollRectA);
            }
            if (this.ScrollRectB.Contains(e.X, e.Y))
            {
                if (!this.MouseInRectB)
                {
                    this.MouseInRectB = true;
                    base.Invalidate(this.ScrollRectB);
                }
            }
            else if (this.MouseInRectB)
            {
                this.MouseInRectB = false;
                base.Invalidate(this.ScrollRectB);
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            try
            {
                this.Drawer.DrawTabs(e.Graphics, this);
                this.Drawer.DrawBorder(e.Graphics, this);
            }
            catch
            {
            }
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.UpdateTabPageBounds();
        }

        protected void RemoveAll()
        {
            base.Controls.Clear();
        }

        internal void RemoveTabPage(int index)
        {
            if ((index < 0) || (index >= this.tabPageCount))
            {
                throw new ArgumentOutOfRangeException("index");
            }
            this.tabPageCount--;
            if (index < this.tabPageCount)
            {
                Array.Copy(this.tabPages, index + 1, this.tabPages, index, this.tabPageCount - index);
            }
            this.tabPages[this.tabPageCount] = null;
            base.Invalidate(false);
        }

        private void ScrollDown()
        {
            for (int i = 1; i < this.TabCount; i++)
            {
                if (!this.TabPages[i].Hided)
                {
                    this.TabPages[i].Hided = true;
                    return;
                }
            }
        }

        private void ScrollUp()
        {
            if (!this._actionInAnimation)
            {
                this._actionInAnimation = true;
                int num = 0;
                for (int i = 1; i < this.TabCount; i++)
                {
                    if (this.TabPages[i].Hided)
                    {
                        num++;
                        if (i == (this.TabCount - 1))
                        {
                            this.TabPages[i].Hided = false;
                        }
                    }
                    else if (num > 0)
                    {
                        this.TabPages[i - 1].Hided = false;
                        return;
                    }
                }
            }
        }

        public void SelectTab(XTabPage tabPage)
        {
            if (tabPage == null)
            {
                throw new ArgumentNullException("tabPage");
            }
            int index = this.FindTabPage(tabPage);
            this.SelectTab(index);
        }

        public void SelectTab(int index)
        {
            XTabPage tabPage = this.GetTabPage(index);
            if (tabPage != null)
            {
                this.SelectedTab = tabPage;
                base.Invalidate(this.TabRectangle);
            }
        }

        public void SelectTab(string tabPageName)
        {
            if (tabPageName == null)
            {
                throw new ArgumentNullException("tabPageName");
            }
            XTabPage tabPage = this.TabPages[tabPageName];
            this.SelectTab(tabPage);
        }

        internal void SetTabPage(int index, XTabPage tabPage)
        {
            if ((index < 0) || (index >= this.tabPageCount))
            {
                throw new ArgumentOutOfRangeException("index");
            }
            this.tabPages[index] = tabPage;
        }

        private void ShowTip(string text)
        {
            if (this.EnableToolTip)
            {
                this.TabTip.ShowAlways = false;
                this.TabTip.set_UseAnimation(true);
                this.TabTip.set_UseFading(true);
                this.TabTip.SetToolTip(this, text);
            }
        }

        private void Style_StyleChanged(object sender, EventArgs e)
        {
            base.Invalidate();
        }

        private void UpdateTabPageBounds()
        {
            if ((this.SelectedIndex > -1) && (this.SelectedIndex < this.TabPages.Count))
            {
                XTabPage page = this.TabPages[this.SelectedIndex];
                if (page != null)
                {
                    page.SetBounds(this.XTabPageRectangle.X, this.XTabPageRectangle.Y, this.XTabPageRectangle.Width, this.XTabPageRectangle.Height - 20, BoundsSpecified.Size);
                }
            }
        }

        private void XTab_OnScroll(object sender, Imps.Client.Pc.XControls.ScrollEventArgs e)
        {
            if (this.IsScorllNeed(e.Direction))
            {
                lock (this.SyncRoot)
                {
                    this.ScrollActions.Enqueue(e.Direction);
                }
                if (!this.AnimationTimer.Enabled)
                {
                    this.AnimationTimer.Enabled = true;
                    this.Animating = true;
                }
            }
        }

        private void XTabControl_Disposed(object sender, EventArgs e)
        {
            Style.StyleChanged -= new EventHandler(this.Style_StyleChanged);
        }

        private void XTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.TabPages[this.SelectedIndex].Visible = true;
            for (int i = 0; i < this.TabCount; i++)
            {
                if (i != this.SelectedIndex)
                {
                    this.TabPages[i].Visible = false;
                }
            }
            this.UpdateTabPageBounds();
        }

        [Description("Tab所在的位置"), Category("XControl"), Browsable(true), DefaultValue(2)]
        public TabAlignment Alignment
        {
            get
            {
                return this._alignment;
            }
            set
            {
                this._alignment = value;
            }
        }

        public Rectangle AnimateRectangle
        {
            get
            {
                Rectangle empty = Rectangle.Empty;
                switch (this.Alignment)
                {
                    case TabAlignment.Top:
                        return new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y + this.TabHeight, this.ClientRectangle.Width, this.TabHeight);

                    case TabAlignment.Bottom:
                    case TabAlignment.Right:
                        return empty;

                    case TabAlignment.Left:
                        return new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y + this.TabHeight, this.TabWidth, this.ClientRectangle.Height - this.TabHeight);
                }
                return empty;
            }
        }

        public bool Animating
        {
            get
            {
                return this._animating;
            }
            set
            {
                this._animating = value;
            }
        }

        public override Color BackColor
        {
            get
            {
                if (this.ThemeEnabled && (this.Alignment == TabAlignment.Left))
                {
                    return Style.BackColor;
                }
                return base.BackColor;
            }
            set
            {
                base.BackColor = value;
            }
        }

        [Description("Tab的边框颜色"), Browsable(true), Category("XControl")]
        public Color BorderColor
        {
            get
            {
                if (this.ThemeEnabled)
                {
                    return Style.BorderColor;
                }
                return this._borderColor;
            }
            set
            {
                this._borderColor = value;
            }
        }

        [DefaultValue(1), Description("Tab边框的宽度,默认为1个像素"), Browsable(true), Category("XControl")]
        public int BorderWidth
        {
            get
            {
                return this._borderWidth;
            }
            set
            {
                this._borderWidth = value;
            }
        }

        public Rectangle ClientRectangle
        {
            get
            {
                Rectangle clientRectangle = base.ClientRectangle;
                return new Rectangle(clientRectangle.X + base.get_Padding().get_Left(), clientRectangle.Y + base.get_Padding().get_Top(), (clientRectangle.Width - base.get_Padding().get_Left()) - base.get_Padding().get_Right(), (clientRectangle.Height - base.get_Padding().get_Top()) - base.get_Padding().get_Bottom());
            }
        }

        [Browsable(false)]
        public ScrollDirection CurrentDirection
        {
            get
            {
                return this._currentDirection;
            }
            set
            {
                this._currentDirection = value;
            }
        }

        public int CurrentOffSet
        {
            get
            {
                int tabWidth = 0;
                if (this.Animating)
                {
                    tabWidth = this.DistancePerTick * this.TickCounter;
                    switch (this.Alignment)
                    {
                        case TabAlignment.Top:
                        case TabAlignment.Bottom:
                            if (tabWidth > this.TabWidth)
                            {
                                tabWidth = this.TabWidth;
                            }
                            switch (this.CurrentDirection)
                            {
                                case ScrollDirection.Left:
                                    if (tabWidth > 0)
                                    {
                                        tabWidth -= this.TabWidth;
                                    }
                                    return tabWidth;

                                case ScrollDirection.Right:
                                    return -tabWidth;
                            }
                            return tabWidth;

                        case TabAlignment.Left:
                        case TabAlignment.Right:
                            if (tabWidth > this.TabHeight)
                            {
                                tabWidth = this.TabHeight;
                            }
                            switch (this.CurrentDirection)
                            {
                                case ScrollDirection.Up:
                                    if (tabWidth > 0)
                                    {
                                        tabWidth -= this.TabHeight;
                                    }
                                    return tabWidth;

                                case ScrollDirection.Down:
                                    return -tabWidth;
                            }
                            return tabWidth;
                    }
                }
                return tabWidth;
            }
        }

        [Browsable(true), DefaultValue(8), Description("每一次移动的距离,可以控制动画的速度"), Category("XControl")]
        public int DistancePerTick
        {
            get
            {
                return this._distancePerTick;
            }
            set
            {
                this._distancePerTick = value;
            }
        }

        protected IXTabDrawer Drawer
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -