2022-12-23 22:20:26 +00:00
|
|
|
|
using System;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
using System.Collections.Generic;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
using BookmarkManager.Services;
|
2022-12-23 22:20:26 +00:00
|
|
|
|
using bzit.bomg.Models;
|
|
|
|
|
using RyzStudio.Windows.Forms;
|
|
|
|
|
using RyzStudio.Windows.ThemedForms;
|
|
|
|
|
using RyzStudio.Windows.ThemedForms.PickerBox;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
|
|
|
|
namespace FizzyLauncher
|
|
|
|
|
{
|
2024-07-20 17:09:44 +00:00
|
|
|
|
public class UpdateIconsForm : Form
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
|
|
|
|
private System.Windows.Forms.Label label1;
|
|
|
|
|
private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator2;
|
|
|
|
|
private Label label2;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
private ThYesNoPickerBox pickerBox1;
|
|
|
|
|
private ThButton button2;
|
|
|
|
|
private RyzStudio.Windows.ThemedForms.ThProgressBar progressBar1;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
private readonly WebProvider _webProvider;
|
|
|
|
|
private BookmarkTreeView _treeView;
|
|
|
|
|
private bool _isBusy = false;
|
2024-07-18 16:28:21 +00:00
|
|
|
|
private Label label4;
|
|
|
|
|
private THorizontalSeparator tHorizontalSeparator3;
|
|
|
|
|
private ThButton button3;
|
2024-07-19 20:22:24 +00:00
|
|
|
|
private ThProgressBar progressBar2;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
private bool _requestCancel = false;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
public UpdateIconsForm(BookmarkTreeView treeView)
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2024-07-20 17:09:44 +00:00
|
|
|
|
UISetup.Dialog(this);
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
_webProvider = new WebProvider();
|
2024-07-18 22:45:51 +00:00
|
|
|
|
_webProvider.IgnoreSSL = true;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
_treeView = treeView;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
label1 = new Label();
|
|
|
|
|
tHorizontalSeparator2 = new THorizontalSeparator();
|
|
|
|
|
label2 = new Label();
|
|
|
|
|
pickerBox1 = new ThYesNoPickerBox();
|
|
|
|
|
button2 = new ThButton();
|
|
|
|
|
progressBar1 = new ThProgressBar();
|
2024-07-18 16:28:21 +00:00
|
|
|
|
label4 = new Label();
|
|
|
|
|
tHorizontalSeparator3 = new THorizontalSeparator();
|
|
|
|
|
button3 = new ThButton();
|
2024-07-19 20:22:24 +00:00
|
|
|
|
progressBar2 = new ThProgressBar();
|
2024-07-20 17:09:44 +00:00
|
|
|
|
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
|
2024-07-17 00:56:17 +00:00
|
|
|
|
SuspendLayout();
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// label1
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
label1.AutoSize = true;
|
|
|
|
|
label1.BackColor = System.Drawing.Color.Transparent;
|
|
|
|
|
label1.ForeColor = System.Drawing.SystemColors.ControlText;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
label1.Location = new System.Drawing.Point(10, 20);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
label1.Margin = new Padding(0);
|
|
|
|
|
label1.Name = "label1";
|
|
|
|
|
label1.Padding = new Padding(0, 8, 0, 0);
|
|
|
|
|
label1.Size = new System.Drawing.Size(156, 23);
|
|
|
|
|
label1.TabIndex = 153;
|
|
|
|
|
label1.Text = "Update Missing Icons (Only)";
|
|
|
|
|
label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// tHorizontalSeparator2
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
tHorizontalSeparator2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
|
|
|
tHorizontalSeparator2.AutoScrollMargin = new System.Drawing.Size(0, 0);
|
|
|
|
|
tHorizontalSeparator2.AutoScrollMinSize = new System.Drawing.Size(0, 0);
|
|
|
|
|
tHorizontalSeparator2.BackColor = System.Drawing.Color.Transparent;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
tHorizontalSeparator2.Location = new System.Drawing.Point(10, 64);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
tHorizontalSeparator2.Margin = new Padding(0, 10, 0, 0);
|
|
|
|
|
tHorizontalSeparator2.MaximumSize = new System.Drawing.Size(4920, 2);
|
|
|
|
|
tHorizontalSeparator2.MinimumSize = new System.Drawing.Size(0, 22);
|
|
|
|
|
tHorizontalSeparator2.Name = "tHorizontalSeparator2";
|
|
|
|
|
tHorizontalSeparator2.Size = new System.Drawing.Size(424, 22);
|
|
|
|
|
tHorizontalSeparator2.TabIndex = 190;
|
|
|
|
|
tHorizontalSeparator2.TabStop = false;
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// label2
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
label2.AutoSize = true;
|
|
|
|
|
label2.BackColor = System.Drawing.Color.Transparent;
|
|
|
|
|
label2.ForeColor = System.Drawing.SystemColors.ControlText;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
label2.Location = new System.Drawing.Point(10, 136);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
label2.Margin = new Padding(0);
|
|
|
|
|
label2.Name = "label2";
|
|
|
|
|
label2.Padding = new Padding(0, 8, 0, 0);
|
2024-07-18 16:28:21 +00:00
|
|
|
|
label2.Size = new System.Drawing.Size(231, 23);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
label2.TabIndex = 195;
|
2024-07-18 16:28:21 +00:00
|
|
|
|
label2.Text = "Retrieve supported icons from bookmarks.";
|
2024-07-17 00:56:17 +00:00
|
|
|
|
label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// pickerBox1
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
pickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
|
|
|
pickerBox1.BackColor = System.Drawing.Color.Transparent;
|
|
|
|
|
pickerBox1.EnableReactiveVisual = true;
|
|
|
|
|
pickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
|
2024-07-20 17:09:44 +00:00
|
|
|
|
pickerBox1.Location = new System.Drawing.Point(350, 20);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
pickerBox1.Name = "pickerBox1";
|
|
|
|
|
pickerBox1.SelectedIndex = 1;
|
|
|
|
|
pickerBox1.Size = new System.Drawing.Size(84, 35);
|
|
|
|
|
pickerBox1.TabIndex = 0;
|
|
|
|
|
pickerBox1.TabStop = false;
|
|
|
|
|
pickerBox1.Value = true;
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// button2
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
button2.ActiveImage = null;
|
|
|
|
|
button2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
|
|
|
button2.BackColor = System.Drawing.Color.Transparent;
|
|
|
|
|
button2.EnableMenuOnClick = false;
|
|
|
|
|
button2.EnableReactiveVisual = true;
|
|
|
|
|
button2.HoverImage = null;
|
|
|
|
|
button2.IdleImage = null;
|
|
|
|
|
button2.LabelText = "&Run";
|
2024-07-20 17:09:44 +00:00
|
|
|
|
button2.Location = new System.Drawing.Point(306, 136);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
button2.Name = "button2";
|
|
|
|
|
button2.Size = new System.Drawing.Size(128, 32);
|
|
|
|
|
button2.TabIndex = 1;
|
|
|
|
|
button2.TabStop = false;
|
|
|
|
|
button2.MouseClick += button2_MouseClick;
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// progressBar1
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
progressBar1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
|
|
|
progressBar1.BackColor = System.Drawing.Color.Transparent;
|
2024-07-19 20:22:24 +00:00
|
|
|
|
progressBar1.BarColour = System.Drawing.Color.FromArgb(79, 202, 130);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
progressBar1.BarTextColour = System.Drawing.Color.Black;
|
|
|
|
|
progressBar1.EnableReactiveVisual = false;
|
|
|
|
|
progressBar1.Font = new System.Drawing.Font("Segoe UI", 9F);
|
2024-07-20 17:09:44 +00:00
|
|
|
|
progressBar1.Location = new System.Drawing.Point(10, 96);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
progressBar1.Maximum = 100;
|
|
|
|
|
progressBar1.Minimum = 0;
|
|
|
|
|
progressBar1.Name = "progressBar1";
|
|
|
|
|
progressBar1.ProgressText = "50/100";
|
|
|
|
|
progressBar1.ShowProgressText = true;
|
|
|
|
|
progressBar1.Size = new System.Drawing.Size(424, 20);
|
|
|
|
|
progressBar1.TabIndex = 206;
|
|
|
|
|
progressBar1.TabStop = false;
|
|
|
|
|
progressBar1.Value = 50;
|
|
|
|
|
//
|
2024-07-18 16:28:21 +00:00
|
|
|
|
// label4
|
|
|
|
|
//
|
|
|
|
|
label4.AutoSize = true;
|
|
|
|
|
label4.BackColor = System.Drawing.Color.Transparent;
|
|
|
|
|
label4.ForeColor = System.Drawing.SystemColors.ControlText;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
label4.Location = new System.Drawing.Point(10, 250);
|
2024-07-18 16:28:21 +00:00
|
|
|
|
label4.Margin = new Padding(0);
|
|
|
|
|
label4.Name = "label4";
|
|
|
|
|
label4.Padding = new Padding(0, 8, 0, 0);
|
|
|
|
|
label4.Size = new System.Drawing.Size(83, 23);
|
|
|
|
|
label4.TabIndex = 208;
|
|
|
|
|
label4.Text = "Clear all icons.";
|
|
|
|
|
label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
|
|
|
//
|
|
|
|
|
// tHorizontalSeparator3
|
|
|
|
|
//
|
|
|
|
|
tHorizontalSeparator3.Anchor = AnchorStyles.Top | 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;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
tHorizontalSeparator3.Location = new System.Drawing.Point(10, 178);
|
2024-07-18 16:28:21 +00:00
|
|
|
|
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.BackColor = System.Drawing.Color.Transparent;
|
|
|
|
|
button3.EnableMenuOnClick = false;
|
|
|
|
|
button3.EnableReactiveVisual = true;
|
|
|
|
|
button3.HoverImage = null;
|
|
|
|
|
button3.IdleImage = null;
|
|
|
|
|
button3.LabelText = "Clear &All";
|
2024-07-20 17:09:44 +00:00
|
|
|
|
button3.Location = new System.Drawing.Point(306, 250);
|
2024-07-18 16:28:21 +00:00
|
|
|
|
button3.Name = "button3";
|
|
|
|
|
button3.Size = new System.Drawing.Size(128, 32);
|
|
|
|
|
button3.TabIndex = 209;
|
|
|
|
|
button3.TabStop = false;
|
|
|
|
|
button3.MouseClick += button3_MouseClick;
|
|
|
|
|
//
|
2024-07-19 20:22:24 +00:00
|
|
|
|
// progressBar2
|
|
|
|
|
//
|
|
|
|
|
progressBar2.Anchor = AnchorStyles.Top | 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);
|
2024-07-20 17:09:44 +00:00
|
|
|
|
progressBar2.Location = new System.Drawing.Point(10, 210);
|
2024-07-19 20:22:24 +00:00
|
|
|
|
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;
|
|
|
|
|
//
|
2024-07-20 17:09:44 +00:00
|
|
|
|
// dialogFooter1
|
|
|
|
|
//
|
|
|
|
|
dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
|
|
|
|
|
dialogFooter1.Button1Text = "&Close";
|
2024-07-21 17:44:05 +00:00
|
|
|
|
dialogFooter1.Dialog = this;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
dialogFooter1.Dock = DockStyle.Bottom;
|
2024-07-21 17:44:05 +00:00
|
|
|
|
dialogFooter1.IsBusy = false;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
dialogFooter1.Location = new System.Drawing.Point(0, 437);
|
|
|
|
|
dialogFooter1.Name = "dialogFooter1";
|
|
|
|
|
dialogFooter1.Size = new System.Drawing.Size(444, 84);
|
|
|
|
|
//
|
2021-09-30 21:26:17 +00:00
|
|
|
|
// UpdateIconsForm
|
2024-07-17 00:56:17 +00:00
|
|
|
|
//
|
|
|
|
|
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
|
|
|
AutoScaleMode = AutoScaleMode.Font;
|
2024-07-20 17:09:44 +00:00
|
|
|
|
BackColor = System.Drawing.Color.White;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
ClientSize = new System.Drawing.Size(444, 521);
|
2024-07-20 17:09:44 +00:00
|
|
|
|
Controls.Add(dialogFooter1);
|
2024-07-19 20:22:24 +00:00
|
|
|
|
Controls.Add(progressBar2);
|
2024-07-18 16:28:21 +00:00
|
|
|
|
Controls.Add(button3);
|
|
|
|
|
Controls.Add(label4);
|
|
|
|
|
Controls.Add(tHorizontalSeparator3);
|
2024-07-17 00:56:17 +00:00
|
|
|
|
Controls.Add(progressBar1);
|
|
|
|
|
Controls.Add(button2);
|
|
|
|
|
Controls.Add(pickerBox1);
|
|
|
|
|
Controls.Add(label2);
|
|
|
|
|
Controls.Add(tHorizontalSeparator2);
|
|
|
|
|
Controls.Add(label1);
|
|
|
|
|
KeyPreview = true;
|
|
|
|
|
MinimumSize = new System.Drawing.Size(460, 560);
|
|
|
|
|
Name = "UpdateIconsForm";
|
|
|
|
|
Text = "Update Icons";
|
|
|
|
|
ResumeLayout(false);
|
|
|
|
|
PerformLayout();
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
var model = _treeView.ToNodeList<BookmarkModel>();
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-18 16:28:21 +00:00
|
|
|
|
if (pickerBox1.Value)
|
|
|
|
|
{
|
|
|
|
|
model = model.Where(x => x.Value.Icon == null)?.ToList() ?? new List<KeyValuePair<TreeNode, BookmarkModel>>();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
progressBar1.Minimum = 0;
|
|
|
|
|
progressBar1.Value = 0;
|
|
|
|
|
progressBar1.Maximum = model.Count;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-19 20:22:24 +00:00
|
|
|
|
progressBar2.Minimum = 0;
|
|
|
|
|
progressBar2.Value = 0;
|
|
|
|
|
progressBar2.Maximum = model.Count;
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
pickerBox1.Focus();
|
|
|
|
|
}
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnClosing(e);
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
if (this.IsBusy)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
protected bool IsBusy
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
get => _isBusy;
|
|
|
|
|
set
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
_isBusy = value;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
UIControl.SetEnable(pickerBox1, !this.IsBusy);
|
2024-07-18 16:28:21 +00:00
|
|
|
|
UIControl.Invoke(button2, (x) =>
|
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
button2.LabelText = (this.IsBusy ? "&Stop" : "&Run");
|
|
|
|
|
});
|
2024-07-19 20:22:24 +00:00
|
|
|
|
UIControl.Invoke(button3, (x) =>
|
|
|
|
|
{
|
|
|
|
|
button3.LabelText = (this.IsBusy ? "&Stop" : "Clear &All");
|
|
|
|
|
});
|
2024-07-21 17:44:05 +00:00
|
|
|
|
|
|
|
|
|
dialogFooter1.IsBusy = _isBusy;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
}
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
|
2021-09-30 21:26:17 +00:00
|
|
|
|
private async void button2_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
await Task.Run(async () =>
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
if (this.IsBusy)
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
_requestCancel = true;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
this.IsBusy = true;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
var model = _treeView.ToNodeList<BookmarkModel>();
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
if (pickerBox1.Value)
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
model = model.Where(x => x.Value.Icon == null)?.ToList() ?? new List<KeyValuePair<TreeNode, BookmarkModel>>();
|
|
|
|
|
}
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
progressBar1.Minimum = 0;
|
|
|
|
|
progressBar1.Value = 0;
|
|
|
|
|
progressBar1.Maximum = model.Count;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
|
|
|
|
progressBar1.Value++;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(item.Value.Address))
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
if (_requestCancel)
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
2024-07-17 00:56:17 +00:00
|
|
|
|
break;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
var document = await _webProvider.RetrieveHtmlDocument(item.Value.Address);
|
|
|
|
|
if (document == null)
|
2021-09-30 21:26:17 +00:00
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
if (_requestCancel)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-08-04 01:47:25 +00:00
|
|
|
|
var newModel = item.Value;
|
|
|
|
|
|
|
|
|
|
try
|
2024-07-17 00:56:17 +00:00
|
|
|
|
{
|
2024-08-04 01:47:25 +00:00
|
|
|
|
var image = await _webProvider.RetrieveImage(document);
|
2024-08-04 03:11:19 +00:00
|
|
|
|
if (image != null)
|
2024-08-04 01:47:25 +00:00
|
|
|
|
{
|
2024-08-04 03:11:19 +00:00
|
|
|
|
if (image.Width > 16)
|
|
|
|
|
{
|
|
|
|
|
image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16);
|
|
|
|
|
}
|
2024-08-04 01:47:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newModel.Icon = image;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
newModel.Icon = null;
|
2024-07-17 00:56:17 +00:00
|
|
|
|
}
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
_treeView.UpdateNode(item.Key, newModel);
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
_requestCancel = false;
|
2021-09-30 21:26:17 +00:00
|
|
|
|
|
2024-07-17 00:56:17 +00:00
|
|
|
|
this.IsBusy = false;
|
|
|
|
|
});
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 16:28:21 +00:00
|
|
|
|
private async void button3_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy)
|
|
|
|
|
{
|
2024-07-19 20:22:24 +00:00
|
|
|
|
_requestCancel = true;
|
2024-07-18 16:28:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.IsBusy = true;
|
|
|
|
|
|
|
|
|
|
var model = _treeView.ToNodeList<BookmarkModel>();
|
2024-07-19 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
progressBar2.Minimum = 0;
|
|
|
|
|
progressBar2.Value = 0;
|
|
|
|
|
progressBar2.Maximum = model.Count;
|
|
|
|
|
|
2024-07-18 16:28:21 +00:00
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
2024-07-19 20:22:24 +00:00
|
|
|
|
progressBar2.Value++;
|
2024-07-18 16:28:21 +00:00
|
|
|
|
|
|
|
|
|
if (item.Value.Icon == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-19 20:22:24 +00:00
|
|
|
|
if (_requestCancel)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 16:28:21 +00:00
|
|
|
|
var newModel = item.Value;
|
|
|
|
|
newModel.Icon = null;
|
|
|
|
|
|
|
|
|
|
_treeView.UpdateNode(item.Key, newModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_requestCancel = false;
|
|
|
|
|
|
|
|
|
|
this.IsBusy = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 21:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|