Esempio n. 1
0
		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			if (value is string) {
				string[] v = ((string)value).Split('|');
				
				FileName fileName = FileName.Create(v[1]);
				int lineNumber = int.Parse(v[2], culture);
				int columnNumber = int.Parse(v[3], culture);
				if (lineNumber < 0)
					return null;
				if (columnNumber < 0)
					return null;
				SDBookmark bookmark;
				switch (v[0]) {
					case "Breakpoint":
						Debugging.BreakpointAction action = Debugging.BreakpointAction.Break;
						string scriptLanguage = "";
						string script = "";
						action = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
						scriptLanguage = v[6];
						script = v[7];
					
						var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
						bbm.IsEnabled = bool.Parse(v[4]);
						bbm.Action = action;
						bbm.ScriptLanguage = scriptLanguage;
						bbm.Condition = script;
						bookmark = bbm;
						break;
					case "PinBookmark":
						var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber));
						pin.Comment = v[4];
						pin.PinPosition = 
							new Point
							{ 
								X = double.Parse(v[5], culture),
								Y = double.Parse(v[6], culture)
							};
								
						// pop-up nodes
						pin.SavedNodes = new System.Collections.Generic.List<Tuple<string, string, string>>();
						for (int i = 7; i < v.Length; i+=3) {
							pin.SavedNodes.Add(new Tuple<string, string, string>(v[i], v[i+1], v[i+2]));
						}
						
						bookmark = pin;
						break;
					default:
						bookmark = new Bookmark(fileName, new Location(columnNumber, lineNumber));
						break;
				}
				return bookmark;
			} else {
				return base.ConvertFrom(context, culture, value);
			}
		}
Esempio n. 2
0
        public static void RemoveNode(this PinBookmark mark, ITreeNode node)
        {
            if (mark == null)
            {
                throw new ArgumentNullException("mark is null");
            }
            if (node == null)
            {
                throw new ArgumentNullException("Node is null");
            }

            foreach (var currentNode in mark.Nodes)
            {
                if (node.FullName == currentNode.FullName)
                {
                    mark.Nodes.Remove(currentNode);
                    return;
                }
            }
        }
Esempio n. 3
0
        public static bool ContainsNode(this PinBookmark mark, ITreeNode node)
        {
            if (mark == null)
            {
                throw new ArgumentNullException("mark is null");
            }
            if (node == null)
            {
                throw new ArgumentNullException("Node is null");
            }

            foreach (var currentNode in mark.Nodes)
            {
                if (node.FullName == currentNode.FullName)
                {
                    return(true);
                }
            }

            return(false);
        }
		void PinButton_Checked(object sender, RoutedEventArgs e)
		{
			ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
			var editor = provider.TextEditor;
			if (editor == null) return;
			var node = (ITreeNode)(((ToggleButton)(e.OriginalSource)).DataContext);
			
			if (!string.IsNullOrEmpty(editor.FileName)) {
				
				// verify if at the line of the root there's a pin bookmark
				var pin = BookmarkManager.Bookmarks.Find(
					b => b is PinBookmark &&
					b.LineNumber == logicalPosition.Line &&
					b.FileName == editor.FileName) as PinBookmark;
				
				if (pin == null) {
					pin = new PinBookmark(editor.FileName, logicalPosition);
					// show pinned DebuggerPopup
					if (pin.Popup == null) {
						pin.Popup = new PinDebuggerControl();
						pin.Popup.Mark = pin;
						Rect rect = new Rect(this.DesiredSize);
						var point = this.PointToScreen(rect.TopRight);
						pin.Popup.Location = new Point { X = 500, Y = point.Y - 150 };
						pin.Nodes.Add(node);
						pin.Popup.ItemsSource = pin.Nodes;
					}
					
					// do actions
					pin.Popup.Open();
					BookmarkManager.AddMark(pin);
				}
				else
				{
					if (!pin.ContainsNode(node)) {
						pin.Nodes.Add(node);
						pin.Popup.ItemsSource = pin.Nodes;
					}
				}
			}
		}
Esempio n. 5
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                string[] v = ((string)value).Split('|');

                FileName fileName     = FileName.Create(v[1]);
                int      lineNumber   = int.Parse(v[2], culture);
                int      columnNumber = int.Parse(v[3], culture);
                if (lineNumber < 0)
                {
                    return(null);
                }
                if (columnNumber < 0)
                {
                    return(null);
                }
                SDBookmark bookmark;
                switch (v[0])
                {
                case "Breakpoint":
                    Debugging.BreakpointAction action = Debugging.BreakpointAction.Break;
                    string scriptLanguage             = "";
                    string script = "";
                    action         = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
                    scriptLanguage = v[6];
                    script         = v[7];

                    var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
                    bbm.IsEnabled      = bool.Parse(v[4]);
                    bbm.Action         = action;
                    bbm.ScriptLanguage = scriptLanguage;
                    bbm.Condition      = script;
                    bookmark           = bbm;
                    break;

                case "DecompiledBreakpointBookmark":
                    action         = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
                    scriptLanguage = v[6];
                    script         = v[7];

                    bbm                = new DecompiledBreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
                    bbm.IsEnabled      = bool.Parse(v[4]);
                    bbm.Action         = action;
                    bbm.ScriptLanguage = scriptLanguage;
                    bbm.Condition      = script;
                    bookmark           = bbm;
                    break;

                case "PinBookmark":
                    var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber));
                    pin.Comment     = v[4];
                    pin.PinPosition =
                        new Point
                    {
                        X = double.Parse(v[5], culture),
                        Y = double.Parse(v[6], culture)
                    };

                    // pop-up nodes
                    pin.SavedNodes = new System.Collections.Generic.List <Tuple <string, string, string> >();
                    for (int i = 7; i < v.Length; i += 3)
                    {
                        pin.SavedNodes.Add(new Tuple <string, string, string>(v[i], v[i + 1], v[i + 2]));
                    }

                    bookmark = pin;
                    break;

                default:
                    bookmark = new Bookmark(fileName, new Location(columnNumber, lineNumber));
                    break;
                }
                return(bookmark);
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }