本文整理汇总了C#中TextAlignment类的典型用法代码示例。如果您正苦于以下问题:C# TextAlignment类的具体用法?C# TextAlignment怎么用?C# TextAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextAlignment类属于命名空间,在下文中一共展示了TextAlignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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();
}
示例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);
}
示例5: FixedWidthColumn
public FixedWidthColumn(string name, int width, TextAlignment align, char blankChar)
{
this._name = name;
this._w = width;
this._align = align;
this._blank = blankChar;
}
示例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();
}
示例7: Text
public Text(string text, TextAlignment align, int x, int y)
{
Label = text;
Align = align;
X = x;
Y = y;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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();
}
示例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;
}
示例13: TextComponent
public TextComponent(string myText, TextAlignment myAlignment, Vector2 myPosition, SpriteFont myFont)
{
Destination = myPosition;
textAlighment = myAlignment;
font = myFont;
text = myText;
}
示例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;
}
示例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;
}