-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
using Lenovo.Modern.Portable.Battery; | ||
using Native; | ||
using System; | ||
|
||
namespace ThinkBattery | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
|
||
var batInterface = new BatteryInterface(); | ||
var chargeStatus = batInterface.QueryBattery(1).SmartBatteryStatus.ChargeStatus.GetValue(); | ||
var chargeStatusTwo = batInterface.QueryBattery(2).SmartBatteryStatus.ChargeStatus.GetValue(); | ||
var bat = new ChargeThreshold { | ||
IsEnabled = true, | ||
SlotNumber = 1, | ||
StartValue = 0, | ||
StopValue = 0 | ||
}; | ||
if (chargeStatus == "Charging" || chargeStatusTwo == "Charging") { | ||
bat.StopValue = 1; | ||
} | ||
if (args.Length == 1 && args[0] == "on") { | ||
bat.StopValue = 1; | ||
} else if (args.Length == 1 && args[0] == "off") { | ||
bat.StopValue = 0; | ||
} | ||
batInterface.SetChargeThreshold(bat); | ||
bat.SlotNumber = 2; | ||
batInterface.SetChargeThreshold(bat); | ||
} | ||
} | ||
} | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var batInterface = new BatteryInterface(); | ||
var chargeStatus = batInterface.QueryBattery(1).SmartBatteryStatus.ChargeStatus.GetValue(); | ||
var chargeStatusTwo = batInterface.QueryBattery(2).SmartBatteryStatus.ChargeStatus.GetValue(); | ||
var notification = new System.Windows.Forms.NotifyIcon() | ||
{ | ||
Visible = true, | ||
Icon = System.Drawing.SystemIcons.Information, | ||
BalloonTipTitle = "FakeSlice", | ||
BalloonTipText = "Charging battery." | ||
}; | ||
var bat = new ChargeThreshold { | ||
IsEnabled = true, | ||
SlotNumber = 1, | ||
StartValue = 0, | ||
StopValue = 0 | ||
}; | ||
if ((chargeStatus == "Charging" || chargeStatusTwo == "Charging") && (args.Length == 0 || (args.Length == 1 && args[0] != "off"))) { | ||
bat.StopValue = 1; | ||
notification.BalloonTipText = "Running on external power."; | ||
} | ||
batInterface.SetChargeThreshold(bat); | ||
bat.SlotNumber = 2; | ||
batInterface.SetChargeThreshold(bat); | ||
notification.ShowBalloonTip(1000); | ||
notification.Dispose(); | ||
} | ||
} | ||
} |