From 08ae4a21acc2b1a7813b897a09b82104c81aadcd Mon Sep 17 00:00:00 2001 From: George Kushnir Date: Thu, 12 Jul 2018 08:39:53 -0400 Subject: [PATCH 1/5] Add tooltip. --- FakeSlice.cs | 61 +++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/FakeSlice.cs b/FakeSlice.cs index b009615..4d51835 100644 --- a/FakeSlice.cs +++ b/FakeSlice.cs @@ -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); - } - } -} \ No newline at end of file + 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(); + } + } +} From 51b676dcb94e2d76b5e7dbc99d70e9d1444d28bc Mon Sep 17 00:00:00 2001 From: chx Date: Mon, 25 Feb 2019 18:55:41 -0800 Subject: [PATCH 2/5] Give build instructions. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ed7ebba..be9ab7c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ This application requires Lenovo Vantage to be installed, but doesn't require yo Just throw `FakeSlice.cs` into your favorite C# compiler, target .NET Framework 4.5, and add the two required references - `Plugins.Battery.Think.Native.dll` & `Lenovo.Modern.Portable.Battery.dll`, then compile as Windows Application. +Alternatively, change to the directory where the DLLs and `FakeSlice.cs` is and run the following: `\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /platform:x86 FakeSlice.cs /r:Lenovo.Modern.Portable.Battery.dll /r:Plugins.Battery.Think.Native.dll`. + ## Run The included release binary will toggle your setting when launched without any commandline arguments. Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (ike `Fn + F12`) using Lenovo Vantage. From 057a24b1d6a6f3059d2e4fbd3f8a23acff35df13 Mon Sep 17 00:00:00 2001 From: chx Date: Mon, 25 Feb 2019 19:12:16 -0800 Subject: [PATCH 3/5] Grammar fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be9ab7c..9f763bf 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This application requires Lenovo Vantage to be installed, but doesn't require yo Just throw `FakeSlice.cs` into your favorite C# compiler, target .NET Framework 4.5, and add the two required references - `Plugins.Battery.Think.Native.dll` & `Lenovo.Modern.Portable.Battery.dll`, then compile as Windows Application. -Alternatively, change to the directory where the DLLs and `FakeSlice.cs` is and run the following: `\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /platform:x86 FakeSlice.cs /r:Lenovo.Modern.Portable.Battery.dll /r:Plugins.Battery.Think.Native.dll`. +Alternatively, change to the directory where the DLLs and `FakeSlice.cs` are and run the following: `\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /platform:x86 FakeSlice.cs /r:Lenovo.Modern.Portable.Battery.dll /r:Plugins.Battery.Think.Native.dll`. ## Run From 1bfa5c3f62d174ad59e77f26e8760de61dfe78e1 Mon Sep 17 00:00:00 2001 From: chx Date: Mon, 25 Feb 2019 19:16:23 -0800 Subject: [PATCH 4/5] Better phrasing for release and run --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f763bf..d599dd8 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,14 @@ This application requires Lenovo Vantage to be installed, but doesn't require yo ## Build +This step is optional, you can use the provided [release](https://github.com/n4ru/FakeSlice/releases/latest). + Just throw `FakeSlice.cs` into your favorite C# compiler, target .NET Framework 4.5, and add the two required references - `Plugins.Battery.Think.Native.dll` & `Lenovo.Modern.Portable.Battery.dll`, then compile as Windows Application. Alternatively, change to the directory where the DLLs and `FakeSlice.cs` are and run the following: `\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /platform:x86 FakeSlice.cs /r:Lenovo.Modern.Portable.Battery.dll /r:Plugins.Battery.Think.Native.dll`. ## Run -The included release binary will toggle your setting when launched without any commandline arguments. Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (ike `Fn + F12`) using Lenovo Vantage. +Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. Running the application without any commandline arguments will toggle your setting when launched. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (ike `Fn + F12`) using Lenovo Vantage. ### Credits to [Ciastix](https://github.com/Ciastex) for helping expose Lenovo's proprietary interface. From ebc5cfef348f41245b06f2588f697f163e2ca3ba Mon Sep 17 00:00:00 2001 From: chx Date: Mon, 25 Feb 2019 20:09:42 -0800 Subject: [PATCH 5/5] typofix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d599dd8..115e5e9 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,6 @@ Alternatively, change to the directory where the DLLs and `FakeSlice.cs` are and ## Run -Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. Running the application without any commandline arguments will toggle your setting when launched. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (ike `Fn + F12`) using Lenovo Vantage. +Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. Running the application without any commandline arguments will toggle your setting when launched. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (like `Fn + F12`) using Lenovo Vantage. ### Credits to [Ciastix](https://github.com/Ciastex) for helping expose Lenovo's proprietary interface.