Пример #1
0
		protected void OnBookmarkTextChanged(Bookmark bookmark)
		{
			if (BookmarkTextChanged != null)
			{
				BookmarkTextChanged(new BookmarkEventArgs(bookmark));
			}
		}
Пример #2
0
		private static SortedList<int, Bookmark> ReadBookmarks(XmlElement startNode)
		{
			SortedList<int, Bookmark> bookmarkList = new SortedList<int, Bookmark>();
			XmlNode boomarksNode = startNode.SelectSingleNode("bookmarks");
			if (boomarksNode != null)
			{
				XmlNodeList bookmarkNodeList = boomarksNode.ChildNodes;   // all "bookmark" nodes
				foreach (XmlNode node in bookmarkNodeList)
				{
					string text = null;
					string posX = null;
					string posY = null;
					string line = null;
					foreach (XmlAttribute attr in node.Attributes)
					{
						if (attr.Name.Equals("line"))
						{
							line = attr.InnerText;
						}
					}
					foreach (XmlNode subNode in node.ChildNodes)
					{
						if (subNode.Name.Equals("text"))
						{
							text = subNode.InnerText;
						}
						else if (subNode.Name.Equals("posX"))
						{
							posX = subNode.InnerText;
						}
						else if (subNode.Name.Equals("posY"))
						{
							posY = subNode.InnerText;
						}
					}
					if (line == null || posX == null || posY == null)
					{
						Logger.logError("Invalid XML format for bookmark: " + node.InnerText);
						continue;
					}
					int lineNum = Int32.Parse(line);
					Bookmark bookmark = new Bookmark(lineNum);
					bookmark.OverlayOffset = new Size(Int32.Parse(posX), Int32.Parse(posY));
					if (text != null)
					{
						bookmark.Text = text;
					}
					bookmarkList.Add(lineNum, bookmark);
				}
			}
			return bookmarkList;
		}
Пример #3
0
        void AddBookmarkComment(string text)
        {
            int lineNum = dataGridView.CurrentCellAddress.Y;

            Bookmark bookmark = BookmarkProvider.GetBookmarkForLine(lineNum);

            if (bookmark == null)
            {
                bookmark = new Bookmark(lineNum);
                bookmark.Text = text;
            }
            else
            {
                bookmark.Text += text;
            }

            BookmarkProvider.AddOrUpdateBookmark(bookmark);

            dataGridView.Refresh();
            filterGridView.Refresh();
        }
Пример #4
0
 void BookmarkComment(Bookmark bookmark)
 {
     BookmarkCommentDlg dlg = new BookmarkCommentDlg();
     dlg.Comment = bookmark.Text;
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         BookmarkProvider.UpdateBookmarkText(bookmark, dlg.Comment);
         dataGridView.Refresh();
     }
 }
Пример #5
0
		public BookmarkEventArgs(Bookmark bookmark)
		{
			this.Bookmark = bookmark;
		}
Пример #6
0
		public void ImportBookmarkList(string logfileName, string fileName)
		{
			using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
			using (StreamReader reader = new StreamReader(fs))
			{
				if (!reader.EndOfStream)
				{
					reader.ReadLine(); // skip "Log file name;Line number;Comment"
				}
				
				while (!reader.EndOfStream)
				{
					try
					{
						string line = reader.ReadLine();
						line = line.Replace(REPLACEMENT_FOR_NEW_LINE, "\r\n").Replace("\\\r\n", REPLACEMENT_FOR_NEW_LINE);
						
						// Line is formatted: logfileName ";" bookmark.LineNum ";" bookmark.Text;
						int firstSeparator = line.IndexOf(';');
						int secondSeparator = line.IndexOf(';', firstSeparator + 1);
						
						string lineStr = line.Substring(firstSeparator + 1, secondSeparator - firstSeparator - 1);
						string comment = line.Substring(secondSeparator + 1);
						
						int lineNum;
						if (int.TryParse(lineStr, out lineNum))
						{
							Bookmark bookmark = new Bookmark(lineNum, comment);
							AddOrUpdateBookmark(bookmark);
						}
						else
						{
							//!!!log error: skipping a line entry
						}
					}
					catch
					{
						//!!!
					}
				}
			}
		}
Пример #7
0
		internal void UpdateBookmarkText(Bookmark bookmark, string text)
		{
			bookmark.Text = text;
			OnBookmarkTextChanged(bookmark);
		}
Пример #8
0
		internal void AddOrUpdateBookmark(Bookmark bookmark)
		{
			if (BookmarkList.ContainsKey(bookmark.LineNum))
			{
				AddBookmark(bookmark);
			}
			else
			{
				Bookmark existingBookmark = BookmarkList[bookmark.LineNum];
				existingBookmark.Text = bookmark.Text; // replace existing bookmark for that line, preserving the overlay
				OnBookmarkTextChanged(bookmark);
			}
		}
Пример #9
0
		internal void AddBookmark(Bookmark bookmark)
		{
			BookmarkList.Add(bookmark.LineNum, bookmark);
			OnBookmarkAdded();
		}
Пример #10
0
 internal void AddBookmark(Bookmark bookmark)
 {
     this.BookmarkList.Add(bookmark.LineNum, bookmark);
     OnBookmarkAdded();
 }
Пример #11
0
 public BookmarkEventArgs(Bookmark bookmark)
 {
     this.Bookmark = bookmark;
 }