SystemFonts.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / SystemFonts.cs / 1 / SystemFonts.cs

                            using System; 
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Media; 
using System.Security;
using System.Windows.Controls.Primitives; 
using Microsoft.Win32; 
using MS.Win32;
using MS.Internal; 

namespace System.Windows
{
    ///  
    ///     Contains properties that are queries into the system's various settings.
    ///  
    public static class SystemFonts 
    {
 
        #region Fonts

        /// 
        ///     Maps to SPI_GETICONTITLELOGFONT 
        /// 
        public static double IconFontSize 
        { 
            get
            { 
                return ConvertFontHeight(SystemParameters.IconMetrics.lfFont.lfHeight);
            }
        }
 
        /// 
        ///     Maps to SPI_GETICONTITLELOGFONT 
        ///  
        public static FontFamily IconFontFamily
        { 
            get
            {
                if (_iconFontFamily == null)
                { 
                    _iconFontFamily = new FontFamily(SystemParameters.IconMetrics.lfFont.lfFaceName);
                } 
 
                return _iconFontFamily;
            } 
        }

        /// 
        ///     Maps to SPI_GETICONTITLELOGFONT 
        /// 
        public static FontStyle IconFontStyle 
        { 
            get
            { 
                return (SystemParameters.IconMetrics.lfFont.lfItalic != 0) ? FontStyles.Italic : FontStyles.Normal;
            }
        }
 
        /// 
        ///     Maps to SPI_GETICONTITLELOGFONT 
        ///  
        public static FontWeight IconFontWeight
        { 
            get
            {
                return FontWeight.FromOpenTypeWeight(SystemParameters.IconMetrics.lfFont.lfWeight);
            } 
        }
 
        ///  
        ///     Maps to SPI_GETICONTITLELOGFONT
        ///  
        public static TextDecorationCollection IconFontTextDecorations
        {
            get
            { 
                if (_iconFontTextDecorations == null)
                { 
                    _iconFontTextDecorations = new TextDecorationCollection(); 

                    if (SystemParameters.IconMetrics.lfFont.lfUnderline != 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Underline, _iconFontTextDecorations);
                    }
 
                    if (SystemParameters.IconMetrics.lfFont.lfStrikeOut != 0)
                    { 
                        CopyTextDecorationCollection(TextDecorations.Strikethrough, _iconFontTextDecorations); 
                    }
 
                    _iconFontTextDecorations.Freeze();
                }

                return _iconFontTextDecorations; 
            }
        } 
 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS 
        /// 
        public static double CaptionFontSize
        {
            get 
            {
                return ConvertFontHeight(SystemParameters.NonClientMetrics.lfCaptionFont.lfHeight); 
            } 
        }
 

        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static FontFamily CaptionFontFamily
        { 
            get 
            {
                if (_captionFontFamily == null) 
                {
                    _captionFontFamily = new FontFamily(SystemParameters.NonClientMetrics.lfCaptionFont.lfFaceName);
                }
 
                return _captionFontFamily;
            } 
        } 

 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        /// 
        public static FontStyle CaptionFontStyle 
        {
            get 
            { 
                return (SystemParameters.NonClientMetrics.lfCaptionFont.lfItalic != 0) ? FontStyles.Italic : FontStyles.Normal;
            } 
        }


        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static FontWeight CaptionFontWeight 
        {
            get 
            {
                return FontWeight.FromOpenTypeWeight(SystemParameters.NonClientMetrics.lfCaptionFont.lfWeight);
            }
        } 

 
        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static TextDecorationCollection CaptionFontTextDecorations
        {
            get
            { 
                if (_captionFontTextDecorations == null)
                { 
                    _captionFontTextDecorations = new TextDecorationCollection(); 

                    if (SystemParameters.NonClientMetrics.lfCaptionFont.lfUnderline != 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Underline, _captionFontTextDecorations);
                    }
 
                    if (SystemParameters.NonClientMetrics.lfCaptionFont.lfStrikeOut != 0)
                    { 
                        CopyTextDecorationCollection(TextDecorations.Strikethrough, _captionFontTextDecorations); 
                    }
                    _captionFontTextDecorations.Freeze(); 
                }

                return _captionFontTextDecorations;
            } 
        }
 
        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static double SmallCaptionFontSize
        {
            get
            { 
                return ConvertFontHeight(SystemParameters.NonClientMetrics.lfSmCaptionFont.lfHeight);
            } 
        } 

 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        /// 
        public static FontFamily SmallCaptionFontFamily 
        {
            get 
            { 
                if (_smallCaptionFontFamily == null)
                { 
                    _smallCaptionFontFamily = new FontFamily(SystemParameters.NonClientMetrics.lfSmCaptionFont.lfFaceName);
                }

                return _smallCaptionFontFamily; 
            }
        } 
 

        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        /// 
        public static FontStyle SmallCaptionFontStyle
        { 
            get
            { 
                return (SystemParameters.NonClientMetrics.lfSmCaptionFont.lfItalic != 0) ? FontStyles.Italic : FontStyles.Normal; 
            }
        } 


        /// 
        ///     Maps to SPI_NONCLIENTMETRICS 
        /// 
        public static FontWeight SmallCaptionFontWeight 
        { 
            get
            { 
                return FontWeight.FromOpenTypeWeight(SystemParameters.NonClientMetrics.lfSmCaptionFont.lfWeight);
            }
        }
 

        ///  
        ///     Maps to SPI_NONCLIENTMETRICS 
        /// 
        public static TextDecorationCollection SmallCaptionFontTextDecorations 
        {
            get
            {
                if (_smallCaptionFontTextDecorations == null) 
                {
                   _smallCaptionFontTextDecorations = new TextDecorationCollection(); 
 
                    if (SystemParameters.NonClientMetrics.lfSmCaptionFont.lfUnderline != 0)
                    { 
                        CopyTextDecorationCollection(TextDecorations.Underline, _smallCaptionFontTextDecorations);
                    }

                    if (SystemParameters.NonClientMetrics.lfSmCaptionFont.lfStrikeOut != 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Strikethrough, _smallCaptionFontTextDecorations); 
                    } 

                    _smallCaptionFontTextDecorations.Freeze(); 
                }

                return _smallCaptionFontTextDecorations;
            } 
        }
 
        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static double MenuFontSize
        {
            get
            { 
                return ConvertFontHeight(SystemParameters.NonClientMetrics.lfMenuFont.lfHeight);
            } 
        } 

        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        /// 
        public static FontFamily MenuFontFamily
        { 
            get
            { 
                if (_menuFontFamily == null) 
                {
                    _menuFontFamily = new FontFamily(SystemParameters.NonClientMetrics.lfMenuFont.lfFaceName); 
                }

                return _menuFontFamily;
            } 
        }
 
        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static FontStyle MenuFontStyle
        {
            get
            { 
                return (SystemParameters.NonClientMetrics.lfMenuFont.lfItalic != 0) ? FontStyles.Italic : FontStyles.Normal;
            } 
        } 

        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        /// 
        public static FontWeight MenuFontWeight
        { 
            get
            { 
                return FontWeight.FromOpenTypeWeight(SystemParameters.NonClientMetrics.lfMenuFont.lfWeight); 
            }
        } 

        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static TextDecorationCollection MenuFontTextDecorations
        { 
            get 
            {
                if (_menuFontTextDecorations == null) 
                {
                   _menuFontTextDecorations = new TextDecorationCollection();

                    if (SystemParameters.NonClientMetrics.lfMenuFont.lfUnderline != 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Underline, _menuFontTextDecorations); 
                    } 

                    if (SystemParameters.NonClientMetrics.lfMenuFont.lfStrikeOut != 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Strikethrough, _menuFontTextDecorations);
                    }
                    _menuFontTextDecorations.Freeze(); 
                }
 
                return _menuFontTextDecorations; 
            }
        } 

        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static double StatusFontSize
        { 
            get 
            {
                return ConvertFontHeight(SystemParameters.NonClientMetrics.lfStatusFont.lfHeight); 
            }
        }

 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS 
        ///  
        public static FontFamily StatusFontFamily
        { 
            get
            {
                if (_statusFontFamily == null)
                { 
                    _statusFontFamily = new FontFamily(SystemParameters.NonClientMetrics.lfStatusFont.lfFaceName);
                } 
 
                return _statusFontFamily;
            } 
        }


        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static FontStyle StatusFontStyle 
        {
            get 
            {
                return (SystemParameters.NonClientMetrics.lfStatusFont.lfItalic != 0) ? FontStyles.Italic : FontStyles.Normal;
            }
        } 

 
        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static FontWeight StatusFontWeight
        {
            get
            { 
                return FontWeight.FromOpenTypeWeight(SystemParameters.NonClientMetrics.lfStatusFont.lfWeight);
            } 
        } 

 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        /// 
        public static TextDecorationCollection StatusFontTextDecorations 
        {
            get 
            { 

                if (_statusFontTextDecorations == null) 
                {
                   _statusFontTextDecorations = new TextDecorationCollection();

                    if (SystemParameters.NonClientMetrics.lfStatusFont.lfUnderline!= 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Underline, _statusFontTextDecorations); 
                    } 

                    if (SystemParameters.NonClientMetrics.lfStatusFont.lfStrikeOut != 0) 
                    {
                        CopyTextDecorationCollection(TextDecorations.Strikethrough, _statusFontTextDecorations);
                    }
                    _statusFontTextDecorations.Freeze(); 
                }
 
                return _statusFontTextDecorations; 
            }
        } 

        /// 
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static double MessageFontSize
        { 
            get 
            {
                return ConvertFontHeight(SystemParameters.NonClientMetrics.lfMessageFont.lfHeight); 
            }
        }

 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS 
        ///  
        public static FontFamily MessageFontFamily
        { 
            get
            {
                if (_messageFontFamily == null)
                { 
                    _messageFontFamily = new FontFamily(SystemParameters.NonClientMetrics.lfMessageFont.lfFaceName);
                } 
 
                return _messageFontFamily;
            } 
        }


        ///  
        ///     Maps to SPI_NONCLIENTMETRICS
        ///  
        public static FontStyle MessageFontStyle 
        {
            get 
            {
                return (SystemParameters.NonClientMetrics.lfMessageFont.lfItalic != 0) ? FontStyles.Italic : FontStyles.Normal;
            }
        } 

        ///  
        ///     Maps to SPI_NONCLIENTMETRICS 
        /// 
        public static FontWeight MessageFontWeight 
        {
            get
            {
                return FontWeight.FromOpenTypeWeight(SystemParameters.NonClientMetrics.lfMessageFont.lfWeight); 
            }
        } 
 
        /// 
        ///     Maps to SPI_NONCLIENTMETRICS 
        /// 
        public static TextDecorationCollection MessageFontTextDecorations
        {
            get 
            {
                if (_messageFontTextDecorations == null) 
                { 
                    _messageFontTextDecorations = new TextDecorationCollection();
 
                    if (SystemParameters.NonClientMetrics.lfMessageFont.lfUnderline != 0)
                    {
                        CopyTextDecorationCollection(TextDecorations.Underline, _messageFontTextDecorations);
                    } 

                    if (SystemParameters.NonClientMetrics.lfMessageFont.lfStrikeOut != 0) 
                    { 
                        CopyTextDecorationCollection(TextDecorations.Strikethrough, _messageFontTextDecorations);
                    } 
                    _messageFontTextDecorations.Freeze();
                }

                return _messageFontTextDecorations; 
            }
        } 
 
        private static void CopyTextDecorationCollection(TextDecorationCollection from, TextDecorationCollection to)
        { 

            int count = from.Count;
            for (int i = 0; i < count; ++i)
            { 
                to.Add(from[i]);
            } 
        } 

        #endregion 

        #region Keys

        ///  
        ///     IconFontSize System Resource Key
        ///  
        public static ResourceKey IconFontSizeKey 
        {
            get 
            {
                if (_cacheIconFontSize == null)
                {
                    _cacheIconFontSize = new SystemResourceKey(SystemResourceKeyID.IconFontSize); 
                }
 
                return _cacheIconFontSize; 
            }
        } 

        /// 
        ///     IconFontFamily System Resource Key
        ///  
        public static ResourceKey IconFontFamilyKey
        { 
            get 
            {
                if (_cacheIconFontFamily == null) 
                {
                    _cacheIconFontFamily = new SystemResourceKey(SystemResourceKeyID.IconFontFamily);
                }
 
                return _cacheIconFontFamily;
            } 
        } 

        ///  
        ///     IconFontStyle System Resource Key
        /// 
        public static ResourceKey IconFontStyleKey
        { 
            get
            { 
                if (_cacheIconFontStyle == null) 
                {
                    _cacheIconFontStyle = new SystemResourceKey(SystemResourceKeyID.IconFontStyle); 
                }

                return _cacheIconFontStyle;
            } 
        }
 
        ///  
        ///     IconFontWeight System Resource Key
        ///  
        public static ResourceKey IconFontWeightKey
        {
            get
            { 
                if (_cacheIconFontWeight == null)
                { 
                    _cacheIconFontWeight = new SystemResourceKey(SystemResourceKeyID.IconFontWeight); 
                }
 
                return _cacheIconFontWeight;
            }
        }
 
        /// 
        ///     IconFontTextDecorations System Resource Key 
        ///  
        public static ResourceKey IconFontTextDecorationsKey
        { 
            get
            {
                if (_cacheIconFontTextDecorations == null)
                { 
                    _cacheIconFontTextDecorations = new SystemResourceKey(SystemResourceKeyID.IconFontTextDecorations);
                } 
 
                return _cacheIconFontTextDecorations;
            } 
        }


 

        ///  
        ///     CaptionFontSize System Resource Key 
        /// 
        public static ResourceKey CaptionFontSizeKey 
        {
            get
            {
                if (_cacheCaptionFontSize == null) 
                {
                    _cacheCaptionFontSize = new SystemResourceKey(SystemResourceKeyID.CaptionFontSize); 
                } 

                return _cacheCaptionFontSize; 
            }
        }

        ///  
        ///     CaptionFontFamily System Resource Key
        ///  
        public static ResourceKey CaptionFontFamilyKey 
        {
            get 
            {
                if (_cacheCaptionFontFamily == null)
                {
                    _cacheCaptionFontFamily = new SystemResourceKey(SystemResourceKeyID.CaptionFontFamily); 
                }
 
                return _cacheCaptionFontFamily; 
            }
        } 

        /// 
        ///     CaptionFontStyle System Resource Key
        ///  
        public static ResourceKey CaptionFontStyleKey
        { 
            get 
            {
                if (_cacheCaptionFontStyle == null) 
                {
                    _cacheCaptionFontStyle = new SystemResourceKey(SystemResourceKeyID.CaptionFontStyle);
                }
 
                return _cacheCaptionFontStyle;
            } 
        } 

        ///  
        ///     CaptionFontWeight System Resource Key
        /// 
        public static ResourceKey CaptionFontWeightKey
        { 
            get
            { 
                if (_cacheCaptionFontWeight == null) 
                {
                    _cacheCaptionFontWeight = new SystemResourceKey(SystemResourceKeyID.CaptionFontWeight); 
                }

                return _cacheCaptionFontWeight;
            } 
        }
 
        ///  
        ///     CaptionFontTextDecorations System Resource Key
        ///  
        public static ResourceKey CaptionFontTextDecorationsKey
        {
            get
            { 
                if (_cacheCaptionFontTextDecorations == null)
                { 
                    _cacheCaptionFontTextDecorations = new SystemResourceKey(SystemResourceKeyID.CaptionFontTextDecorations); 
                }
 
                return _cacheCaptionFontTextDecorations;
            }
        }
 
        /// 
        ///     SmallCaptionFontSize System Resource Key 
        ///  
        public static ResourceKey SmallCaptionFontSizeKey
        { 
            get
            {
                if (_cacheSmallCaptionFontSize == null)
                { 
                    _cacheSmallCaptionFontSize = new SystemResourceKey(SystemResourceKeyID.SmallCaptionFontSize);
                } 
 
                return _cacheSmallCaptionFontSize;
            } 
        }

        /// 
        ///     SmallCaptionFontFamily System Resource Key 
        /// 
        public static ResourceKey SmallCaptionFontFamilyKey 
        { 
            get
            { 
                if (_cacheSmallCaptionFontFamily == null)
                {
                    _cacheSmallCaptionFontFamily = new SystemResourceKey(SystemResourceKeyID.SmallCaptionFontFamily);
                } 

                return _cacheSmallCaptionFontFamily; 
            } 
        }
 
        /// 
        ///     SmallCaptionFontStyle System Resource Key
        /// 
        public static ResourceKey SmallCaptionFontStyleKey 
        {
            get 
            { 
                if (_cacheSmallCaptionFontStyle == null)
                { 
                    _cacheSmallCaptionFontStyle = new SystemResourceKey(SystemResourceKeyID.SmallCaptionFontStyle);
                }

                return _cacheSmallCaptionFontStyle; 
            }
        } 
 
        /// 
        ///     SmallCaptionFontWeight System Resource Key 
        /// 
        public static ResourceKey SmallCaptionFontWeightKey
        {
            get 
            {
                if (_cacheSmallCaptionFontWeight == null) 
                { 
                    _cacheSmallCaptionFontWeight = new SystemResourceKey(SystemResourceKeyID.SmallCaptionFontWeight);
                } 

                return _cacheSmallCaptionFontWeight;
            }
        } 

        ///  
        ///     SmallCaptionFontTextDecorations System Resource Key 
        /// 
        public static ResourceKey SmallCaptionFontTextDecorationsKey 
        {
            get
            {
                if (_cacheSmallCaptionFontTextDecorations == null) 
                {
                    _cacheSmallCaptionFontTextDecorations = new SystemResourceKey(SystemResourceKeyID.SmallCaptionFontTextDecorations); 
                } 

                return _cacheSmallCaptionFontTextDecorations; 
            }
        }

        ///  
        ///     MenuFontSize System Resource Key
        ///  
        public static ResourceKey MenuFontSizeKey 
        {
            get 
            {
                if (_cacheMenuFontSize == null)
                {
                    _cacheMenuFontSize = new SystemResourceKey(SystemResourceKeyID.MenuFontSize); 
                }
 
                return _cacheMenuFontSize; 
            }
        } 

        /// 
        ///     MenuFontFamily System Resource Key
        ///  
        public static ResourceKey MenuFontFamilyKey
        { 
            get 
            {
                if (_cacheMenuFontFamily == null) 
                {
                    _cacheMenuFontFamily = new SystemResourceKey(SystemResourceKeyID.MenuFontFamily);
                }
 
                return _cacheMenuFontFamily;
            } 
        } 

        ///  
        ///     MenuFontStyle System Resource Key
        /// 
        public static ResourceKey MenuFontStyleKey
        { 
            get
            { 
                if (_cacheMenuFontStyle == null) 
                {
                    _cacheMenuFontStyle = new SystemResourceKey(SystemResourceKeyID.MenuFontStyle); 
                }

                return _cacheMenuFontStyle;
            } 
        }
 
        ///  
        ///     MenuFontWeight System Resource Key
        ///  
        public static ResourceKey MenuFontWeightKey
        {
            get
            { 
                if (_cacheMenuFontWeight == null)
                { 
                    _cacheMenuFontWeight = new SystemResourceKey(SystemResourceKeyID.MenuFontWeight); 
                }
 
                return _cacheMenuFontWeight;
            }
        }
 
        /// 
        ///     MenuFontTextDecorations System Resource Key 
        ///  
        public static ResourceKey MenuFontTextDecorationsKey
        { 
            get
            {
                if (_cacheMenuFontTextDecorations == null)
                { 
                    _cacheMenuFontTextDecorations = new SystemResourceKey(SystemResourceKeyID.MenuFontTextDecorations);
                } 
 
                return _cacheMenuFontTextDecorations;
            } 
        }

        /// 
        ///     StatusFontSize System Resource Key 
        /// 
        public static ResourceKey StatusFontSizeKey 
        { 
            get
            { 
                if (_cacheStatusFontSize == null)
                {
                    _cacheStatusFontSize = new SystemResourceKey(SystemResourceKeyID.StatusFontSize);
                } 

                return _cacheStatusFontSize; 
            } 
        }
 
        /// 
        ///     StatusFontFamily System Resource Key
        /// 
        public static ResourceKey StatusFontFamilyKey 
        {
            get 
            { 
                if (_cacheStatusFontFamily == null)
                { 
                    _cacheStatusFontFamily = new SystemResourceKey(SystemResourceKeyID.StatusFontFamily);
                }

                return _cacheStatusFontFamily; 
            }
        } 
 
        /// 
        ///     StatusFontStyle System Resource Key 
        /// 
        public static ResourceKey StatusFontStyleKey
        {
            get 
            {
                if (_cacheStatusFontStyle == null) 
                { 
                    _cacheStatusFontStyle = new SystemResourceKey(SystemResourceKeyID.StatusFontStyle);
                } 

                return _cacheStatusFontStyle;
            }
        } 

        ///  
        ///     StatusFontWeight System Resource Key 
        /// 
        public static ResourceKey StatusFontWeightKey 
        {
            get
            {
                if (_cacheStatusFontWeight == null) 
                {
                    _cacheStatusFontWeight = new SystemResourceKey(SystemResourceKeyID.StatusFontWeight); 
                } 

                return _cacheStatusFontWeight; 
            }
        }

        ///  
        ///     StatusFontTextDecorations System Resource Key
        ///  
        public static ResourceKey StatusFontTextDecorationsKey 
        {
            get 
            {
                if (_cacheStatusFontTextDecorations == null)
                {
                    _cacheStatusFontTextDecorations = new SystemResourceKey(SystemResourceKeyID.StatusFontTextDecorations); 
                }
 
                return _cacheStatusFontTextDecorations; 
            }
        } 

        /// 
        ///     MessageFontSize System Resource Key
        ///  
        public static ResourceKey MessageFontSizeKey
        { 
            get 
            {
                if (_cacheMessageFontSize == null) 
                {
                    _cacheMessageFontSize = new SystemResourceKey(SystemResourceKeyID.MessageFontSize);
                }
 
                return _cacheMessageFontSize;
            } 
        } 

        ///  
        ///     MessageFontFamily System Resource Key
        /// 
        public static ResourceKey MessageFontFamilyKey
        { 
            get
            { 
                if (_cacheMessageFontFamily == null) 
                {
                    _cacheMessageFontFamily = new SystemResourceKey(SystemResourceKeyID.MessageFontFamily); 
                }

                return _cacheMessageFontFamily;
            } 
        }
 
        ///  
        ///     MessageFontStyle System Resource Key
        ///  
        public static ResourceKey MessageFontStyleKey
        {
            get
            { 
                if (_cacheMessageFontStyle == null)
                { 
                    _cacheMessageFontStyle = new SystemResourceKey(SystemResourceKeyID.MessageFontStyle); 
                }
 
                return _cacheMessageFontStyle;
            }
        }
 
        /// 
        ///     MessageFontWeight System Resource Key 
        ///  
        public static ResourceKey MessageFontWeightKey
        { 
            get
            {
                if (_cacheMessageFontWeight == null)
                { 
                    _cacheMessageFontWeight = new SystemResourceKey(SystemResourceKeyID.MessageFontWeight);
                } 
 
                return _cacheMessageFontWeight;
            } 
        }

        /// 
        ///     MessageFontTextDecorations System Resource Key 
        /// 
        public static ResourceKey MessageFontTextDecorationsKey 
        { 
            get
            { 
                if (_cacheMessageFontTextDecorations == null)
                {
                    _cacheMessageFontTextDecorations = new SystemResourceKey(SystemResourceKeyID.MessageFontTextDecorations);
                } 

                return _cacheMessageFontTextDecorations; 
            } 
        }
 
        #endregion

        #region Implementation
 
        private static double ConvertFontHeight(int height)
        { 
            int dpi = SystemParameters.Dpi; 

            if (dpi != 0) 
            {
                return (double)(Math.Abs(height) * 96 / dpi);
            }
            else 
            {
                // Could not get the DPI to convert the size, using the hardcoded fallback value 
                return FallbackFontSize; 
            }
        } 

        private const double FallbackFontSize = 11.0;   // To use if unable to get the system size

        internal static void InvalidateIconMetrics() 
        {
            _iconFontTextDecorations = null; 
            _iconFontFamily = null; 
        }
 
        internal static void InvalidateNonClientMetrics()
        {
            _messageFontTextDecorations = null;
            _statusFontTextDecorations = null; 
            _menuFontTextDecorations = null;
            _smallCaptionFontTextDecorations = null; 
            _captionFontTextDecorations = null; 

            _messageFontFamily = null; 
            _statusFontFamily = null;
            _menuFontFamily = null;
            _smallCaptionFontFamily = null;
            _captionFontFamily = null; 
        }
 
        private static TextDecorationCollection _iconFontTextDecorations; 
        private static TextDecorationCollection _messageFontTextDecorations;
        private static TextDecorationCollection _statusFontTextDecorations; 
        private static TextDecorationCollection _menuFontTextDecorations;
        private static TextDecorationCollection _smallCaptionFontTextDecorations;
        private static TextDecorationCollection _captionFontTextDecorations;
 
        private static FontFamily _iconFontFamily;
        private static FontFamily _messageFontFamily; 
        private static FontFamily _statusFontFamily; 
        private static FontFamily _menuFontFamily;
        private static FontFamily _smallCaptionFontFamily; 
        private static FontFamily _captionFontFamily;

        private static SystemResourceKey _cacheIconFontSize;
        private static SystemResourceKey _cacheIconFontFamily; 
        private static SystemResourceKey _cacheIconFontStyle;
        private static SystemResourceKey _cacheIconFontWeight; 
        private static SystemResourceKey _cacheIconFontTextDecorations; 
        private static SystemResourceKey _cacheCaptionFontSize;
        private static SystemResourceKey _cacheCaptionFontFamily; 
        private static SystemResourceKey _cacheCaptionFontStyle;
        private static SystemResourceKey _cacheCaptionFontWeight;
        private static SystemResourceKey _cacheCaptionFontTextDecorations;
        private static SystemResourceKey _cacheSmallCaptionFontSize; 
        private static SystemResourceKey _cacheSmallCaptionFontFamily;
        private static SystemResourceKey _cacheSmallCaptionFontStyle; 
        private static SystemResourceKey _cacheSmallCaptionFontWeight; 
        private static SystemResourceKey _cacheSmallCaptionFontTextDecorations;
        private static SystemResourceKey _cacheMenuFontSize; 
        private static SystemResourceKey _cacheMenuFontFamily;
        private static SystemResourceKey _cacheMenuFontStyle;
        private static SystemResourceKey _cacheMenuFontWeight;
        private static SystemResourceKey _cacheMenuFontTextDecorations; 
        private static SystemResourceKey _cacheStatusFontSize;
        private static SystemResourceKey _cacheStatusFontFamily; 
        private static SystemResourceKey _cacheStatusFontStyle; 
        private static SystemResourceKey _cacheStatusFontWeight;
        private static SystemResourceKey _cacheStatusFontTextDecorations; 
        private static SystemResourceKey _cacheMessageFontSize;
        private static SystemResourceKey _cacheMessageFontFamily;
        private static SystemResourceKey _cacheMessageFontStyle;
        private static SystemResourceKey _cacheMessageFontWeight; 
        private static SystemResourceKey _cacheMessageFontTextDecorations;
 
        #endregion 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK