Пример #1
0
        //添加书签
        private void tsmiAddBookmark_Click(object sender, EventArgs e)
        {
            if (currentfilepath != null && currentfilepath != string.Empty)
            {
                int markedindex = rtbxMain.GetCharIndexFromPosition(new Point(0, 0));
                //int xx2 = rtbxMain.GetFirstCharIndexFromLine(1);

                List <BookmarkInfo> bmlist = bookmarklist.FindAll(
                    delegate(BookmarkInfo info)
                {
                    return(info.FilePath == currentfilepath);
                }
                    );
                if (bmlist.Count > 0)
                {
                    bmlist[0].MarkedIndex = markedindex;
                    Bookmark.Update(bmlist[0]);
                    MessageBox.Show("更新书签成功.");
                }
                else
                {
                    BookmarkInfo info;
                    info             = new BookmarkInfo();
                    info.BookName    = this.tsmiCurrentFilename.Text;
                    info.ClassID     = 0;
                    info.MarkedIndex = markedindex;
                    info.FilePath    = currentfilepath;
                    Bookmark.Add(info);
                    MessageBox.Show("添加书签成功.");
                }
                InitBookmarkMenu();
            }
            else
            {
                MessageBox.Show("还没有打开任何文件,无法加入书签.");
            }
        }