diff --git a/XplorePlane/App.xaml.cs b/XplorePlane/App.xaml.cs index 07dfcb3..a15cf4d 100644 --- a/XplorePlane/App.xaml.cs +++ b/XplorePlane/App.xaml.cs @@ -1,5 +1,7 @@ using System; +using System.Globalization; using System.IO; +using System.Threading; using System.Windows; using XplorePlane.Views; using XplorePlane.ViewModels; @@ -21,6 +23,13 @@ namespace XplorePlane { 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 日志系统 ConfigureLogging(); diff --git a/XplorePlane/Libs/ImageProcessing/ImageROIControl.dll b/XplorePlane/Libs/ImageProcessing/ImageROIControl.dll new file mode 100644 index 0000000..b25bcf4 Binary files /dev/null and b/XplorePlane/Libs/ImageProcessing/ImageROIControl.dll differ diff --git a/XplorePlane/Libs/ImageProcessing/zh-CN/ImageProcessing.Controls.resources.dll b/XplorePlane/Libs/ImageProcessing/zh-CN/ImageProcessing.Controls.resources.dll new file mode 100644 index 0000000..e240299 Binary files /dev/null and b/XplorePlane/Libs/ImageProcessing/zh-CN/ImageProcessing.Controls.resources.dll differ diff --git a/XplorePlane/Libs/ImageProcessing/zh-CN/ImageProcessing.Processors.resources.dll b/XplorePlane/Libs/ImageProcessing/zh-CN/ImageProcessing.Processors.resources.dll new file mode 100644 index 0000000..be92f77 Binary files /dev/null and b/XplorePlane/Libs/ImageProcessing/zh-CN/ImageProcessing.Processors.resources.dll differ diff --git a/XplorePlane/Services/IImageProcessingService.cs b/XplorePlane/Services/IImageProcessingService.cs index 45b4692..365c775 100644 --- a/XplorePlane/Services/IImageProcessingService.cs +++ b/XplorePlane/Services/IImageProcessingService.cs @@ -12,6 +12,7 @@ namespace XplorePlane.Services IReadOnlyList GetAvailableProcessors(); IReadOnlyList GetProcessorParameters(string processorName); ImageProcessorBase GetProcessor(string processorName); + string GetProcessorDisplayName(string processorName); void RegisterProcessor(string name, ImageProcessorBase processor); Task ProcessImageAsync( diff --git a/XplorePlane/Services/ImageProcessingService.cs b/XplorePlane/Services/ImageProcessingService.cs index 87b0e77..c7f2799 100644 --- a/XplorePlane/Services/ImageProcessingService.cs +++ b/XplorePlane/Services/ImageProcessingService.cs @@ -78,6 +78,15 @@ namespace XplorePlane.Services 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 ProcessImageAsync( BitmapSource source, string processorName, diff --git a/XplorePlane/ViewModels/ImageProcessingViewModel.cs b/XplorePlane/ViewModels/ImageProcessingViewModel.cs index d1b1028..1a4078d 100644 --- a/XplorePlane/ViewModels/ImageProcessingViewModel.cs +++ b/XplorePlane/ViewModels/ImageProcessingViewModel.cs @@ -11,12 +11,20 @@ using XplorePlane.Services; namespace XplorePlane.ViewModels { + /// 算子列表项:持有注册 key 和本地化显示名 + 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 { private readonly IImageProcessingService _imageProcessingService; private readonly ILogger _logger; - private string _selectedProcessor; + private ProcessorItem _selectedProcessorItem; private BitmapSource _currentImage; private BitmapSource _originalImage; private double _processingProgress; @@ -28,14 +36,12 @@ namespace XplorePlane.ViewModels _imageProcessingService = imageProcessingService; _logger = logger; - AvailableProcessors = new ObservableCollection(); + AvailableProcessors = new ObservableCollection(); CurrentParameters = new ObservableCollection(); - // Populate available processors - foreach (var name in _imageProcessingService.GetAvailableProcessors()) - AvailableProcessors.Add(name); + foreach (var key in _imageProcessingService.GetAvailableProcessors()) + AvailableProcessors.Add(new ProcessorItem(key, _imageProcessingService.GetProcessorDisplayName(key))); - // Initialize commands (stubs - implemented in tasks 7.2, 7.4, 7.7) SelectProcessorCommand = new DelegateCommand(OnSelectProcessor); ApplyProcessingCommand = new DelegateCommand(OnApplyProcessing); ResetImageCommand = new DelegateCommand(OnResetImage); @@ -43,15 +49,22 @@ namespace XplorePlane.ViewModels SaveResultCommand = new DelegateCommand(OnSaveResult, () => CurrentImage != null); } - public ObservableCollection AvailableProcessors { get; } + public ObservableCollection AvailableProcessors { get; } public ObservableCollection CurrentParameters { get; } - public string SelectedProcessor + public ProcessorItem SelectedProcessorItem { - get => _selectedProcessor; - set => SetProperty(ref _selectedProcessor, value); + get => _selectedProcessorItem; + 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 { get => _currentImage; diff --git a/XplorePlane/Views/ImageProcessingPanelView.xaml b/XplorePlane/Views/ImageProcessingPanelView.xaml index 48fec4e..f3ba1f8 100644 --- a/XplorePlane/Views/ImageProcessingPanelView.xaml +++ b/XplorePlane/Views/ImageProcessingPanelView.xaml @@ -84,9 +84,9 @@ - + - + @@ -148,7 +148,9 @@ - + @@ -159,7 +161,7 @@ FontFamily="{StaticResource CsdFont}" FontSize="12" ItemsSource="{Binding AvailableProcessors}" - SelectedItem="{Binding SelectedProcessor}" + SelectedItem="{Binding SelectedProcessorItem}" SelectionChanged="OnProcessorComboChanged" /> diff --git a/XplorePlane/Views/ImageProcessingPanelView.xaml.cs b/XplorePlane/Views/ImageProcessingPanelView.xaml.cs index 057f7a3..b2942eb 100644 --- a/XplorePlane/Views/ImageProcessingPanelView.xaml.cs +++ b/XplorePlane/Views/ImageProcessingPanelView.xaml.cs @@ -4,7 +4,6 @@ using System.Windows.Controls; using Prism.Ioc; using XplorePlane.Services; using XplorePlane.ViewModels; - namespace XplorePlane.Views { public partial class ImageProcessingPanelView : UserControl @@ -27,12 +26,12 @@ namespace XplorePlane.Views 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) { try { - var processor = _imageProcessingService.GetProcessor(processorName); + var processor = _imageProcessingService.GetProcessor(item.Key); parameterControl.LoadProcessor(processor); } catch (ArgumentException) diff --git a/XplorePlane/Views/ImageProcessingWindow.xaml b/XplorePlane/Views/ImageProcessingWindow.xaml index 4340ea2..5281dc0 100644 --- a/XplorePlane/Views/ImageProcessingWindow.xaml +++ b/XplorePlane/Views/ImageProcessingWindow.xaml @@ -3,8 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="clr-namespace:XplorePlane.Views" Title="图像处理" - Width="1000" Height="700" - MinWidth="800" MinHeight="500" + Width="1200" Height="750" + MinWidth="900" MinHeight="550" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"> diff --git a/XplorePlane/XplorePlane.csproj b/XplorePlane/XplorePlane.csproj index b1023d4..3e04bfc 100644 --- a/XplorePlane/XplorePlane.csproj +++ b/XplorePlane/XplorePlane.csproj @@ -174,6 +174,12 @@ PreserveNewest + + + + PreserveNewest + zh-CN\%(Filename)%(Extension) + diff --git a/XplorePlane/readme.txt b/XplorePlane/readme.txt index f366e2d..2cac0a9 100644 --- a/XplorePlane/readme.txt +++ b/XplorePlane/readme.txt @@ -12,4 +12,6 @@ 2026.3.14 ---------------------- -1、主页面的布局与拆分 √ \ No newline at end of file +1、主页面的布局与拆分 √ +2、硬件层射线源的集成 √ +3、图像层集成,包括复刻一个示例界面,优化界面布局及算子中文 √ \ No newline at end of file