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> <Copyright>Ray Lam</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<Version>0.6.1.0244</Version> <Version>0.6.1.0249</Version>
<PackageId>bukkubuddy</PackageId> <PackageId>bukkubuddy</PackageId>
<RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis> <RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>

View File

@ -15,6 +15,7 @@ using FizzyLauncher.Models;
using RyzStudio; using RyzStudio;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using static RyzStudio.Windows.Forms.BookmarkTreeView;
namespace FizzyLauncher namespace FizzyLauncher
{ {
@ -784,7 +785,7 @@ namespace FizzyLauncher
if (result.IsSuccess) if (result.IsSuccess)
{ {
// Add icons to save file // Add icons to save file
var result2 = AddImagesToZipFile(filename, this.CurrentSession.Items); var result2 = AddImagesToZipFile(filename, nodeList);
if (!result2.IsSuccess) if (!result2.IsSuccess)
{ {
if (showNotices) 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)) if (string.IsNullOrWhiteSpace(zipFilename))
{ {
@ -1006,26 +1007,38 @@ namespace FizzyLauncher
{ {
foreach (var item in items) 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); var zipEntry = archive.GetEntry(key);
if (zipEntry != null) if (zipEntry != null)
{ {
zipEntry.Delete(); 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; continue;
} }
try try
{ {
if (item.Icon.Width <= 0) if (icon.Width <= 0)
{ {
continue; continue;
} }
} }
catch catch (Exception)
{ {
continue; continue;
} }
@ -1036,7 +1049,7 @@ namespace FizzyLauncher
{ {
using (Stream entryStream = zipEntry.Open()) using (Stream entryStream = zipEntry.Open())
{ {
using (Image image = item.Icon) using (Image image = icon)
{ {
image.Save(entryStream, ImageFormat.Png); image.Save(entryStream, ImageFormat.Png);
} }

View File

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