public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var s = parameter as string; if (vm == null || s == null) return null; if (StringComparer.OrdinalIgnoreCase.Equals(s, "CurrentImage")) { if (vm.IsCurrent) return vm.Context.ImageManager.GetImage(GetType().Assembly, "CurrentLine", BackgroundType.GridViewItem); if (vm.Type == ThreadType.Main) return vm.Context.ImageManager.GetImage(GetType().Assembly, "DraggedCurrentInstructionPointer", BackgroundType.GridViewItem); return null; } if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryImage")) { switch (vm.Type) { case ThreadType.Unknown: case ThreadType.Terminated: return vm.Context.ImageManager.GetImage(GetType().Assembly, "QuestionMark", BackgroundType.GridViewItem); case ThreadType.Main: return vm.Context.ImageManager.GetImage(GetType().Assembly, "Thread", BackgroundType.GridViewItem); case ThreadType.BGCOrFinalizer: case ThreadType.ThreadPool: case ThreadType.Worker: return vm.Context.ImageManager.GetImage(GetType().Assembly, "Process", BackgroundType.GridViewItem); default: Debug.Fail(string.Format("Unknown thread type: {0}", vm.Type)); goto case ThreadType.Unknown; } } var gen = UISyntaxHighlighter.Create(vm.Context.SyntaxHighlight); var printer = new ThreadPrinter(gen.Output, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (StringComparer.OrdinalIgnoreCase.Equals(s, "Id")) printer.WriteId(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "ManagedId")) printer.WriteManagedId(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryText")) printer.WriteCategory(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name")) printer.WriteName(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Location")) printer.WriteLocation(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Priority")) printer.WritePriority(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AffinityMask")) printer.WriteAffinityMask(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Suspended")) printer.WriteSuspended(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Process")) printer.WriteProcess(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AppDomain")) printer.WriteAppDomain(vm); else if (StringComparer.OrdinalIgnoreCase.Equals(s, "UserState")) printer.WriteUserState(vm); else return null; return gen.CreateResult(true); }
public override void Execute(ThreadsCtxMenuContext context) { var output = new StringBuilderTextColorOutput(); foreach (var vm in context.SelectedItems) { var printer = new ThreadPrinter(output, debuggerSettings.UseHexadecimal, theDebugger.Value.Debugger); printer.WriteCurrent(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteId(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteManagedId(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteCategory(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteName(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteLocation(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WritePriority(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAffinityMask(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteSuspended(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteProcess(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAppDomain(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteUserState(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var tag = parameter as string; if (vm == null || tag == null) return null; var writer = Cache.GetWriter(); try { var printer = new ThreadPrinter(writer, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (tag == PredefinedTextClassifierTags.ThreadsWindowId) printer.WriteId(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowManagedId) printer.WriteManagedId(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowCategoryText) printer.WriteCategory(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowName) printer.WriteName(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowLocation) printer.WriteLocation(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowPriority) printer.WritePriority(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowAffinityMask) printer.WriteAffinityMask(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowSuspended) printer.WriteSuspended(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowProcess) printer.WriteProcess(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowAppDomain) printer.WriteAppDomain(vm); else if (tag == PredefinedTextClassifierTags.ThreadsWindowUserState) printer.WriteUserState(vm); else return null; var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); return vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.ThreadsWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis); } finally { Cache.FreeWriter(writer); } }
public override void Execute(ThreadsCtxMenuContext context) { var output = new NoSyntaxHighlightOutput(); foreach (var vm in context.SelectedItems) { var printer = new ThreadPrinter(output, debuggerSettings.UseHexadecimal, theDebugger.Value.Debugger); printer.WriteCurrent(vm); output.Write("\t", TextTokenKind.Text); printer.WriteId(vm); output.Write("\t", TextTokenKind.Text); printer.WriteManagedId(vm); output.Write("\t", TextTokenKind.Text); printer.WriteCategory(vm); output.Write("\t", TextTokenKind.Text); printer.WriteName(vm); output.Write("\t", TextTokenKind.Text); printer.WriteLocation(vm); output.Write("\t", TextTokenKind.Text); printer.WritePriority(vm); output.Write("\t", TextTokenKind.Text); printer.WriteAffinityMask(vm); output.Write("\t", TextTokenKind.Text); printer.WriteSuspended(vm); output.Write("\t", TextTokenKind.Text); printer.WriteProcess(vm); output.Write("\t", TextTokenKind.Text); printer.WriteAppDomain(vm); output.Write("\t", TextTokenKind.Text); printer.WriteUserState(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { Clipboard.SetText(s); } }
protected override void Execute(ThreadsCtxMenuContext context) { var output = new PlainTextOutput(); foreach (var vm in context.SelectedItems) { var printer = new ThreadPrinter(output, DebuggerSettings.Instance.UseHexadecimal); printer.WriteCurrent(vm); output.Write('\t', TextTokenType.Text); printer.WriteId(vm); output.Write('\t', TextTokenType.Text); printer.WriteManagedId(vm); output.Write('\t', TextTokenType.Text); printer.WriteCategory(vm); output.Write('\t', TextTokenType.Text); printer.WriteName(vm); output.Write('\t', TextTokenType.Text); printer.WriteLocation(vm); output.Write('\t', TextTokenType.Text); printer.WritePriority(vm); output.Write('\t', TextTokenType.Text); printer.WriteAffinityMask(vm); output.Write('\t', TextTokenType.Text); printer.WriteSuspended(vm); output.Write('\t', TextTokenType.Text); printer.WriteProcess(vm); output.Write('\t', TextTokenType.Text); printer.WriteAppDomain(vm); output.Write('\t', TextTokenType.Text); printer.WriteUserState(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { Clipboard.SetText(s); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var s = parameter as string; if (vm == null || s == null) { return(null); } if (StringComparer.OrdinalIgnoreCase.Equals(s, "CurrentImage")) { if (vm.IsCurrent) { return(vm.Context.ImageManager.GetImage(new ImageReference(GetType().Assembly, "CurrentStatement"), BackgroundType.GridViewItem)); } if (vm.Type == ThreadType.Main) { return(vm.Context.ImageManager.GetImage(new ImageReference(GetType().Assembly, "DraggedCurrentInstructionPointer"), BackgroundType.GridViewItem)); } return(null); } if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryImage")) { switch (vm.Type) { case ThreadType.Unknown: case ThreadType.Terminated: return(vm.Context.ImageManager.GetImage(new ImageReference(GetType().Assembly, "QuestionMark"), BackgroundType.GridViewItem)); case ThreadType.Main: return(vm.Context.ImageManager.GetImage(new ImageReference(GetType().Assembly, "Thread"), BackgroundType.GridViewItem)); case ThreadType.BGCOrFinalizer: case ThreadType.ThreadPool: case ThreadType.Worker: return(vm.Context.ImageManager.GetImage(new ImageReference(GetType().Assembly, "Process"), BackgroundType.GridViewItem)); default: Debug.Fail(string.Format("Unknown thread type: {0}", vm.Type)); goto case ThreadType.Unknown; } } var gen = ColorizedTextElementProvider.Create(vm.Context.SyntaxHighlight); var printer = new ThreadPrinter(gen.Output, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (StringComparer.OrdinalIgnoreCase.Equals(s, "Id")) { printer.WriteId(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "ManagedId")) { printer.WriteManagedId(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryText")) { printer.WriteCategory(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name")) { printer.WriteName(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Location")) { printer.WriteLocation(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Priority")) { printer.WritePriority(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AffinityMask")) { printer.WriteAffinityMask(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Suspended")) { printer.WriteSuspended(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Process")) { printer.WriteProcess(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AppDomain")) { printer.WriteAppDomain(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "UserState")) { printer.WriteUserState(vm); } else { return(null); } return(gen.CreateResult(true)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var s = parameter as string; if (vm == null || s == null) { return(null); } if (StringComparer.OrdinalIgnoreCase.Equals(s, "CurrentImage")) { if (vm.IsCurrent) { return(ImageCache.Instance.GetImage("CurrentLine", BackgroundType.GridViewItem)); } if (vm.Type == ThreadType.Main) { return(ImageCache.Instance.GetImage("DraggedCurrentInstructionPointer", BackgroundType.GridViewItem)); } return(null); } if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryImage")) { switch (vm.Type) { case ThreadType.Unknown: case ThreadType.Terminated: return(ImageCache.Instance.GetImage("QuestionMark", BackgroundType.GridViewItem)); case ThreadType.Main: return(ImageCache.Instance.GetImage("Thread", BackgroundType.GridViewItem)); case ThreadType.BGCOrFinalizer: case ThreadType.ThreadPool: case ThreadType.Worker: return(ImageCache.Instance.GetImage("Process", BackgroundType.GridViewItem)); default: Debug.Fail(string.Format("Unknown thread type: {0}", vm.Type)); goto case ThreadType.Unknown; } } var gen = UISyntaxHighlighter.Create(DebuggerSettings.Instance.SyntaxHighlightThreads); var printer = new ThreadPrinter(gen.TextOutput, DebuggerSettings.Instance.UseHexadecimal); if (StringComparer.OrdinalIgnoreCase.Equals(s, "Id")) { printer.WriteId(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "ManagedId")) { printer.WriteManagedId(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryText")) { printer.WriteCategory(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name")) { printer.WriteName(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Location")) { printer.WriteLocation(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Priority")) { printer.WritePriority(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AffinityMask")) { printer.WriteAffinityMask(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Suspended")) { printer.WriteSuspended(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Process")) { printer.WriteProcess(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AppDomain")) { printer.WriteAppDomain(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "UserState")) { printer.WriteUserState(vm); } else { return(null); } return(gen.CreateTextBlock(true)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var s = parameter as string; if (vm == null || s == null) { return(null); } var gen = ColorizedTextElementProvider.Create(vm.Context.SyntaxHighlight); var printer = new ThreadPrinter(gen.Output, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (StringComparer.OrdinalIgnoreCase.Equals(s, "Id")) { printer.WriteId(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "ManagedId")) { printer.WriteManagedId(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "CategoryText")) { printer.WriteCategory(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name")) { printer.WriteName(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Location")) { printer.WriteLocation(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Priority")) { printer.WritePriority(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AffinityMask")) { printer.WriteAffinityMask(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Suspended")) { printer.WriteSuspended(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Process")) { printer.WriteProcess(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "AppDomain")) { printer.WriteAppDomain(vm); } else if (StringComparer.OrdinalIgnoreCase.Equals(s, "UserState")) { printer.WriteUserState(vm); } else { return(null); } return(gen.CreateResult(true)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var tag = parameter as string; if (vm == null || tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new ThreadPrinter(writer, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (tag == PredefinedTextClassifierTags.ThreadsWindowId) { printer.WriteId(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowManagedId) { printer.WriteManagedId(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowCategoryText) { printer.WriteCategory(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowName) { printer.WriteName(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowLocation) { printer.WriteLocation(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowPriority) { printer.WritePriority(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowAffinityMask) { printer.WriteAffinityMask(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowSuspended) { printer.WriteSuspended(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowProcess) { printer.WriteProcess(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowAppDomain) { printer.WriteAppDomain(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowUserState) { printer.WriteUserState(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); return(vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.ThreadsWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }