Skip to content

Commit

Permalink
fix folder image size issue (back to allowing 228x204 on snes)
Browse files Browse the repository at this point in the history
  • Loading branch information
daPhie79 committed Apr 20, 2018
1 parent 0306102 commit bb721a4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
12 changes: 8 additions & 4 deletions Apps/NesMenuFolder.cs
Expand Up @@ -262,18 +262,20 @@ public override bool Save()
Directory.CreateDirectory(basePath);
getAdjustedDesktopFile().Save(Path.Combine(basePath, desktop.Code + ".desktop"), false, true);

var maxX = hakchi.IsSnes(ConfigIni.Instance.ConsoleType) ? 228 : 204;
var maxY = 204;
var sourcePath = getImagePath(ImageId);
if (sourcePath != null)
{
var smallSourcePath = sourcePath.Replace(".png", "_small.png");
if (!File.Exists(smallSourcePath))
smallSourcePath = sourcePath;
ProcessImageFile(sourcePath, iconPath, 204, 204, true, false, false);
ProcessImageFile(sourcePath, iconPath, maxX, maxY, true, false, false);
ProcessImageFile(smallSourcePath, smallIconPath, 40, 40, true, false, false);
}
else
{
ProcessImage(Image, iconPath, 204, 204, true, false, false);
ProcessImage(Image, iconPath, maxX, maxY, true, false, false);
ProcessImage(Image, smallIconPath, 40, 40, true, false, false);
}
return true;
Expand All @@ -293,22 +295,24 @@ public long CopyTo(string relativeTargetPath, HashSet<ApplicationFileInfo> local
var desktopStream = getAdjustedDesktopFile().SaveTo(new MemoryStream(), false, true);
localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}.desktop", DateTime.UtcNow, desktopStream));

var maxX = hakchi.IsSnes(ConfigIni.Instance.ConsoleType) ? 228 : 204;
var maxY = 204;
var sourcePath = getImagePath(ImageId);
Stream iconStream, smallIconStream;
if (sourcePath != null)
{
var smallSourcePath = sourcePath.Replace(".png", "_small.png");
if (!File.Exists(smallSourcePath))
smallSourcePath = sourcePath;
iconStream = ProcessImageFileToStream(sourcePath, 204, 204, true, false, false);
iconStream = ProcessImageFileToStream(sourcePath, maxX, maxY, true, false, false);
smallIconStream = ProcessImageFileToStream(smallSourcePath, 40, 40, true, false, false);

localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}.png", File.GetLastWriteTimeUtc(sourcePath), iconStream));
localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}_small.png", File.GetLastWriteTimeUtc(smallSourcePath), smallIconStream));
}
else
{
iconStream = ProcessImageToStream(Image, 204, 204, true, false, false);
iconStream = ProcessImageToStream(Image, maxX, maxY, true, false, false);
smallIconStream = ProcessImageToStream(Image, 40, 40, true, false, false);

localGameSet.Add(new ApplicationFileInfo($"./{targetDir}/{desktop.Code}.png", DateTime.UtcNow, iconStream));
Expand Down
7 changes: 4 additions & 3 deletions FoldersManagerForm.cs
Expand Up @@ -264,13 +264,14 @@ private void treeView_AfterSelect(object sender, TreeViewEventArgs e)

private void ShowSelected()
{
var maxX = (hakchi.IsSnes(ConfigIni.Instance.ConsoleType) ? 228 : 204);
var node = treeView.SelectedNode;
listViewContent.Clear();
if (node != null && (node.Nodes.Count > 0 || node.Tag is NesMenuFolder)) // Folder or root
{
pictureBoxArt.Image = (node.Tag is NesMenuFolder) ? (node.Tag as NesMenuFolder).Image : null;
pictureBoxArt.Width = 204;
pictureBoxArt.Left = pictureBoxLeft + 7;
pictureBoxArt.Width = maxX;
pictureBoxArt.Left = pictureBoxLeft + ((maxX - 204) / 2);
groupBoxArt.Enabled = (node.Tag is NesMenuFolder);
groupBoxSplitModes.Enabled = true;
pictureBoxArt.Cursor = Cursors.Hand;
Expand Down Expand Up @@ -304,7 +305,7 @@ private void ShowSelected()

if (pictureBoxArt.Image != null)
{
pictureBoxArt.SizeMode = (pictureBoxArt.Image.Width > 204 || pictureBoxArt.Image.Height > 204) ? PictureBoxSizeMode.Zoom : PictureBoxSizeMode.CenterImage;
pictureBoxArt.SizeMode = (pictureBoxArt.Image.Width > pictureBoxArt.Width || pictureBoxArt.Image.Height > 204) ? PictureBoxSizeMode.Zoom : PictureBoxSizeMode.CenterImage;
}

ShowFolderStats();
Expand Down
2 changes: 1 addition & 1 deletion SelectIconForm.cs
Expand Up @@ -82,7 +82,7 @@ private void listBox_SelectedIndexChanged(object sender, EventArgs e)
{
buttonOk.Enabled = true;
pictureBoxArt.Image = Image.FromFile((listBox.SelectedItem as IconItem).Path);
pictureBoxArt.SizeMode = (pictureBoxArt.Image.Width > 204 || pictureBoxArt.Image.Height > 204) ? PictureBoxSizeMode.Zoom : PictureBoxSizeMode.CenterImage;
pictureBoxArt.SizeMode = (pictureBoxArt.Image.Width > (hakchi.IsSnes(ConfigIni.Instance.ConsoleType) ? 228 : 204) || pictureBoxArt.Image.Height > 204) ? PictureBoxSizeMode.Zoom : PictureBoxSizeMode.CenterImage;
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions SelectIconForm.resx
Expand Up @@ -126,7 +126,7 @@
<value>12, 12</value>
</data>
<data name="listBox.Size" type="System.Drawing.Size, System.Drawing">
<value>300, 238</value>
<value>276, 238</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="listBox.TabIndex" type="System.Int32, mscorlib">
Expand Down Expand Up @@ -181,10 +181,10 @@
<value>NoControl</value>
</data>
<data name="pictureBoxArt.Location" type="System.Drawing.Point, System.Drawing">
<value>318, 12</value>
<value>294, 12</value>
</data>
<data name="pictureBoxArt.Size" type="System.Drawing.Size, System.Drawing">
<value>204, 204</value>
<value>228, 204</value>
</data>
<data name="pictureBoxArt.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>CenterImage</value>
Expand Down

0 comments on commit bb721a4

Please sign in to comment.