修复流程图编辑器界面及初步的功能
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
|
||||
namespace XplorePlane.Services
|
||||
{
|
||||
internal static class ProcessorUiMetadata
|
||||
{
|
||||
private static readonly (string Category, string CategoryIcon, int Order)[] CategoryDefinitions =
|
||||
{
|
||||
("滤波与平滑", "🌀", 0),
|
||||
("图像增强", "✨", 1),
|
||||
("图像变换", "🔁", 2),
|
||||
("数学运算", "➗", 3),
|
||||
("形态学处理", "⬚", 4),
|
||||
("边缘检测", "📐", 5),
|
||||
("检测分析", "🔎", 6),
|
||||
("其他", "⚙", 99),
|
||||
};
|
||||
|
||||
internal static (string Category, string CategoryIcon, string OperatorIcon) Get(string operatorKey)
|
||||
{
|
||||
var category = GetCategory(operatorKey);
|
||||
return (category, GetCategoryIcon(category), GetOperatorIcon(operatorKey, category));
|
||||
}
|
||||
|
||||
internal static string GetCategory(string operatorKey)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(operatorKey))
|
||||
return "其他";
|
||||
|
||||
if (ContainsAny(operatorKey, "Blur", "Filter", "Shock"))
|
||||
return "滤波与平滑";
|
||||
|
||||
if (ContainsAny(operatorKey, "Contrast", "Gamma", "Retinex", "Histogram", "Sharpen", "Layer",
|
||||
"SubPixel", "SuperResolution", "HDR", "Effect", "PseudoColor", "Color"))
|
||||
return "图像增强";
|
||||
|
||||
if (ContainsAny(operatorKey, "Mirror", "Rotate", "Grayscale", "Threshold"))
|
||||
return "图像变换";
|
||||
|
||||
if (ContainsAny(operatorKey, "Division", "Multiplication", "Difference", "Integral", "Or"))
|
||||
return "数学运算";
|
||||
|
||||
if (ContainsAny(operatorKey, "Morphology"))
|
||||
return "形态学处理";
|
||||
|
||||
if (ContainsAny(operatorKey, "Edge"))
|
||||
return "边缘检测";
|
||||
|
||||
if (ContainsAny(operatorKey, "Measurement", "Detection", "Contour", "FillRate", "Void", "Line", "PointToLine", "Ellipse", "Bga"))
|
||||
return "检测分析";
|
||||
|
||||
return "其他";
|
||||
}
|
||||
|
||||
internal static int GetCategoryOrder(string category)
|
||||
{
|
||||
foreach (var definition in CategoryDefinitions)
|
||||
{
|
||||
if (string.Equals(definition.Category, category, StringComparison.Ordinal))
|
||||
return definition.Order;
|
||||
}
|
||||
|
||||
return 99;
|
||||
}
|
||||
|
||||
internal static string GetCategoryIcon(string category)
|
||||
{
|
||||
foreach (var definition in CategoryDefinitions)
|
||||
{
|
||||
if (string.Equals(definition.Category, category, StringComparison.Ordinal))
|
||||
return definition.CategoryIcon;
|
||||
}
|
||||
|
||||
return "⚙";
|
||||
}
|
||||
|
||||
internal static string GetOperatorIcon(string operatorKey) => GetOperatorIcon(operatorKey, GetCategory(operatorKey));
|
||||
|
||||
private static string GetOperatorIcon(string operatorKey, string category)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(operatorKey))
|
||||
return GetCategoryIcon(category);
|
||||
|
||||
if (ContainsAny(operatorKey, "Shock"))
|
||||
return "⚡";
|
||||
if (ContainsAny(operatorKey, "BandPass"))
|
||||
return "📶";
|
||||
if (ContainsAny(operatorKey, "GaussianBlur", "MeanFilter", "MedianFilter", "BilateralFilter", "LowPassFilter", "HighPassFilter"))
|
||||
return "🌀";
|
||||
if (ContainsAny(operatorKey, "Contrast"))
|
||||
return "🌗";
|
||||
if (ContainsAny(operatorKey, "Gamma"))
|
||||
return "γ";
|
||||
if (ContainsAny(operatorKey, "Retinex"))
|
||||
return "🎛";
|
||||
if (ContainsAny(operatorKey, "Histogram"))
|
||||
return "📊";
|
||||
if (ContainsAny(operatorKey, "Sharpen"))
|
||||
return "✦";
|
||||
if (ContainsAny(operatorKey, "SubPixel", "SuperResolution"))
|
||||
return "🔬";
|
||||
if (ContainsAny(operatorKey, "HDR"))
|
||||
return "💡";
|
||||
if (ContainsAny(operatorKey, "PseudoColor"))
|
||||
return "🎨";
|
||||
if (ContainsAny(operatorKey, "FilmEffect"))
|
||||
return "🎞";
|
||||
if (ContainsAny(operatorKey, "ColorLayer"))
|
||||
return "🧪";
|
||||
if (ContainsAny(operatorKey, "Mirror"))
|
||||
return "↔";
|
||||
if (ContainsAny(operatorKey, "Rotate"))
|
||||
return "⟳";
|
||||
if (ContainsAny(operatorKey, "Grayscale"))
|
||||
return "◻";
|
||||
if (ContainsAny(operatorKey, "Threshold"))
|
||||
return "▣";
|
||||
if (ContainsAny(operatorKey, "Division"))
|
||||
return "➗";
|
||||
if (ContainsAny(operatorKey, "Multiplication"))
|
||||
return "✕";
|
||||
if (ContainsAny(operatorKey, "Difference"))
|
||||
return "Δ";
|
||||
if (ContainsAny(operatorKey, "Integral"))
|
||||
return "∫";
|
||||
if (ContainsAny(operatorKey, "Or"))
|
||||
return "∨";
|
||||
if (ContainsAny(operatorKey, "Morphology"))
|
||||
return "⬚";
|
||||
if (ContainsAny(operatorKey, "Sobel", "Kirsch", "HorizontalEdge"))
|
||||
return "📐";
|
||||
if (ContainsAny(operatorKey, "Contour"))
|
||||
return "✏";
|
||||
if (ContainsAny(operatorKey, "Measurement"))
|
||||
return "📏";
|
||||
if (ContainsAny(operatorKey, "FillRate"))
|
||||
return "🧮";
|
||||
if (ContainsAny(operatorKey, "Void"))
|
||||
return "⚪";
|
||||
if (ContainsAny(operatorKey, "Ellipse"))
|
||||
return "⭕";
|
||||
if (ContainsAny(operatorKey, "PointToLine"))
|
||||
return "📍";
|
||||
if (ContainsAny(operatorKey, "Edge"))
|
||||
return "📐";
|
||||
|
||||
return GetCategoryIcon(category);
|
||||
}
|
||||
|
||||
private static bool ContainsAny(string value, params string[] terms)
|
||||
{
|
||||
foreach (var term in terms)
|
||||
{
|
||||
if (value.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user