本文整理汇总了C#中MatterHackers.Agg.UI.GuiWidget.HAnchorIsSet方法的典型用法代码示例。如果您正苦于以下问题:C# GuiWidget.HAnchorIsSet方法的具体用法?C# GuiWidget.HAnchorIsSet怎么用?C# GuiWidget.HAnchorIsSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatterHackers.Agg.UI.GuiWidget
的用法示例。
在下文中一共展示了GuiWidget.HAnchorIsSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例2: 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;
}
}
}
}
示例3: ApplyHAnchorToChild
protected override void ApplyHAnchorToChild(GuiWidget parent, GuiWidget child)
{
if (FlowDirection == UI.FlowDirection.BottomToTop || FlowDirection == UI.FlowDirection.TopToBottom)
{
base.ApplyHAnchorToChild(parent, child);
}
else
{
if (child.HAnchor == HAnchor.ParentLeftRight || child.HAnchorIsSet(HAnchor.FitToChildren))
{
}
else if (child.HAnchor != HAnchor.None)
{
throw new Exception("HAnchor for a left right flow widget needs to be none or ParentLeftRight.");
}
}
}
示例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;
widgetToAdjustBounds.Right = Math.Max(childrenEnclosingBounds.Left + widthToMatchParent, childrenEnclosingBounds.Right);
if (widgetToAdjust.LocalBounds != widgetToAdjustBounds)
{
// push the new size in
widgetToAdjust.LocalBounds = widgetToAdjustBounds;
sizeWasChanged = true;
}
}
}