本文整理汇总了C#中QFontAlignment类的典型用法代码示例。如果您正苦于以下问题:C# QFontAlignment类的具体用法?C# QFontAlignment怎么用?C# QFontAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QFontAlignment类属于命名空间,在下文中一共展示了QFontAlignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PlainText
public PlainText(bool autoSize, string text, Color color, QFontAlignment alignment, float offsetX, float offsetY)
{
this.AutoSize = autoSize;
this.text = text;
this.Color = color;
this.Alignment = alignment;
this.offsetX = offsetX;
this.offsetY = offsetY;
}
开发者ID:law4x,项目名称:stonevox3d,代码行数:9,代码来源:PlainText.cs
示例2: TextObject
/// <summary>
/// Initializes a new <see cref="TextObject" /> instance.
/// </summary>
/// <param name="text">The initial text to set for this text object.</param>
/// <param name="font">The font to use for this text object.</param>
/// <param name="position">The intitial position of this text object.</param>
/// <param name="alignment">The intitial alignment of the text in this text object.</param>
public TextObject(string text, Font font, Point<int> position = new Point<int>(),
QFontAlignment alignment = QFontAlignment.Centre)
{
if (font == null)
throw new EngineException("Font supplied for TextObject is null!", new ArgumentNullException("font"));
Text = text;
Font = font;
Position = position;
Alignment = alignment;
}
开发者ID:TriDevs,项目名称:TriEngine,代码行数:18,代码来源:TextObject.cs
示例3: PrintOrMeasure
private SizeF PrintOrMeasure(string text, QFontAlignment alignment, bool measureOnly)
{
float maxWidth = 0f;
float xOffset = 0f;
float yOffset = 0f;
var caps = new EnableCap[] { };
if(!UsingVertexBuffers)
caps = new EnableCap[] { EnableCap.Texture2D, EnableCap.Blend };
Helper.SafeGLEnable(caps, () =>
{
float maxXpos = float.MinValue;
float minXPos = float.MaxValue;
if (!UsingVertexBuffers)
{
GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);
if (Options.UseDefaultBlendFunction)
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
}
text = text.Replace("\r\n", "\r");
if (alignment == QFontAlignment.Right)
xOffset -= MeasureNextlineLength(text);
else if (alignment == QFontAlignment.Centre)
xOffset -= (int)(0.5f * MeasureNextlineLength(text));
for (int i = 0; i < text.Length; i++)
{
char c = text[i];
//newline
if (c == '\r' || c == '\n')
{
yOffset += LineSpacing;
xOffset = 0f;
if (alignment == QFontAlignment.Right)
xOffset -= MeasureNextlineLength(text.Substring(i + 1));
else if (alignment == QFontAlignment.Centre)
xOffset -= (int)(0.5f * MeasureNextlineLength(text.Substring(i + 1)));
}
else
{
minXPos = Math.Min(xOffset, minXPos);
//normal character
if (c != ' ' && fontData.CharSetMapping.ContainsKey(c))
{
QFontGlyph glyph = fontData.CharSetMapping[c];
if (!measureOnly)
RenderGlyph(xOffset, yOffset, c, false);
}
if (IsMonospacingActive)
xOffset += MonoSpaceWidth;
else
{
if (c == ' ')
xOffset += (float)Math.Ceiling(fontData.meanGlyphWidth * Options.WordSpacing);
//normal character
else if (fontData.CharSetMapping.ContainsKey(c))
{
QFontGlyph glyph = fontData.CharSetMapping[c];
xOffset += (float)Math.Ceiling(glyph.rect.Width + fontData.meanGlyphWidth * Options.CharacterSpacing + fontData.GetKerningPairCorrection(i, text, null));
}
}
maxXpos = Math.Max(xOffset, maxXpos);
}
}
if (minXPos != float.MaxValue)
maxWidth = maxXpos - minXPos;
});
return new SizeF(maxWidth, yOffset + LineSpacing);
}
开发者ID:swax,项目名称:QuickFont,代码行数:83,代码来源:QFont.cs
示例4: PrintToVBO
public void PrintToVBO(string text, QFontAlignment alignment, Vector3 position, Color color, SizeF maxSize)
{
Options.Colour = color;
PrintOffset = position;
Print(text, maxSize, alignment);
}
开发者ID:swax,项目名称:QuickFont,代码行数:6,代码来源:QFont.cs
示例5: Print
/// <summary>
/// Prints text inside the given bounds.
/// </summary>
/// <param name="text"></param>
/// <param name="bounds"></param>
/// <param name="alignment"></param>
public void Print(string text, SizeF maxSize, QFontAlignment alignment)
{
var processedText = ProcessText(text, maxSize, alignment);
Print(processedText);
}
开发者ID:swax,项目名称:QuickFont,代码行数:11,代码来源:QFont.cs
示例6: Measure
public SizeF Measure(string text, QFontAlignment alignment = QFontAlignment.Left)
{
return TransformMeasureFromViewport(PrintOrMeasure(text, alignment, true));
}
开发者ID:swax,项目名称:QuickFont,代码行数:4,代码来源:QFont.cs
示例7: Measure
/// <summary>
/// Measures the actual width and height of the block of text.
/// </summary>
/// <param name="text"></param>
/// <param name="bounds"></param>
/// <param name="alignment"></param>
/// <returns></returns>
public SizeF Measure(string text, float maxWidth, QFontAlignment alignment)
{
var processedText = ProcessText(text, maxWidth, alignment);
return Measure(processedText);
}
开发者ID:Pireax,项目名称:neovim.cs,代码行数:12,代码来源:QFont.cs
示例8: Measure
public SizeF Measure(string text, QFontAlignment alignment = QFontAlignment.Left)
{
return PrintOrMeasure(text, alignment, true);
}
开发者ID:rumkex,项目名称:QuickFont,代码行数:4,代码来源:QFont.cs
示例9: WriteCommentWithLine
private void WriteCommentWithLine(NxFont font, string comment, QFontAlignment alignment, float xOffset, ref float yOffset)
{
//GL.PushMatrix();
yOffset += 20;
var offset = new Vector3((int)xOffset, yOffset, 0f);
var transform = Matrix4.CreateTranslation(offset);
var mvp = Matrix4.Mult (transform, mOrthographicMatrix);
font.Print(mvp, comment, alignment);
var bounds = font.SafeMeasure(ClientRectangle, comment, Width-60, alignment);
// GL.Disable(EnableCap.Texture2D);
// GL.Begin(BeginMode.Lines);
// GL.Color4(1.0f, 0f, 0f, 1f);
// GL.Vertex2(0f, 0f);
// GL.Color4(1.0f, 0f, 0f, 1f);
// GL.Vertex2(0f, bounds.Height + 20f);
// GL.End();
yOffset += bounds.Height;
// GL.PopMatrix();
}
开发者ID:tgsstdio,项目名称:BirdNest.QuickFont,代码行数:22,代码来源:Example.cs
示例10: PrintCommentWithLine
private void PrintCommentWithLine(string comment, QFontAlignment alignment, float xOffset, ref float yOffset)
{
WriteCommentWithLine(mainText, comment, alignment, xOffset, ref yOffset);
}
开发者ID:tgsstdio,项目名称:BirdNest.QuickFont,代码行数:4,代码来源:Example.cs
示例11: WriteComment
private void WriteComment(NxFont font, string comment,QFontAlignment alignment, ref float yOffset)
{
//GL.PushMatrix();
yOffset += 20;
var offset = new Vector3(30f, yOffset, 0f);
var transform = Matrix4.CreateTranslation(offset);
var mvp = Matrix4.Mult (transform, mOrthographicMatrix);
font.SafePrint(mvp, ClientRectangle, comment, Width - 60, alignment);
yOffset += font.SafeMeasure(ClientRectangle, comment, Width - 60, alignment).Height;
//GL.PopMatrix();
}
开发者ID:tgsstdio,项目名称:BirdNest.QuickFont,代码行数:13,代码来源:Example.cs
示例12: PrintWithBounds
private void PrintWithBounds(NxFont font, string text, RectangleF bounds, QFontAlignment alignment, ref float yOffset)
{
// GL.Disable(EnableCap.Texture2D);
// GL.Color4(1.0f, 0f, 0f, 1.0f);
float maxWidth = bounds.Width;
float height = font.SafeMeasure(ClientRectangle, text, maxWidth, alignment).Height;
// GL.Begin(BeginMode.LineLoop);
// GL.Vertex3(bounds.X, bounds.Y, 0f);
// GL.Vertex3(bounds.X + bounds.Width, bounds.Y, 0f);
// GL.Vertex3(bounds.X + bounds.Width, bounds.Y + height, 0f);
// GL.Vertex3(bounds.X, bounds.Y + height, 0f);
// GL.End();
font.PrintAt(ClientRectangle, text, maxWidth, alignment, new Vector2(bounds.X,bounds.Y));
yOffset += height;
}
开发者ID:tgsstdio,项目名称:BirdNest.QuickFont,代码行数:21,代码来源:Example.cs
示例13: InitialiseKeyDown
private void InitialiseKeyDown()
{
KeyDown += (sender, ke) => {
if (ke.Key == Key.Escape)
{
this.Exit ();
}
};
KeyDown += (sender, ke) => {
switch (ke.Key)
{
case Key.Space:
useShader = !useShader;
break;
case Key.Right:
currentDemoPage++;
break;
case Key.BackSpace:
case Key.Left:
currentDemoPage--;
break;
case Key.Enter:
{
if (currentDemoPage == 4)
boundsAnimationCnt = 0f;
}
break;
case Key.Up:
{
if (currentDemoPage == 4)
{
if (cycleAlignment == QFontAlignment.Justify)
cycleAlignment = QFontAlignment.Left;
else
cycleAlignment++;
}
}
break;
case Key.Down:
{
if (currentDemoPage == 4)
{
if (cycleAlignment == QFontAlignment.Left)
cycleAlignment = QFontAlignment.Justify;
else
cycleAlignment--;
}
}
break;
case Key.F9:
break;
}
if (currentDemoPage > LAST_PAGE)
currentDemoPage = LAST_PAGE;
if (currentDemoPage < FIRST_PAGE)
currentDemoPage = FIRST_PAGE;
};
}
开发者ID:tgsstdio,项目名称:BirdNest.QuickFont,代码行数:74,代码来源:Example.cs
示例14: PrintCommentWithLine
private void PrintCommentWithLine(QFont font, string comment, QFontAlignment alignment, float xOffset, ref float yOffset)
{
GL.PushMatrix();
yOffset += 20;
GL.Translate((int)xOffset, yOffset, 0f);
font.Print(comment, alignment);
var bounds = font.Measure(comment, Width-60, alignment);
GL.Disable(EnableCap.Texture2D);
GL.Begin(BeginMode.Lines);
GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, 0f);
GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, bounds.Height + 20f);
GL.End();
yOffset += bounds.Height;
GL.PopMatrix();
}
开发者ID:kbollini,项目名称:Asynchronous3DSceneRenderingEngine,代码行数:22,代码来源:Game.cs
示例15: PrintToVBO
public void PrintToVBO(string text, Vector2 position, QFontAlignment alignment = QFontAlignment.Left)
{
PrintOffset = new Vector3(position.X, position.Y, 0f);
PrintOrMeasure(text, alignment, false);
}
开发者ID:mlabs-pl,项目名称:QuickFont,代码行数:5,代码来源:QFont.cs
示例16: Print
/// <summary>
/// Prints text inside the given bounds.
/// </summary>
/// <param name="text"></param>
/// <param name="bounds"></param>
/// <param name="alignment"></param>
public void Print(string text, float maxWidth, QFontAlignment alignment)
{
var processedText = ProcessText(text, maxWidth, alignment);
Print(processedText);
}
开发者ID:Pireax,项目名称:neovim.cs,代码行数:11,代码来源:QFont.cs
示例17: Print
public void Print(string text, float maxWidth, QFontAlignment alignment, PointF position)
{
position = LockToPixel(position);
renderer.Begin(position);
Print(text, maxWidth, alignment);
renderer.End();
}
开发者ID:rumkex,项目名称:QuickFont,代码行数:8,代码来源:QFont.cs
示例18: PrintOrMeasure
private SizeF PrintOrMeasure(string text, QFontAlignment alignment, bool measureOnly)
{
var popRequired = false;
if (!measureOnly && !ProjectionStack.Begun && Options.TransformToViewport != null)
{
GL.PushMatrix();
popRequired = true;
GL.Scale(1 / fontData.scaleDueToTransformToViewport, 1 / fontData.scaleDueToTransformToViewport, 0);
}
float maxXpos = float.MinValue;
float minXPos = float.MaxValue;
if (!measureOnly)
{
GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);
GL.Enable(EnableCap.Texture2D);
GL.Enable(EnableCap.Blend);
if (Options.UseDefaultBlendFunction)
{
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
}
}
float xOffset = 0f;
float yOffset = 0f;
text = text.Replace("\r\n", "\r");
if (alignment == QFontAlignment.Right)
xOffset -= MeasureNextlineLength(text);
else if (alignment == QFontAlignment.Centre)
xOffset -= (int)(0.5f * MeasureNextlineLength(text));
for(int i = 0; i < text.Length; i++)
{
char c = text[i];
//newline
if (c == '\r' || c == '\n')
{
yOffset += LineSpacing;
xOffset = 0f;
if (alignment == QFontAlignment.Right)
xOffset -= MeasureNextlineLength(text.Substring(i + 1));
else if (alignment == QFontAlignment.Centre)
xOffset -= (int)(0.5f * MeasureNextlineLength(text.Substring(i + 1)));
}
else
{
minXPos = Math.Min(xOffset, minXPos);
//normal character
if (c != ' ' && fontData.CharSetMapping.ContainsKey(c))
{
QFontGlyph glyph = fontData.CharSetMapping[c];
if(!measureOnly)
RenderGlyph(xOffset, yOffset, c, false);
}
if (IsMonospacingActive)
xOffset += MonoSpaceWidth;
else
{
if (c == ' ')
xOffset += (float)Math.Ceiling(fontData.meanGlyphWidth * Options.WordSpacing);
//normal character
else if (fontData.CharSetMapping.ContainsKey(c))
{
QFontGlyph glyph = fontData.CharSetMapping[c];
xOffset += (float)Math.Ceiling(glyph.rect.Width + fontData.meanGlyphWidth * Options.CharacterSpacing + fontData.GetKerningPairCorrection(i, text, null));
}
}
maxXpos = Math.Max(xOffset, maxXpos);
}
}
float maxWidth = 0f;
if (minXPos != float.MaxValue)
maxWidth = maxXpos - minXPos;
if (popRequired)
GL.PopMatrix();
return new SizeF(maxWidth, yOffset + LineSpacing);
//.........这里部分代码省略.........
开发者ID:Pireax,项目名称:neovim.cs,代码行数:101,代码来源:QFont.cs
示例19: PrintOrMeasure
private SizeF PrintOrMeasure(string text, QFontAlignment alignment, bool measureOnly)
{
float maxXpos = float.MinValue;
float minXPos = float.MaxValue;
float xOffset = 0f;
float yOffset = 0f;
text = text.Replace("\r\n", "\r");
if (alignment == QFontAlignment.Right)
xOffset -= MeasureNextlineLength(text);
else if (alignment == QFontAlignment.Centre)
xOffset -= (int)(0.5f * MeasureNextlineLength(text));
for(int i = 0; i < text.Length; i++)
{
char c = text[i];
//newline
if (c == '\r' || c == '\n')
{
yOffset += LineSpacing;
xOffset = 0f;
if (alignment == QFontAlignment.Right)
xOffset -= MeasureNextlineLength(text.Substring(i + 1));
else if (alignment == QFontAlignment.Centre)
xOffset -= (int)(0.5f * MeasureNextlineLength(text.Substring(i + 1)));
}
else
{
minXPos = Math.Min(xOffset, minXPos);
//normal character
if (c != ' ' && fontData.CharSetMapping.ContainsKey(c))
{
QFontGlyph glyph = fontData.CharSetMapping[c];
if(!measureOnly)
RenderGlyph(xOffset, yOffset, c, false);
}
if (IsMonospacingActive)
xOffset += MonoSpaceWidth;
else
{
if (c == ' ')
xOffset += (float)Math.Ceiling(fontData.meanGlyphWidth * Options.WordSpacing);
//normal character
else if (fontData.CharSetMapping.ContainsKey(c))
{
QFontGlyph glyph = fontData.CharSetMapping[c];
xOffset += (float)Math.Ceiling(glyph.rect.Width + fontData.meanGlyphWidth * Options.CharacterSpacing + fontData.GetKerningPairCorrection(i, text, null));
}
}
maxXpos = Math.Max(xOffset, maxXpos);
}
}
float maxWidth = 0f;
if (minXPos != float.MaxValue)
maxWidth = maxXpos - minXPos;
return new SizeF(maxWidth, yOffset + LineSpacing);
}
开发者ID:rumkex,项目名称:QuickFont,代码行数:70,代码来源:QFont.cs
示例20: Measure
/// <summary>
/// Measures the specified text. Helper method delegating functionality.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="maxWidth">The maximum width.</param>
/// <param name="alignment">The alignment.</param>
/// <returns>
/// Measured size.
/// </returns>
public SizeF Measure(string text, float maxWidth, QFontAlignment alignment)
{
var test = new QFontDrawingPimitive(this);
return test.Measure(text, maxWidth, alignment);
}
开发者ID:vescon,项目名称:QuickFont,代码行数:14,代码来源:QFont.cs
注:本文中的QFontAlignment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论