internal static bool AddUrlBookmark(UrlBookmark b) { if (UrlBookmarks.Any(z => z.OriginalUrl == b.OriginalUrl)) { return(false); } UrlBookmarks.Add(b); IsDirty = true; return(true); }
private void ListView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F2) { if (listView1.SelectedItems.Count == 0) { return; } var bm = listView1.SelectedItems[0].Tag as UrlBookmark; RenameDialog rd = new RenameDialog(); rd.Value = bm.Info; if (rd.ShowDialog() == DialogResult.OK) { bm.Info = rd.Value; listView1.SelectedItems[0].SubItems[1].Text = bm.Info; Stuff.IsDirty = true; } } if (e.KeyCode == Keys.Delete) { DeleteSelected(); } if (e.Modifiers == Keys.Control && e.KeyCode == Keys.V) { var txt = Clipboard.GetText(); if (Stuff.UrlBookmarks.Any(z => z.OriginalUrl == txt)) { Stuff.Warning("same url already exist."); return; } if (hash.Add(txt)) { var dec = HttpUtility.UrlDecode(txt); var b = new UrlBookmark() { Uri = new Uri(txt), OriginalUrl = dec }; if (dec.ToLower().Contains(watermark1.Text)) { listView1.Items.Add(new ListViewItem(new string[] { dec, "" }) { Tag = b }); } Stuff.AddUrlBookmark(b); } } }
public static void LoadBookmarks(XElement elem) { foreach (var book in elem.Descendants("bookmark")) { var uri = Encoding.UTF8.GetString(Convert.FromBase64String(book.Attribute("uri").Value)); var orig = Encoding.UTF8.GetString(Convert.FromBase64String(book.Attribute("original").Value)); var info = Encoding.UTF8.GetString(Convert.FromBase64String(book.Attribute("info").Value)); var f = new UrlBookmark() { OriginalUrl = orig, Info = info, Uri = new Uri(uri) }; Stuff.AddUrlBookmark(f); } }
internal static void DeleteBookmark(UrlBookmark bm) { UrlBookmarks.Remove(bm); Stuff.IsDirty = true; }