using OpenCvSharp;
using OpenCvSharp.WpfExtensions;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using TeamAAS_VP.Core;
using TeamAAS_VP.Enums;
using TeamAAS_VP.Models;
namespace TeamAAS_VP.Controls
{
///
/// FocusAnalyzer用户控件ViewModel
///
public class FocusAnalyzerViewModel : BindableBase
{
#region 可绑定属性
// 图像源
private ImageSource _currentImage;
public ImageSource CurrentImage
{
get => _currentImage;
set => SetProperty(ref _currentImage, value);
}
// 分析参数
private AnalysisParameters _parameters = new AnalysisParameters();
public AnalysisParameters Parameters
{
get => _parameters;
set => SetProperty(ref _parameters, value);
}
// 当前结果
private AnalysisResult _currentResult = new AnalysisResult();
public AnalysisResult CurrentResult
{
get => _currentResult;
set => SetProperty(ref _currentResult, value);
}
// 最终报告
private AnalysisReport _finalReport = new AnalysisReport();
public AnalysisReport FinalReport
{
get => _finalReport;
set => SetProperty(ref _finalReport, value);
}
// 分析状态
private bool _isAnalyzing;
public bool IsAnalyzing
{
get => _isAnalyzing;
set => SetProperty(ref _isAnalyzing, value);
}
// ROI区域
private RotatedRect _currentRoi;
public RotatedRect CurrentRoi
{
get => _currentRoi;
set => SetProperty(ref _currentRoi, value);
}
// 是否显示ROI
private bool _showRoi = true;
public bool ShowRoi
{
get => _showRoi;
set => SetProperty(ref _showRoi, value);
}
// ROI操作模式
private RoiOperationMode _roiMode = RoiOperationMode.Draw;
public RoiOperationMode RoiMode
{
get => _roiMode;
set => SetProperty(ref _roiMode, value);
}
// 图表模型
private PlotModel _plotModel;
public PlotModel PlotModel
{
get => _plotModel;
set => SetProperty(ref _plotModel, value);
}
// 状态文本
private string _statusText = "就绪";
public string StatusText
{
get => _statusText;
set => SetProperty(ref _statusText, value);
}
// 帧数文本
private string _frameCountText = "帧数: 0";
public string FrameCountText
{
get => _frameCountText;
set => SetProperty(ref _frameCountText, value);
}
// 最佳清晰度文本
private string _bestSharpnessText = "最佳: 0.00";
public string BestSharpnessText
{
get => _bestSharpnessText;
set => SetProperty(ref _bestSharpnessText, value);
}
// 枚举列表
public Array FocusMethods => Enum.GetValues(typeof(FocusMethod));
public Array AnalysisModes => Enum.GetValues(typeof(AnalysisMode));
#endregion
#region 命令
// 控制命令(绑定到外部)
public ICommand StartAnalysisCommand { get; set; }
public ICommand StopAnalysisCommand { get; set; }
public ICommand ResetCommand { get; set; }
public ICommand ExportCommand { get; set; }
// 内部命令
public DelegateCommand