diff --git a/BookmarkEditForm.cs b/BookmarkEditForm.cs index ab1ea96..4790f05 100644 --- a/BookmarkEditForm.cs +++ b/BookmarkEditForm.cs @@ -153,7 +153,7 @@ namespace bzit.bomg itemModel.SiteAddress = textBox2.Text?.Trim(); itemModel.SiteDescription = memoBox1.Text?.Trim(); - treeView?.AddOrUpdateItem_OnSelectedNode(itemModel.ToViewModel()); + treeView?.SNode.AddOrUpdateItem(itemModel.ToViewModel()); this.Close(); } diff --git a/MainForm.cs b/MainForm.cs index a8181aa..de99d05 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1144,6 +1144,13 @@ namespace bzit.bomg return; case Keys.Enter: openBookmark(tn); + break; + case Keys.F2: + if (nodeType == NodeType.Page) + { + (new BookmarkEditForm(treeView1)).ShowDialog(); + } + break; case Keys.Insert: if (e.Modifiers != Keys.Shift) @@ -1165,7 +1172,6 @@ namespace bzit.bomg } } - #region root context menu private void addPageContextMenu_Click(object sender, EventArgs e) => (new BookmarkEditForm(treeView1)).ShowDialog(); diff --git a/Models/BookmarkItemModel.cs b/Models/BookmarkItemModel.cs index aa1f427..8aa2de0 100644 --- a/Models/BookmarkItemModel.cs +++ b/Models/BookmarkItemModel.cs @@ -87,6 +87,32 @@ namespace bzit.bomg return true; } + public bool UpdateFavicon() + { + string sourceCode = retrieveSourceCode(); + if (string.IsNullOrWhiteSpace(sourceCode)) + { + return false; + } + + HtmlDocument document = new HtmlDocument(); + document.LoadHtml(sourceCode); + + // favicon + this.FaviconAddress = parseSiteIcon(document); + if (!string.IsNullOrWhiteSpace(this.FaviconAddress)) + { + Uri iconAddressURI; + bool rv = Uri.TryCreate(new Uri(this.SiteAddress), this.FaviconAddress, out iconAddressURI); + if (rv) + { + this.FaviconAddress = iconAddressURI.ToString(); + } + } + + return true; + } + public Bitmap RetrieveFavicon() { if (string.IsNullOrWhiteSpace(this.FaviconAddress)) @@ -134,9 +160,6 @@ namespace bzit.bomg } } - //protected string encodePath(string text) => System.Web.HttpUtility.UrlEncode(text); - //protected string decodePath(string text) => System.Web.HttpUtility.UrlDecode(text); - protected string parseTagValue(HtmlDocument doc, string xpath, string defaultValue = "") { HtmlNodeCollection hnc = doc.DocumentNode.SelectNodes(xpath); diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c0f53bc..154548b 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.1.012")] +[assembly: AssemblyVersion("0.3.0.012")] [assembly: AssemblyFileVersion("0.1.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index ba0cfae..30474e0 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -89,7 +89,7 @@ namespace bzit.bomg.Properties { } /// - /// Looks up a localized string similar to 0.2.1.012 beta. + /// Looks up a localized string similar to 0.3.0.012 beta. /// internal static string app_version { get { diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 833b209..7053999 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -128,7 +128,7 @@ Bookmark Manager - 0.2.1.012 beta + 0.3.0.012 beta ..\Resources\2\arrow-down-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/RyzStudio/Windows/ThemedForms/Button.cs b/RyzStudio/Windows/ThemedForms/Button.cs index 9e3cf0a..4762b3c 100644 --- a/RyzStudio/Windows/ThemedForms/Button.cs +++ b/RyzStudio/Windows/ThemedForms/Button.cs @@ -93,13 +93,13 @@ public Image DefaultImage { get; set; } = null; [Browsable(false)] - public ButtonStyle StyleOver { get; set; } = new ButtonStyle(Color.Black, Color.White); + public ButtonStyle StyleOver { get; set; } = new ButtonStyle(Color.FromArgb(71, 142, 203), Color.FromArgb(250, 250, 250)); - [Browsable(false)] - public ButtonStyle StyleDown { get; set; } = new ButtonStyle(Color.LightGray, Color.Black); + [Browsable(false)] + public ButtonStyle StyleDown { get; set; } = new ButtonStyle(Color.FromArgb(61, 132, 193), Color.FromArgb(250, 250, 250)); - [Browsable(false)] - public ButtonStyle StyleDefault { get; set; } = new ButtonStyle(Color.White, Color.Black); + [Browsable(false)] + public ButtonStyle StyleDefault { get; set; } = new ButtonStyle(Color.FromArgb(51, 122, 183), Color.FromArgb(250, 250, 250)); public void PerformClick() => this.OnClick(null); } diff --git a/RyzStudio/Windows/ThemedForms/UserControl.cs b/RyzStudio/Windows/ThemedForms/UserControl.cs index 8f25bdb..2bb47f2 100644 --- a/RyzStudio/Windows/ThemedForms/UserControl.cs +++ b/RyzStudio/Windows/ThemedForms/UserControl.cs @@ -8,7 +8,8 @@ public partial class UserControl : System.Windows.Forms.UserControl { - protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(112, 112, 112), Color.White); + //protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(112, 112, 112), Color.White); + protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(212, 212, 212), Color.White); public UserControl() { diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs index f76dc69..846763b 100644 --- a/Windows/Forms/BookmarkTreeView.cs +++ b/Windows/Forms/BookmarkTreeView.cs @@ -35,7 +35,7 @@ namespace RyzStudio.Windows.Forms protected IconDatabase iconDatabase = null; protected TreeNode draggingNode = null; - protected bool allowBeginEdit = false; + protected bool hasChanged = false; public BookmarkTreeView() : base() @@ -60,10 +60,13 @@ namespace RyzStudio.Windows.Forms this.PathSeparator = "\n"; } + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool AllowBeginEdit { get; set; } = false; + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new ImageList ImageList { get => base.ImageList; set => base.ImageList = value; } - [Browsable(false)] + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool HasChanged { get { return hasChanged; } @@ -75,7 +78,6 @@ namespace RyzStudio.Windows.Forms } } - #region public methods public bool InitialiseIconDatabase(out string message, string filename) @@ -172,20 +174,34 @@ namespace RyzStudio.Windows.Forms this.HasChanged = true; } - public void AddOrUpdateItem_OnSelectedNode(BookmarkItemViewModel viewModel) + public void AddItem(TreeNode treeNode, BookmarkItemViewModel viewModel) { - switch (this.SNode.GetNodeType()) + if (treeNode == null) + { + return; + } + + int iconIndex = addIcon(viewModel); + + TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex); + tn.Tag = viewModel; + tn.ToolTipText = viewModel.ToString(); + + treeNode.Nodes.Add(tn); + + this.HasChanged = true; + } + + public void AddOrUpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel) + { + switch (this.GetNodeType(treeNode)) { case NodeType.Root: case NodeType.Folder: - addItem_OnSelectedNode(viewModel); - - this.HasChanged = true; + AddItem(treeNode, viewModel); break; case NodeType.Page: - updateItem_OnSelectedNode(viewModel); - - this.HasChanged = true; + UpdateItem(treeNode, viewModel); break; default: break; @@ -353,6 +369,24 @@ namespace RyzStudio.Windows.Forms return rt; } + public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel viewModel) + { + if (treeNode == null) + { + return; + } + + int iconIndex = addIcon(viewModel); + + treeNode.Text = viewModel.SiteName; + treeNode.ImageIndex = iconIndex; + treeNode.SelectedImageIndex = iconIndex; + treeNode.Tag = viewModel; + treeNode.ToolTipText = viewModel.ToString(); + + this.HasChanged = true; + } + #endregion #region integrated behaviour @@ -423,9 +457,9 @@ namespace RyzStudio.Windows.Forms protected override void OnBeforeLabelEdit(NodeLabelEditEventArgs e) { - if (!allowBeginEdit) + if (!AllowBeginEdit) { - allowBeginEdit = false; + AllowBeginEdit = false; e.CancelEdit = true; return; @@ -459,7 +493,7 @@ namespace RyzStudio.Windows.Forms // e.CancelEdit = true; //} - allowBeginEdit = false; + AllowBeginEdit = false; } protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e) @@ -497,9 +531,13 @@ namespace RyzStudio.Windows.Forms break; case Keys.F2: - allowBeginEdit = true; + if ((nodeType == NodeType.Root) || (nodeType == NodeType.Folder)) + { + this.AllowBeginEdit = true; + + this.SNode.Edit(); + } - this.SNode.Edit(); break; case Keys.F3: switch (nodeType) @@ -643,24 +681,6 @@ namespace RyzStudio.Windows.Forms 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 string decodePath(string value) => System.Web.HttpUtility.UrlDecode(value); protected string encodePath(string value) => System.Web.HttpUtility.UrlEncode(value); @@ -687,22 +707,6 @@ namespace RyzStudio.Windows.Forms } } - 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; diff --git a/Windows/Forms/BookmarkTreeViewSNode.cs b/Windows/Forms/BookmarkTreeViewSNode.cs index df058db..efd9dc0 100644 --- a/Windows/Forms/BookmarkTreeViewSNode.cs +++ b/Windows/Forms/BookmarkTreeViewSNode.cs @@ -1,6 +1,7 @@ using bzit.bomg.Models; using System; using System.Windows.Forms; +using static RyzStudio.Windows.Forms.BookmarkTreeView; namespace RyzStudio.Windows.Forms { @@ -43,6 +44,22 @@ namespace RyzStudio.Windows.Forms return tn; } + public void AddOrUpdateItem(BookmarkItemViewModel viewModel) + { + switch (this.GetNodeType()) + { + case NodeType.Root: + case NodeType.Folder: + Treeview.AddItem(this.SelectedNode, viewModel); + break; + case NodeType.Page: + Treeview.UpdateItem(this.SelectedNode, viewModel); + break; + default: + break; + } + } + public void Delete() { if (this.SelectedNode == null) @@ -79,28 +96,16 @@ namespace RyzStudio.Windows.Forms { case BookmarkTreeView.NodeType.Root: case BookmarkTreeView.NodeType.Folder: + this.Treeview.AllowBeginEdit = true; this.SelectedNode.BeginEdit(); break; case BookmarkTreeView.NodeType.Page: + this.Treeview.AllowBeginEdit = true; this.SelectedNode.BeginEdit(); break; default: break; } - - - //this.HasChanged = true; - - //if (this.SelectedNode == null) - //{ - // return; - //} - - //if (!this.SelectedNode.IsEditing) - //{ - // allowBeginEdit = true; - // this.SelectedNode.BeginEdit(); - //} } public bool FindTextNode(string term) => this.Treeview.FindTextNode(this.SelectedNode, term);