first commit
This commit is contained in:
20
DCIT.App/Presentation/IUserDialogService.cs
Normal file
20
DCIT.App/Presentation/IUserDialogService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using DCIT.Core.Models;
|
||||
|
||||
namespace DCIT.App.Presentation
|
||||
{
|
||||
public interface IUserDialogService
|
||||
{
|
||||
DialogResult ShowMessage(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);
|
||||
|
||||
AutoExtractPreviewResult ShowAutoExtractPreview(IWin32Window owner, IList<ExtractionCandidate> candidates);
|
||||
}
|
||||
|
||||
public sealed class AutoExtractPreviewResult
|
||||
{
|
||||
public DialogResult DialogResult { get; set; }
|
||||
|
||||
public IList<ExtractionCandidate> SelectedCandidates { get; set; } = new List<ExtractionCandidate>();
|
||||
}
|
||||
}
|
||||
33
DCIT.App/Presentation/ModernFolderPicker.cs
Normal file
33
DCIT.App/Presentation/ModernFolderPicker.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DCIT.App.Presentation
|
||||
{
|
||||
internal static class ModernFolderPicker
|
||||
{
|
||||
public static bool TrySelectFolder(IWin32Window owner, string initialDirectory, out string selectedPath)
|
||||
{
|
||||
selectedPath = null;
|
||||
using (var dialog = new OpenFileDialog())
|
||||
{
|
||||
dialog.ValidateNames = false;
|
||||
dialog.CheckFileExists = false;
|
||||
dialog.CheckPathExists = true;
|
||||
dialog.FileName = "选择当前文件夹";
|
||||
dialog.Filter = "文件夹|*.folder";
|
||||
if (!string.IsNullOrWhiteSpace(initialDirectory) && Directory.Exists(initialDirectory))
|
||||
{
|
||||
dialog.InitialDirectory = initialDirectory;
|
||||
}
|
||||
|
||||
if (dialog.ShowDialog(owner) != DialogResult.OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
selectedPath = Path.GetDirectoryName(dialog.FileName);
|
||||
return !string.IsNullOrWhiteSpace(selectedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
DCIT.App/Presentation/UserDialogService.cs
Normal file
31
DCIT.App/Presentation/UserDialogService.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using DCIT.App.Forms;
|
||||
using DCIT.Core.Models;
|
||||
|
||||
namespace DCIT.App.Presentation
|
||||
{
|
||||
public sealed class UserDialogService : IUserDialogService
|
||||
{
|
||||
public DialogResult ShowMessage(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
||||
{
|
||||
return MessageBox.Show(owner, text, caption, buttons, icon);
|
||||
}
|
||||
|
||||
public AutoExtractPreviewResult ShowAutoExtractPreview(IWin32Window owner, IList<ExtractionCandidate> candidates)
|
||||
{
|
||||
using (var preview = new AutoExtractPreviewForm(candidates))
|
||||
{
|
||||
var dialogResult = preview.ShowDialog(owner);
|
||||
return new AutoExtractPreviewResult
|
||||
{
|
||||
DialogResult = dialogResult,
|
||||
SelectedCandidates = preview.SelectedCandidates == null
|
||||
? new List<ExtractionCandidate>()
|
||||
: preview.SelectedCandidates.ToList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user