Esempio n. 1
0
        public ConsoleBitmap(Rectangle bounds, ConsoleCharacter? bg = null)
        {
            _syncLock = new object();
            this.Top = bounds.Y;
            this.Left = bounds.X;

            bounds = new Rectangle(0, 0, bounds.Width, bounds.Height);

            this.Bounds = bounds;
            this.scope = bounds;
            this.Console = ConsoleProvider.Current;
            this.Background = bg.HasValue ? bg.Value : new ConsoleCharacter(' ');
            this.Pen = new ConsoleCharacter('*');
            pixels = new ConsolePixel[this.Width][];
            for (int x = 0; x < this.Width; x++)
            {
                pixels[x] = new ConsolePixel[this.Height];
                for (int y = 0; y < pixels[x].Length; y++)
                {
                    pixels[x][y] = new ConsolePixel() { Value = bg };
                }
            }
        }
Esempio n. 2
0
 public void Scope(Rectangle bounds)
 {
     this.scope = bounds;
 }
Esempio n. 3
0
        public void Rescope(int xIncrement, int yIncrement, int w, int h)
        {
            w = Math.Min(w, scope.Width - xIncrement);
            h = Math.Min(h, scope.Height - yIncrement);

            scope = new Rectangle(scope.X + xIncrement, scope.Y + yIncrement, w, h);
        }
Esempio n. 4
0
 public bool IsRightOf(Rectangle other)
 {
     return Right > other.Right;
 }
Esempio n. 5
0
 public bool IsLeftOf(Rectangle other)
 {
     return Left < other.Left;
 }
Esempio n. 6
0
 public bool IsBelow(Rectangle other)
 {
     return Bottom > other.Bottom;
 }
Esempio n. 7
0
 public bool IsAbove(Rectangle other)
 {
     return Top < other.Top;
 }
Esempio n. 8
0
        public bool Contains(Rectangle other)
        {
            var insideLeftEdge = other.Left >= Left;
            var insideRightEdge = other.Right <= Right;

            var insideTopEdge = other.Top >= Top;
            var insideBottomEdge = other.Bottom <= Bottom;

            return insideLeftEdge && insideRightEdge && insideTopEdge && insideBottomEdge;
        }
        private void FocusChanged()
        {
            bool focusedControlIsWithinMe = VisitControlTree((control) =>
            {
                return control == Application.FocusManager.FocusedControl;
            });

            if (focusedControlIsWithinMe)
            {
                var offset = Application.FocusManager.FocusedControl.CalculateRelativePosition(this);

                var visibleWindowBounds = new Rectangle(HorizontalScrollUnits, VerticalScrollUnits, Width, Height);
                var focusedControlBounds = new Rectangle(offset, Application.FocusManager.FocusedControl.Size);

                if (focusedControlBounds.IsAbove(visibleWindowBounds))
                {
                    int amount = visibleWindowBounds.Top - focusedControlBounds.Top;
                    VerticalScrollUnits -= amount;
                }

                if (focusedControlBounds.IsBelow(visibleWindowBounds))
                {
                    int amount = focusedControlBounds.Bottom - visibleWindowBounds.Bottom;
                    VerticalScrollUnits += amount;
                }

                if (focusedControlBounds.IsLeftOf(visibleWindowBounds))
                {
                    int amount = visibleWindowBounds.Left - focusedControlBounds.Left;
                    HorizontalScrollUnits -= amount;
                }

                if (focusedControlBounds.IsRightOf(visibleWindowBounds))
                {
                    int amount = focusedControlBounds.Right - visibleWindowBounds.Right;
                    HorizontalScrollUnits += amount;
                }
            }
        }