private void button_Click(object sender, MouseButtonEventArgs e) { if (!File.Exists(StaticDeclarations.Bookmarkspath)) { var bookmark = new BookItem(); bookmark.Title = TitleBox.Text; bookmark.Url = _url; var bookmarks = new List<BookItem>(); bookmarks.Add(bookmark); var newJson = JsonConvert.SerializeObject(bookmarks); File.WriteAllText(StaticDeclarations.Bookmarkspath, newJson); } else { var bookmark = new BookItem(); bookmark.Title = TitleBox.Text; bookmark.Url = _url; var json = File.ReadAllText(StaticDeclarations.Bookmarkspath); var bookmarks = JsonConvert.DeserializeObject<List<BookItem>>(json); bookmarks.Add(bookmark); var newJson = JsonConvert.SerializeObject(bookmarks); File.WriteAllText(StaticDeclarations.Bookmarkspath, newJson); } ExecuteStoryboard(); foreach (var tab in mainWindow.Pages) { tab.startPage.RefreshFavs(mainWindow); } }
private void button_Click(object sender, MouseButtonEventArgs e) { if (!File.Exists(StaticDeclarations.Bookmarkspath)) { var bookmark = new BookItem(); bookmark.Title = TitleBox.Text; bookmark.Url = _url; var bookmarks = new List <BookItem>(); bookmarks.Add(bookmark); var newJson = JsonConvert.SerializeObject(bookmarks); File.WriteAllText(StaticDeclarations.Bookmarkspath, newJson); } else { var bookmark = new BookItem(); bookmark.Title = TitleBox.Text; bookmark.Url = _url; var json = File.ReadAllText(StaticDeclarations.Bookmarkspath); var bookmarks = JsonConvert.DeserializeObject <List <BookItem> >(json); bookmarks.Add(bookmark); var newJson = JsonConvert.SerializeObject(bookmarks); File.WriteAllText(StaticDeclarations.Bookmarkspath, newJson); } ExecuteStoryboard(); foreach (var tab in mainWindow.Pages) { tab.startPage.RefreshFavs(mainWindow); } }