예제 #1
0
 public static void Render()
 {
     if (!isInitialized)
     {
         throw new InvalidOperationException("UIManager has to be initialized");
     }
     lock (_lock)
     {
         rendered = currentElement.Render();
         processSwitches();
     }
 }
예제 #2
0
 public UIScene(IRenderable[] contents, int[][] positions, string[] captions, int height, int width, ConsoleColor? captionColor = null, ConsoleColor? borderColor = null)
 {
     unrenderedContents = contents;
     this.positions = positions;
     this.captions = captions;
     this.height = height;
     this.width = width;
     this.captionColor = captionColor;
     this.borderColor = borderColor;
     lastRendered = new Canvas(height, width);
     this.preRender();
     this.Invalidate();
 }
예제 #3
0
        public Buffer(IRenderable inner, Margin margin, char filler = ' ')
        {
            this.Filler = filler;
            this.Margin = margin;
            this.Inner = inner;

            // Init canvas
            lastRendered = new Canvas(this.Height, this.Width);

            lastRendered.Symbols = Helper.Repeat(Helper.Repeat(filler, this.Width), this.Height);
            lastRendered.Colors = Helper.Repeat(Helper.Repeat(UIManager.DefaultColor, this.Width), this.Height);

            firstDrawn = false;
        }
예제 #4
0
        public Canvas Render()
        {
            if (this.HasChanged)
            {
                Canvas rendered = lastRendered;

                // Render every element that has changed since last time and insert it into the canvas
                for (int element = 0; element < unrenderedContents.Length; element++)
                {
                    if (unrenderedContents[element].HasChanged)
                    {
                        Canvas renderedElement = unrenderedContents[element].Render();
                        Helper.Copy2D(rendered.Symbols, renderedElement.Symbols, positions[element][0], positions[element][1]);
                        Helper.Copy2D(rendered.Colors, renderedElement.Colors, positions[element][0], positions[element][1]);
                    }
                }
                lastRendered = rendered;
            }
            return lastRendered;
        }
예제 #5
0
        public Canvas Render()
        {
            Canvas field = new Canvas(40, 20);
            ghost.Reset();

            while (tryMove(1, 0, ghost))
            {
                ghost.X++;
            }

            for (int x = 0; x < 40; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    field.Symbols[x][y] = isBlocked((int)Math.Floor(x / 2.0) + 2, (int)Math.Floor(y / 2.0)) ? '#' : ' ';
                    field.Colors[x][y] = effectiveColor((int) Math.Floor(x / 2.0) + 2, (int)Math.Floor(y / 2.0));
                }
            }
            return field;
        }
예제 #6
0
 public void Update(Canvas contents)
 {
     this.contents = contents;
     hasChanged = true;
 }
예제 #7
0
 public UIElement(Canvas contents)
 {
     height = contents.Height;
     width = contents.Width;
     Update(contents);
 }