WIP: clean-up

This commit is contained in:
Ray 2021-09-07 17:21:28 +01:00
parent 1cdcca7267
commit f58608fc23
14 changed files with 205 additions and 1196 deletions

View File

@ -29,17 +29,23 @@
<ItemGroup> <ItemGroup>
<Compile Remove="#\**" /> <Compile Remove="#\**" />
<Compile Remove="DTO\**" />
<Compile Remove="RyzStudio\Data\**" /> <Compile Remove="RyzStudio\Data\**" />
<Compile Remove="RyzStudio\IO\**" /> <Compile Remove="RyzStudio\IO\**" />
<Compile Remove="RyzStudio\Net\**" /> <Compile Remove="RyzStudio\Net\**" />
<Compile Remove="Text\**" />
<EmbeddedResource Remove="#\**" /> <EmbeddedResource Remove="#\**" />
<EmbeddedResource Remove="DTO\**" />
<EmbeddedResource Remove="RyzStudio\Data\**" /> <EmbeddedResource Remove="RyzStudio\Data\**" />
<EmbeddedResource Remove="RyzStudio\IO\**" /> <EmbeddedResource Remove="RyzStudio\IO\**" />
<EmbeddedResource Remove="RyzStudio\Net\**" /> <EmbeddedResource Remove="RyzStudio\Net\**" />
<EmbeddedResource Remove="Text\**" />
<None Remove="#\**" /> <None Remove="#\**" />
<None Remove="DTO\**" />
<None Remove="RyzStudio\Data\**" /> <None Remove="RyzStudio\Data\**" />
<None Remove="RyzStudio\IO\**" /> <None Remove="RyzStudio\IO\**" />
<None Remove="RyzStudio\Net\**" /> <None Remove="RyzStudio\Net\**" />
<None Remove="Text\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,12 +1,8 @@
using BookmarkManager.DTO; using bzit.bomg.Models;
using bzit.bomg.Models;
using ICSharpCode.SharpZipLib.Zip;
using Newtonsoft.Json; using Newtonsoft.Json;
using RyzStudio.IO; using RyzStudio.IO;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
namespace BookmarkManager namespace BookmarkManager

View File

@ -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();
}
}
}

View File

@ -1,6 +1,5 @@
using BookmarkManager; using BookmarkManager;
using FizzyLauncher.Models; using FizzyLauncher.Models;
using FizzyLauncher.Text.Json;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,8 +7,6 @@ using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -17,13 +14,6 @@ namespace FizzyLauncher
{ {
public partial class MainForm : Form 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 public enum AppMode
{ {
Clear = 0, Clear = 0,
@ -31,15 +21,6 @@ namespace FizzyLauncher
New New
} }
//public enum LoadFileType
//{
// None = 0,
// Jsnx,
// Ryz
//}
//protected BackgroundWorker loadFileThread = null;
//protected bool isBusy = false;
protected OptionsForm optionsForm = null; protected OptionsForm optionsForm = null;
@ -49,28 +30,10 @@ namespace FizzyLauncher
protected bool isBusy = false; 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() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
//tileContainer1.OnColumnSizeChanged += tileContainer1_OnSizeChanged;
this.AutoScaleMode = AutoScaleMode.None; this.AutoScaleMode = AutoScaleMode.None;
this.StartPosition = FormStartPosition.WindowsDefaultLocation; this.StartPosition = FormStartPosition.WindowsDefaultLocation;
this.ClientSize = new System.Drawing.Size(300, 580); this.ClientSize = new System.Drawing.Size(300, 580);
@ -87,9 +50,9 @@ namespace FizzyLauncher
ThreadControl.SetSize(this, 300, 580); ThreadControl.SetSize(this, 300, 580);
} }
protected async override void OnShown(EventArgs e) //protected async override void OnShown(EventArgs e)
{ //{
base.OnShown(e); // base.OnShown(e);
//ThreadControl.SetVisible(this, false); //ThreadControl.SetVisible(this, false);
@ -104,65 +67,40 @@ namespace FizzyLauncher
// ThreadControl.SetVisible(this, true); // 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.IsBusy = true;
// {
// this.Visible = !this.Visible;
// e.Cancel = true;
// return;
// }
// 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)) e.Cancel = true;
// {
// // 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);
// }
// }
// if (this.CurrentSession.HotKey != null) return;
// { }
// if (this.CurrentSession.HotKey.KeyCode != Keys.None)
// {
//#if !DEBUG
// UnregisterHotKey((IntPtr)Handle, 1);
//#endif
// }
// }
sessionFilename = null;
sessionPassword = null;
treeView1.Clear();
ApplicationMode = AppMode.Clear;
this.IsBusy = false;
Application.Exit();
} }
public LauncherSession CurrentSession { get; set; } = null; public LauncherSession CurrentSession { get; set; } = null;
@ -193,18 +131,11 @@ namespace FizzyLauncher
ThreadControl.SetEnable(saveToolStripMenuItem, false); ThreadControl.SetEnable(saveToolStripMenuItem, false);
ThreadControl.SetEnable(saveAsToolStripMenuItem, false); ThreadControl.SetEnable(saveAsToolStripMenuItem, false);
ThreadControl.SetEnable(findToolStripMenuItem, false);
ThreadControl.SetEnable(expandAllToolStripMenuItem, false); ThreadControl.SetEnable(expandAllToolStripMenuItem, false);
ThreadControl.SetEnable(collapseAllToolStripMenuItem, 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; break;
case AppMode.Open: case AppMode.Open:
ThreadControl.SetEnable(closeToolStripMenuItem, true); ThreadControl.SetEnable(closeToolStripMenuItem, true);
@ -212,17 +143,11 @@ namespace FizzyLauncher
ThreadControl.SetEnable(saveToolStripMenuItem, true); ThreadControl.SetEnable(saveToolStripMenuItem, true);
ThreadControl.SetEnable(saveAsToolStripMenuItem, true); ThreadControl.SetEnable(saveAsToolStripMenuItem, true);
ThreadControl.SetEnable(findToolStripMenuItem, true);
ThreadControl.SetEnable(expandAllToolStripMenuItem, true); ThreadControl.SetEnable(expandAllToolStripMenuItem, true);
ThreadControl.SetEnable(collapseAllToolStripMenuItem, 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; break;
case AppMode.New: case AppMode.New:
ThreadControl.SetText(this, AppResource.app_name); ThreadControl.SetText(this, AppResource.app_name);
@ -232,261 +157,18 @@ namespace FizzyLauncher
ThreadControl.SetEnable(saveToolStripMenuItem, false); ThreadControl.SetEnable(saveToolStripMenuItem, false);
ThreadControl.SetEnable(saveAsToolStripMenuItem, true); ThreadControl.SetEnable(saveAsToolStripMenuItem, true);
ThreadControl.SetEnable(findToolStripMenuItem, true);
ThreadControl.SetEnable(expandAllToolStripMenuItem, true); ThreadControl.SetEnable(expandAllToolStripMenuItem, true);
ThreadControl.SetEnable(collapseAllToolStripMenuItem, 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; 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<LauncherSession>(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<TileGroupModel>();
//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 #region main menu
/// <summary> /// <summary>
@ -494,7 +176,7 @@ namespace FizzyLauncher
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void newToolStripMenuItem_Click(object sender, EventArgs e) private async void newToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (this.IsBusy) if (this.IsBusy)
{ {
@ -503,7 +185,13 @@ namespace FizzyLauncher
this.IsBusy = true; 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; sessionFilename = null;
sessionPassword = null; sessionPassword = null;
@ -529,12 +217,22 @@ namespace FizzyLauncher
this.IsBusy = true; 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) if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ {
Result result = await LoadFile(openFileDialog1.FileName); result = await LoadFile(openFileDialog1.FileName);
if (!result.IsSuccess) if (result.IsSuccess)
{
ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + " - " + AppResource.app_name);
}
else
{ {
MessageBox.Show(result.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(result.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
@ -548,7 +246,7 @@ namespace FizzyLauncher
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void closeToolStripMenuItem_Click(object sender, EventArgs e) private async void closeToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (this.IsBusy) if (this.IsBusy)
{ {
@ -557,7 +255,13 @@ namespace FizzyLauncher
this.IsBusy = true; 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; sessionFilename = null;
sessionPassword = null; sessionPassword = null;
@ -762,55 +466,58 @@ namespace FizzyLauncher
MessageBox.Show(Application.ProductName + " v" + Application.ProductVersion, "About", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show(Application.ProductName + " v" + Application.ProductVersion, "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
#endregion #endregion
protected async void CloseFile() protected async Task<Result> CloseFile()
{ {
if (this.ApplicationMode == AppMode.Clear) return await Task.Run<Result>(async () =>
{ {
return; if (this.ApplicationMode == AppMode.Clear)
}
if (!treeView1.HasChanged)
{
return;
}
if (this.ApplicationMode == AppMode.New)
{
DialogResult response = MessageBox.Show("Save bookmarks", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (response == DialogResult.Yes)
{ {
Result result = await SaveAsFile(sessionFilename); return Result.Create(true);
if (!result.IsSuccess) }
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); Result result = await SaveAsFile(sessionFilename);
return; 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; DialogResult response = MessageBox.Show("Save changes to open bookmarks", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
} if (response == DialogResult.Yes)
}
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)
{ {
MessageBox.Show(result.Message, "Save File", MessageBoxButtons.OK, MessageBoxIcon.Error); Result result = await SaveFile(sessionFilename, sessionPassword);
return; 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 Result.Create(true);
return; });
}
}
} }
protected SupportedFileBase GetSupportedFileHandler(string filename) protected SupportedFileBase GetSupportedFileHandler(string filename)

View File

@ -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<TileModel> Items { get; set; } = new List<TileModel>();
[JsonConverter(typeof(JsonSizeConverter))]
public Size GridSize { get; set; } = new Size(0, 0);
}
}

View File

@ -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<TileModel> Items { get; set; } = new List<TileModel>();
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;
}
}
}

View File

@ -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();
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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();
}
}
}

View File

@ -1,82 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="textBox1.HighlightImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vQAADr0BR/uQrQAAAK9JREFUOE/t0zsKwkAURuGp1BWJK3EhIrgAV+EOLLWwtRQLwQdiIbbiIkwynj+O
IVwnyhR2XvjyInNIkXHee8f0cEQBPbDOaKEarSvXhsAJO4wirlB4jipiA3phoIvIrLFChhnKiA3o8Ckw
RR93LNBODVwwwRL62kNKYIxNzQ1FSsDOEHk08HrYJMw/8KtA06/cCef6KJDZgDbTFrHNZO3x9idqOyui
m2+07bvPgHcPXOhtG3D6cUIAAAAASUVORK5CYII=
</value>
</data>
<data name="textBox1.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vQAADr0BR/uQrQAAAMZJREFUOE/tk7sNwjAQQF3BRohJGAQhMQBTsAElFLSUiAKJTxIXhBZlCILNuyRG
iXEQKeg46fmsO/slhU9Za5XWehiXYcD6JElygZ6qhdwTioVDGo4wDXDjsohXdYkvMDTHVa8R9Hb0tpCz
XzqJL5Df/CRYRFE0Yn8nr9M07XcSwBXmXN6QDfncRTCjt6+Rgfla4Adfn3D+ERS4Yht/wY8FxVN2xTac
gLP5qyYLAhmmA4SGyeeEoPkSq3EWydsoB4gRDEqBVU/p15ajstHKCgAAAABJRU5ErkJggg==
</value>
</data>
</root>

View File

@ -181,6 +181,56 @@ namespace RyzStudio.Windows.Forms
return rv; 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) public static void AddLine(RichTextBox control, string text)
{ {
if (control.InvokeRequired) if (control.InvokeRequired)
@ -355,6 +405,12 @@ namespace RyzStudio.Windows.Forms
public static void SetEnable(ToolStripMenuItem control, bool value) public static void SetEnable(ToolStripMenuItem control, bool value)
{ {
if (control.GetCurrentParent() == null)
{
control.Enabled = value;
return;
}
if (control.GetCurrentParent().InvokeRequired) if (control.GetCurrentParent().InvokeRequired)
{ {
control.GetCurrentParent().Invoke(new MethodInvoker(() => control.GetCurrentParent().Invoke(new MethodInvoker(() =>

View File

@ -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<Point>
{
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()));
}
}
}

View File

@ -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<Size>
{
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()));
}
}
}

View File

@ -12,10 +12,7 @@ namespace RyzStudio.Windows.Forms
{ {
public partial class BookmarkTreeView : TreeView public partial class BookmarkTreeView : TreeView
{ {
public static string DecodePath(string value) public static string DecodePath(string value) => System.Web.HttpUtility.UrlDecode(value);
{
return System.Web.HttpUtility.UrlDecode(value);
}
public static void DeleteNode(TreeNode node) public static void DeleteNode(TreeNode node)
{ {
@ -381,7 +378,7 @@ namespace RyzStudio.Windows.Forms
tn.Tag = viewModel; tn.Tag = viewModel;
tn.ToolTipText = viewModel.ToString(); tn.ToolTipText = viewModel.ToString();
TreeNode tn2 = addFolderPath(viewModel.TreeviewPath); TreeNode tn2 = AddFolderPath(viewModel.TreeviewPath);
ThreadControl.Add(tn2, tn); ThreadControl.Add(tn2, tn);
@ -453,7 +450,7 @@ namespace RyzStudio.Windows.Forms
foreach (TreeNode item in this.Nodes) foreach (TreeNode item in this.Nodes)
{ {
traverseBookmarkList(ref itemCount, item); TraverseBookmarkList(ref itemCount, item);
} }
return itemCount; return itemCount;
@ -489,8 +486,7 @@ namespace RyzStudio.Windows.Forms
this.AllowBeginEdit = true; this.AllowBeginEdit = true;
node.BeginEdit(); node.BeginEdit();
break; break;
default: default: break;
break;
} }
} }
@ -512,7 +508,7 @@ namespace RyzStudio.Windows.Forms
foreach (TreeNode item in this.Nodes) foreach (TreeNode item in this.Nodes)
{ {
traverseBookmarkList(rs, item); TraverseBookmarkList(rs, item);
} }
return rs; return rs;
@ -616,8 +612,6 @@ namespace RyzStudio.Windows.Forms
public void Sort() => Sort(this.SelectedNode); public void Sort() => Sort(this.SelectedNode);
public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel) public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel)
{ {
if (treeNode == null) if (treeNode == null)
@ -662,7 +656,7 @@ namespace RyzStudio.Windows.Forms
return; return;
} }
if (isNodeChild(draggingNode, en)) if (IsNodeChild(draggingNode, en))
{ {
return; return;
} }
@ -879,14 +873,14 @@ namespace RyzStudio.Windows.Forms
return (int)IconSet.Default; return (int)IconSet.Default;
} }
this.Add(this.ImageList, model.SiteAddress, bmp); ThreadControl.Add(this, this.ImageList, model.SiteAddress, bmp);
//iconDatabase.AddIcon(model.SiteAddress, rawData); //iconDatabase.AddIcon(model.SiteAddress, rawData);
return this.ImageList.Images.IndexOfKey(model.SiteAddress); return this.ImageList.Images.IndexOfKey(model.SiteAddress);
} }
protected TreeNode addFolderPath(string path) protected TreeNode AddFolderPath(string path)
{ {
TreeNode tn = null; TreeNode tn = null;
//TreeNode tn = this.Nodes[0]; //TreeNode tn = this.Nodes[0];
@ -919,7 +913,7 @@ namespace RyzStudio.Windows.Forms
{ {
if (!this.Nodes.ContainsKey(item)) 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]; tn = this.Nodes[item];
@ -928,7 +922,7 @@ namespace RyzStudio.Windows.Forms
{ {
if (!tn.Nodes.ContainsKey(item)) 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]; tn = tn.Nodes[item];
@ -938,14 +932,35 @@ namespace RyzStudio.Windows.Forms
return tn; return tn;
} }
protected void traverseBookmarkList(List<BookmarkItemViewModel> 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<BookmarkItemViewModel> rs, TreeNode node)
{ {
foreach (TreeNode tn in node.Nodes) foreach (TreeNode tn in node.Nodes)
{ {
NodeType nodeType = GetNodeType(tn); NodeType nodeType = GetNodeType(tn);
if (nodeType == NodeType.Folder) if (nodeType == NodeType.Folder)
{ {
traverseBookmarkList(rs, tn); TraverseBookmarkList(rs, tn);
} }
else if (nodeType == NodeType.Page) else if (nodeType == NodeType.Page)
{ {
@ -960,14 +975,14 @@ namespace RyzStudio.Windows.Forms
} }
} }
protected void traverseBookmarkList(List<TreeNode> rs, TreeNode node) protected void TraverseBookmarkList(List<TreeNode> rs, TreeNode node)
{ {
foreach (TreeNode tn in node.Nodes) foreach (TreeNode tn in node.Nodes)
{ {
NodeType nodeType = GetNodeType(tn); NodeType nodeType = GetNodeType(tn);
if (nodeType == NodeType.Folder) if (nodeType == NodeType.Folder)
{ {
traverseBookmarkList(rs, tn); TraverseBookmarkList(rs, tn);
} }
else if (nodeType == NodeType.Page) 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) foreach (TreeNode tn in node.Nodes)
{ {
NodeType nodeType = GetNodeType(tn); NodeType nodeType = GetNodeType(tn);
if (nodeType == NodeType.Folder) if (nodeType == NodeType.Folder)
{ {
traverseBookmarkList(ref itemCount, tn); TraverseBookmarkList(ref itemCount, tn);
} }
else if (nodeType == NodeType.Page) 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;
}
} }