增加文件夹查找
This commit is contained in:
@@ -333,12 +333,9 @@ namespace SpineViewer.Controls
|
|||||||
{
|
{
|
||||||
lock (Spines)
|
lock (Spines)
|
||||||
{
|
{
|
||||||
lock (Spines)
|
var spine = spines[index];
|
||||||
{
|
spines.RemoveAt(index);
|
||||||
var spine = spines[index];
|
spines.Add(spine);
|
||||||
spines.RemoveAt(index);
|
|
||||||
spines.Add(spine);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var item = listView.Items[index];
|
var item = listView.Items[index];
|
||||||
listView.Items.RemoveAt(index);
|
listView.Items.RemoveAt(index);
|
||||||
@@ -525,20 +522,38 @@ namespace SpineViewer.Controls
|
|||||||
|
|
||||||
private void AddFromFileDrop(string[] paths)
|
private void AddFromFileDrop(string[] paths)
|
||||||
{
|
{
|
||||||
var validPaths = paths.Where(
|
List<string> validPaths = [];
|
||||||
path => File.Exists(path) &&
|
foreach (var path in paths)
|
||||||
(Path.GetExtension(path).Equals(".skel", StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
Path.GetExtension(path).Equals(".json", StringComparison.OrdinalIgnoreCase))
|
|
||||||
).ToArray();
|
|
||||||
|
|
||||||
if (validPaths.Length > 1)
|
|
||||||
{
|
{
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
if (Spine.Spine.CommonSkelSuffix.Contains(Path.GetExtension(path).ToLower()))
|
||||||
|
validPaths.Add(path);
|
||||||
|
}
|
||||||
|
else if (Directory.Exists(path))
|
||||||
|
{
|
||||||
|
// 遍历该目录下所有深度文件,判断是否符合要求并ADD
|
||||||
|
foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
if (Spine.Spine.CommonSkelSuffix.Contains(Path.GetExtension(file).ToLower()))
|
||||||
|
validPaths.Add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validPaths.Count > 1)
|
||||||
|
{
|
||||||
|
if (validPaths.Count > 100)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show($"共发现 {validPaths.Count} 个可加载骨骼,数量较大,是否一次性全部加载?", "操作确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
|
||||||
|
return;
|
||||||
|
}
|
||||||
var progressDialog = new Dialogs.ProgressDialog();
|
var progressDialog = new Dialogs.ProgressDialog();
|
||||||
progressDialog.DoWork += BatchAdd_Work;
|
progressDialog.DoWork += BatchAdd_Work;
|
||||||
progressDialog.RunWorkerAsync(new Dialogs.BatchOpenSpineDialogResult(Spine.Version.Auto, validPaths));
|
progressDialog.RunWorkerAsync(new Dialogs.BatchOpenSpineDialogResult(Spine.Version.Auto, validPaths.ToArray()));
|
||||||
progressDialog.ShowDialog();
|
progressDialog.ShowDialog();
|
||||||
}
|
}
|
||||||
else if (validPaths.Length > 0)
|
else if (validPaths.Count > 0)
|
||||||
{
|
{
|
||||||
Insert(new Dialogs.OpenSpineDialogResult(Spine.Version.Auto, validPaths[0]));
|
Insert(new Dialogs.OpenSpineDialogResult(Spine.Version.Auto, validPaths[0]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using System.Reflection;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Collections.Immutable;
|
||||||
|
|
||||||
namespace SpineViewer.Spine
|
namespace SpineViewer.Spine
|
||||||
{
|
{
|
||||||
@@ -37,6 +38,11 @@ namespace SpineViewer.Spine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Spine : SFML.Graphics.Drawable, IDisposable
|
public abstract class Spine : SFML.Graphics.Drawable, IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 常规骨骼文件后缀集合
|
||||||
|
/// </summary>
|
||||||
|
public static readonly ImmutableHashSet<string> CommonSkelSuffix = [".skel", ".json"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 空动画标记
|
/// 空动画标记
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -211,6 +217,7 @@ namespace SpineViewer.Spine
|
|||||||
|
|
||||||
// 设置 Version
|
// 设置 Version
|
||||||
Version = attr.Version;
|
Version = attr.Version;
|
||||||
|
AssetsDir = Directory.GetParent(skelPath).FullName;
|
||||||
SkelPath = Path.GetFullPath(skelPath);
|
SkelPath = Path.GetFullPath(skelPath);
|
||||||
AtlasPath = Path.GetFullPath(atlasPath);
|
AtlasPath = Path.GetFullPath(atlasPath);
|
||||||
Name = Path.GetFileNameWithoutExtension(skelPath);
|
Name = Path.GetFileNameWithoutExtension(skelPath);
|
||||||
@@ -227,6 +234,12 @@ namespace SpineViewer.Spine
|
|||||||
[Category("基本信息"), DisplayName("运行时版本")]
|
[Category("基本信息"), DisplayName("运行时版本")]
|
||||||
public Version Version { get; }
|
public Version Version { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源所在完整目录
|
||||||
|
/// </summary>
|
||||||
|
[Category("基本信息"), DisplayName("资源目录")]
|
||||||
|
public string AssetsDir { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// skel 文件完整路径
|
/// skel 文件完整路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -239,6 +252,9 @@ namespace SpineViewer.Spine
|
|||||||
[Category("基本信息"), DisplayName("atlas文件路径")]
|
[Category("基本信息"), DisplayName("atlas文件路径")]
|
||||||
public string AtlasPath { get; }
|
public string AtlasPath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
[Category("基本信息"), DisplayName("名称")]
|
[Category("基本信息"), DisplayName("名称")]
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
@@ -397,5 +413,23 @@ namespace SpineViewer.Spine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public bool IsSelected { get; set; } = false;
|
public bool IsSelected { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示调试
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(false)]
|
||||||
|
public bool IsDebug { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示包围盒
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(false)]
|
||||||
|
public bool DebugBounds { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示骨骼
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(false)]
|
||||||
|
public bool DebugBones { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user