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
- ByteConverter.cs
- CurrentTimeZone.cs
- DrawingGroup.cs
- InstancePersistence.cs
- DbParameterCollectionHelper.cs
- PipeStream.cs
- GeometryHitTestResult.cs
- WebPageTraceListener.cs
- UnsafeNativeMethods.cs
- GuidelineSet.cs
- ToolBarButtonClickEvent.cs
- WpfGeneratedKnownProperties.cs
- XmlSchemaComplexContent.cs
- PaperSize.cs
- SocketStream.cs
- CapabilitiesRule.cs
- Serializer.cs
- TextChange.cs
- SchemaHelper.cs
- TailCallAnalyzer.cs
- DiagnosticSection.cs
- WebServiceResponse.cs
- GenerateScriptTypeAttribute.cs
- CreateUserWizardStep.cs
- AuthenticationModuleElement.cs
- DisableDpiAwarenessAttribute.cs
- SrgsElementList.cs
- DbExpressionVisitor.cs
- srgsitem.cs
- DbConnectionOptions.cs
- ObjectContextServiceProvider.cs
- SoapAttributeAttribute.cs
- EventManager.cs
- EntitySqlQueryCacheKey.cs
- RegexMatchCollection.cs
- ServiceEndpointElementCollection.cs
- HttpInputStream.cs
- ReturnValue.cs
- XmlObjectSerializerContext.cs
- Vector3D.cs
- PreservationFileReader.cs
- LingerOption.cs
- OutKeywords.cs
- HttpDebugHandler.cs
- UInt32Storage.cs
- NamedObject.cs
- RegexCaptureCollection.cs
- AtomPub10ServiceDocumentFormatter.cs
- MessageEnumerator.cs
- ScrollChrome.cs
- CompilerState.cs
- FontWeight.cs
- ApplicationServicesHostFactory.cs
- AdPostCacheSubstitution.cs
- PathFigureCollectionConverter.cs
- VisualBasicDesignerHelper.cs
- ThreadPool.cs
- PageEventArgs.cs
- Command.cs
- AdCreatedEventArgs.cs
- DataKeyCollection.cs
- ActivityMetadata.cs
- RequestCacheValidator.cs
- SpanIndex.cs
- HandlerMappingMemo.cs
- RegexWorker.cs
- MetadataUtilsSmi.cs
- WindowsGrip.cs
- WebPartConnectionCollection.cs
- StateInitializationDesigner.cs
- TableCellCollection.cs
- PointKeyFrameCollection.cs
- ProcessHostMapPath.cs
- HttpHostedTransportConfiguration.cs
- GenerateTemporaryTargetAssembly.cs
- ImageCollectionEditor.cs
- TextUtf8RawTextWriter.cs
- PropertyEntry.cs
- StreamMarshaler.cs
- CachedFontFace.cs
- FileLogRecordEnumerator.cs
- sapiproxy.cs
- PropertyGridView.cs
- ThreadAbortException.cs
- Matrix3DStack.cs
- CommandLineParser.cs
- _DomainName.cs
- DataGridViewRowsRemovedEventArgs.cs
- VerticalConnector.xaml.cs
- DelegatedStream.cs
- SwitchAttribute.cs
- WebPartAddingEventArgs.cs
- WindowsFormsHelpers.cs
- XmlException.cs
- BitConverter.cs
- InvalidProgramException.cs
- ByteFacetDescriptionElement.cs
- CardSpaceSelector.cs
- NativeMethods.cs
- Expression.cs