From d97959f53c1f39d1c38fd4a556c70245bc9c6a49 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 28 Aug 2020 23:05:59 +0100 Subject: [PATCH] Changed: update icons with task --- BookmarkEditForm.Designer.cs | 82 ++++---- FindForm.Designer.cs | 1 - FindForm.cs | 1 + MainForm.Designer.cs | 8 +- MainForm.cs | 2 +- OptionForm.cs | 131 ------------- RyzStudio/Windows/ThemedForms/ProgressBar.cs | 4 + ...Designer.cs => UpdateIconsForm.Designer.cs | 29 ++- UpdateIconsForm.cs | 177 ++++++++++++++++++ OptionForm.resx => UpdateIconsForm.resx | 0 bomg.csproj | 10 +- 11 files changed, 246 insertions(+), 199 deletions(-) delete mode 100644 OptionForm.cs rename OptionForm.Designer.cs => UpdateIconsForm.Designer.cs (91%) create mode 100644 UpdateIconsForm.cs rename OptionForm.resx => UpdateIconsForm.resx (100%) diff --git a/BookmarkEditForm.Designer.cs b/BookmarkEditForm.Designer.cs index 049eff0..fb0db6d 100644 --- a/BookmarkEditForm.Designer.cs +++ b/BookmarkEditForm.Designer.cs @@ -36,10 +36,10 @@ namespace bzit.bomg this.label5 = new System.Windows.Forms.Label(); this.memoBox1 = new RyzStudio.Windows.ThemedForms.MemoBox(); this.textBox2 = new RyzStudio.Windows.ThemedForms.TextBox(); - this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox(); - this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator(); this.button1 = new RyzStudio.Windows.ThemedForms.Button(); + this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox(); this.button2 = new RyzStudio.Windows.ThemedForms.Button(); + this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -50,7 +50,7 @@ namespace bzit.bomg this.label1.Location = new System.Drawing.Point(12, 25); this.label1.Margin = new System.Windows.Forms.Padding(3); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(28, 13); + this.label1.Size = new System.Drawing.Size(29, 13); this.label1.TabIndex = 0; this.label1.Text = "Title"; // @@ -81,7 +81,7 @@ namespace bzit.bomg this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox2.ErrorImage = null; this.pictureBox2.InitialImage = null; - this.pictureBox2.Location = new System.Drawing.Point(368, 15); + this.pictureBox2.Location = new System.Drawing.Point(348, 15); this.pictureBox2.Name = "pictureBox2"; this.pictureBox2.Size = new System.Drawing.Size(32, 32); this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; @@ -95,7 +95,7 @@ namespace bzit.bomg this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox1.ErrorImage = null; this.pictureBox1.InitialImage = null; - this.pictureBox1.Location = new System.Drawing.Point(286, 217); + this.pictureBox1.Location = new System.Drawing.Point(266, 217); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(32, 32); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; @@ -110,7 +110,7 @@ namespace bzit.bomg this.label5.Location = new System.Drawing.Point(9, 217); this.label5.Margin = new System.Windows.Forms.Padding(3); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(271, 32); + this.label5.Size = new System.Drawing.Size(251, 32); this.label5.TabIndex = 64; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -124,7 +124,7 @@ namespace bzit.bomg this.memoBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); this.memoBox1.Name = "memoBox1"; this.memoBox1.Padding = new System.Windows.Forms.Padding(10, 10, 3, 9); - this.memoBox1.Size = new System.Drawing.Size(336, 83); + this.memoBox1.Size = new System.Drawing.Size(316, 83); this.memoBox1.TabIndex = 3; // // textBox2 @@ -136,11 +136,26 @@ namespace bzit.bomg this.textBox2.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); this.textBox2.Name = "textBox2"; this.textBox2.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9); - this.textBox2.Size = new System.Drawing.Size(259, 32); + this.textBox2.Size = new System.Drawing.Size(239, 34); this.textBox2.SubmitButton = this.button1; this.textBox2.TabIndex = 0; this.textBox2.UseSystemPasswordChar = false; // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackColor = System.Drawing.Color.Transparent; + this.button1.DefaultImage = null; + this.button1.DownImage = null; + this.button1.LabelText = "S&can"; + this.button1.Location = new System.Drawing.Point(348, 59); + this.button1.Name = "button1"; + this.button1.OverImage = null; + this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.button1.Size = new System.Drawing.Size(64, 32); + this.button1.TabIndex = 1; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // textBox1 // this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -150,11 +165,26 @@ namespace bzit.bomg this.textBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); this.textBox1.Name = "textBox1"; this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9); - this.textBox1.Size = new System.Drawing.Size(259, 32); + this.textBox1.Size = new System.Drawing.Size(239, 34); this.textBox1.SubmitButton = this.button2; this.textBox1.TabIndex = 2; this.textBox1.UseSystemPasswordChar = false; // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.BackColor = System.Drawing.Color.Transparent; + this.button2.DefaultImage = null; + this.button2.DownImage = null; + this.button2.LabelText = "&Save"; + this.button2.Location = new System.Drawing.Point(304, 217); + this.button2.Name = "button2"; + this.button2.OverImage = null; + this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.button2.Size = new System.Drawing.Size(108, 32); + this.button2.TabIndex = 4; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // horizontalSeparator1 // this.horizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) @@ -163,44 +193,14 @@ namespace bzit.bomg this.horizontalSeparator1.Margin = new System.Windows.Forms.Padding(3, 10, 3, 10); this.horizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2); this.horizontalSeparator1.Name = "horizontalSeparator1"; - this.horizontalSeparator1.Size = new System.Drawing.Size(420, 2); + this.horizontalSeparator1.Size = new System.Drawing.Size(400, 2); this.horizontalSeparator1.TabIndex = 65; // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button1.BackColor = System.Drawing.Color.Transparent; - this.button1.DefaultImage = null; - this.button1.DownImage = null; - this.button1.LabelText = "S&can"; - this.button1.Location = new System.Drawing.Point(368, 59); - this.button1.Name = "button1"; - this.button1.OverImage = null; - this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.button1.Size = new System.Drawing.Size(64, 32); - this.button1.TabIndex = 1; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // button2 - // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.BackColor = System.Drawing.Color.Transparent; - this.button2.DefaultImage = null; - this.button2.DownImage = null; - this.button2.LabelText = "&Save"; - this.button2.Location = new System.Drawing.Point(324, 217); - this.button2.Name = "button2"; - this.button2.OverImage = null; - this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.button2.Size = new System.Drawing.Size(108, 32); - this.button2.TabIndex = 4; - this.button2.Click += new System.EventHandler(this.button2_Click); - // // BookmarkEditForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(444, 261); + this.ClientSize = new System.Drawing.Size(424, 261); this.Controls.Add(this.memoBox1); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); diff --git a/FindForm.Designer.cs b/FindForm.Designer.cs index c0a9dda..448db17 100644 --- a/FindForm.Designer.cs +++ b/FindForm.Designer.cs @@ -113,7 +113,6 @@ namespace bzit.bomg this.Font = new System.Drawing.Font("Tahoma", 8.25F); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(400, 160); this.Name = "FindForm"; this.ShowIcon = false; this.ShowInTaskbar = false; diff --git a/FindForm.cs b/FindForm.cs index 61891c4..083e90c 100644 --- a/FindForm.cs +++ b/FindForm.cs @@ -91,5 +91,6 @@ namespace bzit.bomg findNextNew = true; } } + } } \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index ee63ad6..133506f 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -310,7 +310,7 @@ namespace bzit.bomg this.findEditMenuItem.Image = global::bzit.bomg.Properties.Resources.search; this.findEditMenuItem.Name = "findEditMenuItem"; this.findEditMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); - this.findEditMenuItem.Size = new System.Drawing.Size(137, 22); + this.findEditMenuItem.Size = new System.Drawing.Size(180, 22); this.findEditMenuItem.Text = "&Find"; this.findEditMenuItem.Click += new System.EventHandler(this.editFindMenuItem_Click); // @@ -368,11 +368,9 @@ namespace bzit.bomg // // optionsToolMenuItem // - this.optionsToolMenuItem.Image = global::bzit.bomg.Properties.Resources.settings; this.optionsToolMenuItem.Name = "optionsToolMenuItem"; - this.optionsToolMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F12; - this.optionsToolMenuItem.Size = new System.Drawing.Size(141, 22); - this.optionsToolMenuItem.Text = "&Options"; + this.optionsToolMenuItem.Size = new System.Drawing.Size(180, 22); + this.optionsToolMenuItem.Text = "&Update Icons"; this.optionsToolMenuItem.Click += new System.EventHandler(this.toolsOptionsMenuItem_Click); // // toolStripDropDownButton5 diff --git a/MainForm.cs b/MainForm.cs index e4fbe77..2392009 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -627,7 +627,7 @@ namespace bzit.bomg return; } - OptionForm optionForm = new OptionForm(this); + UpdateIconsForm optionForm = new UpdateIconsForm(this); optionForm.ShowDialog(); } diff --git a/OptionForm.cs b/OptionForm.cs deleted file mode 100644 index c7a3705..0000000 --- a/OptionForm.cs +++ /dev/null @@ -1,131 +0,0 @@ -using bzit.bomg.Models; -using RyzStudio.Windows.Forms; -using RyzStudio.Windows.ThemedForms; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Windows.Forms; -using Form = System.Windows.Forms.Form; -using Resources = bzit.bomg.Properties.Resources; - -namespace bzit.bomg -{ - public partial class OptionForm : Form - { - protected BackgroundWorker threadWorker = null; - - protected BookmarkItemModel itemModel = null; - protected MainForm parentForm = null; - - public OptionForm(MainForm mainForm) : base() - { - InitializeComponent(); - - parentForm = mainForm; - - this.StartPosition = FormStartPosition.WindowsDefaultLocation; - - if (threadWorker == null) - { - threadWorker = new BackgroundWorker(); - threadWorker.WorkerReportsProgress = threadWorker.WorkerSupportsCancellation = true; - threadWorker.DoWork += threadWorker1_DoWork; - threadWorker.RunWorkerCompleted += threadWorker1_RunWorkerCompleted; - } - } - - protected void threadWorker1_DoWork(object sender, DoWorkEventArgs e) - { - if (threadWorker.CancellationPending) - { - return; - } - - List nodeList = parentForm.treeView1.GetBookmarkNodeList(); - - ThreadControl.SetValue(progressBar1, 0, nodeList.Count); - - for (int i=0; i { - parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel()); - })); - } - else - { - parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel()); - } - } - } - } - - protected void threadWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - this.IsBusy = false; - - ThreadControl.SetText(button2, "&Update"); - } - - protected override void OnClosing(CancelEventArgs e) - { - base.OnClosing(e); - - if (this.IsBusy) - { - e.Cancel = true; - } - } - - protected bool IsBusy - { - get => threadWorker.IsBusy; - set - { - pictureBox1.Image = (value) ? Resources.aniZomq2x32 : null; - } - } - - private void button1_Click(object sender, EventArgs e) - { - if (this.IsBusy) - { - ThreadControl.SetText(button2, "&Cancelling..."); - - threadWorker.CancelAsync(); - } - else - { - this.IsBusy = true; - - ThreadControl.SetText(button2, "&Updating..."); - - threadWorker.RunWorkerAsync(); - } - } - - private void button2_Click(object sender, EventArgs e) - { - if (this.IsBusy) - { - return; - } - - this.Close(); - } - - } -} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/ProgressBar.cs b/RyzStudio/Windows/ThemedForms/ProgressBar.cs index 6660601..ba55446 100644 --- a/RyzStudio/Windows/ThemedForms/ProgressBar.cs +++ b/RyzStudio/Windows/ThemedForms/ProgressBar.cs @@ -13,10 +13,13 @@ namespace RyzStudio.Windows.ThemedForms } public int Minimum { get => userControl1.Minimum; set => userControl1.Minimum = value; } + public int Maximum { get => userControl1.Maximum; set => userControl1.Maximum = value; } + public int Value { get => userControl1.Value; set => userControl1.Value = value; } public Color BarColour { get => userControl1.BarColour; set => userControl1.BarColour = value; } + public Color BarTextColour { get => userControl1.BarTextColour; set => userControl1.BarTextColour = value; } protected override void OnSizeChanged(EventArgs e) @@ -25,5 +28,6 @@ namespace RyzStudio.Windows.ThemedForms this.Invalidate(); } + } } diff --git a/OptionForm.Designer.cs b/UpdateIconsForm.Designer.cs similarity index 91% rename from OptionForm.Designer.cs rename to UpdateIconsForm.Designer.cs index cac19db..77af899 100644 --- a/OptionForm.Designer.cs +++ b/UpdateIconsForm.Designer.cs @@ -1,6 +1,6 @@ namespace bzit.bomg { - partial class OptionForm + partial class UpdateIconsForm { /// /// Required designer variable. @@ -57,7 +57,7 @@ namespace bzit.bomg this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox1.ErrorImage = null; this.pictureBox1.InitialImage = null; - this.pictureBox1.Location = new System.Drawing.Point(306, 237); + this.pictureBox1.Location = new System.Drawing.Point(112, 77); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(32, 32); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; @@ -69,25 +69,25 @@ namespace bzit.bomg this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.label5.ForeColor = System.Drawing.Color.OrangeRed; - this.label5.Location = new System.Drawing.Point(9, 237); + this.label5.Location = new System.Drawing.Point(9, 77); this.label5.Margin = new System.Windows.Forms.Padding(3); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(291, 32); + this.label5.Size = new System.Drawing.Size(97, 32); this.label5.TabIndex = 64; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // button1 // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button1.BackColor = System.Drawing.Color.Transparent; this.button1.DefaultImage = null; this.button1.DownImage = null; this.button1.LabelText = "&Update"; - this.button1.Location = new System.Drawing.Point(368, 59); + this.button1.Location = new System.Drawing.Point(150, 77); this.button1.Name = "button1"; this.button1.OverImage = null; this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.button1.Size = new System.Drawing.Size(84, 32); + this.button1.Size = new System.Drawing.Size(108, 32); this.button1.TabIndex = 1; this.button1.Click += new System.EventHandler(this.button1_Click); // @@ -98,7 +98,7 @@ namespace bzit.bomg this.button2.DefaultImage = null; this.button2.DownImage = null; this.button2.LabelText = "&Close"; - this.button2.Location = new System.Drawing.Point(344, 237); + this.button2.Location = new System.Drawing.Point(264, 77); this.button2.Name = "button2"; this.button2.OverImage = null; this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); @@ -110,11 +110,11 @@ namespace bzit.bomg // this.horizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.horizontalSeparator1.Location = new System.Drawing.Point(12, 222); + this.horizontalSeparator1.Location = new System.Drawing.Point(12, 62); this.horizontalSeparator1.Margin = new System.Windows.Forms.Padding(3, 10, 3, 10); this.horizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2); this.horizontalSeparator1.Name = "horizontalSeparator1"; - this.horizontalSeparator1.Size = new System.Drawing.Size(440, 2); + this.horizontalSeparator1.Size = new System.Drawing.Size(360, 2); this.horizontalSeparator1.TabIndex = 65; // // progressBar1 @@ -124,13 +124,13 @@ namespace bzit.bomg this.progressBar1.BackColor = System.Drawing.Color.Transparent; this.progressBar1.BarColour = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(225)))), ((int)(((byte)(249))))); this.progressBar1.BarTextColour = System.Drawing.SystemColors.ControlText; - this.progressBar1.Location = new System.Drawing.Point(96, 17); + this.progressBar1.Location = new System.Drawing.Point(96, 15); this.progressBar1.Margin = new System.Windows.Forms.Padding(3, 10, 3, 10); this.progressBar1.Maximum = 0; this.progressBar1.Minimum = 0; this.progressBar1.Name = "progressBar1"; this.progressBar1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.progressBar1.Size = new System.Drawing.Size(356, 29); + this.progressBar1.Size = new System.Drawing.Size(276, 32); this.progressBar1.TabIndex = 66; this.progressBar1.Value = 0; // @@ -138,7 +138,7 @@ namespace bzit.bomg // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(464, 281); + this.ClientSize = new System.Drawing.Size(384, 121); this.Controls.Add(this.progressBar1); this.Controls.Add(this.horizontalSeparator1); this.Controls.Add(this.label5); @@ -149,13 +149,12 @@ namespace bzit.bomg this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(480, 320); this.Name = "OptionForm"; this.ShowIcon = false; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Options"; + this.Text = "Update Icons"; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/UpdateIconsForm.cs b/UpdateIconsForm.cs new file mode 100644 index 0000000..46dde3b --- /dev/null +++ b/UpdateIconsForm.cs @@ -0,0 +1,177 @@ +using bzit.bomg.Models; +using RyzStudio.Windows.Forms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading.Tasks; +using System.Windows.Forms; +using Form = System.Windows.Forms.Form; +using Resources = bzit.bomg.Properties.Resources; + +namespace bzit.bomg +{ + public partial class UpdateIconsForm : Form + { + protected bool isBusy = false; + protected bool requestCancel = false; + protected BookmarkItemModel itemModel = null; + protected MainForm parentForm = null; + + public UpdateIconsForm(MainForm mainForm) : base() + { + InitializeComponent(); + + parentForm = mainForm; + + this.StartPosition = FormStartPosition.WindowsDefaultLocation; + } + + //protected void threadWorker1_DoWork(object sender, DoWorkEventArgs e) + //{ + // if (threadWorker.CancellationPending) + // { + // return; + // } + + // List nodeList = parentForm.treeView1.GetBookmarkNodeList(); + + // ThreadControl.SetValue(progressBar1, 0, nodeList.Count); + + // for (int i=0; i { + // parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel()); + // })); + // } + // else + // { + // parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel()); + // } + // } + // } + //} + + //protected void threadWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + //{ + // this.IsBusy = false; + + // ThreadControl.SetText(button1, "&Update"); + //} + + protected override void OnClosing(CancelEventArgs e) + { + base.OnClosing(e); + + if (this.IsBusy) + { + e.Cancel = true; + } + } + + protected bool IsBusy + { + get => isBusy; + set + { + isBusy = value; + ThreadControl.SetImage(pictureBox1, (value) ? Resources.aniZomq2x32 : null); + ThreadControl.SetEnable(button2, !value); + } + } + + private async void button1_Click(object sender, EventArgs e) + { + if (this.IsBusy) + { + requestCancel = true; + ThreadControl.SetText(button1, "&Cancelling..."); + return; + } + + this.IsBusy = true; + + await Task.Run(() => + { + ThreadControl.SetText(button1, "&Updating..."); + + if (requestCancel) + { + this.IsBusy = false; + + ThreadControl.SetText(button1, "&Update"); + + requestCancel = false; + return; + } + + List nodeList = parentForm.treeView1.GetBookmarkNodeList(); + + ThreadControl.SetValue(progressBar1, 0, nodeList.Count); + + for (int i = 0; i < nodeList.Count; i++) + { + if (requestCancel) + { + this.IsBusy = false; + + ThreadControl.SetText(button1, "&Update"); + + requestCancel = false; + return; + } + + ThreadControl.SetValue(progressBar1, (i + 1)); + + BookmarkItemViewModel viewModel = (BookmarkItemViewModel)nodeList[i].Tag; + BookmarkItemModel model = viewModel.ToModel(); + bool rv = model.UpdateFavicon(); + if (rv) + { + if (parentForm.treeView1.InvokeRequired) + { + parentForm.treeView1.Invoke(new MethodInvoker(() => + { + parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel()); + })); + } + else + { + parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel()); + } + } + } + + this.IsBusy = false; + + ThreadControl.SetText(button1, "&Update"); + + requestCancel = false; + }); + } + + private void button2_Click(object sender, EventArgs e) + { + if (this.IsBusy) + { + return; + } + + this.Close(); + } + + } +} \ No newline at end of file diff --git a/OptionForm.resx b/UpdateIconsForm.resx similarity index 100% rename from OptionForm.resx rename to UpdateIconsForm.resx diff --git a/bomg.csproj b/bomg.csproj index cacb1ac..76666bd 100644 --- a/bomg.csproj +++ b/bomg.csproj @@ -102,11 +102,11 @@ - + Form - - OptionForm.cs + + UpdateIconsForm.cs @@ -199,8 +199,8 @@ Component - - OptionForm.cs + + UpdateIconsForm.cs MemoBox.cs