本文整理匯總了C#中System.Windows.Controls.TextBlock.GetLength方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBlock.GetLength方法的具體用法?C# TextBlock.GetLength怎麽用?C# TextBlock.GetLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.GetLength方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Validate
public void Validate( ref TextBlock[,] textblocks, List<Point> alreadyUsedPoints )
{
var laidPoints = new List<Point>();
for(var i = 0; i < textblocks.GetLength(1); i++)
{
for(var j = 0; j < textblocks.GetLength(0); j++)
{
if(!Util.IsEmpty(textblocks[j, i]?.Text))
{
laidPoints.Add(new Point(j,i));
}
}
}
for(var i = 0; i < textblocks.GetLength(1); i++)
{
for(var j = 0; j < textblocks.GetLength(0); j++)
{
if(App.GameModel.PlayerToMove != App.GameModel.Me)
{
textblocks[j, i].AllowDrop = false;
continue;
}
// noch keine Buchstaben gelegt in diesen Zug
switch (alreadyUsedPoints.Count)
{
case 0:
// erster Zug ueberhaupt
if(App.GameModel.IsFirstMove)
{
ValidateBetweenPoints(ref textblocks, Util.NullPoint, App.GameModel.Centre, j, i);
}
// ein spaeterer Zug
else
{
foreach(var p2 in laidPoints)
{
var b = ValidateBetweenPoints(ref textblocks, Util.NullPoint, p2, j, i);
if(b) break;
}
}
break;
case 1:
{
var p1 = alreadyUsedPoints.FirstOrDefault();
// erster Zug ueberhaupt
if(App.GameModel.IsFirstMove)
{
ValidateBetweenPoints(ref textblocks, p1, App.GameModel.Centre, j, i);
}
// ein spaeterer Zug
else
{
// Alle Punkt,in gleicher Spalte oder Zeile, die 7 Einheiten entfernt sind
var endPoints = laidPoints.Where(p => ( Util.DoubleCompare(p.X, p1.X) || Util.DoubleCompare(p.Y, p1.Y) ) && Util.CalcDistance(p, p1) <= 7 && Util.CalcDistance(p, p1) > 0);
foreach(var p2 in endPoints)
{
var b = ValidateBetweenPoints(ref textblocks, p1, p2, j, i);
if(b) break;
}
}
}
break;
default:
{
var p1 = alreadyUsedPoints.ElementAtOrDefault(0);
var p2 = alreadyUsedPoints.ElementAtOrDefault(1);
var d = Util.PointRelativeTo(p1, p2);
// horizontal
if (d == Util.Direction.Left || d == Util.Direction.Right)
{
var leftestPoint = Util.MinPoint(alreadyUsedPoints, Util.Axis.X);
var rightestPoint = Util.MaxPoint(alreadyUsedPoints, Util.Axis.X);
ValidateBetweenPoints(ref textblocks, leftestPoint, rightestPoint, j, i);
}
// vertikal
else if (d == Util.Direction.Top || d == Util.Direction.Bottom)
{
var highestPoint = Util.MinPoint(alreadyUsedPoints, Util.Axis.Y);
var lowestPoint = Util.MaxPoint(alreadyUsedPoints, Util.Axis.Y);
ValidateBetweenPoints(ref textblocks, highestPoint, lowestPoint, j, i);
}
}
break;
}
}
}
}