Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
port to avalonia 11 rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
vddCore committed Jul 1, 2023
1 parent 47eeff4 commit 7c1a183
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 21 deletions.
3 changes: 1 addition & 2 deletions Slate/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
<Application.Styles>
<fa:FluentAvaloniaTheme PreferSystemTheme="False"
PreferUserAccentColor="True"
UseSystemFontOnWindows="True"
RequestedTheme="Dark" />
UseSystemFontOnWindows="True" />

<StyleInclude Source="/Resources/Styles/ToggleSwitch.axaml" />
<StyleInclude Source="/Resources/Styles/Card.axaml" />
Expand Down
6 changes: 2 additions & 4 deletions Slate/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ public override void OnFrameworkInitializationCompleted()

base.OnFrameworkInitializationCompleted();

TrayIcon.GetIcons(this)[0].IsVisible = true;

_platformSettings = AvaloniaLocator.Current.GetRequiredService<IPlatformSettings>();
_platformSettings.ColorValuesChanged += PlatformSettings_ColorValuesChanged;
TrayIcon.GetIcons(this)![0].IsVisible = true;
PlatformSettings!.ColorValuesChanged += PlatformSettings_ColorValuesChanged;
}

private void OnMainWindowTransitionFinished(MainWindowTransitionFinishedMessage msg)
Expand Down
9 changes: 9 additions & 0 deletions Slate/Infrastructure/Services/IApplicationExecutionService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Glitonea.Mvvm;

namespace Slate.Infrastructure.Services
{
public interface IApplicationExecutionService : IService
{
void RunElevatedProcess(string path);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Diagnostics;
using System.IO;

namespace Slate.Infrastructure.Services.Implementations
{
public class ApplicationExecutionService : IApplicationExecutionService
{
public void RunElevatedProcess(string path)
{
Process.Start(new ProcessStartInfo
{
UseShellExecute = true,
WorkingDirectory = Path.GetDirectoryName(path),
FileName = path,
Verb = "runas"
});
}
}
}
11 changes: 5 additions & 6 deletions Slate/Slate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview5" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview5" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-beta.700-11.0.0-preview5" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-rc1" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-beta.802-11.0.0-rc1.1" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="All" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions Slate/View/Window/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ private void UpdateVisualState(PageMarker page)

protected override void OnLoaded()
{
var hwnd = PlatformImpl!.Handle.Handle;

ConfigureAsToolWindow(hwnd);
var hwnd = TryGetPlatformHandle()?.Handle ?? IntPtr.Zero;

if (hwnd != IntPtr.Zero)
{
ConfigureAsToolWindow(hwnd);
}

IsVisible = false;
Position = HiddenDesktopPosition;

Expand Down
4 changes: 1 addition & 3 deletions Slate/ViewModel/Control/AuraColorControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public bool FollowSystemAccentColor

if (value)
{
var color = AvaloniaLocator
.Current
.GetRequiredService<IPlatformSettings>()
var color = Application.Current!.PlatformSettings!
.GetColorValues()
.AccentColor1;

Expand Down
4 changes: 1 addition & 3 deletions Slate/ViewModel/Page/FansPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public FansPageViewModel(
_asusHalService = asusHalService;
HardwareMonitor = hardwareMonitor;

var primaryColor = AvaloniaLocator
.Current
.GetRequiredService<IPlatformSettings>()
var primaryColor = Application.Current!.PlatformSettings!
.GetColorValues()
.AccentColor1
.ToSKColor();
Expand Down

0 comments on commit 7c1a183

Please sign in to comment.