Compare commits

..

No commits in common. "master" and "release/0.6.0" have entirely different histories.

13 changed files with 332 additions and 879 deletions

View File

@ -1,312 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Forms;
using BookmarkManager.Services;
using bzit.bomg.Models;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
namespace FizzyLauncher
{
public class AddBatchPageForm : Form
{
private System.Windows.Forms.Label label1;
private readonly WebProvider _webProvider;
private string _rootPath;
private bool _isBusy = false;
private THorizontalSeparator tHorizontalSeparator3;
private ThButton button3;
private ThProgressBar progressBar2;
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
private ThToolbarMemoBox memoBox1;
private List<BookmarkModel> _result = new List<BookmarkModel>();
private bool _requestCancel = false;
public AddBatchPageForm(string rootPath)
{
InitializeComponent();
UISetup.Dialog(this);
_result = new List<BookmarkModel>();
_webProvider = new WebProvider();
_webProvider.IgnoreSSL = true;
_rootPath = rootPath;
}
private void InitializeComponent()
{
label1 = new Label();
tHorizontalSeparator3 = new THorizontalSeparator();
button3 = new ThButton();
progressBar2 = new ThProgressBar();
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
memoBox1 = new ThToolbarMemoBox();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.BackColor = System.Drawing.Color.Transparent;
label1.ForeColor = System.Drawing.SystemColors.ControlText;
label1.Location = new System.Drawing.Point(10, 20);
label1.Margin = new Padding(0);
label1.Name = "label1";
label1.Padding = new Padding(0, 8, 0, 0);
label1.Size = new System.Drawing.Size(185, 23);
label1.TabIndex = 153;
label1.Text = "Add pages (one URL on each line)";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tHorizontalSeparator3
//
tHorizontalSeparator3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
tHorizontalSeparator3.AutoScrollMargin = new System.Drawing.Size(0, 0);
tHorizontalSeparator3.AutoScrollMinSize = new System.Drawing.Size(0, 0);
tHorizontalSeparator3.BackColor = System.Drawing.Color.Transparent;
tHorizontalSeparator3.Location = new System.Drawing.Point(10, 321);
tHorizontalSeparator3.Margin = new Padding(0, 10, 0, 0);
tHorizontalSeparator3.MaximumSize = new System.Drawing.Size(4920, 2);
tHorizontalSeparator3.MinimumSize = new System.Drawing.Size(0, 22);
tHorizontalSeparator3.Name = "tHorizontalSeparator3";
tHorizontalSeparator3.Size = new System.Drawing.Size(424, 22);
tHorizontalSeparator3.TabIndex = 207;
tHorizontalSeparator3.TabStop = false;
//
// button3
//
button3.ActiveImage = null;
button3.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button3.BackColor = System.Drawing.Color.Transparent;
button3.EnableMenuOnClick = false;
button3.EnableReactiveVisual = true;
button3.HoverImage = null;
button3.IdleImage = null;
button3.LabelText = "&Add Pages";
button3.Location = new System.Drawing.Point(306, 393);
button3.Name = "button3";
button3.Size = new System.Drawing.Size(128, 32);
button3.TabIndex = 209;
button3.TabStop = false;
button3.MouseClick += button3_MouseClick;
//
// progressBar2
//
progressBar2.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
progressBar2.BackColor = System.Drawing.Color.Transparent;
progressBar2.BarColour = System.Drawing.Color.FromArgb(79, 193, 203);
progressBar2.BarTextColour = System.Drawing.Color.Black;
progressBar2.EnableReactiveVisual = false;
progressBar2.Font = new System.Drawing.Font("Segoe UI", 9F);
progressBar2.Location = new System.Drawing.Point(10, 353);
progressBar2.Maximum = 100;
progressBar2.Minimum = 0;
progressBar2.Name = "progressBar2";
progressBar2.ProgressText = "50/100";
progressBar2.ShowProgressText = true;
progressBar2.Size = new System.Drawing.Size(424, 20);
progressBar2.TabIndex = 210;
progressBar2.TabStop = false;
progressBar2.Value = 50;
//
// dialogFooter1
//
dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
dialogFooter1.Button1Text = "&Close";
dialogFooter1.Dialog = this;
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.IsBusy = false;
dialogFooter1.Location = new System.Drawing.Point(0, 437);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new System.Drawing.Size(444, 84);
//
// memoBox1
//
memoBox1.AllowDrop = true;
memoBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
memoBox1.BackColor = System.Drawing.Color.Transparent;
memoBox1.ClearedValue = "";
memoBox1.EnableReactiveVisual = true;
memoBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
memoBox1.Location = new System.Drawing.Point(10, 53);
memoBox1.Name = "memoBox1";
memoBox1.ReadOnly = false;
memoBox1.ScrollBars = ScrollBars.Vertical;
memoBox1.Size = new System.Drawing.Size(424, 258);
memoBox1.TabIndex = 211;
memoBox1.TabStop = false;
memoBox1.WordWrap = false;
//
// AddBatchPageForm
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = System.Drawing.Color.White;
ClientSize = new System.Drawing.Size(444, 521);
Controls.Add(memoBox1);
Controls.Add(dialogFooter1);
Controls.Add(progressBar2);
Controls.Add(button3);
Controls.Add(tHorizontalSeparator3);
Controls.Add(label1);
KeyPreview = true;
MinimumSize = new System.Drawing.Size(460, 560);
Name = "AddBatchPageForm";
Text = "Add Pages (Batch)";
ResumeLayout(false);
PerformLayout();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
memoBox1.Text = string.Empty;
progressBar2.Minimum = 0;
progressBar2.Value = 0;
progressBar2.Maximum = memoBox1.Lines?.Length ?? 0;
memoBox1.Focus();
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
if (this.IsBusy)
{
e.Cancel = true;
}
}
public List<BookmarkModel> Result
{
get => _result;
private set => _result = value;
}
protected bool IsBusy
{
get => _isBusy;
set
{
_isBusy = value;
UIControl.SetEnable(memoBox1, !this.IsBusy);
UIControl.Invoke(button3, (x) =>
{
button3.LabelText = (this.IsBusy ? "&Stop" : "&Add Pages");
});
dialogFooter1.IsBusy = _isBusy;
}
}
private async void button3_MouseClick(object sender, MouseEventArgs e)
{
await Task.Run(async () =>
{
if (this.IsBusy)
{
_requestCancel = true;
return;
}
this.IsBusy = true;
this.Result = new List<BookmarkModel>();
progressBar2.Minimum = 0;
progressBar2.Value = 0;
progressBar2.Maximum = memoBox1.Lines?.Length ?? 0;
foreach (var item in memoBox1.Lines ?? new string[0])
{
progressBar2.Value++;
if (string.IsNullOrWhiteSpace(item))
{
continue;
}
var newModel = new BookmarkModel();
newModel.Address = item;
newModel.Path = _rootPath;
if (_requestCancel)
{
break;
}
newModel = await UpdateBookmark(newModel, true, true);
if (newModel == null)
{
continue;
}
if (_requestCancel)
{
break;
}
this.Result.Add(newModel);
}
//_requestCancel = false;
this.IsBusy = false;
if (!_requestCancel)
{
this.DialogResult = DialogResult.OK;
UIControl.Close(this);
}
_requestCancel = false;
});
}
private async Task<BookmarkModel> UpdateBookmark(BookmarkModel model, bool updateTitle, bool updateDescription)
{
if (string.IsNullOrWhiteSpace(model.Address))
{
return null;
}
if (!model.Address.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !model.Address.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
{
model.Address = "http://" + model.Address;
}
var document = await _webProvider.RetrieveHtmlDocument(model.Address);
if (document == null)
{
return null;
}
if (updateTitle)
{
model.Title = _webProvider.ParseTitle(document);
}
if (updateDescription)
{
model.Description = _webProvider.ParseDescription(document);
}
return model;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

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>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </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>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </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>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -139,6 +139,9 @@
<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>
</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">
<value>Resources\file-text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -148,12 +151,24 @@
<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>
</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">
<value>Resources\hexagon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<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>
</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">
<value>Resources\trash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

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.2.092</Version>
<Version>0.6.0.972</Version>
<PackageId>bukkubuddy</PackageId>
<RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
@ -106,9 +106,6 @@
<AutoGen>True</AutoGen>
<DependentUpon>AppResource.resx</DependentUpon>
</Compile>
<Compile Update="AddBatchPageForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="UpdateIconsForm.cs" />
<Compile Update="FindForm.cs" />
<Compile Update="EditBookmarkForm.cs" />
@ -123,8 +120,8 @@
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
<PackageReference Include="RyzStudio" Version="8.1.2.366" />
<PackageReference Include="RyzStudio.Windows.Forms" Version="8.1.3.689" />
<PackageReference Include="RyzStudio" Version="8.1.2.249" />
<PackageReference Include="RyzStudio.Windows.Forms" Version="8.1.3.614" />
</ItemGroup>
</Project>

View File

@ -1,9 +1,7 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using BookmarkManager.Services;
using bzit.bomg.Models;
using RyzStudio.Windows.Forms;
@ -22,6 +20,7 @@ namespace FizzyLauncher
private Label label4;
private ThHiButtonTextBox textBox2;
private PictureBox pictureBox1;
private PictureBox pictureBox2;
private ToolTip toolTip1;
private System.ComponentModel.IContainer components;
private ThClearableTextBox textBox3;
@ -56,19 +55,11 @@ namespace FizzyLauncher
try
{
if (model.Icon != null)
{
if (model.Icon.Width > 16)
{
model.Icon = RyzStudio.Drawing.ImageEditor.Resize(model.Icon, 16, 16);
}
}
pictureBox1.Image = model.Icon;
}
catch (Exception)
{
pictureBox1.Image = model.Icon = null;
// do nothing
}
memoBox1.Text = model.Notes?.Trim() ?? string.Empty;
@ -77,7 +68,7 @@ namespace FizzyLauncher
private void InitializeComponent()
{
components = new Container();
components = new System.ComponentModel.Container();
label1 = new Label();
textBox1 = new ThClearableTextBox();
label2 = new Label();
@ -87,11 +78,13 @@ namespace FizzyLauncher
textBox2 = new ThHiButtonTextBox();
pictureBox1 = new PictureBox();
toolTip1 = new ToolTip(components);
pictureBox2 = new PictureBox();
textBox3 = new ThClearableTextBox();
thUserControl1 = new ThUserControl();
label5 = new Label();
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
((ISupportInitialize)pictureBox1).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
SuspendLayout();
//
// label1
@ -210,9 +203,21 @@ namespace FizzyLauncher
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox1.TabIndex = 201;
pictureBox1.TabStop = false;
pictureBox1.MouseClick += pictureBox1_MouseClick;
pictureBox1.MouseDoubleClick += pictureBox1_MouseDoubleClick;
//
// pictureBox2
//
pictureBox2.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
pictureBox2.BackColor = Color.Transparent;
pictureBox2.ErrorImage = null;
pictureBox2.InitialImage = null;
pictureBox2.Location = new Point(10, 396);
pictureBox2.Name = "pictureBox2";
pictureBox2.Size = new Size(32, 32);
pictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox2.TabIndex = 202;
pictureBox2.TabStop = false;
//
// textBox3
//
textBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -259,7 +264,6 @@ namespace FizzyLauncher
dialogFooter1.Button1Text = "&OK";
dialogFooter1.Dialog = this;
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.IsBusy = false;
dialogFooter1.Location = new Point(0, 437);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new Size(384, 84);
@ -272,6 +276,7 @@ namespace FizzyLauncher
ClientSize = new Size(384, 521);
Controls.Add(dialogFooter1);
Controls.Add(textBox3);
Controls.Add(pictureBox2);
Controls.Add(pictureBox1);
Controls.Add(textBox2);
Controls.Add(memoBox1);
@ -286,7 +291,8 @@ namespace FizzyLauncher
MinimumSize = new Size(400, 560);
Name = "EditBookmarkForm";
Text = "Edit Bookmark";
((ISupportInitialize)pictureBox1).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit();
ResumeLayout(false);
PerformLayout();
}
@ -346,7 +352,7 @@ namespace FizzyLauncher
UIControl.SetEnable(textBox1, !this.IsBusy);
UIControl.SetEnable(textBox2, !this.IsBusy);
UIControl.SetEnable(textBox3, !this.IsBusy);
dialogFooter1.IsBusy = _isBusy;
UIControl.SetValue(pictureBox2, (this.IsBusy ? RyzStudio.Windows.ThemedForms.Resource2.loading_block : null));
UIControl.SetEnable(memoBox1, !this.IsBusy);
}
}
@ -354,30 +360,7 @@ namespace FizzyLauncher
private async void textBox2_OnButtonClick(object sender, EventArgs e)
{
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 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))
if (string.IsNullOrWhiteSpace(textBox2.Text))
{
return;
}
@ -389,48 +372,59 @@ namespace FizzyLauncher
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)
{
this.IsBusy = false;
return;
}
if (updateTitle)
{
textBox1.Text = _webProvider.ParseTitle(document);
}
if (updateDescription)
{
textBox3.Text = _webProvider.ParseDescription(document);
}
if (updateIcon)
{
try
{
pictureBox1.Image = await _webProvider.RetrieveImage(url, 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;
}
}
textBox1.Text = _webProvider.ParseTitle(document);
textBox3.Text = _webProvider.ParseMetaDescription(document);
pictureBox1.Image = await _webProvider.RetrieveImage(document);
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;
}
}
}

72
MainForm.Designer.cs generated
View File

@ -71,7 +71,6 @@ namespace FizzyLauncher
sortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
folderContextMenu = new System.Windows.Forms.ContextMenuStrip(components);
addPageToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem10 = new System.Windows.Forms.ToolStripMenuItem();
addFolderToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
openAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -91,7 +90,6 @@ namespace FizzyLauncher
moveUpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
moveDownToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
treeView1 = new RyzStudio.Windows.Forms.BookmarkTreeView();
toolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem();
menuStrip1.SuspendLayout();
rootContextMenu.SuspendLayout();
folderContextMenu.SuspendLayout();
@ -122,7 +120,7 @@ namespace FizzyLauncher
//
// newToolStripMenuItem
//
newToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
newToolStripMenuItem.Image = BookmarkManager.AppResource.file;
newToolStripMenuItem.Name = "newToolStripMenuItem";
newToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N;
newToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@ -131,7 +129,7 @@ namespace FizzyLauncher
//
// openToolStripMenuItem
//
openToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
openToolStripMenuItem.Image = BookmarkManager.AppResource.folder;
openToolStripMenuItem.Name = "openToolStripMenuItem";
openToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O;
openToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@ -157,7 +155,7 @@ namespace FizzyLauncher
//
// saveToolStripMenuItem
//
saveToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
saveToolStripMenuItem.Image = BookmarkManager.AppResource.save;
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S;
saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@ -192,7 +190,7 @@ namespace FizzyLauncher
//
// findToolStripMenuItem
//
findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
findToolStripMenuItem.Image = BookmarkManager.AppResource.search;
findToolStripMenuItem.Name = "findToolStripMenuItem";
findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F;
findToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
@ -253,7 +251,7 @@ namespace FizzyLauncher
//
// optionsToolStripMenuItem
//
optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
optionsToolStripMenuItem.Image = BookmarkManager.AppResource.settings;
optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12;
optionsToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
@ -269,7 +267,7 @@ namespace FizzyLauncher
//
// viewHelpToolStripMenuItem1
//
viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
viewHelpToolStripMenuItem1.Image = BookmarkManager.AppResource.help_circle;
viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1";
viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1;
viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(146, 22);
@ -296,92 +294,85 @@ namespace FizzyLauncher
//
// rootContextMenu
//
rootContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem, toolStripMenuItem11, addFolderToolStripMenuItem, toolStripMenuItem2, editToolStripMenuItem, toolStripMenuItem3, sortToolStripMenuItem });
rootContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem, addFolderToolStripMenuItem, toolStripMenuItem2, editToolStripMenuItem, toolStripMenuItem3, sortToolStripMenuItem });
rootContextMenu.Name = "rootContextMenu";
rootContextMenu.Size = new System.Drawing.Size(181, 148);
rootContextMenu.Size = new System.Drawing.Size(133, 104);
//
// addPageToolStripMenuItem
//
addPageToolStripMenuItem.Name = "addPageToolStripMenuItem";
addPageToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
addPageToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
addPageToolStripMenuItem.Text = "Add &Page";
addPageToolStripMenuItem.Click += addPageToolStripMenuItem_Click;
//
// addFolderToolStripMenuItem
//
addFolderToolStripMenuItem.Name = "addFolderToolStripMenuItem";
addFolderToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
addFolderToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
addFolderToolStripMenuItem.Text = "Add &Folder";
addFolderToolStripMenuItem.Click += addFolderToolStripMenuItem_Click;
//
// toolStripMenuItem2
//
toolStripMenuItem2.Name = "toolStripMenuItem2";
toolStripMenuItem2.Size = new System.Drawing.Size(177, 6);
toolStripMenuItem2.Size = new System.Drawing.Size(129, 6);
//
// editToolStripMenuItem
//
editToolStripMenuItem.Name = "editToolStripMenuItem";
editToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
editToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
editToolStripMenuItem.Text = "&Edit";
editToolStripMenuItem.Click += editToolStripMenuItem_Click;
//
// toolStripMenuItem3
//
toolStripMenuItem3.Name = "toolStripMenuItem3";
toolStripMenuItem3.Size = new System.Drawing.Size(177, 6);
toolStripMenuItem3.Size = new System.Drawing.Size(129, 6);
//
// sortToolStripMenuItem
//
sortToolStripMenuItem.Name = "sortToolStripMenuItem";
sortToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
sortToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
sortToolStripMenuItem.Text = "&Sort";
sortToolStripMenuItem.Click += sortToolStripMenuItem_Click;
//
// folderContextMenu
//
folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem1, toolStripMenuItem10, addFolderToolStripMenuItem1, toolStripMenuItem4, openAllToolStripMenuItem, editToolStripMenuItem1, deleteToolStripMenuItem, toolStripMenuItem5, sortToolStripMenuItem1, toolStripMenuItem6, moveUpToolStripMenuItem, moveDownToolStripMenuItem });
folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem1, addFolderToolStripMenuItem1, toolStripMenuItem4, openAllToolStripMenuItem, editToolStripMenuItem1, deleteToolStripMenuItem, toolStripMenuItem5, sortToolStripMenuItem1, toolStripMenuItem6, moveUpToolStripMenuItem, moveDownToolStripMenuItem });
folderContextMenu.Name = "folderContextMenu";
folderContextMenu.Size = new System.Drawing.Size(167, 220);
folderContextMenu.Size = new System.Drawing.Size(139, 198);
//
// addPageToolStripMenuItem1
//
addPageToolStripMenuItem1.Name = "addPageToolStripMenuItem1";
addPageToolStripMenuItem1.Size = new System.Drawing.Size(166, 22);
addPageToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
addPageToolStripMenuItem1.Text = "Add &Page";
addPageToolStripMenuItem1.Click += addPageToolStripMenuItem1_Click;
//
// toolStripMenuItem10
//
toolStripMenuItem10.Name = "toolStripMenuItem10";
toolStripMenuItem10.Size = new System.Drawing.Size(166, 22);
toolStripMenuItem10.Text = "Add Page (&Batch)";
toolStripMenuItem10.Click += toolStripMenuItem10_Click;
//
// addFolderToolStripMenuItem1
//
addFolderToolStripMenuItem1.Name = "addFolderToolStripMenuItem1";
addFolderToolStripMenuItem1.Size = new System.Drawing.Size(166, 22);
addFolderToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
addFolderToolStripMenuItem1.Text = "Add &Folder";
addFolderToolStripMenuItem1.Click += addFolderToolStripMenuItem1_Click;
//
// toolStripMenuItem4
//
toolStripMenuItem4.Name = "toolStripMenuItem4";
toolStripMenuItem4.Size = new System.Drawing.Size(163, 6);
toolStripMenuItem4.Size = new System.Drawing.Size(135, 6);
//
// openAllToolStripMenuItem
//
openAllToolStripMenuItem.Image = BookmarkManager.AppResource.bookmark;
openAllToolStripMenuItem.Name = "openAllToolStripMenuItem";
openAllToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
openAllToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
openAllToolStripMenuItem.Text = "&Open All";
openAllToolStripMenuItem.Click += openAllToolStripMenuItem_Click;
//
// editToolStripMenuItem1
//
editToolStripMenuItem1.Name = "editToolStripMenuItem1";
editToolStripMenuItem1.Size = new System.Drawing.Size(166, 22);
editToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
editToolStripMenuItem1.Text = "&Edit";
editToolStripMenuItem1.Click += editToolStripMenuItem1_Click;
//
@ -389,32 +380,32 @@ namespace FizzyLauncher
//
deleteToolStripMenuItem.Image = BookmarkManager.AppResource.trash;
deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
deleteToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
deleteToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
deleteToolStripMenuItem.Text = "&Delete";
deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click;
//
// toolStripMenuItem5
//
toolStripMenuItem5.Name = "toolStripMenuItem5";
toolStripMenuItem5.Size = new System.Drawing.Size(163, 6);
toolStripMenuItem5.Size = new System.Drawing.Size(135, 6);
//
// sortToolStripMenuItem1
//
sortToolStripMenuItem1.Name = "sortToolStripMenuItem1";
sortToolStripMenuItem1.Size = new System.Drawing.Size(166, 22);
sortToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
sortToolStripMenuItem1.Text = "&Sort";
sortToolStripMenuItem1.Click += sortToolStripMenuItem1_Click;
//
// toolStripMenuItem6
//
toolStripMenuItem6.Name = "toolStripMenuItem6";
toolStripMenuItem6.Size = new System.Drawing.Size(163, 6);
toolStripMenuItem6.Size = new System.Drawing.Size(135, 6);
//
// moveUpToolStripMenuItem
//
moveUpToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_up_circle;
moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
moveUpToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
moveUpToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
moveUpToolStripMenuItem.Text = "Move &Up";
moveUpToolStripMenuItem.Click += moveUpToolStripMenuItem_Click;
//
@ -422,7 +413,7 @@ namespace FizzyLauncher
//
moveDownToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_down_circle;
moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
moveDownToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
moveDownToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
moveDownToolStripMenuItem.Text = "Move &Down";
moveDownToolStripMenuItem.Click += moveDownToolStripMenuItem_Click;
//
@ -491,13 +482,6 @@ namespace FizzyLauncher
treeView1.Size = new System.Drawing.Size(300, 556);
treeView1.TabIndex = 5;
//
// toolStripMenuItem11
//
toolStripMenuItem11.Name = "toolStripMenuItem11";
toolStripMenuItem11.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem11.Text = "Add Page (&Batch)";
toolStripMenuItem11.Click += toolStripMenuItem11_Click;
//
// MainForm
//
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -579,8 +563,6 @@ namespace FizzyLauncher
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private RyzStudio.Windows.Forms.BookmarkTreeView treeView1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem10;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem11;
}
}

View File

@ -15,7 +15,6 @@ using FizzyLauncher.Models;
using RyzStudio;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
using static RyzStudio.Windows.Forms.BookmarkTreeView;
namespace FizzyLauncher
{
@ -32,14 +31,6 @@ 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;
@ -394,36 +385,6 @@ namespace FizzyLauncher
}
}
/// <summary>
/// Add page (batch)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem11_Click(object sender, EventArgs e)
{
if (this.IsBusy)
{
return;
}
var nodeType = treeView1.GetNodeType();
if ((nodeType != NodeType.Root) && (nodeType != NodeType.Folder))
{
return;
}
var nodePath = treeView1.GetNodePath();
var form = new AddBatchPageForm(nodePath);
if (form.ShowDialog() == DialogResult.OK)
{
foreach (var item in form.Result)
{
treeView1.AddNode(item);
}
}
}
/// <summary>
/// Add folder
/// </summary>
@ -487,16 +448,6 @@ namespace FizzyLauncher
addPageToolStripMenuItem_Click(sender, e);
}
/// <summary>
/// Add page (batch)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem10_Click(object sender, EventArgs e)
{
toolStripMenuItem11_Click(this, e);
}
/// <summary>
/// Add folder
/// </summary>
@ -799,15 +750,6 @@ namespace FizzyLauncher
this.CurrentSession.Height = this.Height;
var nodeList = treeView1.ToNodeList<BookmarkModel>() ?? new List<KeyValuePair<TreeNode, BookmarkModel>>();
foreach (var node in nodeList)
{
node.Value.Path = treeView1.GetNodePath(node.Key);
if (node.Value.Path.Contains('\n'))
{
node.Value.Path = node.Value.Path.Substring(0, node.Value.Path.LastIndexOf('\n'));
}
}
this.CurrentSession.Items = nodeList.Select(x => x.Value).ToList();
@ -825,7 +767,7 @@ namespace FizzyLauncher
if (result.IsSuccess)
{
// Add icons to save file
var result2 = AddImagesToZipFile(filename, nodeList);
var result2 = AddImagesToZipFile(filename, this.CurrentSession.Items);
if (!result2.IsSuccess)
{
if (showNotices)
@ -1019,7 +961,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))
{
@ -1047,38 +989,14 @@ namespace FizzyLauncher
{
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);
if (zipEntry != null)
{
zipEntry.Delete();
}
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 (icon.Width <= 0)
{
continue;
}
}
catch (Exception)
if (item.Icon == null)
{
continue;
}
@ -1089,7 +1007,7 @@ namespace FizzyLauncher
{
using (Stream entryStream = zipEntry.Open())
{
using (Image image = icon)
using (Image image = item.Icon)
{
image.Save(entryStream, ImageFormat.Png);
}
@ -1097,8 +1015,6 @@ namespace FizzyLauncher
}
catch (Exception)
{
zipEntry.Delete();
continue;
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using HtmlAgilityPack;
@ -150,7 +148,7 @@ namespace BookmarkManager.Services
return result;
}
public async Task<Image> RetrieveImage(string url, HtmlAgilityPack.HtmlDocument document)
public async Task<Image> RetrieveImage(HtmlAgilityPack.HtmlDocument document)
{
var iconUrl = this.ParseFavicon(document);
if (string.IsNullOrWhiteSpace(iconUrl))
@ -158,18 +156,6 @@ namespace BookmarkManager.Services
return null;
}
try
{
var baseUri = new Uri(url);
var absoluteUri = new Uri(baseUri, iconUrl);
iconUrl = absoluteUri.AbsoluteUri;
}
catch
{
return null;
}
return await this.RetrieveImage(iconUrl);
}
@ -177,102 +163,132 @@ namespace BookmarkManager.Services
{
string result = null;
// Find basic title
result = FindNodeValue(document, "//title", string.Empty)?.Trim();
result = ParseTagValue(document, "//title", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
// Find title from extended meta
var patternList = new List<string>()
result = ParseTagValue_Attr(document, "//meta[@property='og:title']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
"//meta[@property='og:title']",
"//meta[@property='og:site_name']",
"//meta[@name='twitter:title']",
"//meta[@itemprop='name']"
};
return result;
}
foreach (var item in patternList)
result = ParseTagValue_Attr(document, "//meta[@name='twitter:title']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
result = FindNodeAttrValue(document, item, "content", string.Empty)?.Trim();
if (string.IsNullOrWhiteSpace(result))
{
continue;
}
return result;
}
result = ParseTagValue_Attr(document, "//meta[@property='og:site_name']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@itemprop='name']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
return string.Empty;
}
public string ParseDescription(HtmlAgilityPack.HtmlDocument document)
public string ParseMetaDescription(HtmlAgilityPack.HtmlDocument document)
{
var patternList = new List<string>()
{
"//meta[@name='description']",
"//meta[@property='og:description']",
"//meta[@name='twitter:description']",
"//meta[@itemprop='description']",
};
string result = null;
foreach (var item in patternList)
result = ParseTagValue_Attr(document, "//meta[@name='description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
var result = FindNodeAttrValue(document, item, "content", string.Empty)?.Trim();
if (string.IsNullOrWhiteSpace(result))
{
continue;
}
return result;
}
return string.Empty;
result = ParseTagValue_Attr(document, "//meta[@property='og:description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@name='twitter:description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@property='og:description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@itemprop='description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
return result;
}
public string ParseFavicon(HtmlAgilityPack.HtmlDocument document)
{
string result = null;
// Find link-rel that contains word
result = FindNodeAttrValue_ContainsWord(document, "link", "rel", "href", "icon");
result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'shortcut icon']", "href", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
// Find link-rel contains apple-icon
var matchPatterns = new List<string>() { "apple-touch-icon", "apple-touch-icon-precomposed" };
result = FindNodeAttrValue_Equals(document, "link", "rel", "href", matchPatterns);
result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'icon']", "href", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
// Find favicon from extended meta
var patternList = new List<string>()
result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'apple-touch-icon']", "href", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
"//meta[@property='og:image']",
"//meta[@name='twitter:image']",
"//meta[@itemprop='image']"
};
foreach (var item in patternList)
{
result = FindNodeAttrValue(document, item, "content", string.Empty)?.Trim();
if (string.IsNullOrWhiteSpace(result))
{
continue;
}
return result;
}
return string.Empty;
result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'apple-touch-icon-precomposed']", "href", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'og:image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'twitter:image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'og:image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@itemprop, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
return "/favicon.ico";
}
private string FindNodeValue(HtmlAgilityPack.HtmlDocument document, string xPath, string defaultValue = "")
private string ParseTagValue(HtmlAgilityPack.HtmlDocument document, string xPath, string defaultValue = "")
{
var hnc = document.DocumentNode.SelectNodes(xPath);
if (hnc == null)
@ -304,7 +320,7 @@ namespace BookmarkManager.Services
return defaultValue;
}
private string FindNodeAttrValue(HtmlAgilityPack.HtmlDocument document, string xPath, string attr, string defaultValue = "")
private string ParseTagValue_Attr(HtmlAgilityPack.HtmlDocument document, string xPath, string attr, string defaultValue = "")
{
var hnc = document.DocumentNode.SelectNodes(xPath);
if (hnc == null)
@ -335,93 +351,5 @@ namespace BookmarkManager.Services
return defaultValue;
}
private List<HtmlNode> FindNode(HtmlAgilityPack.HtmlDocument document, string nodeName, string attrName)
{
var xPath = (string.IsNullOrWhiteSpace(attrName) ? $"//{nodeName}" : $"//{nodeName}[@{attrName}]");
var hnc = document.DocumentNode.SelectNodes(xPath);
if (hnc == null)
{
return new List<HtmlNode>();
}
if (hnc.Count <= 0)
{
return new List<HtmlNode>();
}
return hnc.ToList();
}
private string FindNodeAttrValue_ContainsWord(HtmlAgilityPack.HtmlDocument document, string nodeName, string attrName, string returnAttrName, string matchEqualList, string defaultValue = "")
{
var linkNodes = FindNode(document, nodeName, attrName);
foreach (var item in linkNodes)
{
var relValue = item.Attributes[attrName].Value?.Trim() ?? string.Empty;
if (!ContainsWord(relValue, matchEqualList))
{
continue;
}
var hrefValue = item.Attributes[returnAttrName].Value?.Trim() ?? string.Empty;
if (string.IsNullOrWhiteSpace(hrefValue))
{
continue;
}
return System.Web.HttpUtility.HtmlDecode(hrefValue);
}
return defaultValue;
}
private string FindNodeAttrValue_Equals(HtmlAgilityPack.HtmlDocument document, string nodeName, string attrName, string returnAttrName, List<string> matchValueList, string defaultValue = "")
{
var linkNodes = FindNode(document, nodeName, attrName);
foreach (var item in linkNodes)
{
var relValue = item.Attributes[attrName].Value?.Trim() ?? string.Empty;
if (!matchValueList.Contains(relValue?.ToLower() ?? string.Empty))
{
continue;
}
var hrefValue = item.Attributes[returnAttrName].Value?.Trim() ?? string.Empty;
if (string.IsNullOrWhiteSpace(hrefValue))
{
continue;
}
return System.Web.HttpUtility.HtmlDecode(hrefValue);
}
return defaultValue;
}
private bool ContainsWord(string haystack, string needle)
{
haystack = haystack?.Trim() ?? string.Empty;
if (!haystack.Contains(" "))
{
return haystack.Equals(needle, StringComparison.CurrentCultureIgnoreCase);
}
foreach (var item in haystack.Split(" "))
{
if (string.IsNullOrWhiteSpace(item))
{
continue;
}
if (item.Equals(needle, StringComparison.CurrentCultureIgnoreCase))
{
return true;
}
}
return false;
}
}
}

View File

@ -17,6 +17,7 @@ namespace FizzyLauncher
private System.Windows.Forms.Label label1;
private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator2;
private Label label2;
private PictureBox pictureBox2;
private ThYesNoPickerBox pickerBox1;
private ThButton button2;
private RyzStudio.Windows.ThemedForms.ThProgressBar progressBar1;
@ -50,6 +51,7 @@ namespace FizzyLauncher
label1 = new Label();
tHorizontalSeparator2 = new THorizontalSeparator();
label2 = new Label();
pictureBox2 = new PictureBox();
pickerBox1 = new ThYesNoPickerBox();
button2 = new ThButton();
progressBar1 = new ThProgressBar();
@ -58,6 +60,7 @@ namespace FizzyLauncher
button3 = new ThButton();
progressBar2 = new ThProgressBar();
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
((ISupportInitialize)pictureBox2).BeginInit();
SuspendLayout();
//
// label1
@ -103,6 +106,19 @@ namespace FizzyLauncher
label2.Text = "Retrieve supported icons from bookmarks.";
label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// pictureBox2
//
pictureBox2.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
pictureBox2.BackColor = System.Drawing.Color.Transparent;
pictureBox2.ErrorImage = null;
pictureBox2.InitialImage = null;
pictureBox2.Location = new System.Drawing.Point(402, 294);
pictureBox2.Name = "pictureBox2";
pictureBox2.Size = new System.Drawing.Size(32, 32);
pictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox2.TabIndex = 202;
pictureBox2.TabStop = false;
//
// pickerBox1
//
pickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
@ -221,9 +237,8 @@ namespace FizzyLauncher
//
dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
dialogFooter1.Button1Text = "&Close";
dialogFooter1.Dialog = this;
dialogFooter1.Dialog = null;
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.IsBusy = false;
dialogFooter1.Location = new System.Drawing.Point(0, 437);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new System.Drawing.Size(444, 84);
@ -242,6 +257,7 @@ namespace FizzyLauncher
Controls.Add(progressBar1);
Controls.Add(button2);
Controls.Add(pickerBox1);
Controls.Add(pictureBox2);
Controls.Add(label2);
Controls.Add(tHorizontalSeparator2);
Controls.Add(label1);
@ -249,6 +265,7 @@ namespace FizzyLauncher
MinimumSize = new System.Drawing.Size(460, 560);
Name = "UpdateIconsForm";
Text = "Update Icons";
((ISupportInitialize)pictureBox2).EndInit();
ResumeLayout(false);
PerformLayout();
}
@ -302,8 +319,7 @@ namespace FizzyLauncher
{
button3.LabelText = (this.IsBusy ? "&Stop" : "Clear &All");
});
dialogFooter1.IsBusy = _isBusy;
UIControl.SetValue(pictureBox2, (this.IsBusy ? RyzStudio.Windows.ThemedForms.Resource2.loading_block : null));
}
}
@ -356,25 +372,14 @@ namespace FizzyLauncher
break;
}
var image = await _webProvider.RetrieveImage(document);
if (image == null)
{
continue;
}
var newModel = item.Value;
try
{
var image = await _webProvider.RetrieveImage(item.Value.Address, document);
if (image != null)
{
if (image.Width > 16)
{
image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16);
}
}
newModel.Icon = image;
}
catch (Exception)
{
newModel.Icon = null;
}
newModel.Icon = image;
_treeView.UpdateNode(item.Key, newModel);
}

View File

@ -1,7 +1,5 @@
using System;
using System.ComponentModel;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using bzit.bomg.Models;
using FizzyLauncher;
@ -127,8 +125,6 @@ namespace RyzStudio.Windows.Forms
if (MessageBox.Show("Delete?", "Delete?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.DeleteNode();
this.HasChanged = true;
}
}
@ -247,8 +243,6 @@ namespace RyzStudio.Windows.Forms
this.EditNode(treeNode);
}
this.HasChanged = true;
return treeNode;
}
@ -278,8 +272,6 @@ namespace RyzStudio.Windows.Forms
this.SelectedNode = newNode;
this.HasChanged = true;
return newNode;
}
}
@ -289,12 +281,30 @@ namespace RyzStudio.Windows.Forms
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, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2);
int iconIndex = (int)NodeIcon.Default;
// 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, iconIndex, iconIndex);
newNode.Tag = model;
newNode.ToolTipText = model.ToString();
@ -394,6 +404,10 @@ namespace RyzStudio.Windows.Forms
if (node == null)
{
node = this.SelectedNode;
}
if (node == null)
{
return;
}
@ -402,18 +416,36 @@ namespace RyzStudio.Windows.Forms
return;
}
if (model.Id == Guid.Empty)
{
return;
}
var iconIndex = (int)NodeIcon.Default;
// 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) =>
{
node.Text = model.Title;
node.ImageIndex = node.SelectedImageIndex = n;
node.ImageIndex = iconIndex;
node.SelectedImageIndex = iconIndex;
node.Tag = model;
node.ToolTipText = model.ToString();
});
@ -430,43 +462,9 @@ namespace RyzStudio.Windows.Forms
this.ImageList.Images.Add(Resources.hexagon);
this.ImageList.Images.Add(Resources.folder);
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);
}
}
}

View File

@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "BukkuBuddy Bookmark Manager"
#define MyAppVersion "0.6.2.092"
#define MyAppVersion "0.6.0.716"
#define MyAppPublisher "Hi, I'm Ray"
#define MyAppURL "https://www.hiimray.co.uk/software-bookmark-manager"
#define MyAppExeName "bukkubuddy.exe"