當前位置: 首頁>>代碼示例>>C#>>正文


C# Edge.HasFlag方法代碼示例

本文整理匯總了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));
            }
        }
開發者ID:adamxi,項目名稱:SharpDXFramework,代碼行數:55,代碼來源:UIConstrainer.cs


注:本文中的System.Edge.HasFlag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。