diff --git a/AddBatchPageForm.cs b/AddBatchPageForm.cs deleted file mode 100644 index 5df9a1e..0000000 --- a/AddBatchPageForm.cs +++ /dev/null @@ -1,315 +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 _result = new List(); - private bool _requestCancel = false; - - - public AddBatchPageForm(string rootPath) - { - InitializeComponent(); - - UISetup.Dialog(this); - - _result = new List(); - - _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, 361); - 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, 433); - button3.Name = "button3"; - button3.Padding = new Padding(4, 4, 3, 3); - 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, 393); - progressBar2.Maximum = 100; - progressBar2.Minimum = 0; - progressBar2.Name = "progressBar2"; - progressBar2.Padding = new Padding(4, 4, 3, 3); - 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, 477); - 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.Padding = new Padding(4, 4, 3, 3); - memoBox1.ReadOnly = false; - memoBox1.ScrollBars = ScrollBars.Vertical; - memoBox1.Size = new System.Drawing.Size(424, 298); - 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, 561); - 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, 600); - 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 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(); - - 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 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; - } - - } -} \ No newline at end of file diff --git a/BookmarkManager.csproj b/BukkuBuddy.csproj similarity index 65% rename from BookmarkManager.csproj rename to BukkuBuddy.csproj index 217981c..35ef2d6 100644 --- a/BookmarkManager.csproj +++ b/BukkuBuddy.csproj @@ -2,7 +2,7 @@ WinExe - net8.0-windows8.0 + net10.0-windows8.0 true true favicon.ico @@ -14,7 +14,7 @@ Ray Lam 1.0.0.0 1.0.0.0 - 0.6.5.149 + 0.7.0.255 bukkubuddy True 8.0 @@ -38,7 +38,9 @@ - + + + @@ -46,7 +48,9 @@ - + + + @@ -54,17 +58,21 @@ - + + + - - + + + + @@ -80,6 +88,7 @@ + @@ -90,10 +99,13 @@ + + + @@ -101,30 +113,44 @@ - + True True - AppResource.resx + MainMenuResource.resx - + Form - - - + + Form + + + Form + + + + + True + True + TreeViewResource.resx + - + ResXFileCodeGenerator - AppResource.Designer.cs + MainMenuResource.Designer.cs + + + ResXFileCodeGenerator + TreeViewResource.Designer.cs - - - + + + \ No newline at end of file diff --git a/Models/BookmarkModel.cs b/DTOs/BookmarkModel.cs similarity index 100% rename from Models/BookmarkModel.cs rename to DTOs/BookmarkModel.cs diff --git a/DTOs/SaveFile/App4Options.cs b/DTOs/SaveFile/App4Options.cs new file mode 100644 index 0000000..e676463 --- /dev/null +++ b/DTOs/SaveFile/App4Options.cs @@ -0,0 +1,54 @@ +using System.Text; + +namespace BukkuBuddy.DTOs.SaveFile +{ + public class App4Options : AppOptionsBase + { + public class Item + { + public string SiteName { get; set; } + + public string SiteAddress { get; set; } + + public string SiteDescription { get; set; } + + public string TreeviewPath { get; set; } + + public string Notes { get; set; } + + + public string Path + { + get + { + if (string.IsNullOrWhiteSpace(TreeviewPath)) + { + return string.Empty; + } + + var path = this.TreeviewPath?.Trim('\\')?.Trim() ?? string.Empty; + if (!path.Contains("\\")) + { + return path?.Trim() ?? string.Empty; + } + + var sb = new StringBuilder(); + + var parts = path.Split("\\"); + for (var i = 1; i < parts.Length; i++) + { + var item = System.Web.HttpUtility.UrlDecode(parts[i]); + + sb.Append(item); + sb.Append("\n"); + } + + return sb.ToString()?.Trim() ?? string.Empty; + } + } + + } + + + } +} \ No newline at end of file diff --git a/DTOs/SaveFile/App6Options.cs b/DTOs/SaveFile/App6Options.cs new file mode 100644 index 0000000..74cff17 --- /dev/null +++ b/DTOs/SaveFile/App6Options.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using System.Text.Json.Serialization; + +namespace BukkuBuddy.DTOs.SaveFile +{ + public class App6Options : AppOptionsBase + { + public class Item + { + public Guid Id { get; set; } = Guid.NewGuid(); + + public string Title { get; set; } + + public string Address { get; set; } + + public string Description { get; set; } + + public string Path { get; set; } + + public string Notes { get; set; } + + [JsonIgnore] + public Image Icon { get; set; } + + + public new string ToString() + { + StringBuilder sb = new StringBuilder(); + + if (!string.IsNullOrWhiteSpace(this.Title)) + { + sb.AppendLine("Name"); + sb.AppendLine(this.Title + Environment.NewLine); + } + + if (!string.IsNullOrWhiteSpace(this.Address)) + { + sb.AppendLine("Address"); + sb.AppendLine(this.Address + Environment.NewLine); + } + + if (!string.IsNullOrWhiteSpace(this.Description)) + { + sb.AppendLine("Description"); + sb.AppendLine(this.Description + Environment.NewLine); + } + + if (!string.IsNullOrWhiteSpace(this.Notes)) + { + sb.AppendLine("Notes"); + sb.AppendLine(this.Notes + Environment.NewLine); + } + + return sb.ToString(); + } + + } + + + public new int FileVersion { get; set; } = 6; + + public bool RestorePosition { get; set; } = true; + + public bool AlwaysOnTop { get; set; } = false; + + public string RunCommand { get; set; } = "{0}"; + + public bool AllowUnsafeSSL { get; set; } = false; + + public bool AllowCookies { get; set; } = false; + + public bool AllowRedirects { get; set; } = true; + + public int Timeout { get; set; } = 6; + + public List Directories { get; set; } = new List(); + + public List Items { get; set; } = new List(); + + } +} \ No newline at end of file diff --git a/DTOs/SaveFile/AppOptionsBase.cs b/DTOs/SaveFile/AppOptionsBase.cs new file mode 100644 index 0000000..0369153 --- /dev/null +++ b/DTOs/SaveFile/AppOptionsBase.cs @@ -0,0 +1,16 @@ +using System.Drawing; + +namespace BukkuBuddy.DTOs.SaveFile +{ + public class AppOptionsBase + { + public int FileVersion { get; set; } = 0; + + public Point StartPosition { get; set; } = Point.Empty; + + public int Width { get; set; } = 0; + + public int Height { get; set; } = 320; + + } +} diff --git a/FindForm.cs b/FindForm.cs deleted file mode 100644 index ff00d2b..0000000 --- a/FindForm.cs +++ /dev/null @@ -1,257 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; -using bzit.bomg.Models; -using RyzStudio.Windows.Forms; -using RyzStudio.Windows.ThemedForms; -using RyzStudio.Windows.ThemedForms.ButtonTextBox; - -namespace FizzyLauncher -{ - public class FindForm : Form - { - private System.Windows.Forms.Label label1; - private ThButton button2; - private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator1; - private ThButton button1; - private ThClearableTextBox textBox1; - - - private BookmarkTreeView treeView1 = null; - private int findPosition = -1; - - - public FindForm(BookmarkTreeView treeView) - { - InitializeComponent(); - - this.MinimizeBox = false; - this.MaximizeBox = false; - this.ShowIcon = false; - this.ShowInTaskbar = true; - - treeView1 = treeView; - - textBox1.PreviewKeyDown += textBox1_PreviewKeyDown; - } - - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.button2 = new RyzStudio.Windows.ThemedForms.ThButton(); - this.tHorizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator(); - this.textBox1 = new ThClearableTextBox(); - this.button1 = new RyzStudio.Windows.ThemedForms.ThButton(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.BackColor = System.Drawing.Color.Transparent; - this.label1.ForeColor = System.Drawing.SystemColors.ControlText; - this.label1.Location = new System.Drawing.Point(10, 21); - this.label1.Margin = new System.Windows.Forms.Padding(0); - this.label1.Name = "label1"; - this.label1.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10); - this.label1.Size = new System.Drawing.Size(30, 34); - this.label1.TabIndex = 153; - this.label1.Text = "Find"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // button2 - // - this.button2.ActiveImage = null; - 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.HoverImage = null; - this.button2.IdleImage = null; - this.button2.LabelText = "&Next"; - this.button2.Location = new System.Drawing.Point(321, 99); - this.button2.Margin = new System.Windows.Forms.Padding(10, 0, 0, 10); - this.button2.Name = "button2"; - this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.button2.Size = new System.Drawing.Size(128, 32); - this.button2.TabIndex = 2; - this.button2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button2_MouseClick); - // - // tHorizontalSeparator1 - // - this.tHorizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tHorizontalSeparator1.AutoScrollMargin = new System.Drawing.Size(0, 0); - this.tHorizontalSeparator1.AutoScrollMinSize = new System.Drawing.Size(0, 0); - this.tHorizontalSeparator1.BackColor = System.Drawing.Color.Transparent; - this.tHorizontalSeparator1.Location = new System.Drawing.Point(10, 67); - this.tHorizontalSeparator1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 10); - this.tHorizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2); - this.tHorizontalSeparator1.MinimumSize = new System.Drawing.Size(0, 22); - this.tHorizontalSeparator1.Name = "tHorizontalSeparator1"; - this.tHorizontalSeparator1.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10); - this.tHorizontalSeparator1.Size = new System.Drawing.Size(444, 22); - this.tHorizontalSeparator1.TabIndex = 188; - this.tHorizontalSeparator1.TabStop = false; - // - // textBox1 - // - this.textBox1.AcceptButton = this.button2; - this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBox1.BackColor = System.Drawing.Color.Transparent; - this.textBox1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.textBox1.Location = new System.Drawing.Point(121, 20); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(328, 35); - this.textBox1.TabIndex = 0; - this.textBox1.UseSystemPasswordChar = false; - // - // button1 - // - this.button1.ActiveImage = null; - 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.HoverImage = null; - this.button1.IdleImage = null; - this.button1.LabelText = "&First"; - this.button1.Location = new System.Drawing.Point(185, 99); - this.button1.Margin = new System.Windows.Forms.Padding(10, 0, 0, 10); - this.button1.Name = "button1"; - this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.button1.Size = new System.Drawing.Size(128, 32); - this.button1.TabIndex = 1; - this.button1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button1_MouseClick); - // - // FindForm - // - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.ClientSize = new System.Drawing.Size(464, 151); - this.Controls.Add(this.button1); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.tHorizontalSeparator1); - this.Controls.Add(this.button2); - this.Controls.Add(this.label1); - this.MinimumSize = new System.Drawing.Size(480, 190); - this.Name = "FindForm"; - this.Text = "Find"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - protected override void OnShown(EventArgs e) - { - base.OnShown(e); - - textBox1.Focus(); - } - - - private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - switch (e.KeyCode) - { - case Keys.Enter: - if (findPosition < 0) - { - button1_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); - } - else - { - button2_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); - } - - break; - case Keys.Escape: - this.Close(); - break; - default: - break; - } - } - - /// - /// Find first. - /// - /// - /// - private void button1_MouseClick(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - if (string.IsNullOrWhiteSpace(textBox1.Text)) - { - return; - } - - if (treeView1.Nodes.Count <= 0) - { - return; - } - - findPosition = -1; - - var nodeList = treeView1.ToNodeList(); - - var node = nodeList.Where(x => x.Value.Title.Contains(textBox1.Text?.Trim())).Select(x => x.Key).FirstOrDefault(); - if (node != null) - { - findPosition = 0; - - treeView1.SelectedNode = node; - treeView1.SelectedNode.EnsureVisible(); - } - } - } - - /// - /// Find next. - /// - /// - /// - private void button2_MouseClick(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - if (string.IsNullOrWhiteSpace(textBox1.Text)) - { - return; - } - - if (treeView1.Nodes.Count <= 0) - { - return; - } - - if (treeView1.SelectedNode == null) - { - treeView1.SelectedNode = treeView1.Nodes[0]; - } - - var nodeList = treeView1.ToNodeList(); - - var node = nodeList.Where(x => x.Value.Title.Contains(textBox1.Text?.Trim())).Select(x => x.Key)?.ToList() ?? new List(); - if (node != null) - { - //var pos = nodeList.FindIndex(x => x.Key == treeView1.SelectedNode); - //if (pos < 0) - //{ - // findPosition = -1; - //} else { - // findPosition = pos; - //} - - findPosition++; - - if (findPosition >= node.Count) - { - findPosition = 0; - } - - treeView1.SelectedNode = node[findPosition]; - treeView1.SelectedNode.EnsureVisible(); - } - } - } - - } -} \ No newline at end of file diff --git a/FindForm.resx b/FindForm.resx deleted file mode 100644 index f298a7b..0000000 --- a/FindForm.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Forms/AddMultiPageForm.cs b/Forms/AddMultiPageForm.cs new file mode 100644 index 0000000..0677c02 --- /dev/null +++ b/Forms/AddMultiPageForm.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading.Tasks; +using System.Windows.Forms; +using BukkuBuddy.DTOs.SaveFile; +using BukkuBuddy.Services; +using RyzStudio.Windows.Forms; +using RyzStudio.Windows.ThemedForms; + +namespace BukkuBuddy.Forms +{ + public class AddMultiPageForm : Form + { + private Label label1; + private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1; + private ThToolbarMemoBox memoBox1; + private ThUserControl userControl1; + private TProgressBar progressBar1; + + private readonly WebPageService _webPageService; + private readonly string _rootPath; + + private List result = null; + private bool isBusy = false; + + + public AddMultiPageForm(string rootPath, App6Options options) + { + InitializeComponent(); + + UISetup.Dialog(this); + + _webPageService = new WebPageService(options.AllowUnsafeSSL, options.Timeout, options.AllowCookies, options.AllowRedirects); + _rootPath = rootPath; + } + + private void InitializeComponent() + { + label1 = new Label(); + dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter(); + memoBox1 = new ThToolbarMemoBox(); + userControl1 = new ThUserControl(); + progressBar1 = new TProgressBar(); + userControl1.SuspendLayout(); + 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(60, 23); + label1.TabIndex = 153; + label1.Text = "Addresses"; + label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // dialogFooter1 + // + dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240); + dialogFooter1.Dock = DockStyle.Bottom; + dialogFooter1.EnableMovable = false; + dialogFooter1.IsBusy = false; + dialogFooter1.Location = new System.Drawing.Point(0, 451); + dialogFooter1.Name = "dialogFooter1"; + dialogFooter1.Size = new System.Drawing.Size(384, 70); + dialogFooter1.TabIndex = 212; + dialogFooter1.TabStop = false; + dialogFooter1.OnButton1Click += dialogFooter1_OnButton1Click; + // + // memoBox1 + // + memoBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + memoBox1.BackColor = System.Drawing.Color.Transparent; + memoBox1.ClearedValue = ""; + memoBox1.EnableMovable = false; + memoBox1.Location = new System.Drawing.Point(95, 20); + memoBox1.Name = "memoBox1"; + memoBox1.ReadOnly = false; + memoBox1.ScrollBars = ScrollBars.Vertical; + memoBox1.Size = new System.Drawing.Size(280, 387); + memoBox1.TabIndex = 211; + memoBox1.TabStop = false; + memoBox1.WordWrap = false; + // + // userControl1 + // + userControl1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + userControl1.BackColor = System.Drawing.Color.Transparent; + userControl1.Controls.Add(progressBar1); + userControl1.EnableMovable = false; + userControl1.Location = new System.Drawing.Point(95, 417); + userControl1.Name = "userControl1"; + userControl1.Size = new System.Drawing.Size(280, 24); + userControl1.TabIndex = 214; + // + // progressBar1 + // + progressBar1.BarColour = System.Drawing.Color.FromArgb(190, 100, 242); + progressBar1.Dock = DockStyle.Fill; + progressBar1.EnableMovable = false; + progressBar1.Location = new System.Drawing.Point(3, 3); + progressBar1.Maximum = 100; + progressBar1.Minimum = 0; + progressBar1.Name = "progressBar1"; + progressBar1.OnProgressChanged = null; + progressBar1.ShowText = true; + progressBar1.Size = new System.Drawing.Size(274, 18); + progressBar1.TabIndex = 156; + progressBar1.Value = 25; + // + // AddBatchPageForm + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = System.Drawing.Color.White; + ClientSize = new System.Drawing.Size(384, 521); + Controls.Add(userControl1); + Controls.Add(memoBox1); + Controls.Add(dialogFooter1); + Controls.Add(label1); + KeyPreview = true; + MinimumSize = new System.Drawing.Size(400, 560); + Name = "AddBatchPageForm"; + Text = "Add Multiple Pages"; + userControl1.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + + memoBox1.Text = string.Empty; + + progressBar1.Minimum = 0; + progressBar1.Value = 0; + progressBar1.Maximum = 0; + + memoBox1.Focus(); + } + + protected override void OnFormClosing(FormClosingEventArgs e) + { + base.OnFormClosing(e); + + if (this.IsBusy) + { + e.Cancel = true; + } + } + + + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public List Result + { + get => result; + private set => result = value; + } + + + protected bool IsBusy + { + get => isBusy; + set + { + isBusy = value; + + UIControl.SetEnable(memoBox1, !isBusy); + + dialogFooter1.IsBusy = isBusy; + } + } + + + private async void dialogFooter1_OnButton1Click(object sender, MouseEventArgs e) + { + if (this.IsBusy) + { + return; + } + + this.IsBusy = true; + this.Result = new List(); + + await Task.Run(async () => + { + progressBar1.Value = 0; + progressBar1.Maximum = memoBox1.Lines?.Length ?? 0; + + foreach (var item in memoBox1.Lines ?? new string[0]) + { + progressBar1.Value++; + + if (string.IsNullOrWhiteSpace(item)) + { + continue; + } + + if (!_webPageService.IsValidUrl(item)) + { + continue; + } + + var newBookmark = await CreateApp6OptionsItem(item, _rootPath); + if (newBookmark == null) + { + continue; + } + + this.Result.Add(newBookmark); + } + }); + + this.IsBusy = false; + this.DialogResult = DialogResult.OK; + + this.Close(); + } + + private async Task CreateApp6OptionsItem(string url, string path) + { + if (!_webPageService.IsValidUrl(url)) + { + return null; + } + + HtmlAgilityPack.HtmlDocument htmlDocument = null; + + try + { + htmlDocument = await _webPageService.GetDocument(url); + } + catch (Exception exc) + { + MessageBox.Show(exc.Message, "Update Icon", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return null; + } + + if (htmlDocument == null) + { + return null; + } + + var response = new App6Options.Item(); + response.Address = url; + response.Path = path; + response.Title = _webPageService.ParseTitle(htmlDocument) ?? string.Empty; + response.Description = _webPageService.ParseDescription(htmlDocument) ?? string.Empty; + + var faviconUrl = _webPageService.ParseFavicon(htmlDocument); + if (!string.IsNullOrWhiteSpace(faviconUrl)) + { + var favicon = await _webPageService.GetImage(faviconUrl); + if (favicon != null) + { + if (favicon.Width > 16) + { + favicon = RyzStudio.Drawing.ImageEditor.Resize(favicon, 16, 16); + } + } + + response.Icon = favicon; + } + + return response; + } + + } +} \ No newline at end of file diff --git a/AddBatchPageForm.resx b/Forms/AddMultiPageForm.resx similarity index 100% rename from AddBatchPageForm.resx rename to Forms/AddMultiPageForm.resx diff --git a/Forms/ClearIconsForm.cs b/Forms/ClearIconsForm.cs new file mode 100644 index 0000000..e008e56 --- /dev/null +++ b/Forms/ClearIconsForm.cs @@ -0,0 +1,161 @@ +using System; +using System.Drawing; +using System.Threading.Tasks; +using System.Windows.Forms; +using BukkuBuddy.DTOs.SaveFile; +using RyzStudio.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace BukkuBuddy.Forms +{ + public class ClearIconsForm : Form + { + private TProgressBar progressBar1; + private RyzStudio.Windows.ThemedForms.ThUserControl userControl1; + private Label label1; + private Label label2; + + private readonly BookmarkTreeView _treeView = null; + + + public ClearIconsForm(BookmarkTreeView treeView) + { + InitializeComponent(); + + UISetup.Dialog(this, true); + + this.Text = "Deleting Icons"; + + _treeView = treeView; + } + + + private void InitializeComponent() + { + progressBar1 = new TProgressBar(); + userControl1 = new RyzStudio.Windows.ThemedForms.ThUserControl(); + label1 = new Label(); + label2 = new Label(); + userControl1.SuspendLayout(); + SuspendLayout(); + // + // progressBar1 + // + progressBar1.BarColour = Color.FromArgb(25, 104, 218); + progressBar1.Dock = DockStyle.Fill; + progressBar1.EnableMovable = false; + progressBar1.Location = new Point(3, 3); + progressBar1.Maximum = 100; + progressBar1.Minimum = 0; + progressBar1.Name = "progressBar1"; + progressBar1.OnProgressChanged = null; + progressBar1.ShowText = true; + progressBar1.Size = new Size(418, 18); + progressBar1.TabIndex = 156; + progressBar1.Value = 25; + // + // userControl1 + // + userControl1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + userControl1.BackColor = Color.Transparent; + userControl1.Controls.Add(progressBar1); + userControl1.EnableMovable = false; + userControl1.Location = new Point(10, 64); + userControl1.Name = "userControl1"; + userControl1.Size = new Size(424, 24); + userControl1.TabIndex = 157; + // + // label1 + // + label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label1.AutoEllipsis = true; + label1.Location = new Point(10, 20); + label1.Name = "label1"; + label1.Size = new Size(424, 15); + label1.TabIndex = 159; + // + // label2 + // + label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label2.AutoEllipsis = true; + label2.Location = new Point(10, 40); + label2.Name = "label2"; + label2.Size = new Size(424, 15); + label2.TabIndex = 160; + // + // ClearIconsForm + // + BackColor = Color.White; + ClientSize = new Size(444, 117); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(userControl1); + Name = "ClearIconsForm"; + Text = "Clear Icons"; + userControl1.ResumeLayout(false); + ResumeLayout(false); + } + + protected async override void OnShown(EventArgs e) + { + base.OnShown(e); + + await Task.Run(async () => + { + this.Clear(); + + var model = _treeView.ToNodeList(); + + // Update progress bars + progressBar1.Maximum = model.Count; + progressBar1.Value = 0; + + UIControl.SetText(label1, "Deleting..."); + UIControl.SetText(label2, ""); + + foreach (var item in model) + { + UIControl.SetText(label2, "... " + item.Value.Title); + + progressBar1.Value++; + + if (item.Value.Icon == null) + { + continue; + } + + var newModel = item.Value; + newModel.Icon = null; + + _treeView.UpdateNode(item.Key, newModel); + } + + _treeView.Clear(false, true); + + UIControl.SetText(label1, ""); + UIControl.SetText(label2, "Done"); + }); + + this.DialogResult = DialogResult.OK; + } + + protected override void OnFormClosing(FormClosingEventArgs e) + { + base.OnFormClosing(e); + + if (this.DialogResult != DialogResult.OK) + { + e.Cancel = true; + } + } + + public void Clear() + { + UIControl.SetText(label1, "Ready"); + UIControl.SetText(label2, ""); + + progressBar1.Value = progressBar1.Maximum = 0; + } + + } +} \ No newline at end of file diff --git a/OptionsForm.resx b/Forms/ClearIconsForm.resx similarity index 100% rename from OptionsForm.resx rename to Forms/ClearIconsForm.resx diff --git a/EditBookmarkForm.cs b/Forms/EditBookmarkForm.cs similarity index 53% rename from EditBookmarkForm.cs rename to Forms/EditBookmarkForm.cs index 69f8310..eae135a 100644 --- a/EditBookmarkForm.cs +++ b/Forms/EditBookmarkForm.cs @@ -3,39 +3,37 @@ 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 BukkuBuddy.DTOs.SaveFile; +using BukkuBuddy.Services; +using RyzStudio; using RyzStudio.Windows.Forms; using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms.ButtonTextBox; -namespace FizzyLauncher +namespace BukkuBuddy.Forms { public class EditBookmarkForm : Form { - private System.Windows.Forms.Label label1; + private Label label1; private ThClearableTextBox textBox1; private Label label2; private Label label3; private ThToolbarMemoBox memoBox1; private Label label4; - private ThHiButtonTextBox textBox2; + private ThIconButtonTextBox textBox2; private PictureBox pictureBox1; - private ToolTip toolTip1; private System.ComponentModel.IContainer components; private ThClearableTextBox textBox3; - private ThUserControl thUserControl1; - - - private readonly WebProvider _webProvider; - private BookmarkModel result = null; private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1; - private THorizontalSeparator tHorizontalSeparator1; - private bool _isBusy = false; + private THorizontalSeparator horizontalSeparator1; + + private readonly WebPageService _webPageService; + + private bool isBusy = false; + private App6Options.Item result = null; - public EditBookmarkForm(BookmarkModel model = null) + public EditBookmarkForm(App6Options.Item model, App6Options options) { InitializeComponent(); @@ -45,34 +43,7 @@ namespace FizzyLauncher result = model; - _webProvider = new WebProvider(); - _webProvider.IgnoreSSL = true; - - if (result != null) - { - textBox1.Text = model.Title?.Trim() ?? string.Empty; - textBox2.Text = model.Address?.Trim() ?? string.Empty; - textBox3.Text = model.Description?.Trim() ?? string.Empty; - - 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; - } - - memoBox1.Text = model.Notes?.Trim() ?? string.Empty; - } + _webPageService = new WebPageService(options.AllowUnsafeSSL, options.Timeout, options.AllowCookies, options.AllowRedirects); } private void InitializeComponent() @@ -84,21 +55,20 @@ namespace FizzyLauncher label3 = new Label(); memoBox1 = new ThToolbarMemoBox(); label4 = new Label(); - textBox2 = new ThHiButtonTextBox(); + textBox2 = new ThIconButtonTextBox(); pictureBox1 = new PictureBox(); - toolTip1 = new ToolTip(components); textBox3 = new ThClearableTextBox(); dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter(); - tHorizontalSeparator1 = new THorizontalSeparator(); + horizontalSeparator1 = new THorizontalSeparator(); ((ISupportInitialize)pictureBox1).BeginInit(); SuspendLayout(); - // + // // label1 - // + // label1.AutoSize = true; label1.BackColor = Color.Transparent; label1.ForeColor = SystemColors.ControlText; - label1.Location = new Point(9, 21); + label1.Location = new Point(10, 20); label1.Margin = new Padding(0); label1.Name = "label1"; label1.Padding = new Padding(0, 8, 0, 0); @@ -106,26 +76,24 @@ namespace FizzyLauncher label1.TabIndex = 153; label1.Text = "Title"; label1.TextAlign = ContentAlignment.MiddleLeft; - // + // // textBox1 - // + // textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; textBox1.BackColor = Color.Transparent; textBox1.ClearedValue = ""; - textBox1.EnableReactiveVisual = true; - textBox1.Font = new Font("Segoe UI", 9F); + textBox1.EnableMovable = false; textBox1.Icon = "O"; textBox1.IconSize = 13F; - textBox1.Location = new Point(115, 20); + textBox1.Location = new Point(95, 20); textBox1.Name = "textBox1"; - textBox1.Padding = new Padding(4, 4, 3, 3); - textBox1.Size = new Size(314, 32); + textBox1.Size = new Size(280, 32); textBox1.TabIndex = 0; textBox1.TabStop = false; textBox1.UseSystemPasswordChar = false; - // + // // label2 - // + // label2.AutoSize = true; label2.BackColor = Color.Transparent; label2.ForeColor = SystemColors.ControlText; @@ -137,9 +105,9 @@ namespace FizzyLauncher label2.TabIndex = 193; label2.Text = "Address"; label2.TextAlign = ContentAlignment.MiddleLeft; - // + // // label3 - // + // label3.AutoSize = true; label3.BackColor = Color.Transparent; label3.ForeColor = SystemColors.ControlText; @@ -151,31 +119,28 @@ namespace FizzyLauncher label3.TabIndex = 195; label3.Text = "Description"; label3.TextAlign = ContentAlignment.MiddleLeft; - // + // // memoBox1 - // - memoBox1.AllowDrop = true; + // memoBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; memoBox1.BackColor = Color.Transparent; memoBox1.ClearedValue = ""; - memoBox1.EnableReactiveVisual = true; - memoBox1.Font = new Font("Segoe UI", 9F); - memoBox1.Location = new Point(87, 166); + memoBox1.EnableMovable = false; + memoBox1.Location = new Point(95, 158); memoBox1.Name = "memoBox1"; - memoBox1.Padding = new Padding(4, 4, 3, 3); memoBox1.ReadOnly = false; memoBox1.ScrollBars = ScrollBars.Vertical; - memoBox1.Size = new Size(342, 302); + memoBox1.Size = new Size(280, 283); memoBox1.TabIndex = 3; memoBox1.TabStop = false; memoBox1.WordWrap = false; - // + // // label4 - // + // label4.AutoSize = true; label4.BackColor = Color.Transparent; label4.ForeColor = SystemColors.ControlText; - label4.Location = new Point(9, 166); + label4.Location = new Point(10, 158); label4.Margin = new Padding(0); label4.Name = "label4"; label4.Padding = new Padding(0, 8, 0, 0); @@ -183,30 +148,28 @@ namespace FizzyLauncher label4.TabIndex = 198; label4.Text = "Notes"; label4.TextAlign = ContentAlignment.MiddleLeft; - // + // // textBox2 - // + // textBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; textBox2.BackColor = Color.Transparent; - textBox2.EnableReactiveVisual = true; - textBox2.Font = new Font("Segoe UI", 9F); + textBox2.EnableMovable = false; textBox2.Icon = "M"; textBox2.IconSize = 13F; - textBox2.Location = new Point(98, 62); + textBox2.Location = new Point(115, 62); textBox2.Name = "textBox2"; - textBox2.Padding = new Padding(4, 4, 3, 3); - textBox2.Size = new Size(331, 32); + textBox2.Size = new Size(260, 32); textBox2.TabIndex = 1; textBox2.TabStop = false; textBox2.UseSystemPasswordChar = false; textBox2.OnButtonClick += textBox2_OnButtonClick; - // + // // pictureBox1 - // + // pictureBox1.BackColor = Color.White; pictureBox1.ErrorImage = null; pictureBox1.InitialImage = null; - pictureBox1.Location = new Point(78, 20); + pictureBox1.Location = new Point(61, 20); pictureBox1.Name = "pictureBox1"; pictureBox1.Size = new Size(32, 32); pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; @@ -214,55 +177,48 @@ namespace FizzyLauncher pictureBox1.TabStop = false; pictureBox1.MouseClick += pictureBox1_MouseClick; pictureBox1.MouseDoubleClick += pictureBox1_MouseDoubleClick; - // + // // textBox3 - // + // textBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; textBox3.BackColor = Color.Transparent; textBox3.ClearedValue = ""; - textBox3.EnableReactiveVisual = true; - textBox3.Font = new Font("Segoe UI", 9F); + textBox3.EnableMovable = false; textBox3.Icon = "O"; textBox3.IconSize = 13F; - textBox3.Location = new Point(116, 104); + textBox3.Location = new Point(115, 104); textBox3.Name = "textBox3"; - textBox3.Padding = new Padding(4, 4, 3, 3); - textBox3.Size = new Size(313, 32); + textBox3.Size = new Size(260, 32); textBox3.TabIndex = 203; textBox3.TabStop = false; textBox3.UseSystemPasswordChar = false; - // + // // dialogFooter1 - // + // dialogFooter1.BackColor = Color.FromArgb(240, 240, 240); - dialogFooter1.Button1Text = "&OK"; - dialogFooter1.Dialog = this; dialogFooter1.Dock = DockStyle.Bottom; + dialogFooter1.EnableMovable = false; dialogFooter1.IsBusy = false; - dialogFooter1.Location = new Point(0, 477); + dialogFooter1.Location = new Point(0, 451); dialogFooter1.Name = "dialogFooter1"; - dialogFooter1.Size = new Size(444, 84); - // - // tHorizontalSeparator1 - // - tHorizontalSeparator1.AutoScrollMargin = new Size(0, 0); - tHorizontalSeparator1.AutoScrollMinSize = new Size(0, 0); - tHorizontalSeparator1.BackColor = Color.Transparent; - tHorizontalSeparator1.Location = new Point(9, 139); - tHorizontalSeparator1.MaximumSize = new Size(3840, 22); - tHorizontalSeparator1.MinimumSize = new Size(0, 22); - tHorizontalSeparator1.Name = "tHorizontalSeparator1"; - tHorizontalSeparator1.Size = new Size(423, 22); - tHorizontalSeparator1.TabIndex = 209; - tHorizontalSeparator1.TabStop = false; - // + dialogFooter1.Size = new Size(384, 70); + dialogFooter1.TabIndex = 210; + dialogFooter1.TabStop = false; + // + // horizontalSeparator1 + // + horizontalSeparator1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + horizontalSeparator1.Location = new Point(5, 141); + horizontalSeparator1.Name = "horizontalSeparator1"; + horizontalSeparator1.Size = new Size(375, 10); + // // EditBookmarkForm - // + // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.White; - ClientSize = new Size(444, 561); - Controls.Add(tHorizontalSeparator1); + ClientSize = new Size(384, 521); + Controls.Add(horizontalSeparator1); Controls.Add(pictureBox1); Controls.Add(dialogFooter1); Controls.Add(textBox3); @@ -274,7 +230,7 @@ namespace FizzyLauncher Controls.Add(textBox1); Controls.Add(label1); KeyPreview = true; - MinimumSize = new Size(460, 600); + MinimumSize = new Size(400, 560); Name = "EditBookmarkForm"; Text = "Edit Bookmark"; ((ISupportInitialize)pictureBox1).EndInit(); @@ -286,12 +242,37 @@ namespace FizzyLauncher { base.OnShown(e); + textBox1.Text = result?.Title?.Trim() ?? string.Empty; + textBox2.Text = result?.Address?.Trim() ?? string.Empty; + textBox3.Text = result?.Description?.Trim() ?? string.Empty; + memoBox1.Text = result?.Notes?.Trim() ?? string.Empty; + + if (result != null) + { + try + { + if (result.Icon != null) + { + if (result.Icon.Width > 16) + { + result.Icon = RyzStudio.Drawing.ImageEditor.Resize(result.Icon, 16, 16); + } + } + + pictureBox1.Image = result.Icon; + } + catch (Exception) + { + pictureBox1.Image = result.Icon = null; + } + } + textBox2.Focus(); } - protected override void OnClosing(CancelEventArgs e) + protected override void OnFormClosing(FormClosingEventArgs e) { - base.OnClosing(e); + base.OnFormClosing(e); if (this.IsBusy) { @@ -299,13 +280,14 @@ namespace FizzyLauncher } } - public BookmarkModel Result + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public App6Options.Item Result { get { if (result == null) { - result = new BookmarkModel(); + result = new App6Options.Item(); } result.Title = textBox1.Text?.Trim() ?? string.Empty; @@ -329,50 +311,90 @@ namespace FizzyLauncher protected bool IsBusy { - get => _isBusy; + get => isBusy; set { - _isBusy = value; + isBusy = value; - UIControl.SetEnable(textBox1, !this.IsBusy); - UIControl.SetEnable(textBox2, !this.IsBusy); - UIControl.SetEnable(textBox3, !this.IsBusy); - dialogFooter1.IsBusy = _isBusy; - UIControl.SetEnable(memoBox1, !this.IsBusy); + UIControl.SetEnable(textBox1, !isBusy); + UIControl.SetEnable(textBox2, !isBusy); + UIControl.SetEnable(textBox3, !isBusy); + UIControl.SetEnable(memoBox1, !isBusy); + dialogFooter1.IsBusy = isBusy; } } - private async void textBox2_OnButtonClick(object sender, EventArgs e) - { - await InvalidateWebPage(textBox2.Text, true, true, true); - - textBox2.Focus(); - } - + /// + /// Retrieve favicon + /// + /// + /// 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 (this.IsBusy) { return; } + if (e.Button == MouseButtons.Left) + { + if (string.IsNullOrWhiteSpace(textBox2.Text)) + { + return; + } + + DialogResult result = DialogResult.Yes; + + if (pictureBox1.Image != null) + { + result = MessageBox.Show("Do you want to (try to) retrieve the favicon?", "Retrieve Favicon", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + } + + if (result == DialogResult.Yes) + { + await Task.Run(async () => + { + this.IsBusy = true; + + var image = await GetFavicon(textBox2.Text); + + UIControl.SetImage(pictureBox1, image); + + this.IsBusy = false; + }); + } + } + } + + /// + /// Clear favicon + /// + /// + /// + private void pictureBox1_MouseClick(object sender, MouseEventArgs e) + { + if (this.IsBusy) + { + return; + } + + if (e.Button == MouseButtons.Right) + { + if (pictureBox1.Image == null) + { + return; + } + + //if (MessageBox.Show("Are you sure you want to clear the favicon?", "Clear Favicon", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + //{ + pictureBox1.Image = null; + //} + } + } + + private async void textBox2_OnButtonClick(object sender, EventArgs e) + { if (this.IsBusy) { return; @@ -380,48 +402,110 @@ namespace FizzyLauncher this.IsBusy = true; - if (!url.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !url.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)) + await Task.Run(async () => { - url = "http://" + url; - } - - var document = await _webProvider.RetrieveHtmlDocument(url); - if (document == null) - { - this.IsBusy = false; - return; - } - - if (updateTitle) - { - textBox1.Text = _webProvider.ParseTitle(document); - } - - if (updateDescription) - { - textBox3.Text = _webProvider.ParseDescription(document); - } - - if (updateIcon) - { - try + var result = await UpdateBookmarkInfo(textBox2.Text); + if (!result.Success) { - 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); - } - } + MessageBox.Show(result.Message, "Update Bookmark", MessageBoxButtons.OK, MessageBoxIcon.Error); } - catch (Exception) - { - pictureBox1.Image = null; - } - } + }); this.IsBusy = false; + + textBox2.Focus(); + } + + private async Task GetFavicon(string url) + { + if (!_webPageService.IsValidUrl(url)) + { + return null; + } + + HtmlAgilityPack.HtmlDocument htmlDocument = null; + + try + { + htmlDocument = await _webPageService.GetDocument(url); + } + catch (Exception exc) + { + MessageBox.Show(exc.Message, "Update Icon", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return null; + } + + if (htmlDocument == null) + { + return null; + } + + var faviconUrl = _webPageService.ParseFavicon(htmlDocument); + if (string.IsNullOrWhiteSpace(faviconUrl)) + { + return null; + } + + var favicon = await _webPageService.GetImage(faviconUrl); + if (favicon != null) + { + if (favicon.Width > 16) + { + favicon = RyzStudio.Drawing.ImageEditor.Resize(favicon, 16, 16); + } + } + + return favicon; + } + + private async Task UpdateBookmarkInfo(string url) + { + if (!_webPageService.IsValidUrl(url)) + { + return MethodResult.Error("Invalid URL."); + } + + HtmlAgilityPack.HtmlDocument htmlDocument = null; + + try + { + htmlDocument = await _webPageService.GetDocument(url); + } + catch (Exception exc) + { + MessageBox.Show(exc.Message, "Update Icon", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return MethodResult.Error(exc.Message); + } + + if (htmlDocument == null) + { + return null; + } + + var title = _webPageService.ParseTitle(htmlDocument) ?? string.Empty; + var description = _webPageService.ParseDescription(htmlDocument) ?? string.Empty; + + UIControl.SetText(textBox1, title); + UIControl.SetText(textBox3, description); + + var faviconUrl = _webPageService.ParseFavicon(htmlDocument); + if (!string.IsNullOrWhiteSpace(faviconUrl)) + { + var favicon = await _webPageService.GetImage(faviconUrl); + if (favicon != null) + { + if (favicon.Width > 16) + { + favicon = RyzStudio.Drawing.ImageEditor.Resize(favicon, 16, 16); + } + } + + UIControl.SetImage(pictureBox1, favicon); + } + + return MethodResult.Create(); } } diff --git a/EditBookmarkForm.resx b/Forms/EditBookmarkForm.resx similarity index 100% rename from EditBookmarkForm.resx rename to Forms/EditBookmarkForm.resx diff --git a/Forms/FindForm.cs b/Forms/FindForm.cs new file mode 100644 index 0000000..5777258 --- /dev/null +++ b/Forms/FindForm.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using BukkuBuddy.DTOs.SaveFile; +using RyzStudio.Windows.Forms; +using RyzStudio.Windows.ThemedForms; +using RyzStudio.Windows.ThemedForms.ButtonTextBox; + +namespace BukkuBuddy.Forms +{ + public class FindForm : Form + { + private Label label1; + private ThButton button2; + private THorizontalSeparator horizontalSeparator1; + private ThButton button1; + private ThClearableTextBox textBox1; + + + private BookmarkTreeView treeView1 = null; + private int findPosition = -1; + + + public FindForm(BookmarkTreeView treeView) + { + InitializeComponent(); + + this.MinimizeBox = false; + this.MaximizeBox = false; + this.ShowIcon = false; + this.ShowInTaskbar = true; + + treeView1 = treeView; + + textBox1.PreviewKeyDown += textBox1_PreviewKeyDown; + } + + private void InitializeComponent() + { + label1 = new Label(); + button2 = new ThButton(); + horizontalSeparator1 = new THorizontalSeparator(); + textBox1 = new ThClearableTextBox(); + button1 = new ThButton(); + 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, 9, 0, 10); + label1.Size = new System.Drawing.Size(30, 34); + label1.TabIndex = 153; + label1.Text = "Find"; + label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // button2 + // + button2.ActiveImage = null; + button2.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + button2.BackColor = System.Drawing.Color.Transparent; + button2.EnableMenuOnClick = false; + button2.EnableMovable = false; + button2.HoverImage = null; + button2.IdleImage = null; + // + // + // + button2.Label.BackColor = System.Drawing.Color.White; + button2.Label.Dock = DockStyle.Fill; + button2.Label.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + button2.Label.ForeColor = System.Drawing.Color.FromArgb(126, 54, 244); + button2.Label.Location = new System.Drawing.Point(4, 4); + button2.Label.Margin = new Padding(0); + button2.Label.Name = "label1"; + button2.Label.Size = new System.Drawing.Size(121, 25); + button2.Label.TabIndex = 0; + button2.Label.Text = "&Next"; + button2.Label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + button2.LabelText = "&Next"; + button2.Location = new System.Drawing.Point(246, 94); + button2.Name = "button2"; + button2.Size = new System.Drawing.Size(128, 32); + button2.TabIndex = 2; + button2.TabStop = false; + button2.MouseClick += button2_MouseClick; + button2.MouseDoubleClick += button2_MouseClick; + // + // horizontalSeparator1 + // + horizontalSeparator1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + horizontalSeparator1.Location = new System.Drawing.Point(5, 73); + horizontalSeparator1.Name = "horizontalSeparator1"; + horizontalSeparator1.Padding = new Padding(0, 10, 0, 10); + horizontalSeparator1.Size = new System.Drawing.Size(375, 10); + // + // textBox1 + // + textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBox1.BackColor = System.Drawing.Color.Transparent; + textBox1.ClearedValue = ""; + textBox1.EnableMovable = false; + textBox1.Icon = "O"; + textBox1.IconSize = 13F; + textBox1.Location = new System.Drawing.Point(95, 20); + textBox1.Name = "textBox1"; + textBox1.Size = new System.Drawing.Size(280, 32); + textBox1.TabIndex = 0; + textBox1.TabStop = false; + textBox1.UseSystemPasswordChar = false; + // + // button1 + // + button1.ActiveImage = null; + button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + button1.BackColor = System.Drawing.Color.Transparent; + button1.EnableMenuOnClick = false; + button1.EnableMovable = false; + button1.HoverImage = null; + button1.IdleImage = null; + // + // + // + button1.Label.BackColor = System.Drawing.Color.White; + button1.Label.Dock = DockStyle.Fill; + button1.Label.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + button1.Label.ForeColor = System.Drawing.Color.FromArgb(126, 54, 244); + button1.Label.Location = new System.Drawing.Point(4, 4); + button1.Label.Margin = new Padding(0); + button1.Label.Name = "label1"; + button1.Label.Size = new System.Drawing.Size(121, 25); + button1.Label.TabIndex = 0; + button1.Label.Text = "&First"; + button1.Label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + button1.LabelText = "&First"; + button1.Location = new System.Drawing.Point(110, 94); + button1.Name = "button1"; + button1.Size = new System.Drawing.Size(128, 32); + button1.TabIndex = 1; + button1.TabStop = false; + button1.MouseClick += button1_MouseClick; + button1.MouseDoubleClick += button1_MouseClick; + // + // FindForm + // + AutoScaleMode = AutoScaleMode.None; + ClientSize = new System.Drawing.Size(384, 141); + Controls.Add(button1); + Controls.Add(textBox1); + Controls.Add(horizontalSeparator1); + Controls.Add(button2); + Controls.Add(label1); + MinimumSize = new System.Drawing.Size(400, 168); + Name = "FindForm"; + Text = "Find"; + ResumeLayout(false); + PerformLayout(); + + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + + textBox1.Focus(); + } + + + private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Enter: + if (findPosition < 0) + { + button1_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + } + else + { + button2_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + } + + break; + case Keys.Escape: + this.Close(); + break; + default: + break; + } + } + + /// + /// Find first. + /// + /// + /// + private void button1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (string.IsNullOrWhiteSpace(textBox1.Text)) + { + return; + } + + if (treeView1.Nodes.Count <= 0) + { + return; + } + + findPosition = -1; + + var nodeList = treeView1.ToNodeList(); + + var node = nodeList.Where(x => x.Value.Title.Contains(textBox1.Text?.Trim())).Select(x => x.Key).FirstOrDefault(); + if (node != null) + { + findPosition = 0; + + treeView1.SelectedNode = node; + treeView1.SelectedNode.EnsureVisible(); + } + } + } + + /// + /// Find next. + /// + /// + /// + private void button2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (string.IsNullOrWhiteSpace(textBox1.Text)) + { + return; + } + + if (treeView1.Nodes.Count <= 0) + { + return; + } + + if (treeView1.SelectedNode == null) + { + treeView1.SelectedNode = treeView1.Nodes[0]; + } + + var nodeList = treeView1.ToNodeList(); + + var node = nodeList.Where(x => x.Value.Title.Contains(textBox1.Text?.Trim())).Select(x => x.Key)?.ToList() ?? new List(); + if (node != null) + { + //var pos = nodeList.FindIndex(x => x.Key == treeView1.SelectedNode); + //if (pos < 0) + //{ + // findPosition = -1; + //} else { + // findPosition = pos; + //} + + findPosition++; + + if (findPosition >= node.Count) + { + findPosition = 0; + } + + treeView1.SelectedNode = node[findPosition]; + treeView1.SelectedNode.EnsureVisible(); + } + } + } + + } +} \ No newline at end of file diff --git a/UpdateIconsForm.resx b/Forms/FindForm.resx similarity index 100% rename from UpdateIconsForm.resx rename to Forms/FindForm.resx diff --git a/Forms/LoadingForm.cs b/Forms/LoadingForm.cs new file mode 100644 index 0000000..6c28c06 --- /dev/null +++ b/Forms/LoadingForm.cs @@ -0,0 +1,360 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.IO.Compression; +using System.Threading.Tasks; +using System.Windows.Forms; +using BukkuBuddy.DTOs.SaveFile; +using RyzStudio.Windows.Forms; +using static RyzStudio.Windows.Forms.BookmarkTreeView; + +namespace BukkuBuddy.Forms +{ + public class LoadingForm : Form + { + private TProgressBar progressBar1; + private RyzStudio.Windows.ThemedForms.ThUserControl userControl1; + private RyzStudio.Windows.ThemedForms.ThUserControl userControl2; + private TProgressBar progressBar2; + private Label label1; + private Label label2; + + private App6Options result = null; + + private string loadFilename = ""; + private BookmarkTreeView treeView = null; + + + public LoadingForm() + { + InitializeComponent(); + + UISetup.Dialog(this, true); + + this.Text = "Loading"; + } + + + private void InitializeComponent() + { + progressBar1 = new TProgressBar(); + userControl1 = new RyzStudio.Windows.ThemedForms.ThUserControl(); + userControl2 = new RyzStudio.Windows.ThemedForms.ThUserControl(); + progressBar2 = new TProgressBar(); + label1 = new Label(); + label2 = new Label(); + userControl1.SuspendLayout(); + userControl2.SuspendLayout(); + SuspendLayout(); + // + // progressBar1 + // + progressBar1.BarColour = Color.FromArgb(191, 102, 243); + progressBar1.Dock = DockStyle.Fill; + progressBar1.EnableMovable = false; + progressBar1.Location = new Point(3, 3); + progressBar1.Maximum = 100; + progressBar1.Minimum = 0; + progressBar1.Name = "progressBar1"; + progressBar1.OnProgressChanged = null; + progressBar1.ShowText = true; + progressBar1.Size = new Size(418, 18); + progressBar1.TabIndex = 156; + progressBar1.Value = 25; + // + // userControl1 + // + userControl1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + userControl1.BackColor = Color.Transparent; + userControl1.Controls.Add(progressBar1); + userControl1.EnableMovable = false; + userControl1.Location = new Point(10, 64); + userControl1.Name = "userControl1"; + userControl1.Size = new Size(424, 24); + userControl1.TabIndex = 157; + // + // userControl2 + // + userControl2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + userControl2.BackColor = Color.Transparent; + userControl2.Controls.Add(progressBar2); + userControl2.EnableMovable = false; + userControl2.Location = new Point(10, 98); + userControl2.Name = "userControl2"; + userControl2.Size = new Size(424, 24); + userControl2.TabIndex = 158; + // + // progressBar2 + // + progressBar2.BarColour = Color.FromArgb(25, 104, 218); + progressBar2.Dock = DockStyle.Fill; + progressBar2.EnableMovable = false; + progressBar2.Location = new Point(3, 3); + progressBar2.Maximum = 100; + progressBar2.Minimum = 0; + progressBar2.Name = "progressBar2"; + progressBar2.OnProgressChanged = null; + progressBar2.ShowText = true; + progressBar2.Size = new Size(418, 18); + progressBar2.TabIndex = 156; + progressBar2.Value = 25; + // + // label1 + // + label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label1.AutoEllipsis = true; + label1.Location = new Point(10, 20); + label1.Name = "label1"; + label1.Size = new Size(424, 15); + label1.TabIndex = 159; + // + // label2 + // + label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label2.AutoEllipsis = true; + label2.Location = new Point(10, 40); + label2.Name = "label2"; + label2.Size = new Size(424, 15); + label2.TabIndex = 160; + // + // LoadingForm + // + BackColor = Color.White; + ClientSize = new Size(444, 141); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(userControl2); + Controls.Add(userControl1); + Name = "LoadingForm"; + Text = "Edit Section"; + userControl1.ResumeLayout(false); + userControl2.ResumeLayout(false); + ResumeLayout(false); + } + + protected async override void OnShown(EventArgs e) + { + base.OnShown(e); + + await Task.Run(async () => + { + this.Clear(); + + UIControl.SetText(label1, "Loading..."); + UIControl.SetText(label2, "... " + Path.GetFileName(loadFilename)); + + var newSession = await LoadSaveSessionWithVersion(loadFilename); + var isPack = Path.GetExtension(loadFilename).Equals(".jsnx", StringComparison.CurrentCultureIgnoreCase); + + // Update progress bars + progressBar1.Maximum = newSession.Directories?.Count ?? 0; + progressBar2.Maximum = newSession.Items?.Count ?? 0; + progressBar1.Value = 0; + progressBar2.Value = 0; + + UIControl.SetText(label1, "Loading..."); + UIControl.SetText(label2, ""); + + foreach (var item in newSession?.Directories ?? new List()) + { + if (string.IsNullOrWhiteSpace(item)) + { + continue; + } + + UIControl.SetText(label2, "... " + Path.GetFileNameWithoutExtension(item)); + + progressBar1.Value++; + + treeView.CreateNodePath(item, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2); + } + + foreach (var item in newSession?.Items ?? new List()) + { + UIControl.SetText(label2, "... " + item.Title); + + progressBar2.Value++; + + // Load extra data from archive file + if (isPack) + { + item.Icon = await LoadIconFromFile(loadFilename, item); + } + + treeView.AddNode(item); + } + + if (treeView.Nodes.Count >= 0) + { + UIControl.Invoke(treeView, (x) => + { + treeView.Nodes[0].Expand(); + + treeView.SelectedNode = treeView.Nodes[0]; + }); + } + + result = newSession; + + UIControl.SetText(label1, ""); + UIControl.SetText(label2, "Done"); + }); + + this.DialogResult = DialogResult.OK; + } + + protected override void OnFormClosing(FormClosingEventArgs e) + { + base.OnFormClosing(e); + + if (this.DialogResult != DialogResult.OK) + { + e.Cancel = true; + } + } + + public App6Options Result + { + get => result ?? new App6Options(); + } + + + public async Task ShowDialog(string filename, BookmarkTreeView control) + { + loadFilename = filename; + treeView = control; + + return this.ShowDialog(); + } + + public void Clear() + { + UIControl.SetText(label1, "Ready"); + UIControl.SetText(label2, ""); + + progressBar1.Value = progressBar1.Maximum = 0; + progressBar2.Value = progressBar2.Maximum = 0; + + treeView.Clear(true, true, "New Session"); + } + + private async Task LoadSaveSessionWithVersion(string filename) + { + var result = new App6Options(); + + if (string.IsNullOrWhiteSpace(filename)) + { + return result; + } + + var fileExtension = Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty); + if (string.IsNullOrWhiteSpace(fileExtension)) + { + return result; + } + + // Load session, assume version 3. + App6Options loadSession = null; + switch (fileExtension) + { + case ".json": + case ".jsonfig": + loadSession = await RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile(filename); + if (loadSession == null) + { + loadSession = await LoadFileR4(filename); + } + + break; + case ".jsnx": + loadSession = await RyzStudio.IO.Compression.ZFile.ReadFile(filename, "Document.json"); + + break; + default: + break; + } + + if (loadSession == null) + { + return result; + } + + // File likely not correct schema. + if (loadSession.FileVersion <= 0) + { + return result; + } + + result = loadSession; + + return result; + } + + private async Task LoadFileR4(string filename) + { + var session = await RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile>(filename); + if (session == null) + { + return null; + } + + var result = new App6Options(); + result.Items = new List(); + + foreach (var item in session) + { + result.Items.Add(new App6Options.Item() + { + Title = item.SiteName, + Address = item.SiteAddress, + Description = item.SiteDescription, + Notes = item.Notes, + Path = item.Path + }); + } + + return result; + } + + private async Task LoadIconFromFile(string filename, App6Options.Item item) + { + if (item == null) + { + return null; + } + + if (item.Id == Guid.Empty) + { + return null; + } + + return await Task.Run(() => + { + try + { + using (var archive = ZipFile.Open(filename, ZipArchiveMode.Read)) + { + var key = "icon\\" + item.Id.ToString() + ".png"; + + var zipEntry = archive.GetEntry(key); + if (zipEntry == null) + { + return null; + } + + using (Stream entryStream = zipEntry.Open()) + { + return Image.FromStream(entryStream); + } + } + } + catch (Exception) + { + return null; + } + }); + } + + } +} \ No newline at end of file diff --git a/Forms/LoadingForm.resx b/Forms/LoadingForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/Forms/LoadingForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Forms/OptionsForm.cs b/Forms/OptionsForm.cs new file mode 100644 index 0000000..2487f6e --- /dev/null +++ b/Forms/OptionsForm.cs @@ -0,0 +1,410 @@ +using System; +using System.Windows.Forms; +using BukkuBuddy.DTOs.SaveFile; +using RyzStudio.Windows.Forms; +using RyzStudio.Windows.ThemedForms.PickerBox; + +namespace BukkuBuddy.Forms +{ + public class OptionsForm : Form + { + private ThYesNoPickerBox pickerBox1; + private Label label2; + private Label label1; + private ThYesNoPickerBox pickerBox2; + private Label label3; + private RyzStudio.Windows.ThemedForms.ButtonTextBox.ThClearableTextBox textBox1; + private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1; + private FlowLayoutPanel flowLayoutPanel1; + private TTogglePanel togglePanel1; + private TTogglePanel togglePanel2; + private Label label4; + private ThYesNoPickerBox pickerBox3; + private TTogglePanel togglePanel3; + private Label label5; + private RyzStudio.Windows.ThemedForms.ThNumericBox numericBox1; + private Label label6; + private ThYesNoPickerBox pickerBox4; + private Label label7; + private ThYesNoPickerBox pickerBox5; + private App6Options _appSession = null; + + + public OptionsForm(App6Options appSession) + { + InitializeComponent(); + + UISetup.Dialog(this, true); + UISetup.AutoSizeChildren(flowLayoutPanel1); + + _appSession = appSession; + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + + pickerBox1.Value = _appSession?.RestorePosition ?? true; + textBox1.Text = _appSession.RunCommand ?? string.Empty; + pickerBox2.Value = _appSession?.AlwaysOnTop ?? false; + pickerBox3.Value = _appSession?.AllowUnsafeSSL ?? false; + numericBox1.Value = _appSession?.Timeout ?? 0; + pickerBox4.Value = _appSession?.AllowCookies ?? false; + pickerBox5.Value = _appSession?.AllowRedirects ?? false; + + } + + private void InitializeComponent() + { + pickerBox1 = new ThYesNoPickerBox(); + label2 = new Label(); + pickerBox2 = new ThYesNoPickerBox(); + label1 = new Label(); + textBox1 = new RyzStudio.Windows.ThemedForms.ButtonTextBox.ThClearableTextBox(); + label3 = new Label(); + dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter(); + flowLayoutPanel1 = new FlowLayoutPanel(); + togglePanel1 = new TTogglePanel(); + togglePanel2 = new TTogglePanel(); + togglePanel3 = new TTogglePanel(); + label6 = new Label(); + pickerBox4 = new ThYesNoPickerBox(); + numericBox1 = new RyzStudio.Windows.ThemedForms.ThNumericBox(); + label4 = new Label(); + label5 = new Label(); + pickerBox3 = new ThYesNoPickerBox(); + label7 = new Label(); + pickerBox5 = new ThYesNoPickerBox(); + flowLayoutPanel1.SuspendLayout(); + togglePanel1.SuspendLayout(); + togglePanel2.SuspendLayout(); + togglePanel3.SuspendLayout(); + SuspendLayout(); + // + // pickerBox1 + // + pickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pickerBox1.BackColor = System.Drawing.Color.Transparent; + pickerBox1.EnableMovable = false; + pickerBox1.Location = new System.Drawing.Point(311, 22); + pickerBox1.Name = "pickerBox1"; + pickerBox1.SelectedIndex = 1; + pickerBox1.Size = new System.Drawing.Size(80, 32); + pickerBox1.TabIndex = 197; + pickerBox1.TabStop = false; + pickerBox1.Value = true; + // + // label2 + // + label2.AutoSize = true; + label2.BackColor = System.Drawing.Color.Transparent; + label2.ForeColor = System.Drawing.SystemColors.ControlText; + label2.Location = new System.Drawing.Point(1, 22); + label2.Margin = new Padding(0); + label2.Name = "label2"; + label2.Padding = new Padding(0, 8, 0, 0); + label2.Size = new System.Drawing.Size(92, 23); + label2.TabIndex = 196; + label2.Text = "Restore Position"; + label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pickerBox2 + // + pickerBox2.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pickerBox2.BackColor = System.Drawing.Color.Transparent; + pickerBox2.EnableMovable = false; + pickerBox2.Location = new System.Drawing.Point(311, 64); + pickerBox2.Name = "pickerBox2"; + pickerBox2.SelectedIndex = 1; + pickerBox2.Size = new System.Drawing.Size(80, 32); + pickerBox2.TabIndex = 198; + pickerBox2.TabStop = false; + pickerBox2.Value = true; + // + // label1 + // + label1.AutoSize = true; + label1.BackColor = System.Drawing.Color.Transparent; + label1.ForeColor = System.Drawing.SystemColors.ControlText; + label1.Location = new System.Drawing.Point(1, 64); + label1.Margin = new Padding(0); + label1.Name = "label1"; + label1.Padding = new Padding(0, 8, 0, 0); + label1.Size = new System.Drawing.Size(85, 23); + label1.TabIndex = 196; + label1.Text = "Always On Top"; + label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBox1 + // + textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBox1.BackColor = System.Drawing.Color.Transparent; + textBox1.ClearedValue = "{0}"; + textBox1.EnableMovable = false; + textBox1.Icon = "O"; + textBox1.IconSize = 13F; + textBox1.Location = new System.Drawing.Point(131, 22); + textBox1.Name = "textBox1"; + textBox1.Size = new System.Drawing.Size(260, 32); + textBox1.TabIndex = 203; + textBox1.TabStop = false; + textBox1.UseSystemPasswordChar = false; + // + // label3 + // + label3.AutoSize = true; + label3.BackColor = System.Drawing.Color.Transparent; + label3.ForeColor = System.Drawing.SystemColors.ControlText; + label3.Location = new System.Drawing.Point(1, 22); + label3.Margin = new Padding(0); + label3.Name = "label3"; + label3.Padding = new Padding(0, 8, 0, 0); + label3.Size = new System.Drawing.Size(88, 23); + label3.TabIndex = 199; + label3.Text = "Run Command"; + label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // dialogFooter1 + // + dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240); + dialogFooter1.Dock = DockStyle.Bottom; + dialogFooter1.EnableMovable = false; + dialogFooter1.IsBusy = false; + dialogFooter1.Location = new System.Drawing.Point(0, 491); + dialogFooter1.Name = "dialogFooter1"; + dialogFooter1.Size = new System.Drawing.Size(444, 70); + dialogFooter1.TabIndex = 196; + dialogFooter1.TabStop = false; + // + // flowLayoutContainer1 + // + flowLayoutPanel1.AutoScroll = true; + flowLayoutPanel1.BackColor = System.Drawing.Color.Transparent; + flowLayoutPanel1.Controls.Add(togglePanel1); + flowLayoutPanel1.Controls.Add(togglePanel2); + flowLayoutPanel1.Controls.Add(togglePanel3); + flowLayoutPanel1.Dock = DockStyle.Fill; + flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + flowLayoutPanel1.Name = "flowLayoutContainer1"; + flowLayoutPanel1.Padding = new Padding(10, 10, 10, 30); + flowLayoutPanel1.Size = new System.Drawing.Size(444, 491); + flowLayoutPanel1.TabIndex = 195; + // + // togglePanel1 + // + togglePanel1.BackColor = System.Drawing.Color.FromArgb(252, 252, 252); + togglePanel1.CloseIcon = "H"; + togglePanel1.Controls.Add(label2); + togglePanel1.Controls.Add(pickerBox1); + togglePanel1.EnableMovable = false; + togglePanel1.ExpandedHeight = 64; + togglePanel1.HeaderPadding = new Padding(4, 0, 0, 2); + togglePanel1.IconWidth = 20; + togglePanel1.Location = new System.Drawing.Point(10, 10); + togglePanel1.Name = "togglePanel1"; + togglePanel1.OpenIcon = "G"; + togglePanel1.Size = new System.Drawing.Size(401, 64); + togglePanel1.TabIndex = 0; + togglePanel1.Title = "Start-Up"; + togglePanel1.TitleContextMenuStrip = null; + togglePanel1.TitleCursor = Cursors.Default; + // + // togglePanel2 + // + togglePanel2.BackColor = System.Drawing.Color.FromArgb(252, 252, 252); + togglePanel2.CloseIcon = "H"; + togglePanel2.Controls.Add(textBox1); + togglePanel2.Controls.Add(label3); + togglePanel2.Controls.Add(label1); + togglePanel2.Controls.Add(pickerBox2); + togglePanel2.EnableMovable = false; + togglePanel2.ExpandedHeight = 103; + togglePanel2.HeaderPadding = new Padding(4, 0, 0, 2); + togglePanel2.IconWidth = 20; + togglePanel2.Location = new System.Drawing.Point(10, 84); + togglePanel2.Name = "togglePanel2"; + togglePanel2.OpenIcon = "G"; + togglePanel2.Size = new System.Drawing.Size(401, 103); + togglePanel2.TabIndex = 1; + togglePanel2.Title = "Behaviour"; + togglePanel2.TitleContextMenuStrip = null; + togglePanel2.TitleCursor = Cursors.Default; + // + // togglePanel3 + // + togglePanel3.BackColor = System.Drawing.Color.FromArgb(252, 252, 252); + togglePanel3.CloseIcon = "H"; + togglePanel3.Controls.Add(label7); + togglePanel3.Controls.Add(pickerBox5); + togglePanel3.Controls.Add(label6); + togglePanel3.Controls.Add(pickerBox4); + togglePanel3.Controls.Add(numericBox1); + togglePanel3.Controls.Add(label4); + togglePanel3.Controls.Add(label5); + togglePanel3.Controls.Add(pickerBox3); + togglePanel3.EnableMovable = false; + togglePanel3.ExpandedHeight = 187; + togglePanel3.HeaderPadding = new Padding(4, 0, 0, 2); + togglePanel3.IconWidth = 20; + togglePanel3.Location = new System.Drawing.Point(10, 197); + togglePanel3.Name = "togglePanel3"; + togglePanel3.OpenIcon = "G"; + togglePanel3.Size = new System.Drawing.Size(401, 187); + togglePanel3.TabIndex = 2; + togglePanel3.Title = "Web Traffic"; + togglePanel3.TitleContextMenuStrip = null; + togglePanel3.TitleCursor = Cursors.Default; + // + // label6 + // + label6.AutoSize = true; + label6.BackColor = System.Drawing.Color.Transparent; + label6.ForeColor = System.Drawing.SystemColors.ControlText; + label6.Location = new System.Drawing.Point(1, 106); + label6.Margin = new Padding(0); + label6.Name = "label6"; + label6.Padding = new Padding(0, 8, 0, 0); + label6.Size = new System.Drawing.Size(82, 23); + label6.TabIndex = 199; + label6.Text = "Allow Cookies"; + label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pickerBox4 + // + pickerBox4.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pickerBox4.BackColor = System.Drawing.Color.Transparent; + pickerBox4.EnableMovable = false; + pickerBox4.Location = new System.Drawing.Point(311, 106); + pickerBox4.Name = "pickerBox4"; + pickerBox4.SelectedIndex = 1; + pickerBox4.Size = new System.Drawing.Size(80, 32); + pickerBox4.TabIndex = 200; + pickerBox4.TabStop = false; + pickerBox4.Value = true; + // + // numericBox1 + // + numericBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericBox1.BackColor = System.Drawing.Color.Transparent; + numericBox1.EnableMovable = false; + numericBox1.Location = new System.Drawing.Point(291, 64); + numericBox1.Maximum = 30; + numericBox1.Minimum = 1; + numericBox1.Name = "numericBox1"; + numericBox1.Size = new System.Drawing.Size(100, 32); + numericBox1.TabIndex = 3; + numericBox1.TabStop = false; + numericBox1.Value = 6; + // + // label4 + // + label4.AutoSize = true; + label4.BackColor = System.Drawing.Color.Transparent; + label4.ForeColor = System.Drawing.SystemColors.ControlText; + label4.Location = new System.Drawing.Point(1, 22); + label4.Margin = new Padding(0); + label4.Name = "label4"; + label4.Padding = new Padding(0, 8, 0, 0); + label4.Size = new System.Drawing.Size(97, 23); + label4.TabIndex = 196; + label4.Text = "Allow Unsafe SSL"; + label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label5 + // + label5.AutoSize = true; + label5.BackColor = System.Drawing.Color.Transparent; + label5.ForeColor = System.Drawing.SystemColors.ControlText; + label5.Location = new System.Drawing.Point(1, 64); + label5.Margin = new Padding(0); + label5.Name = "label5"; + label5.Padding = new Padding(0, 8, 0, 0); + label5.Size = new System.Drawing.Size(151, 23); + label5.TabIndex = 196; + label5.Text = "Request Timeout (Seconds)"; + label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pickerBox3 + // + pickerBox3.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pickerBox3.BackColor = System.Drawing.Color.Transparent; + pickerBox3.EnableMovable = false; + pickerBox3.Location = new System.Drawing.Point(311, 22); + pickerBox3.Name = "pickerBox3"; + pickerBox3.SelectedIndex = 1; + pickerBox3.Size = new System.Drawing.Size(80, 32); + pickerBox3.TabIndex = 198; + pickerBox3.TabStop = false; + pickerBox3.Value = true; + // + // label7 + // + label7.AutoSize = true; + label7.BackColor = System.Drawing.Color.Transparent; + label7.ForeColor = System.Drawing.SystemColors.ControlText; + label7.Location = new System.Drawing.Point(1, 148); + label7.Margin = new Padding(0); + label7.Name = "label7"; + label7.Padding = new Padding(0, 8, 0, 0); + label7.Size = new System.Drawing.Size(88, 23); + label7.TabIndex = 201; + label7.Text = "Allow Redirects"; + label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pickerBox5 + // + pickerBox5.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pickerBox5.BackColor = System.Drawing.Color.Transparent; + pickerBox5.EnableMovable = false; + pickerBox5.Location = new System.Drawing.Point(311, 148); + pickerBox5.Name = "pickerBox5"; + pickerBox5.SelectedIndex = 1; + pickerBox5.Size = new System.Drawing.Size(80, 32); + pickerBox5.TabIndex = 202; + pickerBox5.TabStop = false; + pickerBox5.Value = true; + // + // OptionsForm + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = System.Drawing.Color.WhiteSmoke; + ClientSize = new System.Drawing.Size(444, 561); + Controls.Add(flowLayoutPanel1); + Controls.Add(dialogFooter1); + MinimumSize = new System.Drawing.Size(460, 600); + Name = "OptionsForm"; + Text = "Options"; + flowLayoutPanel1.ResumeLayout(false); + togglePanel1.ResumeLayout(false); + togglePanel1.PerformLayout(); + togglePanel2.ResumeLayout(false); + togglePanel2.PerformLayout(); + togglePanel3.ResumeLayout(false); + togglePanel3.PerformLayout(); + ResumeLayout(false); + } + + public App6Options Result + { + get + { + if (_appSession == null) + { + _appSession = new App6Options(); + } + + _appSession.RestorePosition = pickerBox1.Value; + _appSession.RunCommand = textBox1.Text ?? string.Empty; + _appSession.AlwaysOnTop = pickerBox2.Value; + _appSession.AllowUnsafeSSL = pickerBox3.Value; + _appSession.Timeout = numericBox1.Value; + _appSession.AllowCookies = pickerBox4.Value; + _appSession.AllowRedirects = pickerBox5.Value; + + return _appSession; + } + } + + } +} \ No newline at end of file diff --git a/Forms/OptionsForm.resx b/Forms/OptionsForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/Forms/OptionsForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Forms/UpdateIconsForm.cs b/Forms/UpdateIconsForm.cs new file mode 100644 index 0000000..5dd278a --- /dev/null +++ b/Forms/UpdateIconsForm.cs @@ -0,0 +1,227 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using BukkuBuddy.DTOs.SaveFile; +using BukkuBuddy.Services; +using RyzStudio.Windows.Forms; + +namespace BukkuBuddy.Forms +{ + public class UpdateIconsForm : Form + { + private TProgressBar progressBar1; + private RyzStudio.Windows.ThemedForms.ThUserControl userControl1; + private Label label1; + private Label label2; + + private readonly WebPageService _webPageService; + + private readonly BookmarkTreeView _treeView = null; + private readonly bool _updateOnly; + + private bool cancelRequested = false; + + + public UpdateIconsForm(BookmarkTreeView treeView, App6Options options, bool updateOnly) + { + InitializeComponent(); + + UISetup.Dialog(this, true); + + this.Text = "Updating Icons"; + + _treeView = treeView; + _updateOnly = updateOnly; + + _webPageService = new WebPageService(options.AllowUnsafeSSL, options.Timeout, options.AllowCookies, options.AllowRedirects); + } + + + private void InitializeComponent() + { + progressBar1 = new TProgressBar(); + userControl1 = new RyzStudio.Windows.ThemedForms.ThUserControl(); + label1 = new Label(); + label2 = new Label(); + userControl1.SuspendLayout(); + SuspendLayout(); + // + // progressBar1 + // + progressBar1.BarColour = Color.FromArgb(25, 104, 218); + progressBar1.Dock = DockStyle.Fill; + progressBar1.EnableMovable = false; + progressBar1.Location = new Point(3, 3); + progressBar1.Maximum = 100; + progressBar1.Minimum = 0; + progressBar1.Name = "progressBar1"; + progressBar1.OnProgressChanged = null; + progressBar1.ShowText = true; + progressBar1.Size = new Size(418, 18); + progressBar1.TabIndex = 156; + progressBar1.Value = 25; + // + // userControl1 + // + userControl1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + userControl1.BackColor = Color.Transparent; + userControl1.Controls.Add(progressBar1); + userControl1.EnableMovable = false; + userControl1.Location = new Point(10, 64); + userControl1.Name = "userControl1"; + userControl1.Size = new Size(424, 24); + userControl1.TabIndex = 157; + // + // label1 + // + label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label1.AutoEllipsis = true; + label1.Location = new Point(10, 20); + label1.Name = "label1"; + label1.Size = new Size(424, 15); + label1.TabIndex = 159; + // + // label2 + // + label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label2.AutoEllipsis = true; + label2.Location = new Point(10, 40); + label2.Name = "label2"; + label2.Size = new Size(424, 15); + label2.TabIndex = 160; + // + // LoadIconsForm + // + BackColor = Color.White; + ClientSize = new Size(444, 117); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(userControl1); + Name = "LoadIconsForm"; + Text = "Update Icons"; + userControl1.ResumeLayout(false); + ResumeLayout(false); + } + + protected async override void OnShown(EventArgs e) + { + base.OnShown(e); + + await Task.Run(async () => + { + this.Clear(); + + var model = _treeView.ToNodeList(); + + // Update only + if (_updateOnly) + { + model = model.Where(x => x.Value.Icon == null)?.ToList() ?? new List>(); + } + + // Update progress bars + progressBar1.Maximum = model.Count; + progressBar1.Value = 0; + + UIControl.SetText(label1, "Updating..."); + UIControl.SetText(label2, ""); + + foreach (var item in model) + { + if (cancelRequested) + { + break; + } + + UIControl.SetText(label2, "... " + item.Value.Title); + + progressBar1.Value++; + + if (!_webPageService.IsValidUrl(item.Value.Address)) + { + continue; + } + + // Update only + if (_updateOnly) + { + if (item.Value.Icon != null) + { + continue; + } + } + + var newModel = item.Value; + + HtmlAgilityPack.HtmlDocument htmlDocument = null; + + try + { + htmlDocument = await _webPageService.GetDocument(newModel.Address); + } + catch (Exception) + { + continue; + } + + if (htmlDocument == null) + { + continue; + } + + var faviconUrl = _webPageService.ParseFavicon(htmlDocument); + if (!string.IsNullOrWhiteSpace(faviconUrl)) + { + var favicon = await _webPageService.GetImage(faviconUrl); + if (favicon != null) + { + if (favicon.Width > 16) + { + favicon = RyzStudio.Drawing.ImageEditor.Resize(favicon, 16, 16); + } + } + + newModel.Icon = favicon; + } + + _treeView.UpdateNode(item.Key, newModel); + } + + UIControl.SetText(label1, ""); + UIControl.SetText(label2, "Done"); + }); + + this.DialogResult = DialogResult.OK; + } + + protected override void OnFormClosing(FormClosingEventArgs e) + { + base.OnFormClosing(e); + + if (this.DialogResult != DialogResult.OK) + { + e.Cancel = true; + + if (!cancelRequested) + { + UIControl.SetText(label1, "Cancelling..."); + + cancelRequested = true; + } + } + } + + + public void Clear() + { + UIControl.SetText(label1, "Ready"); + UIControl.SetText(label2, ""); + + progressBar1.Value = progressBar1.Maximum = 0; + } + + } +} \ No newline at end of file diff --git a/Forms/UpdateIconsForm.resx b/Forms/UpdateIconsForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/Forms/UpdateIconsForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 11c53e5..97a1dd6 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -1,8 +1,9 @@ -using RyzStudio; +using BukkuBuddy.Resources; +using RyzStudio; using RyzStudio.IO; using RyzStudio.Windows.ThemedForms; -namespace FizzyLauncher +namespace BukkuBuddy { partial class MainForm { @@ -54,7 +55,9 @@ namespace FizzyLauncher toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); alwaysOnTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - toolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem(); + toolStripMenuItem12 = new System.Windows.Forms.ToolStripMenuItem(); + updateAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); @@ -64,6 +67,7 @@ namespace FizzyLauncher openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); rootContextMenu = new System.Windows.Forms.ContextMenuStrip(components); addPageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + toolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem(); addFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -91,7 +95,8 @@ 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(); + toolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem(); + toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); menuStrip1.SuspendLayout(); rootContextMenu.SuspendLayout(); folderContextMenu.SuspendLayout(); @@ -122,7 +127,6 @@ namespace FizzyLauncher // // newToolStripMenuItem // - newToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; newToolStripMenuItem.Name = "newToolStripMenuItem"; newToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N; newToolStripMenuItem.Size = new System.Drawing.Size(146, 22); @@ -131,7 +135,7 @@ namespace FizzyLauncher // // openToolStripMenuItem // - openToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + openToolStripMenuItem.Image = MainMenuResource.folder_minus; 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 +161,7 @@ namespace FizzyLauncher // // saveToolStripMenuItem // - saveToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + saveToolStripMenuItem.Image = MainMenuResource.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 +196,7 @@ namespace FizzyLauncher // // findToolStripMenuItem // - findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + findToolStripMenuItem.Image = MainMenuResource.search; findToolStripMenuItem.Name = "findToolStripMenuItem"; findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F; findToolStripMenuItem.Size = new System.Drawing.Size(137, 22); @@ -234,29 +238,43 @@ namespace FizzyLauncher // // toolsToolStripMenuItem // - toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem9, toolStripSeparator2, optionsToolStripMenuItem }); + toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem12, toolStripSeparator2, optionsToolStripMenuItem }); toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); toolsToolStripMenuItem.Text = "&Tools"; // - // toolStripMenuItem9 + // toolStripMenuItem12 // - toolStripMenuItem9.Name = "toolStripMenuItem9"; - toolStripMenuItem9.Size = new System.Drawing.Size(168, 22); - toolStripMenuItem9.Text = "Update &Icons"; - toolStripMenuItem9.Click += toolStripMenuItem9_Click; + toolStripMenuItem12.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem9, updateAllToolStripMenuItem, toolStripSeparator3, clearToolStripMenuItem }); + toolStripMenuItem12.Name = "toolStripMenuItem12"; + toolStripMenuItem12.Size = new System.Drawing.Size(180, 22); + toolStripMenuItem12.Text = "&Icons"; + // + // updateAllToolStripMenuItem + // + updateAllToolStripMenuItem.Name = "updateAllToolStripMenuItem"; + updateAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + updateAllToolStripMenuItem.Text = "Update &All"; + updateAllToolStripMenuItem.Click += updateAllToolStripMenuItem_Click; + // + // clearToolStripMenuItem + // + clearToolStripMenuItem.Name = "clearToolStripMenuItem"; + clearToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + clearToolStripMenuItem.Text = "&Clear All"; + clearToolStripMenuItem.Click += clearToolStripMenuItem_Click; // // toolStripSeparator2 // toolStripSeparator2.Name = "toolStripSeparator2"; - toolStripSeparator2.Size = new System.Drawing.Size(165, 6); + toolStripSeparator2.Size = new System.Drawing.Size(177, 6); // // optionsToolStripMenuItem // - optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + optionsToolStripMenuItem.Image = MainMenuResource.settings; optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12; - optionsToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + optionsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); optionsToolStripMenuItem.Text = "&Options"; optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click; // @@ -269,7 +287,7 @@ namespace FizzyLauncher // // viewHelpToolStripMenuItem1 // - viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + viewHelpToolStripMenuItem1.Image = MainMenuResource.help_circle; viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1"; viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); @@ -298,43 +316,52 @@ namespace FizzyLauncher // rootContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem, toolStripMenuItem11, addFolderToolStripMenuItem, toolStripMenuItem2, editToolStripMenuItem, toolStripMenuItem3, sortToolStripMenuItem }); rootContextMenu.Name = "rootContextMenu"; - rootContextMenu.Size = new System.Drawing.Size(181, 148); + rootContextMenu.Size = new System.Drawing.Size(167, 126); // // addPageToolStripMenuItem // + addPageToolStripMenuItem.Image = TreeViewResource.plus; addPageToolStripMenuItem.Name = "addPageToolStripMenuItem"; - addPageToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + addPageToolStripMenuItem.Size = new System.Drawing.Size(166, 22); addPageToolStripMenuItem.Text = "Add &Page"; addPageToolStripMenuItem.Click += addPageToolStripMenuItem_Click; // + // toolStripMenuItem11 + // + toolStripMenuItem11.Name = "toolStripMenuItem11"; + toolStripMenuItem11.Size = new System.Drawing.Size(166, 22); + toolStripMenuItem11.Text = "Add Page (&Batch)"; + toolStripMenuItem11.Click += toolStripMenuItem11_Click; + // // addFolderToolStripMenuItem // + addFolderToolStripMenuItem.Image = TreeViewResource.plus_square; addFolderToolStripMenuItem.Name = "addFolderToolStripMenuItem"; - addFolderToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + addFolderToolStripMenuItem.Size = new System.Drawing.Size(166, 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(163, 6); // // editToolStripMenuItem // editToolStripMenuItem.Name = "editToolStripMenuItem"; - editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + editToolStripMenuItem.Size = new System.Drawing.Size(166, 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(163, 6); // // sortToolStripMenuItem // sortToolStripMenuItem.Name = "sortToolStripMenuItem"; - sortToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + sortToolStripMenuItem.Size = new System.Drawing.Size(166, 22); sortToolStripMenuItem.Text = "&Sort"; sortToolStripMenuItem.Click += sortToolStripMenuItem_Click; // @@ -342,87 +369,88 @@ namespace FizzyLauncher // folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem1, toolStripMenuItem10, 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(178, 220); // // addPageToolStripMenuItem1 // + addPageToolStripMenuItem1.Image = TreeViewResource.plus; addPageToolStripMenuItem1.Name = "addPageToolStripMenuItem1"; - addPageToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); + addPageToolStripMenuItem1.Size = new System.Drawing.Size(177, 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.Size = new System.Drawing.Size(177, 22); + toolStripMenuItem10.Text = "Add &Multiple Pages"; toolStripMenuItem10.Click += toolStripMenuItem10_Click; // // addFolderToolStripMenuItem1 // + addFolderToolStripMenuItem1.Image = TreeViewResource.plus_square; addFolderToolStripMenuItem1.Name = "addFolderToolStripMenuItem1"; - addFolderToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); + addFolderToolStripMenuItem1.Size = new System.Drawing.Size(177, 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(174, 6); // // openAllToolStripMenuItem // - openAllToolStripMenuItem.Image = BookmarkManager.AppResource.bookmark; openAllToolStripMenuItem.Name = "openAllToolStripMenuItem"; - openAllToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + openAllToolStripMenuItem.Size = new System.Drawing.Size(177, 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(177, 22); editToolStripMenuItem1.Text = "&Edit"; editToolStripMenuItem1.Click += editToolStripMenuItem1_Click; // // deleteToolStripMenuItem // - deleteToolStripMenuItem.Image = BookmarkManager.AppResource.trash; + deleteToolStripMenuItem.Image = TreeViewResource.trash_2; deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - deleteToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + deleteToolStripMenuItem.Size = new System.Drawing.Size(177, 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(174, 6); // // sortToolStripMenuItem1 // sortToolStripMenuItem1.Name = "sortToolStripMenuItem1"; - sortToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); + sortToolStripMenuItem1.Size = new System.Drawing.Size(177, 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(174, 6); // // moveUpToolStripMenuItem // - moveUpToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_up_circle; + moveUpToolStripMenuItem.Image = TreeViewResource.arrow_up; moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; - moveUpToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + moveUpToolStripMenuItem.Size = new System.Drawing.Size(177, 22); moveUpToolStripMenuItem.Text = "Move &Up"; moveUpToolStripMenuItem.Click += moveUpToolStripMenuItem_Click; // // moveDownToolStripMenuItem // - moveDownToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_down_circle; + moveDownToolStripMenuItem.Image = TreeViewResource.arrow_down; moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; - moveDownToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + moveDownToolStripMenuItem.Size = new System.Drawing.Size(177, 22); moveDownToolStripMenuItem.Text = "Move &Down"; moveDownToolStripMenuItem.Click += moveDownToolStripMenuItem_Click; // @@ -434,7 +462,6 @@ namespace FizzyLauncher // // openToolStripMenuItem1 // - openToolStripMenuItem1.Image = BookmarkManager.AppResource.bookmark; openToolStripMenuItem1.Name = "openToolStripMenuItem1"; openToolStripMenuItem1.Size = new System.Drawing.Size(138, 22); openToolStripMenuItem1.Text = "&Open"; @@ -454,7 +481,7 @@ namespace FizzyLauncher // // deleteToolStripMenuItem1 // - deleteToolStripMenuItem1.Image = BookmarkManager.AppResource.trash; + deleteToolStripMenuItem1.Image = TreeViewResource.trash_2; deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1"; deleteToolStripMenuItem1.Size = new System.Drawing.Size(138, 22); deleteToolStripMenuItem1.Text = "&Delete"; @@ -467,7 +494,7 @@ namespace FizzyLauncher // // moveUpToolStripMenuItem1 // - moveUpToolStripMenuItem1.Image = BookmarkManager.AppResource.arrow_up_circle; + moveUpToolStripMenuItem1.Image = TreeViewResource.arrow_up; moveUpToolStripMenuItem1.Name = "moveUpToolStripMenuItem1"; moveUpToolStripMenuItem1.Size = new System.Drawing.Size(138, 22); moveUpToolStripMenuItem1.Text = "Move &Up"; @@ -475,7 +502,7 @@ namespace FizzyLauncher // // moveDownToolStripMenuItem1 // - moveDownToolStripMenuItem1.Image = BookmarkManager.AppResource.arrow_down_circle; + moveDownToolStripMenuItem1.Image = TreeViewResource.arrow_down; moveDownToolStripMenuItem1.Name = "moveDownToolStripMenuItem1"; moveDownToolStripMenuItem1.Size = new System.Drawing.Size(138, 22); moveDownToolStripMenuItem1.Text = "Move &Down"; @@ -491,12 +518,17 @@ namespace FizzyLauncher treeView1.Size = new System.Drawing.Size(300, 556); treeView1.TabIndex = 5; // - // toolStripMenuItem11 + // toolStripMenuItem9 // - toolStripMenuItem11.Name = "toolStripMenuItem11"; - toolStripMenuItem11.Size = new System.Drawing.Size(180, 22); - toolStripMenuItem11.Text = "Add Page (&Batch)"; - toolStripMenuItem11.Click += toolStripMenuItem11_Click; + toolStripMenuItem9.Name = "toolStripMenuItem9"; + toolStripMenuItem9.Size = new System.Drawing.Size(180, 22); + toolStripMenuItem9.Text = "&Update"; + toolStripMenuItem9.Click += toolStripMenuItem9_Click_1; + // + // toolStripSeparator3 + // + toolStripSeparator3.Name = "toolStripSeparator3"; + toolStripSeparator3.Size = new System.Drawing.Size(177, 6); // // MainForm // @@ -576,11 +608,15 @@ namespace FizzyLauncher private System.Windows.Forms.ToolStripSeparator toolStripMenuItem8; private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem1; - 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; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem12; + private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem updateAllToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; } } diff --git a/MainForm.cs b/MainForm.cs index 3c180b3..f1650ee 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -8,38 +8,32 @@ using System.IO.Compression; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; -using BookmarkManager; -using BookmarkManager.Models; -using bzit.bomg.Models; -using FizzyLauncher.Models; +using BukkuBuddy.DTOs.SaveFile; +using BukkuBuddy.Forms; +using BukkuBuddy.Resources; using RyzStudio; using RyzStudio.Windows.Forms; using RyzStudio.Windows.ThemedForms; using static RyzStudio.Windows.Forms.BookmarkTreeView; -namespace FizzyLauncher +namespace BukkuBuddy { public partial class MainForm : Form { - private readonly FileSessionManager _fileSessionManager; + private readonly IFileSessionManager _fileSessionManager; - private bool _isBusy = false; + private App6Options currentSession = null; + private bool isBusy = false; public MainForm() { InitializeComponent(); + this.AutoScaleMode = AutoScaleMode.None; + this.StartPosition = FormStartPosition.WindowsDefaultLocation; 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; @@ -49,14 +43,13 @@ namespace FizzyLauncher _fileSessionManager.OnClearing += fileSessionManager_OnClearSession; _fileSessionManager.OnFilenameChanged += fileSessionManager_OnFilenameChanged; - this.AutoScaleMode = AutoScaleMode.None; - this.StartPosition = FormStartPosition.WindowsDefaultLocation; - treeView1.RootContextMenu = rootContextMenu; treeView1.FolderContextMenu = folderContextMenu; treeView1.PageContextMenu = pageContextMenu; + treeView1.OnEditNode += treeView1_OnEditNode; treeView1.NodeMouseDoubleClick += treeView1_NodeMouseDoubleClick; treeView1.PreviewKeyDown += treeView1_PreviewKeyDown; + treeView1.OnChanged += treeView1_OnChanged; } protected async override void OnShown(EventArgs e) @@ -77,41 +70,78 @@ namespace FizzyLauncher } else { - this.CurrentSession = new AppOptions(); + //this.CurrentSession = new AppOptions(); - InvalidateOptions(); + //InvalidateOptions(); } + + UIControl.SetFocus(this); } - protected async override void OnClosing(CancelEventArgs e) + protected async override void OnFormClosing(FormClosingEventArgs e) { - base.OnClosing(e); + base.OnFormClosing(e); await _fileSessionManager.CloseSession(); } - public AppOptions CurrentSession { get; set; } = null; + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public App6Options CurrentSession + { + get + { + if (currentSession == null) + { + currentSession = new App6Options(); + } + return currentSession; + } + set => currentSession = value; + } + + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsBusy { - get => _isBusy; + get => isBusy; set { - treeView1.Enabled = !value; + isBusy = value; + + UIControl.SetEnable(treeView1, !isBusy); } } - private void InvalidateOptions() + private void InvalidateOptions(bool resize) { UIControl.SetTopMost(this, this.CurrentSession.AlwaysOnTop); + + if (resize) + { + if (!this.CurrentSession.StartPosition.IsEmpty) + { + UIControl.SetLocation(this, this.CurrentSession.StartPosition); + } + + if (this.CurrentSession.Width > 0) + { + UIControl.SetClientWidth(this, this.CurrentSession.Width); + } + + if (this.CurrentSession.Height > 0) + { + UIControl.SetClientHeight(this, this.CurrentSession.Height); + } + } } private void menuStrip1_MenuActivate(object sender, EventArgs e) { closeToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close); - saveToolStripMenuItem.Enabled = (_fileSessionManager.SessionState == FileSessionManager.SessionStateEnum.Open) && treeView1.HasChanged; + //saveToolStripMenuItem.Enabled = (_fileSessionManager.SessionState == FileSessionManager.SessionStateEnum.Open) && treeView1.HasChanged; + saveToolStripMenuItem.Enabled = (_fileSessionManager.SessionState == FileSessionManager.SessionStateEnum.Open) && _fileSessionManager.HasChanged; saveAsToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close); findToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close); @@ -121,6 +151,8 @@ namespace FizzyLauncher alwaysOnTopToolStripMenuItem.Checked = this.CurrentSession?.AlwaysOnTop ?? false; toolStripMenuItem9.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close); + updateAllToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close); + clearToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close); } @@ -239,7 +271,7 @@ namespace FizzyLauncher /// /// /// - private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) + private async void expandAllToolStripMenuItem_Click(object sender, EventArgs e) { if (this.IsBusy) { @@ -251,14 +283,20 @@ namespace FizzyLauncher return; } - if (treeView1.SelectedNode == null) + await Task.Run(() => { - treeView1.ExpandAll(); - } - else - { - treeView1.SelectedNode.ExpandAll(); - } + UIControl.Invoke(treeView1, (x) => + { + if (treeView1.SelectedNode == null) + { + treeView1.ExpandAll(); + } + else + { + treeView1.SelectedNode.ExpandAll(); + } + }); + }); } /// @@ -266,7 +304,7 @@ namespace FizzyLauncher /// /// /// - private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) + private async void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) { if (this.IsBusy) { @@ -278,14 +316,20 @@ namespace FizzyLauncher return; } - if (treeView1.SelectedNode == null) + await Task.Run(() => { - treeView1.CollapseAll(); - } - else - { - treeView1.SelectedNode.Collapse(false); - } + UIControl.Invoke(treeView1, (x) => + { + if (treeView1.SelectedNode == null) + { + treeView1.CollapseAll(); + } + else + { + treeView1.SelectedNode.Collapse(false); + } + }); + }); } /// @@ -305,21 +349,123 @@ namespace FizzyLauncher this.TopMost = this.CurrentSession.AlwaysOnTop; } - /// /// Update icons /// /// /// - private void toolStripMenuItem9_Click(object sender, EventArgs e) + private async void toolStripMenuItem9_Click_1(object sender, EventArgs e) { if (this.IsBusy) { return; } - var form = new UpdateIconsForm(treeView1); - form.ShowDialog(); + this.IsBusy = true; + + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + if (treeView1.GetNodeCount(true) <= 0) + { + return; + } + + if (MessageBox.Show("Are you sure you want to update (missing) icons?", "Update Icons", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + var form = new UpdateIconsForm(treeView1, this.CurrentSession, true); + form.ShowDialog(); + } + }); + }); + + this.IsBusy = false; + } + + /// + /// Update all icons. + /// + /// + /// + private async void updateAllToolStripMenuItem_Click(object sender, EventArgs e) + { + if (this.IsBusy) + { + return; + } + + this.IsBusy = true; + + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + if (treeView1.GetNodeCount(true) <= 0) + { + return; + } + + if (MessageBox.Show("Are you sure you want to update all icons?", "Update Icons", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + var form = new UpdateIconsForm(treeView1, this.CurrentSession, false); + form.ShowDialog(); + } + }); + }); + + this.IsBusy = false; + } + + /// + /// Clear All Icons + /// + /// + /// + private async void clearToolStripMenuItem_Click(object sender, EventArgs e) + { + if (this.IsBusy) + { + return; + } + + this.IsBusy = true; + + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + if (treeView1.GetNodeCount(true) <= 0) + { + return; + } + + if (MessageBox.Show("Are you sure you want to clear all icons?", "Clear Icons", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + var form = new ClearIconsForm(treeView1); + form.ShowDialog(); + } + }); + }); + + this.IsBusy = false; + } + + /// + /// Update icons + /// + /// + /// + private async void toolStripMenuItem9_Click(object sender, EventArgs e) + { + //if (this.IsBusy) + //{ + // return; + //} + + + //var form = new UpdateIconsForm(treeView1); + //form.ShowDialog(); } /// @@ -337,9 +483,15 @@ namespace FizzyLauncher var form = new OptionsForm(this.CurrentSession); if (form.ShowDialog() == DialogResult.OK) { - this.CurrentSession = form.Result; + this.CurrentSession.StartPosition = form.Result.StartPosition; + this.CurrentSession.RunCommand = form.Result.RunCommand; + this.CurrentSession.AlwaysOnTop = form.Result.AlwaysOnTop; + this.CurrentSession.AllowUnsafeSSL = form.Result.AllowUnsafeSSL; + this.CurrentSession.Timeout = form.Result.Timeout; + this.CurrentSession.AllowCookies = form.Result.AllowCookies; + this.CurrentSession.AllowRedirects = form.Result.AllowRedirects; - InvalidateOptions(); + InvalidateOptions(false); } } @@ -351,7 +503,7 @@ namespace FizzyLauncher /// private void viewHelpToolStripMenuItem1_Click(object sender, EventArgs e) { - RyzStudio.Diagnostics.Process.Execute(AppResource.AppHelpURL); + RyzStudio.Diagnostics.Process.Execute(MainMenuResource.AppHelpURL); } /// @@ -362,11 +514,11 @@ namespace FizzyLauncher private void aboutToolStripMenuItem1_Click(object sender, EventArgs e) { var form = new RyzStudio.Windows.ThemedForms.AboutForm(); - form.ProductURL = AppResource.AppProductURL; - form.AuthorURL = AppResource.AppAuthorURL; - form.CompanyURL = AppResource.AppCompanyURL; + form.ProductURL = MainMenuResource.AppProductURL; + form.AuthorURL = MainMenuResource.AppAuthorURL; + form.CompanyURL = MainMenuResource.AppCompanyURL; form.ProductCopyrightStartYear = 2012; - form.ProductLogo = AppResource.icon_64; + form.ProductLogo = MainMenuResource.icon_64; form.ShowDialog(); } @@ -380,7 +532,7 @@ namespace FizzyLauncher /// /// /// - private void addPageToolStripMenuItem_Click(object sender, EventArgs e) + private async void addPageToolStripMenuItem_Click(object sender, EventArgs e) { if (this.IsBusy) { @@ -390,16 +542,22 @@ namespace FizzyLauncher var nodeType = treeView1.GetNodeType(); if ((nodeType == BookmarkTreeView.NodeType.Root) || (nodeType == BookmarkTreeView.NodeType.Folder)) { - treeView1.AddNode(); + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + treeView1.AddNode(); + }); + }); } } /// - /// Add page (batch) + /// Add multiple pages /// /// /// - private void toolStripMenuItem11_Click(object sender, EventArgs e) + private async void toolStripMenuItem11_Click(object sender, EventArgs e) { if (this.IsBusy) { @@ -414,13 +572,19 @@ namespace FizzyLauncher var nodePath = treeView1.GetNodePath(); - var form = new AddBatchPageForm(nodePath); + var form = new AddMultiPageForm(nodePath, this.CurrentSession); if (form.ShowDialog() == DialogResult.OK) { - foreach (var item in form.Result) + await Task.Run(async () => { - treeView1.AddNode(item); - } + foreach (var item in form.Result) + { + UIControl.Invoke(treeView1, (x) => + { + treeView1.AddNode(item); + }); + } + }); } } @@ -429,7 +593,7 @@ namespace FizzyLauncher /// /// /// - private void addFolderToolStripMenuItem_Click(object sender, EventArgs e) + private async void addFolderToolStripMenuItem_Click(object sender, EventArgs e) { if (this.IsBusy) { @@ -439,7 +603,13 @@ namespace FizzyLauncher var nodeType = treeView1.GetNodeType(); if ((nodeType == BookmarkTreeView.NodeType.Root) || (nodeType == BookmarkTreeView.NodeType.Folder)) { - treeView1.AddFolder(); + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + treeView1.AddFolder(); + }); + }); } } @@ -463,14 +633,24 @@ namespace FizzyLauncher /// /// /// - private void sortToolStripMenuItem_Click(object sender, EventArgs e) + private async void sortToolStripMenuItem_Click(object sender, EventArgs e) { if (this.IsBusy) { return; } - treeView1.Sort(); + this.IsBusy = true; + + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + treeView1.Sort(); + }); + }); + + this.IsBusy = false; } #endregion @@ -550,7 +730,7 @@ namespace FizzyLauncher /// /// /// - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + private async void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (this.IsBusy) { @@ -559,7 +739,13 @@ namespace FizzyLauncher if (MessageBox.Show("Delete?", "Delete?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { - treeView1.DeleteNode(); + await Task.Run(() => + { + UIControl.Invoke(treeView1, (x) => + { + treeView1.DeleteNode(); + }); + }); } } @@ -666,122 +852,47 @@ namespace FizzyLauncher { return await Task.Run(() => { - treeView1.Clear("New Session"); - - if (treeView1.Nodes.Count >= 0) + UIControl.Invoke(treeView1, (x) => { - UIControl.Invoke(treeView1, (x) => + treeView1.Clear(true, true, "New Session"); + + if (treeView1.Nodes.Count >= 0) { treeView1.Nodes[0].Expand(); treeView1.SelectedNode = treeView1.Nodes[0]; - }); - } + } + }); UIControl.SetFocus(treeView1); + sender.HasChanged = true; + return true; }); } private async Task fileSessionManager_OnLoadSession(FileSessionManager sender, string filename, int formatType) { - return await Task.Run(async () => + var loadingForm = new LoadingForm(); + var result = await loadingForm.ShowDialog(filename, treeView1); + if (result != DialogResult.OK) { - var result = GenericResult.Create(); + return false; + } - switch (Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty)) - { - case ".json": - this.CurrentSession = RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile(filename); + await Task.Run(() => + { + this.CurrentSession = loadingForm.Result; - if (this.CurrentSession == null) - { - this.CurrentSession = LoadR4SaveFile(filename); - } - - break; - case ".jsnx": - this.CurrentSession = await RyzStudio.IO.Compression.ZFile.ReadFile(filename, "Document.json"); - - if (this.CurrentSession == null) - { - this.CurrentSession = new AppOptions(); - } - - // Load icons - this.CurrentSession = await LoadIconsFromZipFile(filename, this.CurrentSession); - - break; - default: - this.CurrentSession = null; - break; - } - - if (this.CurrentSession == null) - { - ThMessageBox.Show(this, "Unable to read session", "Load session", MessageBoxButtons.OK, MessageBoxIcon.Error); - - return false; - } - - if (this.CurrentSession == null) - { - this.CurrentSession = new AppOptions(); - } - - // Reposition + resize - if (!this.CurrentSession.StartPosition.IsEmpty) - { - UIControl.SetLocation(this, this.CurrentSession.StartPosition); - } - - if (this.CurrentSession.Height > 0) - { - UIControl.SetHeight(this, this.CurrentSession.Height); - } - - if (this.CurrentSession.Width > 0) - { - UIControl.SetWidth(this, this.CurrentSession.Width); - } - - InvalidateOptions(); - - // Clear treeview - treeView1.Clear("New Session"); - - // Load directories - foreach (var item in this.CurrentSession.Directories ?? new List()) - { - if (string.IsNullOrWhiteSpace(item)) - { - continue; - } - - treeView1.CreateNodePath(item, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2); - } - - // Load bookmarks - foreach (var item in this.CurrentSession.Items ?? new List()) - { - treeView1.AddNode(item); - } - - if (treeView1.Nodes.Count >= 0) - { - UIControl.Invoke(treeView1, (x) => - { - treeView1.Nodes[0].Expand(); - - treeView1.SelectedNode = treeView1.Nodes[0]; - }); - } - - UIControl.SetFocus(treeView1); - - return true; + this.InvalidateOptions(true); }); + + UIControl.SetFocus(treeView1); + + sender.HasChanged = false; + + return true; } private async Task fileSessionManager_OnSaveSession(FileSessionManager sender, string filename, int formatType, bool showNotices) @@ -793,28 +904,28 @@ namespace FizzyLauncher return await Task.Run(async () => { - if (_isBusy) + if (isBusy) { return false; } - _isBusy = true; + isBusy = true; // update session if (this.CurrentSession == null) { - this.CurrentSession = new AppOptions(); + this.CurrentSession = new App6Options(); } this.CurrentSession.StartPosition = this.Location; this.CurrentSession.Width = this.Width; this.CurrentSession.Height = this.Height; - var directoryList = treeView1.GetAllDirectories(); - var bookmarkList = treeView1.GetAllNodes(); + var directoryList = treeView1.GetAllNodePaths(); + var bookmarkList = treeView1.GetAllItems(); this.CurrentSession.Directories = directoryList ?? new List(); - this.CurrentSession.Items = bookmarkList.Select(x => x.Value)?.ToList() ?? new List(); + this.CurrentSession.Items = bookmarkList.Select(x => x.Value)?.ToList() ?? new List(); var result = GenericResult.Create(); @@ -861,7 +972,12 @@ namespace FizzyLauncher } } - _isBusy = false; + isBusy = false; + + if (result.IsSuccess) + { + sender.HasChanged = false; + } return result.IsSuccess; }); @@ -869,12 +985,11 @@ namespace FizzyLauncher private async Task fileSessionManager_OnClearSession(FileSessionManager sender) { - return await Task.Run(() => - { - UIControl.Clear(treeView1); + UIControl.Clear(treeView1); - return true; - }); + sender.HasChanged = false; + + return true; } private async Task fileSessionManager_OnFilenameChanged(FileSessionManager sender, string filename) @@ -895,13 +1010,12 @@ namespace FizzyLauncher default: break; } - - treeView1.HasChanged = false; }); } #endregion + private async void treeView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { TreeNode node = treeView1.SelectedNode; @@ -927,77 +1041,33 @@ namespace FizzyLauncher await OpenBookmark(e.Node); } - - private AppOptions LoadR4SaveFile(string filename) + private bool treeView1_OnEditNode(BookmarkTreeView sender, TreeNode node, App6Options.Item model) { - var session = RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile>(filename); - if (session == null) + if (this.IsBusy) { - return null; + return false; } - var result = new AppOptions(); - result.Items = new List(); - - foreach (var item in session) + var form = new EditBookmarkForm(model, this.CurrentSession); + if (form.ShowDialog() == DialogResult.OK) { - result.Items.Add(new BookmarkModel() - { - Title = item.SiteName, - Address = item.SiteAddress, - Description = item.SiteDescription, - Notes = item.Notes, - Path = item.Path - }); + sender.UpdateNode(node, form.Result); + + return true; } - return result; + return false; } - private async Task LoadIconsFromZipFile(string filename, AppOptions session) + private void treeView1_OnChanged(BookmarkTreeView sender, bool hasChanged) { - if (string.IsNullOrWhiteSpace(filename)) + if (hasChanged) { - return session; + _fileSessionManager.HasChanged = hasChanged; } - - return await Task.Run(() => - { - try - { - using (var archive = ZipFile.Open(filename, ZipArchiveMode.Read)) - { - foreach (var item in session.Items) - { - if (item.Id == Guid.Empty) - { - continue; - } - - var key = "icon\\" + item.Id.ToString() + ".png"; - - var zipEntry = archive.GetEntry(key); - if (zipEntry == null) - { - continue; - } - - using (Stream entryStream = zipEntry.Open()) - { - item.Icon = Image.FromStream(entryStream); - } - } - } - } - catch (Exception) - { - // do nothing - } - - return session; - }); } + private async Task OpenBookmark(TreeNode node) { await Task.Run(() => @@ -1007,7 +1077,7 @@ namespace FizzyLauncher return; } - var model = UIControl.GetTag(node); + var model = UIControl.GetTag(node); if (model == null) { return; @@ -1024,7 +1094,7 @@ namespace FizzyLauncher }); } - private GenericResult AddImagesToZipFile(string zipFilename, List> items) + private GenericResult AddImagesToZipFile(string zipFilename, List> items) { if (string.IsNullOrWhiteSpace(zipFilename)) { diff --git a/MainForm.resx b/MainForm.resx index ca4a045..dcd211d 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -121,19 +121,19 @@ 172, 17 - 716, 17 + 331, 14 17, 17 - 831, 17 + 478, 19 - 979, 17 + 665, 16 - 1137, 17 + 834, 17 diff --git a/Models/AppOptions.cs b/Models/AppOptions.cs deleted file mode 100644 index 7089cd8..0000000 --- a/Models/AppOptions.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using System.Drawing; -using bzit.bomg.Models; - -namespace FizzyLauncher.Models -{ - public class AppOptions - { - public bool RestorePosition { get; set; } = true; - - public bool AlwaysOnTop { get; set; } = false; - - public string RunCommand { get; set; } = "{0}"; - - //public bool IgnoreSSL { get; set; } = false; - - public Point StartPosition { get; set; } = Point.Empty; - - public int Width { get; set; } = 0; - - public int Height { get; set; } = 0; - - public List Directories { get; set; } = new List(); - - public List Items { get; set; } = new List(); - - } -} \ No newline at end of file diff --git a/Models/R4SaveFileModel.cs b/Models/R4SaveFileModel.cs deleted file mode 100644 index 983d2e5..0000000 --- a/Models/R4SaveFileModel.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Text; - -namespace BookmarkManager.Models -{ - public class R4SaveFileModel - { - public string SiteName { get; set; } - - public string SiteAddress { get; set; } - - public string SiteDescription { get; set; } - - public string TreeviewPath { get; set; } - - public string Notes { get; set; } - - - public string Path - { - get - { - if (string.IsNullOrWhiteSpace(TreeviewPath)) - { - return string.Empty; - } - - var path = this.TreeviewPath?.Trim('\\')?.Trim() ?? string.Empty; - if (!path.Contains("\\")) - { - return path?.Trim() ?? string.Empty; - } - - var sb = new StringBuilder(); - - var parts = path.Split("\\"); - for (var i = 1; i < parts.Length; i++) - { - var item = System.Web.HttpUtility.UrlDecode(parts[i]); - - sb.Append(item); - sb.Append("\n"); - } - - return sb.ToString()?.Trim() ?? string.Empty; - } - } - - } -} \ No newline at end of file diff --git a/OptionsForm.cs b/OptionsForm.cs deleted file mode 100644 index 0f38372..0000000 --- a/OptionsForm.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System.Windows.Forms; -using FizzyLauncher.Models; -using RyzStudio.Windows.Forms; -using RyzStudio.Windows.ThemedForms.PickerBox; - -namespace FizzyLauncher -{ - public class OptionsForm : Form - { - private TTogglePanelC panel1; - private TTogglePanelC panel3; - private ThYesNoPickerBox yesNoPickerBox1; - private Label label2; - private TTogglePanelC panel2; - private Label label1; - private ThYesNoPickerBox yesNoPickerBox2; - private Label label3; - private RyzStudio.Windows.ThemedForms.ButtonTextBox.ThClearableTextBox textBox1; - private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1; - private TFlowLayoutContainer flowLayoutContainer1; - - private AppOptions _appSession = null; - - - public OptionsForm(AppOptions appSession) - { - InitializeComponent(); - - UISetup.Dialog(this); - - _appSession = appSession; - - if (_appSession != null) - { - yesNoPickerBox1.Value = _appSession.RestorePosition; - yesNoPickerBox2.Value = _appSession.AlwaysOnTop; - textBox1.Text = _appSession.RunCommand ?? string.Empty; - } - } - - private void InitializeComponent() - { - panel1 = new TTogglePanelC(); - yesNoPickerBox1 = new ThYesNoPickerBox(); - label2 = new Label(); - panel2 = new TTogglePanelC(); - yesNoPickerBox2 = new ThYesNoPickerBox(); - label1 = new Label(); - panel3 = new TTogglePanelC(); - textBox1 = new RyzStudio.Windows.ThemedForms.ButtonTextBox.ThClearableTextBox(); - label3 = new Label(); - dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter(); - flowLayoutContainer1 = new TFlowLayoutContainer(); - panel1.SuspendLayout(); - panel2.SuspendLayout(); - panel3.SuspendLayout(); - flowLayoutContainer1.SuspendLayout(); - SuspendLayout(); - // - // panel1 - // - panel1.AutoScrollMargin = new System.Drawing.Size(0, 0); - panel1.AutoScrollMinSize = new System.Drawing.Size(0, 0); - panel1.Controls.Add(yesNoPickerBox1); - panel1.Controls.Add(label2); - panel1.ExpandedHeight = 86; - panel1.ForeColor = System.Drawing.Color.FromArgb(31, 31, 31); - panel1.IsOpen = true; - panel1.Location = new System.Drawing.Point(10, 10); - panel1.Margin = new Padding(0, 0, 0, 5); - panel1.Name = "panel1"; - panel1.Padding = new Padding(4, 32, 3, 3); - panel1.Size = new System.Drawing.Size(427, 86); - panel1.TabIndex = 0; - panel1.Title = "On Start-Up"; - panel1.TitleContextMenuStrip = null; - panel1.TitleCursor = Cursors.Default; - // - // yesNoPickerBox1 - // - yesNoPickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; - yesNoPickerBox1.BackColor = System.Drawing.Color.Transparent; - yesNoPickerBox1.EnableReactiveVisual = true; - yesNoPickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F); - yesNoPickerBox1.Location = new System.Drawing.Point(330, 42); - yesNoPickerBox1.Name = "yesNoPickerBox1"; - yesNoPickerBox1.Padding = new Padding(4, 4, 3, 3); - yesNoPickerBox1.SelectedIndex = 1; - yesNoPickerBox1.Size = new System.Drawing.Size(84, 34); - yesNoPickerBox1.TabIndex = 197; - yesNoPickerBox1.TabStop = false; - yesNoPickerBox1.Value = true; - // - // label2 - // - label2.AutoSize = true; - label2.BackColor = System.Drawing.Color.Transparent; - label2.ForeColor = System.Drawing.SystemColors.ControlText; - label2.Location = new System.Drawing.Point(9, 42); - label2.Margin = new Padding(0); - label2.Name = "label2"; - label2.Padding = new Padding(0, 8, 0, 0); - label2.Size = new System.Drawing.Size(92, 23); - label2.TabIndex = 196; - label2.Text = "Restore Position"; - label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // panel2 - // - panel2.AutoScrollMargin = new System.Drawing.Size(0, 0); - panel2.AutoScrollMinSize = new System.Drawing.Size(0, 0); - panel2.Controls.Add(yesNoPickerBox2); - panel2.Controls.Add(label1); - panel2.ExpandedHeight = 86; - panel2.ForeColor = System.Drawing.Color.FromArgb(31, 31, 31); - panel2.IsOpen = true; - panel2.Location = new System.Drawing.Point(10, 101); - panel2.Margin = new Padding(0, 0, 0, 5); - panel2.Name = "panel2"; - panel2.Padding = new Padding(4, 32, 3, 3); - panel2.Size = new System.Drawing.Size(427, 86); - panel2.TabIndex = 2; - panel2.Title = "Appearance"; - panel2.TitleContextMenuStrip = null; - panel2.TitleCursor = Cursors.Default; - // - // yesNoPickerBox2 - // - yesNoPickerBox2.Anchor = AnchorStyles.Top | AnchorStyles.Right; - yesNoPickerBox2.BackColor = System.Drawing.Color.Transparent; - yesNoPickerBox2.EnableReactiveVisual = true; - yesNoPickerBox2.Font = new System.Drawing.Font("Segoe UI", 9F); - yesNoPickerBox2.Location = new System.Drawing.Point(330, 42); - yesNoPickerBox2.Name = "yesNoPickerBox2"; - yesNoPickerBox2.Padding = new Padding(4, 4, 3, 3); - yesNoPickerBox2.SelectedIndex = 1; - yesNoPickerBox2.Size = new System.Drawing.Size(84, 34); - yesNoPickerBox2.TabIndex = 198; - yesNoPickerBox2.TabStop = false; - yesNoPickerBox2.Value = true; - // - // label1 - // - label1.AutoSize = true; - label1.BackColor = System.Drawing.Color.Transparent; - label1.ForeColor = System.Drawing.SystemColors.ControlText; - label1.Location = new System.Drawing.Point(9, 42); - label1.Margin = new Padding(0); - label1.Name = "label1"; - label1.Padding = new Padding(0, 8, 0, 0); - label1.Size = new System.Drawing.Size(85, 23); - label1.TabIndex = 196; - label1.Text = "Always On Top"; - label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // panel3 - // - panel3.AutoScrollMargin = new System.Drawing.Size(0, 0); - panel3.AutoScrollMinSize = new System.Drawing.Size(0, 0); - panel3.Controls.Add(textBox1); - panel3.Controls.Add(label3); - panel3.ExpandedHeight = 86; - panel3.ForeColor = System.Drawing.Color.FromArgb(31, 31, 31); - panel3.IsOpen = true; - panel3.Location = new System.Drawing.Point(10, 192); - panel3.Margin = new Padding(0, 0, 0, 5); - panel3.Name = "panel3"; - panel3.Padding = new Padding(4, 32, 3, 3); - panel3.Size = new System.Drawing.Size(427, 86); - panel3.TabIndex = 1; - panel3.Title = "Behaviour"; - panel3.TitleContextMenuStrip = null; - panel3.TitleCursor = Cursors.Default; - // - // textBox1 - // - textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - textBox1.BackColor = System.Drawing.Color.Transparent; - textBox1.ClearedValue = "{0}"; - textBox1.EnableReactiveVisual = true; - textBox1.Font = new System.Drawing.Font("Segoe UI", 9F); - textBox1.Icon = "O"; - textBox1.IconSize = 13F; - textBox1.Location = new System.Drawing.Point(165, 42); - textBox1.Name = "textBox1"; - textBox1.Padding = new Padding(4, 4, 3, 3); - textBox1.Size = new System.Drawing.Size(249, 32); - textBox1.TabIndex = 203; - textBox1.TabStop = false; - textBox1.UseSystemPasswordChar = false; - // - // label3 - // - label3.AutoSize = true; - label3.BackColor = System.Drawing.Color.Transparent; - label3.ForeColor = System.Drawing.SystemColors.ControlText; - label3.Location = new System.Drawing.Point(9, 42); - label3.Margin = new Padding(0); - label3.Name = "label3"; - label3.Padding = new Padding(0, 8, 0, 0); - label3.Size = new System.Drawing.Size(88, 23); - label3.TabIndex = 199; - label3.Text = "Run Command"; - label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // dialogFooter1 - // - dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240); - dialogFooter1.Button1Text = "&Save"; - dialogFooter1.Dialog = this; - dialogFooter1.Dock = DockStyle.Bottom; - dialogFooter1.IsBusy = false; - dialogFooter1.Location = new System.Drawing.Point(0, 477); - dialogFooter1.Name = "dialogFooter1"; - dialogFooter1.Size = new System.Drawing.Size(444, 84); - // - // flowLayoutContainer1 - // - flowLayoutContainer1.AutoScroll = true; - flowLayoutContainer1.Controls.Add(panel1); - flowLayoutContainer1.Controls.Add(panel2); - flowLayoutContainer1.Controls.Add(panel3); - flowLayoutContainer1.Dock = DockStyle.Fill; - flowLayoutContainer1.Location = new System.Drawing.Point(0, 0); - flowLayoutContainer1.Name = "flowLayoutContainer1"; - flowLayoutContainer1.Padding = new Padding(10, 10, 10, 30); - flowLayoutContainer1.Size = new System.Drawing.Size(444, 477); - flowLayoutContainer1.TabIndex = 195; - // - // OptionsForm - // - AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - BackColor = System.Drawing.Color.WhiteSmoke; - ClientSize = new System.Drawing.Size(444, 561); - Controls.Add(flowLayoutContainer1); - Controls.Add(dialogFooter1); - MinimumSize = new System.Drawing.Size(460, 600); - Name = "OptionsForm"; - Text = "Options"; - panel1.ResumeLayout(false); - panel1.PerformLayout(); - panel2.ResumeLayout(false); - panel2.PerformLayout(); - panel3.ResumeLayout(false); - panel3.PerformLayout(); - flowLayoutContainer1.ResumeLayout(false); - ResumeLayout(false); - } - - public AppOptions Result - { - get - { - if (_appSession == null) - { - _appSession = new AppOptions(); - } - - _appSession.RestorePosition = yesNoPickerBox1.Value; - _appSession.AlwaysOnTop = yesNoPickerBox2.Value; - _appSession.RunCommand = textBox1.Text ?? string.Empty; - - return _appSession; - } - } - - } -} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 54c0a42..bc1f16b 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,7 @@ -using BookmarkManager; -using RyzStudio.IO; using System; using System.Windows.Forms; -namespace FizzyLauncher +namespace BukkuBuddy { static class Program { diff --git a/Resources/MainMenu/folder-minus.png b/Resources/MainMenu/folder-minus.png new file mode 100644 index 0000000..655cfd8 Binary files /dev/null and b/Resources/MainMenu/folder-minus.png differ diff --git a/Resources/MainMenu/help-circle.png b/Resources/MainMenu/help-circle.png new file mode 100644 index 0000000..fa87ded Binary files /dev/null and b/Resources/MainMenu/help-circle.png differ diff --git a/Resources/MainMenu/save.png b/Resources/MainMenu/save.png new file mode 100644 index 0000000..72dfc90 Binary files /dev/null and b/Resources/MainMenu/save.png differ diff --git a/Resources/MainMenu/search.png b/Resources/MainMenu/search.png new file mode 100644 index 0000000..0cdbcd5 Binary files /dev/null and b/Resources/MainMenu/search.png differ diff --git a/Resources/MainMenu/settings.png b/Resources/MainMenu/settings.png new file mode 100644 index 0000000..e4e4b3a Binary files /dev/null and b/Resources/MainMenu/settings.png differ diff --git a/AppResource.Designer.cs b/Resources/MainMenuResource.Designer.cs similarity index 71% rename from AppResource.Designer.cs rename to Resources/MainMenuResource.Designer.cs index 7cb009e..92209da 100644 --- a/AppResource.Designer.cs +++ b/Resources/MainMenuResource.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace BookmarkManager { +namespace BukkuBuddy.Resources { using System; @@ -19,17 +19,17 @@ namespace BookmarkManager { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class AppResource { + internal class MainMenuResource { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal AppResource() { + internal MainMenuResource() { } /// @@ -39,7 +39,7 @@ namespace BookmarkManager { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BookmarkManager.AppResource", typeof(AppResource).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BukkuBuddy.Resources.MainMenuResource", typeof(MainMenuResource).Assembly); resourceMan = temp; } return resourceMan; @@ -99,9 +99,9 @@ namespace BookmarkManager { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap arrow_down_circle { + internal static System.Drawing.Bitmap folder_minus { get { - object obj = ResourceManager.GetObject("arrow_down_circle", resourceCulture); + object obj = ResourceManager.GetObject("folder_minus", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -109,59 +109,9 @@ namespace BookmarkManager { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap arrow_up_circle { + internal static System.Drawing.Bitmap help_circle { get { - object obj = ResourceManager.GetObject("arrow_up_circle", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap bookmark { - get { - object obj = ResourceManager.GetObject("bookmark", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap file_text { - get { - object obj = ResourceManager.GetObject("file_text", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap folder { - get { - object obj = ResourceManager.GetObject("folder", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap folder_explore { - get { - object obj = ResourceManager.GetObject("folder_explore", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap hexagon { - get { - object obj = ResourceManager.GetObject("hexagon", resourceCulture); + object obj = ResourceManager.GetObject("help_circle", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -179,9 +129,29 @@ namespace BookmarkManager { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap trash { + internal static System.Drawing.Bitmap save { get { - object obj = ResourceManager.GetObject("trash", resourceCulture); + object obj = ResourceManager.GetObject("save", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap search { + get { + object obj = ResourceManager.GetObject("search", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap settings { + get { + object obj = ResourceManager.GetObject("settings", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/AppResource.resx b/Resources/MainMenuResource.resx similarity index 78% rename from AppResource.resx rename to Resources/MainMenuResource.resx index 6581710..ce50ede 100644 --- a/AppResource.resx +++ b/Resources/MainMenuResource.resx @@ -130,31 +130,22 @@ https://www.hiimray.co.uk/software-bookmark-manager - - Resources\arrow-down-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + MainMenu\folder-minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Resources\arrow-up-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\bookmark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\file-text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\folder_explore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - Resources\hexagon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + MainMenu\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Resources\icon-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + icon-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Resources\trash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + MainMenu\save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + MainMenu\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + MainMenu\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/Resources/TreeView/arrow-down.png b/Resources/TreeView/arrow-down.png new file mode 100644 index 0000000..9448df5 Binary files /dev/null and b/Resources/TreeView/arrow-down.png differ diff --git a/Resources/TreeView/arrow-up.png b/Resources/TreeView/arrow-up.png new file mode 100644 index 0000000..648b6b2 Binary files /dev/null and b/Resources/TreeView/arrow-up.png differ diff --git a/Resources/TreeView/bookmark16_blue.png b/Resources/TreeView/bookmark16_blue.png new file mode 100644 index 0000000..af46f4b Binary files /dev/null and b/Resources/TreeView/bookmark16_blue.png differ diff --git a/Resources/TreeView/bookmark16_red.png b/Resources/TreeView/bookmark16_red.png new file mode 100644 index 0000000..9117a74 Binary files /dev/null and b/Resources/TreeView/bookmark16_red.png differ diff --git a/Resources/TreeView/bookmark16_white.png b/Resources/TreeView/bookmark16_white.png new file mode 100644 index 0000000..3ae9640 Binary files /dev/null and b/Resources/TreeView/bookmark16_white.png differ diff --git a/Resources/TreeView/bookmark_root.png b/Resources/TreeView/bookmark_root.png new file mode 100644 index 0000000..0b019f3 Binary files /dev/null and b/Resources/TreeView/bookmark_root.png differ diff --git a/Resources/TreeView/bookmark_root.svg b/Resources/TreeView/bookmark_root.svg new file mode 100644 index 0000000..4949193 --- /dev/null +++ b/Resources/TreeView/bookmark_root.svg @@ -0,0 +1,47 @@ + + + + + + diff --git a/Resources/TreeView/file-question-mark.png b/Resources/TreeView/file-question-mark.png new file mode 100644 index 0000000..e112b66 Binary files /dev/null and b/Resources/TreeView/file-question-mark.png differ diff --git a/Resources/TreeView/file-question-mark16.svg b/Resources/TreeView/file-question-mark16.svg new file mode 100644 index 0000000..dbe597d --- /dev/null +++ b/Resources/TreeView/file-question-mark16.svg @@ -0,0 +1,60 @@ + + + + + + + + + + diff --git a/Resources/TreeView/folder-symlink.png b/Resources/TreeView/folder-symlink.png new file mode 100644 index 0000000..8edffb6 Binary files /dev/null and b/Resources/TreeView/folder-symlink.png differ diff --git a/Resources/TreeView/folder-symlink16.svg b/Resources/TreeView/folder-symlink16.svg new file mode 100644 index 0000000..cf40b29 --- /dev/null +++ b/Resources/TreeView/folder-symlink16.svg @@ -0,0 +1,65 @@ + + + + + + + + diff --git a/Resources/TreeView/folder.png b/Resources/TreeView/folder.png new file mode 100644 index 0000000..ee2885a Binary files /dev/null and b/Resources/TreeView/folder.png differ diff --git a/Resources/TreeView/folder16.svg b/Resources/TreeView/folder16.svg new file mode 100644 index 0000000..1345c97 --- /dev/null +++ b/Resources/TreeView/folder16.svg @@ -0,0 +1,48 @@ + + + + + + diff --git a/Resources/TreeView/plus-square.png b/Resources/TreeView/plus-square.png new file mode 100644 index 0000000..4bcd26e Binary files /dev/null and b/Resources/TreeView/plus-square.png differ diff --git a/Resources/TreeView/plus.png b/Resources/TreeView/plus.png new file mode 100644 index 0000000..21c5be4 Binary files /dev/null and b/Resources/TreeView/plus.png differ diff --git a/Resources/TreeView/trash-2.png b/Resources/TreeView/trash-2.png new file mode 100644 index 0000000..f04f773 Binary files /dev/null and b/Resources/TreeView/trash-2.png differ diff --git a/Resources/TreeViewResource.Designer.cs b/Resources/TreeViewResource.Designer.cs new file mode 100644 index 0000000..3a65ada --- /dev/null +++ b/Resources/TreeViewResource.Designer.cs @@ -0,0 +1,153 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace BukkuBuddy.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class TreeViewResource { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal TreeViewResource() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BukkuBuddy.Resources.TreeViewResource", typeof(TreeViewResource).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrow_down { + get { + object obj = ResourceManager.GetObject("arrow_down", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrow_up { + get { + object obj = ResourceManager.GetObject("arrow_up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap bookmark_root { + get { + object obj = ResourceManager.GetObject("bookmark_root", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap file_question_mark { + get { + object obj = ResourceManager.GetObject("file_question_mark", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap folder { + get { + object obj = ResourceManager.GetObject("folder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap folder_symlink { + get { + object obj = ResourceManager.GetObject("folder_symlink", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus_square { + get { + object obj = ResourceManager.GetObject("plus_square", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap trash_2 { + get { + object obj = ResourceManager.GetObject("trash_2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Resources/TreeViewResource.resx b/Resources/TreeViewResource.resx new file mode 100644 index 0000000..155a6c7 --- /dev/null +++ b/Resources/TreeViewResource.resx @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + TreeView\arrow-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\arrow-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\bookmark_root.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\file-question-mark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\folder-symlink.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\plus-square.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + TreeView\trash-2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Resources/arrow-down-circle.png b/Resources/arrow-down-circle.png deleted file mode 100644 index 08dd857..0000000 Binary files a/Resources/arrow-down-circle.png and /dev/null differ diff --git a/Resources/arrow-up-circle.png b/Resources/arrow-up-circle.png deleted file mode 100644 index a4dd233..0000000 Binary files a/Resources/arrow-up-circle.png and /dev/null differ diff --git a/Resources/bookmark.png b/Resources/bookmark.png deleted file mode 100644 index 786e869..0000000 Binary files a/Resources/bookmark.png and /dev/null differ diff --git a/Resources/file-text.png b/Resources/file-text.png deleted file mode 100644 index 4772be9..0000000 Binary files a/Resources/file-text.png and /dev/null differ diff --git a/Resources/file.png b/Resources/file.png deleted file mode 100644 index c4b89eb..0000000 Binary files a/Resources/file.png and /dev/null differ diff --git a/Resources/folder.png b/Resources/folder.png deleted file mode 100644 index 7ec26c4..0000000 Binary files a/Resources/folder.png and /dev/null differ diff --git a/Resources/folder_explore.png b/Resources/folder_explore.png deleted file mode 100644 index 6fdc0bb..0000000 Binary files a/Resources/folder_explore.png and /dev/null differ diff --git a/Resources/help-circle.png b/Resources/help-circle.png deleted file mode 100644 index 67ebb12..0000000 Binary files a/Resources/help-circle.png and /dev/null differ diff --git a/Resources/hexagon.png b/Resources/hexagon.png deleted file mode 100644 index 01e6fdb..0000000 Binary files a/Resources/hexagon.png and /dev/null differ diff --git a/Resources/save.png b/Resources/save.png deleted file mode 100644 index 32a78fa..0000000 Binary files a/Resources/save.png and /dev/null differ diff --git a/Resources/search-2.png b/Resources/search-2.png deleted file mode 100644 index d934a57..0000000 Binary files a/Resources/search-2.png and /dev/null differ diff --git a/Resources/search.png b/Resources/search.png deleted file mode 100644 index 99c44ae..0000000 Binary files a/Resources/search.png and /dev/null differ diff --git a/Resources/settings.png b/Resources/settings.png deleted file mode 100644 index e0d4aa4..0000000 Binary files a/Resources/settings.png and /dev/null differ diff --git a/Resources/trash.png b/Resources/trash.png deleted file mode 100644 index 14a137e..0000000 Binary files a/Resources/trash.png and /dev/null differ diff --git a/Services/WebProvider.cs b/Services/WebPageService.cs similarity index 64% rename from Services/WebProvider.cs rename to Services/WebPageService.cs index 710c0dc..ab85ef4 100644 --- a/Services/WebProvider.cs +++ b/Services/WebPageService.cs @@ -1,184 +1,126 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Linq; using System.Net; +using System.Net.Http; +using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; using HtmlAgilityPack; -using RyzStudio.Net; -namespace BookmarkManager.Services +namespace BukkuBuddy.Services { - public class WebProvider + public class WebPageService { - private readonly WebClientProvider _webClientProvider; + private readonly HttpClient _httpClient; - public WebProvider() + public WebPageService(bool allowUnsafeSSL, int timeout, bool allowCookies, bool allowRedirect) { - _webClientProvider = new WebClientProvider(); - _webClientProvider.Timeout = 4; - } + var handler = new HttpClientHandler(); + handler.AllowAutoRedirect = allowRedirect; - - public bool IgnoreSSL - { - get => _webClientProvider.IgnoreSSL; - set + if (allowUnsafeSSL) { - _webClientProvider.IgnoreSSL = value; + handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; } + + if (allowCookies) + { + handler.UseCookies = allowCookies; + handler.CookieContainer = new CookieContainer(); + } + + _httpClient = new HttpClient(handler); + _httpClient.Timeout = TimeSpan.FromSeconds(timeout); } - public async Task RetrieveHtmlDocument(string url) + public async Task GetDocument(string url, CancellationToken cancellationToken = default) { - var sourceCode = await this.RetrieveSourceCode(url); + var sourceCode = await this.GetSource(url, cancellationToken); if (string.IsNullOrWhiteSpace(sourceCode)) { return null; } var document = new HtmlAgilityPack.HtmlDocument(); - - try - { - document.LoadHtml(sourceCode); - } - catch (Exception) - { - return null; - } + document.LoadHtml(sourceCode); return document; } - public async Task RetrieveSourceCode(string url) + public async Task GetSource(string url, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(url)) { return null; } - if (!Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) + var userAgent = GenerateUserAgent(); + + using var request = new HttpRequestMessage(HttpMethod.Get, url); + request.Headers.UserAgent.ParseAdd(userAgent); + + using var response = await _httpClient.SendAsync(request, cancellationToken); + if (!response.IsSuccessStatusCode) { return null; } - System.Net.Http.HttpResponseMessage response; + response.EnsureSuccessStatusCode(); - try - { - response = await _webClientProvider.Get(url?.Trim()); - } - catch (Exception) - { - return null; - } - - if (response == null) - { - return null; - - } - - if (response.StatusCode != HttpStatusCode.OK) - { - return null; - } - - var sourceCode = ""; - - try - { - sourceCode = await response?.Content?.ReadAsStringAsync(); - } - catch (Exception) - { - // do nothing - } - - if (string.IsNullOrWhiteSpace(sourceCode)) - { - return null; - } - - return sourceCode; + return await response.Content.ReadAsStringAsync(cancellationToken); } - public async Task RetrieveImage(string url) + public async Task GetImage(string url, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(url)) - { - return null; - } - - if (!Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) - { - return null; - } - - System.Net.Http.HttpResponseMessage response; - try { - response = await _webClientProvider.Get(url?.Trim()); + var userAgent = GenerateUserAgent(); + + using var request = new HttpRequestMessage(HttpMethod.Get, url); + request.Headers.UserAgent.ParseAdd(userAgent); + + + using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + if (!response.IsSuccessStatusCode) + { + return null; + } + + response.EnsureSuccessStatusCode(); + + var contentType = response.Content.Headers.ContentType?.MediaType; + if (contentType == null || !contentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase)) + { + return null; + } + + await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken); + + using var memoryStream = new MemoryStream(); + await stream.CopyToAsync(memoryStream, cancellationToken); + memoryStream.Position = 0; + + var image = Image.FromStream(memoryStream); + + return new Bitmap(image); } catch (Exception) { - return null; + // Do nothing } - if (response.StatusCode != HttpStatusCode.OK) - { - return null; - } - - var stream = await response?.Content?.ReadAsStreamAsync(); - - Image result = null; - - try - { - result = Image.FromStream(stream); - } - catch (Exception) - { - return null; - } - - return result; - } - - public async Task RetrieveImage(string url, HtmlAgilityPack.HtmlDocument document) - { - var iconUrl = this.ParseFavicon(document); - if (string.IsNullOrWhiteSpace(iconUrl)) - { - 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); + return null; } public string ParseTitle(HtmlAgilityPack.HtmlDocument document) { - string result = null; - // Find basic title - result = FindNodeValue(document, "//title", string.Empty)?.Trim(); + var result = FindNodeValue(document, "//title", string.Empty)?.Trim(); if (!string.IsNullOrWhiteSpace(result)) { return result; @@ -204,7 +146,7 @@ namespace BookmarkManager.Services return result; } - return string.Empty; + return null; } public string ParseDescription(HtmlAgilityPack.HtmlDocument document) @@ -272,6 +214,22 @@ namespace BookmarkManager.Services return string.Empty; } + public bool IsValidUrl(string url) + { + if (string.IsNullOrWhiteSpace(url)) + { + return false; + } + + if (!url.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !url.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase)) + { + return false; + } + + return true; + } + + private string FindNodeValue(HtmlAgilityPack.HtmlDocument document, string xPath, string defaultValue = "") { var hnc = document.DocumentNode.SelectNodes(xPath); @@ -423,5 +381,48 @@ namespace BookmarkManager.Services return false; } + private string GenerateUserAgent() + { + var os = GetWindowsVersion(); + var arch = RuntimeInformation.OSArchitecture switch + { + Architecture.X64 => "Win64; x64", + Architecture.X86 => "Win32", + Architecture.Arm64 => "ARM64", + _ => "Win64; x64" + }; + + var chromeVersion = GetChromeLikeVersion(); + + return $"Mozilla/5.0 (Windows NT {os}; {arch}) Momozilla/5.0 () AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{chromeVersion} Safari/537.36"; + } + + private string GetWindowsVersion() + { + var v = Environment.OSVersion.Version; + + // Map to common Windows NT versions + return v.Major switch + { + 10 => "10.0", // Windows 10/11 both report 10.0 + 6 when v.Minor == 3 => "6.3", // Windows 8.1 + 6 when v.Minor == 2 => "6.2", // Windows 8 + 6 when v.Minor == 1 => "6.1", // Windows 7 + _ => $"{v.Major}.{v.Minor}" + }; + } + + private string GetChromeLikeVersion() + { + // You can hardcode or randomize within a realistic range + var rnd = new Random(); + + int major = rnd.Next(120, 126); // recent Chrome versions + int build = rnd.Next(0, 7000); + int patch = rnd.Next(0, 200); + + return $"{major}.0.{build}.{patch}"; + } + } } \ No newline at end of file diff --git a/UpdateIconsForm.cs b/UpdateIconsForm.cs deleted file mode 100644 index 4987173..0000000 --- a/UpdateIconsForm.cs +++ /dev/null @@ -1,438 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using BookmarkManager.Services; -using bzit.bomg.Models; -using RyzStudio.Windows.Forms; -using RyzStudio.Windows.ThemedForms; -using RyzStudio.Windows.ThemedForms.PickerBox; - -namespace FizzyLauncher -{ - public class UpdateIconsForm : Form - { - private System.Windows.Forms.Label label1; - private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator2; - private Label label2; - private ThYesNoPickerBox pickerBox1; - private ThButton button2; - private RyzStudio.Windows.ThemedForms.ThProgressBar progressBar1; - - - private readonly WebProvider _webProvider; - private BookmarkTreeView _treeView; - private bool _isBusy = false; - private Label label4; - private THorizontalSeparator tHorizontalSeparator3; - private ThButton button3; - private ThProgressBar progressBar2; - private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1; - private bool _requestCancel = false; - - - public UpdateIconsForm(BookmarkTreeView treeView) - { - InitializeComponent(); - - UISetup.Dialog(this); - - _webProvider = new WebProvider(); - _webProvider.IgnoreSSL = true; - - _treeView = treeView; - } - - private void InitializeComponent() - { - label1 = new Label(); - tHorizontalSeparator2 = new THorizontalSeparator(); - label2 = new Label(); - pickerBox1 = new ThYesNoPickerBox(); - button2 = new ThButton(); - progressBar1 = new ThProgressBar(); - label4 = new Label(); - tHorizontalSeparator3 = new THorizontalSeparator(); - button3 = new ThButton(); - progressBar2 = new ThProgressBar(); - dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter(); - 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(156, 23); - label1.TabIndex = 153; - label1.Text = "Update Missing Icons (Only)"; - label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // tHorizontalSeparator2 - // - 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; - tHorizontalSeparator2.Location = new System.Drawing.Point(10, 64); - 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; - // - // label2 - // - label2.AutoSize = true; - label2.BackColor = System.Drawing.Color.Transparent; - label2.ForeColor = System.Drawing.SystemColors.ControlText; - label2.Location = new System.Drawing.Point(10, 136); - label2.Margin = new Padding(0); - label2.Name = "label2"; - label2.Padding = new Padding(0, 8, 0, 0); - label2.Size = new System.Drawing.Size(231, 23); - label2.TabIndex = 195; - label2.Text = "Retrieve supported icons from bookmarks."; - label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // pickerBox1 - // - pickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; - pickerBox1.BackColor = System.Drawing.Color.Transparent; - pickerBox1.EnableReactiveVisual = true; - pickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F); - pickerBox1.Location = new System.Drawing.Point(350, 20); - pickerBox1.Name = "pickerBox1"; - pickerBox1.Padding = new Padding(4, 4, 3, 3); - pickerBox1.SelectedIndex = 1; - pickerBox1.Size = new System.Drawing.Size(84, 35); - pickerBox1.TabIndex = 0; - pickerBox1.TabStop = false; - pickerBox1.Value = true; - // - // button2 - // - 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"; - button2.Location = new System.Drawing.Point(306, 136); - button2.Name = "button2"; - button2.Padding = new Padding(4, 4, 3, 3); - button2.Size = new System.Drawing.Size(128, 32); - button2.TabIndex = 1; - button2.TabStop = false; - button2.MouseClick += button2_MouseClick; - // - // progressBar1 - // - progressBar1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - progressBar1.BackColor = System.Drawing.Color.Transparent; - progressBar1.BarColour = System.Drawing.Color.FromArgb(79, 202, 130); - progressBar1.BarTextColour = System.Drawing.Color.Black; - progressBar1.EnableReactiveVisual = false; - progressBar1.Font = new System.Drawing.Font("Segoe UI", 9F); - progressBar1.Location = new System.Drawing.Point(10, 96); - progressBar1.Maximum = 100; - progressBar1.Minimum = 0; - progressBar1.Name = "progressBar1"; - progressBar1.Padding = new Padding(4, 4, 3, 3); - progressBar1.ProgressText = "50/100"; - progressBar1.ShowProgressText = true; - progressBar1.Size = new System.Drawing.Size(424, 20); - progressBar1.TabIndex = 206; - progressBar1.TabStop = false; - progressBar1.Value = 50; - // - // label4 - // - label4.AutoSize = true; - label4.BackColor = System.Drawing.Color.Transparent; - label4.ForeColor = System.Drawing.SystemColors.ControlText; - label4.Location = new System.Drawing.Point(10, 250); - 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; - tHorizontalSeparator3.Location = new System.Drawing.Point(10, 178); - 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"; - button3.Location = new System.Drawing.Point(306, 250); - button3.Name = "button3"; - button3.Padding = new Padding(4, 4, 3, 3); - button3.Size = new System.Drawing.Size(128, 32); - button3.TabIndex = 209; - button3.TabStop = false; - button3.MouseClick += button3_MouseClick; - // - // 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); - progressBar2.Location = new System.Drawing.Point(10, 210); - progressBar2.Maximum = 100; - progressBar2.Minimum = 0; - progressBar2.Name = "progressBar2"; - progressBar2.Padding = new Padding(4, 4, 3, 3); - 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, 477); - dialogFooter1.Name = "dialogFooter1"; - dialogFooter1.Size = new System.Drawing.Size(444, 84); - // - // UpdateIconsForm - // - AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - BackColor = System.Drawing.Color.White; - ClientSize = new System.Drawing.Size(444, 561); - Controls.Add(dialogFooter1); - Controls.Add(progressBar2); - Controls.Add(button3); - Controls.Add(label4); - Controls.Add(tHorizontalSeparator3); - 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, 600); - Name = "UpdateIconsForm"; - Text = "Update Icons"; - ResumeLayout(false); - PerformLayout(); - } - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - var model = _treeView.ToNodeList(); - - if (pickerBox1.Value) - { - model = model.Where(x => x.Value.Icon == null)?.ToList() ?? new List>(); - } - - progressBar1.Minimum = 0; - progressBar1.Value = 0; - progressBar1.Maximum = model.Count; - - progressBar2.Minimum = 0; - progressBar2.Value = 0; - progressBar2.Maximum = model.Count; - - pickerBox1.Focus(); - } - - protected override void OnClosing(CancelEventArgs e) - { - base.OnClosing(e); - - if (this.IsBusy) - { - e.Cancel = true; - } - } - - - protected bool IsBusy - { - get => _isBusy; - set - { - _isBusy = value; - - UIControl.SetEnable(pickerBox1, !this.IsBusy); - UIControl.Invoke(button2, (x) => - { - button2.LabelText = (this.IsBusy ? "&Stop" : "&Run"); - }); - UIControl.Invoke(button3, (x) => - { - button3.LabelText = (this.IsBusy ? "&Stop" : "Clear &All"); - }); - - dialogFooter1.IsBusy = _isBusy; - } - } - - - private async void button2_MouseClick(object sender, MouseEventArgs e) - { - await Task.Run(async () => - { - if (this.IsBusy) - { - _requestCancel = true; - return; - } - - this.IsBusy = true; - - var model = _treeView.ToNodeList(); - - if (pickerBox1.Value) - { - model = model.Where(x => x.Value.Icon == null)?.ToList() ?? new List>(); - } - - progressBar1.Minimum = 0; - progressBar1.Value = 0; - progressBar1.Maximum = model.Count; - - foreach (var item in model) - { - progressBar1.Value++; - - if (string.IsNullOrWhiteSpace(item.Value.Address)) - { - continue; - } - - if (_requestCancel) - { - break; - } - - var document = await _webProvider.RetrieveHtmlDocument(item.Value.Address); - if (document == null) - { - continue; - } - - if (_requestCancel) - { - break; - } - - 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; - } - - _treeView.UpdateNode(item.Key, newModel); - } - - _requestCancel = false; - - this.IsBusy = false; - }); - } - - private async void button3_MouseClick(object sender, MouseEventArgs e) - { - await Task.Run(() => - { - if (this.IsBusy) - { - _requestCancel = true; - return; - } - - this.IsBusy = true; - - var model = _treeView.ToNodeList(); - - progressBar2.Minimum = 0; - progressBar2.Value = 0; - progressBar2.Maximum = model.Count; - - foreach (var item in model) - { - progressBar2.Value++; - - if (item.Value.Icon == null) - { - continue; - } - - if (_requestCancel) - { - break; - } - - var newModel = item.Value; - newModel.Icon = null; - - _treeView.UpdateNode(item.Key, newModel); - } - - _requestCancel = false; - - this.IsBusy = false; - }); - } - - } -} \ No newline at end of file diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs index c40c7bd..2c5a7ff 100644 --- a/Windows/Forms/BookmarkTreeView.cs +++ b/Windows/Forms/BookmarkTreeView.cs @@ -4,14 +4,17 @@ using System.ComponentModel; using System.Drawing; using System.Linq; using System.Windows.Forms; -using bzit.bomg.Models; -using FizzyLauncher; -using Resources = BookmarkManager.AppResource; +using BukkuBuddy; +using BukkuBuddy.DTOs.SaveFile; +using BukkuBuddy.Resources; namespace RyzStudio.Windows.Forms { public partial class BookmarkTreeView : TTreeView { + public delegate bool EditNodeDelegate(BookmarkTreeView sender, TreeNode node, App6Options.Item model); + public delegate void OnChangedDelegate(BookmarkTreeView sender, bool hasChanged); + public enum NodeIcon { Root = 0, @@ -30,6 +33,7 @@ namespace RyzStudio.Windows.Forms protected const string DEFAULT_NEW_FOLDER_NAME = "New Folder"; + protected const string DEFAULT_NEW_PAGE_NAME = "New Page"; public BookmarkTreeView() @@ -43,7 +47,7 @@ namespace RyzStudio.Windows.Forms this.ImageList.ImageSize = new Size(16, 16); this.ImageList.TransparentColor = Color.Transparent; - ClearImageList(); + this.Clear(false, true); } @@ -74,7 +78,7 @@ namespace RyzStudio.Windows.Forms protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e) { - TreeNode tn = this.SelectedNode; + var tn = this.SelectedNode; if (tn == null) { return; @@ -142,7 +146,7 @@ namespace RyzStudio.Windows.Forms break; case NodeType.Page: - var viewModel = UIControl.GetTag(this.SelectedNode); + var viewModel = UIControl.GetTag(this.SelectedNode); if (viewModel != null) { try @@ -203,11 +207,22 @@ namespace RyzStudio.Windows.Forms set { base.HasChanged = value; + + if (this.OnChanged != null) + { + this.OnChanged(this, value); + } } } + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public EditNodeDelegate OnEditNode { get; set; } - public TreeNode AddFolder(TreeNode node = null, string name = "", bool quol = true) + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new OnChangedDelegate OnChanged { get; set; } + + + public TreeNode AddFolder(TreeNode node = null, string name = "") { if (node == null) { @@ -228,14 +243,11 @@ namespace RyzStudio.Windows.Forms var key = EncodeNodeName(name); var treeNode = node.Nodes.Add(key, name, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2); - if (quol) - { - node.Expand(); + node.Expand(); - this.SelectedNode = treeNode; + this.SelectedNode = treeNode; - this.EditNode(treeNode); - } + this.EditNode(treeNode); this.HasChanged = true; @@ -249,45 +261,65 @@ namespace RyzStudio.Windows.Forms node = this.SelectedNode; } + if (this.OnEditNode == null) + { + return null; + } + var nodeType = GetNodeType(node); if ((nodeType != NodeType.Root) && (nodeType != NodeType.Folder)) { return null; } - var form = new EditBookmarkForm(); - if (form.ShowDialog() == DialogResult.OK) + var newItem = new App6Options.Item() { - var model = form.Result; - model.Path = GetNodePath(node); + Id = Guid.NewGuid(), + Title = DEFAULT_NEW_PAGE_NAME, + Path = GetNodePath(node) + }; - var newNode = this.AddNode(model); - if (newNode != null) - { - newNode.EnsureVisible(); + var newNode = this.AddNode(newItem); - this.SelectedNode = newNode; + var result = this.OnEditNode(this, newNode, newItem); + if (result) + { + newNode.EnsureVisible(); - this.HasChanged = true; + this.SelectedNode = newNode; + this.HasChanged = true; - return newNode; - } + return newNode; } + else + { + this.DeleteNode(newNode); - return null; + return null; + } } - public TreeNode AddNode(BookmarkModel model) + public TreeNode AddNode(App6Options.Item model) { + if (model.Id == Guid.Empty) + { + model.Id = Guid.NewGuid(); + } + var parentNode = this.CreateNodePath(model?.Path?.Trim() ?? string.Empty, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2); // Add custom favicon - var n = AddImage(model.Id.ToString(), model.Icon); + var hasIcon = AddImage(model.Id.ToString(), model.Icon); - TreeNode newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, n, n); + var newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, (int)NodeIcon.Default, (int)NodeIcon.Default); newNode.Tag = model; newNode.ToolTipText = model.ToString(); + if (hasIcon) + { + newNode.ImageKey = newNode.SelectedImageKey = model.Id.ToString(); + } + UIControl.Add(parentNode, newNode); this.HasChanged = true; @@ -295,16 +327,28 @@ namespace RyzStudio.Windows.Forms return newNode; } - public void Clear(string rootName) + public void Clear(bool deleteNodes, bool deleteIcons, string rootName = "") { - ClearImageList(); - - UIControl.Clear(this); - - UIControl.Invoke(this, (x) => + if (deleteNodes) { - this.Nodes.Add("", rootName?.Trim() ?? string.Empty, (int)NodeIcon.Root, (int)NodeIcon.Root); - }); + UIControl.Invoke(this, (x) => + { + this.Nodes.Clear(); + this.Nodes.Add("", rootName?.Trim() ?? string.Empty, (int)NodeIcon.Root, (int)NodeIcon.Root); + }); + } + + if (deleteIcons) + { + UIControl.Invoke(this, (x) => + { + this.ImageList.Images.Clear(); + this.ImageList.Images.Add(TreeViewResource.bookmark_root); + this.ImageList.Images.Add(TreeViewResource.folder); + this.ImageList.Images.Add(TreeViewResource.folder_symlink); + this.ImageList.Images.Add("default", TreeViewResource.file_question_mark); + }); + } this.HasChanged = true; } @@ -330,14 +374,10 @@ namespace RyzStudio.Windows.Forms } else if (nodeType == NodeType.Page) { - var model = UIControl.GetTag(node); + var model = UIControl.GetTag(node); model.Path = GetNodePath(node); - var form = new EditBookmarkForm(model); - if (form.ShowDialog() == DialogResult.OK) - { - this.UpdateNode(node, form.Result); - } + if (this.OnEditNode != null) this.OnEditNode(this, node, model); } return node; @@ -368,7 +408,7 @@ namespace RyzStudio.Windows.Forms } else { - if (node.Tag is BookmarkModel) + if (node.Tag is App6Options.Item) { return NodeType.Page; } @@ -379,11 +419,10 @@ namespace RyzStudio.Windows.Forms } } - public void UpdateNode(TreeNode node, BookmarkModel model) + public void UpdateNode(TreeNode node, App6Options.Item model) { if (node == null) { - node = this.SelectedNode; return; } @@ -397,32 +436,38 @@ namespace RyzStudio.Windows.Forms return; } - // Update custom favicon - var n = AddImage(model.Id.ToString(), model.Icon); + // Replace icon + var hasIcon = AddImage(model.Id.ToString(), model.Icon); UIControl.Invoke(this, (x) => { node.Text = model.Title; - node.ImageIndex = node.SelectedImageIndex = n; + node.ImageIndex = node.SelectedImageIndex = (int)NodeIcon.Default; node.Tag = model; node.ToolTipText = model.ToString(); + + if (hasIcon) + { + node.ImageKey = node.SelectedImageKey = model.Id.ToString(); + } }); this.HasChanged = true; } - public List GetAllDirectories() + public List GetAllNodePaths() { - var result = GetAllNodes(this.Nodes); + var result = this.GetAllNodes(this.Nodes); return result.Where(x => this.GetNodeType(x) == NodeType.Folder) - .Select(x => this.GetNodePath(x)) - ?.ToList() ?? new List(); + .Select(x => this.GetNodePath(x)) + ?.ToList() + ?? new List(); } - public List> GetAllNodes() + public List> GetAllItems() { - var result = this.ToNodeList() ?? new List>(); + var result = this.ToNodeList() ?? new List>(); foreach (var node in result) { node.Value.Path = this.GetNodePath(node.Key); @@ -436,60 +481,49 @@ namespace RyzStudio.Windows.Forms return result; } - private void ClearImageList() + private bool AddImage(string key, Image image) { UIControl.Invoke(this, (x) => { - this.ImageList.Images.Clear(); - 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); + if (this.ImageList.Images.ContainsKey(key)) + { + this.ImageList.Images.RemoveByKey(key); + } }); - } - private int AddImage(string key, Image image) - { if (image == null) { - return (int)NodeIcon.Default; + return false; } try { if (image.Width <= 0) { - return (int)NodeIcon.Default; + return false; } } catch (Exception) { - return (int)NodeIcon.Default; + return false; } 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); + this.ImageList.Images.Add(key, new Bitmap(image)); }); - return this.ImageList.Images.IndexOfKey(key); + return true; } private List GetAllNodes(TreeNodeCollection nodes) { var result = new List(); - foreach (TreeNode node in nodes) + foreach (var node in nodes.OfType()) { result.Add(node); - result.AddRange(GetAllNodes(node.Nodes)); + result.AddRange(this.GetAllNodes(node.Nodes)); } return result; diff --git a/skye.sln b/skye.sln index 9c9d90e..0d0bc09 100644 --- a/skye.sln +++ b/skye.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.4.33205.214 +# Visual Studio Version 18 +VisualStudioVersion = 18.5.11801.241 oobstable MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookmarkManager", "BookmarkManager.csproj", "{4833FB27-0817-4720-A54B-180369B0C374}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BukkuBuddy", "BukkuBuddy.csproj", "{4833FB27-0817-4720-A54B-180369B0C374}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution