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 / 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.
//
//-----------------------------------------------------------------------------
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PathSegment.cs
- BroadcastEventHelper.cs
- StateMachine.cs
- DependencyPropertyChangedEventArgs.cs
- TemplateManager.cs
- QuotedStringFormatReader.cs
- ElementHostPropertyMap.cs
- NetNamedPipeBindingElement.cs
- PenContext.cs
- ListView.cs
- BaseDataListPage.cs
- TreeNodeBinding.cs
- ValueOfAction.cs
- TranslateTransform.cs
- WCFBuildProvider.cs
- CodeExpressionRuleDeclaration.cs
- Vector3DAnimation.cs
- StaticTextPointer.cs
- AddressingProperty.cs
- ConstructorBuilder.cs
- BinaryMessageEncodingBindingElement.cs
- Effect.cs
- MinimizableAttributeTypeConverter.cs
- RowBinding.cs
- HMACSHA512.cs
- Int32.cs
- SqlUnionizer.cs
- DataViewManager.cs
- HtmlElementErrorEventArgs.cs
- AttachedAnnotation.cs
- SoapSchemaImporter.cs
- ToolStripContentPanel.cs
- QueryOperationResponseOfT.cs
- EmptyControlCollection.cs
- Point.cs
- RelationshipConstraintValidator.cs
- VirtualizedContainerService.cs
- CollaborationHelperFunctions.cs
- Timer.cs
- StrokeCollection2.cs
- Geometry.cs
- CellParagraph.cs
- RoutedEventConverter.cs
- ExpressionQuoter.cs
- EditorPartDesigner.cs
- InheritanceContextHelper.cs
- AppLevelCompilationSectionCache.cs
- CollectionViewGroupInternal.cs
- ReaderContextStackData.cs
- CacheVirtualItemsEvent.cs
- SafeProcessHandle.cs
- ClassHandlersStore.cs
- FontNameConverter.cs
- GenerateTemporaryTargetAssembly.cs
- ArrayTypeMismatchException.cs
- HiddenField.cs
- GPPOINTF.cs
- OSEnvironmentHelper.cs
- AtomicFile.cs
- StringReader.cs
- LogWriteRestartAreaState.cs
- AppModelKnownContentFactory.cs
- ClientSession.cs
- Object.cs
- SqlProvider.cs
- ClockController.cs
- ProviderUtil.cs
- LexicalChunk.cs
- ReliableOutputConnection.cs
- ProfileManager.cs
- CapabilitiesState.cs
- Helper.cs
- XmlDomTextWriter.cs
- HeaderedContentControl.cs
- HostedElements.cs
- SimpleHandlerBuildProvider.cs
- ClonableStack.cs
- CriticalExceptions.cs
- DataGridTableCollection.cs
- StorageEndPropertyMapping.cs
- _emptywebproxy.cs
- WindowsSecurityTokenAuthenticator.cs
- TimelineGroup.cs
- DelimitedListTraceListener.cs
- TransformCollection.cs
- XPathParser.cs
- GenericWebPart.cs
- WebServiceFault.cs
- GACMembershipCondition.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ProfilePropertyNameValidator.cs
- Inline.cs
- TraceListeners.cs
- SoapSchemaImporter.cs
- ListViewItem.cs
- MemoryStream.cs
- TextView.cs
- DateTimeParse.cs
- RelatedCurrencyManager.cs
- WMIInterop.cs