修复流程图编辑器界面及初步的功能
This commit is contained in:
@@ -60,6 +60,7 @@ namespace XplorePlane.ViewModels
|
||||
SaveAsPipelineCommand = new DelegateCommand(async () => await SaveAsPipelineAsync());
|
||||
DeletePipelineCommand = new DelegateCommand(async () => await DeletePipelineAsync());
|
||||
LoadPipelineCommand = new DelegateCommand(async () => await LoadPipelineAsync());
|
||||
LoadImageCommand = new DelegateCommand(LoadImage);
|
||||
OpenToolboxCommand = new DelegateCommand(OpenToolbox);
|
||||
MoveNodeUpCommand = new DelegateCommand<PipelineNodeViewModel>(MoveNodeUp);
|
||||
MoveNodeDownCommand = new DelegateCommand<PipelineNodeViewModel>(MoveNodeDown);
|
||||
@@ -88,6 +89,7 @@ namespace XplorePlane.ViewModels
|
||||
if (SetProperty(ref _sourceImage, value))
|
||||
{
|
||||
ExecutePipelineCommand.RaiseCanExecuteChanged();
|
||||
RaisePropertyChanged(nameof(DisplayImage));
|
||||
TriggerDebouncedExecution();
|
||||
}
|
||||
}
|
||||
@@ -96,9 +98,15 @@ namespace XplorePlane.ViewModels
|
||||
public BitmapSource PreviewImage
|
||||
{
|
||||
get => _previewImage;
|
||||
set => SetProperty(ref _previewImage, value);
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _previewImage, value))
|
||||
RaisePropertyChanged(nameof(DisplayImage));
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapSource DisplayImage => PreviewImage ?? SourceImage;
|
||||
|
||||
public string PipelineName
|
||||
{
|
||||
get => _pipelineName;
|
||||
@@ -142,6 +150,7 @@ namespace XplorePlane.ViewModels
|
||||
public DelegateCommand SaveAsPipelineCommand { get; }
|
||||
public DelegateCommand DeletePipelineCommand { get; }
|
||||
public DelegateCommand LoadPipelineCommand { get; }
|
||||
public DelegateCommand LoadImageCommand { get; }
|
||||
|
||||
public DelegateCommand OpenToolboxCommand { get; }
|
||||
|
||||
@@ -316,6 +325,45 @@ namespace XplorePlane.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadImage()
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Title = "加载图像",
|
||||
Filter = "图像文件|*.bmp;*.png;*.jpg;*.jpeg;*.tif;*.tiff|所有文件|*.*"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() != true)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
LoadImageFromFile(dialog.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusMessage = $"加载图像失败:{ex.Message}";
|
||||
_logger.Error(ex, "加载图像失败:{Path}", dialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
internal void LoadImageFromFile(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
throw new ArgumentException("图像路径不能为空", nameof(filePath));
|
||||
|
||||
var bitmap = new BitmapImage();
|
||||
bitmap.BeginInit();
|
||||
bitmap.UriSource = new Uri(filePath, UriKind.Absolute);
|
||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmap.EndInit();
|
||||
bitmap.Freeze();
|
||||
|
||||
SourceImage = bitmap;
|
||||
PreviewImage = bitmap;
|
||||
StatusMessage = $"已加载图像:{Path.GetFileName(filePath)}";
|
||||
}
|
||||
|
||||
private void CancelExecution()
|
||||
{
|
||||
_executionCts?.Cancel();
|
||||
|
||||
Reference in New Issue
Block a user