winforms MetroFramework for windows窗体项目和选项卡控件呈现问题

lstz6jyr  于 2023-03-31  发布在  Windows
关注(0)|答案(3)|浏览(408)

我不知道从哪里开始,以排除故障,并在第三方代码工作,试图解决这个问题,所以我想我会问这里,并显示一个屏幕上的问题。我使用的是第三方窗口窗体“地铁控制”软件包从https://thielj.github.io/MetroFramework/和它看起来有点过时,不再维护和唯一真实的的问题,我有是选项卡控制,特别是似乎有额外的渲染“垃圾”,当你点击它时就会消失。但我不知道为什么它会被绘制在第一位,或者如何删除/修复它并更新github上的包。UI包很有用,它使普通的windows窗体项目看起来更漂亮,有一个更好的UI,所以这就是我选择它的原因。
有没有人熟悉这个库并有类似的问题,或者知道自己修复它的最佳方法?请记住,我根本不熟悉windows窗体的绘图/gui部分,当涉及到绘图或UI类型的工作时,通常会参考在线材料。

jei2mxaa

jei2mxaa1#

结果我找到了这个库(稍微更新/更多更新)https://www.nuget.org/packages/MetroModernUI/,但仍然有一些类似的问题,但我稍微修改了代码,以帮助适应我的问题之一,OnDrawItem事件生命周期似乎已经消失,用于在选项卡控件上设置OwnerDrawFixed属性。
下面是我在MetroTabControl.cs中修改的代码,我只是使用本地版本/构建来支持我必须做的任何自定义和增强,因为还有一些其他问题。

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增强框架的选项卡控件或面板中,我可以无效或修复奇怪的附加按钮/可单击消失区域。

wswtfjt7

wswtfjt72#

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

this.metroTabPage1.VerticalScrollbarBarColor = false;
        this.metroTabPage1.VerticalScrollbarSize = 0;
lbsnaicq

lbsnaicq3#

我认为是因为你有一个metroPanel或一个带有Dock的Panel:填充metroTabPage面板,所以也许是一个'面板内面板错误'.我想你是想做的和我一样,试图使用metropanel更新控件主题,因为在黑暗的主题白色的错误,我固定它改变metroTabControl外观正常,并点击页面metroTabPage的背景(或metroTabControl TabPages)并将UseVisualStyleBackColor更改为true,所以现在白色错误消失了,颜色与metroStyleManager相同。

相关问题