本文整理汇总了C#中System.Edge.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# Edge.HasFlag方法的具体用法?C# Edge.HasFlag怎么用?C# Edge.HasFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Edge
的用法示例。
在下文中一共展示了Edge.HasFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddConstraint
/// <summary>
/// Adds a UI constraint to this control.
/// </summary>
/// <param name="controlEdge">Control edge to constraint.</param>
/// <param name="anchor">Anchoring control on which the control edge is constrained. Setting this to 'null' the control is anchored relative to the screen.</param>
/// <param name="anchorEdge">Anchor edge, on which the control edge is constrained relative to.</param>
/// <param name="edgeDistance">Distance between control and anchor constraint edge.</param>
internal void AddConstraint(Edge controlEdge, UIControl anchor, Edge anchorEdge, float edgeDistance, ConstraintCategory category)
{
// Separate edges into their basic flags.
// E.g. 'Edge.BottomRight' is separated into 'Edge.Bottom' and 'Edge.Right', and added as individual edges.
List<Edge> controlEdges = new List<Edge>(4);
List<Edge> anchorEdges = new List<Edge>(4);
foreach (Edge edgeType in EdgeTypes)
{
if (controlEdge.HasFlag(edgeType))
{
controlEdges.Add(edgeType);
}
if (anchorEdge.HasFlag(edgeType))
{
anchorEdges.Add(edgeType);
}
}
if (controlEdges.Count != anchorEdges.Count)
{
throw new ArgumentException("There must be an equal amount of control and anchor edges.");
}
for (int i = 0; i < controlEdges.Count; i++)
{
var cEdge = controlEdges[i];
var aEdge = anchorEdges[i];
if (!OnSameAxis(cEdge, aEdge))
{
throw new ArgumentException($"Control and anchor edge and must be on the same axis: {cEdge}, {aEdge}");
}
foreach (var edge in Constraints.Select(c => c.ControlEdge))
{
if (edge.Equals(cEdge))
{
throw new ArgumentException($"Control edge already bound: {cEdge}");
}
if (Edge.CenterXY.ContainsFlag(cEdge | edge) && OnSameAxis(cEdge, edge)) // Special case to check that no edge is bound to an axis along with a center edge. E.g.: CenterY and Top.
{
throw new ArgumentException($"Control axis already bound: {cEdge}, {edge}");
}
}
Constraints.Add(new UIConstraint(cEdge, anchor, aEdge, edgeDistance, category));
}
}