如何让 .net windows 窗体项目看起来新鲜?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can you make a .net windows forms project look fresh?
提问by Jeffrey
I'm working on a visual studio 2005 vb.net windows forms project that's been around for several years. It's full of default textboxes, labels, dropdowns, datagrids, datetime pickers -- all the standard stuff. The end result is a very gray, old-looking project.
我正在开发一个已经存在了好几年的 Visual Studio 2005 vb.net windows 窗体项目。它充满了默认的文本框、标签、下拉菜单、数据网格、日期时间选择器——所有标准的东西。最终的结果是一个非常灰暗、看起来老旧的项目。
What would be the best approach to making this project look fresh and snazzy? I'd rather not rewrite the entire solution with all brand new forms objects, but would that be avoidable?
使这个项目看起来新鲜和时髦的最佳方法是什么?我宁愿不使用所有全新的表单对象重写整个解决方案,但这是否可以避免?
回答by Jim McKeeth
I was actually just sprucing up a dialog today. A lot of it depends on what kind of application you have, and what OS it is running on. A couple of these tips will certainly go a long way to jazzing things up.
我今天实际上只是在整理一个对话。在很大程度上取决于您拥有什么样的应用程序,以及它在什么操作系统上运行。这些技巧中的一些肯定会大大提高爵士乐的水平。
Ensure adequate spacing between controls — don't cram them all together. Space is appealing. You might also trying flowing the controls a little differently when you have more space.
Put in some new 3D and glossy images. You can put a big yellow exclamation mark on a custom warning dialog. Replace old toolbar buttons with new ones. Two libraries I have used and like are GlyFXand IconExperience. You can find free ones too. Ideally get a graphic artist to make some custom ones for the specific actions your application does to fill in between the common ones you use (make sure they all go together). That will go a long way to making it look fancy.
Try a different font. Tahoma is a good one. Often times the default font is MS Sans Serif. You can do better. Avoid Times New Roman and Comic Sans though. Also avoid large blocks of bold — use it sparingly. Generally you want all your fonts the same, and only use different fonts sparingly to set certain bits of text apart.
Add subdued colors to certain controls. This is a tricky one. You always want to use subdued colors, nothing bright or stark usually, but the colors should indicate something, or if you have a grid you can use it to show logical grouping. This is a slippery slope. Be aware that users might change their system colors, which will change how your colors look. Ideally give them a few color themes, or the ability to change colors.
Instead of thinking eye-candy, think usability. Make the most common course of action obvious. Mark Miller of DevExpress has a great talk on the Science of User Interface Design. I actually have a video of it and might be able to post it online with a little clean-up.
Invest in a few good quality 3rd party controls. Replacing all your controls could be a pain, but if you are using the default grids for example, you would really jazz it up with a good grid from DevExpressor some other component vendor. Be aware that different vendors have different philosophies for how their components are used, so swapping them out can be a bit of a pain. Start small to test the waters, and then try something really complicated before you commit to replacing all of them. The only thing worse then ugly grids is ugly grids mixed with pretty grids. Consistency is golden!
You also might look at replacing your old tool bars and menus with a Ribbon Control like Microsoft did in Office 2007. Then everyone will think you are really uptown! Again only replacing key components and UI elements without thinking you need to revamp the whole UI.
Of course pay attention to the basics like tab order, etc. Consistency, consistency, consistency.
确保控件之间有足够的间距——不要把它们塞在一起。空间很吸引人。当您有更多空间时,您也可以尝试稍微不同地流动控件。
放入一些新的 3D 和光面图像。您可以在自定义警告对话框上放置一个大的黄色感叹号。用新的工具栏按钮替换旧的工具栏按钮。我使用过并喜欢的两个库是GlyFX和IconExperience。你也可以找到免费的。理想情况下,请图形艺术家为您的应用程序执行的特定操作制作一些自定义操作,以填充您使用的常用操作(确保它们都在一起)。这将大大有助于让它看起来很花哨。
尝试不同的字体。塔霍马是一个很好的。通常默认字体是 MS Sans Serif。你可以做得更好。避免 Times New Roman 和 Comic Sans。还要避免大块的粗体——谨慎使用。通常,您希望所有字体都相同,并且仅谨慎使用不同的字体来设置文本的某些位。
为某些控件添加柔和的颜色。这是一个棘手的问题。你总是想使用柔和的颜色,通常没有明亮或鲜明的颜色,但颜色应该表明一些东西,或者如果你有一个网格,你可以用它来显示逻辑分组。这是一个滑坡。请注意,用户可能会更改他们的系统颜色,这将改变您的颜色外观。理想情况下,给他们一些颜色主题,或者改变颜色的能力。
与其考虑眼花缭乱,不如考虑可用性。使最常见的行动方案显而易见。DevExpress 的 Mark Miller 有一个关于用户界面设计科学的精彩演讲。我实际上有一个它的视频,也许可以通过一些清理将其发布到网上。
投资一些优质的 3rd 方控件。替换所有控件可能会很痛苦,但例如,如果您使用的是默认网格,那么您真的会用来自DevExpress或其他一些组件供应商的良好网格来使它变得活泼起来。请注意,不同的供应商对其组件的使用方式有不同的理念,因此更换它们可能会有点麻烦。从小处开始试水,然后在您承诺更换所有这些之前尝试一些非常复杂的事情。唯一比丑陋网格更糟糕的是丑陋的网格与漂亮的网格混合在一起。一致性是金!
您还可以考虑用功能区控件替换旧的工具栏和菜单,就像 Microsoft 在 Office 2007 中所做的那样。然后每个人都会认为您是真正的住宅区!同样只替换关键组件和 UI 元素,而不考虑您需要修改整个 UI。
当然要注意标签顺序等基础知识。一致性,一致性,一致性。
Some apps lend themselves to full blown skinning, while others don't. Generally you don't want anything flashy that gets used a lot.
一些应用程序适合完全成熟的皮肤,而其他应用程序则不然。一般来说,你不想要任何经常使用的华而不实的东西。
回答by Dillie-O
One other thing to also check is that your controls have the FlatStyleproperty set to Systeminstead of Standard.
还要检查的另一件事是您的控件将FlatStyle属性设置为System而不是 Standard。
What this will do is make sure that the app uses the system defaults for radio buttons, standard buttons and the like. This takes all your apps from the flat Win 2000 look and gives them the XP or Vista bling depending on the OS they are running.
这将确保应用程序使用单选按钮、标准按钮等的系统默认值。这使您的所有应用程序都具有 Win 2000 的平面外观,并根据它们运行的操作系统为它们提供 XP 或 Vista 的外观。
回答by Dillie-O
I recommend purchasing a good 3rd-party control library - Infragisticsand DevExpress, are just a couple. Most of these libraries give you the ability to drop in new compatible controls on top of your existing ones - for example, you can replace the default EditBox with an enhanced version. They also give you access to some of the snazzy new UIs such as Ribbon, or the Outlook-style navigator people are always wanting.
我建议购买一个好的 3rd 方控件库 - Infragistics和DevExpress,只是一对。这些库中的大多数使您能够在现有控件之上添加新的兼容控件 - 例如,您可以用增强版本替换默认的 EditBox。它们还使您可以访问一些时髦的新 UI,例如 Ribbon 或人们一直想要的 Outlook 风格的导航器。
The reason I specifically recommend using one of these libraries is that they were designed to be relatively easy to use in existing applications, you get support, a community, and all sorts of upgrade paths/options.
我特别推荐使用这些库之一的原因是它们被设计为在现有应用程序中相对易于使用,您可以获得支持、社区和各种升级路径/选项。
The downside: money.
缺点:钱。
回答by Matt Hamilton
This isn't so much an "answer" as an opinion.
这与其说是“答案”,不如说是意见。
I tried to jazz up a WinForms project I created back a few years ago by giving the forms a fancy blue gradient background etc, and it looked pretty good on XP. But then on Vista it looked out of place. Taking away any custom painting and reverting the form to "battleship gray" made it look much better IMHO.
我试图通过给表单一个花哨的蓝色渐变背景等来使我几年前创建的 WinForms 项目变得活泼起来,它在 XP 上看起来很不错。但后来在 Vista 上它看起来格格不入。去掉任何自定义绘画并将形式恢复为“战舰灰色”,恕我直言,它看起来好多了。
I'm seeing a lot of applications (particularly from MS) coming out with custom window chrome etc, and all it does is detract from the nice sense of consistency that Windows gives.
我看到很多应用程序(特别是来自 MS)带有自定义窗口镶边等,但它所做的一切都削弱了 Windows 提供的良好一致性。
I guess what I'm saying is that you don't need to worry too much about making your application look fashionable. If you keep your colours based on the SystemColors enumeration then Windows can do that for you.
我想我想说的是,您不必太担心让您的应用程序看起来很时尚。如果您根据 SystemColors 枚举保留颜色,则 Windows 可以为您完成。
回答by Orion Edwards
What would be the best approach to making this project look fresh and snazzy?
使这个项目看起来新鲜和时髦的最佳方法是什么?
IMHO the best thing you can do is make sure the controls are logically ordered, and have ample spacing between them, and add groupboxes / labels / etc where appropriate.
恕我直言,您能做的最好的事情是确保控件按逻辑顺序排列,并且它们之间有足够的间距,并在适当的地方添加分组框/标签/等。
If you try and change the 'sea of gray' that is the default color scheme, your app will just end up looking crap.
如果您尝试更改默认配色方案的“灰色海洋”,您的应用程序最终只会看起来很糟糕。
回答by Jason Z
You can subclass all the default controls and override their appearance. Admittedly, you will have to go thru the entire project and change all references of TextBox to MyTextBox, but all of the default properties and methods will still work. The same cannot be guaranteed if you go with a 3rd party vendor. The other advantage of this approach is you can pick one control at a time and perform an incremental upgrade of the application.
您可以将所有默认控件子类化并覆盖它们的外观。诚然,您必须遍历整个项目并将 TextBox 的所有引用更改为 MyTextBox,但所有默认属性和方法仍然有效。如果您与第 3 方供应商合作,则无法保证相同。这种方法的另一个优点是您可以一次选择一个控件并执行应用程序的增量升级。
回答by user352
This depends on how the existing "gray old looking" project is structured in terms of code. For example, is data access code separated from the UI in a Data Access Layer, is the business logic in a Business Logic Layer? If yes, then cleaning the UI for a snazzy look should be relatively simple.
这取决于现有的“灰色旧外观”项目在代码方面的结构。例如,数据访问代码是否与数据访问层中的UI分离,业务逻辑是否在业务逻辑层中?如果是,那么清理 UI 以获得时髦的外观应该相对简单。
If everything is all there in the "Button Click" event, then a rewrite is the only way in my humble opinion as otherwise it will just be too time consuming trying to work with the existing code base.
如果一切都在“按钮单击”事件中,那么在我看来,重写是唯一的方法,否则尝试使用现有代码库会非常耗时。
Cheers
干杯

