Added FontAwesome. Added suggested op decal.

This commit is contained in:
Alexander Shabarshov 2026-05-21 09:37:26 +01:00
parent 1f93eba839
commit 3f1924a429
8 changed files with 76 additions and 12 deletions

View File

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Splitter_UI.App"
xmlns:local="using:Splitter_UI"
xmlns:cnv="using:Splitter_UI.Converters"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
@ -9,7 +10,13 @@
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Resources>
<cnv:ActionToIconConverter x:Key="ActionToIconConverter"/>
<FontFamily x:Key="FontAwesome">avares://Splitter-UI/Assets/Fonts/Font Awesome 7 Free-Solid-900.otf#Font Awesome 7 Free Solid</FontFamily>
</Application.Resources>
<Application.Styles>
<FluentTheme />
<FluentTheme/>
</Application.Styles>
</Application>

View File

@ -0,0 +1,20 @@
using System.Globalization;
using Avalonia.Data.Converters;
namespace Splitter_UI.Converters;
public sealed class ActionToIconConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return value switch
{
"crop" => "\uf125", // FA7 crop
"rotate" => "\uf2f1", // FA7 rotate
_ => null
};
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}

View File

@ -1,4 +1,5 @@
using Avalonia;
using Avalonia.Media;
using Microsoft.Extensions.DependencyInjection;
namespace Splitter_UI;
@ -46,6 +47,14 @@ internal sealed class Program
public static AppBuilder BuildAvaloniaApp(ServiceProvider provider)
=> AppBuilder.Configure<App>(() => new App(provider))
.UsePlatformDetect()
.With(new FontManagerOptions
{
FontFallbacks = new[]
{
new FontFallback { FontFamily = new FontFamily("Font Awesome 7 Free") },
new FontFallback { FontFamily = new FontFamily("Font Awesome 7 Free Solid") }
}
})
#if DEBUG
.WithDeveloperTools()
#endif

View File

@ -35,7 +35,8 @@ public partial class FileJobViewModel : ObservableObject
private async Task LoadThumbnailAsync()
{
Probe = await _fileProbe.ProbeAsync(Job);
Thumbnail = await _thumbnails.CreateThumbnailAsync(Job.InputFile, Probe);
Probe = await _fileProbe.ProbeAsync(Job);
Thumbnail = await _thumbnails.CreateThumbnailAsync(Job.InputFile, Probe);
SuggestedAction = Probe.Rotation == 0 ? "crop" : "rotate";
}
}

View File

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:Splitter_UI.ViewModels"
xmlns:views="clr-namespace:Splitter_UI.Views"
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
x:Class="Splitter_UI.Views.FileListView"
x:DataType="vm:FileListViewModel">
@ -39,21 +40,30 @@
<DataTemplate x:DataType="vm:FileJobViewModel">
<Border Margin="6" Padding="6" Background="#2A2A2A" CornerRadius="4">
<StackPanel MinWidth="160" MaxWidth="160">
<Border Width="160" Height="90" ClipToBounds="True">
<Image Source="{Binding Thumbnail}"
Stretch="UniformToFill"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<Border Width="160" Height="90" ClipToBounds="True">
<Grid>
<!-- Thumbnail -->
<Image Source="{Binding Thumbnail}"
Stretch="UniformToFill"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<!-- Suggested action decal -->
<TextBlock
FontFamily="{StaticResource FontAwesome}"
Text="{Binding SuggestedAction, Converter={StaticResource ActionToIconConverter}}"
FontSize="12"
HorizontalAlignment="Right"
Foreground="LimeGreen"/>
</Grid>
</Border>
<TextBlock Text="{Binding FileName}"
TextWrapping="Wrap"
Margin="0,6,0,0"
FontSize="10"/>
<TextBlock Text="{Binding SuggestedAction}"
Foreground="LightGreen"
FontSize="10"/>
<ProgressBar
MinWidth="160"

View File

@ -1,4 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Platform;
namespace Splitter_UI.Views;
@ -8,5 +11,19 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
//var uri = new Uri("avares://Splitter-UI/Assets/Fonts/Font Awesome 7 Free-Solid-900.otf");
//if (!AssetLoader.Exists(uri))
//{
// Console.WriteLine("Resource NOT FOUND: " + uri);
// return;
//}
//using var stream = AssetLoader.Open(uri);
//using var ms = new MemoryStream();
//stream.CopyTo(ms);
//Console.WriteLine("Resource FOUND. Size = " + ms.Length + " bytes");
}
}