Exemplo n.º 1
0
        private void showCurrentLevelButton_Click(object sender, EventArgs e)
        {
            if ( !this.initialized ) return;

            BatteryStatus battery = new BatteryStatus();
            this.AddLog("バッテリ残量: " + (battery.LifePercent.HasValue ? battery.LifePercent.ToString() + " %" : "不明"));
            this.AddLog("充電中: " + (battery.Charging.HasValue ? (battery.Charging.Value ? "はい" : "いいえ") : "不明"));
            this.AddLog("電源接続中: " + (battery.PowerLineConnecting.HasValue ? (battery.PowerLineConnecting.Value ? "はい" : "いいえ") : "不明"));
        }
Exemplo n.º 2
0
        private void RecordLevel()
        {
            this.lastRecord = DateTime.Now;

            BatteryStatus bs = new BatteryStatus();

            if ( !this.setting.EnableRecordOnBatteryCharging )
            {
                if ( !bs.Charging.HasValue )
                {
                    this.AddLog("充電状態が不明です");
                    return;
                }
                if ( bs.Charging.Value )
                {
                    this.AddLog("充電中のため記録しませんでした");
                    return;
                }
            }

            if ( !this.setting.EnableRecordOnPowerConnecting )
            {
                if ( !bs.PowerLineConnecting.HasValue )
                {
                    this.AddLog("電源状態が不明です");
                    return;
                }
                if ( bs.PowerLineConnecting.Value )
                {
                    this.AddLog("電源接続中のため記録しませんでした");
                    return;
                }
            }

            if ( !bs.LifePercent.HasValue )
            {
                this.AddLog("バッテリレベルが不明です");
                return;
            }

            Record record = new Record(DateTime.Now, bs.LifePercent.Value);
            this.recordManager.Add(record);
            this.recordManager.Save();

            if ( this.setting.EnableLevelLog )
            {
                this.logger.Write(DateTime.Now, bs.LifePercent.Value);
            }
        }