Compare commits

..

2 Commits

Author SHA1 Message Date
ad1e92362d added LoggingModule 2020-01-11 21:15:49 +01:00
a17ea99642 Working on new method 2019-12-16 21:18:54 +01:00
18 changed files with 1373 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ExifLibrary;
using JetBrains.Annotations;
using PhotoRenamer.Base.Types;
namespace PhotoRenamer.Base namespace PhotoRenamer.Base
{ {
public static class FilesHelper public static class FilesHelper
{ {
private static readonly string[] SupportedFileExtensions = {".jpg", ".cr2", ".mp4"}; private static readonly string[] SupportedFileExtensions = {".jpg", ".cr2", ".mp4"};
@ -22,5 +24,18 @@ namespace PhotoRenamer.Base
} }
} }
} }
public static IEnumerable<MediaFile> GetMediaFiles(IEnumerable<string> files)
{
if (files == null) throw new ArgumentNullException(nameof(files));
foreach (var file in files)
{
var imageFile = ImageFile.FromFile(file);
var dateTime = imageFile.Properties.Get<ExifDateTime>(ExifTag.DateTimeOriginal);
var mediaFile = new MediaFile(file, dateTime.Value);
yield return mediaFile;
}
}
} }
} }

View File

@ -2,11 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ExifLibNet" Version="2.1.1" /> <PackageReference Include="ExifLibNet" Version="2.1.1" />
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8"> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -0,0 +1,8 @@
namespace PhotoRenamer.Base
{
public static class RegionNames
{
public static string ContentRegion { get; } = "ContentRegion";
public static string LoggingRegion { get; } = "LoggingRegion";
}
}

View File

@ -0,0 +1,17 @@
using System;
namespace PhotoRenamer.Base.Types
{
public class MediaFile
{
public MediaFile(string path, DateTime creationDate)
{
Path = path;
CreationDate = creationDate;
}
public string Path { get; }
public DateTime CreationDate { get; }
}
}

View File

@ -1,4 +1,5 @@
using System; using System;
using PhotoRenamer.Base;
using PhotoRenamer.File.Views; using PhotoRenamer.File.Views;
using Prism.Ioc; using Prism.Ioc;
using Prism.Modularity; using Prism.Modularity;
@ -23,7 +24,7 @@ namespace PhotoRenamer.File
public void RegisterTypes(IContainerRegistry containerRegistry) public void RegisterTypes(IContainerRegistry containerRegistry)
{ {
containerRegistry.RegisterForNavigation<ViewA>(); containerRegistry.RegisterForNavigation<ViewA>();
_regionManager.RequestNavigate("ContentRegion", new Uri(nameof(ViewA), UriKind.Relative)); _regionManager.RequestNavigate(RegionNames.ContentRegion, new Uri(nameof(ViewA), UriKind.Relative));
} }
} }
} }

View File

@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<AssemblyName>PhotoRenamer.File</AssemblyName> <AssemblyName>PhotoRenamer.File</AssemblyName>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8"> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Prism.Wpf" Version="7.2.0.1422" /> <PackageReference Include="Prism.Wpf" Version="7.2.0.1422" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PhotoRenamer.Base\PhotoRenamer.Base.csproj" />
</ItemGroup>
</Project> </Project>

View File

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

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<AssemblyName>PhotoRenamer.Logging</AssemblyName>
<Nullable>enable</Nullable>
</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>
<ItemGroup>
<ProjectReference Include="..\PhotoRenamer.Base\PhotoRenamer.Base.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
using System.Windows.Input;
using JetBrains.Annotations;
using Prism.Mvvm;
namespace PhotoRenamer.Logging.ViewModels
{
[UsedImplicitly]
public class ViewAViewModel : BindableBase
{
public ICommand SelectFilesCommand { get; }
public ICommand ClearCommand { get; }
}
}

View File

@ -0,0 +1,17 @@
<UserControl
x:Class="PhotoRenamer.Logging.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.Logging.ViewModels"
d:DataContext="{d:DesignInstance viewModels:ViewAViewModel}"
d:DesignHeight="300"
d:DesignWidth="300"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d">
<GroupBox Margin="5" Header="Log">
<ListView />
</GroupBox>
</UserControl>

View File

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

View File

@ -2,6 +2,8 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PhotoRenamer.Base;
using PhotoRenamer.Base.Types;
namespace PhotoRenamer.Test namespace PhotoRenamer.Test
{ {
@ -13,7 +15,7 @@ namespace PhotoRenamer.Test
public FilesTest() public FilesTest()
{ {
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets"); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets");
_files = Base.FilesHelper.FindSupportedFilesRecursively(path).ToArray(); _files = FilesHelper.FindSupportedFilesRecursively(path).ToArray();
} }
[TestMethod, Priority(0)] [TestMethod, Priority(0)]
@ -27,7 +29,8 @@ namespace PhotoRenamer.Test
[TestMethod, Priority(1)] [TestMethod, Priority(1)]
public void GetMetaData() public void GetMetaData()
{ {
var expected = new[] {new MediaFile("r", DateTime.Now), new MediaFile("r", DateTime.Now)};
var actual = FilesHelper.GetMediaFiles(_files);
} }
} }
} }

View File

@ -7,7 +7,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8"> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -15,7 +14,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="coverlet.collector" Version="1.1.0"> <PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.Test", "PhotoR
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.Base", "PhotoRenamer.Base\PhotoRenamer.Base.csproj", "{DE85C395-3D50-4C12-9B7A-021180E26CE1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.Base", "PhotoRenamer.Base\PhotoRenamer.Base.csproj", "{DE85C395-3D50-4C12-9B7A-021180E26CE1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoRenamer.Logging", "PhotoRenamer.Logging\PhotoRenamer.Logging.csproj", "{1AB0E84A-BEEA-4AAA-96BC-D0D66AC63E11}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -33,6 +35,10 @@ Global
{DE85C395-3D50-4C12-9B7A-021180E26CE1}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{DE85C395-3D50-4C12-9B7A-021180E26CE1}.Release|Any CPU.Build.0 = Release|Any CPU {DE85C395-3D50-4C12-9B7A-021180E26CE1}.Release|Any CPU.Build.0 = Release|Any CPU
{1AB0E84A-BEEA-4AAA-96BC-D0D66AC63E11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AB0E84A-BEEA-4AAA-96BC-D0D66AC63E11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AB0E84A-BEEA-4AAA-96BC-D0D66AC63E11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AB0E84A-BEEA-4AAA-96BC-D0D66AC63E11}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -2,6 +2,7 @@
using PhotoRenamer.Views; using PhotoRenamer.Views;
using System.Windows; using System.Windows;
using PhotoRenamer.File; using PhotoRenamer.File;
using PhotoRenamer.Logging;
using Prism.Modularity; using Prism.Modularity;
namespace PhotoRenamer namespace PhotoRenamer
@ -24,6 +25,7 @@ namespace PhotoRenamer
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{ {
moduleCatalog.AddModule<FileModule>(); moduleCatalog.AddModule<FileModule>();
moduleCatalog.AddModule<LoggingModule>();
base.ConfigureModuleCatalog(moduleCatalog); base.ConfigureModuleCatalog(moduleCatalog);
} }
} }

View File

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<AssemblyName>PhotoRenamer</AssemblyName> <AssemblyName>PhotoRenamer</AssemblyName>
<StartupObject>PhotoRenamer.App</StartupObject> <StartupObject>PhotoRenamer.App</StartupObject>
@ -10,9 +11,9 @@
<PublishSingleFile>false</PublishSingleFile> <PublishSingleFile>false</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild> <RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8"> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -20,6 +21,8 @@
<PackageReference Include="Prism.DryIoc" Version="7.2.0.1422" /> <PackageReference Include="Prism.DryIoc" Version="7.2.0.1422" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\PhotoRenamer.Base\PhotoRenamer.Base.csproj" />
<ProjectReference Include="..\PhotoRenamer.File\PhotoRenamer.File.csproj" /> <ProjectReference Include="..\PhotoRenamer.File\PhotoRenamer.File.csproj" />
<ProjectReference Include="..\PhotoRenamer.Logging\PhotoRenamer.Logging.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -2,17 +2,23 @@
x:Class="PhotoRenamer.Views.MainWindow" x:Class="PhotoRenamer.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:PhotoRenamer.Base;assembly=PhotoRenamer.Base"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/" xmlns:prism="http://prismlibrary.com/"
xmlns:viewModels="clr-namespace:PhotoRenamer.ViewModels" xmlns:viewModels="clr-namespace:PhotoRenamer.ViewModels"
Title="{Binding Title}" Title="{Binding Title}"
Width="525" Width="1000"
Height="350" Height="800"
d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel}" d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel}"
prism:ViewModelLocator.AutoWireViewModel="True" prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<ContentControl prism:RegionManager.RegionName="ContentRegion" /> <Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ContentControl prism:RegionManager.RegionName="{x:Static base:RegionNames.ContentRegion}" />
<ContentControl Grid.Column="1" prism:RegionManager.RegionName="{x:Static base:RegionNames.LoggingRegion}" />
</Grid> </Grid>
</Window> </Window>