예제 #1
0
        public void Copy(ConsoleArea window, Position offset)
        {
            var minHeight = Math.Min(window.Size.Height, Size.Height - offset.Y);
            var minWidth  = Math.Min(window.Size.Width, Size.Width - offset.X);

            for (var y = 0; y < minHeight; ++y)
            {
                for (var x = 0; x < minWidth; ++x)
                {
                    var position    = new Position(x, y);
                    var sourceIndex = window.GetCharacterIndex(position);

                    if (sourceIndex < 0)
                    {
                        continue;
                    }
                    var targetIndex = GetCharacterIndex(position + offset);

                    if (targetIndex < 0)
                    {
                        continue;
                    }
                    characters [targetIndex] = window.characters [sourceIndex];
                }
            }
        }
        public void Update(ConsoleArea window)
        {
            Console.CursorVisible = false;
            int lastX        = -1;
            int lastY        = -1;
            var updateHeight = Math.Min(window.Size.Height, screenWindow.Size.Height);
            var updateWidth  = Math.Min(window.Size.Width, screenWindow.Size.Width);

            var chars = window.ConsoleCharacters;

            for (var y = 0; y < updateHeight; ++y)
            {
                for (var x = 0; x < updateWidth; ++x)
                {
                    var position    = new Position(x, y);
                    var sourceIndex = window.GetCharacterIndex(position);
                    var sourceChar  = window.ConsoleCharacters [sourceIndex];
                    var targetIndex = screenWindow.GetCharacterIndex(position);
                    var targetChar  = screenWindow.ConsoleCharacters [targetIndex];

                    if (!sourceChar.IsSame(targetChar))
                    {
                        if (x != lastX || y != lastY)
                        {
                            SetCursorPosition(x, y);
                        }
                        SetCharacterAndColor(sourceChar);
                        lastX = x + 1;
                        lastY = y;
                        screenWindow.ConsoleCharacters [targetIndex] = sourceChar;
                    }
                }
            }
            _driver.Move(window.CursorPosition);
            _driver.Refresh();
            // Console.CursorVisible = true;
        }