首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用于windows窗体的MetroFramework项目和选项卡控件呈现问题

用于windows窗体的MetroFramework项目和选项卡控件呈现问题
EN

Stack Overflow用户
提问于 2020-11-14 20:19:07
回答 2查看 323关注 0票数 1

我不确定从哪里开始,以便排除故障,并在第三方代码上尝试解决这个问题,所以我想我应该在这里询问并显示问题的屏幕。我使用的是来自https://thielj.github.io/MetroFramework/的第三方windows窗体"metro controls“包,它看起来有点过时,不再维护,我唯一真正的问题是,选项卡控件似乎有额外的渲染”垃圾“,当你点击它时,它就会消失。但我不知道为什么首先绘制它,也不知道如何删除/修复它并更新github上的包。UI包很有用,它使一个普通的windows窗体项目看起来更好,并且有一个更好的UI,所以这就是我选择它的原因。

有没有人熟悉这个库,并且有类似的问题,或者知道自己修复它的最好方法?请记住,我对windows forms的绘图/gui部分一点也不熟悉,当涉及绘图或UI类型的工作时,我通常会参考在线材料。

EN

回答 2

Stack Overflow用户

发布于 2020-12-05 14:12:07

结果我找到了这个库(稍微更新/更多更新) https://www.nuget.org/packages/MetroModernUI/,但仍然有一些类似的问题,但是我稍微修改了代码,以帮助解决我遇到的一个问题,在选项卡控件上设置OwnerDrawFixed属性的OnDrawItem事件生命周期似乎消失了。

以下是我在MetroTabControl.cs中修改的代码,我只是使用本地版本/构建来支持我必须执行的任何自定义和增强,因为我还有其他一些问题。

代码语言:javascript
运行
复制
        private void DrawTab(int index, Graphics graphics)
        {
            Color foreColor;
            Color backColor = BackColor;

            if (!useCustomBackColor)
            {
                backColor = MetroPaint.BackColor.Form(Theme);
            }

            TabPage tabPage = TabPages[index];
            Rectangle tabRect = GetTabRect(index);

            if (!Enabled || tabDisable.Contains(tabPage.Name))
            {
                foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
            }
            else
            {
                if (useCustomForeColor)
                {
                    foreColor = DefaultForeColor;
                }
                else
                {
                    foreColor = !useStyleColors ? MetroPaint.ForeColor.TabControl.Normal(Theme) : MetroPaint.GetStyleColor(Style);
                }
            }

            if (index == 0)
            {
                tabRect.X = DisplayRectangle.X;
            }

            Rectangle bgRect = tabRect;

            tabRect.Width += 20;

            using (Brush bgBrush = new SolidBrush(backColor))
            {
                graphics.FillRectangle(bgBrush, bgRect);
            }

            TextRenderer.DrawText(graphics, tabPage.Text, MetroFonts.TabControl(metroLabelSize, metroLabelWeight),
                                  tabRect, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign));

            //HACK not properly handling the owner draw fixed event/override life cycle so we can fire it ourselves and if something is listening
            //      it will execute
            if (this.DrawMode == TabDrawMode.OwnerDrawFixed)
            {
                OnDrawItem(new DrawItemEventArgs(graphics, this.Font, tabRect, index, DrawItemState.None));
            }
        }

对于另一个UI问题,我正在追踪这个UI增强框架的选项卡控件或面板中奇怪的附加按钮/可单击消失区域的位置。

票数 1
EN

Stack Overflow用户

发布于 2021-12-25 19:48:47

发生的情况是,应该存在一些与MetroTabControl大小相关的错误,您可以使用以下代码修复该错误:

代码语言:javascript
运行
复制
        this.metroTabPage1.VerticalScrollbarBarColor = false;
        this.metroTabPage1.VerticalScrollbarSize = 0;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64833813

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档