etBatteryPercent ();
[DllImport ( brightness_dll.dll raquo ;, CharSet=CharSet.Ansi)]
public static extern int GetBatteryTime ();
[DllImport ( brightness_dll.dll raquo ;, CharSet=CharSet.Ansi)]
public static extern int GetFullBatteryTime ();
[DllImport ( brightness_dll.dll raquo ;, CharSet=CharSet.Ansi)]
public static extern void SetBrightness (int Brightness);
short val;
private void SwitchImg ()
{
Image img=Image.FromFile (@ img 8.png );
if (GetPowerStatus () == Power on )
{
if (GetBatteryPercent () gt;=95)
img=Image.FromFile (@ img 1.png );
if (GetBatteryPercent () lt; 95 amp; amp; GetBatteryPercent () gt;=20)
img=Image.FromFile (@ img 2.png );
if (GetBatteryPercent () lt; 20)
img=Image.FromFile (@ img 7.png );
pictureBox1.Image=img;
}
if (GetPowerStatus () == Power off )
{
if (GetBatteryPercent () gt; 50)
img=Image.FromFile (@ img 3.png );
if (GetBatteryPercent () == 50)
img=Image.FromFile (@ img 4.png );
if (GetBatteryPercent () lt; 50 amp; amp; GetBatteryPercent () gt; 10)
img=Image.FromFile (@ img 5.png );
if (GetBatteryPercent () lt;=10)
img=Image.FromFile (@ img 6.png );
pictureBox1.Image=img;
}
if (GetBatteryFlag () == Батарея відсутня )
{
img=Image.FromFile (@ img 8.png );
pictureBox1.Image=img;
}
}
Hashtable pow=new Hashtable ();
string Active;
private void GetPowers ()
{
RegistryKey Key=Registry.LocalMachine.OpenSubKey(@laquo;SYSTEMCurrentControlSetControlPowerUserPowerSchemesraquo;);
string [] powers=Key.GetSubKeyNames ();
Active=(string) Key.GetValue ( ActivePowerScheme );
string Shema;
foreach (string str in powers)
{
Key=Registry.LocalMachine.OpenSubKey (@" SYSTEM CurrentControlSet Control Power User PowerSchemes " + str);
Shema=(string) Key.GetValue ( FriendlyName );
try
{
Shema=Shema.Remove (0, Shema.LastIndexOf (, ) + 1);
}
catch {}
pow.Add (Shema, str);
}
}
private void Create_radio ()
{
RadioButton [] rb={radioButton1, radioButton2, radioButton3, radioButton4, radioButton5, radioButton6};
int i=0;
foreach (DictionaryEntry de in pow)
{
rb [i] .Visible=true;
rb [i] .Text=(string) de.Key;
if (Active == de.Value.ToString ())
{
rb [i] .Checked=true;
}
i ++;
}
for (int j=0; j lt; i - 1; j ++)
{
int h=this.Height + 23;
this.Size=new Size (this.Width, h);
groupBox3.Height=groupBox3.Height + 23;
}
}
private void Form1_Load (object sender, EventArgs e)
{
trackBar1.Value=5;
val=(short) trackBar1.Value;
val=(short) (val * 25.5);
SetBrightness (val);
label2.Text=GetPowerStatus ();
label3.Text=GetBatteryFlag ();
label4.Text=GetBatteryPercent (). ToString () + % raquo ;;
int total=GetBatteryTime ();
if (total == - 1)
...