當前位置: 首頁>>代碼示例>>C#>>正文


C# PNode.IsAncestorOf方法代碼示例

本文整理匯總了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;
		}
開發者ID:malacandrian,項目名稱:Piccolo.NET,代碼行數:72,代碼來源:PNavigationEventHandler.cs


注:本文中的UMD.HCIL.Piccolo.PNode.IsAncestorOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。