Compare commits

..

No commits in common. "3c4e1c735ab08ee4a4db5a597b1d7b3a2ed1a31a" and "a8ecd88fd3a86ebccc4c17342e09ce3241b23123" have entirely different histories.

8 changed files with 191 additions and 196 deletions

View File

@ -126,6 +126,16 @@ namespace BookmarkManager {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap file {
get {
object obj = ResourceManager.GetObject("file", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
@ -156,6 +166,16 @@ namespace BookmarkManager {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap help_circle {
get {
object obj = ResourceManager.GetObject("help_circle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
@ -176,6 +196,36 @@ namespace BookmarkManager {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap save {
get {
object obj = ResourceManager.GetObject("save", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap search {
get {
object obj = ResourceManager.GetObject("search", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap settings {
get {
object obj = ResourceManager.GetObject("settings", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View File

@ -139,6 +139,9 @@
<data name="bookmark" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="bookmark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\bookmark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\bookmark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="file" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="file_text" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="file_text" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\file-text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\file-text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
@ -148,12 +151,24 @@
<data name="folder_explore" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="folder_explore" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\folder_explore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\folder_explore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="help_circle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="hexagon" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="hexagon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\hexagon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\hexagon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="icon_64" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="icon_64" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\icon-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\icon-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="save" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="search" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="trash" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="trash" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\trash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\trash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

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.0249</Version> <Version>0.6.0.1042</Version>
<PackageId>bukkubuddy</PackageId> <PackageId>bukkubuddy</PackageId>
<RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis> <RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
@ -120,8 +120,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.61" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
<PackageReference Include="RyzStudio" Version="8.1.2.366" /> <PackageReference Include="RyzStudio" Version="8.1.2.324" />
<PackageReference Include="RyzStudio.Windows.Forms" Version="8.1.3.689" /> <PackageReference Include="RyzStudio.Windows.Forms" Version="8.1.3.632" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,7 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using BookmarkManager.Services; using BookmarkManager.Services;
using bzit.bomg.Models; using bzit.bomg.Models;
@ -55,19 +54,11 @@ namespace FizzyLauncher
try try
{ {
if (model.Icon != null)
{
if (model.Icon.Width > 16)
{
model.Icon = RyzStudio.Drawing.ImageEditor.Resize(model.Icon, 16, 16);
}
}
pictureBox1.Image = model.Icon; pictureBox1.Image = model.Icon;
} }
catch (Exception) catch (Exception)
{ {
pictureBox1.Image = model.Icon = null; // do nothing
} }
memoBox1.Text = model.Notes?.Trim() ?? string.Empty; memoBox1.Text = model.Notes?.Trim() ?? string.Empty;
@ -209,7 +200,6 @@ namespace FizzyLauncher
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox1.TabIndex = 201; pictureBox1.TabIndex = 201;
pictureBox1.TabStop = false; pictureBox1.TabStop = false;
pictureBox1.MouseClick += pictureBox1_MouseClick;
pictureBox1.MouseDoubleClick += pictureBox1_MouseDoubleClick; pictureBox1.MouseDoubleClick += pictureBox1_MouseDoubleClick;
// //
// textBox3 // textBox3
@ -353,30 +343,7 @@ namespace FizzyLauncher
private async void textBox2_OnButtonClick(object sender, EventArgs e) private async void textBox2_OnButtonClick(object sender, EventArgs e)
{ {
await InvalidateWebPage(textBox2.Text, true, true, true); if (string.IsNullOrWhiteSpace(textBox2.Text))
textBox2.Focus();
}
private async void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
await InvalidateWebPage(textBox2.Text, false, false, true);
}
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
pictureBox1.Image = null;
}
}
private async Task InvalidateWebPage(string url, bool updateTitle, bool updateDescription, bool updateIcon)
{
if (string.IsNullOrWhiteSpace(url))
{ {
return; return;
} }
@ -388,48 +355,59 @@ namespace FizzyLauncher
this.IsBusy = true; this.IsBusy = true;
if (!url.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !url.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)) if (!textBox2.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !textBox2.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
{ {
url = "http://" + url; textBox2.Text = "http://" + textBox2.Text;
} }
var document = await _webProvider.RetrieveHtmlDocument(url); var document = await _webProvider.RetrieveHtmlDocument(textBox2.Text);
if (document == null) if (document == null)
{ {
this.IsBusy = false; this.IsBusy = false;
return; return;
} }
if (updateTitle)
{
textBox1.Text = _webProvider.ParseTitle(document); textBox1.Text = _webProvider.ParseTitle(document);
}
if (updateDescription)
{
textBox3.Text = _webProvider.ParseMetaDescription(document); textBox3.Text = _webProvider.ParseMetaDescription(document);
}
if (updateIcon)
{
try
{
pictureBox1.Image = await _webProvider.RetrieveImage(document); pictureBox1.Image = await _webProvider.RetrieveImage(document);
if (pictureBox1.Image != null)
{
if (pictureBox1.Image.Width > 16)
{
pictureBox1.Image = RyzStudio.Drawing.ImageEditor.Resize(pictureBox1.Image, 16, 16);
}
}
}
catch (Exception)
{
pictureBox1.Image = null;
}
}
this.IsBusy = false; 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;
}
} }
} }

34
MainForm.Designer.cs generated
View File

@ -120,7 +120,7 @@ namespace FizzyLauncher
// //
// newToolStripMenuItem // newToolStripMenuItem
// //
newToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; newToolStripMenuItem.Image = BookmarkManager.AppResource.file;
newToolStripMenuItem.Name = "newToolStripMenuItem"; newToolStripMenuItem.Name = "newToolStripMenuItem";
newToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N; newToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N;
newToolStripMenuItem.Size = new System.Drawing.Size(146, 22); newToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@ -129,7 +129,7 @@ namespace FizzyLauncher
// //
// openToolStripMenuItem // openToolStripMenuItem
// //
openToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; openToolStripMenuItem.Image = BookmarkManager.AppResource.folder;
openToolStripMenuItem.Name = "openToolStripMenuItem"; openToolStripMenuItem.Name = "openToolStripMenuItem";
openToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O; openToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O;
openToolStripMenuItem.Size = new System.Drawing.Size(146, 22); openToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@ -155,7 +155,7 @@ namespace FizzyLauncher
// //
// saveToolStripMenuItem // saveToolStripMenuItem
// //
saveToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; saveToolStripMenuItem.Image = BookmarkManager.AppResource.save;
saveToolStripMenuItem.Name = "saveToolStripMenuItem"; saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S; saveToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S;
saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22); saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@ -190,10 +190,10 @@ namespace FizzyLauncher
// //
// findToolStripMenuItem // findToolStripMenuItem
// //
findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; findToolStripMenuItem.Image = BookmarkManager.AppResource.search;
findToolStripMenuItem.Name = "findToolStripMenuItem"; findToolStripMenuItem.Name = "findToolStripMenuItem";
findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F; findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F;
findToolStripMenuItem.Size = new System.Drawing.Size(180, 22); findToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
findToolStripMenuItem.Text = "&Find"; findToolStripMenuItem.Text = "&Find";
findToolStripMenuItem.Click += findToolStripMenuItem_Click; findToolStripMenuItem.Click += findToolStripMenuItem_Click;
// //
@ -207,26 +207,26 @@ namespace FizzyLauncher
// expandAllToolStripMenuItem // expandAllToolStripMenuItem
// //
expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem";
expandAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); expandAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
expandAllToolStripMenuItem.Text = "&Expand All"; expandAllToolStripMenuItem.Text = "&Expand All";
expandAllToolStripMenuItem.Click += expandAllToolStripMenuItem_Click; expandAllToolStripMenuItem.Click += expandAllToolStripMenuItem_Click;
// //
// collapseAllToolStripMenuItem // collapseAllToolStripMenuItem
// //
collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem";
collapseAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); collapseAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
collapseAllToolStripMenuItem.Text = "&Collapse All"; collapseAllToolStripMenuItem.Text = "&Collapse All";
collapseAllToolStripMenuItem.Click += collapseAllToolStripMenuItem_Click; collapseAllToolStripMenuItem.Click += collapseAllToolStripMenuItem_Click;
// //
// toolStripSeparator1 // toolStripSeparator1
// //
toolStripSeparator1.Name = "toolStripSeparator1"; toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new System.Drawing.Size(177, 6); toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
// //
// alwaysOnTopToolStripMenuItem // alwaysOnTopToolStripMenuItem
// //
alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem";
alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(180, 22); alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
alwaysOnTopToolStripMenuItem.Text = "Always On &Top"; alwaysOnTopToolStripMenuItem.Text = "Always On &Top";
alwaysOnTopToolStripMenuItem.Click += alwaysOnTopToolStripMenuItem_Click; alwaysOnTopToolStripMenuItem.Click += alwaysOnTopToolStripMenuItem_Click;
// //
@ -240,21 +240,21 @@ namespace FizzyLauncher
// toolStripMenuItem9 // toolStripMenuItem9
// //
toolStripMenuItem9.Name = "toolStripMenuItem9"; toolStripMenuItem9.Name = "toolStripMenuItem9";
toolStripMenuItem9.Size = new System.Drawing.Size(180, 22); toolStripMenuItem9.Size = new System.Drawing.Size(168, 22);
toolStripMenuItem9.Text = "Update &Icons"; toolStripMenuItem9.Text = "Update &Icons";
toolStripMenuItem9.Click += toolStripMenuItem9_Click; toolStripMenuItem9.Click += toolStripMenuItem9_Click;
// //
// toolStripSeparator2 // toolStripSeparator2
// //
toolStripSeparator2.Name = "toolStripSeparator2"; toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new System.Drawing.Size(177, 6); toolStripSeparator2.Size = new System.Drawing.Size(165, 6);
// //
// optionsToolStripMenuItem // optionsToolStripMenuItem
// //
optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; optionsToolStripMenuItem.Image = BookmarkManager.AppResource.settings;
optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12; optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12;
optionsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); optionsToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
optionsToolStripMenuItem.Text = "&Options"; optionsToolStripMenuItem.Text = "&Options";
optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click; optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click;
// //
@ -267,22 +267,22 @@ namespace FizzyLauncher
// //
// viewHelpToolStripMenuItem1 // viewHelpToolStripMenuItem1
// //
viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; viewHelpToolStripMenuItem1.Image = BookmarkManager.AppResource.help_circle;
viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1"; viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1";
viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1;
viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(146, 22);
viewHelpToolStripMenuItem1.Text = "&View Help"; viewHelpToolStripMenuItem1.Text = "&View Help";
viewHelpToolStripMenuItem1.Click += viewHelpToolStripMenuItem1_Click; viewHelpToolStripMenuItem1.Click += viewHelpToolStripMenuItem1_Click;
// //
// toolStripMenuItem16 // toolStripMenuItem16
// //
toolStripMenuItem16.Name = "toolStripMenuItem16"; toolStripMenuItem16.Name = "toolStripMenuItem16";
toolStripMenuItem16.Size = new System.Drawing.Size(177, 6); toolStripMenuItem16.Size = new System.Drawing.Size(143, 6);
// //
// aboutToolStripMenuItem1 // aboutToolStripMenuItem1
// //
aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1"; aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1";
aboutToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); aboutToolStripMenuItem1.Size = new System.Drawing.Size(146, 22);
aboutToolStripMenuItem1.Text = "&About"; aboutToolStripMenuItem1.Text = "&About";
aboutToolStripMenuItem1.Click += aboutToolStripMenuItem1_Click; aboutToolStripMenuItem1.Click += aboutToolStripMenuItem1_Click;
// //

View File

@ -15,7 +15,6 @@ 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
{ {
@ -32,14 +31,6 @@ namespace FizzyLauncher
this.Text = Application.ProductName; 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 = new FileSessionManager();
_fileSessionManager.OpenFileDialog = openFileDialog1; _fileSessionManager.OpenFileDialog = openFileDialog1;
_fileSessionManager.SaveFileDialog = saveFileDialog1; _fileSessionManager.SaveFileDialog = saveFileDialog1;
@ -785,7 +776,7 @@ namespace FizzyLauncher
if (result.IsSuccess) if (result.IsSuccess)
{ {
// Add icons to save file // Add icons to save file
var result2 = AddImagesToZipFile(filename, nodeList); var result2 = AddImagesToZipFile(filename, this.CurrentSession.Items);
if (!result2.IsSuccess) if (!result2.IsSuccess)
{ {
if (showNotices) if (showNotices)
@ -979,7 +970,7 @@ namespace FizzyLauncher
}); });
} }
private GenericResult AddImagesToZipFile(string zipFilename, List<KeyValuePair<TreeNode, BookmarkModel>> items) private GenericResult AddImagesToZipFile(string zipFilename, List<BookmarkModel> items)
{ {
if (string.IsNullOrWhiteSpace(zipFilename)) if (string.IsNullOrWhiteSpace(zipFilename))
{ {
@ -1007,38 +998,14 @@ namespace FizzyLauncher
{ {
foreach (var item in items) foreach (var item in items)
{ {
var key = "icon\\" + item.Value.Id.ToString() + ".png"; var key = "icon\\" + item.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.Key.ImageIndex == (int)NodeIcon.Default) if (item.Icon == null)
{
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 (icon.Width <= 0)
{
continue;
}
}
catch (Exception)
{ {
continue; continue;
} }
@ -1049,7 +1016,7 @@ namespace FizzyLauncher
{ {
using (Stream entryStream = zipEntry.Open()) using (Stream entryStream = zipEntry.Open())
{ {
using (Image image = icon) using (Image image = item.Icon)
{ {
image.Save(entryStream, ImageFormat.Png); image.Save(entryStream, ImageFormat.Png);
} }
@ -1057,8 +1024,6 @@ namespace FizzyLauncher
} }
catch (Exception) catch (Exception)
{ {
zipEntry.Delete();
continue; continue;
} }
} }

View File

@ -356,25 +356,14 @@ namespace FizzyLauncher
break; break;
} }
var newModel = item.Value;
try
{
var image = await _webProvider.RetrieveImage(document); var image = await _webProvider.RetrieveImage(document);
if (image != null) if (image == null)
{ {
if (image.Width > 16) continue;
{
image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16);
}
} }
var newModel = item.Value;
newModel.Icon = image; newModel.Icon = image;
}
catch (Exception)
{
newModel.Icon = null;
}
_treeView.UpdateNode(item.Key, newModel); _treeView.UpdateNode(item.Key, newModel);
} }

View File

@ -1,7 +1,5 @@
using System; using System.ComponentModel;
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;
@ -127,8 +125,6 @@ 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;
} }
} }
@ -247,8 +243,6 @@ namespace RyzStudio.Windows.Forms
this.EditNode(treeNode); this.EditNode(treeNode);
} }
this.HasChanged = true;
return treeNode; return treeNode;
} }
@ -278,8 +272,6 @@ namespace RyzStudio.Windows.Forms
this.SelectedNode = newNode; this.SelectedNode = newNode;
this.HasChanged = true;
return newNode; return newNode;
} }
} }
@ -290,11 +282,29 @@ 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
var n = AddImage(model.Id.ToString(), model.Icon); if (model.Icon != null)
{
var iconKey = model.Id.ToString();
if (!string.IsNullOrWhiteSpace(iconKey))
{
if (this.ImageList.Images.ContainsKey(iconKey))
{
this.ImageList.Images.RemoveByKey(iconKey);
}
TreeNode newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, n, n); 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);
newNode.Tag = model; newNode.Tag = model;
newNode.ToolTipText = model.ToString(); newNode.ToolTipText = model.ToString();
@ -394,6 +404,10 @@ namespace RyzStudio.Windows.Forms
if (node == null) if (node == null)
{ {
node = this.SelectedNode; node = this.SelectedNode;
}
if (node == null)
{
return; return;
} }
@ -402,18 +416,36 @@ namespace RyzStudio.Windows.Forms
return; return;
} }
if (model.Id == Guid.Empty) var iconIndex = (int)NodeIcon.Default;
{
return;
}
// Update custom favicon // Update custom favicon
var n = AddImage(model.Id.ToString(), model.Icon); var iconKey = model.Id.ToString();
if (!string.IsNullOrWhiteSpace(iconKey))
{
UIControl.Invoke(this, (x) =>
{
if (this.ImageList.Images.ContainsKey(iconKey))
{
this.ImageList.Images.RemoveByKey(iconKey);
}
});
if (model.Icon != null)
{
UIControl.Invoke(this, (x) =>
{
this.ImageList.Images.Add(iconKey, model.Icon);
});
iconIndex = this.ImageList.Images.IndexOfKey(iconKey);
}
}
UIControl.Invoke(this, (x) => UIControl.Invoke(this, (x) =>
{ {
node.Text = model.Title; node.Text = model.Title;
node.ImageIndex = node.SelectedImageIndex = n; node.ImageIndex = iconIndex;
node.SelectedImageIndex = iconIndex;
node.Tag = model; node.Tag = model;
node.ToolTipText = model.ToString(); node.ToolTipText = model.ToString();
}); });
@ -430,43 +462,9 @@ namespace RyzStudio.Windows.Forms
this.ImageList.Images.Add(Resources.hexagon); this.ImageList.Images.Add(Resources.hexagon);
this.ImageList.Images.Add(Resources.folder); this.ImageList.Images.Add(Resources.folder);
this.ImageList.Images.Add(Resources.folder_explore); this.ImageList.Images.Add(Resources.folder_explore);
this.ImageList.Images.Add("default", Resources.file_text); this.ImageList.Images.Add(Resources.file_text);
}); });
} }
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);
}
} }
} }