本文整理汇总了C#中QFontAlignment类的典型用法代码示例。如果您正苦于以下问题:C# QFontAlignment类的具体用法?C# QFontAlignment怎么用?C# QFontAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QFontAlignment类属于命名空间,在下文中一共展示了QFontAlignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例4: PrintToVBO
public void PrintToVBO(string text, QFontAlignment alignment, Vector3 position, Color color, SizeF maxSize)
{
Options.Colour = color;
PrintOffset = position;
Print(text, maxSize, alignment);
}
示例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);
}
示例6: Measure
public SizeF Measure(string text, QFontAlignment alignment = QFontAlignment.Left)
{
return TransformMeasureFromViewport(PrintOrMeasure(text, alignment, true));
}
示例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);
}
示例8: Measure
public SizeF Measure(string text, QFontAlignment alignment = QFontAlignment.Left)
{
return PrintOrMeasure(text, alignment, true);
}
示例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();
}
示例10: PrintCommentWithLine
private void PrintCommentWithLine(string comment, QFontAlignment alignment, float xOffset, ref float yOffset)
{
WriteCommentWithLine(mainText, comment, alignment, xOffset, ref yOffset);
}
示例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();
}
示例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;
}
示例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;
};
}
示例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();
}
示例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);
}