-
Notifications
You must be signed in to change notification settings - Fork 4
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
67 changed files
with
3,277 additions
and
600 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[*.cs] | ||
|
||
# Default severity for analyzer diagnostics with category 'CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator' | ||
dotnet_analyzer_diagnostic.category-CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator.severity = none |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Release WinUI | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version' | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
env: | ||
App_Packages_Archive: IdeapadToolkit.WinUI.zip | ||
License_Path: IdeapadToolkit.WinUI\Properties\PublishProfiles\3RD_PARTY_LICENSES.txt | ||
App_Publish_Directory: bin\win-x64\publish\win-x64 | ||
App_Project_Directory: IdeapadToolkit.WinUI\ | ||
Solution_Path: IdeapadToolkit.sln | ||
Project_Path: IdeapadToolkit.WinUI\IdeapadToolkit.WinUI3.csproj | ||
Actions_Allow_Unsecure_Commands: true # Allows AddPAth and SetEnv commands | ||
Configuration: Release | ||
RuntimeIdentifier: win-x64 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | ||
|
||
# Install the .NET Core workload | ||
- name: Install .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
# Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild | ||
- name: Setup MSBuild.exe | ||
uses: microsoft/[email protected] | ||
|
||
# Restore the application | ||
- name: Restore the Wpf application to populate the obj folder | ||
run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier | ||
|
||
# Build the Windows Application Packaging project for Prod_Store | ||
- name: Build using the publish profile | ||
run: dotnet publish /p:Configuration=Release /p:PublishProfile=win-x64 | ||
|
||
# Copy license file to the publish directory | ||
- name: Copy license file to the publish directory | ||
run: Copy-Item -Path $env:License_Path -Destination $env:App_Project_Directory\$env:App_Publish_Directory\ | ||
|
||
- name: Remove all *.pdb files | ||
run: Remove-Item -Path $env:App_Project_Directory\$env:App_Publish_Directory\*.pdb -Force | ||
|
||
# Create archive | ||
- name: Create archive | ||
run: Compress-Archive -Path $env:App_Project_Directory\$env:App_Publish_Directory\* -DestinationPath $env:App_Project_Directory\$env:App_Publish_Directory\$env:App_Packages_Archive | ||
|
||
# Create the release: https://github.com/actions/create-release | ||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.event.inputs.version }} | ||
release_name: Release ${{ github.event.inputs.version }} | ||
draft: false | ||
prerelease: true | ||
|
||
# Upload release asset: https://github.com/actions/upload-release-asset | ||
- name: Update release asset | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: ${{ env.App_Project_Directory }}\${{ env.App_Publish_Directory }}\${{ env.App_Packages_Archive }} | ||
asset_name: ${{ env.App_Packages_Archive }} | ||
asset_content_type: application/zip |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Runtime.InteropServices; | ||
using static IdeapadToolkit.Core.Services.UEFISettingsService; | ||
|
||
namespace IdeapadToolkit.Core.Helpers | ||
{ | ||
internal partial class Win32 | ||
{ | ||
[LibraryImport("kernel32.dll")] | ||
public static partial nint OpenProcess( | ||
int dwDesiredAccess, | ||
[MarshalAs(UnmanagedType.Bool)] | ||
bool bInheritHandle, | ||
int dwProcessId); | ||
|
||
[LibraryImport("kernel32.dll", SetLastError = true)] | ||
public static partial int GetFirmwareEnvironmentVariableExW([MarshalAs(UnmanagedType.LPWStr)] string lpName, [MarshalAs(UnmanagedType.LPWStr)] string lpGuid, ref LenovoFlipToBootSwInterface pBuffer, int nSize, nint pAttribute); | ||
|
||
[LibraryImport("kernel32.dll", SetLastError = true)] | ||
public static partial int SetFirmwareEnvironmentVariableExW( | ||
[MarshalAs(UnmanagedType.LPWStr)] string lpName, | ||
[MarshalAs(UnmanagedType.LPWStr)] string lpGuid, | ||
ref LenovoFlipToBootSwInterface pBuffer, | ||
int nSize, | ||
int attribute); | ||
|
||
[LibraryImport("kernel32.dll")] | ||
public static partial nint GetCurrentProcess(); | ||
|
||
[LibraryImport("advapi32.dll", StringMarshalling = StringMarshalling.Utf8)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
public static partial bool LookupPrivilegeValue( | ||
string lpSystemName, | ||
string lpName, | ||
ref long lpLuid); | ||
|
||
[LibraryImport("advapi32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
public static partial bool AdjustTokenPrivileges( | ||
nint tokenHandle, | ||
[MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges, | ||
ref TokenPrivelege newState, | ||
int zero, | ||
nint null1, | ||
nint null2); | ||
|
||
[LibraryImport("advapi32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
public static partial bool OpenProcessToken( | ||
nint processHandle, | ||
uint desiredAccess, | ||
ref nint tokenHandle); | ||
|
||
[LibraryImport("kernel32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
public static partial bool GetFirmwareType(ref FirmwareType firmwareType); | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
public struct TokenPrivelege | ||
{ | ||
public int Count; | ||
public long Luid; | ||
public int Attr; | ||
} | ||
public enum FirmwareType | ||
{ | ||
FirmwareTypeUnknown, | ||
FirmwareTypeBios, | ||
FirmwareTypeUefi, | ||
FirmwareTypeMax, | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<IsAotCompatible>true</IsAotCompatible> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog" Version="4.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
24 changes: 12 additions & 12 deletions
24
IdeapadToolkit/Models/CChargingMode.cs → IdeapadToolkit.Core/Models/CChargingMode.cs
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,12 +1,12 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CChargingMode | ||
{ | ||
private long value; | ||
} | ||
} | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Core.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CChargingMode | ||
{ | ||
private long value; | ||
} | ||
} |
24 changes: 12 additions & 12 deletions
24
IdeapadToolkit/Models/CIntelligentCooling.cs → ...oolkit.Core/Models/CIntelligentCooling.cs
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,12 +1,12 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CIntelligentCooling | ||
{ | ||
private long value; | ||
} | ||
} | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Core.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CIntelligentCooling | ||
{ | ||
private long value; | ||
} | ||
} |
24 changes: 12 additions & 12 deletions
24
IdeapadToolkit/Models/CUSBBatteryCharger.cs → ...Toolkit.Core/Models/CUSBBatteryCharger.cs
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,12 +1,12 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CUSBBatteryCharger | ||
{ | ||
private long value; | ||
} | ||
} | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Core.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CUSBBatteryCharger | ||
{ | ||
private long value; | ||
} | ||
} |
24 changes: 12 additions & 12 deletions
24
IdeapadToolkit/Models/CUSBCharger.cs → IdeapadToolkit.Core/Models/CUSBCharger.cs
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,12 +1,12 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CUSBCharger | ||
{ | ||
private long value; | ||
} | ||
} | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace IdeapadToolkit.Core.Models | ||
{ | ||
[NativeCppClass] | ||
[StructLayout(LayoutKind.Sequential, Size = 16)] | ||
public struct CUSBCharger | ||
{ | ||
private long value; | ||
} | ||
} |
18 changes: 9 additions & 9 deletions
18
IdeapadToolkit/Models/ChargingMode.cs → IdeapadToolkit.Core/Models/ChargingMode.cs
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,9 +1,9 @@ | ||
namespace IdeapadToolkit.Models | ||
{ | ||
public enum ChargingMode | ||
{ | ||
Conservation = 1, | ||
Normal = 0, | ||
Rapid = 2 | ||
} | ||
} | ||
namespace IdeapadToolkit.Core.Models | ||
{ | ||
public enum ChargingMode | ||
{ | ||
Conservation = 1, | ||
Normal = 0, | ||
Rapid = 2 | ||
} | ||
} |
18 changes: 9 additions & 9 deletions
18
IdeapadToolkit/Models/PowerPlanEnum.cs → IdeapadToolkit.Core/Models/PowerPlanEnum.cs
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,9 +1,9 @@ | ||
namespace IdeapadToolkit.Models | ||
{ | ||
public enum PowerPlan | ||
{ | ||
IntelligentCooling = 1, | ||
ExtremePerformance = 3, | ||
EfficiencyMode = 2 | ||
} | ||
} | ||
namespace IdeapadToolkit.Core.Models | ||
{ | ||
public enum PowerPlan | ||
{ | ||
IntelligentCooling = 1, | ||
ExtremePerformance = 3, | ||
EfficiencyMode = 2 | ||
} | ||
} |
59 changes: 29 additions & 30 deletions
59
...ervices/AdministratorPermissionService.cs → ...ervices/AdministratorPermissionService.cs
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,30 +1,29 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Security.Principal; | ||
|
||
namespace IdeapadToolkit.Services | ||
{ | ||
public class AdministratorPermissionService : IAdministratorPermissionService | ||
{ | ||
public bool IsAdministrator | ||
{ | ||
get | ||
{ | ||
var identity = WindowsIdentity.GetCurrent(); | ||
var principal = new WindowsPrincipal(identity); | ||
return principal.IsInRole(WindowsBuiltInRole.Administrator); | ||
} | ||
} | ||
|
||
public void RelaunchAsAdmin() | ||
{ | ||
var proc = new Process | ||
{ | ||
StartInfo = | ||
{FileName = Environment.ProcessPath, UseShellExecute = true, Verb = "runas", Arguments="ignoreRunning"} | ||
}; | ||
proc.Start(); | ||
Environment.Exit(0); | ||
} | ||
} | ||
} | ||
using System.Diagnostics; | ||
using System.Security.Principal; | ||
|
||
namespace IdeapadToolkit.Core.Services | ||
{ | ||
public class AdministratorPermissionService : IAdministratorPermissionService | ||
{ | ||
public bool IsAdministrator | ||
{ | ||
get | ||
{ | ||
var identity = WindowsIdentity.GetCurrent(); | ||
var principal = new WindowsPrincipal(identity); | ||
return principal.IsInRole(WindowsBuiltInRole.Administrator); | ||
} | ||
} | ||
|
||
public void RelaunchAsAdmin() | ||
{ | ||
var proc = new Process | ||
{ | ||
StartInfo = | ||
{FileName = Environment.ProcessPath, UseShellExecute = true, Verb = "runas", Arguments="ignoreRunning"} | ||
}; | ||
proc.Start(); | ||
Environment.Exit(0); | ||
} | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
...rvices/IAdministratorPermissionService.cs → ...rvices/IAdministratorPermissionService.cs
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,8 +1,8 @@ | ||
namespace IdeapadToolkit.Services | ||
{ | ||
public interface IAdministratorPermissionService | ||
{ | ||
public bool IsAdministrator { get; } | ||
public void RelaunchAsAdmin(); | ||
} | ||
} | ||
namespace IdeapadToolkit.Core.Services | ||
{ | ||
public interface IAdministratorPermissionService | ||
{ | ||
public bool IsAdministrator { get; } | ||
public void RelaunchAsAdmin(); | ||
} | ||
} |
Oops, something went wrong.