本文整理汇总了C#中UMD.HCIL.Piccolo.PNode.IsAncestorOf方法的典型用法代码示例。如果您正苦于以下问题:C# PNode.IsAncestorOf方法的具体用法?C# PNode.IsAncestorOf怎么用?C# PNode.IsAncestorOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMD.HCIL.Piccolo.PNode
的用法示例。
在下文中一共展示了PNode.IsAncestorOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NodeIsNeighborInDirection
/// <summary>
/// Returns true if the given node is a neighbor of the current focus in the
/// specified direction.
/// </summary>
/// <param name="aNode">The node to test.</param>
/// <param name="aDirection">The direction in which to perform the test.</param>
/// <returns>
/// True if the given node is a neighbor in the specified direction; otherwise,
/// false.
/// </returns>
public virtual bool NodeIsNeighborInDirection(PNode aNode, Direction aDirection) {
switch (aDirection) {
case Direction.In: {
return aNode.IsDescendentOf(focusNode);
}
case Direction.Out: {
return aNode.IsAncestorOf(focusNode);
}
default: {
if (aNode.IsAncestorOf(focusNode) || aNode.IsDescendentOf(focusNode)) {
return false;
}
break;
}
}
PointF highlightCenter = (PointF) NODE_TO_GLOBAL_NODE_CENTER_MAPPING[focusNode];
PointF nodeCenter = (PointF) NODE_TO_GLOBAL_NODE_CENTER_MAPPING[aNode];
float ytest1 = nodeCenter.X - highlightCenter.X + highlightCenter.Y;
float ytest2 = -nodeCenter.X + highlightCenter.X + highlightCenter.Y;
switch (aDirection) {
case Direction.North: {
if (nodeCenter.Y < highlightCenter.Y) {
if (nodeCenter.Y < ytest1 && nodeCenter.Y < ytest2) {
return true;
}
}
break;
}
case Direction.East: {
if (nodeCenter.X > highlightCenter.X) {
if (nodeCenter.Y < ytest1 && nodeCenter.Y > ytest2) {
return true;
}
}
break;
}
case Direction.South: {
if (nodeCenter.Y > highlightCenter.Y) {
if (nodeCenter.Y > ytest1 && nodeCenter.Y > ytest2) {
return true;
}
}
break;
}
case Direction.West: {
if (nodeCenter.X < highlightCenter.X) {
if (nodeCenter.Y > ytest1 && nodeCenter.Y < ytest2) {
return true;
}
}
break;
}
}
return false;
}