51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using Microsoft.Win32;
|
|
using System.Windows;
|
|
using XP.Common.GeneralForm.Views;
|
|
|
|
namespace XP.Camera.Calibration;
|
|
|
|
/// <summary>
|
|
/// 默认对话框服务实现,使用 HexMessageBox 自定义消息框。
|
|
/// 外部项目可直接使用,无需额外依赖。
|
|
/// </summary>
|
|
public class DefaultCalibrationDialogService : ICalibrationDialogService
|
|
{
|
|
public void ShowMessage(string message, string title)
|
|
{
|
|
HexMessageBox.Show(message, MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
|
|
public void ShowError(string message, string title)
|
|
{
|
|
HexMessageBox.Show(message, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
|
|
public void ShowInfo(string message, string title)
|
|
{
|
|
HexMessageBox.Show(message, MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
|
|
public bool ShowConfirm(string message, string title)
|
|
{
|
|
return HexMessageBox.Show(message, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
|
|
}
|
|
|
|
public string? ShowOpenFileDialog(string filter)
|
|
{
|
|
var dialog = new OpenFileDialog { Filter = filter };
|
|
return dialog.ShowDialog() == true ? dialog.FileName : null;
|
|
}
|
|
|
|
public string[]? ShowOpenMultipleFilesDialog(string filter)
|
|
{
|
|
var dialog = new OpenFileDialog { Filter = filter, Multiselect = true };
|
|
return dialog.ShowDialog() == true ? dialog.FileNames : null;
|
|
}
|
|
|
|
public string? ShowSaveFileDialog(string filter, string? defaultFileName = null)
|
|
{
|
|
var dialog = new SaveFileDialog { Filter = filter, FileName = defaultFileName ?? string.Empty };
|
|
return dialog.ShowDialog() == true ? dialog.FileName : null;
|
|
}
|
|
}
|