initial commit

This commit is contained in:
Holger Börchers 2019-12-14 16:27:17 +01:00
parent 9572114d62
commit 5f4ac1d3ef
20 changed files with 367 additions and 0 deletions

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace PhotoRenamer.Base
{
public static class FilesHelper
{
private static readonly string[] SupportedFileExtensions = {".jpg", ".cr2", ".mp4"};
public static IEnumerable<string> FindSupportedFilesRecursively(string path)
{
var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
foreach (var file in files)
{
var fileExt = Path.GetExtension(file);
if(fileExt == null) continue;
foreach (var supportedFileExtension in SupportedFileExtensions)
{
if (fileExt.Equals(supportedFileExtension, StringComparison.InvariantCultureIgnoreCase)) yield return file;
}
}
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ExifLibNet" Version="2.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,29 @@
using System;
using PhotoRenamer.File.Views;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Regions;
namespace PhotoRenamer.File
{
public class FileModule : IModule
{
private readonly IRegionManager _regionManager;
public FileModule(IRegionManager regionManager)
{
_regionManager = regionManager;
}
public void OnInitialized(IContainerProvider containerProvider)
{
}
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<ViewA>();
_regionManager.RequestNavigate("ContentRegion", new Uri(nameof(ViewA), UriKind.Relative));
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
<AssemblyName>PhotoRenamer.File</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Prism.Wpf" Version="7.2.0.1422" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using Prism.Mvvm;
using System.Windows.Input;
namespace PhotoRenamer.File.ViewModels
{
public class ViewAViewModel : BindableBase
{
public ICommand SelectFilesCommand { get; }
public ICommand ClearCommand { get; }
}
}

View File

@ -0,0 +1,41 @@
<UserControl
x:Class="PhotoRenamer.File.Views.ViewA"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:viewModels="clr-namespace:PhotoRenamer.File.ViewModels"
d:DataContext="{d:DesignInstance viewModels:ViewAViewModel}"
d:DesignHeight="300"
d:DesignWidth="300"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d">
<DockPanel>
<ToolBarTray DockPanel.Dock="Top" Orientation="Horizontal">
<ToolBar ToolBarTray.IsLocked="True">
<Button Command="{Binding SelectFilesCommand}" Content="Select Files" />
<Button Command="{Binding ClearCommand}" Content="Clear" />
</ToolBar>
</ToolBarTray>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<GroupBox
Grid.Row="0"
Margin="5"
Header="Source">
<ListView />
</GroupBox>
<GroupBox
Grid.Row="2"
Margin="5"
Header="Target">
<ListView />
</GroupBox>
</Grid>
</DockPanel>
</UserControl>

View File

@ -0,0 +1,13 @@
namespace PhotoRenamer.File.Views
{
/// <summary>
/// Interaction logic for ViewA.xaml
/// </summary>
public partial class ViewA
{
public ViewA()
{
InitializeComponent();
}
}
}

View File

View File

View File

@ -0,0 +1,21 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PhotoRenamer.Test
{
[TestClass]
public class FilesTest
{
[TestMethod]
public void FindSupportedFiles()
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets");
var files = Base.FilesHelper.FindSupportedFilesRecursively(path).ToArray();
Assert.AreEqual(2, files.Length);
Assert.AreEqual("IMG_3590.CR2", Path.GetFileName(files[0]));
Assert.AreEqual("IMG_3590.JPG", Path.GetFileName(files[1]));
}
}
}

View File

@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="coverlet.collector" Version="1.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Update="Assets\IMG_3590.CR2">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Assets\NIX.TXT">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Assets\Subfolder\IMG_3590.JPG">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PhotoRenamer.Base\PhotoRenamer.Base.csproj" />
</ItemGroup>
</Project>

43
PhotoRenamer.sln Normal file
View File

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29609.76
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PhotoRenamer", "PhotoRenamer\PhotoRenamer.csproj", "{C2C8C238-CB3D-4DDA-96FC-297D029F6022}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.File", "PhotoRenamer.File\PhotoRenamer.File.csproj", "{185069C2-C1EB-4116-8C33-952A2C0BA1F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.Test", "PhotoRenamer.Test\PhotoRenamer.Test.csproj", "{07F827BC-CF99-4E81-A5C7-54085C97FC10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.Base", "PhotoRenamer.Base\PhotoRenamer.Base.csproj", "{DE85C395-3D50-4C12-9B7A-021180E26CE1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2C8C238-CB3D-4DDA-96FC-297D029F6022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2C8C238-CB3D-4DDA-96FC-297D029F6022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2C8C238-CB3D-4DDA-96FC-297D029F6022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2C8C238-CB3D-4DDA-96FC-297D029F6022}.Release|Any CPU.Build.0 = Release|Any CPU
{185069C2-C1EB-4116-8C33-952A2C0BA1F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{185069C2-C1EB-4116-8C33-952A2C0BA1F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{185069C2-C1EB-4116-8C33-952A2C0BA1F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{185069C2-C1EB-4116-8C33-952A2C0BA1F9}.Release|Any CPU.Build.0 = Release|Any CPU
{07F827BC-CF99-4E81-A5C7-54085C97FC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
{DE85C395-3D50-4C12-9B7A-021180E26CE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE85C395-3D50-4C12-9B7A-021180E26CE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE85C395-3D50-4C12-9B7A-021180E26CE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE85C395-3D50-4C12-9B7A-021180E26CE1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {68BF90FC-8E63-4A5F-9CC2-39CCBEACCF0F}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Renamer/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

8
PhotoRenamer/App.xaml Normal file
View File

@ -0,0 +1,8 @@
<prism:PrismApplication
x:Class="PhotoRenamer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PhotoRenamer"
xmlns:prism="http://prismlibrary.com/">
<Application.Resources />
</prism:PrismApplication>

30
PhotoRenamer/App.xaml.cs Normal file
View File

@ -0,0 +1,30 @@
using Prism.Ioc;
using PhotoRenamer.Views;
using System.Windows;
using PhotoRenamer.File;
using Prism.Modularity;
namespace PhotoRenamer
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
}
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
moduleCatalog.AddModule<FileModule>();
base.ConfigureModuleCatalog(moduleCatalog);
}
}
}

View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<AssemblyName>PhotoRenamer</AssemblyName>
<StartupObject>PhotoRenamer.App</StartupObject>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>false</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Prism.DryIoc" Version="7.2.0.1422" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PhotoRenamer.File\PhotoRenamer.File.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using JetBrains.Annotations;
using Prism.Mvvm;
namespace PhotoRenamer.ViewModels
{
[UsedImplicitly]
public class MainWindowViewModel : BindableBase
{
private string _title = "Prism Application";
public string Title
{
get => _title;
set => SetProperty(ref _title, value);
}
}
}

View File

@ -0,0 +1,18 @@
<Window
x:Class="PhotoRenamer.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:viewModels="clr-namespace:PhotoRenamer.ViewModels"
Title="{Binding Title}"
Width="525"
Height="350"
d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel}"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d">
<Grid>
<ContentControl prism:RegionManager.RegionName="ContentRegion" />
</Grid>
</Window>

View File

@ -0,0 +1,15 @@
using System.Windows;
namespace PhotoRenamer.Views
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}