#0018 修复图像处理界面参数区显示不全的问题;将参数及算子名称改为中文

This commit is contained in:
zhengxuan.zhang
2026-03-14 21:27:09 +08:00
parent 9695629a0a
commit d5f32bfadb
12 changed files with 61 additions and 20 deletions
+9
View File
@@ -1,5 +1,7 @@
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
using System.Threading;
using System.Windows; using System.Windows;
using XplorePlane.Views; using XplorePlane.Views;
using XplorePlane.ViewModels; using XplorePlane.ViewModels;
@@ -21,6 +23,13 @@ namespace XplorePlane
{ {
protected override void OnStartup(StartupEventArgs e) protected override void OnStartup(StartupEventArgs e)
{ {
// 强制使用中文 UI,确保 ImageProcessing 库显示中文
var zhCN = new CultureInfo("zh-CN");
Thread.CurrentThread.CurrentCulture = zhCN;
Thread.CurrentThread.CurrentUICulture = zhCN;
CultureInfo.DefaultThreadCurrentCulture = zhCN;
CultureInfo.DefaultThreadCurrentUICulture = zhCN;
// 配置 Serilog 日志系统 // 配置 Serilog 日志系统
ConfigureLogging(); ConfigureLogging();
Binary file not shown.
@@ -12,6 +12,7 @@ namespace XplorePlane.Services
IReadOnlyList<string> GetAvailableProcessors(); IReadOnlyList<string> GetAvailableProcessors();
IReadOnlyList<ProcessorParameter> GetProcessorParameters(string processorName); IReadOnlyList<ProcessorParameter> GetProcessorParameters(string processorName);
ImageProcessorBase GetProcessor(string processorName); ImageProcessorBase GetProcessor(string processorName);
string GetProcessorDisplayName(string processorName);
void RegisterProcessor(string name, ImageProcessorBase processor); void RegisterProcessor(string name, ImageProcessorBase processor);
Task<BitmapSource> ProcessImageAsync( Task<BitmapSource> ProcessImageAsync(
@@ -78,6 +78,15 @@ namespace XplorePlane.Services
throw new ArgumentException($"Processor not registered or is 16-bit only: {processorName}", nameof(processorName)); throw new ArgumentException($"Processor not registered or is 16-bit only: {processorName}", nameof(processorName));
} }
public string GetProcessorDisplayName(string processorName)
{
if (_processorRegistry.TryGetValue(processorName, out var p))
return string.IsNullOrWhiteSpace(p.Name) ? processorName : p.Name;
if (_processorRegistry16.TryGetValue(processorName, out var p16))
return string.IsNullOrWhiteSpace(p16.Name) ? processorName : p16.Name;
return processorName;
}
public async Task<BitmapSource> ProcessImageAsync( public async Task<BitmapSource> ProcessImageAsync(
BitmapSource source, BitmapSource source,
string processorName, string processorName,
@@ -11,12 +11,20 @@ using XplorePlane.Services;
namespace XplorePlane.ViewModels namespace XplorePlane.ViewModels
{ {
/// <summary>算子列表项:持有注册 key 和本地化显示名</summary>
public class ProcessorItem
{
public string Key { get; }
public string DisplayName { get; }
public ProcessorItem(string key, string displayName) { Key = key; DisplayName = displayName; }
public override string ToString() => DisplayName;
}
public class ImageProcessingViewModel : BindableBase public class ImageProcessingViewModel : BindableBase
{ {
private readonly IImageProcessingService _imageProcessingService; private readonly IImageProcessingService _imageProcessingService;
private readonly ILogger _logger; private readonly ILogger _logger;
private string _selectedProcessor; private ProcessorItem _selectedProcessorItem;
private BitmapSource _currentImage; private BitmapSource _currentImage;
private BitmapSource _originalImage; private BitmapSource _originalImage;
private double _processingProgress; private double _processingProgress;
@@ -28,14 +36,12 @@ namespace XplorePlane.ViewModels
_imageProcessingService = imageProcessingService; _imageProcessingService = imageProcessingService;
_logger = logger; _logger = logger;
AvailableProcessors = new ObservableCollection<string>(); AvailableProcessors = new ObservableCollection<ProcessorItem>();
CurrentParameters = new ObservableCollection<ProcessorParameterVM>(); CurrentParameters = new ObservableCollection<ProcessorParameterVM>();
// Populate available processors foreach (var key in _imageProcessingService.GetAvailableProcessors())
foreach (var name in _imageProcessingService.GetAvailableProcessors()) AvailableProcessors.Add(new ProcessorItem(key, _imageProcessingService.GetProcessorDisplayName(key)));
AvailableProcessors.Add(name);
// Initialize commands (stubs - implemented in tasks 7.2, 7.4, 7.7)
SelectProcessorCommand = new DelegateCommand<string>(OnSelectProcessor); SelectProcessorCommand = new DelegateCommand<string>(OnSelectProcessor);
ApplyProcessingCommand = new DelegateCommand(OnApplyProcessing); ApplyProcessingCommand = new DelegateCommand(OnApplyProcessing);
ResetImageCommand = new DelegateCommand(OnResetImage); ResetImageCommand = new DelegateCommand(OnResetImage);
@@ -43,15 +49,22 @@ namespace XplorePlane.ViewModels
SaveResultCommand = new DelegateCommand(OnSaveResult, () => CurrentImage != null); SaveResultCommand = new DelegateCommand(OnSaveResult, () => CurrentImage != null);
} }
public ObservableCollection<string> AvailableProcessors { get; } public ObservableCollection<ProcessorItem> AvailableProcessors { get; }
public ObservableCollection<ProcessorParameterVM> CurrentParameters { get; } public ObservableCollection<ProcessorParameterVM> CurrentParameters { get; }
public string SelectedProcessor public ProcessorItem SelectedProcessorItem
{ {
get => _selectedProcessor; get => _selectedProcessorItem;
set => SetProperty(ref _selectedProcessor, value); set
{
SetProperty(ref _selectedProcessorItem, value);
if (value != null) OnSelectProcessor(value.Key);
}
} }
// Keep SelectedProcessor as the key string for service calls
public string SelectedProcessor => _selectedProcessorItem?.Key;
public BitmapSource CurrentImage public BitmapSource CurrentImage
{ {
get => _currentImage; get => _currentImage;
@@ -84,9 +84,9 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="160" MinWidth="140" MaxWidth="200" /> <ColumnDefinition Width="160" MinWidth="140" MaxWidth="200" />
<ColumnDefinition Width="5" /> <ColumnDefinition Width="5" />
<ColumnDefinition Width="*" MinWidth="400" /> <ColumnDefinition Width="*" MinWidth="300" />
<ColumnDefinition Width="5" /> <ColumnDefinition Width="5" />
<ColumnDefinition Width="300" MinWidth="260" MaxWidth="380" /> <ColumnDefinition Width="320" MinWidth="280" MaxWidth="420" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- ── 左侧操作栏 ── --> <!-- ── 左侧操作栏 ── -->
@@ -148,7 +148,9 @@
<!-- ── 右侧:算子选择 + 参数配置 ── --> <!-- ── 右侧:算子选择 + 参数配置 ── -->
<Border Grid.Column="4" Style="{StaticResource PanelBorderStyle}" Margin="0,0,0,0"> <Border Grid.Column="4" Style="{StaticResource PanelBorderStyle}" Margin="0,0,0,0">
<ScrollViewer VerticalScrollBarVisibility="Auto" VerticalAlignment="Top"> <ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
VerticalAlignment="Top">
<StackPanel Margin="10,8,10,10"> <StackPanel Margin="10,8,10,10">
<GroupBox Header="选择算子" Margin="0,0,0,8"> <GroupBox Header="选择算子" Margin="0,0,0,8">
@@ -159,7 +161,7 @@
FontFamily="{StaticResource CsdFont}" FontFamily="{StaticResource CsdFont}"
FontSize="12" FontSize="12"
ItemsSource="{Binding AvailableProcessors}" ItemsSource="{Binding AvailableProcessors}"
SelectedItem="{Binding SelectedProcessor}" SelectedItem="{Binding SelectedProcessorItem}"
SelectionChanged="OnProcessorComboChanged" /> SelectionChanged="OnProcessorComboChanged" />
</GroupBox> </GroupBox>
@@ -4,7 +4,6 @@ using System.Windows.Controls;
using Prism.Ioc; using Prism.Ioc;
using XplorePlane.Services; using XplorePlane.Services;
using XplorePlane.ViewModels; using XplorePlane.ViewModels;
namespace XplorePlane.Views namespace XplorePlane.Views
{ {
public partial class ImageProcessingPanelView : UserControl public partial class ImageProcessingPanelView : UserControl
@@ -27,12 +26,12 @@ namespace XplorePlane.Views
private void OnProcessorComboChanged(object sender, SelectionChangedEventArgs e) private void OnProcessorComboChanged(object sender, SelectionChangedEventArgs e)
{ {
if (sender is ComboBox cmb && cmb.SelectedItem is string processorName if (sender is ComboBox cmb && cmb.SelectedItem is ProcessorItem item
&& _imageProcessingService != null) && _imageProcessingService != null)
{ {
try try
{ {
var processor = _imageProcessingService.GetProcessor(processorName); var processor = _imageProcessingService.GetProcessor(item.Key);
parameterControl.LoadProcessor(processor); parameterControl.LoadProcessor(processor);
} }
catch (ArgumentException) catch (ArgumentException)
+2 -2
View File
@@ -3,8 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:XplorePlane.Views" xmlns:views="clr-namespace:XplorePlane.Views"
Title="图像处理" Title="图像处理"
Width="1000" Height="700" Width="1200" Height="750"
MinWidth="800" MinHeight="500" MinWidth="900" MinHeight="550"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
ShowInTaskbar="False"> ShowInTaskbar="False">
<views:ImageProcessingPanelView /> <views:ImageProcessingPanelView />
+6
View File
@@ -174,6 +174,12 @@
<None Include="Libs\ImageProcessing\ExternalLibraries\*.dll"> <None Include="Libs\ImageProcessing\ExternalLibraries\*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<!-- 图像处理中文卫星程序集 -->
<None Include="Libs\ImageProcessing\zh-CN\*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>zh-CN\%(Filename)%(Extension)</Link>
</None>
<!-- 配置文件 --> <!-- 配置文件 -->
<None Update="App.config"> <None Update="App.config">
+3 -1
View File
@@ -12,4 +12,6 @@
2026.3.14 2026.3.14
---------------------- ----------------------
1、主页面的布局与拆分 √ 1、主页面的布局与拆分 √
2、硬件层射线源的集成 √
3、图像层集成,包括复刻一个示例界面,优化界面布局及算子中文 √