Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / DisplayInformation.cs / 1 / DisplayInformation.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using Microsoft.Win32; using System.Security; using System.Security.Permissions; internal class DisplayInformation { private static bool highContrast; //whether we are under hight contrast mode private static bool lowRes; //whether we are under low resolution mode private static bool isTerminalServerSession; //whether this application is run on a terminal server (remote desktop) private static bool highContrastSettingValid; //indicates whether the high contrast setting is correct private static bool lowResSettingValid; //indicates whether the low resolution setting is correct private static bool terminalSettingValid; //indicates whether the terminal server setting is correct private static short bitsPerPixel = 0; private static bool dropShadowSettingValid; private static bool dropShadowEnabled; private static bool menuAccessKeysUnderlinedValid; private static bool menuAccessKeysUnderlined; static DisplayInformation() { SystemEvents.UserPreferenceChanging += new UserPreferenceChangingEventHandler(UserPreferenceChanging); SystemEvents.DisplaySettingsChanging += new EventHandler(DisplaySettingsChanging); } public static short BitsPerPixel { get { if (bitsPerPixel == 0) { // we used to iterate through all screens, but // for some reason unused screens can temparily appear // in the AllScreens collection - we would honor the display // setting of an unused screen. // According to EnumDisplayMonitors, a primary screen check should be sufficient bitsPerPixel = (short)Screen.PrimaryScreen.BitsPerPixel; } return bitsPerPixel; } } //////tests to see if the monitor is in low resolution mode (8-bit color depth or less). /// public static bool LowResolution { get { if (lowResSettingValid && !lowRes) { return lowRes; } // dont cache if we're in low resolution. lowRes = BitsPerPixel <= 8; lowResSettingValid = true; return lowRes; } } //////tests to see if we are under high contrast mode /// public static bool HighContrast { get { if (highContrastSettingValid) { return highContrast; } highContrast = SystemInformation.HighContrast; highContrastSettingValid = true; return highContrast; } } public static bool IsDropShadowEnabled { get { if (dropShadowSettingValid) { return dropShadowEnabled; } dropShadowEnabled = SystemInformation.IsDropShadowEnabled; dropShadowSettingValid = true; return dropShadowEnabled; } } //////test to see if we are under terminal server mode /// public static bool TerminalServer { get { if (terminalSettingValid) { return isTerminalServerSession; } isTerminalServerSession = SystemInformation.TerminalServerSession; terminalSettingValid = true; return isTerminalServerSession; } } // return if mnemonic underlines should always be there regardless of ALT public static bool MenuAccessKeysUnderlined { get { if (menuAccessKeysUnderlinedValid) { return menuAccessKeysUnderlined; } menuAccessKeysUnderlined = SystemInformation.MenuAccessKeysUnderlined; menuAccessKeysUnderlinedValid = true; return menuAccessKeysUnderlined; } } //////event handler for change in display setting /// private static void DisplaySettingsChanging(object obj, EventArgs ea) { highContrastSettingValid = false; lowResSettingValid = false; terminalSettingValid = false; dropShadowSettingValid = false; menuAccessKeysUnderlinedValid = false; } //////event handler for change in user preference /// private static void UserPreferenceChanging(object obj, UserPreferenceChangingEventArgs e) { highContrastSettingValid = false; lowResSettingValid = false; terminalSettingValid = false; dropShadowSettingValid = false; bitsPerPixel = 0; if (e.Category == UserPreferenceCategory.General) { menuAccessKeysUnderlinedValid =false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContentPlaceHolder.cs
- TextPattern.cs
- StringComparer.cs
- Point3DCollectionValueSerializer.cs
- Logging.cs
- PagedDataSource.cs
- SelectedDatesCollection.cs
- TextContainerChangedEventArgs.cs
- TdsParserSessionPool.cs
- ApplicationGesture.cs
- PenCursorManager.cs
- SchemaTypeEmitter.cs
- WindowsHyperlink.cs
- NamedElement.cs
- Int32Rect.cs
- SystemIcons.cs
- PagedDataSource.cs
- ObjectNavigationPropertyMapping.cs
- ExpandCollapseProviderWrapper.cs
- DataControlLinkButton.cs
- FreezableCollection.cs
- Slider.cs
- DbProviderSpecificTypePropertyAttribute.cs
- PointKeyFrameCollection.cs
- AttributeCollection.cs
- UnionCqlBlock.cs
- UnitySerializationHolder.cs
- XmlNodeChangedEventArgs.cs
- UrlAuthFailedErrorFormatter.cs
- ReadOnlyCollectionBase.cs
- LoginViewDesigner.cs
- StaticResourceExtension.cs
- DataPagerFieldCollection.cs
- documentsequencetextpointer.cs
- SectionXmlInfo.cs
- QuotedPairReader.cs
- XmlCodeExporter.cs
- FixedPageStructure.cs
- SiteMapDataSource.cs
- FrameworkReadOnlyPropertyMetadata.cs
- _OverlappedAsyncResult.cs
- AuthenticationException.cs
- Suspend.cs
- WebRequest.cs
- BufferedOutputStream.cs
- StreamInfo.cs
- DataObject.cs
- FontUnitConverter.cs
- CompressedStack.cs
- JoinCqlBlock.cs
- XPathDescendantIterator.cs
- ChooseAction.cs
- StaticContext.cs
- UpdatePanel.cs
- ImageCodecInfoPrivate.cs
- ControlFilterExpression.cs
- AccessDataSourceWizardForm.cs
- ColorInterpolationModeValidation.cs
- BitmapEffectRenderDataResource.cs
- SerializationInfoEnumerator.cs
- NopReturnReader.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- coordinatorscratchpad.cs
- TimelineGroup.cs
- MimeMultiPart.cs
- DefaultHttpHandler.cs
- CompletionCallbackWrapper.cs
- SqlGenerator.cs
- PolyLineSegment.cs
- TextServicesManager.cs
- SecUtil.cs
- EntityContainerAssociationSetEnd.cs
- Sql8ExpressionRewriter.cs
- ISAPIWorkerRequest.cs
- LocalBuilder.cs
- CultureInfo.cs
- SendMailErrorEventArgs.cs
- SpotLight.cs
- WindowsToolbarItemAsMenuItem.cs
- Transform3DGroup.cs
- HttpCookieCollection.cs
- LicenseException.cs
- EventDescriptor.cs
- BezierSegment.cs
- Button.cs
- ListBindingConverter.cs
- HtmlTableRowCollection.cs
- JsonDataContract.cs
- FlowDocumentScrollViewer.cs
- CacheForPrimitiveTypes.cs
- ProfilePropertySettingsCollection.cs
- HwndSourceParameters.cs
- HtmlFormWrapper.cs
- ExpressionList.cs
- Int32Rect.cs
- EncoderFallback.cs
- LocalizableResourceBuilder.cs
- OutputCacheProfile.cs
- ContentHostHelper.cs
- QueryMatcher.cs