Exemple #1
0
        private void Fill()
        {
            while (true)
            {
                var rect = Rectangles.FirstOrDefault(x => !x.Completed);

                if (rect == null)
                {
                    return;
                }

                var others = Rectangles.Where(x => x.ID != rect.ID).ToList();

                var topRight = rect.TopRight(others);
                if (topRight == null)
                {
                    continue;
                }

                var top  = topRight.Item2;
                var left = topRight.Item1;

                var colidingRight = others.Where(x => x.Left > left && x.Top >= top && x.Bottom < top);
                var leftMost      = colidingRight.OrderBy(x => x.Left).First();
                var right         = leftMost.Left;

                var colidingBottom = others.Where(x => x.Top < top && ((x.Left <right && x.Left> left) || (x.Right <right && x.Right> left) || (right <x.Right && right> x.Left) || (left <x.Right && left> x.Left)));
                var highest        = colidingBottom.OrderByDescending(x => x.Top).First();
                var bottom         = highest.Top;
                Rectangles.Add(new Rectangle(left, bottom, right, top));
            }
        }
Exemple #2
0
        /// <summary>
        /// Add or update screen rectangle for the view.
        /// </summary>
        private void AddOrUpdateViewRectangle()
        {
            if (Rectangles == null)
            {
                return;
            }
            var screenRectangle = Rectangles.FirstOrDefault(item => ScreenNames.View.Equals(item.Name));

            if (screenRectangle == null)
            {
                screenRectangle = new ScreenRectangle(ScreenNames.View, ViewWidth, ViewHeight);
                Rectangles.Add(screenRectangle);
            }
            else
            {
                screenRectangle.SetSize(ViewWidth, ViewHeight);
            }
        }