Пример #1
0
 /// <summary>
 /// Creates a new run of classified text.
 /// </summary>
 /// <param name="classificationTypeName">
 /// A name indicating a <see cref="IClassificationType"/> that maps to a format that will be applied to the text.
 /// </param>
 /// <param name="text">The text rendered by this run.</param>
 /// <param name="style">The style that will be applied to the text.</param>
 /// <remarks>
 /// Classification types can be platform specific. Only classifications defined in PredefinedClassificationTypeNames
 /// are supported cross platform.
 /// </remarks>
 public ClassifiedTextRun(string classificationTypeName, string text, ClassifiedTextRunStyle style)
 {
     this.ClassificationTypeName = classificationTypeName
                                   ?? throw new ArgumentNullException(nameof(classificationTypeName));
     this.Text  = text ?? throw new ArgumentNullException(nameof(text));
     this.Style = style;
 }
Пример #2
0
 internal static void AssertExpectedClassification(
     ClassifiedTextRun run,
     string expectedText,
     string expectedClassificationType,
     ClassifiedTextRunStyle expectedClassificationStyle = ClassifiedTextRunStyle.Plain)
 {
     Assert.Equal(expectedText, run.Text);
     Assert.Equal(expectedClassificationType, run.ClassificationTypeName);
     Assert.Equal(expectedClassificationStyle, run.Style);
 }
Пример #3
0
        private static string TextRunStyleToString(ClassifiedTextRunStyle style)
        {
            var stringValue = style.ToString();

            return(string.Join(
                       " Or ",
                       stringValue
                       .Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
                       .Select(value => $"{nameof(ClassifiedTextRunStyle)}.{value}")
                       ));
        }
Пример #4
0
        /// <summary>
        /// Creates a new run of classified text.
        /// </summary>
        /// <param name="classificationTypeName">
        /// A name indicating a <see cref="IClassificationType"/> that maps to a format that will be applied to the text.
        /// </param>
        /// <param name="text">The text rendered by this run.</param>
        /// <param name="style">The style that will be applied to the text.</param>
        /// <remarks>
        /// Classification types can be platform specific. Only classifications defined in PredefinedClassificationTypeNames
        /// are supported cross platform.
        /// </remarks>
        public ClassifiedTextRun(
            string classificationTypeName,
            string text,
            Action navigationAction,
            string tooltip = null,
            ClassifiedTextRunStyle style = ClassifiedTextRunStyle.Plain)
        {
            this.ClassificationTypeName = classificationTypeName
                                          ?? throw new ArgumentNullException(nameof(classificationTypeName));
            this.Text  = text ?? throw new ArgumentNullException(nameof(text));
            this.Style = style;

            this.NavigationAction = navigationAction ?? throw new ArgumentNullException(nameof(navigationAction));
            this.Tooltip          = tooltip;
        }