From be983f8407d1e8bf7f4c502df0273984c64bef61 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Mon, 6 Oct 2025 13:32:03 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpineViewer/App.xaml.cs | 76 +++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/SpineViewer/App.xaml.cs b/SpineViewer/App.xaml.cs index f190950..e3064ac 100644 --- a/SpineViewer/App.xaml.cs +++ b/SpineViewer/App.xaml.cs @@ -69,7 +69,7 @@ namespace SpineViewer _instanceMutex = new Mutex(true, MutexName, out var createdNew); if (!createdNew) { - SendCommandLineArgs(); + ConnectAndSendArgs(); Environment.Exit(0); // 不再启动新实例 return; } @@ -99,24 +99,27 @@ namespace SpineViewer LogManager.Configuration = config; } - private static void SendCommandLineArgs() + private static void ConnectAndSendArgs() { - var args = Environment.GetCommandLineArgs().Skip(1).ToArray(); - if (args.Length <= 0) - return; - - _logger.Info("Send command line args to existed instance, \"{0}\"", string.Join(", ", args)); try { // 已有实例在运行,把参数通过命名管道发过去 using (var client = new NamedPipeClientStream(".", PipeName, PipeDirection.Out)) { - client.Connect(10000); // 10 秒超时 - using (var writer = new StreamWriter(client)) + // 只要启动了实例就要进行连接, 10 秒超时 + client.Connect(10000); + + // 但是只有有参数的时候才发送参数 + var args = Environment.GetCommandLineArgs().Skip(1).ToArray(); + if (args.Length > 0) { - foreach (var v in args) + _logger.Info("Send command line args to existed instance, \"{0}\"", string.Join(", ", args)); + using (var writer = new StreamWriter(client)) { - writer.WriteLine(v); + foreach (var v in args) + { + writer.WriteLine(v); + } } } } @@ -132,6 +135,7 @@ namespace SpineViewer { var t = new Task(() => { + // 防止实例和窗口还没创建好 while (Current is null) Thread.Sleep(10); while (true) { @@ -144,44 +148,48 @@ namespace SpineViewer } while (true) { - using (var server = new NamedPipeServerStream(PipeName, PipeDirection.In)) + try { - server.WaitForConnection(); - using (var reader = new StreamReader(server)) + using (var server = new NamedPipeServerStream(PipeName, PipeDirection.In)) { - var args = new List(); - string? line; - while ((line = reader.ReadLine()) != null) - args.Add(line); + server.WaitForConnection(); - if (args.Count > 0) + // 只要收到连接就可以显示窗口了 + Current.Dispatcher.Invoke(() => { - try + var window = (MainWindow)Current.MainWindow; + window.Show(); + if (window.WindowState == WindowState.Minimized) + { + window.WindowState = WindowState.Normal; + } + window.Activate(); + }); + using (var reader = new StreamReader(server)) + { + var args = new List(); + string? line; + while ((line = reader.ReadLine()) != null) + args.Add(line); + + if (args.Count > 0) { Current.Dispatcher.Invoke(() => { - // 只要收到参数就可以显示窗口了 - var window = (MainWindow)Current.MainWindow; - window.Show(); - if (window.WindowState == WindowState.Minimized) - { - window.WindowState = WindowState.Normal; - } - window.Activate(); - // 尝试加载参数内容 + var window = (MainWindow)Current.MainWindow; var vm = (MainWindowViewModel)window.DataContext; vm.SpineObjectListViewModel.AddSpineObjectFromFileList(args); }); } - catch (Exception ex) - { - _logger.Trace(ex.ToString()); - _logger.Error("Failed to process arguments, {0}", ex.Message); - } } } } + catch (Exception ex) + { + _logger.Trace(ex.ToString()); + _logger.Error("Failed to process arguments, {0}", ex.Message); + } } }, default, TaskCreationOptions.LongRunning); t.Start(); From 7aa88089b8f28a67f2370b63f436b17c492dbe60 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Mon, 6 Oct 2025 14:02:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E5=B8=A7?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=8C=85=E5=9B=B4=E7=9B=92=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Spine/SpineExtension.cs | 44 ++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/Spine/SpineExtension.cs b/Spine/SpineExtension.cs index efecba4..9d04db8 100644 --- a/Spine/SpineExtension.cs +++ b/Spine/SpineExtension.cs @@ -110,20 +110,42 @@ namespace Spine break; } - for (int ii = 0; ii + 1 < verticesLength; ii += 2) + if (verticesLength > 0) { - float vx = vertices[ii]; - float vy = vertices[ii + 1]; - minX = Math.Min(minX, vx); - minY = Math.Min(minY, vy); - maxX = Math.Max(maxX, vx); - maxY = Math.Max(maxY, vy); + for (int ii = 0; ii + 1 < verticesLength; ii += 2) + { + float vx = vertices[ii]; + float vy = vertices[ii + 1]; + minX = Math.Min(minX, vx); + minY = Math.Min(minY, vy); + maxX = Math.Max(maxX, vx); + maxY = Math.Max(maxY, vy); + } + } + else + { + var boneX = slot.Bone.WorldX; + var boneY = slot.Bone.WorldY; + minX = Math.Min(minX, boneX); + minY = Math.Min(minY, boneY); + maxX = Math.Max(maxX, boneX); + maxY = Math.Max(maxY, boneY); } } - x = minX; - y = minY; - w = maxX - minX; - h = maxY - minY; + if (minX >= int.MaxValue || minY >= int.MaxValue || maxX <= int.MinValue || maxY <= int.MinValue) + { + x = self.X; + y = self.Y; + w = 0; + h = 0; + } + else + { + x = minX; + y = minY; + w = maxX - minX; + h = maxY - minY; + } } /// From 579ce9f944f3fe0fb91b5364fa7013187e6bd827 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Mon, 6 Oct 2025 14:03:03 +0800 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c3a39..f27ff94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## v0.16.7 + +- 修复空帧导致的包围盒计算错误 +- 修复重复启动程序无法唤出界面的问题 + ## v0.16.6 - 修复控件尺寸为0时导致的画面缩放错误 From f5684a50dcd6e272220a237537ebcee93195cc35 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Mon, 6 Oct 2025 14:03:19 +0800 Subject: [PATCH 4/4] update to v0.16.7 --- Spine/Spine.csproj | 2 +- SpineViewer/SpineViewer.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Spine/Spine.csproj b/Spine/Spine.csproj index 678abdd..1affb8e 100644 --- a/Spine/Spine.csproj +++ b/Spine/Spine.csproj @@ -7,7 +7,7 @@ net8.0-windows $(SolutionDir)out false - 0.16.6 + 0.16.7 diff --git a/SpineViewer/SpineViewer.csproj b/SpineViewer/SpineViewer.csproj index 7b4bfb7..f621c47 100644 --- a/SpineViewer/SpineViewer.csproj +++ b/SpineViewer/SpineViewer.csproj @@ -7,7 +7,7 @@ net8.0-windows $(SolutionDir)out false - 0.16.6 + 0.16.7 WinExe true