Ejemplo n.º 1
0
        private void AddBookmark_OnClick(object sender, RoutedEventArgs e)
        {
            bool foundFirstEmptyKey = false;
            int  key = 0;

            while (!foundFirstEmptyKey)
            {
                foundFirstEmptyKey = (CurrentCodeFile.Bookmarks.Count(b => b.Key == key) == 0);
                key++;
            }

            TextBlock parent = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBlock;
            int       line   = (int)parent.Tag;

            CurrentCodeFile.AddBookmark(line, key - 1);
            codeEditor.UpdateBookmarks();
        }
Ejemplo n.º 2
0
        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();
                    }
                }
            };
        }
Ejemplo n.º 3
0
 private void OnAddBookmarkCommand(object sender, ExecutedRoutedEventArgs e)
 {
     CurrentCodeFile.AddBookmark(AvalonEditor.TextArea.Caret.Line, Convert.ToInt32(e.Parameter));
     BookmarksPanel.UpdateView();
 }