Ejemplo n.º 1
0
        internal void OnTextWrappingChanged(TextWrapping tw)
        {
            if (INTERNAL_HtmlDomManager.IsNotUndefinedOrNull(_contentEditableDiv))
            {
                switch (tw)
                {
                case TextWrapping.NoWrap:
                    INTERNAL_HtmlDomManager.GetDomElementStyleForModification(_contentEditableDiv).whiteSpace = "nowrap";
                    break;

                case TextWrapping.Wrap:
                    INTERNAL_HtmlDomManager.GetDomElementStyleForModification(_contentEditableDiv).whiteSpace = "pre-wrap";
                    //todo: once we find how to make the note work, apply the same thing to the TextBlock.
                    //Note: the following line would be useful to break the words when they are too long without spaces.
                    //      unfortunately, it only works in chrome.
                    //      The other browsers have wordBreak = "break-all" but that doesn't take into account the spaces to break the string.
                    //          it means it will break words in two when it could have gone to the next line before starting the word that overflows in the line.
                    //INTERNAL_HtmlDomManager.GetDomElementStyleForModification(textBox._contentEditableDiv).wordBreak = "break-word";
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 private void SetTextOrientation(TextWrapping value)
 {
     if (value == TextWrapping.Wrap)
     {
         TextOrientation = Orientation.Vertical;
     }
 }
Ejemplo n.º 3
0
        public FormattedTextImpl(
            string text,
            string fontFamily,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight,
            TextWrapping wrapping)
        {
            var factory = AvaloniaLocator.Current.GetService <DWrite.Factory>();

            using (var format = new DWrite.TextFormat(
                       factory,
                       fontFamily,
                       (DWrite.FontWeight)fontWeight,
                       (DWrite.FontStyle)fontStyle,
                       (float)fontSize))
            {
                format.WordWrapping = wrapping == TextWrapping.Wrap ?
                                      DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap;

                TextLayout = new DWrite.TextLayout(
                    factory,
                    text ?? string.Empty,
                    format,
                    float.MaxValue,
                    float.MaxValue);
            }

            TextLayout.TextAlignment = textAlignment.ToDirect2D();
        }
 private void NotifyCellTextWrappingChanged(TextWrapping newvalue)
 {
     if (tb.IsNotNull())
     {
         tb.TextWrapping = newvalue;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextLayout" /> class.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="typeface">The typeface.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="foreground">The foreground.</param>
        /// <param name="textAlignment">The text alignment.</param>
        /// <param name="textWrapping">The text wrapping.</param>
        /// <param name="textTrimming">The text trimming.</param>
        /// <param name="textDecorations">The text decorations.</param>
        /// <param name="maxWidth">The maximum width.</param>
        /// <param name="maxHeight">The maximum height.</param>
        /// <param name="lineHeight">The height of each line of text.</param>
        /// <param name="maxLines">The maximum number of text lines.</param>
        /// <param name="textStyleOverrides">The text style overrides.</param>
        public TextLayout(
            string text,
            Typeface typeface,
            double fontSize,
            IBrush foreground,
            TextAlignment textAlignment = TextAlignment.Left,
            TextWrapping textWrapping   = TextWrapping.NoWrap,
            TextTrimming textTrimming   = TextTrimming.None,
            TextDecorationCollection textDecorations = null,
            double maxWidth   = double.PositiveInfinity,
            double maxHeight  = double.PositiveInfinity,
            double lineHeight = double.NaN,
            int maxLines      = 0,
            IReadOnlyList <ValueSpan <TextRunProperties> > textStyleOverrides = null)
        {
            _text = string.IsNullOrEmpty(text) ?
                    new ReadOnlySlice <char>() :
                    new ReadOnlySlice <char>(text.AsMemory());

            _paragraphProperties =
                CreateTextParagraphProperties(typeface, fontSize, foreground, textAlignment, textWrapping, textTrimming,
                                              textDecorations, lineHeight);

            _textStyleOverrides = textStyleOverrides;

            LineHeight = lineHeight;

            MaxWidth = maxWidth;

            MaxHeight = maxHeight;

            MaxLines = maxLines;

            UpdateLayout();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Method to change the text wrapping value of the annotation
        /// </summary>
        /// <param name="value">Text wrapping value</param>
        private void OnTextWrappingChanged(TextWrapping value)
        {
            foreach (NodeViewModel node in (this.SelectedItems as SelectorViewModel).Nodes as IEnumerable <object> )
            {
                foreach (IAnnotation annotation in node.Annotations as ObservableCollection <IAnnotation> )
                {
                    (annotation as TextAnnotationViewModel).TextWrapping = value;

                    if ((annotation as TextAnnotationViewModel).TextTrimming != TextTrimming.None && value == TextWrapping.NoWrap)
                    {
                        annotation.UnitWidth = 100;
                    }
                    else
                    {
                        annotation.UnitWidth = double.NaN;
                    }
                }
            }
            foreach (ConnectorViewModel conn in (this.SelectedItems as SelectorViewModel).Connectors as IEnumerable <object> )
            {
                foreach (IAnnotation annotation in conn.Annotations as ObservableCollection <IAnnotation> )
                {
                    (annotation as TextAnnotationViewModel).TextWrapping = value;

                    if ((annotation as TextAnnotationViewModel).TextTrimming != TextTrimming.None && value == TextWrapping.NoWrap)
                    {
                        annotation.UnitWidth = 100;
                    }
                    else
                    {
                        annotation.UnitWidth = double.NaN;
                    }
                }
            }
        }
Ejemplo n.º 7
0
            public List <List <InlineSegment> > WrapSegments()
            {
                _curLine = new List <InlineSegment>();
                _lines   = new List <List <InlineSegment> > {
                    _curLine
                };

                foreach (InlineSegment sourceSeg in _container._inlineSequence.Segments)
                {
                    if (sourceSeg.Color != null || sourceSeg.Background != null)
                    {
                        _curLine.Add(sourceSeg);
                    }
                    else
                    {
                        TextWrapping textWrap = _container.TextWrap;
                        if (textWrap == TextWrapping.NoWrap)
                        {
                            AppendTextSegmentNoWrap(sourceSeg);
                        }
                        else if (textWrap == TextWrapping.CharWrap)
                        {
                            AppendTextSegmentCharWrap(sourceSeg);
                        }
                        else if (textWrap == TextWrapping.WordWrap)
                        {
                            AppendTextSegmentWordWrap(sourceSeg);
                        }
                    }
                }
                return(_lines);
            }
Ejemplo n.º 8
0
        public FormattedTextImpl(string text, string fontFamilyName, double fontSize, FontStyle fontStyle,
                                 TextAlignment textAlignment, FontWeight fontWeight, TextWrapping wrapping)
        {
            _text = text ?? string.Empty;

            // Replace 0 characters with zero-width spaces (200B)
            _text = _text.Replace((char)0, (char)0x200B);

            var typeface = TypefaceCache.GetTypeface(fontFamilyName, fontStyle, fontWeight);

            _paint = new SKPaint();

            //currently Skia does not measure properly with Utf8 !!!
            //Paint.TextEncoding = SKTextEncoding.Utf8;
            _paint.TextEncoding = SKTextEncoding.Utf16;
            _paint.IsStroke     = false;
            _paint.IsAntialias  = true;
            _paint.Typeface     = typeface;
            _paint.TextSize     = (float)fontSize;
            _paint.TextAlign    = textAlignment.ToSKTextAlign();

            _wrapping = wrapping;

            Rebuild();
        }
Ejemplo n.º 9
0
        static TextElementFlags GetTextFlags(object ownerControl)
        {
            TextTrimming textTrimming = TextTrimming.None;
            TextWrapping textWrapping = TextWrapping.NoWrap;

            if (ownerControl is TextControl textControl)
            {
                textTrimming = textControl.TextTrimming;
                textWrapping = textControl.TextWrapping;
            }

            TextElementFlags flags = 0;

            switch (textTrimming)
            {
            case TextTrimming.None: flags |= TextElementFlags.NoTrimming; break;

            case TextTrimming.CharacterEllipsis: flags |= TextElementFlags.CharacterEllipsis; break;

            case TextTrimming.WordEllipsis: flags |= TextElementFlags.WordEllipsis; break;

            default: Debug.Fail($"Unknown trimming: {textTrimming}"); break;
            }
            switch (textWrapping)
            {
            case TextWrapping.WrapWithOverflow: flags |= TextElementFlags.WrapWithOverflow; break;

            case TextWrapping.NoWrap: flags |= TextElementFlags.NoWrap; break;

            case TextWrapping.Wrap: flags |= TextElementFlags.Wrap; break;

            default: Debug.Fail($"Unknown wrapping: {textWrapping}"); break;
            }
            return(flags);
        }
Ejemplo n.º 10
0
        public FormattedTextImpl(
            string text,
            string fontFamily,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight,
            TextWrapping wrapping)
        {
            var factory = AvaloniaLocator.Current.GetService<DWrite.Factory>();

            using (var format = new DWrite.TextFormat(
                factory,
                fontFamily,
                (DWrite.FontWeight)fontWeight,
                (DWrite.FontStyle)fontStyle,
                (float)fontSize))
            {
                format.WordWrapping = wrapping == TextWrapping.Wrap ? 
                    DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap;

                TextLayout = new DWrite.TextLayout(
                    factory,
                    text ?? string.Empty,
                    format,
                    float.MaxValue,
                    float.MaxValue);
            }

            TextLayout.TextAlignment = textAlignment.ToDirect2D();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the height required for the text block element without wrapping.
        /// </summary>
        /// <param name="textElement">Textblock whose width needs to be calculated.</param>
        /// <returns>Returns the height needed to show the text without wrapping.</returns>
        public static double GetDesiredHeight(TextBlock textElement)
        {
            double desiredHeight = 0;

#if SILVERLIGHT
            TextWrapping wrap = textElement.TextWrapping;
            textElement.TextWrapping = TextWrapping.NoWrap;
            desiredHeight            = textElement.ActualHeight;
            textElement.TextWrapping = wrap;
#else
            if (!string.IsNullOrEmpty(textElement.Text))
            {
                FormattedText formattedText = new FormattedText(textElement.Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new System.Windows.Media.Typeface(textElement.FontFamily.Source), textElement.FontSize, textElement.Foreground);
                formattedText.SetFontStyle(textElement.FontStyle);
                formattedText.SetFontWeight(textElement.FontWeight);
                desiredHeight = formattedText.Height;
            }
            else
            {
                desiredHeight = 0;
            }
#endif

            return(desiredHeight);
        }
Ejemplo n.º 12
0
        public void When_DefaultTextBlock_Wrap(TextWrapping wrappingMode)
        {
            var SUT = new TextBlockMeasureCache();

            var tb = new TextBlock {
                Text = "42", TextWrapping = wrappingMode
            };                                                                               // Used as key, never measured

            SUT.CacheMeasure(tb, new Size(200, 100), new Size(125, 25));
            SUT.CacheMeasure(tb, new Size(100, 100), new Size(100, 50));
            SUT.CacheMeasure(tb, new Size(75, 100), new Size(75, 100));
            SUT.CacheMeasure(tb, new Size(50, 100), new Size(50, 100));

            Assert.AreEqual(
                new Size(125, 25),
                SUT.FindMeasuredSize(tb, new Size(125, 100))
                );

            Assert.AreEqual(
                new Size(50, 100),
                SUT.FindMeasuredSize(tb, new Size(50, 70))
                );

            Assert.AreEqual(
                null,
                SUT.FindMeasuredSize(tb, new Size(52, 70))
                );

            Assert.AreEqual(
                null,
                SUT.FindMeasuredSize(tb, new Size(500, 500))
                );
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Builds a new layout with the specified parameters.
 /// </summary>
 public LayoutBuilder(
     Java.Lang.ICharSequence textFormatted,
     TextPaint paint,
     TextUtils.TruncateAt ellipsize,
     Android.Text.Layout.Alignment layoutAlignment,
     TextWrapping textWrapping,
     int maxLines,
     Size availableSize,
     bool exactWidth,
     float lineHeight,
     LineStackingStrategy lineStackingStrategy,
     LayoutBuilder existingBuilder
     )
 {
     _textFormatted        = textFormatted;
     _paint                = paint;
     _ellipsize            = ellipsize;
     _layoutAlignment      = layoutAlignment;
     _textWrapping         = textWrapping;
     _maxLines             = maxLines;
     AvailableSize         = availableSize;
     _exactWidth           = exactWidth;
     _lineHeight           = lineHeight;
     _lineStackingStrategy = lineStackingStrategy;
     Layout                = existingBuilder?.Layout;
     _metrics              = existingBuilder?._metrics;
 }
Ejemplo n.º 14
0
        public FormattedTextImpl(string text, string fontFamilyName, double fontSize, FontStyle fontStyle,
                    TextAlignment textAlignment, FontWeight fontWeight, TextWrapping wrapping)
        {
            _text = text ?? string.Empty;

            // Replace 0 characters with zero-width spaces (200B)
            _text = _text.Replace((char)0, (char)0x200B);

            var typeface = TypefaceCache.GetTypeface(fontFamilyName, fontStyle, fontWeight);

            _paint = new SKPaint();

            //currently Skia does not measure properly with Utf8 !!!
            //Paint.TextEncoding = SKTextEncoding.Utf8;
            _paint.TextEncoding = SKTextEncoding.Utf16;
            _paint.IsStroke = false;
            _paint.IsAntialias = true;            
            _paint.LcdRenderText = true;            
            _paint.SubpixelText = true;
            _paint.Typeface = typeface;
            _paint.TextSize = (float)fontSize;
            _paint.TextAlign = textAlignment.ToSKTextAlign();

            _wrapping = wrapping;

            Rebuild();
        }
 private async void EditorSettingsService_OnDefaultTextWrappingChanged(object sender, TextWrapping textWrapping)
 {
     await Dispatcher.CallOnUIThreadAsync(() =>
     {
         TextWrapping = textWrapping;
     });
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextLayout" /> class.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="typeface">The typeface.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="foreground">The foreground.</param>
        /// <param name="textAlignment">The text alignment.</param>
        /// <param name="textWrapping">The text wrapping.</param>
        /// <param name="textTrimming">The text trimming.</param>
        /// <param name="textDecorations">The text decorations.</param>
        /// <param name="flowDirection">The text flow direction.</param>
        /// <param name="maxWidth">The maximum width.</param>
        /// <param name="maxHeight">The maximum height.</param>
        /// <param name="lineHeight">The height of each line of text.</param>
        /// <param name="maxLines">The maximum number of text lines.</param>
        /// <param name="textStyleOverrides">The text style overrides.</param>
        public TextLayout(
            string?text,
            Typeface typeface,
            double fontSize,
            IBrush?foreground,
            TextAlignment textAlignment = TextAlignment.Left,
            TextWrapping textWrapping   = TextWrapping.NoWrap,
            TextTrimming?textTrimming   = null,
            TextDecorationCollection?textDecorations = null,
            FlowDirection flowDirection = FlowDirection.LeftToRight,
            double maxWidth             = double.PositiveInfinity,
            double maxHeight            = double.PositiveInfinity,
            double lineHeight           = double.NaN,
            int maxLines = 0,
            IReadOnlyList <ValueSpan <TextRunProperties> >?textStyleOverrides = null)
        {
            _paragraphProperties =
                CreateTextParagraphProperties(typeface, fontSize, foreground, textAlignment, textWrapping,
                                              textDecorations, flowDirection, lineHeight);

            _textSource = new FormattedTextSource(text.AsMemory(), _paragraphProperties.DefaultTextRunProperties, textStyleOverrides);

            _textTrimming = textTrimming ?? TextTrimming.None;

            LineHeight = lineHeight;

            MaxWidth = maxWidth;

            MaxHeight = maxHeight;

            MaxLines = maxLines;

            TextLines = CreateTextLines();
        }
Ejemplo n.º 17
0
 private void OnTextWrappingChanged(TextWrapping oldTextWrapping, TextWrapping newTextWrapping)
 {
     if (TemplateRoot != null)
     {
         TemplateRoot.TextWrapping = newTextWrapping;
     }
 }
Ejemplo n.º 18
0
 private TextLayout Create(string text, double fontSize, TextWrapping wrap, double widthConstraint)
 {
     return(Create(text, FontName, fontSize,
                   FontStyle.Normal, TextAlignment.Left,
                   FontWeight.Normal, wrap,
                   widthConstraint));
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Text" /> class.
        /// </summary>
        /// <param name="text">Text that will be drawn.</param>
        /// <param name="font">Font that will be used to draw the text.</param>
        /// <param name="foreground">Brush that will be used to paint the text.</param>
        /// <param name="background">Brush that will be used to paint the text's background.</param>
        /// <param name="left">Left position of the text.</param>
        /// <param name="top">Top position of the text.</param>
        /// <param name="width">Virtual text box width. If value is less than 0, it will be automatically computed.</param>
        /// <param name="height">Virtual text box height. If value is less than 0, it will be automatically computed.</param>
        /// <param name="horizontalAlignment">Text horizontal alignment.</param>
        /// <param name="verticalAlignment">Text vertical alignment.</param>
        /// <param name="wrapping">Text wrapping.</param>
        /// <param name="rotation">Text clockwise rotation in radians.</param>
        public Text(string text, IFont font, IBrush foreground, IBrush background, double left, double top, double width, double height, TextHorizontalAlignment horizontalAlignment, TextVerticalAlignment verticalAlignment, TextWrapping wrapping, double rotation)
        {
            Label               = text;
            Font                = font;
            Background          = background;
            Foreground          = foreground;
            Width               = width;
            Height              = height;
            HorizontalAlignment = horizontalAlignment;
            VerticalAlignment   = verticalAlignment;
            Wrapping            = wrapping;
            Rotation            = rotation;

            System.Windows.FontStyle fontStyle;

            switch (font.Style)
            {
            default:
            case FontStyle.Normal:
                fontStyle = System.Windows.FontStyles.Normal;
                break;

            case FontStyle.Italic:
                fontStyle = System.Windows.FontStyles.Italic;
                break;

            case FontStyle.Oblique:
                fontStyle = System.Windows.FontStyles.Oblique;
                break;
            }
            UIText = new System.Windows.Controls.TextBlock()
            {
                Text = text,
                HorizontalAlignment = (System.Windows.HorizontalAlignment)horizontalAlignment,
                VerticalAlignment   = (System.Windows.VerticalAlignment)((int)verticalAlignment - 1),
                Foreground          = (foreground as Brush)?.UIBrush,
                Background          = (background as Brush)?.UIBrush,
                FontFamily          = new System.Windows.Media.FontFamily(font.Family),
                FontSize            = font.Size,
                FontStyle           = fontStyle,
                FontWeight          = System.Windows.FontWeight.FromOpenTypeWeight((int)font.Weight),
                TextWrapping        = (System.Windows.TextWrapping)((int)wrapping + 1),
            };
            if (width >= 0)
            {
                UIText.Width = width;
            }
            if (height >= 0)
            {
                UIText.Height = height;
            }
            if (rotation != 0)
            {
                UIText.RenderTransform       = new System.Windows.Media.RotateTransform(rotation * 180 / Math.PI);
                UIText.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5);
            }
            System.Windows.Controls.Canvas.SetLeft(UIText, left);
            System.Windows.Controls.Canvas.SetTop(UIText, top);
        }
Ejemplo n.º 20
0
 public static void SetTextWrapping(DependencyObject element, TextWrapping value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(JapaneseTextBlock.TextWrappingProperty, value);
 }
Ejemplo n.º 21
0
        void OnRadioButtonChecked(object sender, RoutedEventArgs args)
        {
            var settings = ApplicationData.Current.LocalSettings;

            this.TextWrapping = (TextWrapping)(sender as RadioButton).Tag;

            settings.Values["TextWrapping"] = (int)this.TextWrapping;
        }
Ejemplo n.º 22
0
        void OnRadioButtonChecked(object sender, RoutedEventArgs args)
        {
            var settings = ApplicationData.Current.LocalSettings;

            this.TextWrapping = (TextWrapping)(sender as RadioButton).Tag;

            settings.Values["TextWrapping"] = (int)this.TextWrapping;
        }
Ejemplo n.º 23
0
        private void InitializeToastWithImgAndNoTitle(TextWrapping wrap = default(TextWrapping))
        {
            InitializePrompt();

            _prompt.Message      = LongText;
            _prompt.ImageSource  = new BitmapImage(new Uri("../../media/c4f_26x26.png", UriKind.RelativeOrAbsolute));
            _prompt.TextWrapping = wrap;
        }
        private void InitializeBasicToast(string title = "Basic", TextWrapping wrap = default(TextWrapping))
        {
            InitializePrompt();

            _prompt.Title        = title;
            _prompt.Message      = LongText;
            _prompt.TextWrapping = wrap;
        }
        private void InitializeToastWithImgAndNoTitle(TextWrapping wrap = default(TextWrapping))
        {
            InitializePrompt();

            _prompt.Message      = LongText;
            _prompt.ImageSource  = new BitmapImage(new Uri("ms-appx:/Media/c4f_26x26.png"));
            _prompt.TextWrapping = wrap;
        }
        private static void OnTextWrappingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RaisedText   rtext = d as RaisedText;
            TextWrapping wrap  = (TextWrapping)e.NewValue;

            rtext.DisplayText.TextWrapping     = wrap;
            rtext.DisplayTextBlur.TextWrapping = wrap;
        }
Ejemplo n.º 27
0
        private void InitializeToastWithImgAndNoTitle(TextWrapping wrap = default(TextWrapping))
        {
            InitializePrompt();

            _prompt.Message      = message;
            _prompt.ImageSource  = new BitmapImage(new Uri("/Assets/Images/add.png", UriKind.RelativeOrAbsolute));
            _prompt.TextWrapping = wrap;
        }
		private void InitializeBasicToast(string title = "Basic", TextWrapping wrap = default(TextWrapping))
		{
			InitializePrompt();

			_prompt.Title = title;
			_prompt.Message = LongText;
			_prompt.TextWrapping = wrap;
		}
Ejemplo n.º 29
0
        void InitSources()
        {
            TextWrapping[] wrapping = new TextWrapping[] { TextWrapping.Wrap, TextWrapping.NoWrap, TextWrapping.WrapWithOverflow };
            lbTextWrapping.ItemsSource = wrapping;

            ScrollBarVisibility[] scrollVisibilities = new ScrollBarVisibility[] { ScrollBarVisibility.Auto, ScrollBarVisibility.Disabled, ScrollBarVisibility.Hidden, ScrollBarVisibility.Visible };
            cbHorizontalScroll.ItemsSource = scrollVisibilities;
            cbVerticalScroll.ItemsSource   = scrollVisibilities;
        }
Ejemplo n.º 30
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     Typeface typeface,
     TextAlignment textAlignment,
     TextWrapping wrapping,
     Size constraint,
     IReadOnlyList <FormattedTextStyleSpan> spans)
 {
     return(new FormattedTextImpl(text, typeface, textAlignment, wrapping, constraint, spans));
 }
Ejemplo n.º 31
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     Typeface typeface,
     TextAlignment textAlignment,
     TextWrapping wrapping,
     Size constraint,
     IReadOnlyList <FormattedTextStyleSpan> spans)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 32
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     Typeface typeface,
     TextAlignment textAlignment,
     TextWrapping wrapping,
     Size constraint,
     IReadOnlyList <FormattedTextStyleSpan> spans)
 {
     return(Mock.Of <IFormattedTextImpl>());
 }
 /// <summary>
 /// Constructing TextParagraphProperties
 /// </summary>
 /// <param name="defaultTextRunProperties">default paragraph's default run properties</param>
 /// <param name="textAlignment">logical horizontal alignment</param>
 /// <param name="textWrap">text wrap option</param>
 /// <param name="lineHeight">Paragraph line height</param>
 public GenericTextParagraphProperties(TextRunProperties defaultTextRunProperties,
                                       TextAlignment textAlignment = TextAlignment.Left,
                                       TextWrapping textWrap       = TextWrapping.NoWrap,
                                       double lineHeight           = 0)
 {
     DefaultTextRunProperties = defaultTextRunProperties;
     _textAlignment           = textAlignment;
     _textWrap   = textWrap;
     _lineHeight = lineHeight;
 }
Ejemplo n.º 34
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     string fontFamilyName,
     double fontSize,
     FontStyle fontStyle,
     TextAlignment textAlignment,
     FontWeight fontWeight,
     TextWrapping wrapping)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 35
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     string fontFamily,
     double fontSize,
     FontStyle fontStyle,
     TextAlignment textAlignment,
     FontWeight fontWeight,
     TextWrapping wrapping)
 {
     return new FormattedTextImpl(text, fontFamily, fontSize, fontStyle, textAlignment, fontWeight, wrapping);
 }
Ejemplo n.º 36
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     string fontFamily,
     double fontSize,
     FontStyle fontStyle,
     TextAlignment textAlignment,
     Avalonia.Media.FontWeight fontWeight,
     TextWrapping wrapping)
 {
     return(new FormattedTextImpl(s_pangoContext, text, fontFamily, fontSize, fontStyle, textAlignment, fontWeight));
 }
Ejemplo n.º 37
0
 public IFormattedTextImpl CreateFormattedText(
     string text,
     string fontFamily,
     double fontSize,
     FontStyle fontStyle,
     TextAlignment textAlignment,
     Avalonia.Media.FontWeight fontWeight,
     TextWrapping wrapping)
 {
     return new FormattedTextImpl(s_pangoContext, text, fontFamily, fontSize, fontStyle, textAlignment, fontWeight);
 }
Ejemplo n.º 38
0
		static LineBreakMode ToLineBreakMode(TextWrapping value)
		{
			switch (value)
			{
				case TextWrapping.Wrap:
					return LineBreakMode.CharacterWrap;
				case TextWrapping.WrapWholeWords:
					return LineBreakMode.WordWrap;
				default:
				case TextWrapping.NoWrap:
					return LineBreakMode.NoWrap;
			}
		}
        public static ToastPrompt CreateToastPrompt(string title = "Title goes here", 
            string message = "Message goes here", 
            int milliSecondsUntilHidden = 2000, 
            TextWrapping wrapOption = TextWrapping.Wrap)
        {
            ToastPrompt newToastPrompt = new ToastPrompt();

            newToastPrompt.Title = title;
            newToastPrompt.Message = message;
            newToastPrompt.MillisecondsUntilHidden = milliSecondsUntilHidden;
            newToastPrompt.TextWrapping = wrapOption;

            return newToastPrompt;
        }
Ejemplo n.º 40
0
 public GenericTextParagraphProperties(FontRendering newRendering)
 {
     _flowDirection = FlowDirection.LeftToRight;
     _textAlignment = newRendering.TextAlignment;
     _firstLineInParagraph = false;
     _alwaysCollapsible = false;
     _defaultTextRunProperties = new GenericTextRunProperties(
        newRendering.Typeface, newRendering.FontSize, newRendering.FontSize,
        newRendering.TextDecorations, newRendering.TextColor, null,
        BaselineAlignment.Baseline, CultureInfo.CurrentUICulture);
     _textWrap = TextWrapping.Wrap;
     _lineHeight = 0;
     _indent = 0;
     _paragraphIndent = 0;
 }
Ejemplo n.º 41
0
 private IFormattedTextImpl Create(string text,
     string fontFamily,
     double fontSize,
     FontStyle fontStyle,
     TextAlignment textAlignment,
     FontWeight fontWeight,
     TextWrapping wrapping)
 {
     var r = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();
     return r.CreateFormattedText(text,
         fontFamily,
         fontSize,
         fontStyle,
         textAlignment,
         fontWeight,
         wrapping);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormattedText"/> class.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="fontFamilyName">The font family.</param>
        /// <param name="fontSize">The font size.</param>
        /// <param name="fontStyle">The font style.</param>
        /// <param name="textAlignment">The text alignment.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="wrapping">The text wrapping mode.</param>
        public FormattedText(
            string text,
            string fontFamilyName,
            double fontSize,
            FontStyle fontStyle = FontStyle.Normal,
            TextAlignment textAlignment = TextAlignment.Left,
            FontWeight fontWeight = FontWeight.Normal,
            TextWrapping wrapping = TextWrapping.Wrap)
        {
            Contract.Requires<ArgumentNullException>(text != null);
            Contract.Requires<ArgumentNullException>(fontFamilyName != null);

            if (fontSize <= 0)
            {
                throw new ArgumentException("FontSize must be greater than 0");
            }

            if (fontWeight <= 0)
            {
                throw new ArgumentException("FontWeight must be greater than 0");
            }

            Text = text;
            FontFamilyName = fontFamilyName;
            FontSize = fontSize;
            FontStyle = fontStyle;
            FontWeight = fontWeight;
            TextAlignment = textAlignment;
            Wrapping = wrapping;

            var platform = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();

            if (platform == null)
            {
                throw new Exception("Could not create FormattedText: IPlatformRenderInterface not registered.");
            }

            PlatformImpl = platform.CreateFormattedText(
                text,
                fontFamilyName,
                fontSize,
                fontStyle,
                textAlignment,
                fontWeight,
                wrapping);
        }
Ejemplo n.º 43
0
 public GenericTextParagraphProperties(
    FlowDirection flowDirection,
    TextAlignment textAlignment,
    bool firstLineInParagraph,
    bool alwaysCollapsible,
    TextRunProperties defaultTextRunProperties,
    TextWrapping textWrap,
    double lineHeight,
    double indent)
 {
     _flowDirection = flowDirection;
     _textAlignment = textAlignment;
     _firstLineInParagraph = firstLineInParagraph;
     _alwaysCollapsible = alwaysCollapsible;
     _defaultTextRunProperties = defaultTextRunProperties;
     _textWrap = textWrap;
     _lineHeight = lineHeight;
     _indent = indent;
 }
Ejemplo n.º 44
0
		public IEnumerable<TextLine> Format(string text, IChatSpanProvider spans, double width, Brush foreground, Brush background,
			TextWrapping textWrapping)
		{
			_text = text;
			_spans = spans;
			_background = background;
			_runProperties = new CustomTextRunProperties(_runProperties.Typeface, _runProperties.FontRenderingEmSize, foreground,
				Brushes.Transparent, false);
			_paraProperties = new CustomParagraphProperties(_runProperties);
			if (width < 0)
			{
				width = 0;
				text = "";
			}

			int idx = 0;
			while(idx < _text.Length)
			{
				var line = _formatter.FormatLine(this, idx, width, _paraProperties, null);
				idx += line.Length;
				yield return line;
			}
		}
Ejemplo n.º 45
0
 /// <summary>
 /// Set text wrap 
 /// </summary> 
 internal void SetTextWrapping(TextWrapping textWrap)
 { 
     _textWrap = textWrap;
 }
Ejemplo n.º 46
0
 private void ApplyNativeTextWrapping(TextWrapping textWrapping)
 {
     if (textWrapping == TextWrapping.Wrap)
     {
         ((Android.Widget.TextView)this.NativeUIElement).SetSingleLine(false);
     }
     else
     {
         ((Android.Widget.TextView)this.NativeUIElement).SetSingleLine(true);
     }
 }
        private void InitializeToastWithImgAndNoTitle(TextWrapping wrap = default(TextWrapping))
        {
            InitializePrompt();

            _prompt.Message = LongText;
            _prompt.ImageSource = new BitmapImage(new Uri("ms-appx:/Media/c4f_26x26.png"));
            _prompt.TextWrapping = wrap;
        }
 public JapaneseTextParagraphProperties(FlowDirection flowDirection, TextAlignment textAlignment, bool firstLineInParagraph, bool alwaysCollapsible, JapaneseTextRunProperties defaultTextRunProperties, TextWrapping textWrap, double lineHeight, double indent, bool isVerticalWriting)
 {
     this._flowDirection = flowDirection;
     this._textAlignment = textAlignment;
     this._firstLineInParagraph = firstLineInParagraph;
     this._alwaysCollapsible = alwaysCollapsible;
     this._defaultTextRunProperties = defaultTextRunProperties;
     this._textWrap = textWrap;
     this._lineHeight = lineHeight;
     this._indent = indent;
     this._isVerticalWriting = isVerticalWriting;
 }
Ejemplo n.º 49
0
 // ------------------------- ShowDescription -------------------------
 /// <summary>
 ///     Displays a string of text to the description block.
 /// </summary>
 public void ShowDescription(string description, TextWrapping wrapStyle)
 {
     descriptionBlock.Text = description;
     descriptionBlock.TextWrapping = wrapStyle;
 }
Ejemplo n.º 50
0
        /// <summary>
        /// Occurs when the value of the <see cref="TextWrapping"/> dependency property changes.
        /// </summary>
        private static void HandleTextWrappingChanged(DependencyObject dobj, TextWrapping oldValue, TextWrapping newValue)
        {
            var textBox = (TextBox)dobj;
            textBox.CoerceValue(HorizontalScrollBarVisibilityProperty);

            if (textBox.TextEditor != null)
                textBox.TextEditor.InvalidateMeasure();
        }
Ejemplo n.º 51
0
 public static void SetTextWrapping(this HtmlStyleDictionary style, TextWrapping textWrapping, IHtmlValueConverter converter)
 {
     style.SetValue("white-space", converter.ToWhiteSpaceString(textWrapping));
 }
Ejemplo n.º 52
0
 protected internal override void NativeInit()
 {
     if (this.Parent != null)
     {
         if (this.NativeUIElement == null)
         {
             this.NativeUIElement = new VerticalAlignedLabel();
             this.NativeUIElement.BackgroundColor = UIColor.Clear;
         }
         this.NativeText = (string)this.GetValue(TextProperty);
         this.NativeFontSize = (double)this.GetValue(FontSizeProperty);
         this.NativeTextAlignment = (TextAlignment)this.GetValue(TextAlignmentProperty);
         this.NativeTextWrapping = (TextWrapping)this.GetValue(TextWrappingProperty);
         this.NativeFontFamily = (FontFamily)this.GetValue(FontFamilyProperty);
         this.NativeFontWeight = this.FontWeight;
         this.NativeFontStyle = this.FontStyle;
         this.NativeForeground = this.Foreground;
         this.InvalidateMeasure();
         base.NativeInit();
     }
 }
Ejemplo n.º 53
0
 public static void SetTextWrapping(DependencyObject element, TextWrapping value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(JapaneseTextBlock.TextWrappingProperty, value);
 }
Ejemplo n.º 54
0
			public CustomParagraphProperties(TextRunProperties defaultTextRunProperties)
			{
				_defaultProperties = defaultTextRunProperties;
				_textWrapping = TextWrapping.Wrap;
			}
 void OnRadioButtonChecked(object sender, RoutedEventArgs args)
 {
     this.TextWrapping = (TextWrapping)(sender as RadioButton).Tag;
 }
Ejemplo n.º 56
0
 private Size GetTextSize(double availableWidth, double fontSize, TextWrapping textWrapping)
 {
     var block = new TextBlock
     {
         Text = $"{this.Text}",
         TextAlignment = this.TextAlignment,
         FontSize = fontSize,
         TextWrapping = textWrapping
     };
     block.Measure(new Size(availableWidth, Double.PositiveInfinity));
     return block.DesiredSize;
 }
Ejemplo n.º 57
0
 private static TextAlignment GetResolvedTextAlignment(TextWrapping textWrapping, TextAlignment textAlignment)
 {
     if (textWrapping != TextWrapping.NoWrap)
     {
         return textAlignment;
     }
     if (textAlignment != TextAlignment.Justify)
     {
         return TextAlignment.Left;
     }
     return TextAlignment.Justify;
 }
        private void InitializeAdvancedToast(TextWrapping wrap = default(TextWrapping))
        {
            InitializePrompt();

            _prompt.IsAppBarVisible = false;
            _prompt.Title = "Advanced";
            _prompt.Message = "Custom Fontsize, img, and orientation";
            _prompt.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Logo.scale-100.png"));
            _prompt.FontSize = 50;
            _prompt.TextOrientation = Orientation.Vertical;
            _prompt.Background = _aliceBlueSolidColorBrush;
            _prompt.Foreground = _cornFlowerBlueSolidColorBrush;

            _prompt.TextWrapping = wrap;
        }
Ejemplo n.º 59
0
        public wpf::System.Windows.TextWrapping Convert(TextWrapping textWrapping)
        {
            switch (textWrapping)
            {
                case TextWrapping.Wrap: return wpf::System.Windows.TextWrapping.Wrap;
                case TextWrapping.NoWrap: return wpf::System.Windows.TextWrapping.NoWrap;
            }

            throw new Granular.Exception("Unexpected TextWrapping value \"{0}\"", textWrapping);
        }
Ejemplo n.º 60
0
 protected virtual void OnTextWrappingChanged(DependencyPropertyChangedEventArgs e)
 {
     this.textBlock.TextWrapping = (TextWrapping)e.NewValue;
     this.InvalidateMeasure();
 }