Пример #1
0
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			var vm = value as BreakpointVM;
			if (vm == null)
				return null;
			var s = parameter as string;
			if (s == null)
				return null;

			if (StringComparer.OrdinalIgnoreCase.Equals(s, "Image")) {
				string img = vm.IsEnabled ? "Breakpoint" : "DisabledBreakpoint";
				return ImageCache.Instance.GetImage(img, BackgroundType.GridViewItem);
			}

			var gen = UISyntaxHighlighter.Create(DebuggerSettings.Instance.SyntaxHighlightBreakpoints);
			var printer = new BreakpointPrinter(gen.TextOutput, DebuggerSettings.Instance.UseHexadecimal);
			if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name"))
				printer.WriteName(vm);
			else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Assembly"))
				printer.WriteAssembly(vm);
			else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Module"))
				printer.WriteModule(vm);
			else if (StringComparer.OrdinalIgnoreCase.Equals(s, "File"))
				printer.WriteFile(vm);
			else
				return null;

			return gen.CreateTextBlock(true);
		}
Пример #2
0
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			var vm = value as BreakpointVM;
			if (vm == null)
				return null;
			var s = parameter as string;
			if (s == null)
				return null;

			if (StringComparer.OrdinalIgnoreCase.Equals(s, "Image")) {
				string img = vm.IsEnabled ? "Breakpoint" : "DisabledBreakpoint";
				return vm.Context.ImageManager.GetImage(GetType().Assembly, img, BackgroundType.GridViewItem);
			}

			var gen = UISyntaxHighlighter.Create(vm.Context.SyntaxHighlight);
			var printer = new BreakpointPrinter(gen.Output, vm.Context.UseHexadecimal, vm.Context.Language);
			if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name"))
				printer.WriteName(vm);
			else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Assembly"))
				printer.WriteAssembly(vm);
			else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Module"))
				printer.WriteModule(vm);
			else if (StringComparer.OrdinalIgnoreCase.Equals(s, "File"))
				printer.WriteFile(vm);
			else
				return null;

			return gen.CreateResult(true);
		}
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			var vm = value as BreakpointVM;
			if (vm == null)
				return null;
			var tag = parameter as string;
			if (tag == null)
				return null;

			var writer = Cache.GetWriter();
			try {
				var printer = new BreakpointPrinter(writer, vm.Context.UseHexadecimal, vm.Context.Decompiler);
				if (tag == PredefinedTextClassifierTags.BreakpointsWindowName)
					printer.WriteName(vm);
				else if (tag == PredefinedTextClassifierTags.BreakpointsWindowAssembly)
					printer.WriteAssembly(vm);
				else if (tag == PredefinedTextClassifierTags.BreakpointsWindowModule)
					printer.WriteModule(vm);
				else if (tag == PredefinedTextClassifierTags.BreakpointsWindowFile)
					printer.WriteFile(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.BreakpointsWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis);
			}
			finally {
				Cache.FreeWriter(writer);
			}
		}