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

前端 未结 2 1973
误落风尘
误落风尘 2021-02-02 07:51

Basically, why the need for two abstractions of a pretty simple concept?

2条回答
  •  野的像风
    2021-02-02 08:07

    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.

提交回复
热议问题