Compare commits

..

9 Commits

Author SHA1 Message Date
ww-rm
4b23c779d3 Merge pull request #124 from ww-rm/dev/wpf
v0.16.7
2025-10-06 14:04:13 +08:00
ww-rm
f5684a50dc update to v0.16.7 2025-10-06 14:03:19 +08:00
ww-rm
579ce9f944 update changelog 2025-10-06 14:03:03 +08:00
ww-rm
7aa88089b8 修复空帧导致的包围盒计算错误 2025-10-06 14:02:21 +08:00
ww-rm
be983f8407 修复窗口二次显示错误 2025-10-06 13:32:03 +08:00
ww-rm
249b930602 Merge pull request #122 from ww-rm/dev/wpf
v0.16.6
2025-10-04 20:55:59 +08:00
ww-rm
6472f378b7 update to v0.16.6 2025-10-04 20:53:29 +08:00
ww-rm
8672f0571c udpate changelog 2025-10-04 20:53:06 +08:00
ww-rm
e7a990c1bd 修复可能出现的0缩放错误 2025-10-04 20:50:08 +08:00
7 changed files with 89 additions and 50 deletions

View File

@@ -1,5 +1,14 @@
# CHANGELOG
## v0.16.7
- 修复空帧导致的包围盒计算错误
- 修复重复启动程序无法唤出界面的问题
## v0.16.6
- 修复控件尺寸为0时导致的画面缩放错误
## v0.16.5
- 修复对于无 size 行的旧 atlas 格式读取错误

View File

@@ -240,8 +240,8 @@ namespace SFMLRenderer
if (RenderWindow is null) return;
float parentW = (float)sizeInfo.NewSize.Width;
float parentH = (float)sizeInfo.NewSize.Height;
float renderW = (float)_hwndHost.ActualWidth;
float renderH = (float)_hwndHost.ActualHeight;
float renderW = _resolution.X;
float renderH = _resolution.Y;
float scale = Math.Min(parentW / renderW, parentH / renderH); // 两方向取较小值, 保证 parent 覆盖 render
renderW *= scale;
renderH *= scale;

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.0</Version>
<Version>0.16.6</Version>
<UseWPF>true</UseWPF>
</PropertyGroup>

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.5</Version>
<Version>0.16.7</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -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;
}
}
/// <summary>

View File

@@ -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>();
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>();
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();

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.5</Version>
<Version>0.16.7</Version>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
</PropertyGroup>