Пример #1
0
 public static void Update(BookmarkInfo info)
 {
     XmlNodeList nodelist = ConfigDoc.SelectSingleNode("/TXTReaderConfig/bookmark").ChildNodes;
     foreach (XmlNode xn in nodelist)
     {
         XmlElement xe = (XmlElement)xn;
         if (xe.Attributes["id"].Value == info.id.ToString())
         {
             xe.SetAttribute("markedindex", info.MarkedIndex.ToString());
             break;
         }
     }
     ConfigDoc.Save(ConfigfilePath);
 }
Пример #2
0
        public static void Add(BookmarkInfo info)
        {
            XmlNode objNode = ConfigDoc.SelectSingleNode("/TXTReaderConfig/bookmark");
            XmlElement objElement = ConfigDoc.CreateElement("item");
            objElement.SetAttribute("id", Guid.NewGuid().ToString());
            objElement.SetAttribute("classid", info.ClassID.ToString());
            objElement.SetAttribute("bookname", info.BookName);
            objElement.SetAttribute("markedindex", info.MarkedIndex.ToString());
            objElement.SetAttribute("filepath", info.FilePath);
            //objElement.InnerText = info.BookName;
            objNode.AppendChild(objElement);
            ConfigDoc.Save(ConfigfilePath);

            //List<Natsuhime.XmlAttribInfo> arribs = new List<Natsuhime.XmlAttribInfo>();
            //arribs.Add(new XmlAttribInfo("classid     ", info.ClassID.ToString()             ));
            //arribs.Add(new XmlAttribInfo("markedindex ", info.MarkedIndex.ToString()             ));
            //arribs.Add(new XmlAttribInfo("filepath    ", info.FilePath                  ));
            //XmlHelper.XmlInsertElement(ConfigfilePath, "/TXTReaderConfig/bookmark", "item", arribs, info.BookName);
        }
Пример #3
0
 public static List<BookmarkInfo> GetBookmarkList()
 {
     List<BookmarkInfo> bookmarklist = new List<BookmarkInfo>();
     XmlNode objNode = ConfigDoc.SelectSingleNode("/TXTReaderConfig/bookmark");
     foreach (XmlNode n in objNode.ChildNodes)
     {
         BookmarkInfo info = new BookmarkInfo();
         info.id = n.Attributes["id"].Value;
         info.ClassID = Convert.ToInt32(n.Attributes["classid"].Value);
         info.BookName = n.Attributes["bookname"].Value;
         info.MarkedIndex = Convert.ToInt32(n.Attributes["markedindex"].Value);
         info.FilePath = n.Attributes["filepath"].Value;
         bookmarklist.Add(info);
         //foreach (XmlAttribute a in n.Attributes)
         //{
         //    //a.
         //}
     }
     return bookmarklist;
 }
Пример #4
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("还没有打开任何文件,无法加入书签.");
            }
        }