Ejemplo n.º 1
0
 // If s is immediately adjacent to (shares a border with) us, then add it to the
 // appropriate direction list. If s is not "touching" us, then it will not get added to
 // any list. s can be added to at most one list (hence use of "else if" instead of just
 // a sequence of "if's").
 public void AddDirectionTo(SnagScreen s)
 {
     if ((R.Right == s.R.Left) && OverlapY(R, s.R))
     {
         ToRight.Add(s);
     }
     else if ((R.Left == s.R.Right) && OverlapY(R, s.R))
     {
         ToLeft.Add(s);
     }
     else if ((R.Top == s.R.Bottom) && OverlapX(R, s.R))
     {
         Above.Add(s);
     }
     else if ((R.Bottom == s.R.Top) && OverlapX(R, s.R))
     {
         Below.Add(s);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Links both <see cref="Display"/>s if they are adjacent. Does nothing otherwise.
        /// Adjacent means that both <see cref="Display"/>s share a border
        /// The <see cref="Display"/> passed in will be added to at most one List (<see cref="ToLeft"/>, <see cref="ToRight"/>, <see cref="Above"/>, <see cref="Below"/>)
        /// </summary>
        /// <param name="display"></param>
        public void Link(Display display)
        {
            if (display == null)
            {
                throw new ArgumentNullException(nameof(display));
            }

            if ((Bounds.Right == display.Bounds.Left) && GeometryUtil.OverlapY(Bounds, display.Bounds))
            {
                ToRight.Add(display);
            }
            else if ((Bounds.Left == display.Bounds.Right) && GeometryUtil.OverlapY(Bounds, display.Bounds))
            {
                ToLeft.Add(display);
            }
            else if ((Bounds.Top == display.Bounds.Bottom) && GeometryUtil.OverlapX(Bounds, display.Bounds))
            {
                Above.Add(display);
            }
            else if ((Bounds.Bottom == display.Bounds.Top) && GeometryUtil.OverlapX(Bounds, display.Bounds))
            {
                Below.Add(display);
            }
        }