Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / PowerStatus.cs / 1 / PowerStatus.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { ////// /// public enum PowerLineStatus { ////// To be supplied. /// ////// /// To be supplied. /// Offline = 0, ////// /// To be supplied. /// Online = 1, ////// /// To be supplied. /// Unknown = 255 } ////// /// [Flags] public enum BatteryChargeStatus { ////// To be supplied. /// ////// /// To be supplied. /// High = 1, ////// /// To be supplied. /// Low = 2, ////// /// To be supplied. /// Critical = 4, ////// /// To be supplied. /// Charging = 8, ////// /// To be supplied. /// NoSystemBattery = 128, ////// /// To be supplied. /// Unknown = 255 } ////// /// public enum PowerState { ////// To be supplied. /// ////// /// To be supplied. /// Suspend = 0, ////// /// To be supplied. /// Hibernate = 1 } ////// /// public class PowerStatus { private NativeMethods.SYSTEM_POWER_STATUS systemPowerStatus; internal PowerStatus() { } ////// To be supplied. /// ////// /// public PowerLineStatus PowerLineStatus { get { UpdateSystemPowerStatus(); return (PowerLineStatus)systemPowerStatus.ACLineStatus; } } ///[To be supplied.] ////// /// public BatteryChargeStatus BatteryChargeStatus { get { UpdateSystemPowerStatus(); return (BatteryChargeStatus)systemPowerStatus.BatteryFlag; } } ///[To be supplied.] ////// /// public int BatteryFullLifetime { get { UpdateSystemPowerStatus(); return systemPowerStatus.BatteryFullLifeTime; } } ///[To be supplied.] ////// /// public float BatteryLifePercent { get { UpdateSystemPowerStatus(); float lifePercent = systemPowerStatus.BatteryLifePercent / 100f; return lifePercent > 1f ? 1f : lifePercent; } } ///[To be supplied.] ////// /// public int BatteryLifeRemaining { get { UpdateSystemPowerStatus(); return systemPowerStatus.BatteryLifeTime; } } private void UpdateSystemPowerStatus() { UnsafeNativeMethods.GetSystemPowerStatus(ref systemPowerStatus); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { ////// /// public enum PowerLineStatus { ////// To be supplied. /// ////// /// To be supplied. /// Offline = 0, ////// /// To be supplied. /// Online = 1, ////// /// To be supplied. /// Unknown = 255 } ////// /// [Flags] public enum BatteryChargeStatus { ////// To be supplied. /// ////// /// To be supplied. /// High = 1, ////// /// To be supplied. /// Low = 2, ////// /// To be supplied. /// Critical = 4, ////// /// To be supplied. /// Charging = 8, ////// /// To be supplied. /// NoSystemBattery = 128, ////// /// To be supplied. /// Unknown = 255 } ////// /// public enum PowerState { ////// To be supplied. /// ////// /// To be supplied. /// Suspend = 0, ////// /// To be supplied. /// Hibernate = 1 } ////// /// public class PowerStatus { private NativeMethods.SYSTEM_POWER_STATUS systemPowerStatus; internal PowerStatus() { } ////// To be supplied. /// ////// /// public PowerLineStatus PowerLineStatus { get { UpdateSystemPowerStatus(); return (PowerLineStatus)systemPowerStatus.ACLineStatus; } } ///[To be supplied.] ////// /// public BatteryChargeStatus BatteryChargeStatus { get { UpdateSystemPowerStatus(); return (BatteryChargeStatus)systemPowerStatus.BatteryFlag; } } ///[To be supplied.] ////// /// public int BatteryFullLifetime { get { UpdateSystemPowerStatus(); return systemPowerStatus.BatteryFullLifeTime; } } ///[To be supplied.] ////// /// public float BatteryLifePercent { get { UpdateSystemPowerStatus(); float lifePercent = systemPowerStatus.BatteryLifePercent / 100f; return lifePercent > 1f ? 1f : lifePercent; } } ///[To be supplied.] ////// /// public int BatteryLifeRemaining { get { UpdateSystemPowerStatus(); return systemPowerStatus.BatteryLifeTime; } } private void UpdateSystemPowerStatus() { UnsafeNativeMethods.GetSystemPowerStatus(ref systemPowerStatus); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- X509ThumbprintKeyIdentifierClause.cs
- PasswordRecovery.cs
- GPStream.cs
- ProviderSettings.cs
- CodeAccessSecurityEngine.cs
- PageAsyncTask.cs
- ExpressionPrefixAttribute.cs
- CounterSample.cs
- List.cs
- FeatureSupport.cs
- TextSelectionHighlightLayer.cs
- RegexFCD.cs
- HtmlForm.cs
- FrameworkReadOnlyPropertyMetadata.cs
- IndentTextWriter.cs
- Registry.cs
- PrintPageEvent.cs
- DriveNotFoundException.cs
- securitycriticaldata.cs
- SimpleFieldTemplateUserControl.cs
- InputProviderSite.cs
- Documentation.cs
- DatagridviewDisplayedBandsData.cs
- DWriteFactory.cs
- ObjectMemberMapping.cs
- dsa.cs
- NotifyInputEventArgs.cs
- DataGrid.cs
- DesignerCommandAdapter.cs
- HostingEnvironment.cs
- ThreadStaticAttribute.cs
- ImageMap.cs
- RoutedEventConverter.cs
- ArraySubsetEnumerator.cs
- HttpCookiesSection.cs
- QuaternionAnimation.cs
- C14NUtil.cs
- FixedSOMTableRow.cs
- GenericTypeParameterConverter.cs
- XmlSchemaSubstitutionGroup.cs
- TextRangeBase.cs
- WrapPanel.cs
- EntitySetBase.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- QueryCacheKey.cs
- versioninfo.cs
- HwndHost.cs
- ImageList.cs
- Size3DValueSerializer.cs
- SizeAnimationUsingKeyFrames.cs
- AccessViolationException.cs
- CheckBox.cs
- MimeTypeMapper.cs
- FilteredAttributeCollection.cs
- QilTypeChecker.cs
- DispatcherSynchronizationContext.cs
- GradientStop.cs
- ColorTransform.cs
- Focus.cs
- PathFigure.cs
- Encoding.cs
- DataSourceControlBuilder.cs
- NavigatorOutput.cs
- SelectorItemAutomationPeer.cs
- SetterBaseCollection.cs
- Atom10FormatterFactory.cs
- WindowAutomationPeer.cs
- MemoryMappedViewAccessor.cs
- ProxyWebPart.cs
- IndicShape.cs
- XpsS0ValidatingLoader.cs
- TypeElement.cs
- CallbackDebugBehavior.cs
- DynamicDocumentPaginator.cs
- GridErrorDlg.cs
- ExceptionCollection.cs
- ToggleButtonAutomationPeer.cs
- ListBindableAttribute.cs
- CroppedBitmap.cs
- StorageMappingItemCollection.cs
- InArgumentConverter.cs
- DoubleUtil.cs
- EdmType.cs
- XmlParser.cs
- Vector3DAnimationBase.cs
- DBCommand.cs
- SQLStringStorage.cs
- ArgumentException.cs
- SrgsToken.cs
- PluralizationServiceUtil.cs
- DataViewManager.cs
- PolyLineSegment.cs
- TrackingRecordPreFilter.cs
- HashStream.cs
- TemplatePropertyEntry.cs
- PointLightBase.cs
- MouseWheelEventArgs.cs
- RouteParametersHelper.cs
- ResolvedKeyFrameEntry.cs
- PackWebRequestFactory.cs