From 43a2d756dc2daa71d40180a7933ade32c14a526d Mon Sep 17 00:00:00 2001 From: holger Date: Mon, 11 Sep 2023 22:23:34 +0200 Subject: [PATCH] Add gui for photo renamer --- PhotoRenamer.Test/PhotoRenamer.Test.csproj | 8 +-- PhotoRenamer.sln | 6 +++ PhotoRenamer/PhotoRenamer.csproj | 14 ++--- PhotoRenamer/Program.cs | 4 +- PhotoRenamerGui/App.axaml | 10 ++++ PhotoRenamerGui/App.axaml.cs | 23 ++++++++ PhotoRenamerGui/MainWindow.axaml | 61 ++++++++++++++++++++++ PhotoRenamerGui/MainWindow.axaml.cs | 11 ++++ PhotoRenamerGui/MainWindowViewModel.cs | 9 ++++ PhotoRenamerGui/PhotoRenamerGui.csproj | 21 ++++++++ PhotoRenamerGui/Program.cs | 21 ++++++++ PhotoRenamerGui/app.manifest | 18 +++++++ 12 files changed, 190 insertions(+), 16 deletions(-) create mode 100644 PhotoRenamerGui/App.axaml create mode 100644 PhotoRenamerGui/App.axaml.cs create mode 100644 PhotoRenamerGui/MainWindow.axaml create mode 100644 PhotoRenamerGui/MainWindow.axaml.cs create mode 100644 PhotoRenamerGui/MainWindowViewModel.cs create mode 100644 PhotoRenamerGui/PhotoRenamerGui.csproj create mode 100644 PhotoRenamerGui/Program.cs create mode 100644 PhotoRenamerGui/app.manifest diff --git a/PhotoRenamer.Test/PhotoRenamer.Test.csproj b/PhotoRenamer.Test/PhotoRenamer.Test.csproj index c2108af..898177c 100644 --- a/PhotoRenamer.Test/PhotoRenamer.Test.csproj +++ b/PhotoRenamer.Test/PhotoRenamer.Test.csproj @@ -6,10 +6,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/PhotoRenamer.sln b/PhotoRenamer.sln index 8043c38..2da5ff1 100644 --- a/PhotoRenamer.sln +++ b/PhotoRenamer.sln @@ -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 diff --git a/PhotoRenamer/PhotoRenamer.csproj b/PhotoRenamer/PhotoRenamer.csproj index e6d48c2..3c3e88b 100644 --- a/PhotoRenamer/PhotoRenamer.csproj +++ b/PhotoRenamer/PhotoRenamer.csproj @@ -6,23 +6,17 @@ enable enable - - - true - true - true - - - + + - + - + diff --git a/PhotoRenamer/Program.cs b/PhotoRenamer/Program.cs index 3980de5..a011ef4 100644 --- a/PhotoRenamer/Program.cs +++ b/PhotoRenamer/Program.cs @@ -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); diff --git a/PhotoRenamerGui/App.axaml b/PhotoRenamerGui/App.axaml new file mode 100644 index 0000000..23065b6 --- /dev/null +++ b/PhotoRenamerGui/App.axaml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/PhotoRenamerGui/App.axaml.cs b/PhotoRenamerGui/App.axaml.cs new file mode 100644 index 0000000..d9a6930 --- /dev/null +++ b/PhotoRenamerGui/App.axaml.cs @@ -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(); + } +} \ No newline at end of file diff --git a/PhotoRenamerGui/MainWindow.axaml b/PhotoRenamerGui/MainWindow.axaml new file mode 100644 index 0000000..1bd5698 --- /dev/null +++ b/PhotoRenamerGui/MainWindow.axaml @@ -0,0 +1,61 @@ + + + + + + + + + + diff --git a/PhotoRenamerGui/MainWindow.axaml.cs b/PhotoRenamerGui/MainWindow.axaml.cs new file mode 100644 index 0000000..27e4aec --- /dev/null +++ b/PhotoRenamerGui/MainWindow.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace PhotoRenamerGui; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/PhotoRenamerGui/MainWindowViewModel.cs b/PhotoRenamerGui/MainWindowViewModel.cs new file mode 100644 index 0000000..425de1f --- /dev/null +++ b/PhotoRenamerGui/MainWindowViewModel.cs @@ -0,0 +1,9 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace PhotoRenamerGui; + +public partial class MainWindowViewModel : ObservableObject +{ + [ObservableProperty] private string? _inputFolder; + [ObservableProperty] private string? _outputFolder; +} \ No newline at end of file diff --git a/PhotoRenamerGui/PhotoRenamerGui.csproj b/PhotoRenamerGui/PhotoRenamerGui.csproj new file mode 100644 index 0000000..9570578 --- /dev/null +++ b/PhotoRenamerGui/PhotoRenamerGui.csproj @@ -0,0 +1,21 @@ + + + WinExe + net7.0 + enable + true + app.manifest + true + + + + + + + + + + + + + diff --git a/PhotoRenamerGui/Program.cs b/PhotoRenamerGui/Program.cs new file mode 100644 index 0000000..953d1cf --- /dev/null +++ b/PhotoRenamerGui/Program.cs @@ -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() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); +} \ No newline at end of file diff --git a/PhotoRenamerGui/app.manifest b/PhotoRenamerGui/app.manifest new file mode 100644 index 0000000..ae2af6c --- /dev/null +++ b/PhotoRenamerGui/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +