Exemple #1
0
        private void timer_tick(object sender, EventArgs e)
        {
            System.Windows.Forms.PowerStatus power = System.Windows.Forms.SystemInformation.PowerStatus;



            int powerPercent = (int)(power.BatteryLifePercent * 100);

            switch (power.PowerLineStatus)
            {
            case System.Windows.Forms.PowerLineStatus.Online:
                if (forms.critical == true)
                {
                    forms.HideSign();
                }
                break;

            case System.Windows.Forms.PowerLineStatus.Offline:
                if (powerPercent <= 10 && forms.critical == false)
                {
                    forms.ShowSign();
                }
                break;
            }
        }
        public static BatteryInfo GetInfo()
        {
            System.Windows.Forms.PowerStatus status = System.Windows.Forms.SystemInformation.PowerStatus;

            return(new BatteryInfo
            {
                ChargePercent = (UInt16)(status.BatteryLifePercent * 100),
                Status = (BatteryStatus)status.PowerLineStatus
            });
        }
 float Casey.TraySystemMonitor.Ext.IStatusProvider.NextValue()
 {
     System.Windows.Forms.PowerStatus ps = System.Windows.Forms.SystemInformation.PowerStatus;
     return(ps.BatteryLifePercent * 100);
 }
Exemple #4
0
 public BatteryInfo(System.Windows.Forms.PowerStatus power)
 {
     Percent     = (int)(power.BatteryLifePercent * 100);
     PowerOnline = power.PowerLineStatus == System.Windows.Forms.PowerLineStatus.Online;
 }