private void AddBookmarkButton_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(AddBookmarkName.Text)) { MessageBox.Show("Name cannot be empty.", "Info : Error while adding bookmark", MessageBoxButton.OK, MessageBoxImage.Information); return; } foreach (Bookmark bookmark in bookmarks.allBookmarks.Values) { if (bookmark.Name == AddBookmarkName.Text) { MessageBox.Show("Bookmark already exists.", "Info : Error while adding bookmark", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (bookmark.Url == AddBookmarkUrl.Text) { MessageBox.Show("Bookmark with this url already exist : " + bookmark.Name, "Info : Error while adding bookmark", MessageBoxButton.OK, MessageBoxImage.Information); return; } } if (!IsValidUrl(AddBookmarkUrl.Text)) { MessageBox.Show("Url cannot be empty and must begin with \"http://\", \"https://\" or \"ftp://\".", "Info : Error while adding bookmark", MessageBoxButton.OK, MessageBoxImage.Information); return; } bookmarks.allBookmarks[AddBookmarkName.Text] = bookmarks.BuildBoomark( AddBookmarkName.Text, AddBookmarkUrl.Text, (bool)AddBookmarkIe.IsChecked, (bool)AddBookmarkChrome.IsChecked, (bool)AddBookmarkFirefox.IsChecked); UIInsertBookmark(bookmarks.allBookmarks[AddBookmarkName.Text]); bookmarksModified = true; }