Skip to content

Commit

Permalink
Merge branch 'feat/osd_always_on_top' of https://github.com/Ace-Radom…
Browse files Browse the repository at this point in the history
…/LenovoLegionToolkit into feat/osd_always_on_top
  • Loading branch information
Ace-Radom committed Oct 2, 2024
2 parents 159a070 + 778645f commit 4a28744
Show file tree
Hide file tree
Showing 64 changed files with 3,180 additions and 457 deletions.
68 changes: 68 additions & 0 deletions LenovoLegionToolkit.Lib.Automation/Resources/Resource.nl-nl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,72 @@
<data name="ExternalDisplayDisconnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer een extern beeldscherm is losgekoppeld</value>
</data>
<data name="DisplayOnAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer de schermen ingeschakeld worden</value>
</data>
<data name="DisplayOffAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer de schermen uitgeschakeld worden</value>
</data>
<data name="LidOpenedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Deksel geopend</value>
</data>
<data name="LidClosedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Deksel gesloten</value>
</data>
<data name="GamesStopAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer spel afgesloten wordt</value>
</data>
<data name="GamesAreRunningAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer het spel draait</value>
</data>
<data name="UserInactivityAutomationPipelineTrigger_DisplayName_Zero" xml:space="preserve">
<value>Wanneer gebruiker actief wordt</value>
</data>
<data name="UserInactivityAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer gebruiker inactief wordt</value>
</data>
<data name="DeactivateGpuQuickAction_Title" xml:space="preserve">
<value>GPU uitschakelen</value>
<comment>The display name of the default Quick Action that is presented to the user upon first installation.</comment>
</data>
<data name="OverclockDiscreteGPUAutomationStepState_Off" xml:space="preserve">
<value>Uit</value>
</data>
<data name="OverclockDiscreteGPUAutomationStepState_On" xml:space="preserve">
<value>Aan</value>
</data>
<data name="GodModePresetChangedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer aangepaste modus wordt veranderd</value>
</data>
<data name="PeriodicActionPipelineTrigger_DisplayName" xml:space="preserve">
<value>Periodieke actie</value>
<comment>The display name of the periodic automation action.</comment>
</data>
<data name="WiFiConnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer WiFi verbinding is verbonden</value>
</data>
<data name="WiFiDisconnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer WiFi verbinding is verbroken</value>
</data>
<data name="OnResumeAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Na het hervatten</value>
</data>
<data name="HDROffAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer HDR uitgeschakeld wordt</value>
</data>
<data name="HDROnAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer HDR ingeschakeld wordt</value>
</data>
<data name="MacroAutomationStepState_Off" xml:space="preserve">
<value>Uit</value>
</data>
<data name="MacroAutomationStepState_On" xml:space="preserve">
<value>Aan</value>
</data>
<data name="DeviceDisconnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer apparaat niet verbonden is</value>
</data>
<data name="DeviceConnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Wanneer apparaat verbonden is</value>
</data>
</root>
21 changes: 20 additions & 1 deletion LenovoLegionToolkit.Lib.Automation/Resources/Resource.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<value>Gdy jest podłączony zasilacz o słabej mocy</value>
</data>
<data name="OnStartupAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Przy włączeniu</value>
<value>Przy uruchomieniu</value>
</data>
<data name="PowerModeAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy tryb zasilania ulegnie zmianie</value>
Expand Down Expand Up @@ -196,16 +196,35 @@
<data name="GodModePresetChangedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy szablon trybu własnego ulegnie zmianie</value>
</data>
<data name="PeriodicActionPipelineTrigger_DisplayName" xml:space="preserve">
<value>Akcja periodyczna</value>
<comment>The display name of the periodic automation action.</comment>
</data>
<data name="WiFiConnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy połączono z WiFi</value>
</data>
<data name="WiFiDisconnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy rozłączono z WiFi</value>
</data>
<data name="OnResumeAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Przy wybudzeniu</value>
</data>
<data name="HDROffAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy HDR jest wyłączony</value>
</data>
<data name="HDROnAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy HDR jest włączony</value>
</data>
<data name="MacroAutomationStepState_Off" xml:space="preserve">
<value>Wyłączone</value>
</data>
<data name="MacroAutomationStepState_On" xml:space="preserve">
<value>Włączone</value>
</data>
<data name="DeviceDisconnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy odłączane jest urządzenie</value>
</data>
<data name="DeviceConnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Gdy podłączane jest urządzenie</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
<data name="OnResumeAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Ao retomar</value>
</data>
<data name="HDROffAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Quando o HDR for desligado</value>
</data>
<data name="HDROnAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>Quando o HDR for ligado</value>
</data>
<data name="MacroAutomationStepState_Off" xml:space="preserve">
<value>Desativado</value>
</data>
Expand Down
18 changes: 18 additions & 0 deletions LenovoLegionToolkit.Lib.Automation/Resources/Resource.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,22 @@
<data name="OnResumeAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>При возобновлении</value>
</data>
<data name="HDROffAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>При отключении HDR</value>
</data>
<data name="HDROnAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>При включении HDR</value>
</data>
<data name="MacroAutomationStepState_Off" xml:space="preserve">
<value>Откл.</value>
</data>
<data name="MacroAutomationStepState_On" xml:space="preserve">
<value>Вкл.</value>
</data>
<data name="DeviceDisconnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>При отсоединении устройства</value>
</data>
<data name="DeviceConnectedAutomationPipelineTrigger_DisplayName" xml:space="preserve">
<value>При соединении устройства</value>
</data>
</root>
6 changes: 6 additions & 0 deletions LenovoLegionToolkit.Lib.Macro/Resources/Resource.nl-nl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="MacroSource_Keyboard" xml:space="preserve">
<value>Toetsenbord</value>
</data>
<data name="MacroSource_Mouse" xml:space="preserve">
<value>Muis</value>
</data>
</root>
6 changes: 6 additions & 0 deletions LenovoLegionToolkit.Lib.Macro/Resources/Resource.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="MacroSource_Keyboard" xml:space="preserve">
<value>Klawiatura</value>
</data>
<data name="MacroSource_Mouse" xml:space="preserve">
<value>Mysz</value>
</data>
</root>
6 changes: 6 additions & 0 deletions LenovoLegionToolkit.Lib.Macro/Resources/Resource.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="MacroSource_Keyboard" xml:space="preserve">
<value>Клавиатура</value>
</data>
<data name="MacroSource_Mouse" xml:space="preserve">
<value>Мышь</value>
</data>
</root>
6 changes: 6 additions & 0 deletions LenovoLegionToolkit.Lib.Macro/Resources/Resource.tr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="MacroSource_Keyboard" xml:space="preserve">
<value>Klavye</value>
</data>
<data name="MacroSource_Mouse" xml:space="preserve">
<value>Fare</value>
</data>
</root>
6 changes: 3 additions & 3 deletions LenovoLegionToolkit.Lib/LenovoLegionToolkit.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
<PackageReference Include="CoordinateSharp" Version="2.23.1.1" />
<PackageReference Include="ManagedNativeWifi" Version="2.5.0" />
<PackageReference Include="CoordinateSharp" Version="2.24.2.1" />
<PackageReference Include="ManagedNativeWifi" Version="2.6.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
Expand All @@ -27,7 +27,7 @@
<PackageReference Include="NeoSmart.AsyncLock" Version="3.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" />
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Octokit" Version="13.0.1" />
<PackageReference Include="TaskScheduler" Version="2.11.0" />
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -63,10 +62,10 @@ private static async Task TryValidateChecksum(Package package, string tempPath,
return;
}
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
catch (HttpRequestException ex)
{
if (Log.Instance.IsTraceEnabled)
Log.Instance.Trace($"External file checksum not found. [fileName={package.FileName}, fileLocation={package.FileLocation}, fileCrc={package.FileCrc}]");
Log.Instance.Trace($"External file checksum not found. [statusCode={ex.StatusCode}, fileName={package.FileName}, fileLocation={package.FileLocation}, fileCrc={package.FileCrc}]");
}

if (Log.Instance.IsTraceEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public Task<bool> DetectInstallNeededAsync(List<DriverInfo> _1, HttpClient _2, C

var keyExists = Registry.ValueExists(hive, path, KeyName);
if (!keyExists)
return Task.FromResult(true);
return Task.FromResult(false);

var versionString = Registry.GetValue(hive, path, KeyName, string.Empty);

if (versionString.Any(char.IsWhiteSpace))
versionString = versionString.Split(null).FirstOrDefault(versionString);

if (!Version.TryParse(versionString, out var version))
return Task.FromResult(false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -43,7 +42,7 @@ public override async Task<List<Package>> GetPackagesAsync(string machineType, O
if (!IsCompatible(downloadNode, osString))
continue;

var package = await ParsePackageAsync(httpClient, downloadNode!, token).ConfigureAwait(false);
var package = ParsePackage(downloadNode!);
if (package is null)
continue;

Expand All @@ -53,7 +52,7 @@ public override async Task<List<Package>> GetPackagesAsync(string machineType, O
return packages;
}

private static async Task<Package?> ParsePackageAsync(HttpClient httpClient, JsonNode downloadNode, CancellationToken token)
private static Package? ParsePackage(JsonNode downloadNode)
{
var id = downloadNode["ID"]!.ToJsonString();
var category = downloadNode["Category"]!["Name"]!.ToString();
Expand All @@ -62,31 +61,30 @@ public override async Task<List<Package>> GetPackagesAsync(string machineType, O
var version = downloadNode["SummaryInfo"]!["Version"]!.ToString();

var filesNode = downloadNode["Files"]!.AsArray();
var mainFileNode = filesNode.FirstOrDefault(n => n!["TypeString"]!.ToString() == "EXE") ?? filesNode.FirstOrDefault();
var mainFileNode = filesNode.FirstOrDefault(n => n!["TypeString"]!.ToString().Equals("exe", StringComparison.InvariantCultureIgnoreCase))
?? filesNode.FirstOrDefault(n => n!["TypeString"]!.ToString().Equals("zip", StringComparison.InvariantCultureIgnoreCase))
?? filesNode.FirstOrDefault();

if (mainFileNode is null)
return null;

var fileLocation = mainFileNode["URL"]!.ToString();
var fileName = fileLocation[(fileLocation.LastIndexOf('/') + 1)..];
var fileName = new Uri(fileLocation).Segments.LastOrDefault("file");
var fileSize = mainFileNode["Size"]!.ToString();
var fileCrc = mainFileNode["SHA256"]?.ToString();
var releaseDateUnix = long.Parse(mainFileNode["Date"]!["Unix"]!.ToString());
var releaseDate = DateTimeOffset.FromUnixTimeMilliseconds(releaseDateUnix).DateTime;

string? readme = null;
var readmeFileNode = downloadNode["Files"]!.AsArray().FirstOrDefault(n => n!["TypeString"]!.ToString() == "TXT README");
if (readmeFileNode is not null)
{
var readmeLocation = readmeFileNode["URL"]!.ToString();
readme = await GetReadmeAsync(httpClient, readmeLocation, token).ConfigureAwait(false);
}
var readmeFileNode = filesNode.FirstOrDefault(n => n!["TypeString"]!.ToString().Equals("txt readme", StringComparison.InvariantCultureIgnoreCase))
?? filesNode.FirstOrDefault(n => n!["TypeString"]!.ToString().Equals("html", StringComparison.InvariantCultureIgnoreCase));

var readme = readmeFileNode?["URL"]?.ToString();

return new()
{
Id = id,
Title = title,
Description = (title == description) ? string.Empty : description,
Description = title == description ? string.Empty : description,
Version = version,
Category = category,
FileName = fileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static async Task<Package> GetPackage(HttpClient httpClient, VantagePack
var releaseDateString = document.SelectSingleNode("/Package/ReleaseDate")!.InnerText;
var releaseDate = DateTime.Parse(releaseDateString);
var readmeName = document.SelectSingleNode("/Package/Files/Readme/File/Name")?.InnerText;
var readme = await GetReadmeAsync(httpClient, $"{baseLocation}/{readmeName}", token).ConfigureAwait(false);
var readme = $"{baseLocation}/{readmeName}";
var fileLocation = $"{baseLocation}/{fileName}";
var rebootString = document.SelectSingleNode("/Package/Reboot/@type")!.InnerText;
var reboot = int.TryParse(rebootString, out var rebootInt) ? (RebootType)rebootInt : RebootType.NotRequired;
Expand Down
Loading

0 comments on commit 4a28744

Please sign in to comment.