private void DeleteBookmark_OnClick(object sender, RoutedEventArgs e) { TextBlock parent = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBlock; CurrentCodeFile.DeleteBookmark((int)parent.Tag); UpdateBookmarks(); }
protected override void SetEvents(TextBlock elem) { elem.SetBinding(TextBlock.ToolTipProperty, new Binding() { Source = Application.Current.Resources["LocalString"], Path = new PropertyPath("Dict[Editor_BookmarkTooltip]") }); ToolTipService.SetIsEnabled(elem, false); elem.TextAlignment = TextAlignment.Center; elem.ContextMenu = _emptyContextMenu; elem.MouseDown += (sender, args) => { // Double click if (args.ClickCount == 2) { TextBlock b = sender as TextBlock; if (b.Text != "") { CurrentCodeFile.DeleteBookmark((int)b.Tag); UpdateView(); } else { bool foundFirstEmptyKey = false; int key = 0; while (!foundFirstEmptyKey) { foundFirstEmptyKey = (CurrentCodeFile.Bookmarks.Count(bookmark => bookmark.Key == key) == 0); key++; } int line = (int)b.Tag; CurrentCodeFile.AddBookmark(line, key - 1); UpdateView(); } } }; }