From 0a7bf62bff50d6d196e40940a75aa28a476a71f9 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 4 Aug 2024 02:47:25 +0100 Subject: [PATCH] Fixed save icon_64 Changed to scale icons Changed to ttf-icons for main menu --- AppResource.Designer.cs | 50 --------------------- AppResource.resx | 15 ------- BookmarkManager.csproj | 6 +-- EditBookmarkForm.cs | 96 ++++++++++++++++++++++------------------- MainForm.Designer.cs | 34 +++++++-------- MainForm.cs | 22 ++++++++++ UpdateIconsForm.cs | 27 +++++++++--- 7 files changed, 114 insertions(+), 136 deletions(-) diff --git a/AppResource.Designer.cs b/AppResource.Designer.cs index 38ef02f..7cb009e 100644 --- a/AppResource.Designer.cs +++ b/AppResource.Designer.cs @@ -126,16 +126,6 @@ namespace BookmarkManager { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap file { - get { - object obj = ResourceManager.GetObject("file", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -166,16 +156,6 @@ namespace BookmarkManager { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap help_circle { - get { - object obj = ResourceManager.GetObject("help_circle", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -196,36 +176,6 @@ namespace BookmarkManager { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap save { - get { - object obj = ResourceManager.GetObject("save", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap search { - get { - object obj = ResourceManager.GetObject("search", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap settings { - get { - object obj = ResourceManager.GetObject("settings", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/AppResource.resx b/AppResource.resx index 1626454..6581710 100644 --- a/AppResource.resx +++ b/AppResource.resx @@ -139,9 +139,6 @@ Resources\bookmark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Resources\file-text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -151,24 +148,12 @@ Resources\folder_explore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Resources\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Resources\hexagon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Resources\icon-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Resources\save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Resources\trash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/BookmarkManager.csproj b/BookmarkManager.csproj index 4db039c..5fe18a2 100644 --- a/BookmarkManager.csproj +++ b/BookmarkManager.csproj @@ -14,7 +14,7 @@ Ray Lam 1.0.0.0 1.0.0.0 - 0.6.0.1042 + 0.6.1.0244 bukkubuddy True 8.0 @@ -120,8 +120,8 @@ - - + + \ No newline at end of file diff --git a/EditBookmarkForm.cs b/EditBookmarkForm.cs index f90c8c5..502ecab 100644 --- a/EditBookmarkForm.cs +++ b/EditBookmarkForm.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.Drawing; +using System.Threading.Tasks; using System.Windows.Forms; using BookmarkManager.Services; using bzit.bomg.Models; @@ -54,11 +55,16 @@ namespace FizzyLauncher try { + if (model.Icon.Width > 16) + { + model.Icon = RyzStudio.Drawing.ImageEditor.Resize(model.Icon, 16, 16); + } + pictureBox1.Image = model.Icon; } catch (Exception) { - // do nothing + pictureBox1.Image = model.Icon = null; } memoBox1.Text = model.Notes?.Trim() ?? string.Empty; @@ -343,7 +349,22 @@ namespace FizzyLauncher private async void textBox2_OnButtonClick(object sender, EventArgs e) { - if (string.IsNullOrWhiteSpace(textBox2.Text)) + await InvalidateWebPage(textBox2.Text, true, true, true); + + textBox2.Focus(); + } + + private async void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + await InvalidateWebPage(textBox2.Text, false, false, true); + } + } + + private async Task InvalidateWebPage(string url, bool updateTitle, bool updateDescription, bool updateIcon) + { + if (string.IsNullOrWhiteSpace(url)) { return; } @@ -355,59 +376,46 @@ namespace FizzyLauncher this.IsBusy = true; - if (!textBox2.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !textBox2.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)) + if (!url.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !url.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)) { - textBox2.Text = "http://" + textBox2.Text; + url = "http://" + url; } - var document = await _webProvider.RetrieveHtmlDocument(textBox2.Text); + var document = await _webProvider.RetrieveHtmlDocument(url); if (document == null) { this.IsBusy = false; return; } - textBox1.Text = _webProvider.ParseTitle(document); - textBox3.Text = _webProvider.ParseMetaDescription(document); - pictureBox1.Image = await _webProvider.RetrieveImage(document); + if (updateTitle) + { + textBox1.Text = _webProvider.ParseTitle(document); + } + + if (updateDescription) + { + textBox3.Text = _webProvider.ParseMetaDescription(document); + } + + if (updateIcon) + { + try + { + pictureBox1.Image = await _webProvider.RetrieveImage(document); + + if (pictureBox1.Image.Width > 16) + { + pictureBox1.Image = RyzStudio.Drawing.ImageEditor.Resize(pictureBox1.Image, 16, 16); + } + } + catch (Exception) + { + pictureBox1.Image = null; + } + } this.IsBusy = false; - - textBox2.Focus(); - } - - private async void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - if (string.IsNullOrWhiteSpace(textBox2.Text)) - { - return; - } - - if (this.IsBusy) - { - return; - } - - this.IsBusy = true; - - if (!textBox2.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !textBox2.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)) - { - textBox2.Text = "http://" + textBox2.Text; - } - - var document = await _webProvider.RetrieveHtmlDocument(textBox2.Text); - if (document == null) - { - this.IsBusy = false; - return; - } - - pictureBox1.Image = await _webProvider.RetrieveImage(document); - - this.IsBusy = false; - } } } diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index f0c2781..e98c264 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -120,7 +120,7 @@ namespace FizzyLauncher // // newToolStripMenuItem // - newToolStripMenuItem.Image = BookmarkManager.AppResource.file; + newToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; newToolStripMenuItem.Name = "newToolStripMenuItem"; newToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N; newToolStripMenuItem.Size = new System.Drawing.Size(146, 22); @@ -129,7 +129,7 @@ namespace FizzyLauncher // // openToolStripMenuItem // - openToolStripMenuItem.Image = BookmarkManager.AppResource.folder; + openToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; openToolStripMenuItem.Name = "openToolStripMenuItem"; openToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O; openToolStripMenuItem.Size = new System.Drawing.Size(146, 22); @@ -155,7 +155,7 @@ namespace FizzyLauncher // // saveToolStripMenuItem // - saveToolStripMenuItem.Image = BookmarkManager.AppResource.save; + saveToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; saveToolStripMenuItem.Name = "saveToolStripMenuItem"; saveToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S; saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22); @@ -190,10 +190,10 @@ namespace FizzyLauncher // // findToolStripMenuItem // - findToolStripMenuItem.Image = BookmarkManager.AppResource.search; + findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; findToolStripMenuItem.Name = "findToolStripMenuItem"; findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F; - findToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + findToolStripMenuItem.Size = new System.Drawing.Size(180, 22); findToolStripMenuItem.Text = "&Find"; findToolStripMenuItem.Click += findToolStripMenuItem_Click; // @@ -207,26 +207,26 @@ namespace FizzyLauncher // expandAllToolStripMenuItem // expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; - expandAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + expandAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); expandAllToolStripMenuItem.Text = "&Expand All"; expandAllToolStripMenuItem.Click += expandAllToolStripMenuItem_Click; // // collapseAllToolStripMenuItem // collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; - collapseAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + collapseAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); collapseAllToolStripMenuItem.Text = "&Collapse All"; collapseAllToolStripMenuItem.Click += collapseAllToolStripMenuItem_Click; // // toolStripSeparator1 // toolStripSeparator1.Name = "toolStripSeparator1"; - toolStripSeparator1.Size = new System.Drawing.Size(149, 6); + toolStripSeparator1.Size = new System.Drawing.Size(177, 6); // // alwaysOnTopToolStripMenuItem // alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; - alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(180, 22); alwaysOnTopToolStripMenuItem.Text = "Always On &Top"; alwaysOnTopToolStripMenuItem.Click += alwaysOnTopToolStripMenuItem_Click; // @@ -240,21 +240,21 @@ namespace FizzyLauncher // toolStripMenuItem9 // toolStripMenuItem9.Name = "toolStripMenuItem9"; - toolStripMenuItem9.Size = new System.Drawing.Size(168, 22); + toolStripMenuItem9.Size = new System.Drawing.Size(180, 22); toolStripMenuItem9.Text = "Update &Icons"; toolStripMenuItem9.Click += toolStripMenuItem9_Click; // // toolStripSeparator2 // toolStripSeparator2.Name = "toolStripSeparator2"; - toolStripSeparator2.Size = new System.Drawing.Size(165, 6); + toolStripSeparator2.Size = new System.Drawing.Size(177, 6); // // optionsToolStripMenuItem // - optionsToolStripMenuItem.Image = BookmarkManager.AppResource.settings; + optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12; - optionsToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + optionsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); optionsToolStripMenuItem.Text = "&Options"; optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click; // @@ -267,22 +267,22 @@ namespace FizzyLauncher // // viewHelpToolStripMenuItem1 // - viewHelpToolStripMenuItem1.Image = BookmarkManager.AppResource.help_circle; + viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1"; viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; - viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); + viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); viewHelpToolStripMenuItem1.Text = "&View Help"; viewHelpToolStripMenuItem1.Click += viewHelpToolStripMenuItem1_Click; // // toolStripMenuItem16 // toolStripMenuItem16.Name = "toolStripMenuItem16"; - toolStripMenuItem16.Size = new System.Drawing.Size(143, 6); + toolStripMenuItem16.Size = new System.Drawing.Size(177, 6); // // aboutToolStripMenuItem1 // aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1"; - aboutToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); + aboutToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); aboutToolStripMenuItem1.Text = "&About"; aboutToolStripMenuItem1.Click += aboutToolStripMenuItem1_Click; // diff --git a/MainForm.cs b/MainForm.cs index 88affdd..edbd077 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -31,6 +31,14 @@ namespace FizzyLauncher this.Text = Application.ProductName; + newToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("a", Color.Black, 2); + openToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("b", Color.Black, 2); + saveToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("c", Color.Black, 2); + findToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("d", Color.Black, 2); + optionsToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("i", Color.Black, 2); + viewHelpToolStripMenuItem1.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("j", Color.Black, 2); + //aboutToolStripMenuItem1.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("k", Color.Black, 2); + _fileSessionManager = new FileSessionManager(); _fileSessionManager.OpenFileDialog = openFileDialog1; _fileSessionManager.SaveFileDialog = saveFileDialog1; @@ -1010,6 +1018,18 @@ namespace FizzyLauncher continue; } + try + { + if (item.Icon.Width <= 0) + { + continue; + } + } + catch + { + continue; + } + zipEntry = archive.CreateEntry(key, CompressionLevel.SmallestSize); try @@ -1024,6 +1044,8 @@ namespace FizzyLauncher } catch (Exception) { + zipEntry.Delete(); + continue; } } diff --git a/UpdateIconsForm.cs b/UpdateIconsForm.cs index 8f5ca55..07489b6 100644 --- a/UpdateIconsForm.cs +++ b/UpdateIconsForm.cs @@ -356,14 +356,27 @@ namespace FizzyLauncher break; } - var image = await _webProvider.RetrieveImage(document); - if (image == null) - { - continue; - } - var newModel = item.Value; - newModel.Icon = image; + + try + { + var image = await _webProvider.RetrieveImage(document); + if (image == null) + { + continue; + } + + if (image.Width > 16) + { + image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16); + } + + newModel.Icon = image; + } + catch (Exception) + { + newModel.Icon = null; + } _treeView.UpdateNode(item.Key, newModel); }