Fix exception when moving skin under or below a folder

This commit is contained in:
MattN-L
2024-03-30 13:31:52 -04:00
parent 1cadb432ee
commit 6c2047f6c0
2 changed files with 19 additions and 12 deletions

View File

@@ -49,7 +49,7 @@ namespace PckStudio.IO.TGA
extensionData.JobTime = new TimeSpan(extensionData.TimeStamp.Hour, extensionData.TimeStamp.Minute, extensionData.TimeStamp.Second);
extensionData.SoftwareID = Application.ProductName;
Version.TryParse(Application.ProductVersion, out Version currentVersion);
extensionData.SoftwareVersion = [(byte)currentVersion.Major, (byte)currentVersion.Minor, (byte)currentVersion.Build];
extensionData.SoftwareVersion = new byte[] { (byte)currentVersion.Major, (byte)currentVersion.Minor, (byte)currentVersion.Build };
extensionData.KeyColor = 0;
extensionData.PixelAspectRatio = 0;
extensionData.GammaValue = 0;

View File

@@ -2276,21 +2276,28 @@ namespace PckStudio
int index = pck.IndexOfFile(file);
if (index + amount < 0 || index + amount > pck.FileCount) return;
pck.RemoveFile(file);
pck.InsertFile(index + amount, file);
try
{
if (index + amount < 0 || index + amount > pck.FileCount) return;
pck.RemoveFile(file);
pck.InsertFile(index + amount, file);
if (IsSubPCK)
{
using (var stream = new MemoryStream())
if (IsSubPCK)
{
var writer = new PckFileWriter(pck, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
writer.WriteToStream(stream);
(GetSubPCK(path).Tag as PckFileData).SetData(stream.ToArray());
using (var stream = new MemoryStream())
{
var writer = new PckFileWriter(pck, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
writer.WriteToStream(stream);
(GetSubPCK(path).Tag as PckFileData).SetData(stream.ToArray());
}
}
BuildMainTreeView();
wasModified = true;
}
BuildMainTreeView();
wasModified = true;
catch(Exception ex)
{
MessageBox.Show("Can't move file under or above a folder");
}
}
[Obsolete]
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) => moveFile(-1);