WIP: treeview context
This commit is contained in:
parent
d575c66ed9
commit
bbbd85380e
276
MainForm.Designer.cs
generated
276
MainForm.Designer.cs
generated
@ -31,8 +31,6 @@
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
|
||||
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -59,8 +57,37 @@
|
||||
this.aboutToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.treeView1 = new RyzStudio.Windows.Forms.BookmarkTreeView();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.contextMenuStrip2.SuspendLayout();
|
||||
this.rootContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.addPageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.sortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.folderContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.addPageToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addFolderToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.openAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.sortToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pageContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.openToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.editToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.moveUpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.moveDownToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.rootContextMenu.SuspendLayout();
|
||||
this.folderContextMenu.SuspendLayout();
|
||||
this.pageContextMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// saveFileDialog1
|
||||
@ -69,20 +96,6 @@
|
||||
this.saveFileDialog1.Filter = "Bookmarks files (*.jsnx)|*.jsnx|Bookmarks files (*.ryz)|*.ryz";
|
||||
this.saveFileDialog1.Title = "Save bookmarks file";
|
||||
//
|
||||
// contextMenuStrip2
|
||||
//
|
||||
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.exitToolStripMenuItem1});
|
||||
this.contextMenuStrip2.Name = "contextMenuStrip2";
|
||||
this.contextMenuStrip2.Size = new System.Drawing.Size(94, 26);
|
||||
//
|
||||
// exitToolStripMenuItem1
|
||||
//
|
||||
this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1";
|
||||
this.exitToolStripMenuItem1.Size = new System.Drawing.Size(93, 22);
|
||||
this.exitToolStripMenuItem1.Text = "E&xit";
|
||||
this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@ -291,6 +304,202 @@
|
||||
this.openFileDialog1.Filter = "Bookmarks files (*.jsnx)|*.jsnx|Bookmarks files (*.ryz)|*.ryz";
|
||||
this.openFileDialog1.Title = "Open bookmarks file";
|
||||
//
|
||||
// rootContextMenu
|
||||
//
|
||||
this.rootContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addPageToolStripMenuItem,
|
||||
this.addFolderToolStripMenuItem,
|
||||
this.toolStripMenuItem2,
|
||||
this.editToolStripMenuItem,
|
||||
this.toolStripMenuItem3,
|
||||
this.sortToolStripMenuItem});
|
||||
this.rootContextMenu.Name = "rootContextMenu";
|
||||
this.rootContextMenu.Size = new System.Drawing.Size(133, 104);
|
||||
//
|
||||
// addPageToolStripMenuItem
|
||||
//
|
||||
this.addPageToolStripMenuItem.Name = "addPageToolStripMenuItem";
|
||||
this.addPageToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
|
||||
this.addPageToolStripMenuItem.Text = "Add &Page";
|
||||
this.addPageToolStripMenuItem.Click += new System.EventHandler(this.addPageToolStripMenuItem_Click);
|
||||
//
|
||||
// addFolderToolStripMenuItem
|
||||
//
|
||||
this.addFolderToolStripMenuItem.Name = "addFolderToolStripMenuItem";
|
||||
this.addFolderToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
|
||||
this.addFolderToolStripMenuItem.Text = "Add &Folder";
|
||||
this.addFolderToolStripMenuItem.Click += new System.EventHandler(this.addFolderToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(129, 6);
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
|
||||
this.editToolStripMenuItem.Text = "&Edit";
|
||||
this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripMenuItem3
|
||||
//
|
||||
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||
this.toolStripMenuItem3.Size = new System.Drawing.Size(129, 6);
|
||||
//
|
||||
// sortToolStripMenuItem
|
||||
//
|
||||
this.sortToolStripMenuItem.Name = "sortToolStripMenuItem";
|
||||
this.sortToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
|
||||
this.sortToolStripMenuItem.Text = "&Sort";
|
||||
this.sortToolStripMenuItem.Click += new System.EventHandler(this.sortToolStripMenuItem_Click);
|
||||
//
|
||||
// folderContextMenu
|
||||
//
|
||||
this.folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addPageToolStripMenuItem1,
|
||||
this.addFolderToolStripMenuItem1,
|
||||
this.toolStripMenuItem4,
|
||||
this.openAllToolStripMenuItem,
|
||||
this.editToolStripMenuItem1,
|
||||
this.deleteToolStripMenuItem,
|
||||
this.toolStripMenuItem5,
|
||||
this.sortToolStripMenuItem1,
|
||||
this.toolStripMenuItem6,
|
||||
this.moveUpToolStripMenuItem,
|
||||
this.moveDownToolStripMenuItem});
|
||||
this.folderContextMenu.Name = "folderContextMenu";
|
||||
this.folderContextMenu.Size = new System.Drawing.Size(139, 198);
|
||||
//
|
||||
// addPageToolStripMenuItem1
|
||||
//
|
||||
this.addPageToolStripMenuItem1.Name = "addPageToolStripMenuItem1";
|
||||
this.addPageToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
|
||||
this.addPageToolStripMenuItem1.Text = "Add &Page";
|
||||
this.addPageToolStripMenuItem1.Click += new System.EventHandler(this.addPageToolStripMenuItem1_Click);
|
||||
//
|
||||
// addFolderToolStripMenuItem1
|
||||
//
|
||||
this.addFolderToolStripMenuItem1.Name = "addFolderToolStripMenuItem1";
|
||||
this.addFolderToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
|
||||
this.addFolderToolStripMenuItem1.Text = "Add &Folder";
|
||||
this.addFolderToolStripMenuItem1.Click += new System.EventHandler(this.addFolderToolStripMenuItem1_Click);
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
//
|
||||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(135, 6);
|
||||
//
|
||||
// openAllToolStripMenuItem
|
||||
//
|
||||
this.openAllToolStripMenuItem.Name = "openAllToolStripMenuItem";
|
||||
this.openAllToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
|
||||
this.openAllToolStripMenuItem.Text = "&Open All";
|
||||
this.openAllToolStripMenuItem.Click += new System.EventHandler(this.openAllToolStripMenuItem_Click);
|
||||
//
|
||||
// editToolStripMenuItem1
|
||||
//
|
||||
this.editToolStripMenuItem1.Name = "editToolStripMenuItem1";
|
||||
this.editToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
|
||||
this.editToolStripMenuItem1.Text = "&Edit";
|
||||
this.editToolStripMenuItem1.Click += new System.EventHandler(this.editToolStripMenuItem1_Click);
|
||||
//
|
||||
// deleteToolStripMenuItem
|
||||
//
|
||||
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
|
||||
this.deleteToolStripMenuItem.Text = "&Delete";
|
||||
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripMenuItem5
|
||||
//
|
||||
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
|
||||
this.toolStripMenuItem5.Size = new System.Drawing.Size(135, 6);
|
||||
//
|
||||
// sortToolStripMenuItem1
|
||||
//
|
||||
this.sortToolStripMenuItem1.Name = "sortToolStripMenuItem1";
|
||||
this.sortToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
|
||||
this.sortToolStripMenuItem1.Text = "&Sort";
|
||||
this.sortToolStripMenuItem1.Click += new System.EventHandler(this.sortToolStripMenuItem1_Click);
|
||||
//
|
||||
// toolStripMenuItem6
|
||||
//
|
||||
this.toolStripMenuItem6.Name = "toolStripMenuItem6";
|
||||
this.toolStripMenuItem6.Size = new System.Drawing.Size(135, 6);
|
||||
//
|
||||
// moveUpToolStripMenuItem
|
||||
//
|
||||
this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
|
||||
this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
|
||||
this.moveUpToolStripMenuItem.Text = "Move &Up";
|
||||
this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
|
||||
//
|
||||
// moveDownToolStripMenuItem
|
||||
//
|
||||
this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
|
||||
this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
|
||||
this.moveDownToolStripMenuItem.Text = "Move &Down";
|
||||
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
|
||||
//
|
||||
// pageContextMenu
|
||||
//
|
||||
this.pageContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem1,
|
||||
this.toolStripMenuItem7,
|
||||
this.editToolStripMenuItem2,
|
||||
this.deleteToolStripMenuItem1,
|
||||
this.toolStripMenuItem8,
|
||||
this.moveUpToolStripMenuItem1,
|
||||
this.moveDownToolStripMenuItem1});
|
||||
this.pageContextMenu.Name = "pageContextMenu";
|
||||
this.pageContextMenu.Size = new System.Drawing.Size(181, 148);
|
||||
//
|
||||
// openToolStripMenuItem1
|
||||
//
|
||||
this.openToolStripMenuItem1.Name = "openToolStripMenuItem1";
|
||||
this.openToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.openToolStripMenuItem1.Text = "&Open";
|
||||
this.openToolStripMenuItem1.Click += new System.EventHandler(this.openToolStripMenuItem1_Click);
|
||||
//
|
||||
// toolStripMenuItem7
|
||||
//
|
||||
this.toolStripMenuItem7.Name = "toolStripMenuItem7";
|
||||
this.toolStripMenuItem7.Size = new System.Drawing.Size(177, 6);
|
||||
//
|
||||
// editToolStripMenuItem2
|
||||
//
|
||||
this.editToolStripMenuItem2.Name = "editToolStripMenuItem2";
|
||||
this.editToolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
|
||||
this.editToolStripMenuItem2.Text = "&Edit";
|
||||
this.editToolStripMenuItem2.Click += new System.EventHandler(this.editToolStripMenuItem2_Click);
|
||||
//
|
||||
// deleteToolStripMenuItem1
|
||||
//
|
||||
this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1";
|
||||
this.deleteToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.deleteToolStripMenuItem1.Text = "&Delete";
|
||||
this.deleteToolStripMenuItem1.Click += new System.EventHandler(this.deleteToolStripMenuItem1_Click);
|
||||
//
|
||||
// toolStripMenuItem8
|
||||
//
|
||||
this.toolStripMenuItem8.Name = "toolStripMenuItem8";
|
||||
this.toolStripMenuItem8.Size = new System.Drawing.Size(177, 6);
|
||||
//
|
||||
// moveUpToolStripMenuItem1
|
||||
//
|
||||
this.moveUpToolStripMenuItem1.Name = "moveUpToolStripMenuItem1";
|
||||
this.moveUpToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.moveUpToolStripMenuItem1.Text = "Move &Up";
|
||||
this.moveUpToolStripMenuItem1.Click += new System.EventHandler(this.moveUpToolStripMenuItem1_Click);
|
||||
//
|
||||
// moveDownToolStripMenuItem1
|
||||
//
|
||||
this.moveDownToolStripMenuItem1.Name = "moveDownToolStripMenuItem1";
|
||||
this.moveDownToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.moveDownToolStripMenuItem1.Text = "Move &Down";
|
||||
this.moveDownToolStripMenuItem1.Click += new System.EventHandler(this.moveDownToolStripMenuItem1_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
@ -307,9 +516,11 @@
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Bookmark Manager";
|
||||
this.contextMenuStrip2.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.rootContextMenu.ResumeLayout(false);
|
||||
this.folderContextMenu.ResumeLayout(false);
|
||||
this.pageContextMenu.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -317,8 +528,6 @@
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
|
||||
@ -345,6 +554,33 @@
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private RyzStudio.Windows.Forms.BookmarkTreeView treeView1;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.ContextMenuStrip rootContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addPageToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addFolderToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
|
||||
private System.Windows.Forms.ToolStripMenuItem sortToolStripMenuItem;
|
||||
private System.Windows.Forms.ContextMenuStrip folderContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addPageToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem addFolderToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
|
||||
private System.Windows.Forms.ToolStripMenuItem openAllToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem5;
|
||||
private System.Windows.Forms.ToolStripMenuItem sortToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem;
|
||||
private System.Windows.Forms.ContextMenuStrip pageContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem2;
|
||||
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem8;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem1;
|
||||
}
|
||||
}
|
||||
|
||||
|
434
MainForm.cs
434
MainForm.cs
@ -1,4 +1,5 @@
|
||||
using BookmarkManager;
|
||||
using bzit.bomg.Models;
|
||||
using FizzyLauncher.Models;
|
||||
using Newtonsoft.Json;
|
||||
using RyzStudio.Windows.Forms;
|
||||
@ -44,11 +45,14 @@ namespace FizzyLauncher
|
||||
|
||||
jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig");
|
||||
|
||||
treeView1.RootContextMenu = rootContextMenu;
|
||||
treeView1.FolderContextMenu = folderContextMenu;
|
||||
treeView1.PageContextMenu = pageContextMenu;
|
||||
treeView1.NodeMouseDoubleClick += treeView1_NodeMouseDoubleClick;
|
||||
treeView1.OnNodeChanged += treeView1_OnNodeChanged;
|
||||
treeView1.NodeMouseClick += treeView1_NodeMouseClick;
|
||||
treeView1.PreviewKeyDown += treeView1_PreviewKeyDown;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
@ -69,6 +73,7 @@ namespace FizzyLauncher
|
||||
|
||||
InvalidateAppSession();
|
||||
|
||||
newToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
|
||||
protected async override void OnClosing(CancelEventArgs e)
|
||||
@ -489,122 +494,216 @@ namespace FizzyLauncher
|
||||
|
||||
#endregion
|
||||
|
||||
#region context menu
|
||||
|
||||
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
/// <summary>
|
||||
/// Add page
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addPageToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (e.Button != MouseButtons.Right)
|
||||
if (this.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (treeView1.GetNodeType())
|
||||
//treeView1.AddItem(.AddFolder("New Folder");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add folder
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addFolderToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.AddFolder("New Folder");
|
||||
|
||||
/// <summary>
|
||||
/// Edit root node
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void editToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.EditNode();
|
||||
|
||||
/// <summary>
|
||||
/// Sort
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void sortToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.Sort();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add page
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addPageToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
case BookmarkTreeView.NodeType.Root:
|
||||
//rootTreeNodeMenu.Show(e.Node.TreeView, e.X, e.Y);
|
||||
break;
|
||||
case BookmarkTreeView.NodeType.Folder:
|
||||
//folderTreeNodeMenu.Show(e.Node.TreeView, e.X, e.Y);
|
||||
break;
|
||||
case BookmarkTreeView.NodeType.Page:
|
||||
//pageTreeNodeMenu.Show(e.Node.TreeView, e.X, e.Y);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add folder
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addFolderToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.AddFolder("New Folder");
|
||||
|
||||
/// <summary>
|
||||
/// Open all pages
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void openAllToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (treeView1.SelectedNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (treeView1.SelectedNode.Nodes.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (TreeNode item in treeView1.SelectedNode.Nodes)
|
||||
{
|
||||
await OpenBookmark(item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edit folder name
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void editToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.EditNode();
|
||||
|
||||
/// <summary>
|
||||
/// Delete folder and contents
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.DeleteNode();
|
||||
|
||||
/// <summary>
|
||||
/// Sort children
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void sortToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.Sort();
|
||||
|
||||
/// <summary>
|
||||
/// Move up
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.MoveUp();
|
||||
|
||||
/// <summary>
|
||||
/// Move down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void moveDownToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.MoveDown();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Open page
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void openToolStripMenuItem1_Click(object sender, EventArgs e) => await OpenBookmark(treeView1.SelectedNode);
|
||||
|
||||
/// <summary>
|
||||
/// Edit page
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void editToolStripMenuItem2_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete page
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void deleteToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.DeleteNode();
|
||||
|
||||
/// <summary>
|
||||
/// Move up
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void moveUpToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.MoveUp();
|
||||
|
||||
/// <summary>
|
||||
/// Move down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void moveDownToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.MoveDown();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private async void treeView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
TreeNode tn = treeView1.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BookmarkTreeView.NodeType nodeType = treeView1.GetNodeType();
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Enter:
|
||||
await OpenBookmark(tn);
|
||||
break;
|
||||
case Keys.F2:
|
||||
if (nodeType == BookmarkTreeView.NodeType.Page)
|
||||
{
|
||||
//(new BookmarkEditForm(treeView1)).ShowDialog();
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Insert:
|
||||
if (e.Modifiers != Keys.Shift)
|
||||
{
|
||||
if ((nodeType == BookmarkTreeView.NodeType.Root) || (nodeType == BookmarkTreeView.NodeType.Folder))
|
||||
{
|
||||
//(new BookmarkEditForm(treeView1)).ShowDialog();
|
||||
}
|
||||
else if (nodeType == BookmarkTreeView.NodeType.Page)
|
||||
{
|
||||
treeView1.SelectedNode = tn.Parent;
|
||||
|
||||
//(new BookmarkEditForm(treeView1)).ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
private async void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) => await OpenBookmark(e.Node);
|
||||
|
||||
private void treeView1_OnNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ThreadControl.SetEnable(saveToolStripMenuItem, (treeView1.HasChanged && ApplicationMode == AppMode.Open));
|
||||
}
|
||||
|
||||
protected void InvalidateAppSession()
|
||||
{
|
||||
if (CurrentSession == null) CurrentSession = new AppSession();
|
||||
|
||||
if (CurrentSession.EnableAutoPosition)
|
||||
{
|
||||
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
|
||||
this.Location = Screen.PrimaryScreen.WorkingArea.Location;
|
||||
}
|
||||
|
||||
this.TopMost = CurrentSession.AlwaysOnTop;
|
||||
}
|
||||
|
||||
protected async Task<bool> LoadAppSession(string filename)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
string sourceCode = null;
|
||||
|
||||
try
|
||||
{
|
||||
sourceCode = File.ReadAllText(filename);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sourceCode))
|
||||
{
|
||||
this.CurrentSession = new AppSession();
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.CurrentSession = JsonConvert.DeserializeObject<AppSession>(sourceCode);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.CurrentSession = null;
|
||||
}
|
||||
|
||||
if (this.CurrentSession == null)
|
||||
{
|
||||
this.CurrentSession = new AppSession();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurrentSession = new AppSession();
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(this.CurrentSession));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task<bool> SaveAppSession(string filename)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
if (this.CurrentSession == null) this.CurrentSession = new AppSession();
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(this.CurrentSession));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task<Result> CloseFile()
|
||||
{
|
||||
@ -681,6 +780,75 @@ namespace FizzyLauncher
|
||||
return rs;
|
||||
}
|
||||
|
||||
protected void InvalidateAppSession()
|
||||
{
|
||||
if (CurrentSession == null) CurrentSession = new AppSession();
|
||||
|
||||
if (CurrentSession.EnableAutoPosition)
|
||||
{
|
||||
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
|
||||
this.Location = Screen.PrimaryScreen.WorkingArea.Location;
|
||||
}
|
||||
|
||||
this.TopMost = CurrentSession.AlwaysOnTop;
|
||||
}
|
||||
|
||||
protected async Task<bool> LoadAppSession(string filename)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
string sourceCode = null;
|
||||
|
||||
try
|
||||
{
|
||||
sourceCode = File.ReadAllText(filename);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sourceCode))
|
||||
{
|
||||
this.CurrentSession = new AppSession();
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.CurrentSession = JsonConvert.DeserializeObject<AppSession>(sourceCode);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.CurrentSession = null;
|
||||
}
|
||||
|
||||
if (this.CurrentSession == null)
|
||||
{
|
||||
this.CurrentSession = new AppSession();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurrentSession = new AppSession();
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(this.CurrentSession));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task<Result> LoadFile(string filename)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
@ -742,6 +910,46 @@ namespace FizzyLauncher
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task OpenBookmark(TreeNode node)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (BookmarkTreeView.GetNodeType(node) != BookmarkTreeView.NodeType.Page)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BookmarkItemViewModel viewModel = (BookmarkItemViewModel)node.Tag;
|
||||
if (viewModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(viewModel.SiteAddress))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string cmd = (string.IsNullOrWhiteSpace(CurrentSession.RunCommand) ? viewModel.SiteAddress : CurrentSession.RunCommand.Replace("{0}", viewModel.SiteAddress));
|
||||
|
||||
try
|
||||
{
|
||||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = cmd,
|
||||
UseShellExecute = true
|
||||
};
|
||||
System.Diagnostics.Process.Start(psi);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
#if DEBUG
|
||||
MessageBox.Show(exc.Message);
|
||||
#endif
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task<Result> SaveFile(string filename, string password = null)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
@ -767,6 +975,25 @@ namespace FizzyLauncher
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task<bool> SaveAppSession(string filename)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
if (this.CurrentSession == null) this.CurrentSession = new AppSession();
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(this.CurrentSession));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
protected async Task<Result> SaveAsFile(string filename)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
@ -806,5 +1033,6 @@ namespace FizzyLauncher
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -60,15 +60,21 @@
|
||||
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>172, 17</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>561, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>716, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="rootContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>831, 17</value>
|
||||
</metadata>
|
||||
<metadata name="folderContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>979, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pageContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>1137, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
@ -6,9 +6,13 @@ namespace bzit.bomg.Models
|
||||
public class BookmarkItemViewModel
|
||||
{
|
||||
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()
|
||||
@ -26,17 +30,17 @@ namespace bzit.bomg.Models
|
||||
public new string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("Name = ");
|
||||
sb.Append(this.SiteName ?? string.Empty);
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine("Name = ");
|
||||
sb.AppendLine(this.SiteName ?? string.Empty);
|
||||
sb.AppendLine(string.Empty);
|
||||
|
||||
sb.Append("Address = ");
|
||||
sb.Append(this.SiteAddress ?? string.Empty);
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine("Address = ");
|
||||
sb.AppendLine(this.SiteAddress ?? string.Empty);
|
||||
sb.AppendLine(string.Empty);
|
||||
|
||||
sb.Append("Description = ");
|
||||
sb.Append(this.SiteDescription ?? string.Empty);
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine("Description = ");
|
||||
sb.AppendLine(this.SiteDescription ?? string.Empty);
|
||||
sb.AppendLine(string.Empty);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -239,6 +239,240 @@ namespace RyzStudio.Windows.Forms
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region integrated behaviour
|
||||
|
||||
protected override void OnItemDrag(ItemDragEventArgs e)
|
||||
{
|
||||
base.OnItemDrag(e);
|
||||
|
||||
draggingNode = (TreeNode)e.Item;
|
||||
DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs e)
|
||||
{
|
||||
base.OnDragDrop(e);
|
||||
|
||||
if (draggingNode.Level <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TreeNode en = this.GetNodeAt(this.PointToClient(new Point(e.X, e.Y)));
|
||||
if (en == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsNodeChild(draggingNode, en))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TreeNode dn = draggingNode;
|
||||
if (en.Tag == null)
|
||||
{
|
||||
dn.Parent.Nodes.Remove(dn);
|
||||
en.Nodes.Insert(0, dn);
|
||||
}
|
||||
else
|
||||
{
|
||||
en.Parent.Nodes.Remove(dn);
|
||||
en.Parent.Nodes.Insert(en.Index + 1, dn);
|
||||
}
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
|
||||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
this.SelectedNode = this.GetNodeAt(e.Location);
|
||||
}
|
||||
|
||||
protected override void OnDragOver(DragEventArgs e)
|
||||
{
|
||||
base.OnDragOver(e);
|
||||
|
||||
this.SelectedNode = this.GetNodeAt(this.PointToClient(new Point(e.X, e.Y)));
|
||||
}
|
||||
|
||||
protected override void OnBeforeLabelEdit(NodeLabelEditEventArgs e)
|
||||
{
|
||||
if (!AllowBeginEdit)
|
||||
{
|
||||
AllowBeginEdit = false;
|
||||
|
||||
e.CancelEdit = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.HasChanged = true;
|
||||
|
||||
base.OnBeforeLabelEdit(e);
|
||||
}
|
||||
|
||||
protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
|
||||
{
|
||||
base.OnAfterLabelEdit(e);
|
||||
|
||||
//if (e.Node.Tag == null)
|
||||
//{
|
||||
// if (e.Label == null)
|
||||
// {
|
||||
// e.CancelEdit = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (e.Label.Trim().Length <= 0)
|
||||
// {
|
||||
// e.CancelEdit = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// e.CancelEdit = true;
|
||||
//}
|
||||
|
||||
AllowBeginEdit = false;
|
||||
}
|
||||
|
||||
protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
switch (this.GetNodeType())
|
||||
{
|
||||
case BookmarkTreeView.NodeType.Root:
|
||||
if (this.RootContextMenu != null) this.RootContextMenu.Show(e.Node.TreeView, e.X, e.Y);
|
||||
break;
|
||||
case BookmarkTreeView.NodeType.Folder:
|
||||
if (this.FolderContextMenu != null) this.FolderContextMenu.Show(e.Node.TreeView, e.X, e.Y);
|
||||
break;
|
||||
case BookmarkTreeView.NodeType.Page:
|
||||
if (this.PageContextMenu != null) this.PageContextMenu.Show(e.Node.TreeView, e.X, e.Y);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnNodeMouseClick(e);
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e)
|
||||
{
|
||||
TreeNode tn = this.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NodeType nodeType = this.GetNodeType();
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Insert:
|
||||
if (e.Modifiers == Keys.Shift)
|
||||
{
|
||||
if ((nodeType == NodeType.Root) || (nodeType == NodeType.Folder))
|
||||
{
|
||||
this.SelectedNode = this.AddFolder();
|
||||
}
|
||||
else if (nodeType == NodeType.Page)
|
||||
{
|
||||
this.SelectedNode = tn.Parent;
|
||||
this.SelectedNode = this.AddFolder();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Delete:
|
||||
if (!tn.IsEditing)
|
||||
{
|
||||
this.DeleteNode();
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.F2:
|
||||
if ((nodeType == NodeType.Root) || (nodeType == NodeType.Folder))
|
||||
{
|
||||
this.AllowBeginEdit = true;
|
||||
|
||||
this.EditNode();
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.F3:
|
||||
switch (nodeType)
|
||||
{
|
||||
case NodeType.Root:
|
||||
case NodeType.Folder:
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(tn.Text ?? string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
break;
|
||||
case NodeType.Page:
|
||||
BookmarkItemViewModel viewModel = this.GetNodeModel();
|
||||
if (viewModel != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(viewModel.SiteAddress ?? string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Up:
|
||||
if (e.Modifiers == Keys.Control)
|
||||
{
|
||||
this.MoveUp();
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Down:
|
||||
if (e.Modifiers == Keys.Control)
|
||||
{
|
||||
this.MoveDown();
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Apps:
|
||||
this.OnNodeMouseClick(new TreeNodeMouseClickEventArgs(tn, MouseButtons.Right, 1, tn.Bounds.X, tn.Bounds.Y));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
base.OnPreviewKeyDown(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region encapsulation
|
||||
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
@ -285,6 +519,15 @@ namespace RyzStudio.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public ContextMenuStrip RootContextMenu { get; set; } = null;
|
||||
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public ContextMenuStrip FolderContextMenu { get; set; } = null;
|
||||
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public ContextMenuStrip PageContextMenu { get; set; } = null;
|
||||
|
||||
|
||||
public bool InitialiseIconDatabase(out string message, string filename)
|
||||
{
|
||||
@ -438,22 +681,22 @@ namespace RyzStudio.Windows.Forms
|
||||
//iconDatabase.Close();
|
||||
}
|
||||
|
||||
public int CountBookmarkItem()
|
||||
{
|
||||
int itemCount = 0;
|
||||
//public int CountBookmarkItem()
|
||||
//{
|
||||
// int itemCount = 0;
|
||||
|
||||
if (this.Nodes.Count <= 0)
|
||||
{
|
||||
return itemCount;
|
||||
}
|
||||
// if (this.Nodes.Count <= 0)
|
||||
// {
|
||||
// return itemCount;
|
||||
// }
|
||||
|
||||
foreach (TreeNode item in this.Nodes)
|
||||
{
|
||||
TraverseBookmarkList(ref itemCount, item);
|
||||
}
|
||||
// foreach (TreeNode item in this.Nodes)
|
||||
// {
|
||||
// TraverseBookmarkList(ref itemCount, item);
|
||||
// }
|
||||
|
||||
return itemCount;
|
||||
}
|
||||
// return itemCount;
|
||||
//}
|
||||
|
||||
public void DeleteNode() => DeleteNode(this.SelectedNode);
|
||||
|
||||
@ -609,233 +852,26 @@ namespace RyzStudio.Windows.Forms
|
||||
this.HasChanged = false;
|
||||
}
|
||||
|
||||
public void Sort() => Sort(this.SelectedNode);
|
||||
public new void Sort() => Sort(this.SelectedNode);
|
||||
|
||||
public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel)
|
||||
{
|
||||
if (treeNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int iconIndex = addIcon(viewModel);
|
||||
|
||||
treeNode.Text = viewModel.SiteName;
|
||||
treeNode.ImageIndex = iconIndex;
|
||||
treeNode.SelectedImageIndex = iconIndex;
|
||||
treeNode.Tag = viewModel;
|
||||
treeNode.ToolTipText = viewModel.ToString();
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
|
||||
#region integrated behaviour
|
||||
|
||||
protected override void OnItemDrag(ItemDragEventArgs e)
|
||||
{
|
||||
base.OnItemDrag(e);
|
||||
|
||||
draggingNode = (TreeNode)e.Item;
|
||||
DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs e)
|
||||
{
|
||||
base.OnDragDrop(e);
|
||||
|
||||
if (draggingNode.Level <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TreeNode en = this.GetNodeAt(this.PointToClient(new Point(e.X, e.Y)));
|
||||
if (en == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsNodeChild(draggingNode, en))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TreeNode dn = draggingNode;
|
||||
if (en.Tag == null)
|
||||
{
|
||||
dn.Parent.Nodes.Remove(dn);
|
||||
en.Nodes.Insert(0, dn);
|
||||
}
|
||||
else
|
||||
{
|
||||
en.Parent.Nodes.Remove(dn);
|
||||
en.Parent.Nodes.Insert(en.Index + 1, dn);
|
||||
}
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
|
||||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
this.SelectedNode = this.GetNodeAt(e.Location);
|
||||
}
|
||||
|
||||
protected override void OnDragOver(DragEventArgs e)
|
||||
{
|
||||
base.OnDragOver(e);
|
||||
|
||||
this.SelectedNode = this.GetNodeAt(this.PointToClient(new Point(e.X, e.Y)));
|
||||
}
|
||||
|
||||
protected override void OnBeforeLabelEdit(NodeLabelEditEventArgs e)
|
||||
{
|
||||
if (!AllowBeginEdit)
|
||||
{
|
||||
AllowBeginEdit = false;
|
||||
|
||||
e.CancelEdit = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.HasChanged = true;
|
||||
|
||||
base.OnBeforeLabelEdit(e);
|
||||
}
|
||||
|
||||
protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
|
||||
{
|
||||
base.OnAfterLabelEdit(e);
|
||||
|
||||
//if (e.Node.Tag == null)
|
||||
//public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel)
|
||||
//{
|
||||
// if (e.Label == null)
|
||||
// if (treeNode == null)
|
||||
// {
|
||||
// e.CancelEdit = true;
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (e.Label.Trim().Length <= 0)
|
||||
// {
|
||||
// e.CancelEdit = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// e.CancelEdit = true;
|
||||
|
||||
// int iconIndex = addIcon(viewModel);
|
||||
|
||||
// treeNode.Text = viewModel.SiteName;
|
||||
// treeNode.ImageIndex = iconIndex;
|
||||
// treeNode.SelectedImageIndex = iconIndex;
|
||||
// treeNode.Tag = viewModel;
|
||||
// treeNode.ToolTipText = viewModel.ToString();
|
||||
|
||||
// this.HasChanged = true;
|
||||
//}
|
||||
|
||||
AllowBeginEdit = false;
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e)
|
||||
{
|
||||
TreeNode tn = this.SelectedNode;
|
||||
if (tn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NodeType nodeType = this.GetNodeType();
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Insert:
|
||||
if (e.Modifiers == Keys.Shift)
|
||||
{
|
||||
if ((nodeType == NodeType.Root) || (nodeType == NodeType.Folder))
|
||||
{
|
||||
this.SelectedNode = this.AddFolder();
|
||||
}
|
||||
else if (nodeType == NodeType.Page)
|
||||
{
|
||||
this.SelectedNode = tn.Parent;
|
||||
this.SelectedNode = this.AddFolder();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Delete:
|
||||
if (!tn.IsEditing)
|
||||
{
|
||||
this.DeleteNode();
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.F2:
|
||||
if ((nodeType == NodeType.Root) || (nodeType == NodeType.Folder))
|
||||
{
|
||||
this.AllowBeginEdit = true;
|
||||
|
||||
this.EditNode();
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.F3:
|
||||
switch (nodeType)
|
||||
{
|
||||
case NodeType.Root:
|
||||
case NodeType.Folder:
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(tn.Text ?? string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
break;
|
||||
case NodeType.Page:
|
||||
BookmarkItemViewModel viewModel = this.GetNodeModel();
|
||||
if (viewModel != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(viewModel.SiteAddress ?? string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Up:
|
||||
if (e.Modifiers == Keys.Control)
|
||||
{
|
||||
this.MoveUp();
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case Keys.Down:
|
||||
if (e.Modifiers == Keys.Control)
|
||||
{
|
||||
this.MoveDown();
|
||||
this.HasChanged = true;
|
||||
}
|
||||
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
base.OnPreviewKeyDown(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
protected int addIcon(BookmarkItemViewModel viewModel)
|
||||
|
Loading…
Reference in New Issue
Block a user