Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



HowTo: How to use the PowerStatus in System.Windows.Forms.SystemInformation


One of the new cool new classes in .net 2.0 is the PowerStatus class (http://msdn2.microsoft.com/en-us/library/system.windows.forms.systeminformation.powerstatus(VS.80).aspx ).  You can use this class to get information about the battery life of your mobile computer.  In my case this is for a Tablet PC application that I am working on for work.

For our project we wanted to get the battery life information for a Tablet PC and display to the user both the amount battery life lift as well as display a visual indicator when the battery goes below a wired percentage.  For this post, I am just going to give a simple overview of some of the different things you can do with this class.


1) Get the Power Status
Gets the current system power status.

2) Get the Charge Status
Gets the current battery charge status.

3) Get the Battery Life Percent
Gets the approximate percentage of the full battery left.

4) Get the Battery Life Remaining
Gets the approximate number of seconds of the battery time remaining.

 

5) Get the Full Life Amount for the Battery
Gets the reported full charge lifetime of the battery power source in seconds. 

There you have it, a clean and simple way to use the PowerStatus class in .net.   The namespace that this class belongs to ystem.Windows.Forms.SystemInformation has some pretty cool little features in it.  You should check it out at http://msdn2.microsoft.com/en-us/library/system.windows.forms.systeminformation_properties(VS.80).aspx

***
Hope everyone has a great Thanksgiving, I'm off till next week....
***

 

dp.SyntaxHighlighter.HighlightAll('code');


Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News