diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index cc55ac7..c1ec0cd 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -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;
}
}
diff --git a/MainForm.cs b/MainForm.cs
index 8f0a140..56d7912 100644
--- a/MainForm.cs
+++ b/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)
+ ///
+ /// Add page
+ ///
+ ///
+ ///
+ 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");
+ }
+
+ ///
+ /// Add folder
+ ///
+ ///
+ ///
+ private void addFolderToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.AddFolder("New Folder");
+
+ ///
+ /// Edit root node
+ ///
+ ///
+ ///
+ private void editToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.EditNode();
+
+ ///
+ /// Sort
+ ///
+ ///
+ ///
+ private void sortToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.Sort();
+
+
+ ///
+ /// Add page
+ ///
+ ///
+ ///
+ private void addPageToolStripMenuItem1_Click(object sender, EventArgs e)
+ {
+ }
+
+ ///
+ /// Add folder
+ ///
+ ///
+ ///
+ private void addFolderToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.AddFolder("New Folder");
+
+ ///
+ /// Open all pages
+ ///
+ ///
+ ///
+ private async void openAllToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (this.IsBusy)
{
- 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;
+ return;
+ }
+
+ if (treeView1.SelectedNode == null)
+ {
+ return;
+ }
+
+ if (treeView1.SelectedNode.Nodes.Count <= 0)
+ {
+ return;
+ }
+
+ foreach (TreeNode item in treeView1.SelectedNode.Nodes)
+ {
+ await OpenBookmark(item);
}
}
+ ///
+ /// Edit folder name
+ ///
+ ///
+ ///
+ private void editToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.EditNode();
+
+ ///
+ /// Delete folder and contents
+ ///
+ ///
+ ///
+ private void deleteToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.DeleteNode();
+
+ ///
+ /// Sort children
+ ///
+ ///
+ ///
+ private void sortToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.Sort();
+
+ ///
+ /// Move up
+ ///
+ ///
+ ///
+ private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.MoveUp();
+
+ ///
+ /// Move down
+ ///
+ ///
+ ///
+ private void moveDownToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.MoveDown();
+
+
+ ///
+ /// Open page
+ ///
+ ///
+ ///
+ private async void openToolStripMenuItem1_Click(object sender, EventArgs e) => await OpenBookmark(treeView1.SelectedNode);
+
+ ///
+ /// Edit page
+ ///
+ ///
+ ///
+ private void editToolStripMenuItem2_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ ///
+ /// Delete page
+ ///
+ ///
+ ///
+ private void deleteToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.DeleteNode();
+
+ ///
+ /// Move up
+ ///
+ ///
+ ///
+ private void moveUpToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.MoveUp();
+
+ ///
+ /// Move down
+ ///
+ ///
+ ///
+ 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 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(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 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 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 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(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 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 SaveFile(string filename, string password = null)
{
return await Task.Run(() =>
@@ -767,6 +975,25 @@ namespace FizzyLauncher
});
}
+ protected async Task 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 SaveAsFile(string filename)
{
return await Task.Run(() =>
@@ -806,5 +1033,6 @@ namespace FizzyLauncher
});
}
+
}
}
\ No newline at end of file
diff --git a/MainForm.resx b/MainForm.resx
index 5b26a88..0bfc5f8 100644
--- a/MainForm.resx
+++ b/MainForm.resx
@@ -60,15 +60,21 @@
172, 17
-
- 561, 17
-
716, 17
17, 17
+
+ 831, 17
+
+
+ 979, 17
+
+
+ 1137, 17
+
diff --git a/Models/BookmarkItemViewModel.cs b/Models/BookmarkItemViewModel.cs
index 54c866d..7db5f07 100644
--- a/Models/BookmarkItemViewModel.cs
+++ b/Models/BookmarkItemViewModel.cs
@@ -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();
}
diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs
index e213eac..5a6e873 100644
--- a/Windows/Forms/BookmarkTreeView.cs
+++ b/Windows/Forms/BookmarkTreeView.cs
@@ -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,234 +852,27 @@ 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;
- }
+ //public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel)
+ //{
+ // if (treeNode == null)
+ // {
+ // return;
+ // }
- int iconIndex = addIcon(viewModel);
+ // int iconIndex = addIcon(viewModel);
- treeNode.Text = viewModel.SiteName;
- treeNode.ImageIndex = iconIndex;
- treeNode.SelectedImageIndex = iconIndex;
- treeNode.Tag = viewModel;
- treeNode.ToolTipText = viewModel.ToString();
+ // treeNode.Text = viewModel.SiteName;
+ // treeNode.ImageIndex = iconIndex;
+ // treeNode.SelectedImageIndex = iconIndex;
+ // treeNode.Tag = viewModel;
+ // treeNode.ToolTipText = viewModel.ToString();
- this.HasChanged = true;
- }
+ // 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)
- //{
- // 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 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)
{