mirror of
https://github.com/unclshura/splitter.git
synced 2026-06-21 16:12:01 +00:00
Added FontAwesome. Added suggested op decal.
This commit is contained in:
parent
1f93eba839
commit
3f1924a429
@ -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>
|
||||
BIN
Splitter-UI/Assets/Fonts/Font Awesome 7 Free-Regular-400.otf
Normal file
BIN
Splitter-UI/Assets/Fonts/Font Awesome 7 Free-Regular-400.otf
Normal file
Binary file not shown.
BIN
Splitter-UI/Assets/Fonts/Font Awesome 7 Free-Solid-900.otf
Normal file
BIN
Splitter-UI/Assets/Fonts/Font Awesome 7 Free-Solid-900.otf
Normal file
Binary file not shown.
20
Splitter-UI/Converters/ActionToIconConverter.cs
Normal file
20
Splitter-UI/Converters/ActionToIconConverter.cs
Normal 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();
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user