Exemplo n.º 1
0
        public static void Main()
        {
            var canvasSize = new IntSize(400, 800);

            var div = new HTMLDivElement();

            div.style.width  = $"{canvasSize.Width}px";
            div.style.height = $"{canvasSize.Height}px";
            document.body.appendChild(div);

            var button = new HTMLButtonElement();

            button.innerHTML             = "Click on game area to start it!";
            button.style.width           = "100%";
            button.style.height          = "100%";
            button.style.backgroundColor = "#6495ED";
            button.style.color           = "#ffffff";
            button.style.fontSize        = "20px";
            div.appendChild(button);

            button.onclick = (ev) =>
            {
                div.removeChild(button);

                var canvas = new HTMLCanvasElement();
                canvas.style.width  = "100%";
                canvas.style.height = "100%";
                canvas.id           = "monogamecanvas";
                div.appendChild(canvas);

                game = new TheGame(canvasSize, Platform.Desktop);
                game.Run();
            };
        }
Exemplo n.º 2
0
        static void Main()
        {
            var div = new HTMLDivElement();

            div.style.width  = "800px";
            div.style.height = "480px";
            document.body.appendChild(div);

            var button = new HTMLButtonElement();

            button.innerHTML             = "Click on game area to start it!";
            button.style.width           = "100%";
            button.style.height          = "100%";
            button.style.backgroundColor = "#000000";
            button.style.color           = "#ffffff";
            button.style.fontSize        = "20px";
            div.appendChild(button);

            button.onclick = (ev) =>
            {
                div.removeChild(button);

                var canvas = new HTMLCanvasElement();
                canvas.style.width  = "100%";
                canvas.style.height = "100%";
                canvas.id           = "monogamecanvas";
                div.appendChild(canvas);

                game = new GameProject.Game1();
                game.Run();
            };
        }
Exemplo n.º 3
0
        public static void Main()
        {
            document.body.setAttribute("style", "margin: 0; overflow: hidden;");

            var div = new HTMLDivElement();

            div.setAttribute("style", "width: 960px; height: 540px;");

            var button = new HTMLButtonElement();

            button.innerHTML = "Run Game";
            button.setAttribute("style", "width: 100%; height: 100%; background-color: rgb(100, 149, 237); color: rgb(255, 255, 255); font-size: 20px; border: 0;");

            document.body.appendChild(div);
            div.appendChild(button);

            button.onclick = (ev) =>
            {
                var canvas = new HTMLCanvasElement();
                canvas.width  = 960;
                canvas.height = 540;
                canvas.id     = "monogamecanvas";

                div.removeChild(button);
                div.appendChild(canvas);

                _game = new Game1();
                _game.Run();

                canvas.focus();
            };
        }
Exemplo n.º 4
0
        public void InternalLog(string source, ConsoleLogType logType = ConsoleLogType.Log)
        {
            var para = new HTMLParagraphElement()
            {
                className = "console-para"
            };

            switch (logType)
            {
            case ConsoleLogType.Debug:
                para.style.color = Color.ForestGreen;
                break;

            case ConsoleLogType.Error:
                para.style.color = Color.Red;
                break;
            }

            para.innerHTML = source;
            logContent.appendChild(para);
            if (logContent.children.length > 1000)
            {
                logContent.removeChild(logContent.children[0]);
            }
            para.scrollIntoView(false);
        }
        public void AttachElement(HTMLElement element)
        {
            if (AssignedElement != null)
            {
                Container.removeChild(AssignedElement);
            }
            AssignedElement = element;

            AssignedElement.style.position  = "absolute";
            AssignedElement.style.boxSizing = "border-box";

            ControlSettings = new ControlSettings();
            Container.appendChild(AssignedElement);
        }
Exemplo n.º 6
0
        private void RenderItem(TodoItem item)
        {
            var itemDiv = new HTMLDivElement();

            // Create a CheckBox
            var checkBox = new HTMLInputElement
            {
                type  = "checkbox",
                style = { margin = "10px" }
            };

            checkBox.addEventListener("click", e =>
            {
                // Set the item as Completed:
                item.Completed = checkBox.@checked;
            });

            var button = new HTMLButtonElement
            {
                innerHTML = "del",
                onclick   = e =>
                {
                    // Remove the item and the controls:
                    _todoDiv.removeChild(itemDiv);
                    _todos.remove(item);
                    return(null);
                }
            };

            itemDiv.appendChild(button);
            itemDiv.appendChild(checkBox);
            itemDiv.appendChild(new HTMLLabelElement {
                innerHTML = item.Task
            });
            itemDiv.appendChild(new HTMLBRElement());

            _todoDiv.appendChild(itemDiv);
        }