更改此自定义控件的默认颜色?

发布于 2024-11-30 11:17:37 字数 609 浏览 0 评论 0原文

我在我的项目中默认使用此 MSDN 示例启动时显示颜色十六进制代码 #442288 (rgb 为 (68, 34, 136)。除了类或文件中的任何位置都找不到这种颜色。我想更改颜色,所以当用户启动程序时,他不会看到这种非常不美观和饱和的颜色。该颜色具有紫色色调,并且与 Windsor 颜色最接近。

通常我只会对我想要的颜色执行 GraphicsDevice.Clear 。当我启动应用程序时,但在加载文件之前我无法开始绘图,因此,在用户加载特定纹理之前,表单包含这种丑陋的紫色,

当然,这不是最严重的问题,但对于我的项目来说。几乎完成我终于解决了从一开始就存在的这些问题

编辑:我想我可以隐藏控件直到用户加载文件,但我仍然好奇这种神秘颜色的存储位置。

编辑#2:实际上,这似乎不太有效,因为如果控件不可见,我无法获取其 GraphicsDevice,因此,我无法创建 spriteBatch。此外,在抓取 GraphicsDevice 之前将控件设置为可见也不起作用。隐藏控件似乎并不能解决这个问题。此外,更改默认颜色会更简单、更优雅。

I'm using this MSDN sample in my project and by default on startup the display is color hex code #442288 (rgb is (68, 34, 136). Except that no where in the classes or files can I find this color. I want to change the color so that when the user starts the program he isn't greeted with this horribly unaesthetic and saturated color. The color has a violet hue and is most closely related to the color Windsor.

Normally I would just do a GraphicsDevice.Clear to the color I want right when I start the application but I cannot begin drawing until a file is loaded. Because of this, until the user loads a specific texture the form contains this ugly purplish color.

Not the most serious of problems, of course, but with my project almost complete I am finally tackling these problems that have existed since the beginning.

Edit: I suppose I could hide the control until a user has loaded a file but I'm still curious as to where this mysterious color is stored.

Edit #2: Actually, that doesn't seem to work too well because if the control is not visible I cannot fetch its GraphicsDevice and consequently, I cannot create a spriteBatch. Also, setting the control to visible right before grabbing its GraphicsDevice does not work either. Doesn't seem like hiding the control will fix this problem. Besides, changing the default color would be so much simpler and more elegant.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伤痕我心 2024-12-07 11:17:37

奇怪的是,代码表明表单应该是 Color.CornflowerBlue:

GraphicsDevice.Clear(Color.CornflowerBlue);

我不想问,但你没有改变你的 Windows 颜色配置文件并意外地重新定义主要颜色之一而不是自定义颜色?

编辑:
只是另一个调查点。

您可以在 Mainform.designer.cs 的第 31 行放置一个断点,然后调查 this 的 BackColor 属性吗?

What's weird is that the Code indicates that the form should be Color.CornflowerBlue:

GraphicsDevice.Clear(Color.CornflowerBlue);

I hate to ask, but you haven't changed your windows color profile and accidentally redefined one of the main colors instead of a custom color ?

Edit:
Just another investigation point.

Can you put a breakpoint in Mainform.designer.cs, on line 31 and at that point investigate the BackColor property of this ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文