From 35eb3a92aee4471387593bc6a5236c4765778fa8 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 18 Apr 2019 21:04:58 +0100 Subject: [PATCH] WIP: rebuild context menu functionality --- .gitignore | 3 +- BookmarkEditForm.Designer.cs | 387 ++++++----- BookmarkEditForm.cs | 243 ++++--- BookmarkEditForm.resx | 27 +- BookmarkItem.cs | 26 +- BookmarkTreeView.cs | 198 ------ MainForm.Designer.cs | 403 ++++++------ MainForm.cs | 378 +++++++---- MainForm.resx | 57 +- RyzStudio/Drawing/Rectangoid.cs | 184 ++++-- .../Forms/HorizontalSeparator.Designer.cs | 37 ++ .../Windows/Forms/HorizontalSeparator.cs | 25 + RyzStudio/Windows/ThemedForms/Button.cs | 104 +++ .../Windows/ThemedForms/Button.designer.cs | 61 ++ RyzStudio/Windows/ThemedForms/Button.resx | 120 ++++ RyzStudio/Windows/ThemedForms/ButtonState.cs | 9 + RyzStudio/Windows/ThemedForms/ButtonStyle.cs | 25 + .../Windows/ThemedForms/Form.Designer.cs | 52 ++ RyzStudio/Windows/ThemedForms/Form.cs | 186 ++++++ RyzStudio/Windows/ThemedForms/Form.resx | 120 ++++ RyzStudio/Windows/ThemedForms/MemoBox.cs | 58 ++ .../Windows/ThemedForms/MemoBox.designer.cs | 63 ++ RyzStudio/Windows/ThemedForms/MemoBox.resx | 120 ++++ .../ThemedForms/ProgressBar.Designer.cs | 72 ++ RyzStudio/Windows/ThemedForms/ProgressBar.cs | 29 + .../Windows/ThemedForms/ProgressBar.resx | 120 ++++ .../ThemedForms/ProgressBarInner.Designer.cs | 63 ++ .../Windows/ThemedForms/ProgressBarInner.cs | 197 ++++++ .../Windows/ThemedForms/ProgressBarInner.resx | 120 ++++ RyzStudio/Windows/ThemedForms/TextBox.cs | 58 ++ .../Windows/ThemedForms/TextBox.designer.cs | 60 ++ RyzStudio/Windows/ThemedForms/TextBox.resx | 120 ++++ RyzStudio/Windows/ThemedForms/ThemeStyle.cs | 34 + RyzStudio/Windows/ThemedForms/ThreadHelper.cs | 51 ++ RyzStudio/Windows/ThemedForms/UserControl.cs | 53 ++ .../ThemedForms/UserControl.designer.cs | 37 ++ .../Forms/BookmarkTreeView.cs | 618 +++++++++--------- .../Forms/BookmarkTreeViewSNode.cs | 90 ++- bomg.csproj | 80 ++- 39 files changed, 3377 insertions(+), 1311 deletions(-) create mode 100644 RyzStudio/Windows/Forms/HorizontalSeparator.Designer.cs create mode 100644 RyzStudio/Windows/Forms/HorizontalSeparator.cs create mode 100644 RyzStudio/Windows/ThemedForms/Button.cs create mode 100644 RyzStudio/Windows/ThemedForms/Button.designer.cs create mode 100644 RyzStudio/Windows/ThemedForms/Button.resx create mode 100644 RyzStudio/Windows/ThemedForms/ButtonState.cs create mode 100644 RyzStudio/Windows/ThemedForms/ButtonStyle.cs create mode 100644 RyzStudio/Windows/ThemedForms/Form.Designer.cs create mode 100644 RyzStudio/Windows/ThemedForms/Form.cs create mode 100644 RyzStudio/Windows/ThemedForms/Form.resx create mode 100644 RyzStudio/Windows/ThemedForms/MemoBox.cs create mode 100644 RyzStudio/Windows/ThemedForms/MemoBox.designer.cs create mode 100644 RyzStudio/Windows/ThemedForms/MemoBox.resx create mode 100644 RyzStudio/Windows/ThemedForms/ProgressBar.Designer.cs create mode 100644 RyzStudio/Windows/ThemedForms/ProgressBar.cs create mode 100644 RyzStudio/Windows/ThemedForms/ProgressBar.resx create mode 100644 RyzStudio/Windows/ThemedForms/ProgressBarInner.Designer.cs create mode 100644 RyzStudio/Windows/ThemedForms/ProgressBarInner.cs create mode 100644 RyzStudio/Windows/ThemedForms/ProgressBarInner.resx create mode 100644 RyzStudio/Windows/ThemedForms/TextBox.cs create mode 100644 RyzStudio/Windows/ThemedForms/TextBox.designer.cs create mode 100644 RyzStudio/Windows/ThemedForms/TextBox.resx create mode 100644 RyzStudio/Windows/ThemedForms/ThemeStyle.cs create mode 100644 RyzStudio/Windows/ThemedForms/ThreadHelper.cs create mode 100644 RyzStudio/Windows/ThemedForms/UserControl.cs create mode 100644 RyzStudio/Windows/ThemedForms/UserControl.designer.cs rename RyzStudio/Windows/Forms/MovableTreeView.cs => Windows/Forms/BookmarkTreeView.cs (55%) rename RyzStudio/Windows/Forms/MovableTreeViewSelectedNode.cs => Windows/Forms/BookmarkTreeViewSNode.cs (67%) diff --git a/.gitignore b/.gitignore index be8a03f..8198594 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -/skye.sln /bomg.csproj.user /bin /obj /packages -/.vs/skye/v14/*.suo +/.vs diff --git a/BookmarkEditForm.Designer.cs b/BookmarkEditForm.Designer.cs index 8ad9413..f9c7c92 100644 --- a/BookmarkEditForm.Designer.cs +++ b/BookmarkEditForm.Designer.cs @@ -28,197 +28,224 @@ namespace bzit.bomg /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BookmarkEditForm)); - this.label1 = new System.Windows.Forms.Label(); - this.tbxAddress = new System.Windows.Forms.TextBox(); - this.tbxName = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.tbxDescription = new System.Windows.Forms.TextBox(); - this.oToolTip = new System.Windows.Forms.ToolTip(this.components); - this.label3 = new System.Windows.Forms.Label(); - this.pbxIcon = new System.Windows.Forms.PictureBox(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.button1 = new RyzStudio.Windows.Forms.BigButton(); - this.btnSave = new RyzStudio.Windows.Forms.BigButton(); - ((System.ComponentModel.ISupportInitialize)(this.pbxIcon)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 12); - this.label1.Margin = new System.Windows.Forms.Padding(3); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(39, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Name:"; - // - // tbxAddress - // - this.tbxAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.components = new System.ComponentModel.Container(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.label3 = new System.Windows.Forms.Label(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button2 = new RyzStudio.Windows.ThemedForms.Button(); + this.button1 = new RyzStudio.Windows.ThemedForms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator(); + this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox(); + this.textBox2 = new RyzStudio.Windows.ThemedForms.TextBox(); + this.memoBox1 = new RyzStudio.Windows.ThemedForms.MemoBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 25); + this.label1.Margin = new System.Windows.Forms.Padding(3); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(28, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Title"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 69); + this.label2.Margin = new System.Windows.Forms.Padding(3); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(48, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Address"; + // + // toolTip1 + // + this.toolTip1.Active = false; + this.toolTip1.BackColor = System.Drawing.Color.IndianRed; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 113); + this.label3.Margin = new System.Windows.Forms.Padding(3); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(66, 13); + this.label3.TabIndex = 55; + this.label3.Text = "Description"; + // + // pictureBox2 + // + this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox2.BackColor = System.Drawing.SystemColors.Window; + this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.pictureBox2.ErrorImage = null; + this.pictureBox2.InitialImage = null; + this.pictureBox2.Location = new System.Drawing.Point(368, 15); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(32, 32); + this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.pictureBox2.TabIndex = 57; + this.pictureBox2.TabStop = false; + // + // pictureBox1 + // + this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox1.BackColor = System.Drawing.Color.Transparent; + this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.pictureBox1.ErrorImage = null; + this.pictureBox1.InitialImage = null; + this.pictureBox1.Location = new System.Drawing.Point(287, 237); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(32, 32); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.pictureBox1.TabIndex = 60; + this.pictureBox1.TabStop = false; + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.BackColor = System.Drawing.Color.Transparent; + this.button2.DefaultImage = null; + this.button2.DownImage = null; + this.button2.LabelText = "&Save"; + this.button2.Location = new System.Drawing.Point(325, 237); + this.button2.Name = "button2"; + this.button2.OverImage = null; + this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.button2.Size = new System.Drawing.Size(107, 32); + this.button2.TabIndex = 4; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackColor = System.Drawing.Color.Transparent; + this.button1.DefaultImage = null; + this.button1.DownImage = null; + this.button1.LabelText = "S&can"; + this.button1.Location = new System.Drawing.Point(368, 59); + 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(64, 32); + this.button1.TabIndex = 2; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.tbxAddress.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - this.tbxAddress.Location = new System.Drawing.Point(12, 78); - this.tbxAddress.MaxLength = 4096; - this.tbxAddress.Name = "tbxAddress"; - this.tbxAddress.Size = new System.Drawing.Size(240, 22); - this.tbxAddress.TabIndex = 1; - this.tbxAddress.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown); - // - // tbxName - // - this.tbxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.label5.ForeColor = System.Drawing.Color.OrangeRed; + this.label5.Location = new System.Drawing.Point(9, 237); + this.label5.Margin = new System.Windows.Forms.Padding(3); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(272, 32); + this.label5.TabIndex = 64; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // horizontalSeparator1 + // + this.horizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.tbxName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - this.tbxName.Location = new System.Drawing.Point(12, 31); - this.tbxName.MaxLength = 4096; - this.tbxName.Name = "tbxName"; - this.tbxName.Size = new System.Drawing.Size(212, 22); - this.tbxName.TabIndex = 0; - this.tbxName.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 59); - this.label2.Margin = new System.Windows.Forms.Padding(3); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(51, 13); - this.label2.TabIndex = 4; - this.label2.Text = "Address:"; - // - // tbxDescription - // - this.tbxDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.horizontalSeparator1.Location = new System.Drawing.Point(12, 222); + this.horizontalSeparator1.Margin = new System.Windows.Forms.Padding(3, 10, 3, 10); + this.horizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2); + this.horizontalSeparator1.Name = "horizontalSeparator1"; + this.horizontalSeparator1.Size = new System.Drawing.Size(420, 2); + this.horizontalSeparator1.TabIndex = 65; + // + // textBox1 + // + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.tbxDescription.BackColor = System.Drawing.SystemColors.Window; - this.tbxDescription.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - this.tbxDescription.Location = new System.Drawing.Point(12, 125); - this.tbxDescription.MaxLength = 4096; - this.tbxDescription.Multiline = true; - this.tbxDescription.Name = "tbxDescription"; - this.tbxDescription.Size = new System.Drawing.Size(240, 84); - this.tbxDescription.TabIndex = 2; - this.tbxDescription.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown); - // - // oToolTip - // - this.oToolTip.Active = false; - this.oToolTip.BackColor = System.Drawing.Color.IndianRed; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(12, 106); - this.label3.Margin = new System.Windows.Forms.Padding(3); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(69, 13); - this.label3.TabIndex = 55; - this.label3.Text = "Description:"; - // - // pbxIcon - // - this.pbxIcon.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.pbxIcon.BackColor = System.Drawing.SystemColors.Window; - this.pbxIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pbxIcon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pbxIcon.ErrorImage = null; - this.pbxIcon.InitialImage = null; - this.pbxIcon.Location = new System.Drawing.Point(230, 31); - this.pbxIcon.Name = "pbxIcon"; - this.pbxIcon.Size = new System.Drawing.Size(22, 22); - this.pbxIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - this.pbxIcon.TabIndex = 57; - this.pbxIcon.TabStop = false; - // - // pictureBox1 - // - this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.pictureBox1.BackColor = System.Drawing.Color.Transparent; - this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pictureBox1.ErrorImage = null; - this.pictureBox1.InitialImage = null; - this.pictureBox1.Location = new System.Drawing.Point(12, 227); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(32, 32); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - this.pictureBox1.TabIndex = 60; - this.pictureBox1.TabStop = false; - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.BackColor = System.Drawing.Color.WhiteSmoke; - this.button1.Location = new System.Drawing.Point(118, 227); - this.button1.MaximumSize = new System.Drawing.Size(120, 32); - this.button1.MinimumSize = new System.Drawing.Size(32, 32); - this.button1.Name = "button1"; - this.button1.Padding = new System.Windows.Forms.Padding(4); - this.button1.Size = new System.Drawing.Size(32, 32); - this.button1.TabIndex = 3; - this.button1.Value = ""; - this.button1.Click += new System.EventHandler(this.btnRetrievePage_Click); - // - // btnSave - // - this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnSave.BackColor = System.Drawing.Color.WhiteSmoke; - this.btnSave.Location = new System.Drawing.Point(156, 227); - this.btnSave.MaximumSize = new System.Drawing.Size(120, 32); - this.btnSave.MinimumSize = new System.Drawing.Size(32, 32); - this.btnSave.Name = "btnSave"; - this.btnSave.Padding = new System.Windows.Forms.Padding(4); - this.btnSave.Size = new System.Drawing.Size(96, 32); - this.btnSave.TabIndex = 4; - this.btnSave.Value = "&OK"; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); - // - // BookmarkEditForm - // - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(264, 271); - this.Controls.Add(this.button1); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.pbxIcon); - this.Controls.Add(this.tbxDescription); - this.Controls.Add(this.label3); - this.Controls.Add(this.tbxName); - this.Controls.Add(this.label1); - this.Controls.Add(this.tbxAddress); - this.Controls.Add(this.btnSave); - this.Controls.Add(this.label2); - this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "BookmarkEditForm"; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit Bookmark"; - ((System.ComponentModel.ISupportInitialize)(this.pbxIcon)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + this.textBox1.BackColor = System.Drawing.Color.Transparent; + this.textBox1.Location = new System.Drawing.Point(96, 15); + this.textBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); + this.textBox1.Name = "textBox1"; + this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9); + this.textBox1.Size = new System.Drawing.Size(259, 32); + this.textBox1.TabIndex = 66; + // + // 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.Location = new System.Drawing.Point(96, 59); + 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(259, 32); + this.textBox2.TabIndex = 67; + // + // memoBox1 + // + this.memoBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.memoBox1.BackColor = System.Drawing.Color.Transparent; + this.memoBox1.Location = new System.Drawing.Point(96, 103); + this.memoBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); + this.memoBox1.Name = "memoBox1"; + this.memoBox1.Padding = new System.Windows.Forms.Padding(10, 10, 3, 9); + this.memoBox1.Size = new System.Drawing.Size(336, 103); + this.memoBox1.TabIndex = 69; + // + // BookmarkEditForm + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(444, 281); + this.Controls.Add(this.memoBox1); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.horizontalSeparator1); + this.Controls.Add(this.label5); + this.Controls.Add(this.button1); + this.Controls.Add(this.button2); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.pictureBox2); + this.Controls.Add(this.label3); + this.Controls.Add(this.label1); + this.Controls.Add(this.label2); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "BookmarkEditForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Edit Bookmark"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox tbxAddress; - private System.Windows.Forms.TextBox tbxName; private System.Windows.Forms.Label label2; - private System.Windows.Forms.TextBox tbxDescription; - private System.Windows.Forms.ToolTip oToolTip; - private RyzStudio.Windows.Forms.BigButton btnSave; + private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.Label label3; - private System.Windows.Forms.PictureBox pbxIcon; + private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox1; - private RyzStudio.Windows.Forms.BigButton button1; + private RyzStudio.Windows.ThemedForms.Button button2; + private RyzStudio.Windows.ThemedForms.Button button1; + private System.Windows.Forms.Label label5; + private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1; + private RyzStudio.Windows.ThemedForms.TextBox textBox1; + private RyzStudio.Windows.ThemedForms.TextBox textBox2; + private RyzStudio.Windows.ThemedForms.MemoBox memoBox1; } } \ No newline at end of file diff --git a/BookmarkEditForm.cs b/BookmarkEditForm.cs index 133fc99..a3bd390 100644 --- a/BookmarkEditForm.cs +++ b/BookmarkEditForm.cs @@ -1,192 +1,225 @@ +using bzit.bomg.Models; +using RyzStudio.Windows.Forms; +using RyzStudio.Windows.ThemedForms; using System; using System.ComponentModel; using System.Windows.Forms; +using Form = System.Windows.Forms.Form; +using Resources = bzit.bomg.Properties.Resources; namespace bzit.bomg { public partial class BookmarkEditForm : Form { - private TreeNode parentNode = null; - private BookmarkItem bookmarkItem; - private bool isWorking = false; + protected BackgroundWorker threadWorker1 = null; - public BookmarkEditForm(ref TreeNode node) + protected BookmarkItemModel itemModel = null; + protected BookmarkTreeView treeView = null; + //protected TreeNode treeNode = null; + + //public BookmarkEditForm(ref TreeNode node) : base() + public BookmarkEditForm(BookmarkTreeView treeview) : base() { InitializeComponent(); - parentNode = node; + treeView = treeview; + + //treeNode = node; this.StartPosition = FormStartPosition.WindowsDefaultLocation; + + if (threadWorker1 == null) + { + threadWorker1 = new BackgroundWorker(); + threadWorker1.WorkerReportsProgress = threadWorker1.WorkerSupportsCancellation = true; + threadWorker1.DoWork += threadWorker1_DoWork; + threadWorker1.RunWorkerCompleted += threadWorker1_RunWorkerCompleted; + } } - protected override void OnLoad(EventArgs e) + protected void threadWorker1_DoWork(object sender, DoWorkEventArgs e) { - base.OnLoad(e); + if (itemModel == null) + { + itemModel = new BookmarkItemModel(); + } - button1.Button.Image = Properties.Resources.magnifier; + itemModel.SiteAddress = textBox2.Text; + + bool rv = itemModel.Update(); + if (rv) + { + ThreadHelper.SetText(textBox1, itemModel.SiteName); + ThreadHelper.SetText(textBox2, itemModel.SiteAddress); + ThreadHelper.SetText(memoBox1, itemModel.SiteDescription); + ThreadHelper.SetImage(pictureBox2, itemModel.RetrieveFavicon()); + } + } + + protected void threadWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + this.IsBusy = false; } protected override void OnShown(EventArgs e) { base.OnShown(e); - if (parentNode.Tag != null) + if (treeView.SNode.GetNodeType() == BookmarkTreeView.NodeType.Page) { - if (parentNode.Tag is BookmarkItem) + BookmarkItemViewModel bookmarkItem = (BookmarkItemViewModel)treeView.SelectedNode.Tag; + if (bookmarkItem != null) { - bookmarkItem = (BookmarkItem)parentNode.Tag; - tbxName.Text = bookmarkItem.GetName(); - tbxAddress.Text = bookmarkItem.SiteAddress; - tbxDescription.Text = bookmarkItem.Description; - - if (parentNode.TreeView.ImageList != null) + if (itemModel == null) { - if (parentNode.ImageIndex >= 0) - { - pbxIcon.Image = parentNode.TreeView.ImageList.Images[parentNode.ImageIndex]; - } - else - { - pbxIcon.Image = parentNode.TreeView.ImageList.Images[parentNode.ImageKey]; - } + itemModel = new BookmarkItemModel(); } + + updateViewModel(bookmarkItem); } } + + + //if (parentNode.Tag != null) + //{ + // if (parentNode.Tag is BookmarkItem) + // { + // bookmarkItem = (BookmarkItem)parentNode.Tag; + // tbxName.Text = bookmarkItem.GetName(); + // tbxAddress.Text = bookmarkItem.SiteAddress; + // tbxDescription.Text = bookmarkItem.Description; + + // if (parentNode.TreeView.ImageList != null) + // { + // if (parentNode.ImageIndex >= 0) + // { + // pbxIcon.Image = parentNode.TreeView.ImageList.Images[parentNode.ImageIndex]; + // } + // else + // { + // pbxIcon.Image = parentNode.TreeView.ImageList.Images[parentNode.ImageKey]; + // } + // } + // } + //} } protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); - if (this.IsWorking) + if (this.IsBusy) { e.Cancel = true; } } - public bool IsWorking + protected bool IsBusy { - get { return isWorking; } + get => threadWorker1.IsBusy; set { - isWorking = value; + textBox1.Enabled = textBox2.Enabled = memoBox1.Enabled = !value; - tbxName.Enabled = tbxAddress.Enabled = tbxDescription.Enabled = !value; - btnSave.Enabled = !value; - button1.Enabled = !value; - - pictureBox1.Image = (value) ? Properties.Resources.aniZomq2x32 : null; + pictureBox1.Image = (value) ? Resources.aniZomq2x32 : null; } } - private void textBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + protected void updateViewModel(BookmarkItemViewModel viewModel) { - if (this.IsWorking) - { - return; - } + itemModel.SiteName = viewModel.SiteName?.Trim(); + itemModel.SiteAddress = viewModel.SiteAddress?.Trim(); + itemModel.SiteDescription = viewModel.SiteDescription?.Trim(); + itemModel.FaviconAddress = viewModel.FaviconAddress?.Trim(); - if (e.KeyCode == Keys.Escape) - { - this.Close(); - } + textBox1.Text = itemModel.SiteName; + textBox2.Text = itemModel.SiteAddress; + memoBox1.Text = itemModel.SiteDescription; + pictureBox2.Image = treeView.ImageList.Images[treeView.SelectedNode.ImageIndex]; } - private void btnRetrievePage_Click(object sender, EventArgs e) + private void button1_Click(object sender, EventArgs e) { - if (this.IsWorking) + if (this.IsBusy) { return; } - if (string.IsNullOrWhiteSpace(tbxAddress.Text)) + if (string.IsNullOrWhiteSpace(textBox2.Text)) { return; } - this.IsWorking = true; - oToolTip.SetToolTip(pictureBox1, ""); + this.IsBusy = true; - BookmarkItem bi = new BookmarkItem(); - bi.OnRetrieveCompleted += bookmarkItem_OnRetrieveCompleted; - bi.RetrieveAsync(tbxAddress.Text.Trim()); + threadWorker1.RunWorkerAsync(); } - private void btnSave_Click(object sender, EventArgs e) + private void button2_Click(object sender, EventArgs e) { - if (this.IsWorking) + if (this.IsBusy) { return; } - if (bookmarkItem == null) + if (itemModel == null) { - bookmarkItem = new BookmarkItem(); + itemModel = new BookmarkItemModel(); } - bookmarkItem.ChangeName(tbxName.Text.Trim()); - bookmarkItem.SiteAddress = tbxAddress.Text.Trim(); - bookmarkItem.Description = tbxDescription.Text.Trim(); + itemModel.SiteName = textBox1.Text?.Trim(); + itemModel.SiteAddress = textBox2.Text?.Trim(); + itemModel.SiteDescription = memoBox1.Text?.Trim(); - parentNode.Text = tbxName.Text.Trim(); -//// parentNode.ImageIndex = parentNode.SelectedImageIndex = 3; - parentNode.ToolTipText = string.Concat(bookmarkItem.SiteAddress, Environment.NewLine, bookmarkItem.Description).Trim(); - parentNode.Tag = bookmarkItem; - - BookmarkTreeView bookmarkTreeView = (BookmarkTreeView)parentNode.TreeView; - if (bookmarkTreeView != null) - { - //##parentNode.ImageIndex = parentNode.SelectedImageIndex = bookmarkTreeView.AddToIconList(bookmarkItem); - } + treeView?.AddOrUpdateItem_OnSelectedNode(itemModel.ToViewModel()); this.Close(); } - protected void bookmarkItem_OnRetrieveCompleted(BookmarkItem sender, bool hasError, string message) - { - if (string.IsNullOrEmpty(sender.SiteName)) - { - if (MessageBox.Show("The page could not be retrieved or the title is blank. Do you want to keep your original title?", "Keep original?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) - { - bookmarkItem.SiteName = sender.SiteName; - tbxName.Text = bookmarkItem.SiteName; - // don't replace with blank - if (!string.IsNullOrEmpty(sender.Description)) - { - bookmarkItem.Description = sender.Description; - } - } - } - else - { - bookmarkItem.SiteName = sender.SiteName; - tbxName.Text = bookmarkItem.SiteName; + // private void btnSave_Click(object sender, EventArgs e) + // { + // if (this.IsBusy) + // { + // return; + // } - // don't replace with blank - if (!string.IsNullOrEmpty(sender.Description)) - { - bookmarkItem.Description = sender.Description; - } - } + // if (itemModel == null) + // { + // itemModel = new BookmarkItemModel(); + // } - // don't replace with blank - if (sender.IconData != null) - { - bookmarkItem.IconData = sender.IconData; - } + // itemModel.SiteName = textBox1.Text?.Trim(); + // itemModel.SiteAddress = textBox2.Text?.Trim(); + // itemModel.SiteDescription = memoBox1.Text?.Trim(); - tbxDescription.Text = bookmarkItem.Description; - pbxIcon.Image = (bookmarkItem.Icon == null) ? parentNode.TreeView.ImageList.Images[3] : bookmarkItem.Icon; + // treeView?.AddOrUpdateItem_OnSelectedNode(itemModel.ToViewModel()); + + //// if (bookmarkItem == null) + //// { + //// bookmarkItem = new BookmarkItem(); + //// } + + //// bookmarkItem.ChangeName(textBox1.Text.Trim()); + //// bookmarkItem.SiteAddress = textBox2.Text.Trim(); + //// bookmarkItem.Description = memoBox1.Text.Trim(); + + //// parentNode.Text = textBox1.Text.Trim(); + //////// parentNode.ImageIndex = parentNode.SelectedImageIndex = 3; + //// parentNode.ToolTipText = string.Concat(bookmarkItem.SiteAddress, Environment.NewLine, bookmarkItem.Description).Trim(); + //// parentNode.Tag = bookmarkItem; + + //// BookmarkTreeView bookmarkTreeView = (BookmarkTreeView)parentNode.TreeView; + //// if (bookmarkTreeView != null) + //// { + //// //##parentNode.ImageIndex = parentNode.SelectedImageIndex = bookmarkTreeView.AddToIconList(bookmarkItem); + //// } + + // this.Close(); + // } - if (hasError) - { - oToolTip.SetToolTip(pictureBox1, message); - } - this.IsWorking = false; - } } } \ No newline at end of file diff --git a/BookmarkEditForm.resx b/BookmarkEditForm.resx index 3b96111..9d9bc4d 100644 --- a/BookmarkEditForm.resx +++ b/BookmarkEditForm.resx @@ -117,32 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - - - - AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAHQAAADQAAAA2AAAANgAAADYAAAA2AAAANgAAADYAAAA2AAAANgAAADYAAAA2AAAAMwAA - AB0AAAAAAAAAAAAAADT5+fn1/Pz8/fz8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8/fn5 - +fMAAAAzAAAAAAAAAAEAAAA2/Pz8/vz8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8 - /P/8/Pz9AAAANgAAAAAAAAABAAAANvz8/P/8/Pz/F0JZ/ypgiP9Lib3/bqfL/+Dp8f/7+/v/+/v7//v7 - +//7+/v//Pz8/wAAADYAAAABAAAAAQAAADb8/Pz//Pz8/y1mhP+Tx/n/kMn5/0CEyf8laq3/1OLu//r6 - +v/6+vr/+vr6//z8/P8AAAA2AAAAAQAAAAEAAAA2/Pz8//z8/P9CiKn/4PL//1OZ2P8Zeb3/SJfE/0eN - x//Y5vP/+Pj4//j4+P/8/Pz/AAAANgAAAAEAAAABAAAANvz8/P/8/Pz/pMLX/3m11f+PttH/VMnk/1rf - 9f930O3/UJzd/9/r9f/4+Pj//Pz8/wAAADYAAAABAAAAAQAAADb8/Pz//Pz8//z8/P+x1eX/dbnX/8H2 - /f9i3/f/XOL4/3jT8P9Il9z/3uny//z8/P8AAAA2AAAAAQAAAAEAAAA2/Pz8//z8/P/8/Pz//Pz8/67U - 5f92y+f/x/f9/13c9f9Z4ff/etTx/0qZ3f/U5fX/AAAANgAAAAEAAAABAAAANvz8/P/8/Pz//Pz8//z8 - /P/8/Pz/vOXy/3jT7v/H9/3/Xtz1/1ri9/951vL/UKHi/yJJalwAAAABAAAAAQAAADb8/Pz/+/v7//z8 - /P/8/Pz/+/v7//j4+P+54/D/fNTu/8P2/f9r3fb/bMrt/2Ki1/9bmM/wTo3DJwAAAAEAAAA2/Pz8//n5 - +f/5+fn/+fn5//f39//29vb/8vLy/6fZ6P+A1u7/seP5/4q/5/+t0/b/w+D8/2We0/cAAAABAAAANvz8 - /P/39/f/+fn5//f39//39/f/8/Pz//Dw8P/q6ur/ruTz/3a95/+z0vD/5fP//6vS7/9Hi8foAAAAAAAA - ADb7+/v99PT0//X19f/19fX/9fX1//Hx8f/v7+//6enp//z8/P+r1eT/V6TY/4Sw2/9FnND/KpTRXgAA - AAAAAAAz+Pj48Pv7+/38/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/4+Pj/k5OTkQAAACAAAAACAAAAAAAA - AAAAAAAAAAAAHAAAADMAAAA2AAAANgAAADYAAAA2AAAANgAAADYAAAA2AAAANgAAACAAAAACAAAAAAAA - AAAAAAAAgAGsQYABrEEAAaxBAACsQQAArEEAAKxBAACsQQAArEEAAKxBAACsQQAArEEAAKxBAACsQYAA - rEGAA6xBgAesQQ== - - \ No newline at end of file diff --git a/BookmarkItem.cs b/BookmarkItem.cs index dcd6993..6ac6e70 100644 --- a/BookmarkItem.cs +++ b/BookmarkItem.cs @@ -20,17 +20,17 @@ namespace bzit.bomg public byte[] IconData { get; set; } = null; public string SiteName { get; set; } = null; - public string SiteAddress { get; set; } + public string SiteAddress { get; set; } public string Description { get; set; } - public string IconAddress { get; protected set; } + public string IconAddress { get; set; } public string Fullpath { get; set; } - public string Created { get; set; } + public string Created { get; set; } protected const char pathSeparator = '|'; //protected TreeNode treeNode = null; protected BackgroundWorker mainThread = null; - + protected bool hasRetrieveError = false; protected string retrieveErrorMessage = null; @@ -46,13 +46,13 @@ namespace bzit.bomg rv += "Address=" + this.SiteAddress + Environment.NewLine; rv += "Description=" + this.Description + Environment.NewLine; rv += "Created=" + this.Created?.Trim(); - + return rv; } #region public properties - + //{ // get // { @@ -64,7 +64,7 @@ namespace bzit.bomg // this.treeNode = value; // } //} - + public Bitmap Icon { get @@ -87,7 +87,7 @@ namespace bzit.bomg } - + #endregion #region public methods @@ -107,7 +107,7 @@ namespace bzit.bomg this.mainThread.RunWorkerCompleted += retrieveWorker_RunWorkerCompleted; } } - + public string GetName() { if (this.Fullpath.Contains(pathSeparator.ToString())) @@ -226,7 +226,7 @@ namespace bzit.bomg // } // } - // // load icon image + // // load icon image // if (!string.IsNullOrEmpty(this.IconAddress)) // { // try @@ -246,7 +246,7 @@ namespace bzit.bomg } public void RetrieveAsync() - { + { if (this.mainThread.IsBusy) { return; @@ -279,7 +279,7 @@ namespace bzit.bomg this.Description = string.Empty; this.IconAddress = string.Empty; - WebClient webClient = new WebClient(); + WebClient webClient = new WebClient(); webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); string sourceCode = string.Empty; @@ -404,7 +404,7 @@ namespace bzit.bomg return System.Web.HttpUtility.HtmlDecode(hn.Attributes[attr].Value?.Trim()); } - + return defaultValue; } diff --git a/BookmarkTreeView.cs b/BookmarkTreeView.cs index ba4819f..85fae29 100644 --- a/BookmarkTreeView.cs +++ b/BookmarkTreeView.cs @@ -9,211 +9,13 @@ namespace bzit.bomg { public partial class BookmarkTreeView : RyzStudio.Windows.Forms.MovableTreeView { - protected IconDatabase iconDatabase = null; public BookmarkTreeView() { InitializeComponent(); - if (this.ImageList == null) - { - this.ImageList = new ImageList(); - } - - this.ImageList.ColorDepth = ColorDepth.Depth16Bit; - this.ImageList.ImageSize = new Size(16, 16); - this.ImageList.TransparentColor = Color.Transparent; - - this.ImageList.Images.Clear(); - this.ImageList.Images.Add(Properties.Resources.transmit_blue); - this.ImageList.Images.Add(Properties.Resources.folder); - this.ImageList.Images.Add(Properties.Resources.folder_explore); - this.ImageList.Images.Add(Properties.Resources.page_white_world_bw); } - [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new ImageList ImageList { get => base.ImageList; set => base.ImageList = value; } - protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e) - { - base.OnPreviewKeyDown(e); - - TreeNode tn = this.SelectedNode; - if (tn == null) - { - return; - } - - switch (e.KeyCode) - { - case Keys.Insert: - if (e.Modifiers == Keys.Shift) - { - // do nothing - } - else - { - MessageBox.Show("!"); - //AddBookmarkPage(); - } - - break; - - default: break; - } - } - - public bool InitialiseIconDatabase(out string message, string filename) - { - message = string.Empty; - - if (string.IsNullOrWhiteSpace(filename)) - { - return false; - } - - if (iconDatabase == null) - { - iconDatabase = new IconDatabase(); - } - - bool rv = false; - if (File.Exists(filename)) - { - rv = iconDatabase.LoadFile(filename); - if (!rv) - { - rv = iconDatabase.Create(filename, true, null, true); - if (!rv) - { - message = iconDatabase.LastError; - return false; - } - } - } - else - { - rv = iconDatabase.Create(filename, true, null, true); - if (!rv) - { - message = iconDatabase.LastError; - return false; - } - } - - return true; - } - - public void AddItem(BookmarkItemViewModel viewModel) - { - int iconIndex = addIcon(viewModel); - - TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex); - tn.Tag = viewModel; - tn.ToolTipText = viewModel.ToString(); - - TreeNode tn2 = addFolderPath(viewModel.TreeviewPath); - - tn2.Nodes.Add(tn); - } - - public void AddItem_OnSelectedNode(BookmarkItemViewModel viewModel) - { - if (this.SelectedNode == null) - { - return; - } - - if (this.SelectedNode.Tag != null) - { - return; - } - - int iconIndex = addIcon(viewModel); - - TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex); - tn.Tag = viewModel; - tn.ToolTipText = viewModel.ToString(); - - int n = this.SelectedNode.Nodes.Add(tn); - - this.SelectedNode = this.SelectedNode.Nodes[n]; - } - - protected int addIcon(BookmarkItemViewModel viewModel) => addIcon(viewModel.ToModel()); - - protected int addIcon(BookmarkItemModel model) - { - if (this.ImageList.Images.ContainsKey(model.SiteAddress)) - { - return this.ImageList.Images.IndexOfKey(model.SiteAddress); - } - - if (iconDatabase.HasIcon(model.SiteAddress)) - { - Image rs = iconDatabase.GetIcon(model.SiteAddress); - if (rs == null) - { - return (int)IconSet.Default; - } - else - { - this.ImageList.Images.Add(model.SiteAddress, rs); - - return this.ImageList.Images.IndexOfKey(model.SiteAddress); - } - } - - Bitmap bmp = model.RetrieveFavicon(); - if (bmp == null) - { - return (int)IconSet.Default; - } - - this.ImageList.Images.Add(model.SiteAddress, bmp); - - return this.ImageList.Images.IndexOfKey(model.SiteAddress); - } - - protected TreeNode addFolderPath(string path) - { - TreeNode tn = this.Nodes[0]; - if (tn == null) - { - return tn; - } - - if (string.IsNullOrWhiteSpace(path)) - { - return tn; - } - - if (string.IsNullOrWhiteSpace(path.Trim('\\'))) - { - return tn; - } - - string[] folderList = path.Trim('\\').Split('\\'); - if (folderList.Length <= 0) - { - return tn; - } - - foreach (string item in folderList) - { - if (tn.Nodes.ContainsKey(item)) - { - // do nothing - } - else - { - tn.Nodes.Add(item, item, (int)IconSet.Folder1, (int)IconSet.Folder2); - } - - tn = tn.Nodes[item]; - } - - return tn; - } } } \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index ba16784..3b6f0a2 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -1,3 +1,5 @@ +using RyzStudio.Windows.Forms; + namespace bzit.bomg { partial class MainForm @@ -30,7 +32,7 @@ namespace bzit.bomg { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.treeMenuItem = new System.Windows.Forms.ContextMenuStrip(this.components); + this.pageTreeNodeMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem(); @@ -72,7 +74,7 @@ namespace bzit.bomg this.toolStripDropDownButton7 = new System.Windows.Forms.ToolStripDropDownButton(); this.alwaysOnTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.treeMenuFolder = new System.Windows.Forms.ContextMenuStrip(this.components); + this.folderTreeNodeMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItem15 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem16 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); @@ -90,27 +92,28 @@ namespace bzit.bomg this.openMenuBarItem = new System.Windows.Forms.ToolStripButton(); this.saveMenuBarItem = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); - this.treeMenuRoot = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.rootTreeNodeMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItem17 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem18 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem20 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem22 = new System.Windows.Forms.ToolStripMenuItem(); - this.treeView1 = new bzit.bomg.BookmarkTreeView(); - this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); - this.treeMenuItem.SuspendLayout(); + this.treeView1 = new RyzStudio.Windows.Forms.BookmarkTreeView(); + this.pageTreeNodeMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); this.toolStrip1.SuspendLayout(); - this.treeMenuFolder.SuspendLayout(); + this.folderTreeNodeMenu.SuspendLayout(); this.toolStrip2.SuspendLayout(); - this.treeMenuRoot.SuspendLayout(); + this.rootTreeNodeMenu.SuspendLayout(); this.SuspendLayout(); - // - // treeMenuItem - // - this.treeMenuItem.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + // + // pageTreeNodeMenu + // + this.pageTreeNodeMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem4, this.toolStripSeparator3, this.toolStripMenuItem8, @@ -118,56 +121,56 @@ namespace bzit.bomg this.toolStripSeparator2, this.listViewMenuItem1, this.moveFileToToolStripMenuItem}); - this.treeMenuItem.Name = "listViewMenu"; - this.treeMenuItem.Size = new System.Drawing.Size(139, 126); - // + this.pageTreeNodeMenu.Name = "listViewMenu"; + this.pageTreeNodeMenu.Size = new System.Drawing.Size(139, 126); + // // toolStripMenuItem4 - // + // this.toolStripMenuItem4.Name = "toolStripMenuItem4"; this.toolStripMenuItem4.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem4.Text = "&Open"; - this.toolStripMenuItem4.Click += new System.EventHandler(this.toolStripMenuItem4_Click); - // + this.toolStripMenuItem4.Click += new System.EventHandler(this.openContextMenu_Click); + // // toolStripSeparator3 - // + // this.toolStripSeparator3.Name = "toolStripSeparator3"; this.toolStripSeparator3.Size = new System.Drawing.Size(135, 6); - // + // // toolStripMenuItem8 - // + // this.toolStripMenuItem8.Name = "toolStripMenuItem8"; this.toolStripMenuItem8.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem8.Text = "E&dit"; - this.toolStripMenuItem8.Click += new System.EventHandler(this.toolStripMenuItem8_Click); - // + this.toolStripMenuItem8.Click += new System.EventHandler(this.editContextMenu3_Click); + // // toolStripMenuItem6 - // + // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; this.toolStripMenuItem6.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem6.Text = "D&elete"; - this.toolStripMenuItem6.Click += new System.EventHandler(this.toolStripMenuItem6_Click); - // + this.toolStripMenuItem6.Click += new System.EventHandler(this.deleteContextMenu2_Click); + // // toolStripSeparator2 - // + // this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new System.Drawing.Size(135, 6); - // + // // listViewMenuItem1 - // + // this.listViewMenuItem1.Name = "listViewMenuItem1"; this.listViewMenuItem1.Size = new System.Drawing.Size(138, 22); this.listViewMenuItem1.Text = "Move &Up"; - this.listViewMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem12_Click); - // + this.listViewMenuItem1.Click += new System.EventHandler(this.moveUpContextMenu2_Click); + // // moveFileToToolStripMenuItem - // + // this.moveFileToToolStripMenuItem.Name = "moveFileToToolStripMenuItem"; this.moveFileToToolStripMenuItem.Size = new System.Drawing.Size(138, 22); this.moveFileToToolStripMenuItem.Text = "Move &Down"; - this.moveFileToToolStripMenuItem.Click += new System.EventHandler(this.toolStripMenuItem13_Click); - // + this.moveFileToToolStripMenuItem.Click += new System.EventHandler(this.moveDownContextMenu2_Click); + // // statusBar1 - // + // this.statusBar1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.statusBar1.Location = new System.Drawing.Point(0, 634); this.statusBar1.Name = "statusBar1"; @@ -178,20 +181,20 @@ namespace bzit.bomg this.statusBar1.Size = new System.Drawing.Size(304, 20); this.statusBar1.SizingGrip = false; this.statusBar1.TabIndex = 9; - // + // // statusBarPanel1 - // + // this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; this.statusBarPanel1.Name = "statusBarPanel1"; this.statusBarPanel1.Width = 204; - // + // // statusBarPanel2 - // + // this.statusBarPanel2.Alignment = System.Windows.Forms.HorizontalAlignment.Center; this.statusBarPanel2.Name = "statusBarPanel2"; - // + // // imageList1 - // + // this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); this.imageList1.TransparentColor = System.Drawing.Color.Transparent; this.imageList1.Images.SetKeyName(0, "transmit_blue.png"); @@ -201,9 +204,9 @@ namespace bzit.bomg this.imageList1.Images.SetKeyName(4, "page.png"); this.imageList1.Images.SetKeyName(5, "page_green.png"); this.imageList1.Images.SetKeyName(6, "page_red.png"); - // + // // toolStrip1 - // + // this.toolStrip1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -220,9 +223,9 @@ namespace bzit.bomg this.toolStrip1.Size = new System.Drawing.Size(304, 25); this.toolStrip1.TabIndex = 25; this.toolStrip1.Text = "toolStrip1"; - // + // // toolStripDropDownButton1 - // + // this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.newFileMenuItem, @@ -241,89 +244,89 @@ namespace bzit.bomg this.toolStripDropDownButton1.ShowDropDownArrow = false; this.toolStripDropDownButton1.Size = new System.Drawing.Size(29, 22); this.toolStripDropDownButton1.Text = "&File"; - // + // // newFileMenuItem - // + // this.newFileMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("newFileMenuItem.Image"))); this.newFileMenuItem.Name = "newFileMenuItem"; this.newFileMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); this.newFileMenuItem.Size = new System.Drawing.Size(186, 22); this.newFileMenuItem.Text = "&New"; - this.newFileMenuItem.Click += new System.EventHandler(this.newSessionToolStripMenuItem_Click); - // + this.newFileMenuItem.Click += new System.EventHandler(this.newMenuItem_Click); + // // openFileMenuItem - // + // this.openFileMenuItem.Image = global::bzit.bomg.Properties.Resources.folder_page; this.openFileMenuItem.Name = "openFileMenuItem"; this.openFileMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); this.openFileMenuItem.Size = new System.Drawing.Size(186, 22); this.openFileMenuItem.Text = "&Open"; - this.openFileMenuItem.Click += new System.EventHandler(this.toolStripMenuItem2_Click); - // + this.openFileMenuItem.Click += new System.EventHandler(this.openMenuItem_Click); + // // toolStripSeparator1 - // + // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(183, 6); - // + // // closeFileMenuItem - // + // this.closeFileMenuItem.Name = "closeFileMenuItem"; this.closeFileMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W))); this.closeFileMenuItem.Size = new System.Drawing.Size(186, 22); this.closeFileMenuItem.Text = "&Close"; - this.closeFileMenuItem.Click += new System.EventHandler(this.toolStripMenuItem3_Click); - // + this.closeFileMenuItem.Click += new System.EventHandler(this.closeMenuItem_Click); + // // toolStripSeparator4 - // + // this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Size = new System.Drawing.Size(183, 6); - // + // // saveFileMenuItem - // + // this.saveFileMenuItem.Image = global::bzit.bomg.Properties.Resources.disk; this.saveFileMenuItem.Name = "saveFileMenuItem"; this.saveFileMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.saveFileMenuItem.Size = new System.Drawing.Size(186, 22); this.saveFileMenuItem.Text = "&Save"; this.saveFileMenuItem.Click += new System.EventHandler(this.importSnapshotToolStripMenuItem_Click); - // + // // saveAsFileMenuItem - // + // this.saveAsFileMenuItem.Image = global::bzit.bomg.Properties.Resources.page_white_disk; this.saveAsFileMenuItem.Name = "saveAsFileMenuItem"; - this.saveAsFileMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + this.saveAsFileMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.S))); this.saveAsFileMenuItem.Size = new System.Drawing.Size(186, 22); this.saveAsFileMenuItem.Text = "Save &As"; this.saveAsFileMenuItem.Click += new System.EventHandler(this.exportSnapshotToolStripMenuItem_Click); - // + // // toolStripSeparator8 - // + // this.toolStripSeparator8.Name = "toolStripSeparator8"; this.toolStripSeparator8.Size = new System.Drawing.Size(183, 6); - // + // // exportFileMenuItem - // + // this.exportFileMenuItem.Enabled = false; this.exportFileMenuItem.Name = "exportFileMenuItem"; this.exportFileMenuItem.Size = new System.Drawing.Size(186, 22); this.exportFileMenuItem.Text = "&Export"; this.exportFileMenuItem.Click += new System.EventHandler(this.toolStripMenuItem7_Click); - // + // // toolStripSeparator6 - // + // this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Size = new System.Drawing.Size(183, 6); - // + // // exitFileMenuItem - // + // this.exitFileMenuItem.Name = "exitFileMenuItem"; this.exitFileMenuItem.Size = new System.Drawing.Size(186, 22); this.exitFileMenuItem.Text = "E&xit"; - this.exitFileMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem1_Click); - // + this.exitFileMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click); + // // toolStripDropDownButton2 - // + // this.toolStripDropDownButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripDropDownButton2.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.findEditMenuItem}); @@ -332,18 +335,18 @@ namespace bzit.bomg this.toolStripDropDownButton2.ShowDropDownArrow = false; this.toolStripDropDownButton2.Size = new System.Drawing.Size(31, 22); this.toolStripDropDownButton2.Text = "&Edit"; - // + // // findEditMenuItem - // + // this.findEditMenuItem.Image = global::bzit.bomg.Properties.Resources.magnifier; this.findEditMenuItem.Name = "findEditMenuItem"; this.findEditMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); this.findEditMenuItem.Size = new System.Drawing.Size(137, 22); this.findEditMenuItem.Text = "&Find"; this.findEditMenuItem.Click += new System.EventHandler(this.toolStripButton5_Click); - // + // // toolStripDropDownButton3 - // + // this.toolStripDropDownButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripDropDownButton3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.expandAllViewMenuItem, @@ -353,25 +356,25 @@ namespace bzit.bomg this.toolStripDropDownButton3.ShowDropDownArrow = false; this.toolStripDropDownButton3.Size = new System.Drawing.Size(36, 22); this.toolStripDropDownButton3.Text = "&View"; - // + // // expandAllViewMenuItem - // + // this.expandAllViewMenuItem.Enabled = false; this.expandAllViewMenuItem.Name = "expandAllViewMenuItem"; this.expandAllViewMenuItem.Size = new System.Drawing.Size(136, 22); this.expandAllViewMenuItem.Text = "&Expand All"; this.expandAllViewMenuItem.Click += new System.EventHandler(this.expandAllToolStripMenuItem_Click); - // + // // collapseAllViewMenuItem - // + // this.collapseAllViewMenuItem.Enabled = false; this.collapseAllViewMenuItem.Name = "collapseAllViewMenuItem"; this.collapseAllViewMenuItem.Size = new System.Drawing.Size(136, 22); this.collapseAllViewMenuItem.Text = "&Collapse All"; this.collapseAllViewMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click); - // + // // toolStripDropDownButton4 - // + // this.toolStripDropDownButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripDropDownButton4.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.updateIconsToolMenuItem, @@ -382,21 +385,21 @@ namespace bzit.bomg this.toolStripDropDownButton4.ShowDropDownArrow = false; this.toolStripDropDownButton4.Size = new System.Drawing.Size(39, 22); this.toolStripDropDownButton4.Text = "&Tools"; - // + // // updateIconsToolMenuItem - // + // this.updateIconsToolMenuItem.Name = "updateIconsToolMenuItem"; this.updateIconsToolMenuItem.Size = new System.Drawing.Size(143, 22); this.updateIconsToolMenuItem.Text = "&Update Icons"; this.updateIconsToolMenuItem.Click += new System.EventHandler(this.toolStripMenuItem1_Click); - // + // // toolStripSeparator14 - // + // this.toolStripSeparator14.Name = "toolStripSeparator14"; this.toolStripSeparator14.Size = new System.Drawing.Size(140, 6); - // + // // optionsToolMenuItem - // + // this.optionsToolMenuItem.Enabled = false; this.optionsToolMenuItem.Image = global::bzit.bomg.Properties.Resources.cog; this.optionsToolMenuItem.Name = "optionsToolMenuItem"; @@ -404,9 +407,9 @@ namespace bzit.bomg this.optionsToolMenuItem.Size = new System.Drawing.Size(143, 22); this.optionsToolMenuItem.Text = "&Options"; this.optionsToolMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem1_Click); - // + // // toolStripDropDownButton5 - // + // this.toolStripDropDownButton5.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripDropDownButton5.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.viewHelpHelpMenuItem, @@ -417,31 +420,31 @@ namespace bzit.bomg this.toolStripDropDownButton5.ShowDropDownArrow = false; this.toolStripDropDownButton5.Size = new System.Drawing.Size(36, 22); this.toolStripDropDownButton5.Text = "&Help"; - // + // // viewHelpHelpMenuItem - // + // this.viewHelpHelpMenuItem.Image = global::bzit.bomg.Properties.Resources.help; this.viewHelpHelpMenuItem.Name = "viewHelpHelpMenuItem"; this.viewHelpHelpMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F1; this.viewHelpHelpMenuItem.Size = new System.Drawing.Size(146, 22); this.viewHelpHelpMenuItem.Text = "View &Help"; this.viewHelpHelpMenuItem.Click += new System.EventHandler(this.documentationToolStripMenuItem_Click); - // + // // toolStripSeparator12 - // + // this.toolStripSeparator12.Name = "toolStripSeparator12"; this.toolStripSeparator12.Size = new System.Drawing.Size(143, 6); - // + // // aboutHelpMenuItem - // + // this.aboutHelpMenuItem.Image = global::bzit.bomg.Properties.Resources.comment; this.aboutHelpMenuItem.Name = "aboutHelpMenuItem"; this.aboutHelpMenuItem.Size = new System.Drawing.Size(146, 22); this.aboutHelpMenuItem.Text = "&About"; this.aboutHelpMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem1_Click); - // + // // toolStripDropDownButton7 - // + // this.toolStripDropDownButton7.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripDropDownButton7.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.alwaysOnTopToolStripMenuItem}); @@ -451,24 +454,24 @@ namespace bzit.bomg this.toolStripDropDownButton7.Size = new System.Drawing.Size(16, 22); this.toolStripDropDownButton7.Text = "&?"; this.toolStripDropDownButton7.Visible = false; - // + // // alwaysOnTopToolStripMenuItem - // + // this.alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; this.alwaysOnTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F11))); this.alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.alwaysOnTopToolStripMenuItem.Text = "Always On Top"; this.alwaysOnTopToolStripMenuItem.Click += new System.EventHandler(this.alwaysOnTopToolStripMenuItem_Click); - // + // // openFileDialog - // + // this.openFileDialog.DefaultExt = "ryz"; this.openFileDialog.Filter = "Bookmarks files|*.ryz"; this.openFileDialog.Title = "Open bookmarks file"; - // - // treeMenuFolder - // - this.treeMenuFolder.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + // + // folderTreeNodeMenu + // + this.folderTreeNodeMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem15, this.toolStripMenuItem16, this.toolStripSeparator5, @@ -480,86 +483,88 @@ namespace bzit.bomg this.toolStripSeparator11, this.toolStripMenuItem12, this.toolStripMenuItem13}); - this.treeMenuFolder.Name = "listViewMenu"; - this.treeMenuFolder.Size = new System.Drawing.Size(139, 198); - // + this.folderTreeNodeMenu.Name = "listViewMenu"; + this.folderTreeNodeMenu.Size = new System.Drawing.Size(139, 198); + // // toolStripMenuItem15 - // + // this.toolStripMenuItem15.Name = "toolStripMenuItem15"; this.toolStripMenuItem15.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem15.Text = "Add &Page"; - // + this.toolStripMenuItem15.Click += new System.EventHandler(this.addPageContextMenu2_Click); + // // toolStripMenuItem16 - // + // this.toolStripMenuItem16.Name = "toolStripMenuItem16"; this.toolStripMenuItem16.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem16.Text = "Add &Folder"; - // + this.toolStripMenuItem16.Click += new System.EventHandler(this.addFolderContextMenu2_Click); + // // toolStripSeparator5 - // + // this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Size = new System.Drawing.Size(135, 6); - // + // // toolStripMenuItem14 - // + // this.toolStripMenuItem14.Name = "toolStripMenuItem14"; this.toolStripMenuItem14.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem14.Text = "&Open All"; - this.toolStripMenuItem14.Click += new System.EventHandler(this.toolStripMenuItem14_Click); - // + this.toolStripMenuItem14.Click += new System.EventHandler(this.openAllContextMenu_Click); + // // toolStripMenuItem9 - // + // this.toolStripMenuItem9.Name = "toolStripMenuItem9"; this.toolStripMenuItem9.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem9.Text = "Edi&t"; - this.toolStripMenuItem9.Click += new System.EventHandler(this.toolStripMenuItem9_Click); - // + this.toolStripMenuItem9.Click += new System.EventHandler(this.editContextMenu2_Click); + // // toolStripMenuItem11 - // + // this.toolStripMenuItem11.Name = "toolStripMenuItem11"; this.toolStripMenuItem11.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem11.Text = "D&elete"; - this.toolStripMenuItem11.Click += new System.EventHandler(this.toolStripMenuItem6_Click); - // + this.toolStripMenuItem11.Click += new System.EventHandler(this.deleteContextMenu_Click); + // // toolStripSeparator7 - // + // this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Size = new System.Drawing.Size(135, 6); - // + // // sortToolStripMenuItem - // + // this.sortToolStripMenuItem.Name = "sortToolStripMenuItem"; this.sortToolStripMenuItem.Size = new System.Drawing.Size(138, 22); this.sortToolStripMenuItem.Text = "&Sort"; - this.sortToolStripMenuItem.Click += new System.EventHandler(this.sortToolStripMenuItem_Click); - // + this.sortToolStripMenuItem.Click += new System.EventHandler(this.sortContextMenu2_Click); + // // toolStripSeparator11 - // + // this.toolStripSeparator11.Name = "toolStripSeparator11"; this.toolStripSeparator11.Size = new System.Drawing.Size(135, 6); - // + // // toolStripMenuItem12 - // + // this.toolStripMenuItem12.Name = "toolStripMenuItem12"; this.toolStripMenuItem12.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem12.Text = "Move &Up"; - this.toolStripMenuItem12.Click += new System.EventHandler(this.toolStripMenuItem12_Click); - // + this.toolStripMenuItem12.Click += new System.EventHandler(this.moveUpContextMenu_Click); + // // toolStripMenuItem13 - // + // this.toolStripMenuItem13.Name = "toolStripMenuItem13"; this.toolStripMenuItem13.Size = new System.Drawing.Size(138, 22); this.toolStripMenuItem13.Text = "Move &Down"; - this.toolStripMenuItem13.Click += new System.EventHandler(this.toolStripMenuItem13_Click); - // + this.toolStripMenuItem13.Click += new System.EventHandler(this.moveDownContextMenu_Click); + // // saveFileDialog - // + // this.saveFileDialog.DefaultExt = "ryz"; this.saveFileDialog.Filter = "Bookmarks file|*.ryz|Bookmarks file (password protected)|*.ryz"; this.saveFileDialog.Title = "Save bookmarks file"; - // + // // toolStrip2 - // + // this.toolStrip2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.toolStrip2.CanOverflow = false; this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -567,16 +572,17 @@ namespace bzit.bomg this.openMenuBarItem, this.saveMenuBarItem, this.toolStripSeparator9, - this.toolStripButton1}); + this.toolStripButton1, + this.toolStripButton2}); this.toolStrip2.Location = new System.Drawing.Point(0, 25); this.toolStrip2.Name = "toolStrip2"; this.toolStrip2.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; this.toolStrip2.Size = new System.Drawing.Size(304, 25); this.toolStrip2.TabIndex = 26; this.toolStrip2.Text = "toolStrip2"; - // + // // newMenuBarItem - // + // this.newMenuBarItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.newMenuBarItem.Image = ((System.Drawing.Image)(resources.GetObject("newMenuBarItem.Image"))); this.newMenuBarItem.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -584,10 +590,10 @@ namespace bzit.bomg this.newMenuBarItem.Size = new System.Drawing.Size(23, 22); this.newMenuBarItem.Text = "toolStripButton1"; this.newMenuBarItem.ToolTipText = "New"; - this.newMenuBarItem.Click += new System.EventHandler(this.newSessionToolStripMenuItem_Click); - // + this.newMenuBarItem.Click += new System.EventHandler(this.newMenuItem_Click); + // // openMenuBarItem - // + // this.openMenuBarItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.openMenuBarItem.Image = global::bzit.bomg.Properties.Resources.folder_page; this.openMenuBarItem.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -595,10 +601,10 @@ namespace bzit.bomg this.openMenuBarItem.Size = new System.Drawing.Size(23, 22); this.openMenuBarItem.Text = "toolStripButton2"; this.openMenuBarItem.ToolTipText = "Open"; - this.openMenuBarItem.Click += new System.EventHandler(this.toolStripMenuItem2_Click); - // + this.openMenuBarItem.Click += new System.EventHandler(this.openMenuItem_Click); + // // saveMenuBarItem - // + // this.saveMenuBarItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.saveMenuBarItem.Image = global::bzit.bomg.Properties.Resources.disk; this.saveMenuBarItem.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -607,62 +613,82 @@ namespace bzit.bomg this.saveMenuBarItem.Text = "toolStripButton3"; this.saveMenuBarItem.ToolTipText = "Save"; this.saveMenuBarItem.Click += new System.EventHandler(this.importSnapshotToolStripMenuItem_Click); - // + // // toolStripSeparator9 - // + // this.toolStripSeparator9.Name = "toolStripSeparator9"; this.toolStripSeparator9.Size = new System.Drawing.Size(6, 25); - // - // treeMenuRoot - // - this.treeMenuRoot.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + // + // toolStripButton1 + // + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(23, 22); + this.toolStripButton1.Text = "toolStripButton1"; + // + // toolStripButton2 + // + this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); + this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton2.Name = "toolStripButton2"; + this.toolStripButton2.Size = new System.Drawing.Size(23, 22); + this.toolStripButton2.Text = "toolStripButton2"; + // + // rootTreeNodeMenu + // + this.rootTreeNodeMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem17, this.toolStripMenuItem18, this.toolStripSeparator10, this.toolStripMenuItem20, this.toolStripSeparator13, this.toolStripMenuItem22}); - this.treeMenuRoot.Name = "listViewMenu"; - this.treeMenuRoot.Size = new System.Drawing.Size(133, 104); - // + this.rootTreeNodeMenu.Name = "listViewMenu"; + this.rootTreeNodeMenu.Size = new System.Drawing.Size(133, 104); + // // toolStripMenuItem17 - // + // this.toolStripMenuItem17.Name = "toolStripMenuItem17"; this.toolStripMenuItem17.Size = new System.Drawing.Size(132, 22); this.toolStripMenuItem17.Text = "Add &Page"; - // + this.toolStripMenuItem17.Click += new System.EventHandler(this.addPageContextMenu_Click); + // // toolStripMenuItem18 - // + // this.toolStripMenuItem18.Name = "toolStripMenuItem18"; this.toolStripMenuItem18.Size = new System.Drawing.Size(132, 22); this.toolStripMenuItem18.Text = "Add &Folder"; - // + this.toolStripMenuItem18.Click += new System.EventHandler(this.addFolderContextMenu_Click); + // // toolStripSeparator10 - // + // this.toolStripSeparator10.Name = "toolStripSeparator10"; this.toolStripSeparator10.Size = new System.Drawing.Size(129, 6); - // + // // toolStripMenuItem20 - // + // this.toolStripMenuItem20.Name = "toolStripMenuItem20"; this.toolStripMenuItem20.Size = new System.Drawing.Size(132, 22); this.toolStripMenuItem20.Text = "Edi&t"; - this.toolStripMenuItem20.Click += new System.EventHandler(this.toolStripMenuItem9_Click); - // + this.toolStripMenuItem20.Click += new System.EventHandler(this.editContextMenu_Click); + // // toolStripSeparator13 - // + // this.toolStripSeparator13.Name = "toolStripSeparator13"; this.toolStripSeparator13.Size = new System.Drawing.Size(129, 6); - // + // // toolStripMenuItem22 - // + // this.toolStripMenuItem22.Name = "toolStripMenuItem22"; this.toolStripMenuItem22.Size = new System.Drawing.Size(132, 22); this.toolStripMenuItem22.Text = "&Sort"; - this.toolStripMenuItem22.Click += new System.EventHandler(this.sortToolStripMenuItem_Click); - // + this.toolStripMenuItem22.Click += new System.EventHandler(this.sortContextMenu_Click); + // // treeView1 - // + // this.treeView1.AllowDrop = true; this.treeView1.BackColor = System.Drawing.Color.White; this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -680,19 +706,9 @@ namespace bzit.bomg this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView2_NodeMouseDoubleClick); this.treeView1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.treeView1_PreviewKeyDown); - // - // toolStripButton1 - // - this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); - this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton1.Name = "toolStripButton1"; - this.toolStripButton1.Size = new System.Drawing.Size(23, 22); - this.toolStripButton1.Text = "toolStripButton1"; - this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); - // + // // MainForm - // + // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(304, 654); @@ -706,15 +722,15 @@ namespace bzit.bomg this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Bookmark Manager"; - this.treeMenuItem.ResumeLayout(false); + this.pageTreeNodeMenu.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); - this.treeMenuFolder.ResumeLayout(false); + this.folderTreeNodeMenu.ResumeLayout(false); this.toolStrip2.ResumeLayout(false); this.toolStrip2.PerformLayout(); - this.treeMenuRoot.ResumeLayout(false); + this.rootTreeNodeMenu.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -725,7 +741,7 @@ namespace bzit.bomg private System.Windows.Forms.StatusBar statusBar1; private System.Windows.Forms.StatusBarPanel statusBarPanel1; private System.Windows.Forms.StatusBarPanel statusBarPanel2; - private System.Windows.Forms.ContextMenuStrip treeMenuItem; + private System.Windows.Forms.ContextMenuStrip pageTreeNodeMenu; private System.Windows.Forms.ToolStripMenuItem listViewMenuItem1; private System.Windows.Forms.ToolStripMenuItem moveFileToToolStripMenuItem; private System.Windows.Forms.ToolTip oToolTip1; @@ -758,7 +774,7 @@ namespace bzit.bomg public BookmarkTreeView treeView1; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4; private System.Windows.Forms.OpenFileDialog openFileDialog; - private System.Windows.Forms.ContextMenuStrip treeMenuFolder; + private System.Windows.Forms.ContextMenuStrip folderTreeNodeMenu; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9; private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem11; @@ -778,7 +794,7 @@ namespace bzit.bomg private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem15; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem16; private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; - private System.Windows.Forms.ContextMenuStrip treeMenuRoot; + private System.Windows.Forms.ContextMenuStrip rootTreeNodeMenu; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem17; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem18; private System.Windows.Forms.ToolStripSeparator toolStripSeparator10; @@ -791,6 +807,7 @@ namespace bzit.bomg private System.Windows.Forms.ToolStripMenuItem updateIconsToolMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator14; private System.Windows.Forms.ToolStripButton toolStripButton1; + private System.Windows.Forms.ToolStripButton toolStripButton2; } } diff --git a/MainForm.cs b/MainForm.cs index 35b3fd3..203181a 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -28,13 +28,6 @@ namespace bzit.bomg { base.OnLoad(e); - this.IconDatabase = new IconDatabase(); - - // toolbar - viewHelpHelpMenuItem.Enabled = File.Exists(Path.ChangeExtension(Application.ExecutablePath, ".chm")); - - - bool rv = false; string iconDBFilename = Path.ChangeExtension(Application.ExecutablePath, ".db"); @@ -42,10 +35,32 @@ namespace bzit.bomg rv = treeView1.InitialiseIconDatabase(out errorMessage, iconDBFilename); if (!rv) { - MessageBox.Show("Can not find icon database. [" + this.IconDatabase.LastError + "]"); + MessageBox.Show("Can not find icon database. [" + errorMessage + "]"); this.Close(); } + + + + + //this.IconDatabase = new IconDatabase(); + + // toolbar + viewHelpHelpMenuItem.Enabled = File.Exists(Path.ChangeExtension(Application.ExecutablePath, ".chm")); + + + + //bool rv = false; + //string iconDBFilename = Path.ChangeExtension(Application.ExecutablePath, ".db"); + + //string errorMessage; + //rv = treeView1.InitialiseIconDatabase(out errorMessage, iconDBFilename); + //if (!rv) + //{ + // MessageBox.Show("Can not find icon database. [" + errorMessage + "]"); + // this.Close(); + //} + sessionFileFormat = new SessionFileFormat(this); this.ApplicationMode = AppMode.Clear; @@ -117,7 +132,7 @@ namespace bzit.bomg protected override void OnFormClosing(FormClosingEventArgs e) { - this.IconDatabase?.Close(); + //this.IconDatabase?.Close(); if (this.ApplicationMode == AppMode.Clear) { @@ -196,7 +211,7 @@ namespace bzit.bomg } } - #region public properties + //#region public properties public AppMode ApplicationMode { @@ -243,26 +258,23 @@ namespace bzit.bomg } } - [DefaultValue(null)] - public IconDatabase IconDatabase { get; set; } + //[DefaultValue(null)] + //public IconDatabase IconDatabase { get; set; } - #endregion + //#endregion #region Toolbar #1 - /** - * File -> New - */ - private void newSessionToolStripMenuItem_Click(object sender, EventArgs e) + private void newMenuItem_Click(object sender, EventArgs e) { - NewSessionForm oNewSession = new NewSessionForm(this); - oNewSession.ShowDialog(); + NewSessionForm newSessionForm = new NewSessionForm(this); + newSessionForm.ShowDialog(); } /* * File -> Open */ - private void toolStripMenuItem2_Click(object sender, EventArgs e) + private void openMenuItem_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { @@ -275,7 +287,7 @@ namespace bzit.bomg /** * File -> Close */ - private void toolStripMenuItem3_Click(object sender, EventArgs e) + private void closeMenuItem_Click(object sender, EventArgs e) { if (ApplicationMode == AppMode.Clear) { @@ -363,7 +375,7 @@ namespace bzit.bomg /** * File -> Exit */ - private void exitToolStripMenuItem1_Click(object sender, EventArgs e) { this.Close(); } + private void exitMenuItem_Click(object sender, EventArgs e) { this.Close(); } /** * Find @@ -476,39 +488,39 @@ namespace bzit.bomg /** * Node -> Open */ - private void toolStripMenuItem4_Click(object sender, EventArgs e) - { - openBookmark(treeView1.SelectedNode); - } + //private void toolStripMenuItem4_Click(object sender, EventArgs e) + //{ + // openBookmark(treeView1.SelectedNode); + //} /** * Node -> Edit */ - private void toolStripMenuItem8_Click(object sender, EventArgs e) - { - if (treeView1.SelectedNode == null) - { - return; - } + //private void toolStripMenuItem8_Click(object sender, EventArgs e) + //{ + // if (treeView1.SelectedNode == null) + // { + // return; + // } - treeView1.HasChanged = true; + // treeView1.HasChanged = true; - TreeNode tn = treeView1.SelectedNode; - BookmarkEditForm oBookmarkEdit = new BookmarkEditForm(ref tn); - oBookmarkEdit.ShowDialog(); - } + // TreeNode tn = treeView1.SelectedNode; + // //##BookmarkEditForm oBookmarkEdit = new BookmarkEditForm(ref tn); + // //##oBookmarkEdit.ShowDialog(); + //} /** * Node -> Delete */ - private void toolStripMenuItem6_Click(object sender, EventArgs e) => treeView1.SNode.Delete(); + //private void toolStripMenuItem6_Click(object sender, EventArgs e) => treeView1.SNode.Delete(); //{ // treeView1.DeleteNode(); //} #endregion - #region TreeView Menu - folder + //#region TreeView Menu - folder /** * Add Page @@ -523,49 +535,36 @@ namespace bzit.bomg /** * Open All */ - private void toolStripMenuItem14_Click(object sender, EventArgs e) - { - if (treeView1.SelectedNode == null) - { - return; - } + //private void toolStripMenuItem14_Click(object sender, EventArgs e) + //{ + // if (treeView1.SelectedNode == null) + // { + // return; + // } - foreach (TreeNode tn in treeView1.SelectedNode.Nodes) - { - if (tn.Tag == null) - { - continue; - } + // foreach (TreeNode tn in treeView1.SelectedNode.Nodes) + // { + // if (tn.Tag == null) + // { + // continue; + // } - openBookmark(tn); - } - } + // openBookmark(tn); + // } + //} /** * Edit */ - private void toolStripMenuItem9_Click(object sender, EventArgs e) - { - treeView1.HasChanged = true; - treeView1.EditNode(); - } + //private void toolStripMenuItem9_Click(object sender, EventArgs e) + //{ + // treeView1.HasChanged = true; + // //##treeView1.EditNode(); + //} - /** - * Move Up - */ - private void toolStripMenuItem12_Click(object sender, EventArgs e) => treeView1.SNode.MoveUp(); - /** - * Move Down - */ - private void toolStripMenuItem13_Click(object sender, EventArgs e) => treeView1.SNode.MoveDown(); - /** - * Sort - */ - private void sortToolStripMenuItem_Click(object sender, EventArgs e) => treeView1.SNode.Sort(); - - #endregion + //#endregion protected void OpenBookmarkFile(string filename) { @@ -636,7 +635,33 @@ namespace bzit.bomg private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { - if (e.Node == null) + if (e.Button != MouseButtons.Right) + { + return; + } + + switch (treeView1.SNode.GetNodeType()) + { + case RyzStudio.Windows.Forms.BookmarkTreeView.NodeType.Root: + rootTreeNodeMenu.Show(Cursor.Position); + break; + case RyzStudio.Windows.Forms.BookmarkTreeView.NodeType.Folder: + folderTreeNodeMenu.Show(Cursor.Position); + break; + case RyzStudio.Windows.Forms.BookmarkTreeView.NodeType.Page: + pageTreeNodeMenu.Show(Cursor.Position); + break; + default: + break; + } + + //BookmarkEditForm editForm = new BookmarkEditForm(treeView1); + //editForm.ShowDialog(); + + return; + + + if (e.Node == null) { return; } @@ -665,11 +690,11 @@ namespace bzit.bomg { if (e.Node.Equals(e.Node.TreeView.Nodes[0])) { - treeMenuRoot.Show(Cursor.Position); + rootTreeNodeMenu.Show(Cursor.Position); } else { - treeMenuFolder.Show(Cursor.Position); + folderTreeNodeMenu.Show(Cursor.Position); } } else @@ -680,7 +705,7 @@ namespace bzit.bomg } BookmarkItem bi = (BookmarkItem)e.Node.Tag; - treeMenuItem.Show(Cursor.Position); + pageTreeNodeMenu.Show(Cursor.Position); } } } @@ -700,20 +725,20 @@ namespace bzit.bomg case Keys.Apps: treeView1_NodeMouseClick(sender, new TreeNodeMouseClickEventArgs(tn, MouseButtons.Right, 1, tn.Bounds.X, tn.Bounds.Y)); return; - case Keys.F2: - if (tn.Tag == null) - { - return; - } + //case Keys.F2: + //if (tn.Tag == null) + //{ + // return; + //} - if (!(tn.Tag is BookmarkItem)) - { - return; - } + //if (!(tn.Tag is BookmarkItem)) + //{ + // return; + //} - toolStripMenuItem8_Click(sender, null); + //toolStripMenuItem8_Click(sender, null); - break; + //break; case Keys.F3: if (tn.Tag == null) { @@ -755,88 +780,157 @@ namespace bzit.bomg protected void openBookmark(TreeNode node) { - if (node == null) + if (treeView1.GetNodeType(node) != RyzStudio.Windows.Forms.BookmarkTreeView.NodeType.Page) { return; } - if (node.Tag == null) + BookmarkItemViewModel viewModel = (BookmarkItemViewModel)node.Tag; + if (viewModel == null) { return; } - if (!(node.Tag is BookmarkItem)) + if (string.IsNullOrWhiteSpace(viewModel.SiteAddress)) { return; } - BookmarkItem item = (BookmarkItem)node.Tag; - if (item == null) + try { - return; + System.Diagnostics.Process.Start(viewModel.SiteAddress); + } + catch + { + // do nothing } - if (string.IsNullOrEmpty(item.SiteAddress)) - { - return; - } - int bookmarkAction; - if (!int.TryParse(this.IconDatabase.GetConfig("core.bookmark.action", string.Empty), out bookmarkAction)) - { - bookmarkAction = 0; - } - string bookmarkCustom1 = this.IconDatabase.GetConfig("core.bookmark.customcommand1", string.Empty).Trim(); - string bookmarkCustom2 = this.IconDatabase.GetConfig("core.bookmark.customcommand2", string.Empty).Trim(); - switch (bookmarkAction) - { - case 1: - if (string.IsNullOrEmpty(bookmarkCustom1)) - { - return; - } - bookmarkCustom1 = bookmarkCustom1.Replace("%1", item.SiteAddress); - bookmarkCustom2 = bookmarkCustom2.Replace("%1", item.SiteAddress); - try - { - System.Diagnostics.Process.Start(bookmarkCustom1, bookmarkCustom2); - } - catch - { - // do nothing - } + //if (node == null) + //{ + // return; + //} - break; - default: - try - { - System.Diagnostics.Process.Start(item.SiteAddress); - } - catch - { - // do nothing - } + //if (node.Tag == null) + //{ + // return; + //} - break; - } + //if (!(node.Tag is BookmarkItem)) + //{ + // return; + //} + + //BookmarkItem item = (BookmarkItem)node.Tag; + //if (item == null) + //{ + // return; + //} + + //if (string.IsNullOrEmpty(item.SiteAddress)) + //{ + // return; + //} + + //int bookmarkAction; + //if (!int.TryParse(this.IconDatabase.GetConfig("core.bookmark.action", string.Empty), out bookmarkAction)) + //{ + // bookmarkAction = 0; + //} + + //string bookmarkCustom1 = this.IconDatabase.GetConfig("core.bookmark.customcommand1", string.Empty).Trim(); + //string bookmarkCustom2 = this.IconDatabase.GetConfig("core.bookmark.customcommand2", string.Empty).Trim(); + + //switch (bookmarkAction) + //{ + // case 1: + // if (string.IsNullOrEmpty(bookmarkCustom1)) + // { + // return; + // } + + // bookmarkCustom1 = bookmarkCustom1.Replace("%1", item.SiteAddress); + // bookmarkCustom2 = bookmarkCustom2.Replace("%1", item.SiteAddress); + + // try + // { + // System.Diagnostics.Process.Start(bookmarkCustom1, bookmarkCustom2); + // } + // catch + // { + // // do nothing + // } + + // break; + // default: + // try + // { + // System.Diagnostics.Process.Start(item.SiteAddress); + // } + // catch + // { + // // do nothing + // } + + // break; + //} } - private void toolStripButton1_Click(object sender, EventArgs e) + + #region root context menu + + private void addPageContextMenu_Click(object sender, EventArgs e) => (new BookmarkEditForm(treeView1)).ShowDialog(); + private void addFolderContextMenu_Click(object sender, EventArgs e) => treeView1.SelectedNode = treeView1.SNode.AddFolder(); + private void editContextMenu_Click(object sender, EventArgs e) => treeView1.SNode.Edit(); + private void sortContextMenu_Click(object sender, EventArgs e) => treeView1.SNode.Sort(); + + #endregion + + #region folder context menu + + private void addPageContextMenu2_Click(object sender, EventArgs e) => (new BookmarkEditForm(treeView1)).ShowDialog(); + private void addFolderContextMenu2_Click(object sender, EventArgs e) => treeView1.SelectedNode = treeView1.SNode.AddFolder(); + + private void openAllContextMenu_Click(object sender, EventArgs e) { - BookmarkItemModel model = new BookmarkItemModel() + if (treeView1.SelectedNode == null) { - SiteAddress = "http://www.hiimray.co.uk", - TreeviewPath = @"\hello\momo\" - }; - model.Update(); + return; + } - treeView1.AddItem_OnSelectedNode(model.ToViewModel()); + if (treeView1.SelectedNode.Nodes.Count <= 0) + { + return; + } - //MessageBox.Show(treeView1.Nodes.Count.ToString()); + foreach (TreeNode item in treeView1.SelectedNode.Nodes) + { + openBookmark(item); + } } + + private void editContextMenu2_Click(object sender, EventArgs e) => treeView1.SNode.Edit(); + private void deleteContextMenu_Click(object sender, EventArgs e) => treeView1.SNode.Delete(); + private void sortContextMenu2_Click(object sender, EventArgs e) => treeView1.SNode.Sort(); + private void moveUpContextMenu_Click(object sender, EventArgs e) => treeView1.SNode.MoveUp(); + private void moveDownContextMenu_Click(object sender, EventArgs e) => treeView1.SNode.MoveDown(); + + #endregion + + #region page context menu + + private void openContextMenu_Click(object sender, EventArgs e) => openBookmark(treeView1.SelectedNode); + private void editContextMenu3_Click(object sender, EventArgs e) => (new BookmarkEditForm(treeView1)).ShowDialog(); + private void deleteContextMenu2_Click(object sender, EventArgs e) => treeView1.SNode.Delete(); + private void moveUpContextMenu2_Click(object sender, EventArgs e) => treeView1.SNode.MoveUp(); + private void moveDownContextMenu2_Click(object sender, EventArgs e) => treeView1.SNode.MoveDown(); + + #endregion + + } } \ No newline at end of file diff --git a/MainForm.resx b/MainForm.resx index bd3674e..6cef617 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -117,21 +117,21 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 412, 17 + + 1034, 17 17, 17 - 307, 17 + 333, 17 AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADU - FwAAAk1TRnQBSQFMAgEBBwEAAWwBAgFsAQIBEAEAARABAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFA + FwAAAk1TRnQBSQFMAgEBBwEAAcwBAgHMAQIBEAEAARABAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABIAMAAQEBAAEQBgABEBQAAZkBSgEYAS4BtwEdAbcBGQG3ARkBtwEZAbcBGQG3ARkBtwEZAbcBGQG3 ARkBtwEdARcBLgGZAUoEAAGZAUoBGAEuAbcBHQG3ARkBtwEZAbcBGQG3ARkBtwEZAbcBGQG3ARkBtwEZ AbcBHQEXAS4BmQFKBAABmQFKARgBLgG3AR0BtwEZAbcBGQG3ARkBtwEZAbcBGQG3ARkBtwEZAbcBGQG3 @@ -236,7 +236,7 @@ - 109, 17 + 123, 17 @@ -254,29 +254,29 @@ - 779, 20 + 443, 17 - - 534, 17 + + 865, 17 - 903, 20 + 576, 17 - 208, 17 + 228, 17 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHZSURBVDhPjZM9SxxRFIaNqfIfIlgJQpDgypZBEAshFkpS - SECIhYJdolikjFiZJizLYiPpAikC6W1EQiQhM4tK/AAlWOy6X+7szse9d2b09ZxLZpxxNyQHHraY8z77 - 3ruzPYl5SGSI7D/oJ3qJjsl4nmcZhnEVhiG6IaVELpd7T7tdJVkOO44D13VjWq0Wms0mKpWKlpTLZeTz - +Q7JPSLLC0IIKKX0J2PbNizLQrVa1QJqCf6SQqEQSfRoQdAqQl7+0IJIwoF2u41arZY6DsMZnabRAnH8 - GuLXQrwQBIE+d3SUer2um5RKpVvB9fmrB/b+i1Hj89imPJyH3JuBPFuH3/iK0HdSEm7C99FoNG4F8mhu - Qx0tQp4swf+9DnX6FsKYgrMzDLG/kmrCx+E7YVEsAJ7f9/amv8iTZRK8I8EqvOIzeOZLhIHSi4zv+/pe - WMLEAp7Ln5NDovgU6mwV6vgNnO1H8K2DOMxwi+hyuU1K4HwfnxDmJNxvj2HvDFL9DNTFlg5FcAOGw52C - 3Sez5seBD6GsIyDE4Rrk+aeOcJKUgCZ+ke6SbJGEn3FGp2m0wDTN67uCv0G7V5zR6T8zQj+Pyw+6BZLw - Dr3ONmX43xtPHzFCsPV/oHBP3w1tip0dw+Y0hQAAAABJRU5ErkJggg== + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHaSURBVDhPjZNNSxtRFIatXfU/KHQlFEqRJmRZhNJFoS6U + uiiC0C4UuquWLlxWurIbCSF0I90VXAju3ZhBLC01QUv9gEpxkZgvM8l83HtnRt+ec3HGGRPRAw9ZzHmf + vPdm0hebASJFZG7gPtFPdE3KdV2zUCicBUGAXkgpkc1ml2i3pyTDYdu24ThORLvdRqvVQrVa1ZJKpYJc + LtcluUNkeEEIAaWU/mQsy4JpmqjValpALcFfks/nQ4keLfDbJcjTn1oQSjjQ6XRQr9cTx2E4o9M0WiAO + ZiH+zEQLvu/rc4dHaTQaukm5XL4UnB+/u2ftTo5srz5dlnvTkDuvII8W4TU3EXh2QsJN+D6azealQO6/ + +aL230IezsH7twj19yPE9hhs4zHE7odEEz4O3wmLIgEwcdfdGV+Th+9J8JkEC3BLL+EWXyPwlV5kPM/T + 98ISJhLwnP4afSRKL6COFqAO5mFvPIRn/o7CDLcIL5fbJAT2j2fPRXEUztYwLOMB1U9BnazrUAg3YDjc + Lfj+ZKr4behrIBvwCbH3CfJ4pSscJyGgiV6kq8RbxOFnnNFpGi0wDOP8quA6aPeMMzp9MWn6eRx+0CsQ + h3fodbYow//eaAaJNMHW20DhvsH/Ib+cRcWEtS4AAAAASUVORK5CYII= @@ -294,8 +294,23 @@ TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - 658, 20 + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 705, 17 108 diff --git a/RyzStudio/Drawing/Rectangoid.cs b/RyzStudio/Drawing/Rectangoid.cs index de846cb..59a24d8 100644 --- a/RyzStudio/Drawing/Rectangoid.cs +++ b/RyzStudio/Drawing/Rectangoid.cs @@ -3,82 +3,122 @@ using System.Drawing.Drawing2D; namespace RyzStudio.Drawing { - public struct Rectangoid - { - int X; - int Y; - int Width; - int Height; - int Radius; + public struct Rectangoid + { + private int X; + private int Y; + private int Width; + private int Height; + private int Radius; - public Rectangoid(int x, int y, int width, int height, int radius) - { - X = x; - Y = y; - Width = width; - Height = height; - Radius = radius; - } + public Rectangoid(Rectangle rect, int radius) + { + X = rect.X; + Y = rect.Y; + Width = rect.Width; + Height = rect.Height; + Radius = radius; + } - public Rectangoid(int x, int y, int width, int height) - { - X = x; - Y = y; - Width = width; - Height = height; - Radius = 0; - } + public Rectangoid(Rectangle rect, int radius, int borderWidth) + { + rect.Inflate((-1 * borderWidth), (-1 * borderWidth)); - public Rectangoid(int width, int height, int radius) - { - X = 0; - Y = 0; - Width = width; - Height = height; - Radius = radius; - } + X = rect.X; + Y = rect.Y; + Width = rect.Width; + Height = rect.Height; + Radius = radius; + } - public Rectangoid(int width, int height) - { - X = 0; - Y = 0; - Width = width; - Height = height; - Radius = 0; - } + public Rectangoid(int x, int y, int width, int height, int radius) + { + X = x; + Y = y; + Width = width; + Height = height; + Radius = radius; + } - public Rectangoid(int width) - { - X = 0; - Y = 0; - Width = width; - Height = width; - Radius = 0; - } - - public GraphicsPath ToGraphicsPath() - { - GraphicsPath rv = new GraphicsPath(); - rv.AddLine(X + Radius, Y, X + Width - (Radius * 2), Y); - rv.AddArc(X + Width - (Radius * 2), Y, Radius * 2, Radius * 2, 270, 90); - rv.AddLine(X + Width, Y + Radius, X + Width, Y + Height - (Radius * 2)); - rv.AddArc(X + Width - (Radius * 2), Y + Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); - rv.AddLine(X + Width - (Radius * 2), Y + Height, X + Radius, Y + Height); - rv.AddArc(X, Y + Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90); - rv.AddLine(X, Y + Height - (Radius * 2), X, Y + Radius); - rv.AddArc(X, Y, Radius * 2, Radius * 2, 180, 90); - rv.CloseFigure(); - - return rv; - } + public Rectangoid(int x, int y, int width, int height) + { + X = x; + Y = y; + Width = width; + Height = height; + Radius = 0; + } - public PointF GetOrigin() - { - PointF retval = new PointF(); - retval.X = ((float)Width / 2) + X; - retval.Y = ((float)Height / 2) + Y; - - return retval; - } - } + public Rectangoid(int width, int height, int radius) + { + X = 0; + Y = 0; + Width = width; + Height = height; + Radius = radius; + } + + public Rectangoid(int width, int height) + { + X = 0; + Y = 0; + Width = width; + Height = height; + Radius = 0; + } + + public Rectangoid(int width) + { + X = 0; + Y = 0; + Width = width; + Height = width; + Radius = 0; + } + + public GraphicsPath ToGraphicsPath() + { + GraphicsPath rv = new GraphicsPath(); + rv.AddLine(X + this.Radius, Y, X + Width - (this.Radius * 2), Y); + + if (this.Radius > 0) + { + rv.AddArc(X + Width - (this.Radius * 2), Y, this.Radius * 2, this.Radius * 2, 270, 90); + } + + rv.AddLine(X + Width, Y + this.Radius, X + Width, Y + Height - (this.Radius * 2)); + + if (this.Radius > 0) + { + rv.AddArc(X + Width - (this.Radius * 2), Y + Height - (this.Radius * 2), this.Radius * 2, this.Radius * 2, 0, 90); + } + + rv.AddLine(X + Width - (this.Radius * 2), Y + Height, X + this.Radius, Y + Height); + + if (this.Radius > 0) + { + rv.AddArc(X, Y + Height - (this.Radius * 2), this.Radius * 2, this.Radius * 2, 90, 90); + } + + rv.AddLine(X, Y + Height - (this.Radius * 2), X, Y + this.Radius); + + if (this.Radius > 0) + { + rv.AddArc(X, Y, this.Radius * 2, this.Radius * 2, 180, 90); + } + + rv.CloseFigure(); + + return rv; + } + + public PointF GetOrigin() + { + PointF rv = new PointF(); + rv.X = ((float)Width / 2) + X; + rv.Y = ((float)Height / 2) + Y; + + return rv; + } + } } \ No newline at end of file diff --git a/RyzStudio/Windows/Forms/HorizontalSeparator.Designer.cs b/RyzStudio/Windows/Forms/HorizontalSeparator.Designer.cs new file mode 100644 index 0000000..f2b384d --- /dev/null +++ b/RyzStudio/Windows/Forms/HorizontalSeparator.Designer.cs @@ -0,0 +1,37 @@ +namespace RyzStudio.Windows.Forms +{ + partial class HorizontalSeparator + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + } + + #endregion + } +} diff --git a/RyzStudio/Windows/Forms/HorizontalSeparator.cs b/RyzStudio/Windows/Forms/HorizontalSeparator.cs new file mode 100644 index 0000000..ace86f8 --- /dev/null +++ b/RyzStudio/Windows/Forms/HorizontalSeparator.cs @@ -0,0 +1,25 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace RyzStudio.Windows.Forms +{ + public partial class HorizontalSeparator : UserControl + { + public HorizontalSeparator() : base() + { + //InitializeComponent(); + + this.MaximumSize = new Size(SystemInformation.VirtualScreen.Width, 2); + } + + + protected override void OnPaintBackground(PaintEventArgs e) + { + base.OnPaintBackground(e); + + Graphics g = e.Graphics; + g.FillRectangle(new SolidBrush(Color.FromArgb(213, 223, 229)), new Rectangle(this.DisplayRectangle.Left, 0, this.DisplayRectangle.Width, 1)); + g.FillRectangle(new SolidBrush(Color.FromArgb(249, 251, 253)), new Rectangle(this.DisplayRectangle.Left, 1, this.DisplayRectangle.Width, 1)); + } + } +} diff --git a/RyzStudio/Windows/ThemedForms/Button.cs b/RyzStudio/Windows/ThemedForms/Button.cs new file mode 100644 index 0000000..06cefb6 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/Button.cs @@ -0,0 +1,104 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using System; + using System.ComponentModel; + using System.Drawing; + + public partial class Button : RyzStudio.Windows.ThemedForms.UserControl + { + protected ButtonState buttonState = ButtonState.Normal; + + public Button() : base() + { + InitializeComponent(); + + label1.ImageAlign = ContentAlignment.MiddleCenter; + + label1.Click += delegate { this.OnClick(null); }; + label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; }; + label1.MouseLeave += delegate { this.VisualState = ButtonState.Normal; }; + label1.MouseDown += delegate { this.VisualState = ButtonState.Down; }; + label1.MouseUp += delegate { this.VisualState = ButtonState.Normal; }; + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + this.StyleOver.ForeImage = this.OverImage; + this.StyleDown.ForeImage = this.DownImage; + this.StyleDefault.ForeImage = this.DefaultImage; + + this.VisualState = ButtonState.Normal; + } + + protected ButtonState VisualState + { + get { return buttonState; } + set + { + switch (value) + { + case ButtonState.Normal: + if (this.VisualState == ButtonState.Down) + { + updateButton(StyleOver); + } + else + { + updateButton(StyleDefault); + } + + break; + case ButtonState.Hover: + updateButton(StyleOver); + break; + case ButtonState.Down: + updateButton(StyleDown); + break; + default: + updateButton(StyleDefault); + break; + } + + buttonState = value; + } + } + + protected void updateButton(ButtonStyle style) + { + label1.ForeColor = style.PenColour; + label1.BackColor = style.BackColour; + label1.Image = style.ForeImage; + } + + [Browsable(true)] + [Category("Appearance")] + public string LabelText + { + get => label1.Text; + set => label1.Text = value; + } + + [Browsable(true)] + [Category("Appearance")] + public Image OverImage { get; set; } = null; + + [Browsable(true)] + [Category("Appearance")] + public Image DownImage { get; set; } = null; + + [Browsable(true)] + [Category("Appearance")] + public Image DefaultImage { get; set; } = null; + + [Browsable(false)] + public ButtonStyle StyleOver { get; set; } = new ButtonStyle(Color.Black, Color.White); + + [Browsable(false)] + public ButtonStyle StyleDown { get; set; } = new ButtonStyle(Color.LightGray, Color.Black); + + [Browsable(false)] + public ButtonStyle StyleDefault { get; set; } = new ButtonStyle(Color.White, Color.Black); + } +} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/Button.designer.cs b/RyzStudio/Windows/ThemedForms/Button.designer.cs new file mode 100644 index 0000000..8791a02 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/Button.designer.cs @@ -0,0 +1,61 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class Button + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Location = new System.Drawing.Point(3, 3); + this.label1.Margin = new System.Windows.Forms.Padding(0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(123, 27); + this.label1.TabIndex = 0; + this.label1.Text = "label1"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // Button + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); + this.Name = "Button"; + this.Padding = new System.Windows.Forms.Padding(3, 3, 2, 2); + this.Size = new System.Drawing.Size(128, 32); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + } +} diff --git a/RyzStudio/Windows/ThemedForms/Button.resx b/RyzStudio/Windows/ThemedForms/Button.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/Button.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/ButtonState.cs b/RyzStudio/Windows/ThemedForms/ButtonState.cs new file mode 100644 index 0000000..9ca2060 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ButtonState.cs @@ -0,0 +1,9 @@ +namespace RyzStudio.Windows.ThemedForms +{ + public enum ButtonState + { + Normal = 0, + Hover, + Down + } +} diff --git a/RyzStudio/Windows/ThemedForms/ButtonStyle.cs b/RyzStudio/Windows/ThemedForms/ButtonStyle.cs new file mode 100644 index 0000000..57c7cb5 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ButtonStyle.cs @@ -0,0 +1,25 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using System.Drawing; + + public class ButtonStyle + { + public Color BackColour { get; set; } + public Color PenColour { get; set; } + public Image ForeImage { get; set; } = null; + + public ButtonStyle(Color backColour, Color penColour) + { + this.BackColour = backColour; + this.PenColour = penColour; + this.ForeImage = null; + } + + public ButtonStyle(Color backColour, Color penColour, Image foreImage) + { + this.BackColour = backColour; + this.PenColour = penColour; + this.ForeImage = foreImage; + } + } +} diff --git a/RyzStudio/Windows/ThemedForms/Form.Designer.cs b/RyzStudio/Windows/ThemedForms/Form.Designer.cs new file mode 100644 index 0000000..a50fcc7 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/Form.Designer.cs @@ -0,0 +1,52 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class Form + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Form + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = System.Drawing.Color.WhiteSmoke; + this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.ClientSize = new System.Drawing.Size(584, 381); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.ForeColor = System.Drawing.Color.Black; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 420); + this.Name = "Form"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/Form.cs b/RyzStudio/Windows/ThemedForms/Form.cs new file mode 100644 index 0000000..00dcbbf --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/Form.cs @@ -0,0 +1,186 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using System; + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + /// + /// Theme customised form + /// + public partial class Form : System.Windows.Forms.Form + { + protected Image topImage = null; + protected Color topFillColour = Color.FromArgb(15, 15, 15); + protected int topFillHeight = 52; + + protected Image bottomImage = null; + protected Color bottomFillColour = Color.FromArgb(15, 15, 15); + protected int bottomFillMargin = 19; + + /// + /// Initializes a new instance of the Form class + /// + public Form() + { + this.InitializeComponent(); + + this.BackColor = Color.FromArgb(246, 246, 246); + } + + /// + /// Onresize event + /// + /// Event argument + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + this.Invalidate(); + } + + /// + /// OnPaint event + /// + /// Event argument + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + Graphics g = e.Graphics; + + Rectangle areaTop = new Rectangle(this.DisplayRectangle.Left, 0, this.DisplayRectangle.Width, topFillHeight); + Rectangle areaBottom = new Rectangle(this.DisplayRectangle.Left, (this.DisplayRectangle.Height - bottomFillMargin), this.DisplayRectangle.Width, bottomFillMargin); + + // draw header + if (topFillHeight > 0) + { + g.FillRectangle(new SolidBrush(topFillColour), areaTop); + } + + // draw footer + if (bottomFillMargin > 0) + { + g.FillRectangle(new SolidBrush(bottomFillColour), areaBottom); + } + + // draw logo + if (topImage != null) + { + g.DrawImageUnscaled(topImage, 0, 0); + } + + if (bottomImage != null) + { + g.DrawImageUnscaled(bottomImage, 0, (this.DisplayRectangle.Height - bottomImage.Height - bottomFillMargin), this.DisplayRectangle.Width, bottomImage.Height); + } + } + + #region public properties + + #endregion + + #region public properties (encapsulation) + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public new Color BackColor { get { return base.BackColor; } set { base.BackColor = value; } } + + #endregion + + public void SetValue(Label sender, string value) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { sender.Text = value; })); + } + else + { + sender.Text = value; + } + } + + public void SetValue(GroupBox sender, string value) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { sender.Text = value; })); + } + else + { + sender.Text = value; + } + } + + public void AddValue(ListBox sender, string value) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { sender.Items.Add(value); })); + } + else + { + sender.Items.Add(value); + } + } + + public void ClearValues(ListBox sender) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { sender.Items.Clear(); })); + } + else + { + sender.Items.Clear(); + } + } + + public string GetValue(ListBox sender) + { + string rv = string.Empty; + + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { rv = (sender.SelectedItem == null) ? string.Empty : sender.SelectedItem.ToString(); })); + } + else + { + rv = (sender.SelectedItem == null) ? string.Empty : sender.SelectedItem.ToString(); + } + + return rv; + } + + public string GetValue(TextBox sender) + { + string rv = string.Empty; + + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { rv = sender.Text.Trim(); })); + } + else + { + rv = sender.Text.Trim(); + } + + return rv; + } + + public int GetValue(NumericUpDown sender) + { + int rv = 0; + + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { rv = (int)sender.Value; })); + } + else + { + rv = (int)sender.Value; + } + + return rv; + } + } +} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/Form.resx b/RyzStudio/Windows/ThemedForms/Form.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/Form.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/MemoBox.cs b/RyzStudio/Windows/ThemedForms/MemoBox.cs new file mode 100644 index 0000000..6e16562 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/MemoBox.cs @@ -0,0 +1,58 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using RyzStudio.Drawing; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + public partial class MemoBox : RyzStudio.Windows.ThemedForms.UserControl + { + protected readonly Padding textboxPadding = new Padding(6, 6, 0, 6); + + public MemoBox() : base() + { + InitializeComponent(); + + this.Margin = new Padding(10, 6, 10, 6); + } + + //protected override void OnResize(EventArgs e) + //{ + // base.OnResize(e); + + // int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; + + // this.Height = textBox1.Height + (b + textboxPadding.Top) + ((b - 1) + textboxPadding.Bottom); + //} + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + + textBox1.Focus(); + } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)] + [Category("Appearance")] + public System.Windows.Forms.TextBox InnerTextBox { get => textBox1; set => textBox1 = value; } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)] + [Category("Appearance")] + public new string Text { get => textBox1.Text; set => textBox1.Text = value; } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public new Padding Margin { get { return base.Margin; } set { base.Margin = value; } } + + protected override void updateBackground(Graphics g, ThemeStyle style) + { + int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; + + this.Padding = new Padding((b + textboxPadding.Left), (b + textboxPadding.Top), ((b - 1) + textboxPadding.Right), ((b - 1) + textboxPadding.Bottom)); + + Rectangoid area = new Rectangoid(this.ClientRectangle, style.BorderRadius, style.BorderWidth); + g.FillPath(new SolidBrush(style.BackColour), area.ToGraphicsPath()); + g.DrawPath(new Pen(new SolidBrush(style.BorderColour), style.BorderWidth), area.ToGraphicsPath()); + } + } +} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/MemoBox.designer.cs b/RyzStudio/Windows/ThemedForms/MemoBox.designer.cs new file mode 100644 index 0000000..19ad7a6 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/MemoBox.designer.cs @@ -0,0 +1,63 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class MemoBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.AcceptsReturn = true; + this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.HideSelection = false; + this.textBox1.Location = new System.Drawing.Point(4, 4); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox1.Size = new System.Drawing.Size(121, 25); + this.textBox1.TabIndex = 0; + // + // MemoBox + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.Controls.Add(this.textBox1); + this.Name = "MemoBox"; + this.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.Size = new System.Drawing.Size(128, 32); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + } +} diff --git a/RyzStudio/Windows/ThemedForms/MemoBox.resx b/RyzStudio/Windows/ThemedForms/MemoBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/MemoBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/ProgressBar.Designer.cs b/RyzStudio/Windows/ThemedForms/ProgressBar.Designer.cs new file mode 100644 index 0000000..032705b --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ProgressBar.Designer.cs @@ -0,0 +1,72 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class ProgressBar + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label3 = new System.Windows.Forms.Label(); + this.userControl1 = new RyzStudio.Windows.ThemedForms.ProgressBarInner(); + this.SuspendLayout(); + // + // label3 + // + this.label3.BackColor = System.Drawing.Color.Transparent; + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Font = new System.Drawing.Font("Segoe UI", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(4, 4); + this.label3.Margin = new System.Windows.Forms.Padding(0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(803, 47); + this.label3.TabIndex = 144; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // userControl1 + // + this.userControl1.BarColour = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(225)))), ((int)(((byte)(249))))); + this.userControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.userControl1.Location = new System.Drawing.Point(4, 4); + this.userControl1.Margin = new System.Windows.Forms.Padding(0); + this.userControl1.Maximum = 100; + this.userControl1.Minimum = 0; + this.userControl1.Name = "userControl1"; + this.userControl1.Size = new System.Drawing.Size(803, 47); + this.userControl1.TabIndex = 145; + this.userControl1.Value = 50; + // + // ProgressBar + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.userControl1); + this.Controls.Add(this.label3); + this.Margin = new System.Windows.Forms.Padding(0); + this.Name = "ProgressBar"; + this.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.Size = new System.Drawing.Size(810, 54); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label3; + private ProgressBarInner userControl1; + } +} diff --git a/RyzStudio/Windows/ThemedForms/ProgressBar.cs b/RyzStudio/Windows/ThemedForms/ProgressBar.cs new file mode 100644 index 0000000..42dc1bf --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ProgressBar.cs @@ -0,0 +1,29 @@ +using System; +using System.Drawing; + +namespace RyzStudio.Windows.ThemedForms +{ + public partial class ProgressBar : RyzStudio.Windows.ThemedForms.UserControl + { + public ProgressBar() : base() + { + InitializeComponent(); + + styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(112, 112, 112), Color.White); + } + + public int Minimum { get => userControl1.Minimum; set => userControl1.Minimum = value; } + public int Maximum { get => userControl1.Maximum; set => userControl1.Maximum = value; } + public int Value { get => userControl1.Value; set => userControl1.Value = value; } + + public Color BarColour { get => userControl1.BarColour; set => userControl1.BarColour = value; } + public Color BarTextColour { get => userControl1.BarTextColour; set => userControl1.BarTextColour = value; } + + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + + this.Invalidate(); + } + } +} diff --git a/RyzStudio/Windows/ThemedForms/ProgressBar.resx b/RyzStudio/Windows/ThemedForms/ProgressBar.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ProgressBar.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/ProgressBarInner.Designer.cs b/RyzStudio/Windows/ThemedForms/ProgressBarInner.Designer.cs new file mode 100644 index 0000000..8a0fc5c --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ProgressBarInner.Designer.cs @@ -0,0 +1,63 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class ProgressBarInner + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label3 + // + this.label3.BackColor = System.Drawing.Color.Transparent; + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Font = new System.Drawing.Font("Segoe UI", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(4, 4); + this.label3.Margin = new System.Windows.Forms.Padding(0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(803, 47); + this.label3.TabIndex = 144; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // ProgressBarInner + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label3); + this.Margin = new System.Windows.Forms.Padding(0); + this.Name = "ProgressBarInner"; + this.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.Size = new System.Drawing.Size(810, 54); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label3; + } +} diff --git a/RyzStudio/Windows/ThemedForms/ProgressBarInner.cs b/RyzStudio/Windows/ThemedForms/ProgressBarInner.cs new file mode 100644 index 0000000..acf6004 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ProgressBarInner.cs @@ -0,0 +1,197 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace RyzStudio.Windows.ThemedForms +{ + public partial class ProgressBarInner : System.Windows.Forms.UserControl + { + protected int minimum = 0; + protected int maximum = 100; + protected int value = 0; + + public ProgressBarInner() : base() + { + InitializeComponent(); + + this.Padding = new Padding(0); + } + + public int Minimum + { + get + { + return minimum; + } + set + { + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(() => { + setMinimum(value); + })); + } + else + { + setMinimum(value); + } + } + } + + public int Maximum + { + get + { + return maximum; + } + set + { + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(() => { + setMaximum(value); + })); + } + else + { + setMaximum(value); + } + } + } + + public int Value + { + get + { + return value; + } + set + { + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(() => { + setValue(value); + })); + } + else + { + setValue(value); + } + } + } + + public Color BarColour { get; set; } = Color.FromArgb(158, 225, 249); + + public Color BarTextColour + { + get => label3.ForeColor; + set => label3.ForeColor = value; + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + Rectangle canvas = this.DisplayRectangle; + Graphics g = e.Graphics; + + if (this.Value > 0) + { + decimal result = decimal.Divide(canvas.Width, this.Maximum) * this.Value; + + canvas.Width = (int)Math.Round(result); + + g.FillRectangle(new SolidBrush(this.BarColour), canvas); + } + } + + protected void updateText() + { + if (label3.InvokeRequired) + { + label3.Invoke(new MethodInvoker(() => + { + label3.Text = string.Format("{0}/{1}", this.Value.ToString(), this.Maximum.ToString()); + })); + } + else + { + label3.Text = string.Format("{0}/{1}", this.Value.ToString(), this.Maximum.ToString()); + } + } + + protected void setMinimum(int value) + { + int m = value; + if (m < 0) + { + m = 0; + } + + if (m > this.Maximum) + { + m = this.Maximum; + } + + if (this.Value < m) + { + this.Value = m; + } + + if (this.value > this.Maximum) + { + this.value = this.Maximum; + } + + minimum = m; + updateText(); + this.Invalidate(); + } + + protected void setMaximum(int value) + { + int m = value; + if (m < 0) + { + m = 0; + } + + if (m < this.Minimum) + { + m = this.Minimum; + } + + if (this.Value > m) + { + this.Value = m; + } + + if (this.value < this.Minimum) + { + this.value = this.Minimum; + } + + maximum = m; + updateText(); + this.Invalidate(); + } + + protected void setValue(int value) + { + int m = value; + if (m < this.Minimum) + { + m = this.Minimum; + } + + if (m > this.Maximum) + { + m = this.Maximum; + } + + this.value = m; + updateText(); + this.Invalidate(); + } + } +} diff --git a/RyzStudio/Windows/ThemedForms/ProgressBarInner.resx b/RyzStudio/Windows/ThemedForms/ProgressBarInner.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ProgressBarInner.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/TextBox.cs b/RyzStudio/Windows/ThemedForms/TextBox.cs new file mode 100644 index 0000000..ec54dc7 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/TextBox.cs @@ -0,0 +1,58 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using RyzStudio.Drawing; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + public partial class TextBox : RyzStudio.Windows.ThemedForms.UserControl + { + protected readonly Padding textboxPadding = new Padding(6, 6, 6, 6); + + public TextBox() : base() + { + InitializeComponent(); + + this.Margin = new Padding(10, 6, 10, 6); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; + + this.Height = textBox1.Height + (b + textboxPadding.Top) + ((b - 1) + textboxPadding.Bottom); + } + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + + textBox1.Focus(); + } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)] + [Category("Appearance")] + public System.Windows.Forms.TextBox InnerTextBox { get => textBox1; set => textBox1 = value; } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)] + [Category("Appearance")] + public new string Text { get => textBox1.Text; set => textBox1.Text = value; } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public new Padding Margin { get { return base.Margin; } set { base.Margin = value; } } + + protected override void updateBackground(Graphics g, ThemeStyle style) + { + int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; + + this.Padding = new Padding((b + textboxPadding.Left), (b + textboxPadding.Top), ((b - 1) + textboxPadding.Right), ((b - 1) + textboxPadding.Bottom)); + + Rectangoid area = new Rectangoid(this.ClientRectangle, style.BorderRadius, style.BorderWidth); + g.FillPath(new SolidBrush(style.BackColour), area.ToGraphicsPath()); + g.DrawPath(new Pen(new SolidBrush(style.BorderColour), style.BorderWidth), area.ToGraphicsPath()); + } + } +} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/TextBox.designer.cs b/RyzStudio/Windows/ThemedForms/TextBox.designer.cs new file mode 100644 index 0000000..29231b0 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/TextBox.designer.cs @@ -0,0 +1,60 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class TextBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.HideSelection = false; + this.textBox1.Location = new System.Drawing.Point(4, 4); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(121, 13); + this.textBox1.TabIndex = 0; + // + // TextBox + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.Controls.Add(this.textBox1); + this.Name = "TextBox"; + this.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.Size = new System.Drawing.Size(128, 32); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + } +} diff --git a/RyzStudio/Windows/ThemedForms/TextBox.resx b/RyzStudio/Windows/ThemedForms/TextBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/TextBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/ThemeStyle.cs b/RyzStudio/Windows/ThemedForms/ThemeStyle.cs new file mode 100644 index 0000000..71d1dee --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ThemeStyle.cs @@ -0,0 +1,34 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using System.Drawing; + + public struct ThemeStyle + { + public int BorderWidth; + public int BorderRadius; + public int BorderPadding; + public Color BorderColour; + public Color BackColour; + public Color ForeColour; + + public ThemeStyle(int borderWidth, int borderRadius, int borderPadding, Color borderColour, Color backColour) + { + this.BorderWidth = borderWidth; + this.BorderRadius = borderRadius; + this.BorderPadding = borderPadding; + this.BorderColour = borderColour; + this.BackColour = backColour; + this.ForeColour = Color.Black; + } + + public ThemeStyle(int borderWidth, int borderRadius, int borderPadding, Color borderColour, Color backColour, Color foreColour) + { + this.BorderWidth = borderWidth; + this.BorderRadius = borderRadius; + this.BorderPadding = borderPadding; + this.BorderColour = borderColour; + this.BackColour = backColour; + this.ForeColour = foreColour; + } + } +} diff --git a/RyzStudio/Windows/ThemedForms/ThreadHelper.cs b/RyzStudio/Windows/ThemedForms/ThreadHelper.cs new file mode 100644 index 0000000..e1e3b82 --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/ThreadHelper.cs @@ -0,0 +1,51 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace RyzStudio.Windows.ThemedForms +{ + public class ThreadHelper + { + public static void SetText(TextBox sender, string text) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { + sender.Text = text; + })); + } + else + { + sender.Text = text; + } + } + + public static void SetText(MemoBox sender, string text) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { + sender.Text = text; + })); + } + else + { + sender.Text = text; + } + } + + public static void SetImage(PictureBox sender, Image image) + { + if (sender.InvokeRequired) + { + sender.Invoke(new MethodInvoker(() => { + sender.Image = image; + })); + } + else + { + sender.Image = image; + } + } + + } +} diff --git a/RyzStudio/Windows/ThemedForms/UserControl.cs b/RyzStudio/Windows/ThemedForms/UserControl.cs new file mode 100644 index 0000000..8f25bdb --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/UserControl.cs @@ -0,0 +1,53 @@ +namespace RyzStudio.Windows.ThemedForms +{ + using System; + using System.Drawing; + using System.Windows.Forms; + using RyzStudio.Drawing; + using System.ComponentModel; + + public partial class UserControl : System.Windows.Forms.UserControl + { + protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(112, 112, 112), Color.White); + + public UserControl() + { + InitializeComponent(); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + this.BackColor = Color.Transparent; + } + + + protected override void OnPaintBackground(PaintEventArgs e) + { + base.OnPaintBackground(e); + + Graphics g = e.Graphics; + //// g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; + //// g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; + //// g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; + //// g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + + updateBackground(g, styleActive); + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public new Padding Padding { get { return base.Padding; } set { base.Padding = value; } } + + protected virtual void updateBackground(Graphics g, ThemeStyle style) + { + int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; + + this.Padding = new Padding(b, b, (b - 1), (b - 1)); + + Rectangoid area = new Rectangoid(this.ClientRectangle, style.BorderRadius, style.BorderWidth); + g.FillPath(new SolidBrush(style.BackColour), area.ToGraphicsPath()); + g.DrawPath(new Pen(new SolidBrush(style.BorderColour), style.BorderWidth), area.ToGraphicsPath()); + } + } +} \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/UserControl.designer.cs b/RyzStudio/Windows/ThemedForms/UserControl.designer.cs new file mode 100644 index 0000000..ea91b3c --- /dev/null +++ b/RyzStudio/Windows/ThemedForms/UserControl.designer.cs @@ -0,0 +1,37 @@ +namespace RyzStudio.Windows.ThemedForms +{ + partial class UserControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/RyzStudio/Windows/Forms/MovableTreeView.cs b/Windows/Forms/BookmarkTreeView.cs similarity index 55% rename from RyzStudio/Windows/Forms/MovableTreeView.cs rename to Windows/Forms/BookmarkTreeView.cs index a2f9f6b..0da84f9 100644 --- a/RyzStudio/Windows/Forms/MovableTreeView.cs +++ b/Windows/Forms/BookmarkTreeView.cs @@ -1,11 +1,15 @@ -using System; +using bzit.bomg; +using bzit.bomg.Models; +using System; using System.ComponentModel; using System.Drawing; +using System.IO; using System.Windows.Forms; +using Resources = bzit.bomg.Properties.Resources; namespace RyzStudio.Windows.Forms { - public class MovableTreeView : System.Windows.Forms.TreeView + public class BookmarkTreeView : System.Windows.Forms.TreeView { public enum IconSet { @@ -15,7 +19,18 @@ namespace RyzStudio.Windows.Forms Default } - public MovableTreeViewSelectedNode SNode { get; set; } + public enum NodeType + { + None = 0, + Root, + Folder, + Page + } + + public BookmarkTreeViewSNode SNode { get; set; } + + protected IconDatabase iconDatabase = null; + public delegate void NodeCountUpdated(ulong v); @@ -23,28 +38,34 @@ namespace RyzStudio.Windows.Forms public NodeCountUpdated OnNodeCountUpdate = null; protected const char pathSeparator = '|'; - //protected const int folderImageIndex = 1; - //protected const int folderSelectedImageIndex = 2; protected TreeNode draggingNode = null; - protected bool allowBeginEdit = false; -//// public int[] folderImageIndex = { 1, 2 }; + //protected bool allowBeginEdit = false; protected ulong nodeCount = 0; protected bool hasChanged = false; - public MovableTreeView() + public BookmarkTreeView() : base() { - this.SNode = new MovableTreeViewSelectedNode(this); + this.SNode = new BookmarkTreeViewSNode(this); + + if (this.ImageList == null) + { + this.ImageList = new ImageList(); + } + + this.ImageList.ColorDepth = ColorDepth.Depth16Bit; + this.ImageList.ImageSize = new Size(16, 16); + this.ImageList.TransparentColor = Color.Transparent; + + this.ImageList.Images.Clear(); + this.ImageList.Images.Add(Resources.transmit_blue); + this.ImageList.Images.Add(Resources.folder); + this.ImageList.Images.Add(Resources.folder_explore); + this.ImageList.Images.Add(Resources.page_white_world_bw); } - #region public properties - -/* [Category("Data")] - public char CustomPathSeparator - { - get { return customPathSeparator; } - set { customPathSeparator = value; } - }*/ + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new ImageList ImageList { get => base.ImageList; set => base.ImageList = value; } [Browsable(false)] public TreeNode[] NodeList @@ -66,26 +87,6 @@ namespace RyzStudio.Windows.Forms } } - //[Browsable(false)] - //public string[] NodeNameList - //{ - // get - // { - // string[] rv = new string[0]; - // if (this.Nodes.Count <= 0) - // { - // return rv; - // } - - // foreach (TreeNode tn in this.Nodes) - // { - // traverseNodeNameList(ref rv, tn); - // } - - // return rv; - // } - //} - [Browsable(false)] public ulong NodeCount { @@ -127,237 +128,122 @@ namespace RyzStudio.Windows.Forms } } - #endregion #region public methods - //public TreeNode AddFolder() - //{ - // return this.AddFolder("New Folder " + (new Random()).Next(10001, 99999).ToString()); - //} - - //public TreeNode AddFolder(string name) - //{ - // if (this.SelectedNode == null) - // { - // return null; - // } - - // if (this.SelectedNode.Tag != null) - // { - // return null; - // } - - // this.HasChanged = true; - - // TreeNode tn = this.SelectedNode.Nodes.Add(PathEncode(name), name, folderImageIndex, folderSelectedImageIndex); - // this.SelectedNode = tn; - - // OnAddFolderNode(tn); - - // return tn; - //} - - //public TreeNode AddBookmarkPage() - //{ - // return this.AddBookmarkPage("New Page " + (new Random()).Next(10001, 99999).ToString()); - //} - - //public TreeNode AddBookmarkPage(string name, int icon = 3) - //{ - // if (this.SelectedNode == null) - // { - // return null; - // } - - // if (this.SelectedNode.Tag != null) - // { - // return null; - // } - - // this.HasChanged = true; - - // TreeNode tn = this.SelectedNode.Nodes.Add(PathEncode(name), name, icon, icon); - // tn.Tag = new object(); - // tn.ToolTipText = name; - - // nodeCount++; - // NodeCountUpdate(nodeCount); - - // this.SelectedNode = tn; - - // OnAddItemNode(tn); - // return tn; - //} - - //public TreeNode AddBookmarkPageFullPath(string name, int icon = 3) - //{ - // if (this.Nodes.Count <= 0) - // { - // return null; - // } - - // this.HasChanged = true; - - // TreeNode tn2; - // if (!name.Contains(pathSeparator.ToString())) - // { - // tn2 = this.Nodes[0].Nodes.Add(name, PathDecode(name), icon, icon); - // tn2.ToolTipText = name; - // nodeCount++; - // } - // else - // { - // tn2 = this.Nodes[0]; - // string[] folders = name.Split(pathSeparator); - // for (int x = 0; x < (folders.Length - 1); x++) - // { - // string dr = folders[x].Trim(); - // if (tn2.Nodes.ContainsKey(dr)) - // { - // tn2 = tn2.Nodes[dr]; - // } - // else - // { - // tn2 = tn2.Nodes.Add(dr, PathDecode(dr), folderImageIndex, folderSelectedImageIndex); - // } - // } - - // string tm = folders[(folders.Length - 1)].Trim(); - // tn2 = tn2.Nodes.Add(tm, PathDecode(tm), icon, icon); - // tn2.Tag = new object(); - // tn2.ToolTipText = tm; - - // nodeCount++; - // } - - // NodeCountUpdate(nodeCount); - - // return tn2; - //} - - public void EditNode() + public bool InitialiseIconDatabase(out string message, string filename) { - this.HasChanged = true; + message = string.Empty; - if (this.SelectedNode == null) + if (string.IsNullOrWhiteSpace(filename)) { - return; + return false; } - if (!this.SelectedNode.IsEditing) + if (iconDatabase == null) { - allowBeginEdit = true; - this.SelectedNode.BeginEdit(); + iconDatabase = new IconDatabase(); + } + + bool rv = false; + if (File.Exists(filename)) + { + rv = iconDatabase.LoadFile(filename); + if (!rv) + { + rv = iconDatabase.Create(filename, true, null, true); + if (!rv) + { + message = iconDatabase.LastError; + return false; + } + } + } + else + { + rv = iconDatabase.Create(filename, true, null, true); + if (!rv) + { + message = iconDatabase.LastError; + return false; + } + } + + return true; + } + + public void AddItem(BookmarkItemViewModel viewModel) + { + int iconIndex = addIcon(viewModel); + + TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex); + tn.Tag = viewModel; + tn.ToolTipText = viewModel.ToString(); + + TreeNode tn2 = addFolderPath(viewModel.TreeviewPath); + + tn2.Nodes.Add(tn); + } + + public void AddOrUpdateItem_OnSelectedNode(BookmarkItemViewModel viewModel) + { + switch (this.SNode.GetNodeType()) + { + case NodeType.Root: + case NodeType.Folder: + addItem_OnSelectedNode(viewModel); + break; + case NodeType.Page: + updateItem_OnSelectedNode(viewModel); + break; + default: + break; } } - //public void DeleteNode() + public NodeType GetNodeType(TreeNode node) + { + if (node.Tag == null) + { + if (node.Equals(this.Nodes[0])) + { + return NodeType.Root; + } + else + { + return NodeType.Folder; + } + } + else + { + if (node.Tag is BookmarkItemViewModel) + { + return NodeType.Page; + } + else + { + return NodeType.None; + } + } + } + + + //public void EditNode() //{ - // if (this.SelectedNode == null) - // { - // return; - // } + // this.SNode. - // if (this.Nodes.Count <= 0) - // { - // return; - // } + // //this.HasChanged = true; - // if (this.SelectedNode.Equals(this.Nodes[0])) - // { - // return; - // } + // //if (this.SelectedNode == null) + // //{ + // // return; + // //} - // this.HasChanged = true; - - // this.SelectedNode.Remove(); - - // if (this.SelectedNode.Tag == null) - // { - // nodeCount = this.NodeCountCalc; - // } - // else - // { - // nodeCount--; - // } - - // NodeCountUpdate(nodeCount); - //} - - //public void SortNode() - //{ - // TreeNode tn = this.SelectedNode; - // string[] tnv = new string[0]; - // TreeNode[] tna = new TreeNode[0]; - - // this.HasChanged = true; - - // foreach (TreeNode tn2 in tn.Nodes) - // { - // Array.Resize(ref tna, (tna.Length + 1)); - // tna[(tna.Length - 1)] = tn2; - - // Array.Resize(ref tnv, (tnv.Length + 1)); - // tnv[(tnv.Length - 1)] = tn2.Text; - // } - - // Array.Sort(tnv, tna); - - // tn.Nodes.Clear(); - // foreach (TreeNode tn2 in tna) - // { - // tn.Nodes.Add(tn2); - // } - //} - - //public void MoveNodeUp() - //{ - // TreeNode tn = this.SelectedNode; - // if (tn.Parent == null) - // { - // return; - // } - - // if (tn.Index == 0) - // { - // return; - // } - - // this.HasChanged = true; - - // int n = tn.Index - 1; - - // TreeNode tn1 = tn.Parent; - // tn1.Nodes.Remove(tn); - // tn1.Nodes.Insert(n, tn); - - // this.SelectedNode = tn; - //} - - //public void MoveNodeDown() - //{ - // TreeNode tn = this.SelectedNode; - // if (tn.Parent == null) - // { - // return; - // } - - // TreeNode tn1 = tn.Parent; - - // this.HasChanged = true; - - // if (tn.Index >= (tn1.Nodes.Count - 1)) - // { - // return; - // } - - // int n = tn.Index + 1; - - // tn1.Nodes.Remove(tn); - // tn1.Nodes.Insert(n, tn); - - // this.SelectedNode = tn; + // //if (!this.SelectedNode.IsEditing) + // //{ + // // allowBeginEdit = true; + // // this.SelectedNode.BeginEdit(); + // //} //} public string GetNodeFullPath(TreeNode node) @@ -534,57 +420,57 @@ namespace RyzStudio.Windows.Forms protected override void OnBeforeLabelEdit(NodeLabelEditEventArgs e) { - if (!allowBeginEdit) - { - e.CancelEdit = true; - return; - } + //if (!allowBeginEdit) + //{ + // e.CancelEdit = true; + // return; + //} - this.HasChanged = true; + //this.HasChanged = true; - base.OnBeforeLabelEdit(e); + //base.OnBeforeLabelEdit(e); - if (e.Node == null) - { - e.CancelEdit = true; - } - else - { - if (e.Node.Tag == null) - { - // do it - } - else - { - e.CancelEdit = true; - } - } + //if (e.Node == null) + //{ + // e.CancelEdit = true; + //} + //else + //{ + // if (e.Node.Tag == null) + // { + // // do it + // } + // else + // { + // e.CancelEdit = true; + // } + //} } 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; - } + //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; + //allowBeginEdit = false; } protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e) @@ -616,11 +502,7 @@ namespace RyzStudio.Windows.Forms break; case Keys.F2: - if (tn.Tag == null) - { - this.EditNode(); - } - + this.SNode.Edit(); break; case Keys.Up: if (e.Modifiers == Keys.Control) @@ -639,7 +521,7 @@ namespace RyzStudio.Windows.Forms default: break; } - base.OnPreviewKeyDown(e); + //base.OnPreviewKeyDown(e); } protected virtual void NodeCountUpdate(ulong v) @@ -649,6 +531,117 @@ namespace RyzStudio.Windows.Forms #endregion + + protected int addIcon(BookmarkItemViewModel viewModel) => addIcon(viewModel.ToModel()); + + protected int addIcon(BookmarkItemModel model) + { + if (this.ImageList.Images.ContainsKey(model.SiteAddress)) + { + return this.ImageList.Images.IndexOfKey(model.SiteAddress); + } + + if (iconDatabase.HasIcon(model.SiteAddress)) + { + Image rs = iconDatabase.GetIcon(model.SiteAddress); + if (rs == null) + { + return (int)IconSet.Default; + } + else + { + this.ImageList.Images.Add(model.SiteAddress, rs); + + return this.ImageList.Images.IndexOfKey(model.SiteAddress); + } + } + + Bitmap bmp = model.RetrieveFavicon(); + if (bmp == null) + { + return (int)IconSet.Default; + } + + this.ImageList.Images.Add(model.SiteAddress, bmp); + + return this.ImageList.Images.IndexOfKey(model.SiteAddress); + } + + protected TreeNode addFolderPath(string path) + { + TreeNode tn = this.Nodes[0]; + if (tn == null) + { + return tn; + } + + if (string.IsNullOrWhiteSpace(path)) + { + return tn; + } + + if (string.IsNullOrWhiteSpace(path.Trim('\\'))) + { + return tn; + } + + string[] folderList = path.Trim('\\').Split('\\'); + if (folderList.Length <= 0) + { + return tn; + } + + foreach (string item in folderList) + { + if (tn.Nodes.ContainsKey(item)) + { + // do nothing + } + else + { + tn.Nodes.Add(item, item, (int)IconSet.Folder1, (int)IconSet.Folder2); + } + + tn = tn.Nodes[item]; + } + + return tn; + } + + protected void addItem_OnSelectedNode(BookmarkItemViewModel viewModel) + { + if (this.SelectedNode == null) + { + return; + } + + int iconIndex = addIcon(viewModel); + + TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex); + tn.Tag = viewModel; + tn.ToolTipText = viewModel.ToString(); + + int n = this.SelectedNode.Nodes.Add(tn); + + this.SelectedNode = this.SelectedNode.Nodes[n]; + } + + protected void updateItem_OnSelectedNode(BookmarkItemViewModel viewModel) + { + if (this.SelectedNode == null) + { + return; + } + + int iconIndex = addIcon(viewModel); + + this.SelectedNode.Text = viewModel.SiteName; + this.SelectedNode.ImageIndex = iconIndex; + this.SelectedNode.SelectedImageIndex = iconIndex; + this.SelectedNode.Tag = viewModel; + this.SelectedNode.ToolTipText = viewModel.ToString(); + } + protected bool isNodeChild(TreeNode drag_node, TreeNode drop_node) { TreeNode tn = drop_node; @@ -686,22 +679,6 @@ namespace RyzStudio.Windows.Forms } } - //protected void traverseNodeNameList(ref string[] results, TreeNode node) - //{ - // foreach (TreeNode tn in node.Nodes) - // { - // if (tn.Tag == null) - // { - // traverseNodeNameList(ref results, tn); - // } - // else - // { - // Array.Resize(ref results, (results.Length + 1)); - // results[(results.Length - 1)] = this.GetNodeFullPath(tn); - // } - // } - //} - protected void traverseNodeCount(ref ulong results, TreeNode node) { foreach (TreeNode tn in node.Nodes) @@ -717,6 +694,12 @@ namespace RyzStudio.Windows.Forms } } + + + + + + protected virtual void OnAddFolderNode(TreeNode node) { } protected virtual void OnAddItemNode(TreeNode node) { } @@ -726,5 +709,10 @@ namespace RyzStudio.Windows.Forms //protected string PathDecode(string text) { return RyzStudio.String.DecodeFrom64(text); } protected string PathEncode(string text) { return System.Web.HttpUtility.UrlEncode(text); } protected string PathDecode(string text) { return System.Web.HttpUtility.UrlDecode(text); } + + + + + } } \ No newline at end of file diff --git a/RyzStudio/Windows/Forms/MovableTreeViewSelectedNode.cs b/Windows/Forms/BookmarkTreeViewSNode.cs similarity index 67% rename from RyzStudio/Windows/Forms/MovableTreeViewSelectedNode.cs rename to Windows/Forms/BookmarkTreeViewSNode.cs index 15e9440..9be4ca0 100644 --- a/RyzStudio/Windows/Forms/MovableTreeViewSelectedNode.cs +++ b/Windows/Forms/BookmarkTreeViewSNode.cs @@ -1,18 +1,23 @@ -using System; +using bzit.bomg.Models; +using System; using System.Windows.Forms; namespace RyzStudio.Windows.Forms { - public class MovableTreeViewSelectedNode + public class BookmarkTreeViewSNode { - protected MovableTreeView Treeview = null; + protected BookmarkTreeView Treeview = null; - public MovableTreeViewSelectedNode(MovableTreeView treeview) + public BookmarkTreeViewSNode(BookmarkTreeView treeview) { Treeview = treeview; } - protected TreeNode SelectedNode { get => this.Treeview.SelectedNode; set => this.Treeview.SelectedNode = value; } + protected TreeNode SelectedNode + { + get => this.Treeview.SelectedNode; + set => this.Treeview.SelectedNode = value; + } protected string encodeName(string name) => Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(name)); @@ -34,7 +39,7 @@ namespace RyzStudio.Windows.Forms return null; } - return this.SelectedNode.Nodes.Add(encodeName(name), name, (int)MovableTreeView.IconSet.Folder1, (int)MovableTreeView.IconSet.Folder2); + return this.SelectedNode.Nodes.Add(encodeName(name), name, (int)BookmarkTreeView.IconSet.Folder1, (int)BookmarkTreeView.IconSet.Folder2); } public TreeNode AddItem(string name, object tag) @@ -49,7 +54,7 @@ namespace RyzStudio.Windows.Forms return null; } - TreeNode tn = new TreeNode(name, (int)MovableTreeView.IconSet.Default, (int)MovableTreeView.IconSet.Default); + TreeNode tn = new TreeNode(name, (int)BookmarkTreeView.IconSet.Default, (int)BookmarkTreeView.IconSet.Default); tn.Tag = tag; this.SelectedNode.Nodes.Add(tn); @@ -57,35 +62,6 @@ namespace RyzStudio.Windows.Forms return tn; } - - //public TreeNode AddPage() => this.AddPage("New Page (" + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ")"); - - //public TreeNode AddPage(string name) - //{ - // if (this.SelectedNode == null) - // { - // return null; - // } - - // if (this.SelectedNode.Tag != null) - // { - // return null; - // } - - // TreeNode tn = this.SelectedNode.Nodes.Add(encodeName(name), name, (int)MovableTreeView.IconSet.Default, (int)MovableTreeView.IconSet.Default); - // tn.Tag = new object(); - // tn.ToolTipText = name; - - // nodeCount++; - // NodeCountUpdate(nodeCount); - - // this.SelectedNode = tn; - - // OnAddItemNode(tn); - // return tn; - //} - - public void Delete() { if (this.SelectedNode == null) @@ -106,6 +82,48 @@ namespace RyzStudio.Windows.Forms this.SelectedNode.Remove(); } + public void Edit() + { + if (this.SelectedNode == null) + { + return; + } + + if (this.SelectedNode.IsEditing) + { + return; + } + + switch (this.GetNodeType()) + { + case BookmarkTreeView.NodeType.Root: + case BookmarkTreeView.NodeType.Folder: + this.SelectedNode.BeginEdit(); + break; + case BookmarkTreeView.NodeType.Page: + this.SelectedNode.BeginEdit(); + break; + default: + break; + } + + + //this.HasChanged = true; + + //if (this.SelectedNode == null) + //{ + // return; + //} + + //if (!this.SelectedNode.IsEditing) + //{ + // allowBeginEdit = true; + // this.SelectedNode.BeginEdit(); + //} + } + + public BookmarkTreeView.NodeType GetNodeType() => this.Treeview.GetNodeType(this.SelectedNode); + public void MoveDown() { if (this.SelectedNode == null) diff --git a/bomg.csproj b/bomg.csproj index 7c502d1..f7e7271 100644 --- a/bomg.csproj +++ b/bomg.csproj @@ -97,7 +97,59 @@ - + + + UserControl + + + HorizontalSeparator.cs + + + + UserControl + + + MemoBox.cs + + + UserControl + + + TextBox.cs + + + UserControl + + + Button.cs + + + + + Form + + + Form.cs + + + UserControl + + + ProgressBar.cs + + + UserControl + + + ProgressBarInner.cs + + + + UserControl + + + UserControl.cs + @@ -157,15 +209,27 @@ BigUserControl.cs - + Component - - Component - - - BookmarkTreeView.cs - + + MemoBox.cs + + + TextBox.cs + + + Button.cs + + + Form.cs + + + ProgressBar.cs + + + ProgressBarInner.cs + UpdateIconForm.cs