Beispiel #1
0
        public void Clear(string boxName)
        {
            DisplayBox box = displayBoxes.FirstOrDefault(x => x.Name == boxName);

            if (box != null)
            {
                for (int i = box.DisplayX; i < box.DisplayX + box.DisplayWidth; i++)
                {
                    for (int j = box.DisplayY; j < box.DisplayY + box.DisplayHeight; j++)
                    {
                        buffer[i, j] = new ColoredChar();
                    }
                }
            }
        }
Beispiel #2
0
 public void Add(DisplayBox box)
 {
     if (displayBoxes.Exists(x => x.Name == box.Name))
     {
         throw new DisplayBoxExistsException(box.Name);
     }
     else
     {
         foreach (DisplayBox boxInList in displayBoxes)
         {
             Rect intersection = Rect.Intersect(box.Rectangle, boxInList.Rectangle);
             if (intersection.Width > 0 && intersection.Height > 0)
             {
                 throw new DisplayBoxOverlapException();
             }
         }
     }
     displayBoxes.Add(box);
 }
Beispiel #3
0
        public void WriteString(string boxName, string str, ConsoleColor foregroundColor, ConsoleColor backgroundColor, int line, int col)
        {
            DisplayBox box = displayBoxes.FirstOrDefault(x => x.Name == boxName);

            if (box != null)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    if (col + i < box.DisplayWidth)
                    {
                        buffer[box.DisplayX + col + i, box.DisplayY + line] = new ColoredChar {
                            BackgroundColor = backgroundColor, Character = str[i], ForegroundColor = foregroundColor
                        }
                    }
                    ;
                }
            }
            else
            {
                throw new ArgumentException("Display box with given name does not exists");
            }
        }