Exemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var vm = value as GACFileVM;
            var s  = parameter as string;

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

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

            if (StringComparer.OrdinalIgnoreCase.Equals(s, "Name"))
            {
                printer.WriteName(vm);
            }
            else if (StringComparer.OrdinalIgnoreCase.Equals(s, "Version"))
            {
                printer.WriteVersion(vm);
            }
            else
            {
                return(null);
            }

            return(gen.CreateResult(true));
        }
Exemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var vm  = value as GACFileVM;
            var tag = parameter as string;

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

            var writer = Cache.GetWriter();

            try {
                var printer = new GACFilePrinter(writer);
                if (tag == PredefinedTextClassifierTags.GacDialogName)
                {
                    printer.WriteName(vm);
                }
                else if (tag == PredefinedTextClassifierTags.GacDialogVersion)
                {
                    printer.WriteVersion(vm);
                }
                else
                {
                    return(null);
                }

                var context = new OpenFromGACTextClassifierContext(vm.Owner.SearchText, writer.Text, tag, vm.Owner.SyntaxHighlight, writer.Colors);
                return(vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.GacDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis));
            }
            finally {
                Cache.FreeWriter(writer);
            }
        }
Exemplo n.º 3
0
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			var vm = value as GACFileVM;
			var tag = parameter as string;
			if (vm == null || tag == null)
				return null;

			var writer = Cache.GetWriter();
			try {
				var printer = new GACFilePrinter(writer);
				if (tag == PredefinedTextClassifierTags.GacDialogName)
					printer.WriteName(vm);
				else if (tag == PredefinedTextClassifierTags.GacDialogVersion)
					printer.WriteVersion(vm);
				else
					return null;

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