Skip to content

Commit

Permalink
refactor: convert code for Avalonia 11
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Jun 9, 2024
1 parent 0ac15a9 commit 5d6f5a1
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 461 deletions.
16 changes: 16 additions & 0 deletions src/AvaloniaApp/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaApp.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.Styles>
<FluentTheme>
<FluentTheme.Palettes>
<ColorPaletteResources x:Key="Light" Accent="#ffcc4d11" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" AltMediumLow="White" BaseHigh="Black" BaseLow="#ff7cbee0" BaseMedium="#ff3282a8" BaseMediumHigh="#ff005a83" BaseMediumLow="#ff196e96" ChromeAltLow="#ff005a83" ChromeBlackHigh="Black" ChromeBlackLow="#ff7cbee0" ChromeBlackMedium="#ff005a83" ChromeBlackMediumLow="#ff3282a8" ChromeDisabledHigh="#ff7cbee0" ChromeDisabledLow="#ff3282a8" ChromeGray="#ff196e96" ChromeHigh="#ff7cbee0" ChromeLow="#ffc1e9fe" ChromeMedium="#ffb3e0f8" ChromeMediumLow="#ffc1e9fe" ChromeWhite="White" ListLow="#ffb3e0f8" ListMedium="#ff7cbee0" RegionColor="#ffcfeaff" />
<ColorPaletteResources x:Key="Dark" Accent="#ffcc4d11" AltHigh="Black" AltLow="Black" AltMedium="Black" AltMediumHigh="Black" AltMediumLow="Black" BaseHigh="White" BaseLow="#ff2f7bad" BaseMedium="#ff8dbfdf" BaseMediumHigh="#ffa5d0ec" BaseMediumLow="#ff5e9dc6" ChromeAltLow="#ffa5d0ec" ChromeBlackHigh="Black" ChromeBlackLow="#ffa5d0ec" ChromeBlackMedium="Black" ChromeBlackMediumLow="Black" ChromeDisabledHigh="#ff2f7bad" ChromeDisabledLow="#ff8dbfdf" ChromeGray="#ff76aed3" ChromeHigh="#ff76aed3" ChromeLow="#ff093b73" ChromeMedium="#ff134b82" ChromeMediumLow="#ff266b9f" ChromeWhite="White" ListLow="#ff134b82" ListMedium="#ff2f7bad" RegionColor="#ff0d2644" />
</FluentTheme.Palettes>
</FluentTheme>
<StyleInclude Source="avares://AvaloniaIconPacks/BoxIcons.xaml"/>
</Application.Styles>
</Application>
4 changes: 2 additions & 2 deletions src/MyApp/App.axaml.cs → src/AvaloniaApp/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace MyApp
namespace AvaloniaApp
{
public class App : Application
public partial class App : Application
{
public override void Initialize()
{
Expand Down
24 changes: 24 additions & 0 deletions src/AvaloniaApp/AvaloniaApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
<!--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.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaIconPacks\AvaloniaIconPacks.csproj" />
</ItemGroup>

</Project>
36 changes: 22 additions & 14 deletions src/MyApp/MainWindow.axaml → src/AvaloniaApp/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:iconPacks="clr-namespace:MahApps.Metro.IconPacks;assembly=AvaloniaIconPacks"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="MyApp.MainWindow"
Title="MyApp"
Width="800"
Height="600">

<ScrollViewer >
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
x:Class="AvaloniaApp.MainWindow"
Title="AvaloniaApp">

<ScrollViewer>
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
<TextBlock Margin="0 10" Text="Welcome to Avalonia!" FontSize="22" FontWeight="SemiBold" />
<TextBlock Margin="0 10" Text="IconPacks - PackIconBoxIcons" FontSize="18" FontWeight="SemiBold" />

<ComboBox Name="FlipOrientation" Width="200" SelectedIndex="1">
<iconPacks:PackIconFlipOrientation>Horizontal</iconPacks:PackIconFlipOrientation>
<iconPacks:PackIconFlipOrientation>Vertical</iconPacks:PackIconFlipOrientation>
<iconPacks:PackIconFlipOrientation>Both</iconPacks:PackIconFlipOrientation>
<iconPacks:PackIconFlipOrientation>Normal</iconPacks:PackIconFlipOrientation>
</ComboBox>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5">
<iconPacks:PackIconBoxIcons Kind="RegularRecycle"
Foreground="{DynamicResource SystemControlHighlightAccentBrush}"
Expand All @@ -27,14 +31,19 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="144" Height="144"
Flip="Vertical" />
Flip="{Binding #FlipOrientation.SelectedItem, Mode=OneWay}" />
</StackPanel>

<TextBlock Margin="0 10" Text="{Binding #RotationSlider.Value, Mode=OneWay, StringFormat='RotationAngle {0}'}" FontSize="22" FontWeight="SemiBold" />
<Slider Name="RotationSlider" Margin="0 2" Width="200" Minimum="0" Maximum="360" Value="45" SmallChange="1" LargeChange="10" TickFrequency="1" IsSnapToTickEnabled="True" />
<TextBlock Margin="0 10"
Text="{Binding #RotationSlider.Value, Mode=OneWay, StringFormat='RotationAngle {0}'}"
FontSize="22" FontWeight="SemiBold" />
<Slider Name="RotationSlider" Margin="0 2" Width="200" Minimum="0" Maximum="360" Value="45" SmallChange="1"
LargeChange="10" TickFrequency="1" IsSnapToTickEnabled="True" />

<TextBlock Margin="0 2" Text="{Binding #DurationSlider.Value, Mode=OneWay, StringFormat='Duration {0}'}" FontSize="22" FontWeight="SemiBold" />
<Slider Name="DurationSlider" Margin="0 2" Width="200" Minimum="0" Maximum="10" Value="3" SmallChange="1" LargeChange="2" TickFrequency="1" IsSnapToTickEnabled="True" />
<TextBlock Margin="0 2" Text="{Binding #DurationSlider.Value, Mode=OneWay, StringFormat='Duration {0}'}"
FontSize="22" FontWeight="SemiBold" />
<Slider Name="DurationSlider" Margin="0 2" Width="200" Minimum="0" Maximum="10" Value="3" SmallChange="1"
LargeChange="2" TickFrequency="1" IsSnapToTickEnabled="True" />

<CheckBox Name="SpinCheckBox" Margin="0 2" Content="Spin" IsChecked="True" />
<CheckBox Name="VisibilityCheckBox" Margin="0 2" Content="Visible" IsChecked="True" />
Expand All @@ -52,5 +61,4 @@

</StackPanel>
</ScrollViewer>

</Window>
</Window>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace MyApp
namespace AvaloniaApp
{
public class MainWindow : Window
public partial class MainWindow : Window
{
public MainWindow()
{
Expand All @@ -13,10 +12,5 @@ public MainWindow()
this.AttachDevTools();
#endif
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}
12 changes: 6 additions & 6 deletions src/MyApp/Program.cs → src/AvaloniaApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia;
using System;

namespace MyApp
namespace AvaloniaApp
{
class Program
internal class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}
}
18 changes: 18 additions & 0 deletions src/AvaloniaApp/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="AvaloniaApp.Desktop"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>
41 changes: 22 additions & 19 deletions src/AvaloniaIconPacks.TestApp.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.6.30114.105
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaIconPacks", "AvaloniaIconPacks\AvaloniaIconPacks.csproj", "{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaIconPacks", "AvaloniaIconPacks\AvaloniaIconPacks.csproj", "{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp", "MyApp\MyApp.csproj", "{1B18E252-C278-47C3-8BD2-8097D69B04A4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaApp", "AvaloniaApp\AvaloniaApp.csproj", "{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -16,9 +16,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -32,17 +29,23 @@ Global
{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}.Release|x64.Build.0 = Release|Any CPU
{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}.Release|x86.ActiveCfg = Release|Any CPU
{9D89109C-03C6-4F03-ACFF-0212CA6FAAA3}.Release|x86.Build.0 = Release|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Debug|x64.ActiveCfg = Debug|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Debug|x64.Build.0 = Debug|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Debug|x86.ActiveCfg = Debug|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Debug|x86.Build.0 = Debug|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Release|Any CPU.Build.0 = Release|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Release|x64.ActiveCfg = Release|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Release|x64.Build.0 = Release|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Release|x86.ActiveCfg = Release|Any CPU
{1B18E252-C278-47C3-8BD2-8097D69B04A4}.Release|x86.Build.0 = Release|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x64.ActiveCfg = Debug|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x64.Build.0 = Debug|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x86.ActiveCfg = Debug|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x86.Build.0 = Debug|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|Any CPU.Build.0 = Release|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x64.ActiveCfg = Release|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x64.Build.0 = Release|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x86.ActiveCfg = Release|Any CPU
{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E6ECA210-1B2F-4011-A34A-7E9D2CC4721F}
EndGlobalSection
EndGlobal
18 changes: 7 additions & 11 deletions src/AvaloniaIconPacks/AvaloniaIconPacks.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);AVALONIA</DefineConstants>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.0" />
<AvaloniaResource Include="**/*.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<PackageReference Include="Avalonia" Version="11.0.6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.6" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions src/AvaloniaIconPacks/BoxIcons.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- <StyleInclude Source="avares://AvaloniaIconPacks/PackIconBoxIcons.xaml" /> -->
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="avares://AvaloniaIconPacks/PackIconBoxIcons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>
</Styles>
25 changes: 0 additions & 25 deletions src/AvaloniaIconPacks/Core/Converter/DataToGeometryConverter.cs

This file was deleted.

74 changes: 0 additions & 74 deletions src/AvaloniaIconPacks/Core/Converter/FlipToScaleXValueConverter.cs

This file was deleted.

Loading

0 comments on commit 5d6f5a1

Please sign in to comment.