移除winforms引用
This commit is contained in:
@@ -1,18 +0,0 @@
|
|||||||
using SpineViewer.Views;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpineViewer.Services
|
|
||||||
{
|
|
||||||
public static class AboutDialogService
|
|
||||||
{
|
|
||||||
public static bool ShowAboutDialog()
|
|
||||||
{
|
|
||||||
var dialog = new AboutDialog() { Owner = App.Current.MainWindow };
|
|
||||||
return dialog.ShowDialog() ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using SpineViewer.Views;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpineViewer.Services
|
|
||||||
{
|
|
||||||
public static class DiagnosticsDialogService
|
|
||||||
{
|
|
||||||
public static bool ShowDiagnosticsDialog()
|
|
||||||
{
|
|
||||||
var dialog = new DiagnosticsDialog() { Owner = App.Current.MainWindow };
|
|
||||||
return dialog.ShowDialog() ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
85
SpineViewer/Services/DialogService.cs
Normal file
85
SpineViewer/Services/DialogService.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
|
using SpineViewer.ViewModels.Exporters;
|
||||||
|
using SpineViewer.Views;
|
||||||
|
using SpineViewer.Views.ExporterDialogs;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SpineViewer.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用于弹出各种对话框的服务
|
||||||
|
/// </summary>
|
||||||
|
public static class DialogService
|
||||||
|
{
|
||||||
|
public static bool ShowDiagnosticsDialog()
|
||||||
|
{
|
||||||
|
var dialog = new DiagnosticsDialog() { Owner = App.Current.MainWindow };
|
||||||
|
return dialog.ShowDialog() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ShowAboutDialog()
|
||||||
|
{
|
||||||
|
var dialog = new AboutDialog() { Owner = App.Current.MainWindow };
|
||||||
|
return dialog.ShowDialog() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ShowFrameExporterDialog(FrameExporterViewModel vm)
|
||||||
|
{
|
||||||
|
var dialog = new FrameExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
||||||
|
return dialog.ShowDialog() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ShowFrameSequenceExporterDialog(FrameSequenceExporterViewModel vm)
|
||||||
|
{
|
||||||
|
var dialog = new FrameSequenceExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
||||||
|
return dialog.ShowDialog() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ShowFFmpegVideoExporterDialog(FFmpegVideoExporterViewModel vm)
|
||||||
|
{
|
||||||
|
var dialog = new FFmpegVideoExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
||||||
|
return dialog.ShowDialog() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ShowCustomFFmpegExporterDialog(CustomFFmpegExporterViewModel vm)
|
||||||
|
{
|
||||||
|
var dialog = new CustomFFmpegExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
||||||
|
return dialog.ShowDialog() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户选择的文件夹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderName"></param>
|
||||||
|
/// <returns>是否确认了选择</returns>
|
||||||
|
public static bool ShowOpenFolderDialog(out string? folderName)
|
||||||
|
{
|
||||||
|
// XXX: 此处使用了 System.Windows.Forms 的文件夹浏览对话框
|
||||||
|
var folderDialog = new OpenFolderDialog() { Multiselect = false };
|
||||||
|
if (folderDialog.ShowDialog() is true)
|
||||||
|
{
|
||||||
|
folderName = folderDialog.FolderName;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
folderName = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户选择的文件夹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="selectedPath"></param>
|
||||||
|
/// <returns>是否确认了选择</returns>
|
||||||
|
public static bool ShowSaveFileDialog(out string? selectedPath)
|
||||||
|
{
|
||||||
|
var dialog = new SaveFileDialog() { };
|
||||||
|
selectedPath = null;
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
using SpineViewer.ViewModels.Exporters;
|
|
||||||
using SpineViewer.Views;
|
|
||||||
using SpineViewer.Views.ExporterDialogs;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpineViewer.Services
|
|
||||||
{
|
|
||||||
public static class ExporterDialogService
|
|
||||||
{
|
|
||||||
public static bool ShowFrameExporterDialog(FrameExporterViewModel vm)
|
|
||||||
{
|
|
||||||
var dialog = new FrameExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
|
||||||
return dialog.ShowDialog() ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ShowFrameSequenceExporterDialog(FrameSequenceExporterViewModel vm)
|
|
||||||
{
|
|
||||||
var dialog = new FrameSequenceExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
|
||||||
return dialog.ShowDialog() ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ShowFFmpegVideoExporterDialog(FFmpegVideoExporterViewModel vm)
|
|
||||||
{
|
|
||||||
var dialog = new FFmpegVideoExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
|
||||||
return dialog.ShowDialog() ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ShowCustomFFmpegExporterDialog(CustomFFmpegExporterViewModel vm)
|
|
||||||
{
|
|
||||||
var dialog = new CustomFFmpegExporterDialog() { DataContext = vm, Owner = App.Current.MainWindow };
|
|
||||||
return dialog.ShowDialog() ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpineViewer.Services
|
|
||||||
{
|
|
||||||
public static class OpenFolderService
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取用户选择的文件夹
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="selectedPath"></param>
|
|
||||||
/// <returns>是否确认了选择</returns>
|
|
||||||
public static bool OpenFolder(out string? selectedPath)
|
|
||||||
{
|
|
||||||
// XXX: 此处使用了 System.Windows.Forms 的文件夹浏览对话框
|
|
||||||
using var folderDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
||||||
if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
||||||
{
|
|
||||||
selectedPath = folderDialog.SelectedPath;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
selectedPath = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using Microsoft.Win32;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SpineViewer.Services
|
|
||||||
{
|
|
||||||
public static class SaveService
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取用户选择的文件夹
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="selectedPath"></param>
|
|
||||||
/// <returns>是否确认了选择</returns>
|
|
||||||
public static bool SaveFile(out string? selectedPath)
|
|
||||||
{
|
|
||||||
var dialog = new SaveFileDialog() { };
|
|
||||||
selectedPath = null;
|
|
||||||
// TODO
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
<Version>0.15.0</Version>
|
<Version>0.15.0</Version>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@@ -18,11 +17,6 @@
|
|||||||
<ApplicationIcon>appicon.ico</ApplicationIcon>
|
<ApplicationIcon>appicon.ico</ApplicationIcon>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Remove="System.Windows.Forms" />
|
|
||||||
<Using Remove="System.Drawing" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="appicon.ico" />
|
<Content Include="appicon.ico" />
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
|
||||||
namespace SpineViewer.ViewModels
|
namespace SpineViewer.ViewModels
|
||||||
{
|
{
|
||||||
public class DiagnosticsDialogViewModel : ObservableObject
|
public class DiagnosticsDialogViewModel : ObservableObject
|
||||||
@@ -31,7 +32,20 @@ namespace SpineViewer.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Memory => $"{new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory / 1024f / 1024f / 1024f:F1} GB";
|
public string Memory
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var searcher = new ManagementObjectSearcher("SELECT TotalPhysicalMemory FROM Win32_ComputerSystem");
|
||||||
|
foreach (ManagementObject obj in searcher.Get())
|
||||||
|
{
|
||||||
|
ulong bytes = (ulong)obj["TotalPhysicalMemory"];
|
||||||
|
float gb = bytes / 1024f / 1024f / 1024f;
|
||||||
|
return $"{gb:F1} GB";
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string WindowsVersion
|
public string WindowsVersion
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace SpineViewer.ViewModels.Exporters
|
|||||||
protected override void Export_Execute(IList? args)
|
protected override void Export_Execute(IList? args)
|
||||||
{
|
{
|
||||||
if (args is null || args.Count <= 0) return;
|
if (args is null || args.Count <= 0) return;
|
||||||
if (!ExporterDialogService.ShowCustomFFmpegExporterDialog(this)) return;
|
if (!DialogService.ShowCustomFFmpegExporterDialog(this)) return;
|
||||||
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject()).ToArray();
|
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject()).ToArray();
|
||||||
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_CustomFFmpegExporterTitle);
|
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_CustomFFmpegExporterTitle);
|
||||||
foreach (var sp in spines) sp.Dispose();
|
foreach (var sp in spines) sp.Dispose();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace SpineViewer.ViewModels.Exporters
|
|||||||
protected override void Export_Execute(IList? args)
|
protected override void Export_Execute(IList? args)
|
||||||
{
|
{
|
||||||
if (args is null || args.Count <= 0) return;
|
if (args is null || args.Count <= 0) return;
|
||||||
if (!ExporterDialogService.ShowFFmpegVideoExporterDialog(this)) return;
|
if (!DialogService.ShowFFmpegVideoExporterDialog(this)) return;
|
||||||
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject()).ToArray();
|
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject()).ToArray();
|
||||||
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_FFmpegVideoExporterTitle);
|
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_FFmpegVideoExporterTitle);
|
||||||
foreach (var sp in spines) sp.Dispose();
|
foreach (var sp in spines) sp.Dispose();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace SpineViewer.ViewModels.Exporters
|
|||||||
protected override void Export_Execute(IList? args)
|
protected override void Export_Execute(IList? args)
|
||||||
{
|
{
|
||||||
if (args is null || args.Count <= 0) return;
|
if (args is null || args.Count <= 0) return;
|
||||||
if (!ExporterDialogService.ShowFrameExporterDialog(this)) return;
|
if (!DialogService.ShowFrameExporterDialog(this)) return;
|
||||||
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject(true)).ToArray();
|
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject(true)).ToArray();
|
||||||
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_FrameExporterTitle);
|
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_FrameExporterTitle);
|
||||||
foreach (var sp in spines) sp.Dispose();
|
foreach (var sp in spines) sp.Dispose();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace SpineViewer.ViewModels.Exporters
|
|||||||
protected override void Export_Execute(IList? args)
|
protected override void Export_Execute(IList? args)
|
||||||
{
|
{
|
||||||
if (args is null || args.Count <= 0) return;
|
if (args is null || args.Count <= 0) return;
|
||||||
if (!ExporterDialogService.ShowFrameSequenceExporterDialog(this)) return;
|
if (!DialogService.ShowFrameSequenceExporterDialog(this)) return;
|
||||||
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject()).ToArray();
|
SpineObject[] spines = args.Cast<SpineObjectModel>().Select(m => m.GetSpineObject()).ToArray();
|
||||||
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_FrameSequenceExporterTitle);
|
ProgressService.RunAsync((pr, ct) => ExportTask(spines, pr, ct), AppResource.Str_FrameSequenceExporterTitle);
|
||||||
foreach (var sp in spines) sp.Dispose();
|
foreach (var sp in spines) sp.Dispose();
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand Cmd_ChangeCurrentDirectory => _cmd_ChangeCurrentDirectory ??= new(() =>
|
public RelayCommand Cmd_ChangeCurrentDirectory => _cmd_ChangeCurrentDirectory ??= new(() =>
|
||||||
{
|
{
|
||||||
if (OpenFolderService.OpenFolder(out var selectedPath))
|
if (DialogService.ShowOpenFolderDialog(out var selectedPath))
|
||||||
{
|
{
|
||||||
_currentDirectory = selectedPath;
|
_currentDirectory = selectedPath;
|
||||||
RefreshItems();
|
RefreshItems();
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示诊断信息对话框
|
/// 显示诊断信息对话框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand Cmd_ShowDiagnosticsDialog => _cmd_ShowDiagnosticsDialog ??= new(() => { DiagnosticsDialogService.ShowDiagnosticsDialog(); });
|
public RelayCommand Cmd_ShowDiagnosticsDialog => _cmd_ShowDiagnosticsDialog ??= new(() => { DialogService.ShowDiagnosticsDialog(); });
|
||||||
private RelayCommand? _cmd_ShowDiagnosticsDialog;
|
private RelayCommand? _cmd_ShowDiagnosticsDialog;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示关于对话框
|
/// 显示关于对话框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand Cmd_ShowAboutDialog => _cmd_ShowAboutDialog ??= new(() => { AboutDialogService.ShowAboutDialog(); });
|
public RelayCommand Cmd_ShowAboutDialog => _cmd_ShowAboutDialog ??= new(() => { DialogService.ShowAboutDialog(); });
|
||||||
private RelayCommand? _cmd_ShowAboutDialog;
|
private RelayCommand? _cmd_ShowAboutDialog;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (OpenFolderService.OpenFolder(out var selectedPath))
|
if (DialogService.ShowOpenFolderDialog(out var selectedPath))
|
||||||
{
|
{
|
||||||
var vm = (CustomFFmpegExporterViewModel)DataContext;
|
var vm = (CustomFFmpegExporterViewModel)DataContext;
|
||||||
vm.OutputDir = selectedPath;
|
vm.OutputDir = selectedPath;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (OpenFolderService.OpenFolder(out var selectedPath))
|
if (DialogService.ShowOpenFolderDialog(out var selectedPath))
|
||||||
{
|
{
|
||||||
var vm = (FFmpegVideoExporterViewModel)DataContext;
|
var vm = (FFmpegVideoExporterViewModel)DataContext;
|
||||||
vm.OutputDir = selectedPath;
|
vm.OutputDir = selectedPath;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (OpenFolderService.OpenFolder(out var selectedPath))
|
if (DialogService.ShowOpenFolderDialog(out var selectedPath))
|
||||||
{
|
{
|
||||||
var vm = (FrameExporterViewModel)DataContext;
|
var vm = (FrameExporterViewModel)DataContext;
|
||||||
vm.OutputDir = selectedPath;
|
vm.OutputDir = selectedPath;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
private void ButtonSelectOutputDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (OpenFolderService.OpenFolder(out var selectedPath))
|
if (DialogService.ShowOpenFolderDialog(out var selectedPath))
|
||||||
{
|
{
|
||||||
var vm = (FrameSequenceExporterViewModel)DataContext;
|
var vm = (FrameSequenceExporterViewModel)DataContext;
|
||||||
vm.OutputDir = selectedPath;
|
vm.OutputDir = selectedPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user