コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var vm = value as DocumentListVM;
            var s  = parameter as string;

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

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

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

            return(gen.CreateResult(true));
        }
コード例 #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var vm  = value as DocumentListVM;
            var tag = parameter as string;

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

            var writer = Cache.GetWriter();

            try {
                var printer = new DocumentListPrinter(writer);
                if (tag == PredefinedTextClassifierTags.DocListDialogName)
                {
                    printer.WriteName(vm);
                }
                else if (tag == PredefinedTextClassifierTags.DocListDialogCount)
                {
                    printer.WriteDocumentCount(vm);
                }
                else
                {
                    return(null);
                }

                var context = new OpenDocumentListTextClassifierContext(vm.Owner.SearchText, writer.Text, tag, vm.Owner.SyntaxHighlight, writer.Colors);
                return(vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.DocListDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis));
            }
            finally {
                Cache.FreeWriter(writer);
            }
        }
コード例 #3
0
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			var vm = value as DocumentListVM;
			var tag = parameter as string;
			if (vm == null || tag == null)
				return null;

			var writer = Cache.GetWriter();
			try {
				var printer = new DocumentListPrinter(writer);
				if (tag == PredefinedTextClassifierTags.DocListDialogName)
					printer.WriteName(vm);
				else if (tag == PredefinedTextClassifierTags.DocListDialogCount)
					printer.WriteDocumentCount(vm);
				else
					return null;

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