release/0.6.1 #4

Merged
Ray merged 3 commits from release/0.6.1 into master 2024-08-04 15:03:09 +00:00
3 changed files with 72 additions and 49 deletions
Showing only changes of commit b17ba5665b - Show all commits

View File

@ -14,7 +14,7 @@
<Copyright>Ray Lam</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>0.6.1.0244</Version>
<Version>0.6.1.0249</Version>
<PackageId>bukkubuddy</PackageId>
<RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>

View File

@ -15,6 +15,7 @@ using FizzyLauncher.Models;
using RyzStudio;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
using static RyzStudio.Windows.Forms.BookmarkTreeView;
namespace FizzyLauncher
{
@ -784,7 +785,7 @@ namespace FizzyLauncher
if (result.IsSuccess)
{
// Add icons to save file
var result2 = AddImagesToZipFile(filename, this.CurrentSession.Items);
var result2 = AddImagesToZipFile(filename, nodeList);
if (!result2.IsSuccess)
{
if (showNotices)
@ -978,7 +979,7 @@ namespace FizzyLauncher
});
}
private GenericResult AddImagesToZipFile(string zipFilename, List<BookmarkModel> items)
private GenericResult AddImagesToZipFile(string zipFilename, List<KeyValuePair<TreeNode, BookmarkModel>> items)
{
if (string.IsNullOrWhiteSpace(zipFilename))
{
@ -1006,26 +1007,38 @@ namespace FizzyLauncher
{
foreach (var item in items)
{
var key = "icon\\" + item.Id.ToString() + ".png";
var key = "icon\\" + item.Value.Id.ToString() + ".png";
var zipEntry = archive.GetEntry(key);
if (zipEntry != null)
{
zipEntry.Delete();
}
if (item.Icon == null)
if (item.Key.ImageIndex == (int)NodeIcon.Default)
{
continue;
}
if (!treeView1.ImageList.Images.ContainsKey(item.Value.Id.ToString()))
{
continue;
}
var icon = treeView1.ImageList.Images[item.Value.Id.ToString()];
if (icon == null)
{
continue;
}
try
{
if (item.Icon.Width <= 0)
if (icon.Width <= 0)
{
continue;
}
}
catch
catch (Exception)
{
continue;
}
@ -1036,7 +1049,7 @@ namespace FizzyLauncher
{
using (Stream entryStream = zipEntry.Open())
{
using (Image image = item.Icon)
using (Image image = icon)
{
image.Save(entryStream, ImageFormat.Png);
}

View File

@ -1,5 +1,7 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using bzit.bomg.Models;
using FizzyLauncher;
@ -125,6 +127,8 @@ namespace RyzStudio.Windows.Forms
if (MessageBox.Show("Delete?", "Delete?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.DeleteNode();
this.HasChanged = true;
}
}
@ -243,6 +247,8 @@ namespace RyzStudio.Windows.Forms
this.EditNode(treeNode);
}
this.HasChanged = true;
return treeNode;
}
@ -272,6 +278,8 @@ namespace RyzStudio.Windows.Forms
this.SelectedNode = newNode;
this.HasChanged = true;
return newNode;
}
}
@ -282,29 +290,11 @@ namespace RyzStudio.Windows.Forms
public TreeNode AddNode(BookmarkModel model)
{
var parentNode = this.CreateNodePath(model?.Path?.Trim() ?? string.Empty, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2);
int iconIndex = (int)NodeIcon.Default;
// Add custom favicon
if (model.Icon != null)
{
var iconKey = model.Id.ToString();
if (!string.IsNullOrWhiteSpace(iconKey))
{
if (this.ImageList.Images.ContainsKey(iconKey))
{
this.ImageList.Images.RemoveByKey(iconKey);
}
var n = AddImage(model.Id.ToString(), model.Icon);
UIControl.Invoke(this, (x) =>
{
this.ImageList.Images.Add(iconKey, model.Icon);
});
iconIndex = this.ImageList.Images.IndexOfKey(iconKey);
}
}
TreeNode newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, iconIndex, iconIndex);
TreeNode newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, n, n);
newNode.Tag = model;
newNode.ToolTipText = model.ToString();
@ -404,10 +394,6 @@ namespace RyzStudio.Windows.Forms
if (node == null)
{
node = this.SelectedNode;
}
if (node == null)
{
return;
}
@ -416,28 +402,18 @@ namespace RyzStudio.Windows.Forms
return;
}
var iconKey = "default";
if (model.Id == Guid.Empty)
{
return;
}
// Update custom favicon
var key = model.Id.ToString();
if (!string.IsNullOrWhiteSpace(key))
{
if (model.Icon != null)
{
UIControl.Invoke(this, (x) =>
{
this.ImageList.Images.Add(key, model.Icon);
});
iconKey = key;
}
}
var n = AddImage(model.Id.ToString(), model.Icon);
UIControl.Invoke(this, (x) =>
{
node.Text = model.Title;
node.ImageKey = iconKey;
node.SelectedImageKey = iconKey;
node.ImageIndex = node.SelectedImageIndex = n;
node.Tag = model;
node.ToolTipText = model.ToString();
});
@ -458,5 +434,39 @@ namespace RyzStudio.Windows.Forms
});
}
private int AddImage(string key, Image image)
{
if (image == null)
{
return (int)NodeIcon.Default;
}
try
{
if (image.Width <= 0)
{
return (int)NodeIcon.Default;
}
}
catch (Exception)
{
return (int)NodeIcon.Default;
}
UIControl.Invoke(this, (x) =>
{
if (this.ImageList.Images.ContainsKey(key))
{
var n = this.ImageList.Images.IndexOfKey(key);
this.ImageList.Images.SetKeyName(n, ".deleted");
}
this.ImageList.Images.Add(key, image);
});
return this.ImageList.Images.IndexOfKey(key);
}
}
}