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


C# Rect.Contains方法代码示例

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


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

示例1: _contentGrid_ManipulationStarted

        private void _contentGrid_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
        {
            if (e.PointerDeviceType != PointerDeviceType.Touch)
            {
                return;
            }
            if (manipulationStatus == ManipulationStatus.None)
            {
                if (PivotItem != null && FrozenColumns > 0)
                {
                    var pt = e.Position;
                    pt = this.TransformToVisual(_columnHeaderPanel).TransformPoint(pt);

                    var fx = _columnHeaderPanel.Columns.GetFrozenSize();
                    // adjust for scroll position
                    var sp = _columnHeaderPanel.ScrollPosition;
                    if (pt.X < 0 || pt.X > fx) pt.X -= sp.X;
                    var column = _columnHeaderPanel.Columns.GetItemAt(pt.X);
                    if (FrozenColumns > column)
                    {
                        startingCrossSlideLeft = startingCrossSlideRight = true;
                    }
                }

                if (_header != null)
                {
                    var pt = e.Position;
                    pt = this.TransformToVisual(_header).TransformPoint(pt);
                    var rect = new Rect(0, 0, _header.ActualWidth, _header.ActualHeight);
                    if (rect.Contains(pt))
                    {
                        if (PivotItem != null)
                        {
                            startingCrossSlideLeft = startingCrossSlideRight = true;
                        }
                        manipulationOnHeaderOrFooter = true;
                    }
                }

                if (_footer != null)
                {
                    var pt = e.Position;
                    pt = this.TransformToVisual(_footer).TransformPoint(pt);
                    var rect = new Rect(0, 0, _footer.ActualWidth, _footer.ActualHeight);
                    if (rect.Contains(pt))
                    {
                        if (PivotItem != null)
                        {
                            startingCrossSlideLeft = startingCrossSlideRight = true;
                        }
                        manipulationOnHeaderOrFooter = true;
                    }
                }
            }
        }
开发者ID:GJian,项目名称:UWP-master,代码行数:55,代码来源:DataGridTouchMethods.cs

示例2: IsElementFullVisible

        public static bool IsElementFullVisible(FrameworkElement element, FrameworkElement container)
        {
            if (element.Visibility == Visibility.Collapsed)
                return false;

            var elementSize = new Rect(0.0, 0.0, element.ActualWidth, element.ActualHeight);

            Rect bounds = element.TransformToVisual(container).TransformBounds(elementSize);

            var parentBounds = new Rect(0.0, 0.0, container.ActualWidth, container.ActualHeight);

            return parentBounds.Contains(new Point(bounds.Left, bounds.Top)) && parentBounds.Contains(new Point(bounds.Right, bounds.Bottom));
        }
开发者ID:juanpaexpedite,项目名称:MasterDetailsComposition,代码行数:13,代码来源:ElementManager.cs

示例3: Update

        /// <summary>
        /// Core game method. Updates state of the game.
        /// </summary>
        public void Update()
        {
            _lastUpdated = DateTime.Now;

            Twinkle(); // Stars always twinkle
            if(!GameOver)
            {
                // Check if there is any invader ship. If not, create new wave
                if(!_invaders.Any())
                    NextWave();

                // Check if player is alive
                if(!PlayerDying)
                {
                    MoveInvaders();

                    // Move all shots
                    Rect playAreaRect = new Rect(new Point(0, 0), PlayAreaSize);

                    foreach (var shot in _playerShots)
                    {
                        shot.Move();
                        if (!playAreaRect.Contains(shot.Location))
                            _playerShots.Remove(shot);
                        OnShotMoved(shot, false);
                    }
                    foreach (var shot in _invaderShots)
                    {
                        shot.Move();
                        if (!playAreaRect.Contains(shot.Location))
                            _invaderShots.Remove(shot);
                        OnShotMoved(shot, false);
                    }

                    ReturnFire();

                    // Collisions check
                    // At first check for shots which struck into invader ship

                    //We are using ToList() to make collection copy. We're iterating through copy
                    // and we're using remove on the original collection. This prevents the occurrence
                    // of an exception.
                    foreach (Shot playerShot in _playerShots.ToList())
                    {
                        foreach (Invader invader in _invaders.ToList())
                        {
                            if (CheckForInvaderCollision(playerShot, invader))
                            {
                                _invaders.Remove(invader);
                                OnShipChanged(invader, true);
                                _playerShots.Remove(playerShot);
                                OnShotMoved(playerShot, true);
                                break;
                            }
                        }
                    }
                    // Check if any enemy shot struck player ship
                    foreach (Shot enemyShot in _invaderShots.ToList())
                    {
                        if (CheckForPlayerCollision(enemyShot))
                        {
                            _playerDied = DateTime.Now;
                            OnShipChanged(_player, true);
                            _invaderShots.Remove(enemyShot);
                            OnShotMoved(enemyShot, true);
                            break;
                        }
                    }
                }
            }
        }
开发者ID:Arasz,项目名称:Invaders,代码行数:74,代码来源:InvadersModel.cs

示例4: Intersects

		public static bool Intersects(Point p1, Point p2, Rect r)
		{
			return Intersects(p1, p2, new Point(r.X, r.Y), new Point(r.X + r.Width, r.Y)).HasValue ||
				   Intersects(p1, p2, new Point(r.X + r.Width, r.Y), new Point(r.X + r.Width, r.Y + r.Height)).HasValue ||
				   Intersects(p1, p2, new Point(r.X + r.Width, r.Y + r.Height), new Point(r.X, r.Y + r.Height)).HasValue ||
				   Intersects(p1, p2, new Point(r.X, r.Y + r.Height), new Point(r.X, r.Y)).HasValue ||
				   (r.Contains(p1) && r.Contains(p2));
		}
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:8,代码来源:VectorMath.cs

示例5: CheckIsSelected

 //check if point is in shape
 public virtual Boolean CheckIsSelected(Point point)
 {
     Rect rect = new Rect(TopLeftPoint, BottomRightPoint);
     return rect.Contains(point);
 }
开发者ID:housemeow,项目名称:MyPaint,代码行数:6,代码来源:Shape.cs

示例6: OnPointerEntered

        protected override void OnPointerEntered(PointerRoutedEventArgs e)
        {
            base.OnPointerEntered(e);
            double leftLimit = (ActualWidth / 2) - (YawGazJoystick.ActualWidth / 2);
            double rightLimit = (ActualWidth / 2) + (YawGazJoystick.ActualWidth / 2);
            double topLimit = YawGazJoystick.ActualHeight / 2;
            double bottomLimit = ActualHeight - (YawGazJoystick.ActualWidth / 2);
            if (e.Pointer.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch)
                return;
            Point pos = e.GetCurrentPoint(JoystickGrid).Position;
            var joy = pos.X < (ActualWidth / 2) ? RollPitchJoystick : YawGazJoystick;
            var bounds = new Rect(joy.ActualWidth / 2, joy.ActualHeight / 2, JoystickGrid.ActualWidth - joy.ActualWidth / 2, JoystickGrid.ActualHeight - joy.ActualHeight / 2);
            if (!bounds.Contains(pos))
                return;
            joy.Margin = new Thickness(pos.X - joy.ActualWidth / 2, pos.Y - joy.ActualHeight / 2, 0, 0);
            joy.VerticalAlignment = VerticalAlignment.Top;
            joy.HorizontalAlignment = HorizontalAlignment.Left;

            //if (location.Y > topLimit && location.Y < bottomLimit)
            //{
            //    JoystickControl joystick = null;
            //    if (location.X < leftLimit)
            //    {
            //        joystick = RollPitchJoystick;
            //    }
            //    else if (location.X > rightLimit)
            //    {
            //        joystick = YawGazJoystick;
            //        //YawGazJoystick.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            //        //YawGazJoystick.Margin = new Thickness(0, location.Y - joyPos.X, ActualWidth - location.X - joyPos.Y, 0);
            //    }
            //    if (joystick != null)
            //    {
            //        var joyPos = new Point(RollPitchJoystick.ActualWidth / 2, RollPitchJoystick.ActualHeight / 2);
            //        joystick.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            //        joystick.Margin = new Thickness(location.X - joyPos.X, location.Y - joyPos.Y, 0, 0);
            //    }
            //}
        }
开发者ID:napolini,项目名称:SDK,代码行数:39,代码来源:FlyPage.xaml.cs

示例7: PointerMoved

        static void PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            FrameworkElement uiElement = sender as FrameworkElement;
            if (uiElement == null) return;
            Point ptStart = GetStartPoint(uiElement);
            Point pt = e.GetCurrentPoint(null).Position;
            
            Rect itemRect = new Rect(ptStart.X, ptStart.Y, uiElement.ActualWidth, uiElement.ActualHeight);

            Debug.WriteLine(itemRect.ToString());
            if (itemRect.Contains(pt)) {
                Debug.WriteLine("down:" + pt.ToString());
                DisplayDownAnimation(uiElement);
            }
            else
            {
                Debug.WriteLine("up:"+pt.ToString());
                DisplayUpAnimation(uiElement);
            }

            // DOESN'T work
            //var elems = VisualTreeHelper.FindElementsInHostCoordinates(pt, uiElement);
            //if (elems.Contains(uiElement))
            
        }
开发者ID:xdumaine,项目名称:Avocado,代码行数:25,代码来源:TapBehaviour.cs

示例8: OnPointerEntered

        protected override void OnPointerEntered(PointerRoutedEventArgs e)
        {
            base.OnPointerEntered(e);

            if (e.Pointer.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch)
                return;

            Point pos = e.GetCurrentPoint(JoystickGrid).Position;
            var joy = pos.X < (ActualWidth / 2) ? RollPitchJoystick : YawGazJoystick;
            var bounds = new Rect(joy.ActualWidth / 2, joy.ActualHeight / 2, JoystickGrid.ActualWidth - joy.ActualWidth / 2, JoystickGrid.ActualHeight - 75 - joy.ActualHeight / 2);
            if (!bounds.Contains(pos))
                return;
            joy.Margin = new Thickness(pos.X - joy.ActualWidth / 2, pos.Y - joy.ActualHeight / 2, 0, 0);
            joy.VerticalAlignment = VerticalAlignment.Top;
            joy.HorizontalAlignment = HorizontalAlignment.Left;
        }
开发者ID:Eggies,项目名称:SDK,代码行数:16,代码来源:PilotagePage.xaml.cs


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