public static void Clear() { while (bookmarks.Count > 0) { SDBookmark b = bookmarks[bookmarks.Count - 1]; bookmarks.RemoveAt(bookmarks.Count - 1); OnRemoved(new BookmarkEventArgs(b)); } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string[] v = ((string)value).Split('|'); if (v.Length != 8) { return(null); } FileName fileName = FileName.Create(v[1]); int lineNumber = int.Parse(v[2], culture); int columnNumber = int.Parse(v[3], culture); Debugging.BreakpointAction action = Debugging.BreakpointAction.Break; string scriptLanguage = ""; string script = ""; if (v[0] == "Breakpoint") { action = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]); scriptLanguage = v[6]; script = v[7]; } if (lineNumber < 0) { return(null); } if (columnNumber < 0) { return(null); } SDBookmark bookmark; switch (v[0]) { case "Breakpoint": var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script); bbm.IsEnabled = bool.Parse(v[4]); bookmark = bbm; break; default: bookmark = new SDBookmark(fileName, new Location(columnNumber, lineNumber)); break; } return(bookmark); } else { return(base.ConvertFrom(context, culture, value)); } }
public static void AddMark(SDBookmark bookmark) { if (bookmark == null) { return; } if (bookmarks.Contains(bookmark)) { return; } if (bookmarks.Exists(b => IsEqualBookmark(b, bookmark))) { return; } bookmarks.Add(bookmark); OnAdded(new BookmarkEventArgs(bookmark)); }
private static bool IsEqualBookmark(SDBookmark a, SDBookmark b) { if (a == b) { return(true); } if (a == null || b == null) { return(false); } if (a.GetType() != b.GetType()) { return(false); } if (a.FileName != b.FileName) { return(false); } return(a.LineNumber == b.LineNumber); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { SDBookmark bookmark = value as SDBookmark; if (destinationType == typeof(string) && bookmark != null) { StringBuilder b = new StringBuilder(); if (bookmark is Debugging.BreakpointBookmark) { b.Append("Breakpoint"); } else { b.Append("Bookmark"); } b.Append('|'); b.Append(bookmark.FileName); b.Append('|'); b.Append(bookmark.LineNumber); b.Append('|'); b.Append(bookmark.ColumnNumber); if (bookmark is Debugging.BreakpointBookmark) { Debugging.BreakpointBookmark bbm = (Debugging.BreakpointBookmark)bookmark; b.Append('|'); b.Append(bbm.IsEnabled.ToString()); b.Append('|'); b.Append(bbm.Action.ToString()); b.Append('|'); b.Append(bbm.ScriptLanguage); b.Append('|'); b.Append(bbm.Condition); } return(b.ToString()); } else { return(base.ConvertTo(context, culture, value, destinationType)); } }
public static void RemoveMark(SDBookmark bookmark) { bookmarks.Remove(bookmark); OnRemoved(new BookmarkEventArgs(bookmark)); }
public BookmarkEventArgs(SDBookmark bookmark) { this.bookmark = bookmark; }