using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
namespace pil_seviyesi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void RefreshStatus()
{
PowerStatus power = SystemInformation.PowerStatus;
// Show the main power status
switch (power.PowerLineStatus)
{
case PowerLineStatus.Online:
MainsPower.Checked = true;
break;
case PowerLineStatus.Offline:
MainsPower.Checked = false;
break;
case PowerLineStatus.Unknown:
MainsPower.CheckState = CheckState.Indeterminate;
break;
}
// Power level
int powerPercent = (int)(power.BatteryLifePercent * 100);
if (powerPercent <= 100)
{
BatteryIndicator.Value = powerPercent;
label3.Text = "%" + powerPercent.ToString();
}
else
{
BatteryIndicator.Value = 0;
}
// Battery Remaining
int secondsRemaining = power.BatteryLifeRemaining;
if (secondsRemaining >= 0)
{
BatteryLifeRemaining.Text = string.Format("{0} Dk.", secondsRemaining / 60);
}
else
{
BatteryLifeRemaining.Text = string.Empty;
}
// Battery Status
BatteryStatus.Text = power.BatteryChargeStatus.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
RefreshStatus();
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
RefreshStatus();
}
//MainsPower checkbox
//BatteryIndicator proggesbar
//BatteryLifeRemaining label4
//BatteryStatus label5
}
}
0 yorum:
Yorum Gönder