Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / PowerStatus.cs / 1305376 / 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
- ProvideValueServiceProvider.cs
- ContractInferenceHelper.cs
- Attributes.cs
- CatalogPart.cs
- SqlLiftIndependentRowExpressions.cs
- IconHelper.cs
- RequestSecurityTokenSerializer.cs
- RectangleConverter.cs
- CryptoConfig.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ServiceInfoCollection.cs
- HeaderedItemsControl.cs
- ActiveXContainer.cs
- ObjectDataSourceDisposingEventArgs.cs
- WebPartDisplayModeCancelEventArgs.cs
- Event.cs
- MLangCodePageEncoding.cs
- SqlError.cs
- EncodingTable.cs
- DataControlImageButton.cs
- TextRangeEditTables.cs
- ReferenceConverter.cs
- ToolboxItemFilterAttribute.cs
- Token.cs
- CodeThrowExceptionStatement.cs
- ProviderCollection.cs
- HttpHandlersSection.cs
- InvalidWMPVersionException.cs
- MimeBasePart.cs
- Menu.cs
- StylusPointPropertyInfo.cs
- NetSectionGroup.cs
- RouteCollection.cs
- RepeatBehaviorConverter.cs
- NameTable.cs
- CompoundFileStorageReference.cs
- ObfuscationAttribute.cs
- FieldNameLookup.cs
- BinaryExpression.cs
- ZoneMembershipCondition.cs
- CheckBoxStandardAdapter.cs
- PropertyValueUIItem.cs
- DateBoldEvent.cs
- WorkerRequest.cs
- CounterCreationDataCollection.cs
- SHA512.cs
- SystemInformation.cs
- FamilyTypeface.cs
- SharedUtils.cs
- AuthorizationRuleCollection.cs
- SqlDataSourceSelectingEventArgs.cs
- TextRunTypographyProperties.cs
- AlphabetConverter.cs
- PreProcessor.cs
- DetailsViewPageEventArgs.cs
- BaseDataBoundControl.cs
- SQLByteStorage.cs
- GacUtil.cs
- TemplateManager.cs
- CancelRequestedQuery.cs
- WindowsAuthenticationEventArgs.cs
- Imaging.cs
- InputScopeManager.cs
- DataServiceHostWrapper.cs
- ArglessEventHandlerProxy.cs
- FtpWebResponse.cs
- SimpleRecyclingCache.cs
- ProxyManager.cs
- MsmqTransportReceiveParameters.cs
- XmlSchemaSimpleTypeRestriction.cs
- SessionStateContainer.cs
- IProducerConsumerCollection.cs
- SessionStateItemCollection.cs
- MethodBody.cs
- DrawingContextDrawingContextWalker.cs
- XmlSchemaParticle.cs
- MDIClient.cs
- NegationPusher.cs
- DropSource.cs
- XmlSchemaFacet.cs
- ContainerFilterService.cs
- RtType.cs
- CrossSiteScriptingValidation.cs
- SqlIdentifier.cs
- ZoneButton.cs
- PenThreadPool.cs
- TextLineResult.cs
- DataListItemCollection.cs
- CounterSetInstance.cs
- MouseButton.cs
- SuppressMergeCheckAttribute.cs
- StructuralCache.cs
- SecurityContext.cs
- PrimarySelectionGlyph.cs
- Trace.cs
- SessionStateModule.cs
- ConnectionPoolManager.cs
- TextureBrush.cs
- TaskFormBase.cs
- ManagementEventArgs.cs