本文整理汇总了C#中FSO.Client.UI.Framework.UIElement.LocalPoint方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.LocalPoint方法的具体用法?C# UIElement.LocalPoint怎么用?C# UIElement.LocalPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSO.Client.UI.Framework.UIElement
的用法示例。
在下文中一共展示了UIElement.LocalPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeText
/// <summary>
/// Computes drawing commands to layout a block of text within
/// certain constraints
/// </summary>
/// <returns></returns>
public static TextRendererResult ComputeText(string text, TextRendererOptions options, UIElement target)
{
var TextStyle = options.TextStyle;
var _Scale = options.Scale;
var txtScale = TextStyle.Scale * _Scale;
var m_LineHeight = TextStyle.MeasureString("W").Y - (2 * txtScale.Y);
var spaceWidth = TextStyle.MeasureString(" ").X;
var words = text.Split(' ').ToList();
var newWordsArray = TextRenderer.ExtractLineBreaks(words);
var m_Lines = new List<UITextEditLine>();
TextRenderer.CalculateLines(m_Lines, newWordsArray, TextStyle, options.MaxWidth, spaceWidth, options.TopLeftIconSpace, m_LineHeight);
var topLeft = options.Position;
var position = topLeft;
var result = new TextRendererResult();
var drawCommands = new List<ITextDrawCmd>();
result.DrawingCommands = drawCommands;
var yPosition = topLeft.Y;
var numLinesAdded = 0;
var realMaxWidth = 0;
for (var i = 0; i < m_Lines.Count; i++)
{
var lineOffset = (i*m_LineHeight < options.TopLeftIconSpace.Y) ? options.TopLeftIconSpace.X : 0;
var line = m_Lines[i];
var xPosition = topLeft.X+lineOffset;
if (line.LineWidth > realMaxWidth) realMaxWidth = (int)line.LineWidth;
/** Alignment **/
if (options.Alignment == TextAlignment.Center)
{
xPosition += (int)Math.Round(((options.MaxWidth-lineOffset) - line.LineWidth) / 2);
}
var segmentPosition = target.LocalPoint(new Vector2(xPosition, yPosition));
drawCommands.Add(new TextDrawCmd_Text
{
Selected = false,
Text = line.Text,
Style = TextStyle,
Position = segmentPosition,
Scale = txtScale
});
numLinesAdded++;
yPosition += m_LineHeight;
position.Y += m_LineHeight;
}
result.BoundingBox = new Rectangle((int)topLeft.X, (int)topLeft.Y, (int)options.MaxWidth, (int)(yPosition-m_LineHeight));
result.MaxWidth = realMaxWidth;
foreach (var cmd in drawCommands)
{
cmd.Init();
}
return result;
}
示例2: CenterAround
public void CenterAround(UIElement element, int offsetX, int offsetY)
{
var bounds = element.GetBounds();
if (bounds == null) { return; }
var topLeft =
element.LocalPoint(new Microsoft.Xna.Framework.Vector2(bounds.X, bounds.Y));
this.X = offsetX + topLeft.X + ((bounds.Width - this.Width) / 2);
this.Y = offsetY + topLeft.Y + ((bounds.Height - this.Height) / 2);
}