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


C# Rect.TopLine方法代码示例

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


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

示例1: ClosestLine

        private static Line ClosestLine(Rect rect, Point p)
        {
            var angle = new Vector(1, 1).AngleTo(p.VectorTo(rect.CenterPoint()));
            if (angle >= 0 && angle <= 90)
            {
                return rect.TopLine();
            }

            if (angle >= 90 && angle <= 180)
            {
                return rect.RightLine();
            }

            if (angle >= -90 && angle <= 0)
            {
                return rect.LeftLine();
            }

            if (angle >= -180 && angle <= -90)
            {
                return rect.BottomLine();
            }

            throw new InvalidOperationException("Could not find closest line");
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:25,代码来源:PlacementOptions.cs

示例2: GetPointOnTarget

        private Point? GetPointOnTarget(Point sourceMidPoint, Rect target)
        {
            switch (this.Vertical)
            {
                case VerticalPlacement.Auto:
                    switch (this.Horizontal)
                    {
                        case HorizontalPlacement.Auto:
                            var closestLine = ClosestLine(target, sourceMidPoint);
                            return AutoPoint(sourceMidPoint.LineTo(target.CenterPoint()), closestLine);
                        case HorizontalPlacement.Left:
                            return AutoPoint(sourceMidPoint.LineTo(target.CenterPoint()), target.LeftLine());
                        case HorizontalPlacement.Center:
                            return sourceMidPoint.Closest(target.BottomLine(), target.TopLine())
                                                 .MidPoint;
                        case HorizontalPlacement.Right:
                            return AutoPoint(sourceMidPoint.LineTo(target.CenterPoint()), target.RightLine());
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                case VerticalPlacement.Top:
                    switch (this.Horizontal)
                    {
                        case HorizontalPlacement.Auto:
                            return AutoPoint(sourceMidPoint.LineTo(target.CenterPoint()), target.TopLine());
                        case HorizontalPlacement.Left:
                            return target.TopLeft;
                        case HorizontalPlacement.Center:
                            return PointExt.MidPoint(target.TopLeft, target.TopRight);
                        case HorizontalPlacement.Right:
                            return target.TopRight;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                case VerticalPlacement.Center:
                    switch (this.Horizontal)
                    {
                        case HorizontalPlacement.Auto:
                            return sourceMidPoint.Closest(target.LeftLine(), target.RightLine())
                                                 .MidPoint;
                        case HorizontalPlacement.Left:
                            return PointExt.MidPoint(target.BottomLeft, target.TopLeft);
                        case HorizontalPlacement.Center:
                            return PointExt.MidPoint(target.TopLeft, target.BottomRight);
                        case HorizontalPlacement.Right:
                            return PointExt.MidPoint(target.BottomRight, target.TopRight);
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                case VerticalPlacement.Bottom:
                    switch (this.Horizontal)
                    {
                        case HorizontalPlacement.Auto:
                            return AutoPoint(sourceMidPoint.LineTo(target.CenterPoint()), target.BottomLine());
                        case HorizontalPlacement.Left:
                            return target.BottomLeft;
                        case HorizontalPlacement.Center:
                            return PointExt.MidPoint(target.BottomLeft, target.BottomRight);
                        case HorizontalPlacement.Right:
                            return target.BottomRight;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:71,代码来源:PlacementOptions.cs

示例3: FirstIntersectionWith

        internal Point? FirstIntersectionWith(Rect rectangle)
        {
            var quadrant = rectangle.Contains(this.Point)
                ? this.Direction.Quadrant()
                : this.Direction.Negated().Quadrant();

            switch (quadrant)
            {
                case Quadrant.NegativeXPositiveY:
                    return IntersectionPoint(this, rectangle.LeftLine(), true) ??
                           IntersectionPoint(this, rectangle.BottomLine(), true);
                case Quadrant.PositiveXPositiveY:
                    return IntersectionPoint(this, rectangle.RightLine(), true) ??
                           IntersectionPoint(this, rectangle.BottomLine(), true);
                case Quadrant.PositiveXNegativeY:
                    return IntersectionPoint(this, rectangle.RightLine(), true) ??
                           IntersectionPoint(this, rectangle.TopLine(), true);
                case Quadrant.NegativeXNegativeY:
                    return IntersectionPoint(this, rectangle.LeftLine(), true) ??
                           IntersectionPoint(this, rectangle.TopLine(), true);
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:24,代码来源:Ray.cs


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