• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TextAlignment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TextAlignment的典型用法代码示例。如果您正苦于以下问题:C# TextAlignment类的具体用法?C# TextAlignment怎么用?C# TextAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextAlignment类属于命名空间,在下文中一共展示了TextAlignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ShowText

    public static GameObject ShowText(string name, string text, float time, TextAlignment alignment, TextAnchor anchor, float x, float y)
    {
        LoadFonts();

        // Destroy old object if existent
        GameObject textObject = GameObject.Find(PREFIX + name);
        MonoBehaviour.Destroy(textObject);

        textObject = new GameObject(PREFIX + name);

        textObject.AddComponent<OutlineText>().thickness = 2;

        TutorialText textBehaviour = textObject.GetComponent<TutorialText>();

        if (textBehaviour == null)
            textBehaviour = textObject.AddComponent<TutorialText>();

        GUIScale textScaler = textObject.GetComponent<GUIScale>();
        GUIText guitext = textObject.guiText;
        guitext.enabled = true;

        textObject.transform.position = new Vector3(x, y, 0);

        guitext.text = text;
        guitext.anchor = anchor;
        guitext.alignment = alignment;
        //guitext.font = bigFont;
        //guitext.material = bigMat;
        //guitext.fontSize = 48;

        if (time > 0)
            textBehaviour.DestroyIn(time);

        return textObject;
    }
开发者ID:mokacao,项目名称:StellarSwingClassic,代码行数:35,代码来源:Tutorial.cs


示例2: UpdateFromFormsControl

 public static void UpdateFromFormsControl(this TextView textView, string text, Color formsColor, Font formsFont, TextAlignment textAlignment)
 {
     textView.Text = text;
     textView.SetTextColor(formsColor.ToAndroid(Color.Default));
     textView.UpdateFont(formsFont);
     textView.Gravity = textAlignment.ToNative();
 }
开发者ID:patridge,项目名称:Xamarin.Forms.Plugins,代码行数:7,代码来源:TextViewExtensions.cs


示例3: FormattedTextImpl

        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();
        }
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:27,代码来源:FormattedTextImpl.cs


示例4: FormattedText

        /// <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>
        public FormattedText(
            string text,
            string fontFamilyName,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            Contract.Requires<ArgumentNullException>(text != null);
            Contract.Requires<ArgumentNullException>(fontFamilyName != null);
            Contract.Requires<ArgumentException>(fontSize > 0);

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

            var platform = PerspexLocator.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);
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:43,代码来源:FormattedText.cs


示例5: FixedWidthColumn

 public FixedWidthColumn(string name, int width, TextAlignment align, char blankChar)
 {
     this._name = name;
     this._w = width;
     this._align = align;
     this._blank = blankChar;
 }
开发者ID:tenshino,项目名称:RainstormStudios,代码行数:7,代码来源:FixedWidthStreamWriter.cs


示例6: FormattedTextImpl

        public FormattedTextImpl(
            Pango.Context context,
            string text,
            string fontFamily,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            Contract.Requires<ArgumentNullException>(context != null);
            Contract.Requires<ArgumentNullException>(text != null);
            Layout = new Pango.Layout(context);
            _text = text;
            Layout.SetText(text);
            Layout.FontDescription = new Pango.FontDescription
            {
                Family = fontFamily,
                Size = Pango.Units.FromDouble(CorrectScale(fontSize)),
                Style = (Pango.Style)fontStyle,
                Weight = fontWeight.ToCairo()
            };

            Layout.Alignment = textAlignment.ToCairo();
            Layout.Attributes = new Pango.AttrList();
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:25,代码来源:FormattedTextImpl.cs


示例7: Text

 public Text(string text, TextAlignment align, int x, int y)
 {
     Label = text;
     Align = align;
     X = x;
     Y = y;
 }
开发者ID:ademar,项目名称:melon-reports,代码行数:7,代码来源:Text.cs


示例8: FormattedText

        /// <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>
        public FormattedText(
            string text,
            string fontFamilyName,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            //TODO: Find out why it was null in the first place. Demo project - AvalonStudio
            //https://github.com/VitalElement/AvalonStudio/commit/787fb9396feb74e6ca6bd4e08436269a349df9c6
            text = text ?? "";
            Text = text;
            FontFamilyName = fontFamilyName;
            FontSize = fontSize;
            FontStyle = fontStyle;
            FontWeight = fontWeight;
            TextAlignment = textAlignment;

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

            PlatformImpl = platform.CreateFormattedText(
                text,
                fontFamilyName,
                fontSize,
                fontStyle,
                textAlignment,
                fontWeight);
        }
开发者ID:g4idrijs,项目名称:Perspex,代码行数:37,代码来源:FormattedText.cs


示例9: Create

        public static FormattedText Create(string text, Font font, TextAlignment alignment, SizeConstraint constraint)
        {
            if (text == null)
            {
                return new FormattedText(null, new Box2(0, 0, 0, 0), text, font, alignment, constraint);
            }
            else
            {
                var instances = new List<GlyphInstance>(text.Length);
                var x = 0f;

                foreach (var c in text)
                {
                    var glyph = font.GetGlyph(c);

                    if (glyph != null)
                    {
                        instances.Add(new GlyphInstance(new Box2(x, 0, glyph.Size.X, glyph.Size.Y), glyph.Sprite));
                        x += glyph.Size.X;
                    }
                }

                return new FormattedText(instances, new Box2(0, 0, x, font.Height), text, font, alignment, constraint);
            }
        }
开发者ID:nicolas-repiquet,项目名称:Granite,代码行数:25,代码来源:FormattedText.cs


示例10: FormattedText

        public FormattedText(
            string text,
            string fontFamilyName,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            this.Text = text;
            this.FontFamilyName = fontFamilyName;
            this.FontSize = fontSize;
            this.FontStyle = fontStyle;
            this.FontWeight = fontWeight;
            this.TextAlignment = textAlignment;

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

            this.PlatformImpl = platform.CreateFormattedText(
                text,
                fontFamilyName,
                fontSize,
                fontStyle,
                textAlignment,
                fontWeight);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:25,代码来源:FormattedText.cs


示例11: FormattedTextImpl

        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();
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:31,代码来源:FormattedTextImpl.cs


示例12: BuildStringFormat

        //    http://stackoverflow.com/questions/14932063/convert-code-of-a-user-control-from-vb-net-to-c-sharp
        //https://mightycoco.wordpress.com/2009/09/22/getstringformatfromcontentallignment-converting-contentallignment-data-into-stringformat-data/
        public static StringFormat BuildStringFormat(StringTrimming stringTrimming,TextAlignment alignment)
        {
            StringFormat format = StringFormat.GenericTypographic;
            format.Trimming = stringTrimming;
            format.FormatFlags = StringFormatFlags.LineLimit;
            switch (alignment) {
                    case TextAlignment.Left:{
                        format.Alignment = StringAlignment.Near;
                        format.LineAlignment = StringAlignment.Near;
                        return format;
                    }
                    case TextAlignment.Center:{
                        format.Alignment = StringAlignment.Center;
                        format.LineAlignment = StringAlignment.Near;
                        return format;
                    }

                    case TextAlignment.Right:{
                        format.Alignment = StringAlignment.Far;
                        format.LineAlignment = StringAlignment.Near;
                        return format;
                    }

                    case TextAlignment.Justify:{
                        format.Alignment = StringAlignment.Center;
                        format.LineAlignment = StringAlignment.Near;
                        return format;
                    }
            }
            return format;
        }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:33,代码来源:TextDrawer.cs


示例13: TextComponent

 public TextComponent(string myText, TextAlignment myAlignment, Vector2 myPosition, SpriteFont myFont)
 {
     Destination = myPosition;
     textAlighment = myAlignment;
     font = myFont;
     text = myText;
 }
开发者ID:TheNextGuy32,项目名称:SpectreProtectre,代码行数:7,代码来源:TextComponent.cs


示例14: GestureOptionEntry

 public GestureOptionEntry(string text, Texture2D icon, Vector2 iconSize, Vector2 position, float scale, Color color, TextAlignment alignment, GestureTest test, GestureHandler callback)
     : base(text, icon, iconSize, position, scale, color, alignment)
 {
     unlockedColor = color;
     this.callback = callback;
     this.test = test;
 }
开发者ID:alexander-jones,项目名称:Kinect-Snake,代码行数:7,代码来源:GesturePromptScreen.cs


示例15: LabelTextureButton

 public LabelTextureButton(
     Screen screen,
     SpriteBatch spriteBatch,
     UIAlignment alignment,
     int x,
     int y,
     Texture2D selectedTexture,
     Texture2D deselectedTexture,
     Rectangle localHitBox,
     SpriteFont font,
     TextAlignment textAlignment,
     string text,
     int textXOffset,
     int textYOffset,
     int outline,
     Color selectedColor,
     Color deselectedColor,
     Action onActivate,
     Action onMouseOver,
     Action onMouseOut)
     : base(screen, spriteBatch, alignment, x, y, selectedTexture, deselectedTexture, localHitBox, onActivate, onMouseOver, onMouseOut)
 {
     _font = font;
     _textAlignment = textAlignment;
     _text = text;
     _textXOffset = textXOffset;
     _textYOffset = textYOffset;
     _outline = outline;
     _selectedColor = selectedColor;
     _deselectedColor = deselectedColor;
 }
开发者ID:klutch,项目名称:StasisEngine,代码行数:31,代码来源:LabelTextureButton.cs


示例16: SignalChooser

 public SignalChooser(INodeWrapper nodeItem, NodeSignalIn initialSignalIn, double maxWidth, TextAlignment textAlignment)
 {
     NodeItem = nodeItem;
     SignalIn = initialSignalIn;
     MaxWidth = maxWidth;
     TextAlignment = textAlignment;
 }
开发者ID:EdWeller,项目名称:SoapboxSnap,代码行数:7,代码来源:SignalChooser.cs


示例17: UpdateFromFormsControl

		public static void UpdateFromFormsControl (this UILabel uiLabel, string text, TextAlignment textAlignment, Color textColor, Font font)
		{
			uiLabel.Text = text;
			uiLabel.TextAlignment = textAlignment.ToUITextAlignment ();
			uiLabel.TextColor = textColor.ToUIColor ();
			uiLabel.Font = font.ToUIFont ();
		}
开发者ID:JoshuaNovak919,项目名称:Xamarin.Forms.Plugins,代码行数:7,代码来源:UILabelExtensions.cs


示例18: FormattedTextImpl

        public FormattedTextImpl(
            string text,
            string fontFamily,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            var factory = Locator.Current.GetService<DWrite.Factory>();

            var format = new DWrite.TextFormat(
                factory,
                fontFamily,
                (DWrite.FontWeight)fontWeight,
                (DWrite.FontStyle)fontStyle,
                (float)fontSize);

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

            TextLayout.TextAlignment = textAlignment.ToDirect2D();
        }
开发者ID:healtech,项目名称:Perspex,代码行数:26,代码来源:FormattedTextImpl.cs


示例19: GUIButton

 public GUIButton(int x, int y, int width, int height)
     : base(x, y, width, height)
 {
     _text = "New Button";
     _clickAction = GUIClickAction.RunScript;
     _textAlign = TextAlignment.TopMiddle;
 }
开发者ID:smarinel,项目名称:ags-web,代码行数:7,代码来源:GUIButton.cs


示例20: SignalValue

 public SignalValue(INodeWrapper nodeItem, NodeSignal initialSignal, double maxWidth, TextAlignment textAlignment, string formatString)
 {
     Signal = initialSignal;
     NodeItem = nodeItem;
     MaxWidth = maxWidth;
     TextAlignment = textAlignment;
     FormatString = formatString;
 }
开发者ID:EdWeller,项目名称:SoapboxSnap,代码行数:8,代码来源:SignalValue.cs



注:本文中的TextAlignment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextAnchor类代码示例发布时间:2022-05-24
下一篇:
C# TextAccessor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap