开发者

What is the difference between System.Drawing.Color and System.Windows.Media.Color?

开发者 https://www.devze.com 2022-12-23 03:24 出处:网络
Basically, why the need for two abstractions of a开发者_StackOverflow社区 pretty simple concept?System.Windows.Media.Color is part of the System.Windows.Media namespace:

Basically, why the need for two abstractions of a开发者_StackOverflow社区 pretty simple concept?


System.Windows.Media.Color is part of the System.Windows.Media namespace:

Provides types that enable integration of rich media, including drawings, text, and audio/video content in Windows Presentation Foundation (WPF) applications.

System.Drawing.Color is part of the System.Drawing namespace:

The System.Drawing namespace provides access to GDI+ basic graphics functionality. More advanced functionality is provided in the System.Drawing.Drawing2D, System.Drawing.Imaging, and System.Drawing.Text namespaces.

I'm guessing that the latter is Windows specific, whilst the former is more general and is more easily portable to Mac OS etc. for use in Silverlight applications.

There is also this caution on the latter namespace which would tend to support this:

Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.


I don't think there was a "need" as such, just that they made an early (probably wrong) decision to put the Color class into the the WinForms-specific System.Drawing - because at the time, Win32 and Winforms was all there was.

Later when they wanted to enhance the concepts in "Color", they didn't want WPF to depend on WinForms. So rather than fix the situation by moving a more abstract Color class to a generic assembly, they just copy-pasted a new Color class in WPF.

0

精彩评论

暂无评论...
验证码 换一张
取 消