Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //----------------------------------------------------------------------------- /* */ 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ResourceExpressionEditorSheet.cs
- SimpleParser.cs
- WindowsUpDown.cs
- mil_commands.cs
- TPLETWProvider.cs
- EraserBehavior.cs
- TemplateControlParser.cs
- UrlEncodedParameterWriter.cs
- FileDialog_Vista_Interop.cs
- RoleService.cs
- ClientSideQueueItem.cs
- LoginName.cs
- UidPropertyAttribute.cs
- CodeThrowExceptionStatement.cs
- StringSource.cs
- MaterialGroup.cs
- Group.cs
- PerformanceCounterManager.cs
- PrintDialog.cs
- TemplateField.cs
- ResetableIterator.cs
- StdRegProviderWrapper.cs
- GlobalizationAssembly.cs
- AutomationProperties.cs
- X509CertificateStore.cs
- FileLogRecord.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- DataGridViewLayoutData.cs
- FormClosingEvent.cs
- RawTextInputReport.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- PerformanceCounterPermissionAttribute.cs
- HttpDictionary.cs
- TdsParser.cs
- xmlsaver.cs
- SafeNativeMethodsCLR.cs
- FacetValueContainer.cs
- ToolBar.cs
- LinkedResource.cs
- ProxyElement.cs
- _BufferOffsetSize.cs
- TabItemAutomationPeer.cs
- ClientFormsIdentity.cs
- TraversalRequest.cs
- XmlWrappingWriter.cs
- CompilerState.cs
- DnsElement.cs
- TypedReference.cs
- PagesChangedEventArgs.cs
- StaticContext.cs
- DiscoveryDocumentLinksPattern.cs
- PriorityQueue.cs
- CheckPair.cs
- XmlQueryTypeFactory.cs
- InvalidOleVariantTypeException.cs
- MSAANativeProvider.cs
- WindowsFormsSectionHandler.cs
- Models.cs
- XXXOnTypeBuilderInstantiation.cs
- QueryBranchOp.cs
- ResolveCriteria.cs
- GZipObjectSerializer.cs
- ParenthesizePropertyNameAttribute.cs
- DbConnectionStringCommon.cs
- AppliedDeviceFiltersEditor.cs
- DebugInfoExpression.cs
- MaterializeFromAtom.cs
- GACMembershipCondition.cs
- HostingEnvironment.cs
- StyleSheet.cs
- XmlReturnWriter.cs
- latinshape.cs
- login.cs
- CodeGen.cs
- CollectionViewProxy.cs
- ComponentSerializationService.cs
- ListViewCancelEventArgs.cs
- Encoder.cs
- COM2ExtendedUITypeEditor.cs
- StreamWriter.cs
- QueryRelOp.cs
- Subtree.cs
- DataColumnChangeEvent.cs
- remotingproxy.cs
- SharedConnectionWorkflowTransactionService.cs
- SymLanguageType.cs
- ListSourceHelper.cs
- LocatorPartList.cs
- RuntimeIdentifierPropertyAttribute.cs
- DurableErrorHandler.cs
- ColorKeyFrameCollection.cs
- QueryModel.cs
- XmlIlGenerator.cs
- ProxyAttribute.cs
- LabelExpression.cs
- ExpressionParser.cs
- DataGridTablesFactory.cs
- AccessControlEntry.cs
- DirectoryInfo.cs
- HeaderedContentControl.cs