当前位置: 首页>>代码示例>>C#>>正文


C# Path.SubPath方法代码示例

本文整理汇总了C#中Path.SubPath方法的典型用法代码示例。如果您正苦于以下问题:C# Path.SubPath方法的具体用法?C# Path.SubPath怎么用?C# Path.SubPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path.SubPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertNode

		/// <summary>
		/// Insert a node to the proper depth using the path.
		/// </summary>
		public void InsertNode(FolderConfigurationNodeBase node, Path path)
		{
			// There is no recommended path.  Add it immediately
			if (path == null || path.Segments.Count == 0)
			{
				AddChildNode(node);
				return;
			}

			var text  = CollectionUtils.FirstElement(path.Segments).LocalizedText;
			var childWithMatchingText = _subTree == null ? null : CollectionUtils.SelectFirst(_subTree.Items, child => child.Text == text);
			
			if (childWithMatchingText == null)
			{
				if (path.Segments.Count == 1)
				{
					// There are no more depth to the path, add child now.
					AddChildNode(node);
					PropagateCheckStateUp(node.Parent);
				}
				else
				{
					// create a container node and insert into the container node's subtree
					var containerNode = new ContainerNode(text);
					AddChildNode(containerNode);
					containerNode.InsertNode(node, path.SubPath(1, path.Segments.Count - 1));
				}
			}
			else
			{
				if (path.Segments.Count == 1)
				{
					// There are no more depth to the path, add child now.
					if (childWithMatchingText is ContainerNode)
						ReplaceChildNode(childWithMatchingText, node);
					else
						AddChildNode(node);

					PropagateCheckStateUp(node.Parent);
				}
				else
				{
					// insert this node child's subtree
					childWithMatchingText.InsertNode(node, path.SubPath(1, path.Segments.Count - 1));
				}
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:50,代码来源:FolderExplorerConfigurationTreeNode.cs

示例2: CreateLoadingPriorsAction

		private static IClickAction CreateLoadingPriorsAction(ActionPlaceholder actionPlaceholder, string basePath, int number)
		{
			const string actionIdPrefix = "loadingPriors";
			
			Path pathSuffix = new Path(basePath);
			pathSuffix = pathSuffix.SubPath(1, pathSuffix.Segments.Count - 1);
			pathSuffix = pathSuffix.Append(new PathSegment(actionIdPrefix));

			string actionId = actionIdPrefix + number;
			var action = actionPlaceholder.CreateMenuAction(actionId, pathSuffix.ToString(), ClickActionFlags.None, null);
			action.Label = SR.LabelLoadingPriors;
			action.SetClickHandler(delegate { });
			return action;
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:14,代码来源:ContextMenuLayoutTool.cs


注:本文中的Path.SubPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。