Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / PowerStatus.cs / 1 / PowerStatus.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms {
///
///
///
/// To be supplied.
///
///
public enum PowerLineStatus
{
///
///
/// To be supplied.
///
Offline = 0,
///
///
/// To be supplied.
///
Online = 1,
///
///
/// To be supplied.
///
Unknown = 255
}
///
///
///
/// To be supplied.
///
///
[Flags]
public enum BatteryChargeStatus
{
///
///
/// 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
}
///
///
///
/// To be supplied.
///
///
public enum PowerState
{
///
///
/// To be supplied.
///
Suspend = 0,
///
///
/// To be supplied.
///
Hibernate = 1
}
///
///
///
/// To be supplied.
///
///
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.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RemotingHelper.cs
- LogWriteRestartAreaState.cs
- MsmqReceiveParameters.cs
- Int16Storage.cs
- BlurBitmapEffect.cs
- Oid.cs
- ReliableSessionBindingElement.cs
- EnumMemberAttribute.cs
- OdbcPermission.cs
- TemplateBindingExpressionConverter.cs
- PinnedBufferMemoryStream.cs
- Color.cs
- Stroke2.cs
- WithParamAction.cs
- TypeSystem.cs
- ToolStripControlHost.cs
- ToolboxDataAttribute.cs
- MbpInfo.cs
- MappingSource.cs
- SizeAnimationClockResource.cs
- XmlTypeAttribute.cs
- PageThemeBuildProvider.cs
- RoutedCommand.cs
- CharAnimationBase.cs
- PrimitiveCodeDomSerializer.cs
- EdmComplexTypeAttribute.cs
- ProjectionRewriter.cs
- SRef.cs
- AssemblyBuilder.cs
- Fault.cs
- ApplicationServiceManager.cs
- ScriptReferenceBase.cs
- HitTestWithPointDrawingContextWalker.cs
- WebServiceParameterData.cs
- SystemSounds.cs
- FindRequestContext.cs
- PrimitiveCodeDomSerializer.cs
- CompoundFileIOPermission.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- DataGridViewCellPaintingEventArgs.cs
- TraceHandler.cs
- IpcClientChannel.cs
- TextPointer.cs
- Interop.cs
- SqlExpander.cs
- ControlUtil.cs
- ItemsControlAutomationPeer.cs
- Symbol.cs
- RecordManager.cs
- Line.cs
- SamlNameIdentifierClaimResource.cs
- MetricEntry.cs
- ContextMarshalException.cs
- __ComObject.cs
- TextElement.cs
- WebPartEditVerb.cs
- SafeSecurityHandles.cs
- BitmapCodecInfoInternal.cs
- StylusPointDescription.cs
- MessageCredentialType.cs
- SessionConnectionReader.cs
- SiteMapDataSourceView.cs
- EntityCommand.cs
- ImplicitInputBrush.cs
- SoapSchemaImporter.cs
- TextDecorationUnitValidation.cs
- MemberDescriptor.cs
- SortExpressionBuilder.cs
- ControlAdapter.cs
- InkPresenterAutomationPeer.cs
- WebHeaderCollection.cs
- OpenFileDialog.cs
- ButtonField.cs
- DataGridViewRowPostPaintEventArgs.cs
- CodeTypeMember.cs
- EnumUnknown.cs
- FieldAccessException.cs
- BitmapEncoder.cs
- CompilerWrapper.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- ActivityWithResultConverter.cs
- ManualWorkflowSchedulerService.cs
- XsltLibrary.cs
- StringReader.cs
- WorkflowWebService.cs
- TemplateParser.cs
- IisTraceWebEventProvider.cs
- NativeMethodsCLR.cs
- InvocationExpression.cs
- VisualTarget.cs
- PageWrapper.cs
- WebPart.cs
- DrawItemEvent.cs
- WebPartTransformerCollection.cs
- ButtonDesigner.cs
- GridItemPattern.cs
- _StreamFramer.cs
- DateTimeStorage.cs
- TemplatedMailWebEventProvider.cs
- IOException.cs