我不确定从哪里开始,以便排除故障,并在第三方代码上尝试解决这个问题,所以我想我应该在这里询问并显示问题的屏幕。我使用的是来自https://thielj.github.io/MetroFramework/的第三方windows窗体"metro controls“包,它看起来有点过时,不再维护,我唯一真正的问题是,选项卡控件似乎有额外的渲染”垃圾“,当你点击它时,它就会消失。但我不知道为什么首先绘制它,也不知道如何删除/修复它并更新github上的包。UI包很有用,它使一个普通的windows窗体项目看起来更好,并且有一个更好的UI,所以这就是我选择它的原因。
有没有人熟悉这个库,并且有类似的问题,或者知道自己修复它的最好方法?请记住,我对windows forms的绘图/gui部分一点也不熟悉,当涉及绘图或UI类型的工作时,我通常会参考在线材料。
发布于 2020-12-05 14:12:07
结果我找到了这个库(稍微更新/更多更新) https://www.nuget.org/packages/MetroModernUI/,但仍然有一些类似的问题,但是我稍微修改了代码,以帮助解决我遇到的一个问题,在选项卡控件上设置OwnerDrawFixed属性的OnDrawItem事件生命周期似乎消失了。
以下是我在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增强框架的选项卡控件或面板中奇怪的附加按钮/可单击消失区域的位置。
发布于 2021-12-25 19:48:47
发生的情况是,应该存在一些与MetroTabControl大小相关的错误,您可以使用以下代码修复该错误:
this.metroTabPage1.VerticalScrollbarBarColor = false;
this.metroTabPage1.VerticalScrollbarSize = 0;
https://stackoverflow.com/questions/64833813
复制相似问题