diff --git a/BookmarkManager.csproj b/BookmarkManager.csproj
index a9bf7f6..413023a 100644
--- a/BookmarkManager.csproj
+++ b/BookmarkManager.csproj
@@ -29,17 +29,23 @@
+
+
+
+
+
+
diff --git a/Classes/SupportedFile/JSNXSupportedFile.cs b/Classes/SupportedFile/JSNXSupportedFile.cs
index 862b95f..c05607c 100644
--- a/Classes/SupportedFile/JSNXSupportedFile.cs
+++ b/Classes/SupportedFile/JSNXSupportedFile.cs
@@ -1,12 +1,8 @@
-using BookmarkManager.DTO;
-using bzit.bomg.Models;
-using ICSharpCode.SharpZipLib.Zip;
+using bzit.bomg.Models;
using Newtonsoft.Json;
using RyzStudio.IO;
using RyzStudio.Windows.Forms;
-using System;
using System.Collections.Generic;
-using System.IO;
using System.Windows.Forms;
namespace BookmarkManager
diff --git a/DTO/BookmarkItem.cs b/DTO/BookmarkItem.cs
deleted file mode 100644
index 9d8feb3..0000000
--- a/DTO/BookmarkItem.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Text;
-
-namespace BookmarkManager.DTO
-{
- public class BookmarkItem
- {
- public string SiteName { get; set; }
-
- public string SiteAddress { get; set; }
-
- public string SiteDescription { get; set; }
-
- public string FaviconAddress { get; set; }
-
- public string TreeviewPath { get; set; }
-
- //public BookmarkItemModel ToModel()
- //{
- // return new BookmarkItemModel()
- // {
- // SiteName = this.SiteName,
- // SiteAddress = this.SiteAddress,
- // SiteDescription = this.SiteDescription,
- // FaviconAddress = this.FaviconAddress,
- // TreeviewPath = this.TreeviewPath
- // };
- //}
-
- public new string ToString()
- {
- StringBuilder sb = new StringBuilder();
- sb.AppendLine("Name = " + this.SiteName ?? string.Empty);
- sb.AppendLine("Address = " + this.SiteAddress ?? string.Empty);
- sb.AppendLine("Description = " + this.SiteDescription ?? string.Empty);
-
- return sb.ToString();
- }
-
- }
-}
diff --git a/MainForm.cs b/MainForm.cs
index c5aa021..ebc2428 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -1,6 +1,5 @@
using BookmarkManager;
using FizzyLauncher.Models;
-using FizzyLauncher.Text.Json;
using RyzStudio.Windows.Forms;
using System;
using System.Collections.Generic;
@@ -8,8 +7,6 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -17,13 +14,6 @@ namespace FizzyLauncher
{
public partial class MainForm : Form
{
- //[DllImport("user32.dll")]
- //protected static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
-
- //[DllImport("user32.dll")]
- //protected static extern bool UnregisterHotKey(IntPtr hWnd, int id);
-
-
public enum AppMode
{
Clear = 0,
@@ -31,15 +21,6 @@ namespace FizzyLauncher
New
}
- //public enum LoadFileType
- //{
- // None = 0,
- // Jsnx,
- // Ryz
- //}
-
- //protected BackgroundWorker loadFileThread = null;
- //protected bool isBusy = false;
protected OptionsForm optionsForm = null;
@@ -49,28 +30,10 @@ namespace FizzyLauncher
protected bool isBusy = false;
- //protected LoadFileType loadFileType = LoadFileType.None;
- //protected bool usePassword = false;
-
-
- //protected const int MOD_ALT = 0x1;
- //protected const int MOD_CONTROL = 0x2;
- //protected const int MOD_SHIFT = 0x4;
- //protected const int MOD_WIN = 0x8;
- //protected const int WM_HOTKEY = 0x312;
- //protected const int WM_QUERYENDSESSION = 0x0011;
-
- //protected string sessionFilename = null;
-
- //protected bool requestExit = false;
-
-
public MainForm()
{
InitializeComponent();
- //tileContainer1.OnColumnSizeChanged += tileContainer1_OnSizeChanged;
-
this.AutoScaleMode = AutoScaleMode.None;
this.StartPosition = FormStartPosition.WindowsDefaultLocation;
this.ClientSize = new System.Drawing.Size(300, 580);
@@ -87,9 +50,9 @@ namespace FizzyLauncher
ThreadControl.SetSize(this, 300, 580);
}
- protected async override void OnShown(EventArgs e)
- {
- base.OnShown(e);
+ //protected async override void OnShown(EventArgs e)
+ //{
+ // base.OnShown(e);
//ThreadControl.SetVisible(this, false);
@@ -104,65 +67,40 @@ namespace FizzyLauncher
// ThreadControl.SetVisible(this, true);
//}
- }
+ //}
- protected override void OnClosing(CancelEventArgs e)
+ protected async override void OnClosing(CancelEventArgs e)
{
- base.OnClosing(e);
+ e.Cancel = true;
-// if (this.CurrentSession == null) this.CurrentSession = new LauncherSession();
+ if (this.IsBusy)
+ {
+ return;
+ }
-// if (this.CurrentSession.HideOnClose && !requestExit)
-// {
-// this.Visible = !this.Visible;
-// e.Cancel = true;
-// return;
-// }
+ this.IsBusy = true;
-// requestExit = false;
+ Result result = await CloseFile();
+ if (!result.IsSuccess)
+ {
+ MessageBox.Show(result.Message, "Close", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ this.IsBusy = false;
-// if (string.IsNullOrWhiteSpace(sessionFilename))
-// {
-// // do nothing
-// }
-// else
-// {
-// if (this.CurrentSession.AutoSave == LauncherSession.AutoSaveOption.Prompt)
-// {
-// DialogResult dr = MessageBox.Show("Save existing session?", "Exit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
-// if (dr == DialogResult.Yes)
-// {
-// bool rv = saveFile(sessionFilename, false);
-// if (!rv)
-// {
-// e.Cancel = true;
-// }
-// }
-// else if (dr == DialogResult.No)
-// {
-// // do nothing
-// }
-// else if (dr == DialogResult.Cancel)
-// {
-// e.Cancel = true;
-// }
-// }
-// else if (this.CurrentSession.AutoSave == LauncherSession.AutoSaveOption.Yes)
-// {
-// saveFile(sessionFilename, false);
-// }
-// }
+ e.Cancel = true;
-// if (this.CurrentSession.HotKey != null)
-// {
-// if (this.CurrentSession.HotKey.KeyCode != Keys.None)
-// {
-//#if !DEBUG
-// UnregisterHotKey((IntPtr)Handle, 1);
-//#endif
-// }
-// }
+ return;
+ }
+ sessionFilename = null;
+ sessionPassword = null;
+
+ treeView1.Clear();
+
+ ApplicationMode = AppMode.Clear;
+
+ this.IsBusy = false;
+
+ Application.Exit();
}
public LauncherSession CurrentSession { get; set; } = null;
@@ -193,18 +131,11 @@ namespace FizzyLauncher
ThreadControl.SetEnable(saveToolStripMenuItem, false);
ThreadControl.SetEnable(saveAsToolStripMenuItem, false);
+ ThreadControl.SetEnable(findToolStripMenuItem, false);
+
ThreadControl.SetEnable(expandAllToolStripMenuItem, false);
ThreadControl.SetEnable(collapseAllToolStripMenuItem, false);
- //ThreadControl.SetEnable(toolStrip1, closeFileMenuItem, false);
- //this.AllowSave = false;
- //ThreadControl.SetEnable(toolStrip1, saveAsFileMenuItem, false);
- //ThreadControl.SetEnable(toolStrip1, findEditMenuItem, false);
-
- //ThreadControl.SetEnable(toolStrip1, expandAllViewMenuItem, false);
- //ThreadControl.SetEnable(toolStrip1, collapseAllViewMenuItem, false);
- //ThreadControl.SetEnable(toolStrip1, optionsToolMenuItem, false);
-
break;
case AppMode.Open:
ThreadControl.SetEnable(closeToolStripMenuItem, true);
@@ -212,17 +143,11 @@ namespace FizzyLauncher
ThreadControl.SetEnable(saveToolStripMenuItem, true);
ThreadControl.SetEnable(saveAsToolStripMenuItem, true);
+ ThreadControl.SetEnable(findToolStripMenuItem, true);
+
ThreadControl.SetEnable(expandAllToolStripMenuItem, true);
ThreadControl.SetEnable(collapseAllToolStripMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, closeFileMenuItem, true);
- //this.AllowSave = true;
- //ThreadControl.SetEnable(toolStrip1, saveAsFileMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, findEditMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, expandAllViewMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, collapseAllViewMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, optionsToolMenuItem, true);
-
break;
case AppMode.New:
ThreadControl.SetText(this, AppResource.app_name);
@@ -232,261 +157,18 @@ namespace FizzyLauncher
ThreadControl.SetEnable(saveToolStripMenuItem, false);
ThreadControl.SetEnable(saveAsToolStripMenuItem, true);
+ ThreadControl.SetEnable(findToolStripMenuItem, true);
+
ThreadControl.SetEnable(expandAllToolStripMenuItem, true);
ThreadControl.SetEnable(collapseAllToolStripMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, closeFileMenuItem, true);
- //this.AllowSave = true;
- //ThreadControl.SetEnable(toolStrip1, saveAsFileMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, findEditMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, expandAllViewMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, collapseAllViewMenuItem, true);
- //ThreadControl.SetEnable(toolStrip1, optionsToolMenuItem, true);
-
break;
+ default: break;
}
}
}
- //public void Clear(int columnCount)
- //{
- // //tileContainer1.Clear();
- // //tileContainer1.Add(columnCount);
-
- // sessionFilename = null;
- //}
-
-
- //protected async Task collapseWindow(int width, int increment = 6)
- //{
- // await Task.Run(() =>
- // {
- // while (this.Width > width)
- // {
- // ThreadControl.SetWidth(this, (this.Width - increment));
-
- // Application.DoEvents();
- // }
-
- // ThreadControl.SetWidth(this, width);
- // });
- //}
-
- //protected async Task expandWindow(int width, int increment = 8)
- //{
- // await Task.Run(() =>
- // {
- // while (this.Width < width)
- // {
- // ThreadControl.SetWidth(this, (this.Width + increment));
-
- // Application.DoEvents();
- // }
-
- // ThreadControl.SetWidth(this, width);
- // });
- //}
-
-// protected void invalidateHotKey()
-// {
-//#if !DEBUG
-// if (this.InvokeRequired)
-// {
-// this.Invoke(new MethodInvoker(() =>
-// {
-// UnregisterHotKey((IntPtr)Handle, 1);
-// }));
-// }
-// else
-// {
-// UnregisterHotKey((IntPtr)Handle, 1);
-// }
-//#endif
-
-// if (this.CurrentSession.HotKey != null)
-// {
-// if (this.CurrentSession.HotKey.KeyCode != Keys.None)
-// {
-//#if !DEBUG
-// if (this.InvokeRequired)
-// {
-// this.Invoke(new MethodInvoker(() =>
-// {
-// RegisterHotKey((IntPtr)Handle, 1, this.CurrentSession.HotKey.ModifierCode, this.CurrentSession.HotKey.Key);
-// }));
-// }
-// else
-// {
-// RegisterHotKey((IntPtr)Handle, 1, this.CurrentSession.HotKey.ModifierCode, this.CurrentSession.HotKey.Key);
-// }
-//#endif
-// }
-// }
-// }
-
-
- //protected void newSession()
- //{
- //NewForm form = new NewForm(this);
- //form.ShowDialog();
- //}
-
- //protected async Task loadFile(string filename)
- //{
- // await Task.Run(() =>
- // {
- // if (isBusy)
- // {
- // return;
- // }
-
- // if (string.IsNullOrWhiteSpace(filename))
- // {
- // return;
- // }
-
- // if (!File.Exists(filename))
- // {
- // return;
- // }
-
- // string sourceCode = null;
-
- // try
- // {
- // sessionFilename = filename;
-
- // sourceCode = File.ReadAllText(sessionFilename);
- // }
- // catch (Exception exc)
- // {
- // MessageBox.Show(exc.Message, "Load session");
- // return;
- // }
-
- // if (string.IsNullOrWhiteSpace(sourceCode))
- // {
- // return;
- // }
-
- // // load options
- // var options = new JsonSerializerOptions();
- // options.Converters.Add(new JsonPointConverter());
- // options.Converters.Add(new JsonSizeConverter());
-
- // try
- // {
- // this.CurrentSession = JsonSerializer.Deserialize(sourceCode, options);
- // }
- // catch (Exception exc)
- // {
- // MessageBox.Show("Unable to read session", "Load session");
- // return;
- // }
-
- // if (this.CurrentSession == null)
- // {
- // this.CurrentSession = new LauncherSession();
- // }
-
- // // load tiles
- // //tileContainer1.Load(this.CurrentSession.Groups);
-
- // // reposition
- // if (!this.CurrentSession.StartPosition.IsEmpty) ThreadControl.SetLocation(this, this.CurrentSession.StartPosition);
-
- // //
- // ThreadControl.SetTopMost(this, this.CurrentSession.AlwaysOnTop);
- // ThreadControl.SetVisible(this, true);
- // ThreadControl.SetChecked(collapseAllToolStripMenuItem, this.CurrentSession.EnableAnimation);
- // ThreadControl.SetChecked(expandAllToolStripMenuItem, this.CurrentSession.EnableBigIconInFolder);
- // //ThreadControl.SetClientHeight(this, this.CurrentSession.DefaultHeight);
-
- // ThreadControl.SetFocus(this);
-
- // // hotkey
- // invalidateHotKey();
-
- // });
- //}
-
- //protected bool saveFile(string filename, bool showNotices = true)
- //{
- //if (isBusy)
- //{
- // return false;
- //}
-
- //if (string.IsNullOrWhiteSpace(filename))
- //{
- // return false;
- //}
-
- //if (tileContainer1.GroupCount <= 0)
- //{
- // return true;
- //}
-
- //isBusy = true;
-
- //// update session
- //if (this.CurrentSession == null)
- //{
- // this.CurrentSession = new LauncherSession();
- //}
-
- //this.CurrentSession.DefaultHeight = this.Height;
- //this.CurrentSession.AlwaysOnTop = this.TopMost;
- //this.CurrentSession.StartPosition = this.Location;
- //this.CurrentSession.Groups = tileContainer1.GroupModels?.ToList() ?? new List();
-
- //var options = new JsonSerializerOptions();
- //options.Converters.Add(new JsonPointConverter());
- //options.Converters.Add(new JsonSizeConverter());
-
- //try
- //{
- // File.WriteAllText(filename, JsonSerializer.Serialize(this.CurrentSession, options));
-
- // if (showNotices)
- // {
- // MessageBox.Show("Session saved!", "Save session", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // }
- //}
- //catch (Exception exc)
- //{
- // MessageBox.Show(exc.Message, "Save session");
-
- // return false;
- //}
-
- //isBusy = false;
-
- //return true;
- //}
-
- //protected bool saveAsFile()
- //{
- //if (isBusy)
- //{
- // return false;
- //}
-
- //if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- //{
- // bool rv = saveFile(saveFileDialog1.FileName);
- // if (rv)
- // {
- // sessionFilename = saveFileDialog1.FileName;
- // }
-
- // return rv;
- //}
-
- // return false;
- //}
-
#region main menu
///
@@ -494,7 +176,7 @@ namespace FizzyLauncher
///
///
///
- private void newToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void newToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.IsBusy)
{
@@ -503,7 +185,13 @@ namespace FizzyLauncher
this.IsBusy = true;
- CloseFile();
+ Result result = await CloseFile();
+ if (!result.IsSuccess)
+ {
+ MessageBox.Show(result.Message, "New Session", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ this.IsBusy = false;
+ return;
+ }
sessionFilename = null;
sessionPassword = null;
@@ -529,12 +217,22 @@ namespace FizzyLauncher
this.IsBusy = true;
- CloseFile();
+ Result result = await CloseFile();
+ if (!result.IsSuccess)
+ {
+ MessageBox.Show(result.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ this.IsBusy = false;
+ return;
+ }
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
- Result result = await LoadFile(openFileDialog1.FileName);
- if (!result.IsSuccess)
+ result = await LoadFile(openFileDialog1.FileName);
+ if (result.IsSuccess)
+ {
+ ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + " - " + AppResource.app_name);
+ }
+ else
{
MessageBox.Show(result.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
@@ -548,7 +246,7 @@ namespace FizzyLauncher
///
///
///
- private void closeToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.IsBusy)
{
@@ -557,7 +255,13 @@ namespace FizzyLauncher
this.IsBusy = true;
- CloseFile();
+ Result result = await CloseFile();
+ if (!result.IsSuccess)
+ {
+ MessageBox.Show(result.Message, "Close File", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ this.IsBusy = false;
+ return;
+ }
sessionFilename = null;
sessionPassword = null;
@@ -762,55 +466,58 @@ namespace FizzyLauncher
MessageBox.Show(Application.ProductName + " v" + Application.ProductVersion, "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
- #endregion
+#endregion
- protected async void CloseFile()
+ protected async Task CloseFile()
{
- if (this.ApplicationMode == AppMode.Clear)
+ return await Task.Run(async () =>
{
- return;
- }
-
- if (!treeView1.HasChanged)
- {
- return;
- }
-
- if (this.ApplicationMode == AppMode.New)
- {
- DialogResult response = MessageBox.Show("Save bookmarks", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (response == DialogResult.Yes)
+ if (this.ApplicationMode == AppMode.Clear)
{
- Result result = await SaveAsFile(sessionFilename);
- if (!result.IsSuccess)
+ return Result.Create(true);
+ }
+
+ if (!treeView1.HasChanged)
+ {
+ return Result.Create(true);
+ }
+
+ if (this.ApplicationMode == AppMode.New)
+ {
+ DialogResult response = MessageBox.Show("Save bookmarks", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
+ if (response == DialogResult.Yes)
{
- MessageBox.Show(result.Message, "Save File", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
+ Result result = await SaveAsFile(sessionFilename);
+ if (!result.IsSuccess)
+ {
+ return Result.Create(false, result.Message);
+ }
+ }
+ else if (response == DialogResult.Cancel)
+ {
+ return Result.Create(false, "User cancelled");
}
}
- else if (response == DialogResult.Cancel)
+ else if (this.ApplicationMode == AppMode.Open)
{
- return;
- }
- }
- else if (this.ApplicationMode == AppMode.Open)
- {
- DialogResult response = MessageBox.Show("Save changes to open bookmarks", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (response == DialogResult.Yes)
- {
- Result result = await SaveFile(sessionFilename, sessionPassword);
- if (!result.IsSuccess)
+ DialogResult response = MessageBox.Show("Save changes to open bookmarks", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
+ if (response == DialogResult.Yes)
{
- MessageBox.Show(result.Message, "Save File", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
+ Result result = await SaveFile(sessionFilename, sessionPassword);
+ if (!result.IsSuccess)
+ {
+ return Result.Create(false, result.Message);
+ }
+ }
+ else if (response == DialogResult.Cancel)
+ {
+ return Result.Create(false, "User cancelled");
}
}
- else if (response == DialogResult.Cancel)
- {
- return;
- }
- }
+
+ return Result.Create(true);
+ });
}
protected SupportedFileBase GetSupportedFileHandler(string filename)
diff --git a/Models/TileGroupModel.cs b/Models/TileGroupModel.cs
deleted file mode 100644
index 6f69481..0000000
--- a/Models/TileGroupModel.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using FizzyLauncher.Text.Json;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Text.Json.Serialization;
-
-namespace FizzyLauncher.Models
-{
- public class TileGroupModel
- {
- public string Title { get; set; }
-
- public bool IsExpanded { get; set; } = false;
-
- public bool IsExclusive { get; set; } = false;
-
- public List Items { get; set; } = new List();
-
- [JsonConverter(typeof(JsonSizeConverter))]
- public Size GridSize { get; set; } = new Size(0, 0);
- }
-}
\ No newline at end of file
diff --git a/Models/TileModel.cs b/Models/TileModel.cs
deleted file mode 100644
index 9e47756..0000000
--- a/Models/TileModel.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using FizzyLauncher.Text.Json;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.Text.Json.Serialization;
-
-namespace FizzyLauncher.Models
-{
- public class TileModel
- {
- public string Title { get; set; }
-
- public string ProcessFilename { get; set; }
-
- public string ProcessArgument { get; set; }
-
- public string ProcessWorkingDirectory { get; set; }
-
- public ProcessWindowStyle ProcessWindowStyle { get; set; } = ProcessWindowStyle.Normal;
-
- public bool ProcessAsAdmin { get; set; } = false;
-
- [JsonConverter(typeof(JsonPointConverter))]
- public Point Position { get; set; }
-
- public bool IsGroup { get; set; } = false;
-
- public List Items { get; set; } = new List();
-
- public override string ToString() => this.Title ?? string.Empty;
-
- public string CleanProcessFilename => (string.IsNullOrWhiteSpace(this.ProcessFilename) ? string.Empty : resolvePath(this.ProcessFilename));
-
- public string CleanProcessArgument => (string.IsNullOrWhiteSpace(this.ProcessArgument) ? string.Empty : resolvePath(this.ProcessArgument));
-
- public string CleanProcessWorkingDirectory => (string.IsNullOrWhiteSpace(this.ProcessWorkingDirectory) ? string.Empty : resolvePath(this.ProcessWorkingDirectory));
-
- protected string resolvePath(string value)
- {
- string rv = Environment.ExpandEnvironmentVariables(value);
-
- rv = resolveFirstPath(rv);
- rv = resolveLastPath(rv);
-
- return rv;
- }
-
- protected string resolveFirstPath(string value)
- {
- const string last = "%FIRST%";
- if (!value.Contains(last))
- {
- return value;
- }
-
- string head = value.Substring(0, value.IndexOf(last));
- string tail = value.Substring(value.IndexOf(last) + last.Length);
-
- string[] dirList = new string[0];
-
- try
- {
- dirList = System.IO.Directory.GetDirectories(head, "*", System.IO.SearchOption.TopDirectoryOnly);
- }
- catch
- {
- // do nothing
- }
-
- if (dirList.Length <= 0)
- {
- return value;
- }
-
- return dirList[0] + tail;
- }
-
- protected string resolveLastPath(string value)
- {
- const string last = "%LAST%";
- if (!value.Contains(last))
- {
- return value;
- }
-
- string head = value.Substring(0, value.IndexOf(last));
- string tail = value.Substring(value.IndexOf(last) + last.Length);
-
- string[] dirList = new string[0];
-
- try
- {
- dirList = System.IO.Directory.GetDirectories(head, "*", System.IO.SearchOption.TopDirectoryOnly);
- }
- catch
- {
- // do nothing
- }
-
- if (dirList.Length <= 0)
- {
- return value;
- }
-
- return dirList[(dirList.Length - 1)] + tail;
- }
-
- }
-}
diff --git a/NewForm.cs b/NewForm.cs
deleted file mode 100644
index 24d6442..0000000
--- a/NewForm.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using RyzStudio.Windows.ThemedForms;
-using System;
-
-namespace FizzyLauncher
-{
- public class NewForm : TDialogForm
- {
- private System.Windows.Forms.Label label1;
- private TButton button1;
- private TNumericBox numericBox1;
- private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator1;
-
-
- public NewForm(MainForm parent) : base()
- {
- InitializeComponent();
-
- parentForm = parent;
-
- numericBox1.InnerControl.Minimum = 4;
- numericBox1.InnerControl.Maximum = 24;
- numericBox1.InnerControl.Value = 6;
- }
-
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.button1 = new RyzStudio.Windows.ThemedForms.TButton();
- this.tHorizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator();
- this.numericBox1 = new RyzStudio.Windows.ThemedForms.TNumericBox();
- 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(137, 34);
- this.label1.TabIndex = 153;
- this.label1.Text = "Number of Tiles Per Row";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // button1
- //
- this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.button1.BackColor = System.Drawing.Color.Transparent;
- this.button1.DefaultImage = null;
- this.button1.DownImage = null;
- this.button1.IsSelected = false;
- this.button1.LabelText = "&Save";
- this.button1.Location = new System.Drawing.Point(241, 109);
- this.button1.Margin = new System.Windows.Forms.Padding(10);
- this.button1.Name = "button1";
- this.button1.OverImage = null;
- this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
- this.button1.Size = new System.Drawing.Size(128, 32);
- this.button1.TabIndex = 173;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // 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, 77);
- this.tHorizontalSeparator1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
- 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(364, 22);
- this.tHorizontalSeparator1.TabIndex = 188;
- //
- // numericBox1
- //
- this.numericBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.numericBox1.BackColor = System.Drawing.Color.Transparent;
- this.numericBox1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.numericBox1.Location = new System.Drawing.Point(285, 20);
- this.numericBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
- this.numericBox1.Name = "numericBox1";
- this.numericBox1.Padding = new System.Windows.Forms.Padding(8, 8, 7, 7);
- this.numericBox1.Size = new System.Drawing.Size(84, 34);
- this.numericBox1.SubmitButton = null;
- this.numericBox1.TabIndex = 189;
- this.numericBox1.Value = 0;
- //
- // NewForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(384, 161);
- this.Controls.Add(this.numericBox1);
- this.Controls.Add(this.tHorizontalSeparator1);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.label1);
- this.MinimumSize = new System.Drawing.Size(400, 200);
- this.Name = "NewForm";
- this.Text = "New";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
-
- public MainForm parentForm { get; set; } = null;
-
-
- private void button1_Click(object sender, EventArgs e)
- {
- if (parentForm != null)
- {
- parentForm.Clear(numericBox1.Value);
- }
-
- this.Close();
- }
-
- }
-}
\ No newline at end of file
diff --git a/NewForm.resx b/NewForm.resx
deleted file mode 100644
index f298a7b..0000000
--- a/NewForm.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/OpenFileForm.cs b/OpenFileForm.cs
deleted file mode 100644
index 1b20e57..0000000
--- a/OpenFileForm.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using RyzStudio.Windows.ThemedForms;
-using System;
-using System.ComponentModel;
-
-namespace FizzyLauncher
-{
- public class OpenFileForm : TDialogForm
- {
- private System.Windows.Forms.Label label1;
- private TButton button1;
- private System.Windows.Forms.Label label8;
- private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator1;
- private TOpenFileTextBox textBox1;
- private TTextBox textBox2;
- private System.Windows.Forms.OpenFileDialog openFileDialog1;
-
-
- public OpenFileForm(MainForm parent) : base()
- {
- InitializeComponent();
-
- this.ParentForm = parent;
-
- textBox2.InnerTextBox.MaxLength = 128;
- }
-
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenFileForm));
- this.label1 = new System.Windows.Forms.Label();
- this.button1 = new RyzStudio.Windows.ThemedForms.TButton();
- this.label8 = new System.Windows.Forms.Label();
- this.tHorizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator();
- this.textBox1 = new RyzStudio.Windows.ThemedForms.TOpenFileTextBox();
- this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
- this.textBox2 = new RyzStudio.Windows.ThemedForms.TTextBox();
- 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(55, 34);
- this.label1.TabIndex = 153;
- this.label1.Text = "Filename";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // button1
- //
- this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.button1.BackColor = System.Drawing.Color.Transparent;
- this.button1.DefaultImage = null;
- this.button1.DownImage = null;
- this.button1.IsSelected = false;
- this.button1.LabelText = "&OK";
- this.button1.Location = new System.Drawing.Point(321, 149);
- this.button1.Margin = new System.Windows.Forms.Padding(10);
- this.button1.Name = "button1";
- this.button1.OverImage = null;
- this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
- this.button1.Size = new System.Drawing.Size(128, 32);
- this.button1.TabIndex = 173;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.BackColor = System.Drawing.Color.Transparent;
- this.label8.ForeColor = System.Drawing.SystemColors.ControlText;
- this.label8.Location = new System.Drawing.Point(10, 62);
- this.label8.Margin = new System.Windows.Forms.Padding(0);
- this.label8.Name = "label8";
- this.label8.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
- this.label8.Size = new System.Drawing.Size(134, 34);
- this.label8.TabIndex = 186;
- this.label8.Text = "Password (If Applicable)";
- this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // 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, 117);
- this.tHorizontalSeparator1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
- 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;
- //
- // textBox1
- //
- 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.FileDialog = this.openFileDialog1;
- this.textBox1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.textBox1.HighlightImage = ((System.Drawing.Image)(resources.GetObject("textBox1.HighlightImage")));
- this.textBox1.Location = new System.Drawing.Point(192, 20);
- this.textBox1.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
- this.textBox1.Name = "textBox1";
- this.textBox1.NormalImage = ((System.Drawing.Image)(resources.GetObject("textBox1.NormalImage")));
- this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
- this.textBox1.Size = new System.Drawing.Size(257, 35);
- this.textBox1.SubmitButton = null;
- this.textBox1.TabIndex = 190;
- this.textBox1.UseSystemPasswordChar = false;
- //
- // openFileDialog1
- //
- this.openFileDialog1.DefaultExt = "jsnx";
- this.openFileDialog1.Filter = "Bookmarks files (*.jsnx)|*.jsnx|Bookmarks files (*.ryz)|*.ryz";
- this.openFileDialog1.Title = "Open bookmarks file";
- //
- // textBox2
- //
- this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.textBox2.BackColor = System.Drawing.Color.Transparent;
- this.textBox2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.textBox2.Location = new System.Drawing.Point(231, 62);
- this.textBox2.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
- this.textBox2.Name = "textBox2";
- this.textBox2.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
- this.textBox2.Size = new System.Drawing.Size(218, 35);
- this.textBox2.SubmitButton = null;
- this.textBox2.TabIndex = 191;
- this.textBox2.UseSystemPasswordChar = true;
- //
- // OpenFileForm
- //
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
- this.ClientSize = new System.Drawing.Size(464, 201);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.tHorizontalSeparator1);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.label1);
- this.MinimumSize = new System.Drawing.Size(400, 240);
- this.Name = "OpenFileForm";
- this.Text = "Open File";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
-
- this.DialogResult = System.Windows.Forms.DialogResult.None;
- }
-
-
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public MainForm ParentForm { get; protected set; } = null;
-
- [Browsable(false)]
- public string FileName => textBox1.Text;
-
- [Browsable(false)]
- public string Password => textBox2.Text;
-
-
- private void button1_Click(object sender, EventArgs e)
- {
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.Close();
- }
-
- }
-}
\ No newline at end of file
diff --git a/OpenFileForm.resx b/OpenFileForm.resx
deleted file mode 100644
index dce4b6e..0000000
--- a/OpenFileForm.resx
+++ /dev/null
@@ -1,82 +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
-
-
- 17, 17
-
-
-
-
- iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
- vQAADr0BR/uQrQAAAK9JREFUOE/t0zsKwkAURuGp1BWJK3EhIrgAV+EOLLWwtRQLwQdiIbbiIkwynj+O
- IVwnyhR2XvjyInNIkXHee8f0cEQBPbDOaKEarSvXhsAJO4wirlB4jipiA3phoIvIrLFChhnKiA3o8Ckw
- RR93LNBODVwwwRL62kNKYIxNzQ1FSsDOEHk08HrYJMw/8KtA06/cCef6KJDZgDbTFrHNZO3x9idqOyui
- m2+07bvPgHcPXOhtG3D6cUIAAAAASUVORK5CYII=
-
-
-
-
- iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
- vQAADr0BR/uQrQAAAMZJREFUOE/tk7sNwjAQQF3BRohJGAQhMQBTsAElFLSUiAKJTxIXhBZlCILNuyRG
- iXEQKeg46fmsO/slhU9Za5XWehiXYcD6JElygZ6qhdwTioVDGo4wDXDjsohXdYkvMDTHVa8R9Hb0tpCz
- XzqJL5Df/CRYRFE0Yn8nr9M07XcSwBXmXN6QDfncRTCjt6+Rgfla4Adfn3D+ERS4Yht/wY8FxVN2xTac
- gLP5qyYLAhmmA4SGyeeEoPkSq3EWydsoB4gRDEqBVU/p15ajstHKCgAAAABJRU5ErkJggg==
-
-
-
\ No newline at end of file
diff --git a/RyzStudio/Windows/Forms/ThreadControl.cs b/RyzStudio/Windows/Forms/ThreadControl.cs
index 28f909e..d1318db 100644
--- a/RyzStudio/Windows/Forms/ThreadControl.cs
+++ b/RyzStudio/Windows/Forms/ThreadControl.cs
@@ -181,6 +181,56 @@ namespace RyzStudio.Windows.Forms
return rv;
}
+ public static TreeNode Add(TreeNode control, string key, string text, int imageIndex, int selectedImageIndex)
+ {
+ TreeNode rv = null;
+
+ if (control.TreeView.InvokeRequired)
+ {
+ control.TreeView.Invoke(new MethodInvoker(() => {
+ rv = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
+ }));
+ }
+ else
+ {
+ rv = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
+ }
+
+ return rv;
+ }
+
+ public static TreeNode Add(TreeView control, string key, string text, int imageIndex, int selectedImageIndex)
+ {
+ TreeNode rv = null;
+
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ rv = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
+ }));
+ }
+ else
+ {
+ rv = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
+ }
+
+ return rv;
+ }
+
+ public static void Add(Control parentControl, ImageList control, string key, Image value)
+ {
+ if (parentControl.InvokeRequired)
+ {
+ parentControl.Invoke(new MethodInvoker(() => {
+ control.Images.Add(key, value);
+ }));
+ }
+ else
+ {
+ control.Images.Add(key, value);
+ }
+ }
+
public static void AddLine(RichTextBox control, string text)
{
if (control.InvokeRequired)
@@ -355,6 +405,12 @@ namespace RyzStudio.Windows.Forms
public static void SetEnable(ToolStripMenuItem control, bool value)
{
+ if (control.GetCurrentParent() == null)
+ {
+ control.Enabled = value;
+ return;
+ }
+
if (control.GetCurrentParent().InvokeRequired)
{
control.GetCurrentParent().Invoke(new MethodInvoker(() =>
diff --git a/Text/Json/JsonPointConverter.cs b/Text/Json/JsonPointConverter.cs
deleted file mode 100644
index e787cdc..0000000
--- a/Text/Json/JsonPointConverter.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Drawing;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace FizzyLauncher.Text.Json
-{
- public class JsonPointConverter : JsonConverter
- {
- public override Point Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- Point rs = new Point(0, 0);
-
- if (reader.TokenType == JsonTokenType.String)
- {
- string[] parts = reader.GetString().Split(',');
- if (parts.Length != 2)
- {
- return rs;
- }
-
- int x = 0;
- int y = 0;
-
- if (!int.TryParse(parts[0].Trim(), out x)) x = 0;
- if (!int.TryParse(parts[1].Trim(), out y)) y = 0;
-
- return new Point(x, y);
- }
-
- return rs;
- }
-
- public override void Write(Utf8JsonWriter writer, Point value, JsonSerializerOptions options)
- {
- writer.WriteStringValue(string.Format("{0}, {1}", value.X.ToString(), value.Y.ToString()));
- }
-
- }
-}
diff --git a/Text/Json/JsonSizeConverter.cs b/Text/Json/JsonSizeConverter.cs
deleted file mode 100644
index eb763fa..0000000
--- a/Text/Json/JsonSizeConverter.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Drawing;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace FizzyLauncher.Text.Json
-{
- public class JsonSizeConverter : JsonConverter
- {
- public override Size Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- Size rs = new Size(0, 0);
-
- if (reader.TokenType == JsonTokenType.String)
- {
- string[] parts = reader.GetString().Split(',');
- if (parts.Length != 2)
- {
- return rs;
- }
-
- int w = 0;
- int h = 0;
-
- if (!int.TryParse(parts[0].Trim(), out w)) w = 0;
- if (!int.TryParse(parts[1].Trim(), out h)) h = 0;
-
- return new Size(w, h);
- }
-
- return rs;
- }
-
- public override void Write(Utf8JsonWriter writer, Size value, JsonSerializerOptions options)
- {
- writer.WriteStringValue(string.Format("{0}, {1}", value.Width.ToString(), value.Height.ToString()));
- }
-
- }
-}
diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs
index 2b01cb7..84d3039 100644
--- a/Windows/Forms/BookmarkTreeView.cs
+++ b/Windows/Forms/BookmarkTreeView.cs
@@ -12,10 +12,7 @@ namespace RyzStudio.Windows.Forms
{
public partial class BookmarkTreeView : TreeView
{
- public static string DecodePath(string value)
- {
- return System.Web.HttpUtility.UrlDecode(value);
- }
+ public static string DecodePath(string value) => System.Web.HttpUtility.UrlDecode(value);
public static void DeleteNode(TreeNode node)
{
@@ -381,7 +378,7 @@ namespace RyzStudio.Windows.Forms
tn.Tag = viewModel;
tn.ToolTipText = viewModel.ToString();
- TreeNode tn2 = addFolderPath(viewModel.TreeviewPath);
+ TreeNode tn2 = AddFolderPath(viewModel.TreeviewPath);
ThreadControl.Add(tn2, tn);
@@ -453,7 +450,7 @@ namespace RyzStudio.Windows.Forms
foreach (TreeNode item in this.Nodes)
{
- traverseBookmarkList(ref itemCount, item);
+ TraverseBookmarkList(ref itemCount, item);
}
return itemCount;
@@ -489,8 +486,7 @@ namespace RyzStudio.Windows.Forms
this.AllowBeginEdit = true;
node.BeginEdit();
break;
- default:
- break;
+ default: break;
}
}
@@ -512,7 +508,7 @@ namespace RyzStudio.Windows.Forms
foreach (TreeNode item in this.Nodes)
{
- traverseBookmarkList(rs, item);
+ TraverseBookmarkList(rs, item);
}
return rs;
@@ -616,8 +612,6 @@ namespace RyzStudio.Windows.Forms
public void Sort() => Sort(this.SelectedNode);
-
-
public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel)
{
if (treeNode == null)
@@ -662,7 +656,7 @@ namespace RyzStudio.Windows.Forms
return;
}
- if (isNodeChild(draggingNode, en))
+ if (IsNodeChild(draggingNode, en))
{
return;
}
@@ -879,14 +873,14 @@ namespace RyzStudio.Windows.Forms
return (int)IconSet.Default;
}
- this.Add(this.ImageList, model.SiteAddress, bmp);
+ ThreadControl.Add(this, this.ImageList, model.SiteAddress, bmp);
//iconDatabase.AddIcon(model.SiteAddress, rawData);
return this.ImageList.Images.IndexOfKey(model.SiteAddress);
}
- protected TreeNode addFolderPath(string path)
+ protected TreeNode AddFolderPath(string path)
{
TreeNode tn = null;
//TreeNode tn = this.Nodes[0];
@@ -919,7 +913,7 @@ namespace RyzStudio.Windows.Forms
{
if (!this.Nodes.ContainsKey(item))
{
- this.Add(item, DecodePath(item), (int)IconSet.Root, (int)IconSet.Root);
+ ThreadControl.Add(this, item, DecodePath(item), (int)IconSet.Root, (int)IconSet.Root);
}
tn = this.Nodes[item];
@@ -928,7 +922,7 @@ namespace RyzStudio.Windows.Forms
{
if (!tn.Nodes.ContainsKey(item))
{
- this.Add(tn, item, DecodePath(item), (int)IconSet.Folder1, (int)IconSet.Folder2);
+ ThreadControl.Add(tn, item, DecodePath(item), (int)IconSet.Folder1, (int)IconSet.Folder2);
}
tn = tn.Nodes[item];
@@ -938,14 +932,35 @@ namespace RyzStudio.Windows.Forms
return tn;
}
- protected void traverseBookmarkList(List rs, TreeNode node)
+ protected bool IsNodeChild(TreeNode dragNode, TreeNode dropNode)
+ {
+ TreeNode tn = dropNode;
+ while (true)
+ {
+ if (tn.Parent == null)
+ {
+ break;
+ }
+
+ if (tn.Equals(dragNode))
+ {
+ return true;
+ }
+
+ tn = tn.Parent;
+ }
+
+ return false;
+ }
+
+ protected void TraverseBookmarkList(List rs, TreeNode node)
{
foreach (TreeNode tn in node.Nodes)
{
NodeType nodeType = GetNodeType(tn);
if (nodeType == NodeType.Folder)
{
- traverseBookmarkList(rs, tn);
+ TraverseBookmarkList(rs, tn);
}
else if (nodeType == NodeType.Page)
{
@@ -960,14 +975,14 @@ namespace RyzStudio.Windows.Forms
}
}
- protected void traverseBookmarkList(List rs, TreeNode node)
+ protected void TraverseBookmarkList(List rs, TreeNode node)
{
foreach (TreeNode tn in node.Nodes)
{
NodeType nodeType = GetNodeType(tn);
if (nodeType == NodeType.Folder)
{
- traverseBookmarkList(rs, tn);
+ TraverseBookmarkList(rs, tn);
}
else if (nodeType == NodeType.Page)
{
@@ -982,14 +997,14 @@ namespace RyzStudio.Windows.Forms
}
}
- protected void traverseBookmarkList(ref int itemCount, TreeNode node)
+ protected void TraverseBookmarkList(ref int itemCount, TreeNode node)
{
foreach (TreeNode tn in node.Nodes)
{
NodeType nodeType = GetNodeType(tn);
if (nodeType == NodeType.Folder)
{
- traverseBookmarkList(ref itemCount, tn);
+ TraverseBookmarkList(ref itemCount, tn);
}
else if (nodeType == NodeType.Page)
{
@@ -998,76 +1013,6 @@ namespace RyzStudio.Windows.Forms
}
}
- protected bool isNodeChild(TreeNode drag_node, TreeNode drop_node)
- {
- TreeNode tn = drop_node;
- while (true)
- {
- if (tn.Parent == null)
- {
- break;
- }
-
- if (tn.Equals(drag_node))
- {
- return true;
- }
-
- tn = tn.Parent;
- }
-
- return false;
- }
-
- protected void Add(ImageList control, string key, Image value)
- {
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(() => {
- control.Images.Add(key, value);
- }));
- }
- else
- {
- control.Images.Add(key, value);
- }
- }
-
- protected TreeNode Add(string key, string text, int imageIndex, int selectedImageIndex)
- {
- TreeNode rs = null;
-
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(() => {
- rs = this.Nodes.Add(key, text, imageIndex, selectedImageIndex);
- }));
- }
- else
- {
- rs = this.Nodes.Add(key, text, imageIndex, selectedImageIndex);
- }
-
- return rs;
- }
-
- protected TreeNode Add(TreeNode control, string key, string text, int imageIndex, int selectedImageIndex)
- {
- TreeNode rs = null;
-
- if (control.TreeView.InvokeRequired)
- {
- control.TreeView.Invoke(new MethodInvoker(() => {
- rs = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
- }));
- }
- else
- {
- rs = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
- }
-
- return rs;
- }
}