Esempio n. 1
0
        private void GoTo(BookmarkInfo bookmark)
        {
            TbInfo info = bookmark.tb.Tag as TbInfo;

            try
            {
                CurrentTB = bookmark.tb;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (bookmark.iBookmark < 0 || bookmark.iBookmark >= info.bookmarks.Count)
            {
                return;
            }

            int id = info.bookmarks[bookmark.iBookmark];

            for (int i = 0; i < CurrentTB.LinesCount; i++)
            {
                if (CurrentTB[i].UniqueId == id)
                {
                    CurrentTB.Selection.Start = new Place(0, i);
                    CurrentTB.DoSelectionVisible();
                    CurrentTB.Invalidate();
                    break;
                }
            }
        }
Esempio n. 2
0
        void tb_PaintLine(object sender, PaintLineEventArgs e)
        {
            TbInfo info = (sender as FastColoredTextBox).Tag as TbInfo;

            //draw bookmark
            if (info.bookmarksLineId.Contains((sender as FastColoredTextBox)[e.LineIndex].UniqueId))
            {
                e.Graphics.FillEllipse(new LinearGradientBrush(new Rectangle(0, e.LineRect.Top, 15, 15), Color.White, Color.PowderBlue, 45), 0, e.LineRect.Top, 15, 15);
                e.Graphics.DrawEllipse(Pens.PowderBlue, 0, e.LineRect.Top, 15, 15);
            }
        }
Esempio n. 3
0
        void tb_LineRemoved(object sender, LineRemovedEventArgs e)
        {
            TbInfo info = (sender as FastColoredTextBox).Tag as TbInfo;

            //remove lines from bookmarks
            foreach (int id in e.RemovedLineUniqueIds)
            {
                if (info.bookmarksLineId.Contains(id))
                {
                    info.bookmarksLineId.Remove(id);
                    info.bookmarks.Remove(id);
                }
            }
        }
Esempio n. 4
0
 private void gotoButton_DropDownOpening(object sender, EventArgs e)
 {
     gotoButton.DropDownItems.Clear();
     foreach (Control tab in tsFiles.Items)
     {
         FastColoredTextBox tb   = tab.Controls[0] as FastColoredTextBox;
         TbInfo             info = tb.Tag as TbInfo;
         for (int i = 0; i < info.bookmarks.Count; i++)
         {
             var item = gotoButton.DropDownItems.Add("Bookmark " + gotoButton.DropDownItems.Count + " [" + Path.GetFileNameWithoutExtension(tab.Tag as String) + "]");
             item.Tag = new BookmarkInfo()
             {
                 tb = tb, iBookmark = i
             };
             item.Click += (o, a) => GoTo((BookmarkInfo)(o as ToolStripItem).Tag);
         }
     }
 }
Esempio n. 5
0
        private void bookmarkPlusButton_Click(object sender, EventArgs e)
        {
            if (CurrentTB == null)
            {
                return;
            }
            TbInfo info = CurrentTB.Tag as TbInfo;
            //get UniqueId of current line
            int id = CurrentTB[CurrentTB.Selection.Start.iLine].UniqueId;

            if (info.bookmarksLineId.Contains(id))
            {
                return;
            }
            //add bookmark
            info.bookmarks.Add(id);
            info.bookmarksLineId.Add(id);
            //repaint
            CurrentTB.Invalidate();
        }