更改此自定义控件的默认颜色?
我在我的项目中默认使用此 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
奇怪的是,代码表明表单应该是 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
?