public bool HitTestFocusBorder(Point point, out HitSpot hitSpot)
        {
            hitSpot = HitSpot.None;
            if (!selected)
            {
                return(false);
            }
            else
            {
                Rectangle rectInner = Rectangle.Round(Path.GetBounds());
                Rectangle rectOuter = rectInner;
                rectOuter.Inflate(new Size(focusBorderSpace, focusBorderSpace));
                if (rectOuter.Contains(point) && !rectInner.Contains(point))
                {
                    // Here's the simplest hit-testing code.
                    // However, it's insufficient because it doesn't indicate
                    // the side where the hit took place.
                }
                else
                {
                    return(false);
                }

                bool top    = false;
                bool bottom = false;
                bool left   = false;
                bool right  = false;
                if (Math.Abs(point.X - location.X) < focusBorderSpace)
                {
                    left = true;
                }
                if (Math.Abs(point.X - (location.X + size.Width)) < focusBorderSpace)
                {
                    right = true;
                }
                if (Math.Abs(point.Y - location.Y) < focusBorderSpace)
                {
                    top = true;
                }
                if (Math.Abs(point.Y - (location.Y + size.Height)) < focusBorderSpace)
                {
                    bottom = true;
                }
                if (top && left)
                {
                    hitSpot = HitSpot.TopLeftCorner;
                }
                else if (top && right)
                {
                    hitSpot = HitSpot.TopRightCorner;
                }
                else if (bottom && left)
                {
                    hitSpot = HitSpot.BottomLeftCorner;
                }
                else if (bottom && right)
                {
                    hitSpot = HitSpot.BottomRightCorner;
                }
                else if (top)
                {
                    hitSpot = HitSpot.Top;
                }
                else if (bottom)
                {
                    hitSpot = HitSpot.Bottom;
                }
                else if (left)
                {
                    hitSpot = HitSpot.Left;
                }
                else if (right)
                {
                    hitSpot = HitSpot.Right;
                }

                if (hitSpot == HitSpot.None)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Ejemplo n.º 2
0
		public bool HitTestFocusBorder(Point point, out HitSpot hitSpot)
		{
			hitSpot = HitSpot.None;
			if (!selected)
			{
				return false;
			}
			else
			{
				Rectangle rectInner = Rectangle.Round(Path.GetBounds());
				Rectangle rectOuter = rectInner;
				rectOuter.Inflate(new Size(focusBorderSpace, focusBorderSpace));
				if (rectOuter.Contains(point) && !rectInner.Contains(point))
				{
					// Here's the simplest hit-testing code.
					// However, it's insufficient because it doesn't indicate
					// the side where the hit took place.
				}
				else
				{
					return false;
				}

				bool top = false;
				bool bottom = false;
				bool left = false;
				bool right = false;
				if (Math.Abs(point.X - location.X) < focusBorderSpace)
				{
					left = true;
				}
				if (Math.Abs(point.X - (location.X + size.Width)) < focusBorderSpace)
				{
					right = true;
				}
				if (Math.Abs(point.Y - location.Y) < focusBorderSpace)
				{
					top = true;
				}
				if (Math.Abs(point.Y - (location.Y + size.Height)) < focusBorderSpace)
				{
					bottom = true;
				}
				if (top && left) hitSpot = HitSpot.TopLeftCorner;
				else if (top && right) hitSpot = HitSpot.TopRightCorner;
				else if (bottom && left) hitSpot = HitSpot.BottomLeftCorner;
				else if (bottom && right) hitSpot = HitSpot.BottomRightCorner;
				else if (top) hitSpot = HitSpot.Top;
				else if (bottom) hitSpot = HitSpot.Bottom;
				else if (left) hitSpot = HitSpot.Left;
				else if (right) hitSpot = HitSpot.Right;

				if (hitSpot == HitSpot.None)
					return false;
				else
					return true;
			}
		}