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

			var writer = Cache.GetWriter();
			try {
				var printer = new TabPrinter(writer);
				if (tag == PredefinedTextClassifierTags.TabsDialogName)
					printer.WriteName(vm);
				else if (tag == PredefinedTextClassifierTags.TabsDialogModule)
					printer.WriteModule(vm);
				else if (tag == PredefinedTextClassifierTags.TabsDialogPath)
					printer.WritePath(vm);
				else
					return null;

				var context = new TextClassifierContext(writer.Text, tag, vm.Owner.Settings.SyntaxHighlight, writer.Colors);
				return vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.TabsDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis);
			}
			finally {
				Cache.FreeWriter(writer);
			}
		}
Пример #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var vm = value as TabVM;
            var s  = parameter as string;

            if (vm == null || s == null)
            {
                return(null);
            }

            var gen     = ColorizedTextElementProvider.Create(vm.Owner.Settings.SyntaxHighlight);
            var printer = new TabPrinter(gen.Output);

            if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name"))
            {
                printer.WriteName(vm);
            }
            else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Module"))
            {
                printer.WriteModule(vm);
            }
            else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Path"))
            {
                printer.WritePath(vm);
            }
            else
            {
                return(null);
            }

            return(gen.CreateResult(true));
        }
Пример #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var vm  = value as TabVM;
            var tag = parameter as string;

            if (vm == null || tag == null)
            {
                return(null);
            }

            var writer = Cache.GetWriter();

            try {
                var printer = new TabPrinter(writer);
                if (tag == PredefinedTextClassifierTags.TabsDialogName)
                {
                    printer.WriteName(vm);
                }
                else if (tag == PredefinedTextClassifierTags.TabsDialogModule)
                {
                    printer.WriteModule(vm);
                }
                else if (tag == PredefinedTextClassifierTags.TabsDialogPath)
                {
                    printer.WritePath(vm);
                }
                else
                {
                    return(null);
                }

                var context = new TextClassifierContext(writer.Text, tag, vm.Owner.Settings.SyntaxHighlight, writer.Colors);
                return(vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.TabsDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis));
            }
            finally {
                Cache.FreeWriter(writer);
            }
        }