Add gui for photo renamer

This commit is contained in:
Holger Börchers 2023-09-11 22:23:34 +02:00
parent 182813bd21
commit 43a2d756dc
12 changed files with 190 additions and 16 deletions

View File

@ -6,10 +6,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PhotoRenamer", "PhotoRename
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PhotoRenamer.Test", "PhotoRenamer.Test\PhotoRenamer.Test.csproj", "{07F827BC-CF99-4E81-A5C7-54085C97FC10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamerGui", "PhotoRenamerGui\PhotoRenamerGui.csproj", "{733313FE-599D-49A4-A909-BBDBFB15E27D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{07F827BC-CF99-4E81-A5C7-54085C97FC10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07F827BC-CF99-4E81-A5C7-54085C97FC10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07F827BC-CF99-4E81-A5C7-54085C97FC10}.Release|Any CPU.Build.0 = Release|Any CPU
{733313FE-599D-49A4-A909-BBDBFB15E27D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{733313FE-599D-49A4-A909-BBDBFB15E27D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{733313FE-599D-49A4-A909-BBDBFB15E27D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{733313FE-599D-49A4-A909-BBDBFB15E27D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -6,23 +6,17 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<PublishAot>true</PublishAot>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PublishAotCompressed" Version="1.0.0" />
<PackageReference Include="MetadataExtractor" Version="2.7.2" />
<PackageReference Include="PublishAotCompressed" Version="1.0.1" />
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Spectre.Console" Version="0.45.0" />
<PackageReference Include="Spectre.Console" Version="0.47.0" />
</ItemGroup>
<ItemGroup>

View File

@ -7,12 +7,12 @@ internal static class Program
{
private static int Main(string[] args)
{
Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
var configuration = CreateHostBuilder(args).Build();
foreach (var (key, value) in configuration.AsEnumerable())
{
Console.WriteLine($"{{{key}: {value}}}");
Log.Information($"{{{key}: {value}}}");
}
Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
try
{
var renamer = new Renamer(configuration);

10
PhotoRenamerGui/App.axaml Normal file
View File

@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="PhotoRenamerGui.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>

View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace PhotoRenamerGui;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}
base.OnFrameworkInitializationCompleted();
}
}

View File

@ -0,0 +1,61 @@
<Window
Title="PhotoRenamerGui"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="PhotoRenamerGui.MainWindow"
x:DataType="photoRenamerGui:MainWindowViewModel"
xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:photoRenamerGui="clr-namespace:PhotoRenamerGui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.DataContext>
<photoRenamerGui:MainWindowViewModel />
</Window.DataContext>
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="Auto,Auto,*">
<Grid.Styles>
<Style Selector="TemplatedControl.space">
<Setter Property="Margin" Value="5" />
</Style>
</Grid.Styles>
<Label
Classes="space"
Content="Input Folder"
Grid.Column="0"
Grid.Row="0"
VerticalAlignment="Center" />
<Label
Classes="space"
Content="Output Folder"
Grid.Column="0"
Grid.Row="1"
VerticalAlignment="Center" />
<TextBox
Classes="space"
Grid.Column="1"
Grid.Row="0"
Text="{Binding InputFolder}"
Watermark="Input" />
<TextBox
Classes="space"
Grid.Column="1"
Grid.Row="1"
Text="{Binding OutputFolder}"
Watermark="Output" />
<Button
Classes="space"
Grid.Column="2"
Grid.Row="0"
VerticalAlignment="Stretch">
...
</Button>
<Button
Classes="space"
Grid.Column="2"
Grid.Row="1"
VerticalAlignment="Stretch">
...
</Button>
</Grid>
</Window>

View File

@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace PhotoRenamerGui;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,9 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace PhotoRenamerGui;
public partial class MainWindowViewModel : ObservableObject
{
[ObservableProperty] private string? _inputFolder;
[ObservableProperty] private string? _outputFolder;
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.4" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.4" />
<!--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.4" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace PhotoRenamerGui;
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();
}

View File

@ -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 embeded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="PhotoRenamerGui.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>