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


C# GuiWidget.GetMinimumBoundsToEncloseChildren方法代码示例

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


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

示例1: FixOriginXIfRightToLeft

        private void FixOriginXIfRightToLeft(GuiWidget parent)
        {
            if (parent.HAnchorIsSet(HAnchor.FitToChildren) && FlowDirection == UI.FlowDirection.RightToLeft)
            {
                RectangleDouble encloseChildrenRect = parent.GetMinimumBoundsToEncloseChildren();

                for (int childIndex = 0; childIndex < parent.Children.Count; childIndex++)
                {
                    GuiWidget child = parent.Children[childIndex];
                    if (child.Visible == false)
                    {
                        continue;
                    }

                    child.OriginRelativeParent = new Vector2(child.OriginRelativeParent.x - encloseChildrenRect.Left, child.OriginRelativeParent.y);
                }
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:18,代码来源:LayoutEngineFlow.cs

示例2: FixOriginYIfTopToBottom

        private void FixOriginYIfTopToBottom(GuiWidget parent)
        {
            if (parent.VAnchorIsSet(VAnchor.FitToChildren) && FlowDirection == UI.FlowDirection.TopToBottom)
            {
                RectangleDouble encloseChildrenRect = parent.GetMinimumBoundsToEncloseChildren();

                for (int childIndex = 0; childIndex < parent.Children.Count; childIndex++)
                {
                    GuiWidget child = parent.Children[childIndex];
                    if (child.Visible == false)
                    {
                        continue;
                    }

                    child.OriginRelativeParent = new Vector2(child.OriginRelativeParent.x, child.OriginRelativeParent.y - encloseChildrenRect.Bottom);
                }
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:18,代码来源:LayoutEngineFlow.cs

示例3: DoFitToChildrenVertical

		public void DoFitToChildrenVertical(GuiWidget widgetToAdjustBounds, ref bool sizeWasChanged)
		{
			if (widgetToAdjustBounds.VAnchorIsSet(VAnchor.FitToChildren))
			{
				double heightToMatchParent = 0;
				if (widgetToAdjustBounds.Parent != null)
				{
					Vector2 newOriginRelParent;
					if (!GetOriginAndHeightForChild(widgetToAdjustBounds.Parent, widgetToAdjustBounds, out newOriginRelParent, out heightToMatchParent))
					{
						// we don't need to adjust anything for the parent so make sure this is not applied below.
						heightToMatchParent = 0;
					}
				}

				// get the bounds
				RectangleDouble adjustBounds = widgetToAdjustBounds.LocalBounds;
				// get the bounds to enclose its childern
				RectangleDouble childrenEnclosingBounds = widgetToAdjustBounds.GetMinimumBoundsToEncloseChildren(true);
				// fix the v size to enclose the children
				adjustBounds.Bottom = childrenEnclosingBounds.Bottom;
				adjustBounds.Top = Math.Max(childrenEnclosingBounds.Bottom + heightToMatchParent, childrenEnclosingBounds.Top);
				if (widgetToAdjustBounds.LocalBounds != adjustBounds)
				{
					if (widgetToAdjustBounds.VAnchorIsSet(VAnchor.ParentBottomTop))
					{
						if (widgetToAdjustBounds.LocalBounds.Height < adjustBounds.Height)
						{
							widgetToAdjustBounds.LocalBounds = adjustBounds;
							sizeWasChanged = true;
						}
					}
					else
					{
						// push the new size in
						widgetToAdjustBounds.LocalBounds = adjustBounds;
						sizeWasChanged = true;
					}
				}
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:41,代码来源:LayoutEngineSimpleAlign.cs

示例4: DoFitToChildrenHorizontal

		public void DoFitToChildrenHorizontal(GuiWidget widgetToAdjust, ref bool sizeWasChanged)
		{
			if (widgetToAdjust.HAnchorIsSet(HAnchor.FitToChildren))
			{
				double widthToMatchParent = 0;
				// let's check if the parent would like to make this widget bigger
				if (widgetToAdjust.Parent != null)
				{
					Vector2 newOriginRelParent;
					if (!GetOriginAndWidthForChild(widgetToAdjust.Parent, widgetToAdjust, out newOriginRelParent, out widthToMatchParent))
					{
						// we don't need to adjust anything for the parent so make sure this is not applied below.
						widthToMatchParent = 0;
					}
				}

				// get the bounds
				RectangleDouble widgetToAdjustBounds = widgetToAdjust.LocalBounds;
				// get the bounds to enclose its childern
				RectangleDouble childrenEnclosingBounds = widgetToAdjust.GetMinimumBoundsToEncloseChildren(true);
				// fix the h size to enclose the children
				widgetToAdjustBounds.Left = childrenEnclosingBounds.Left;
				if (widgetToAdjust.Parent != null
					&& widgetToAdjust.Parent.LayoutEngine != null)
				{
					if(widgetToAdjust.Parent.LayoutEngine as LayoutEngineFlow != null)
					{
						// The parent is a flow layout widget but it will only adjust our size if we are HAnchor leftright
						if (widgetToAdjust.HAnchorIsSet(HAnchor.ParentLeftRight))
						{
							// We make the assumption that the parent has set the size correctly assuming flow layout and this can only be made bigger if fit needs to.
							widgetToAdjustBounds.Right = Math.Max(widgetToAdjustBounds.Right, childrenEnclosingBounds.Right);
						}
						else // we need to just do the fit to children
						{
							widgetToAdjustBounds.Right = Math.Max(childrenEnclosingBounds.Left + widthToMatchParent, childrenEnclosingBounds.Right);
						}
					}
					else if ((widgetToAdjust.Parent.LayoutEngine as LayoutEngineSimpleAlign) != null)
					{
						widgetToAdjustBounds.Right = Math.Max(childrenEnclosingBounds.Left + widthToMatchParent, childrenEnclosingBounds.Right);
					}
					else
					{
							throw new NotImplementedException();
					}
				}
				else
				{
					widgetToAdjustBounds.Right = Math.Max(childrenEnclosingBounds.Left + widthToMatchParent, childrenEnclosingBounds.Right);
				}
				if (widgetToAdjust.LocalBounds != widgetToAdjustBounds)
				{
					if (widgetToAdjust.HAnchorIsSet(HAnchor.ParentLeftRight))
					{
						if (widgetToAdjust.LocalBounds.Width < widgetToAdjustBounds.Width)
						{
							widgetToAdjust.LocalBounds = widgetToAdjustBounds;
							sizeWasChanged = true;
						}
					}
					else
					{
						// push the new size in
						widgetToAdjust.LocalBounds = widgetToAdjustBounds;
						sizeWasChanged = true;
					}
				}
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:70,代码来源:LayoutEngineSimpleAlign.cs

示例5: DoFitToChildrenHorizontal

        public void DoFitToChildrenHorizontal(GuiWidget widgetToAdjust, ref bool sizeWasChanged)
        {
            if (widgetToAdjust.HAnchorIsSet(HAnchor.FitToChildren))
            {
                double widthToMatchParent = 0;
                // let's check if the parent would like to make this widget bigger
                if (widgetToAdjust.Parent != null)
                {
                    Vector2 newOriginRelParent;
                    if (!GetOriginAndWidthForChild(widgetToAdjust.Parent, widgetToAdjust, out newOriginRelParent, out widthToMatchParent))
                    {
                        // we don't need to adjust anything for the parent so make sure this is not applied below.
                        widthToMatchParent = 0;
                    }
                }

                // get the bounds
                RectangleDouble widgetToAdjustBounds = widgetToAdjust.LocalBounds;
                // get the bounds to enclose its childern
                RectangleDouble childrenEnclosingBounds = widgetToAdjust.GetMinimumBoundsToEncloseChildren(true);
                // fix the h size to enclose the children
                widgetToAdjustBounds.Left = childrenEnclosingBounds.Left;
                widgetToAdjustBounds.Right = Math.Max(childrenEnclosingBounds.Left + widthToMatchParent, childrenEnclosingBounds.Right);
                if (widgetToAdjust.LocalBounds != widgetToAdjustBounds)
                {
                    // push the new size in
                    widgetToAdjust.LocalBounds = widgetToAdjustBounds;
                    sizeWasChanged = true;
                }
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:31,代码来源:LayoutEngineSimpleAlign.cs


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