feat: Everything2Everything 양방향 변환 매트릭스 피보팅
EverythingToJpeg(N→JPEG 단방향)에서 Everything2Everything(N×M 매트릭스)으로 앱을 피보팅. 7개 Provider, 200+ 변환 쌍 지원. 리네이밍 - 디렉토리/솔루션/csproj/namespace/AssemblyName/MSIX Identity 일괄 치환 - 임시파일 prefix e2j_ → e2e_, 로고 라벨 E2J → E2E 아키텍처 - ConversionPair(input, output) 신규 + ProviderCapability.SupportedConversions - IConverterProvider.ConvertAsync에 outputExtension 파라미터 추가 - ProviderRegistry를 Dictionary<(input, output), Provider> 매트릭스로 재작성 + OutputsForInput / OutputsForFile 쿼리 API - ConversionEngine: 출력 ext 라우팅, 동일 입출력 자동 skip, 서브폴더 suffix를 출력 ext에서 자동 도출 - ConvertOptions를 형식별 sub-record로 분리 (Jpeg/Png/Webp/Avif/Tiff/Pdf*/Html*/Ocr) Provider 매트릭스 - MagickProvider: PNG/JPEG/WebP/AVIF/BMP/TIFF/GIF/PDF 양방향 + RAW/PSD 디코딩 (단일이미지→1페이지 PDF, GIF/TIFF→다페이지 PDF) - HeicProvider: HEIC/HEIF → 이미지 7종 - PdfProvider: PDF → 이미지 6종 (PNG임베드 후 ImageMagick 인코딩) - HtmlProvider: HTML/HTM → 이미지 + PDF (CDP printToPDF) - DocxProvider/HwpxProvider: PDF + 이미지 7종 (LibreOffice 활용) - OcrProvider 신규: 이미지/PDF → TXT/DOCX (Windows.Media.Ocr + DocumentFormat.OpenXml, PDF는 페이지별 OCR 후 결합) UI - 사이드바 TARGET FORMAT을 동적 ComboBox로 (큐 파일 매트릭스의 교집합만 표시) - 출력 형식별 색상 배지 + Quality 패널 라벨 동적 - OUTPUT DESTINATION hint도 출력 ext 기반 동적 CLI - 신규 'to <ext> <files...>' verb (예: to png photo.heic doc.docx) - help 텍스트 양방향 컨셉으로 갱신 셸 통합 - ContextMenuRegistrar 카스케이드로 재설계 (ExtendedSubCommandsKey + Everything2Everything.SubMenu.<ext>) - 입력별 매트릭스에 따라 인기 출력 10종(JPEG/PNG/WebP/PDF/TXT/DOCX/AVIF/GIF/TIFF/BMP) 동적 노출, 마지막에 '변환…' 옵션 - 메뉴 라벨 'JPEG로 변환' → 'Everything2Everything으로 변환' 기타 - Core.csproj TFM net9.0-windows → net9.0-windows10.0.19041.0 (WinRT API용) - DocumentFormat.OpenXml 3.1.0 NuGet 추가 - README 양방향 매트릭스 기준 전면 개편 - MSIX appxmanifest Description / IExplorerCommand DLL 라벨 갱신 빌드: 0 errors, 0 warnings
This commit is contained in:
parent
96861e627d
commit
9b7e5f0d0c
63 changed files with 1788 additions and 733 deletions
177
src/Everything2Everything.App/Shell/ContextMenuRegistrar.cs
Normal file
177
src/Everything2Everything.App/Shell/ContextMenuRegistrar.cs
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
using Everything2Everything.Core;
|
||||
using Everything2Everything.Core.Providers;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Everything2Everything.App.Shell;
|
||||
|
||||
internal static class ContextMenuRegistrar
|
||||
{
|
||||
private const string MainVerb = "Everything2Everything";
|
||||
private const string MainLabel = "Everything2Everything으로 변환";
|
||||
|
||||
private const string SubmenuKeyPrefix = "Everything2Everything.SubMenu.";
|
||||
|
||||
private static readonly (string Ext, string Label, string SortPrefix)[] PopularOutputs =
|
||||
{
|
||||
(".jpg", "JPEG (.jpg)", "01"),
|
||||
(".png", "PNG (.png)", "02"),
|
||||
(".webp", "WebP (.webp)", "03"),
|
||||
(".pdf", "PDF (.pdf)", "04"),
|
||||
(".txt", "텍스트 (.txt) — OCR", "05"),
|
||||
(".docx", "Word (.docx) — OCR", "06"),
|
||||
(".avif", "AVIF (.avif)", "07"),
|
||||
(".gif", "GIF (.gif)", "08"),
|
||||
(".tif", "TIFF (.tif)", "09"),
|
||||
(".bmp", "BMP (.bmp)", "10"),
|
||||
};
|
||||
|
||||
public static void Register(ConversionEngine engine)
|
||||
{
|
||||
var exe = GetAppExecutablePath();
|
||||
var icon = exe + ",0";
|
||||
|
||||
foreach (var ext in CollectInputExtensions(engine))
|
||||
{
|
||||
var outputs = engine.Providers.OutputsForInput(ext)
|
||||
.Select(o => o.ToLowerInvariant())
|
||||
.ToHashSet();
|
||||
|
||||
var availableOutputs = PopularOutputs
|
||||
.Where(p => outputs.Contains(p.Ext) && !string.Equals(p.Ext, ext, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
if (availableOutputs.Count == 0) continue;
|
||||
|
||||
WriteCascade(ext, exe, icon, availableOutputs);
|
||||
}
|
||||
|
||||
NotifyShell();
|
||||
}
|
||||
|
||||
public static void Unregister(ConversionEngine engine)
|
||||
{
|
||||
foreach (var ext in CollectInputExtensions(engine))
|
||||
{
|
||||
DeleteVerb(ext, MainVerb);
|
||||
DeleteVerb(ext, "Everything2Everything.Quick");
|
||||
DeleteVerb(ext, "Everything2Everything.Dialog");
|
||||
DeleteSubmenuTree(ext);
|
||||
}
|
||||
NotifyShell();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> CollectInputExtensions(ConversionEngine engine)
|
||||
{
|
||||
return engine.Providers.Implemented
|
||||
.Where(p => p.Capability.CanRegisterContextMenu)
|
||||
.SelectMany(p => p.Capability.InputExtensions)
|
||||
.Select(e => e.StartsWith('.') ? e : "." + e)
|
||||
.Select(e => e.ToLowerInvariant())
|
||||
.Distinct();
|
||||
}
|
||||
|
||||
private static void WriteCascade(
|
||||
string ext,
|
||||
string exe,
|
||||
string icon,
|
||||
IReadOnlyList<(string Ext, string Label, string SortPrefix)> availableOutputs)
|
||||
{
|
||||
var submenuKeyName = SubmenuKeyPrefix + ext.TrimStart('.');
|
||||
|
||||
var verbPath = $@"Software\Classes\SystemFileAssociations\{ext}\shell\{MainVerb}";
|
||||
using (var verbKey = Registry.CurrentUser.CreateSubKey(verbPath, writable: true)
|
||||
?? throw new InvalidOperationException($"레지스트리 키 생성 실패: {verbPath}"))
|
||||
{
|
||||
verbKey.SetValue(null, MainLabel, RegistryValueKind.String);
|
||||
verbKey.SetValue("MUIVerb", MainLabel, RegistryValueKind.String);
|
||||
verbKey.SetValue("Icon", icon, RegistryValueKind.String);
|
||||
verbKey.SetValue("SubCommands", "", RegistryValueKind.String);
|
||||
verbKey.SetValue("ExtendedSubCommandsKey", submenuKeyName, RegistryValueKind.String);
|
||||
try { verbKey.DeleteSubKeyTree("command", throwOnMissingSubKey: false); } catch { }
|
||||
}
|
||||
|
||||
var submenuShellPath = $@"Software\Classes\{submenuKeyName}\shell";
|
||||
using (var existing = Registry.CurrentUser.OpenSubKey(submenuShellPath, writable: true))
|
||||
{
|
||||
if (existing is not null)
|
||||
{
|
||||
foreach (var name in existing.GetSubKeyNames())
|
||||
{
|
||||
try { existing.DeleteSubKeyTree(name, throwOnMissingSubKey: false); } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (outExt, outLabel, sortPrefix) in availableOutputs)
|
||||
{
|
||||
var subVerbName = $"{sortPrefix}_{outExt.TrimStart('.')}";
|
||||
var cliExt = outExt.TrimStart('.');
|
||||
WriteSubmenuItem(submenuKeyName, subVerbName, outLabel, icon,
|
||||
$"\"{exe}\" to {cliExt} \"%1\"");
|
||||
}
|
||||
|
||||
WriteSubmenuItem(submenuKeyName, "98_dialog", "변환… (옵션 선택)", icon,
|
||||
$"\"{exe}\" dialog \"%1\"");
|
||||
}
|
||||
|
||||
private static void WriteSubmenuItem(string submenuKeyName, string verbName, string label, string icon, string command)
|
||||
{
|
||||
var path = $@"Software\Classes\{submenuKeyName}\shell\{verbName}";
|
||||
using var key = Registry.CurrentUser.CreateSubKey(path, writable: true)
|
||||
?? throw new InvalidOperationException($"서브메뉴 키 생성 실패: {path}");
|
||||
|
||||
key.SetValue(null, label, RegistryValueKind.String);
|
||||
key.SetValue("MUIVerb", label, RegistryValueKind.String);
|
||||
key.SetValue("Icon", icon, RegistryValueKind.String);
|
||||
|
||||
using var commandKey = key.CreateSubKey("command", writable: true)
|
||||
?? throw new InvalidOperationException("command 하위 키 생성 실패");
|
||||
commandKey.SetValue(null, command, RegistryValueKind.String);
|
||||
}
|
||||
|
||||
private static void DeleteVerb(string ext, string verb)
|
||||
{
|
||||
var parentPath = $@"Software\Classes\SystemFileAssociations\{ext}\shell";
|
||||
try
|
||||
{
|
||||
using var parent = Registry.CurrentUser.OpenSubKey(parentPath, writable: true);
|
||||
parent?.DeleteSubKeyTree(verb, throwOnMissingSubKey: false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeleteSubmenuTree(string ext)
|
||||
{
|
||||
var submenuKeyName = SubmenuKeyPrefix + ext.TrimStart('.');
|
||||
var path = $@"Software\Classes\{submenuKeyName}";
|
||||
try
|
||||
{
|
||||
Registry.CurrentUser.DeleteSubKeyTree(path, throwOnMissingSubKey: false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAppExecutablePath()
|
||||
{
|
||||
var exe = Environment.ProcessPath;
|
||||
if (!string.IsNullOrEmpty(exe) && File.Exists(exe)) return exe;
|
||||
return AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar)
|
||||
+ Path.DirectorySeparatorChar + "Everything2Everything.exe";
|
||||
}
|
||||
|
||||
private static void NotifyShell()
|
||||
{
|
||||
try { NativeMethods.SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static class NativeMethods
|
||||
{
|
||||
[System.Runtime.InteropServices.DllImport("shell32.dll")]
|
||||
public static extern void SHChangeNotify(int wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue