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


C# DesignItem.GetBehavior方法代码示例

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


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

示例1: ChangeContainer

		/// <summary>
		/// Make the placed item switch the container.
		/// This method assumes that you already have checked if changing the container is possible.
		/// </summary>
		public void ChangeContainer(DesignItem newContainer)
		{
			if (newContainer == null)
				throw new ArgumentNullException("newContainer");
			if (isAborted || isCommitted)
				throw new InvalidOperationException("The operation is not running anymore.");
			if (currentContainer == newContainer)
				return;
			
			if (!currentContainerBehavior.CanLeaveContainer(this))
				throw new NotSupportedException("The items cannot be removed from their parent container.");
			
			try {
				currentContainerBehavior.LeaveContainer(this);
				
				GeneralTransform transform = currentContainer.View.TransformToVisual(newContainer.View);
				
				foreach (PlacementInformation info in placedItems) {
					info.OriginalBounds = TransformRectByMiddlePoint(transform, info.OriginalBounds);
					info.Bounds = TransformRectByMiddlePoint(transform, info.Bounds).Round();
				}
				
				currentContainer = newContainer;
				currentContainerBehavior = newContainer.GetBehavior<IPlacementBehavior>();
				
				Debug.Assert(currentContainerBehavior != null);
				currentContainerBehavior.EnterContainer(this);
			} catch (Exception ex) {
				Debug.WriteLine(ex.ToString());
				Abort();
				throw;
			}
		}
开发者ID:JGroot,项目名称:SharpDevelop,代码行数:37,代码来源:PlacementOperation.cs

示例2: TryStartInsertNewComponents

		/// <summary>
		/// Try to insert new components into the container.
		/// </summary>
		/// <param name="container">The container that should become the parent of the components.</param>
		/// <param name="placedItems">The components to add to the container.</param>
		/// <param name="positions">The rectangle specifying the position the element should get.</param>
		/// <param name="type">The type </param>
		/// <returns>The operation that inserts the new components, or null if inserting is not possible.</returns>
		public static PlacementOperation TryStartInsertNewComponents(DesignItem container, IList<DesignItem> placedItems, IList<Rect> positions, PlacementType type)
		{
			if (container == null)
				throw new ArgumentNullException("container");
			if (placedItems == null)
				throw new ArgumentNullException("placedItems");
			if (positions == null)
				throw new ArgumentNullException("positions");
			if (type == null)
				throw new ArgumentNullException("type");
			if (placedItems.Count == 0)
				throw new ArgumentException("placedItems.Count must be > 0");
			if (placedItems.Count != positions.Count)
				throw new ArgumentException("positions.Count must be = placedItems.Count");
			
			DesignItem[] items = placedItems.ToArray();
			
			PlacementOperation op = new PlacementOperation(items, type);
			try {
				for (int i = 0; i < items.Length; i++) {
					op.placedItems[i].OriginalBounds = op.placedItems[i].Bounds = positions[i];
				}
				op.currentContainer = container;
				op.currentContainerBehavior = container.GetBehavior<IPlacementBehavior>();
				if (op.currentContainerBehavior == null || !op.currentContainerBehavior.CanEnterContainer(op, true)) {
					op.changeGroup.Abort();
					return null;
				}
				op.currentContainerBehavior.EnterContainer(op);
			} catch (Exception ex) {
				Debug.WriteLine(ex.ToString());
				op.changeGroup.Abort();
				throw;
			}
			return op;
		}
开发者ID:JGroot,项目名称:SharpDevelop,代码行数:44,代码来源:PlacementOperation.cs


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