Drag Drop Form
This commit is contained in:
parent
972d8e429d
commit
c6757ad332
26
Drag-Drop/.vscode/launch.json
vendored
Normal file
26
Drag-Drop/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/bin/Debug/net6.0-windows/win-x64/Drag-Drop.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
41
Drag-Drop/.vscode/tasks.json
vendored
Normal file
41
Drag-Drop/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/Drag-Drop.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/Drag-Drop.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/Drag-Drop.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
54
Drag-Drop/Drag-Drop.csproj
Normal file
54
Drag-Drop/Drag-Drop.csproj
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<LangVersion>10.0</LangVersion>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
|
||||||
|
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
|
||||||
|
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(IsWindows)'=='true'">
|
||||||
|
<DefineConstants>Windows</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(IsOSX)'=='true'">
|
||||||
|
<DefineConstants>OSX</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(IsLinux)'=='true'">
|
||||||
|
<DefineConstants>Linux</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||||
|
<SupportedPlatform Include="browser" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||||
|
<ProjectReference Include="..\Property\Property.csproj" />
|
||||||
|
<ProjectReference Include="..\Resize\Resize.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\Instance\appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="..\Instance\appsettings.Development.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="..\Instance\appsettings.Staging.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
39
Drag-Drop/Form.Designer.cs
generated
Normal file
39
Drag-Drop/Form.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace View_by_Distance.Drag_Drop;
|
||||||
|
|
||||||
|
partial class Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(640, 100);
|
||||||
|
this.StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
150
Drag-Drop/Form.cs
Normal file
150
Drag-Drop/Form.cs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Phares.Shared;
|
||||||
|
using Serilog;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using View_by_Distance.Drag_Drop.Models;
|
||||||
|
using View_by_Distance.Resize.Models;
|
||||||
|
using View_by_Distance.Shared.Models;
|
||||||
|
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Drag_Drop;
|
||||||
|
|
||||||
|
public partial class Form : System.Windows.Forms.Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ILogger _Logger;
|
||||||
|
private readonly TextBox _TextBox;
|
||||||
|
private readonly AppSettings _AppSettings;
|
||||||
|
private readonly string _WorkingDirectory;
|
||||||
|
private readonly Configuration _Configuration;
|
||||||
|
private readonly IsEnvironment _IsEnvironment;
|
||||||
|
private readonly string _ResizeFileNameExtension;
|
||||||
|
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||||
|
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||||
|
private readonly Dictionary<int, MappingFromItem> _IdToMappingFromItem;
|
||||||
|
|
||||||
|
public Form()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
ILogger logger;
|
||||||
|
AppSettings appSettings;
|
||||||
|
string workingDirectory;
|
||||||
|
Configuration configuration;
|
||||||
|
IsEnvironment isEnvironment;
|
||||||
|
_IdToMappingFromItem = new();
|
||||||
|
IConfigurationRoot configurationRoot;
|
||||||
|
LoggerConfiguration loggerConfiguration = new();
|
||||||
|
Property.Models.Configuration propertyConfiguration;
|
||||||
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
|
||||||
|
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||||
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
|
.AddEnvironmentVariables()
|
||||||
|
.AddJsonFile(isEnvironment.AppSettingsFileName);
|
||||||
|
configurationRoot = configurationBuilder.Build();
|
||||||
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
|
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||||
|
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||||
|
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||||
|
Log.Logger = loggerConfiguration.CreateLogger();
|
||||||
|
logger = Log.ForContext<Form>();
|
||||||
|
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
|
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||||
|
(_, _, string resizeFileNameExtension) = C_Resize.GetTuple(configuration.OutputExtension, configuration.OutputQuality);
|
||||||
|
logger.Information("Complete");
|
||||||
|
_Logger = logger;
|
||||||
|
_AppSettings = appSettings;
|
||||||
|
_Configuration = configuration;
|
||||||
|
_IsEnvironment = isEnvironment;
|
||||||
|
_WorkingDirectory = workingDirectory;
|
||||||
|
_ConfigurationRoot = configurationRoot;
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
|
_ResizeFileNameExtension = resizeFileNameExtension;
|
||||||
|
_TextBox = new() { Location = new(5, 5), Dock = DockStyle.Top };
|
||||||
|
Load += new EventHandler(Form1_Load);
|
||||||
|
Controls.Add(_TextBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Form1_Load(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
int f;
|
||||||
|
int t;
|
||||||
|
AllowDrop = true;
|
||||||
|
bool firstRun = false;
|
||||||
|
Container[] containers;
|
||||||
|
DragDrop += new DragEventHandler(Form1_DragDrop);
|
||||||
|
DragEnter += new DragEventHandler(Form1_DragEnter);
|
||||||
|
Property.Models.A_Property propertyLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _ResizeFileNameExtension, _Configuration.Reverse);
|
||||||
|
(j, f, t, containers) = Property.Models.Stateless.Container.GetContainers(_Configuration.PropertyConfiguration, firstRun, propertyLogic);
|
||||||
|
List<MappingFromItem> collection = Program.GetCollection(_Configuration, containers);
|
||||||
|
foreach (MappingFromItem mappingFromItem in collection)
|
||||||
|
{
|
||||||
|
if (_IdToMappingFromItem.ContainsKey(mappingFromItem.Id))
|
||||||
|
continue;
|
||||||
|
_IdToMappingFromItem.Add(mappingFromItem.Id, mappingFromItem);
|
||||||
|
}
|
||||||
|
if (_Logger is null)
|
||||||
|
throw new NullReferenceException(nameof(_Logger));
|
||||||
|
_Logger.Debug((_AppSettings is null).ToString());
|
||||||
|
_Logger.Debug((_Configuration is null).ToString());
|
||||||
|
_Logger.Debug((_IsEnvironment is null).ToString());
|
||||||
|
_Logger.Debug((_WorkingDirectory is null).ToString());
|
||||||
|
_Logger.Debug((_ConfigurationRoot is null).ToString());
|
||||||
|
_Logger.Debug((_PropertyConfiguration is null).ToString());
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Form1_DragEnter(object? sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (e.Data is not null && e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Form1_DragDrop(object? sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (e.Data is not null)
|
||||||
|
{
|
||||||
|
string fileName;
|
||||||
|
string[] segments;
|
||||||
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
fileName = Path.GetFileNameWithoutExtension(file);
|
||||||
|
Text = fileName;
|
||||||
|
segments = fileName.Split('.');
|
||||||
|
if (int.TryParse(segments[0], out int id) && _IdToMappingFromItem.ContainsKey(id))
|
||||||
|
{
|
||||||
|
MappingFromItem mappingFromItem = _IdToMappingFromItem[id];
|
||||||
|
Text = mappingFromItem.ImageFileHolder.Name;
|
||||||
|
_TextBox.Text = mappingFromItem.ImageFileHolder.FullName;
|
||||||
|
_Logger.Information(mappingFromItem.ImageFileHolder.DirectoryName);
|
||||||
|
if (!string.IsNullOrEmpty(mappingFromItem.ImageFileHolder.DirectoryName))
|
||||||
|
_ = Process.Start("explorer.exe", string.Concat("\"", mappingFromItem.ImageFileHolder.DirectoryName, "\""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
Drag-Drop/Models/AppSettings.cs
Normal file
27
Drag-Drop/Models/AppSettings.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Drag_Drop.Models;
|
||||||
|
|
||||||
|
public class AppSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
public string Company { init; get; }
|
||||||
|
public int MaxDegreeOfParallelism { init; get; }
|
||||||
|
public string WorkingDirectoryName { init; get; }
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
||||||
|
{
|
||||||
|
Company = company;
|
||||||
|
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||||
|
WorkingDirectoryName = workingDirectoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
44
Drag-Drop/Models/Binder/AppSettings.cs
Normal file
44
Drag-Drop/Models/Binder/AppSettings.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Drag_Drop.Models.Binder;
|
||||||
|
|
||||||
|
public class AppSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
public string Company { get; set; }
|
||||||
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
|
public string WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
|
#nullable restore
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Models.AppSettings Get(AppSettings appSettings)
|
||||||
|
{
|
||||||
|
Models.AppSettings result;
|
||||||
|
if (appSettings.MaxDegreeOfParallelism is null)
|
||||||
|
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
|
result = new(
|
||||||
|
appSettings.Company,
|
||||||
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
|
appSettings.WorkingDirectoryName
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
|
{
|
||||||
|
Models.AppSettings result;
|
||||||
|
AppSettings appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
result = Get(appSettings);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
208
Drag-Drop/Models/Binder/Configuration.cs
Normal file
208
Drag-Drop/Models/Binder/Configuration.cs
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Phares.Shared;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Drag_Drop.Models.Binder;
|
||||||
|
|
||||||
|
public class Configuration
|
||||||
|
{
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
[Display(Name = "Check D Face and Up Dates"), Required] public bool? CheckDFaceAndUpWriteDates { get; set; }
|
||||||
|
[Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; }
|
||||||
|
[Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
||||||
|
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
|
||||||
|
[Display(Name = "Force Face Last Write Time to Creation Time"), Required] public bool? ForceFaceLastWriteTimeToCreationTime { get; set; }
|
||||||
|
[Display(Name = "Force Metadata Last Write Time to Creation Time"), Required] public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
||||||
|
[Display(Name = "Force Resize Last Write Time to Creation Time"), Required] public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||||
|
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
||||||
|
[Display(Name = "Ignore Relative Paths"), Required] public string[] IgnoreRelativePaths { get; set; }
|
||||||
|
[Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JLinks { get; set; }
|
||||||
|
[Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; }
|
||||||
|
[Display(Name = "Location Confidence Factor"), Required] public int? LocationConfidenceFactor { get; set; }
|
||||||
|
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
||||||
|
[Display(Name = "Max Items In Distance Collection"), Required] public int? MaxItemsInDistanceCollection { get; set; }
|
||||||
|
[Display(Name = "Mixed Year Relative Paths"), Required] public string[] MixedYearRelativePaths { get; set; }
|
||||||
|
[Display(Name = "Model Directory"), Required] public string ModelDirectory { get; set; }
|
||||||
|
[Display(Name = "Model Name"), Required] public string ModelName { get; set; }
|
||||||
|
[Display(Name = "Number Jitters"), Required] public int? NumberOfJitters { get; set; }
|
||||||
|
[Display(Name = "Number of Times To Up Sample"), Required] public int? NumberOfTimesToUpsample { get; set; }
|
||||||
|
[Display(Name = "Output Extension"), Required] public string OutputExtension { get; set; }
|
||||||
|
[Display(Name = "Output Quality"), Required] public int? OutputQuality { get; set; }
|
||||||
|
[Display(Name = "Output Resolutions"), Required] public string[] OutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Override For Face Images"), Required] public bool? OverrideForFaceImages { get; set; }
|
||||||
|
[Display(Name = "Override For Face Landmark Images"), Required] public bool? OverrideForFaceLandmarkImages { get; set; }
|
||||||
|
[Display(Name = "Override For Resize Images"), Required] public bool? OverrideForResizeImages { get; set; }
|
||||||
|
[Display(Name = "Padding Loops"), Required] public int? PaddingLoops { get; set; }
|
||||||
|
[Display(Name = "Predictor Model Name"), Required] public string PredictorModelName { get; set; }
|
||||||
|
[Display(Name = "Properties Changed For Distance"), Required] public bool? PropertiesChangedForDistance { get; set; }
|
||||||
|
[Display(Name = "Properties Changed For Faces"), Required] public bool? PropertiesChangedForFaces { get; set; }
|
||||||
|
[Display(Name = "Properties Changed For Index"), Required] public bool? PropertiesChangedForIndex { get; set; }
|
||||||
|
[Display(Name = "Properties Changed For Metadata"), Required] public bool? PropertiesChangedForMetadata { get; set; }
|
||||||
|
[Display(Name = "Properties Changed For Resize"), Required] public bool? PropertiesChangedForResize { get; set; }
|
||||||
|
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
|
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
||||||
|
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
|
||||||
|
[Display(Name = "Save Resized Images by Person Key Formatted"), Required] public string[] SaveResizedImagesByPersonKeyFormattedForOutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Save Resized Subfiles"), Required] public bool? SaveResizedSubfiles { get; set; }
|
||||||
|
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
||||||
|
[Display(Name = "Test Distance Results"), Required] public bool? TestDistanceResults { get; set; }
|
||||||
|
[Display(Name = "Valid Resolutions"), Required] public string[] ValidResolutions { get; set; }
|
||||||
|
|
||||||
|
#nullable restore
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Models.Configuration Get(Configuration configuration)
|
||||||
|
{
|
||||||
|
Models.Configuration result;
|
||||||
|
if (configuration.CheckDFaceAndUpWriteDates is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.CheckDFaceAndUpWriteDates));
|
||||||
|
if (configuration.CheckJsonForDistanceResults is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
||||||
|
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
||||||
|
if (configuration.DistanceFactor is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.DistanceFactor));
|
||||||
|
if (configuration.ForceFaceLastWriteTimeToCreationTime is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.ForceFaceLastWriteTimeToCreationTime));
|
||||||
|
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||||
|
if (configuration.ForceResizeLastWriteTimeToCreationTime is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||||
|
if (configuration.IgnoreExtensions is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
|
if (configuration.IgnoreRelativePaths is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.IgnoreRelativePaths));
|
||||||
|
if (configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions is null)
|
||||||
|
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions = Array.Empty<string>();
|
||||||
|
if (configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions is null)
|
||||||
|
configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = Array.Empty<string>();
|
||||||
|
if (configuration.LoadOrCreateThenSaveIndex is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveIndex));
|
||||||
|
if (configuration.LocationConfidenceFactor is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.LocationConfidenceFactor));
|
||||||
|
if (configuration.MaxItemsInDistanceCollection is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.MaxItemsInDistanceCollection));
|
||||||
|
if (configuration.MixedYearRelativePaths is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths));
|
||||||
|
if (configuration.NumberOfJitters is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||||
|
if (configuration.NumberOfTimesToUpsample is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||||
|
if (configuration.OutputQuality is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.OutputQuality));
|
||||||
|
if (configuration.OutputResolutions is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.OutputResolutions));
|
||||||
|
if (configuration.OverrideForFaceImages is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.OverrideForFaceImages));
|
||||||
|
if (configuration.OverrideForFaceLandmarkImages is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.OverrideForFaceLandmarkImages));
|
||||||
|
if (configuration.OverrideForResizeImages is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
||||||
|
if (configuration.PaddingLoops is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.PaddingLoops));
|
||||||
|
if (configuration.PropertiesChangedForDistance is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
||||||
|
if (configuration.PropertiesChangedForFaces is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.PropertiesChangedForFaces));
|
||||||
|
if (configuration.PropertiesChangedForIndex is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.PropertiesChangedForIndex));
|
||||||
|
if (configuration.PropertiesChangedForMetadata is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.PropertiesChangedForMetadata));
|
||||||
|
if (configuration.PropertiesChangedForResize is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.PropertiesChangedForResize));
|
||||||
|
if (configuration.Reverse is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.Reverse));
|
||||||
|
if (configuration.SaveFaceLandmarkForOutputResolutions is null)
|
||||||
|
configuration.SaveFaceLandmarkForOutputResolutions = Array.Empty<string>();
|
||||||
|
if (configuration.SaveFullYearOfRandomFiles is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.SaveFullYearOfRandomFiles));
|
||||||
|
if (configuration.SaveResizedImagesByPersonKeyFormattedForOutputResolutions is null)
|
||||||
|
configuration.SaveResizedImagesByPersonKeyFormattedForOutputResolutions = Array.Empty<string>();
|
||||||
|
if (configuration.SaveResizedSubfiles is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.SaveResizedSubfiles));
|
||||||
|
if (configuration.SaveShortcutsForOutputResolutions is null)
|
||||||
|
configuration.SaveShortcutsForOutputResolutions = Array.Empty<string>();
|
||||||
|
if (configuration.SkipSearch is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||||
|
if (configuration.TestDistanceResults is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.TestDistanceResults));
|
||||||
|
if (configuration.ValidResolutions is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.ValidResolutions));
|
||||||
|
result = new(configuration.PropertyConfiguration,
|
||||||
|
configuration.CheckDFaceAndUpWriteDates.Value,
|
||||||
|
configuration.CheckJsonForDistanceResults.Value,
|
||||||
|
configuration.CrossDirectoryMaxItemsInDistanceCollection.Value,
|
||||||
|
configuration.DistanceFactor.Value,
|
||||||
|
configuration.ForceFaceLastWriteTimeToCreationTime.Value,
|
||||||
|
configuration.ForceMetadataLastWriteTimeToCreationTime.Value,
|
||||||
|
configuration.ForceResizeLastWriteTimeToCreationTime.Value,
|
||||||
|
configuration.IgnoreExtensions,
|
||||||
|
configuration.IgnoreRelativePaths,
|
||||||
|
configuration.JLinks,
|
||||||
|
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions,
|
||||||
|
configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions,
|
||||||
|
configuration.LoadOrCreateThenSaveIndex.Value,
|
||||||
|
configuration.LocationConfidenceFactor.Value,
|
||||||
|
configuration.MappedMaxIndex,
|
||||||
|
configuration.MaxItemsInDistanceCollection.Value,
|
||||||
|
configuration.MixedYearRelativePaths,
|
||||||
|
configuration.ModelDirectory,
|
||||||
|
configuration.ModelName,
|
||||||
|
configuration.NumberOfJitters.Value,
|
||||||
|
configuration.NumberOfTimesToUpsample.Value,
|
||||||
|
configuration.OutputExtension,
|
||||||
|
configuration.OutputQuality.Value,
|
||||||
|
configuration.OutputResolutions,
|
||||||
|
configuration.OverrideForFaceImages.Value,
|
||||||
|
configuration.OverrideForFaceLandmarkImages.Value,
|
||||||
|
configuration.OverrideForResizeImages.Value,
|
||||||
|
configuration.PaddingLoops.Value,
|
||||||
|
configuration.PredictorModelName,
|
||||||
|
configuration.PropertiesChangedForDistance.Value,
|
||||||
|
configuration.PropertiesChangedForFaces.Value,
|
||||||
|
configuration.PropertiesChangedForIndex.Value,
|
||||||
|
configuration.PropertiesChangedForMetadata.Value,
|
||||||
|
configuration.PropertiesChangedForResize.Value,
|
||||||
|
configuration.Reverse.Value,
|
||||||
|
configuration.SaveFaceLandmarkForOutputResolutions,
|
||||||
|
configuration.SaveFullYearOfRandomFiles.Value,
|
||||||
|
configuration.SaveResizedImagesByPersonKeyFormattedForOutputResolutions,
|
||||||
|
configuration.SaveShortcutsForOutputResolutions,
|
||||||
|
configuration.SaveResizedSubfiles.Value,
|
||||||
|
configuration.SkipSearch.Value,
|
||||||
|
configuration.TestDistanceResults.Value,
|
||||||
|
configuration.ValidResolutions);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, Property.Models.Configuration propertyConfiguration)
|
||||||
|
{
|
||||||
|
Models.Configuration result;
|
||||||
|
Configuration configuration;
|
||||||
|
if (isEnvironment is null)
|
||||||
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
}
|
||||||
|
result = Get(configuration);
|
||||||
|
result.SetAndUpdate(propertyConfiguration, null, null, null, null);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
160
Drag-Drop/Models/Configuration.cs
Normal file
160
Drag-Drop/Models/Configuration.cs
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Drag_Drop.Models;
|
||||||
|
|
||||||
|
public class Configuration
|
||||||
|
{
|
||||||
|
|
||||||
|
protected Property.Models.Configuration _PropertyConfiguration;
|
||||||
|
public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration;
|
||||||
|
|
||||||
|
public bool CheckDFaceAndUpWriteDates { init; get; }
|
||||||
|
public bool CheckJsonForDistanceResults { init; get; }
|
||||||
|
public int CrossDirectoryMaxItemsInDistanceCollection { init; get; }
|
||||||
|
public int DistanceFactor { init; get; }
|
||||||
|
public bool ForceFaceLastWriteTimeToCreationTime { init; get; }
|
||||||
|
public bool ForceMetadataLastWriteTimeToCreationTime { init; get; }
|
||||||
|
public bool ForceResizeLastWriteTimeToCreationTime { init; get; }
|
||||||
|
public string[] IgnoreExtensions { init; get; }
|
||||||
|
public string[] IgnoreRelativePaths { init; get; }
|
||||||
|
public string[] JLinks { init; get; }
|
||||||
|
public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { init; get; }
|
||||||
|
public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { init; get; }
|
||||||
|
public bool LoadOrCreateThenSaveIndex { init; get; }
|
||||||
|
public int LocationConfidenceFactor { init; get; }
|
||||||
|
public int? MappedMaxIndex { init; get; }
|
||||||
|
public int MaxItemsInDistanceCollection { init; get; }
|
||||||
|
public string[] MixedYearRelativePaths { init; get; }
|
||||||
|
public string ModelDirectory { init; get; }
|
||||||
|
public string ModelName { init; get; }
|
||||||
|
public int NumberOfJitters { init; get; }
|
||||||
|
public int NumberOfTimesToUpsample { init; get; }
|
||||||
|
public string OutputExtension { init; get; }
|
||||||
|
public int OutputQuality { init; get; }
|
||||||
|
public string[] OutputResolutions { init; get; }
|
||||||
|
public bool OverrideForFaceImages { init; get; }
|
||||||
|
public bool OverrideForFaceLandmarkImages { init; get; }
|
||||||
|
public bool OverrideForResizeImages { init; get; }
|
||||||
|
public int PaddingLoops { init; get; }
|
||||||
|
public string PredictorModelName { init; get; }
|
||||||
|
public bool PropertiesChangedForDistance { init; get; }
|
||||||
|
public bool PropertiesChangedForFaces { init; get; }
|
||||||
|
public bool PropertiesChangedForIndex { init; get; }
|
||||||
|
public bool PropertiesChangedForMetadata { init; get; }
|
||||||
|
public bool PropertiesChangedForResize { init; get; }
|
||||||
|
public bool Reverse { init; get; }
|
||||||
|
public string[] SaveFaceLandmarkForOutputResolutions { init; get; }
|
||||||
|
public bool SaveFullYearOfRandomFiles { init; get; }
|
||||||
|
public string[] SaveResizedImagesByPersonKeyFormattedForOutputResolutions { init; get; }
|
||||||
|
public string[] SaveShortcutsForOutputResolutions { init; get; }
|
||||||
|
public bool SaveResizedSubfiles { init; get; }
|
||||||
|
public bool SkipSearch { init; get; }
|
||||||
|
public bool TestDistanceResults { init; get; }
|
||||||
|
public string[] ValidResolutions { init; get; }
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public Configuration(Property.Models.Configuration propertyConfiguration,
|
||||||
|
bool checkDFaceAndUpWriteDates,
|
||||||
|
bool checkJsonForDistanceResults,
|
||||||
|
int crossDirectoryMaxItemsInDistanceCollection,
|
||||||
|
int distanceFactor,
|
||||||
|
bool forceFaceLastWriteTimeToCreationTime,
|
||||||
|
bool forceMetadataLastWriteTimeToCreationTime,
|
||||||
|
bool forceResizeLastWriteTimeToCreationTime,
|
||||||
|
string[] ignoreExtensions,
|
||||||
|
string[] ignoreRelativePaths,
|
||||||
|
string[] jLinks,
|
||||||
|
string[] loadOrCreateThenSaveDistanceResultsForOutputResolutions,
|
||||||
|
string[] loadOrCreateThenSaveImageFacesResultsForOutputResolutions,
|
||||||
|
bool loadOrCreateThenSaveIndex,
|
||||||
|
int locationConfidenceFactor,
|
||||||
|
int? mappedMaxIndex,
|
||||||
|
int maxItemsInDistanceCollection,
|
||||||
|
string[] mixedYearRelativePaths,
|
||||||
|
string modelDirectory,
|
||||||
|
string modelName,
|
||||||
|
int numberOfJitters,
|
||||||
|
int numberOfTimesToUpsample,
|
||||||
|
string outputExtension,
|
||||||
|
int outputQuality,
|
||||||
|
string[] outputResolutions,
|
||||||
|
bool overrideForFaceImages,
|
||||||
|
bool overrideForFaceLandmarkImages,
|
||||||
|
bool overrideForResizeImages,
|
||||||
|
int paddingLoops,
|
||||||
|
string predictorModelName,
|
||||||
|
bool propertiesChangedForDistance,
|
||||||
|
bool propertiesChangedForFaces,
|
||||||
|
bool propertiesChangedForIndex,
|
||||||
|
bool propertiesChangedForMetadata,
|
||||||
|
bool propertiesChangedForResize,
|
||||||
|
bool reverse,
|
||||||
|
string[] saveFaceLandmarkForOutputResolutions,
|
||||||
|
bool saveFullYearOfRandomFiles,
|
||||||
|
string[] saveResizedImagesByPersonKeyFormattedForOutputResolutions,
|
||||||
|
string[] saveShortcutsForOutputResolutions,
|
||||||
|
bool saveResizedSubfiles,
|
||||||
|
bool skipSearch,
|
||||||
|
bool testDistanceResults,
|
||||||
|
string[] validResolutions)
|
||||||
|
{
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
|
CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates;
|
||||||
|
CheckJsonForDistanceResults = checkJsonForDistanceResults;
|
||||||
|
CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection;
|
||||||
|
DistanceFactor = distanceFactor;
|
||||||
|
ForceFaceLastWriteTimeToCreationTime = forceFaceLastWriteTimeToCreationTime;
|
||||||
|
ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
||||||
|
ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
||||||
|
IgnoreExtensions = ignoreExtensions;
|
||||||
|
IgnoreRelativePaths = ignoreRelativePaths;
|
||||||
|
JLinks = jLinks;
|
||||||
|
LoadOrCreateThenSaveDistanceResultsForOutputResolutions = loadOrCreateThenSaveDistanceResultsForOutputResolutions;
|
||||||
|
LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = loadOrCreateThenSaveImageFacesResultsForOutputResolutions;
|
||||||
|
LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex;
|
||||||
|
LocationConfidenceFactor = locationConfidenceFactor;
|
||||||
|
MappedMaxIndex = mappedMaxIndex;
|
||||||
|
MaxItemsInDistanceCollection = maxItemsInDistanceCollection;
|
||||||
|
MixedYearRelativePaths = mixedYearRelativePaths;
|
||||||
|
ModelDirectory = modelDirectory;
|
||||||
|
ModelName = modelName;
|
||||||
|
NumberOfJitters = numberOfJitters;
|
||||||
|
NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
||||||
|
OutputExtension = outputExtension;
|
||||||
|
OutputQuality = outputQuality;
|
||||||
|
OutputResolutions = outputResolutions;
|
||||||
|
OverrideForFaceImages = overrideForFaceImages;
|
||||||
|
OverrideForFaceLandmarkImages = overrideForFaceLandmarkImages;
|
||||||
|
OverrideForResizeImages = overrideForResizeImages;
|
||||||
|
PaddingLoops = paddingLoops;
|
||||||
|
PredictorModelName = predictorModelName;
|
||||||
|
PropertiesChangedForDistance = propertiesChangedForDistance;
|
||||||
|
PropertiesChangedForFaces = propertiesChangedForFaces;
|
||||||
|
PropertiesChangedForIndex = propertiesChangedForIndex;
|
||||||
|
PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||||
|
PropertiesChangedForResize = propertiesChangedForResize;
|
||||||
|
Reverse = reverse;
|
||||||
|
SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
|
||||||
|
SaveFullYearOfRandomFiles = saveFullYearOfRandomFiles;
|
||||||
|
SaveResizedImagesByPersonKeyFormattedForOutputResolutions = saveResizedImagesByPersonKeyFormattedForOutputResolutions;
|
||||||
|
SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
||||||
|
SaveResizedSubfiles = saveResizedSubfiles;
|
||||||
|
SkipSearch = skipSearch;
|
||||||
|
TestDistanceResults = testDistanceResults;
|
||||||
|
ValidResolutions = validResolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAndUpdate(Property.Models.Configuration configuration, int? numberOfJitters, int? numberOfTimesToUpsample, string? modelName, string? predictorModelName)
|
||||||
|
{
|
||||||
|
_PropertyConfiguration = configuration;
|
||||||
|
_PropertyConfiguration.Update(numberOfJitters, numberOfTimesToUpsample, modelName, predictorModelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
78
Drag-Drop/Program.cs
Normal file
78
Drag-Drop/Program.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using View_by_Distance.Shared.Models;
|
||||||
|
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Drag_Drop;
|
||||||
|
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Item[] GetFilterItems(Models.Configuration configuration, Container container)
|
||||||
|
{
|
||||||
|
List<Item> results = new();
|
||||||
|
foreach (Item item in container.Items)
|
||||||
|
{
|
||||||
|
if (item.ImageFileHolder is not null
|
||||||
|
&& (item.Abandoned is null || !item.Abandoned.Value)
|
||||||
|
&& item.ValidImageFormatExtension
|
||||||
|
&& !configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered))
|
||||||
|
results.Add(item);
|
||||||
|
}
|
||||||
|
return results.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsIgnoreRelativePath(Models.Configuration configuration, string directory)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
string? checkDirectory = Path.GetFullPath(directory);
|
||||||
|
for (int i = 0; i < int.MaxValue; i++)
|
||||||
|
{
|
||||||
|
if (configuration.IgnoreRelativePaths.Contains(Path.GetFileName(checkDirectory)))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
||||||
|
if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == configuration.PropertyConfiguration.RootDirectory)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<MappingFromItem> GetCollection(Models.Configuration configuration, Container[] containers)
|
||||||
|
{
|
||||||
|
List<MappingFromItem> results = new();
|
||||||
|
bool? isWrongYear;
|
||||||
|
Item[] filteredItems;
|
||||||
|
DateTime minimumDateTime;
|
||||||
|
MappingFromItem mappingFromItem;
|
||||||
|
foreach (Container container in containers)
|
||||||
|
{
|
||||||
|
if (!container.Items.Any())
|
||||||
|
continue;
|
||||||
|
if (configuration.IgnoreRelativePaths.Any(l => container.SourceDirectory.Contains(l)) && IsIgnoreRelativePath(configuration, container.SourceDirectory))
|
||||||
|
continue;
|
||||||
|
filteredItems = GetFilterItems(configuration, container);
|
||||||
|
if (!filteredItems.Any())
|
||||||
|
continue;
|
||||||
|
foreach (Item item in filteredItems)
|
||||||
|
{
|
||||||
|
if (item.Property?.Id is null || item.ImageFileHolder is null)
|
||||||
|
continue;
|
||||||
|
minimumDateTime = IProperty.GetMinimumDateTime(item.Property);
|
||||||
|
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
||||||
|
mappingFromItem = new(item.Property.Id.Value, item.ImageFileHolder, isWrongYear, minimumDateTime, item.RelativePath, item.ImageFileHolder);
|
||||||
|
results.Add(mappingFromItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Face", "Face\Face.csproj",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaceParts", "FaceParts\FaceParts.csproj", "{919525B1-60BA-40C6-BA66-6F7F4C526E01}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaceParts", "FaceParts\FaceParts.csproj", "{919525B1-60BA-40C6-BA66-6F7F4C526E01}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Drag-Drop", "Drag-Drop\Drag-Drop.csproj", "{796F5B13-1E23-433F-8CBF-BF548AC4AF3F}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -114,5 +116,9 @@ Global
|
|||||||
{919525B1-60BA-40C6-BA66-6F7F4C526E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{919525B1-60BA-40C6-BA66-6F7F4C526E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{919525B1-60BA-40C6-BA66-6F7F4C526E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{919525B1-60BA-40C6-BA66-6F7F4C526E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{919525B1-60BA-40C6-BA66-6F7F4C526E01}.Release|Any CPU.Build.0 = Release|Any CPU
|
{919525B1-60BA-40C6-BA66-6F7F4C526E01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{796F5B13-1E23-433F-8CBF-BF548AC4AF3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{796F5B13-1E23-433F-8CBF-BF548AC4AF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{796F5B13-1E23-433F-8CBF-BF548AC4AF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{796F5B13-1E23-433F-8CBF-BF548AC4AF3F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user