mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a45d693937 | ||
|
|
0db49af310 | ||
|
|
28daaf9a4c | ||
|
|
38d02ee7f9 | ||
|
|
c6d1b29a49 |
@@ -12,7 +12,7 @@ public static class AppConfig
|
|||||||
private static string? _bios;
|
private static string? _bios;
|
||||||
|
|
||||||
private static Dictionary<string, object> config = new Dictionary<string, object>();
|
private static Dictionary<string, object> config = new Dictionary<string, object>();
|
||||||
private static System.Timers.Timer timer = new System.Timers.Timer(1000);
|
private static System.Timers.Timer timer = new System.Timers.Timer(2000);
|
||||||
|
|
||||||
static AppConfig()
|
static AppConfig()
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,9 @@ public static class AppConfig
|
|||||||
|
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
|
|
||||||
if (File.ReadAllText(backup).Contains("}"))
|
var backupText = File.ReadAllText(backup);
|
||||||
|
|
||||||
|
if (backupText.Contains("{") && backupText.Contains("}"))
|
||||||
{
|
{
|
||||||
File.Copy(backup, configFile, true);
|
File.Copy(backup, configFile, true);
|
||||||
}
|
}
|
||||||
@@ -219,6 +221,7 @@ public static class AppConfig
|
|||||||
|
|
||||||
private static void Write()
|
private static void Write()
|
||||||
{
|
{
|
||||||
|
timer.Stop();
|
||||||
timer.Start();
|
timer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -505,7 +505,10 @@ namespace GHelper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
eCoresMax = Math.Max(8, eCoresMax);
|
if (eCoresMax == 0) eCoresMax = 8;
|
||||||
|
if (pCoresMax == 0) pCoresMax = 6;
|
||||||
|
|
||||||
|
eCoresMax = Math.Max(4, eCoresMax);
|
||||||
pCoresMax = Math.Max(6, pCoresMax);
|
pCoresMax = Math.Max(6, pCoresMax);
|
||||||
|
|
||||||
panelCores.Visible = true;
|
panelCores.Visible = true;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.192</AssemblyVersion>
|
<AssemblyVersion>0.193</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -2,21 +2,31 @@
|
|||||||
|
|
||||||
public static class TouchscreenHelper
|
public static class TouchscreenHelper
|
||||||
{
|
{
|
||||||
public static bool? ToggleTouchscreen()
|
|
||||||
|
public static bool? GetStatus()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProcessHelper.RunAsAdmin();
|
ProcessHelper.RunAsAdmin();
|
||||||
|
return ProcessHelper.RunCMD("powershell", "(Get-PnpDevice -FriendlyName '*touch*screen*').Status").Contains("OK");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine($"Can't get touchscreen status: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var status = !ProcessHelper.RunCMD("powershell", "(Get-PnpDevice -FriendlyName '*touch*screen*').Status").Contains("OK");
|
public static void ToggleTouchscreen(bool status)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ProcessHelper.RunAsAdmin();
|
||||||
ProcessHelper.RunCMD("powershell", (status ? "Enable-PnpDevice" : "Disable-PnpDevice") + " -InstanceId (Get-PnpDevice -FriendlyName '*touch*screen*').InstanceId -Confirm:$false");
|
ProcessHelper.RunCMD("powershell", (status ? "Enable-PnpDevice" : "Disable-PnpDevice") + " -InstanceId (Get-PnpDevice -FriendlyName '*touch*screen*').InstanceId -Confirm:$false");
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WriteLine($"Can't toggle touchscreen: {ex.Message}");
|
Logger.WriteLine($"Can't toggle touchscreen: {ex.Message}");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -591,9 +591,13 @@ namespace GHelper.Input
|
|||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
|
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
|
||||||
break;
|
break;
|
||||||
case "touchscreen":
|
case "touchscreen":
|
||||||
var touchscreenStatus = TouchscreenHelper.ToggleTouchscreen();
|
var status = !TouchscreenHelper.GetStatus();
|
||||||
if (touchscreenStatus is not null)
|
Logger.WriteLine("Touchscreen status: " + status);
|
||||||
Program.toast.RunToast(Properties.Strings.Touchscreen + " " + ((bool)touchscreenStatus ? Properties.Strings.On : Properties.Strings.Off), ToastIcon.Touchpad);
|
if (status is not null)
|
||||||
|
{
|
||||||
|
Program.toast.RunToast(Properties.Strings.Touchscreen + " " + ((bool)status ? Properties.Strings.On : Properties.Strings.Off), ToastIcon.Touchpad);
|
||||||
|
TouchscreenHelper.ToggleTouchscreen((bool)status);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user