Ejemplo n.º 1
0
        private static void WriteOnlyToMemoryWithoutReplacing_UNSAFE(char c, int x, int y)
        {
            CodePageEnsurer.EnsureLegitCP850(c);

            //Write to memory
            memory.Add(new PositionedChar(new Point(x, y), c));
        }
Ejemplo n.º 2
0
        public static void Write(string s, int startLeft, int startTop, ConsoleColor color = ConsoleColor.White)
        {
            CodePageEnsurer.EnsureLegitCP850(s);

            foreach (char c in s)
            {
                IEnumerable <PositionedChar> toReplace = memory.Where(ch => ch.Position.X == startLeft && ch.Position.Y == startTop);
                if (toReplace != null && toReplace.Count() == 1)
                {
                    memory.Remove(toReplace.First());
                }

                //Write to memory
                memory.Add(new PositionedChar(new Point(startLeft, startTop), c));

                //Write to screen
                ConsoleColor before = Console.ForegroundColor;
                Console.ForegroundColor = color;
                Console.SetCursorPosition(startLeft, startTop);
                Console.Write(c);
                Console.ForegroundColor = before;

                startLeft++;
            }
        }
Ejemplo n.º 3
0
        public PositionedChar(Point position, char inputChar)
        {
            if (position == null)
            {
                throw new ArgumentNullException();
            }
            Position = position;

            CodePageEnsurer.EnsureLegitCP850(inputChar);
            Char = inputChar;
        }
Ejemplo n.º 4
0
        private static void WriteOnlyToMemory(char c, int x, int y)
        {
            CodePageEnsurer.EnsureLegitCP850(c);

            IEnumerable <PositionedChar> toReplace = memory.Where(ch => ch.Position.X == x && ch.Position.Y == y);

            if (toReplace != null && toReplace.Count() == 1)
            {
                memory.Remove(toReplace.First());
            }

            //Write to memory
            memory.Add(new PositionedChar(new Point(x, y), c));
        }
Ejemplo n.º 5
0
        public static void Write(char c, int x, int y, ConsoleColor color = ConsoleColor.White)
        {
            CodePageEnsurer.EnsureLegitCP850(c);

            IEnumerable <PositionedChar> toReplace = memory.Where(ch => ch.Position.X == x && ch.Position.Y == y);

            if (toReplace != null && toReplace.Count() == 1)
            {
                memory.Remove(toReplace.First());
            }

            //Write to memory
            memory.Add(new PositionedChar(new Point(x, y), c));

            //Write to screen
            ConsoleColor before = Console.ForegroundColor;

            Console.ForegroundColor = color;
            Console.SetCursorPosition(x, y);
            Console.Write(c);
            Console.ForegroundColor = before;
        }