.config
.vscode
Compare
Date-Group
Delete-By-Distinct
Delete-By-Relative
Distance
Drag-Drop-Explorer
Drag-Drop-Move
Drag-Drop-Search
Duplicate-Search
Face
FaceParts
FaceRecognitionDotNet
Instance
Map
Metadata
Move-By-Id
Person
PhotoPrism
PrepareForOld
Property
Property-Compare
Rename
Resize
Shared
.vscode
Models
Methods
Properties
Stateless
%ClassName%.cs .ai
Console.cs
Container.cs
DatabaseFile.cs
DirectoryFileSystem.cs
DistanceHolder.cs
Face.cs
FaceDistance.cs
FaceDistanceContainer.cs
FaceEncoding.cs
FaceFileSystem.cs
FacePoint.cs
FileHolder.cs
FilePair.cs
FileSystem.cs
GenealogicalDataCommunication.cs
GenealogicalDataCommunicationLines.cs
Item.cs
Location.cs
LocationContainer.cs
Mapping.cs
Marker.cs
MatchNginx.cs
MetadataFile.cs
MetadataFileCollection.cs
MetadataFileId.cs
OutputResolution.cs
Person.cs
PersonAddress.cs
PersonAddressCity.cs
PersonAddressState.cs
PersonAddressStreet.cs
PersonAddressZipCode.cs
PersonBirthday.cs
PersonComment.cs
PersonContainer.cs
PersonDirectory.cs
PersonEmail.cs
PersonId.cs
PersonImport.cs
PersonName.cs
PersonNameAlias.cs
PersonNameFirst.cs
PersonNameLast.cs
PersonNameMiddle.cs
PersonNumber.cs
PersonURL.cs
Property.cs
RelativeLocation.cs
RelativePaths.cs
SaveContainer.cs
SaveShortcutsForOutputResolutions.cs
Sorting.cs
SortingContainer.cs
Storage.cs
XPath.cs
Phares
Sample-Data
View-by-Distance.Shared.csproj
Tests
TestsWithFaceRecognitionDotNet
.editorconfig
.gitattributes
.gitignore
.txt
View-by-Distance-MKLink-Console.sln
package.json
83 lines
3.9 KiB
C#
83 lines
3.9 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace View_by_Distance.Shared.Models;
|
|
|
|
public class Item : Properties.IItem
|
|
{
|
|
|
|
protected List<Face> _Faces;
|
|
protected readonly bool? _FileSizeChanged;
|
|
protected readonly FileHolder _ImageFileHolder;
|
|
protected bool? _IsUniqueFileName;
|
|
protected bool _IsValidImageFormatExtension;
|
|
protected bool? _LastWriteTimeChanged;
|
|
protected bool? _Moved;
|
|
protected Property? _Property;
|
|
protected readonly string _RelativePath;
|
|
protected FileHolder? _ResizedFileHolder;
|
|
protected readonly FileHolder _SourceDirectoryFileHolder;
|
|
public List<Face> Faces => _Faces;
|
|
public bool? FileSizeChanged => _FileSizeChanged;
|
|
public FileHolder ImageFileHolder => _ImageFileHolder;
|
|
public bool? IsUniqueFileName => _IsUniqueFileName;
|
|
public bool IsValidImageFormatExtension => _IsValidImageFormatExtension;
|
|
public bool? LastWriteTimeChanged => _LastWriteTimeChanged;
|
|
public bool? Moved => _Moved;
|
|
public Property? Property => _Property;
|
|
public string RelativePath => _RelativePath;
|
|
public FileHolder? ResizedFileHolder => _ResizedFileHolder;
|
|
public FileHolder SourceDirectoryFileHolder => _SourceDirectoryFileHolder;
|
|
|
|
[JsonConstructor]
|
|
public Item(List<Face> faces, bool? fileSizeChanged, FileHolder imageFileHolder, bool? isUniqueFileName, bool isValidImageFormatExtension, bool? lastWriteTimeChanged, bool? moved, Property? property, string relativePath, FileHolder? resizedFileHolder, FileHolder sourceDirectoryFileHolder)
|
|
{
|
|
_Faces = faces;
|
|
_FileSizeChanged = fileSizeChanged;
|
|
_ImageFileHolder = imageFileHolder;
|
|
_IsUniqueFileName = isUniqueFileName;
|
|
_IsValidImageFormatExtension = isValidImageFormatExtension;
|
|
_LastWriteTimeChanged = lastWriteTimeChanged;
|
|
_Moved = moved;
|
|
_Property = property;
|
|
_RelativePath = relativePath;
|
|
_ResizedFileHolder = resizedFileHolder;
|
|
_SourceDirectoryFileHolder = sourceDirectoryFileHolder;
|
|
}
|
|
|
|
public Item(FileHolder sourceDirectoryFileHolder, string relativePath, FileHolder imageFileInfo, bool? isUniqueFileName, bool isValidImageFormatExtension, Property? property, bool? abandoned, bool? fileSizeChanged, bool? lastWriteTimeChanged) :
|
|
this(new(), fileSizeChanged, imageFileInfo, isUniqueFileName, isValidImageFormatExtension, lastWriteTimeChanged, null, property, relativePath, null, sourceDirectoryFileHolder)
|
|
{
|
|
if (relativePath.EndsWith(".json"))
|
|
throw new ArgumentException("Can not be a *.json file!");
|
|
if (imageFileInfo is not null && imageFileInfo.ExtensionLowered is ".json")
|
|
throw new ArgumentException("Can not be a *.json file!");
|
|
}
|
|
|
|
public Item(FileHolder sourceDirectoryFileHolder, string relativePath, bool isValidImageFormatExtension) :
|
|
this(sourceDirectoryFileHolder, relativePath, sourceDirectoryFileHolder, null, isValidImageFormatExtension, null, null, null, null)
|
|
{ }
|
|
|
|
public override string ToString()
|
|
{
|
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
|
return result;
|
|
}
|
|
|
|
public void SetMoved(bool moved) => _Moved = moved;
|
|
|
|
public void SetResizedFileHolder(string filenameExtension, FileHolder fileHolder)
|
|
{
|
|
if (fileHolder.ExtensionLowered == filenameExtension)
|
|
_ResizedFileHolder = fileHolder;
|
|
else if (fileHolder.ExtensionLowered.Length > 3 && fileHolder.ExtensionLowered[3] == 'e' && fileHolder.ExtensionLowered.Remove(3, 1) == filenameExtension)
|
|
_ResizedFileHolder = fileHolder;
|
|
else
|
|
_ResizedFileHolder = fileHolder;
|
|
}
|
|
|
|
public bool Any() => !_SourceDirectoryFileHolder.Exists || (_FileSizeChanged.HasValue && _FileSizeChanged.Value) || (_LastWriteTimeChanged.HasValue && _LastWriteTimeChanged.Value) || (_Moved.HasValue && _Moved.Value);
|
|
|
|
public void Update(Property property) => _Property = property;
|
|
|
|
} |