示例#1
0
        public static void Main()
        {
            // A root container for the elements we will use in this example -
            // text input and two buttons
            var div = new Bridge.Html5.DivElement();

            // Create an input element, with Placeholder text
            // and KeyPress listener to call Save method after Enter key pressed
            var input = new Bridge.Html5.InputElement()
            {
                Id          = "number",
                Type        = InputType.Text,
                Placeholder = "Enter a number to store...",
                Style       =
                {
                    Margin = "5px"
                }
            };

            input.AddEventListener(EventType.KeyPress, InputKeyPress);
            div.AppendChild(input);

            // Add a Save button to save entered number into Storage
            var buttonSave = new Bridge.Html5.ButtonElement()
            {
                Id        = "save",
                InnerHTML = "Save"
            };

            buttonSave.AddEventListener(EventType.Click, Save);
            div.AppendChild(buttonSave);

            // Add a Restore button to get saved number and populate
            // the text input with its value
            var buttonRestore = new Bridge.Html5.ButtonElement()
            {
                Id        = "restore",
                InnerHTML = "Restore",
                Style     =
                {
                    Margin = "5px"
                }
            };

            buttonRestore.AddEventListener(EventType.Click, Restore);
            div.AppendChild(buttonRestore);

            // Do not forget add the elements on the page
            Document.Body.AppendChild(div);

            // It is good to get the text element focused
            input.Focus();
        }
示例#2
0
        public static void Main()
        {
            // A root container for the elements we will use in this example -
            // text input and two buttons
            var div = new Bridge.Html5.DivElement();

            // Create an input element, with Placeholder text
            // and KeyPress listener to call Save method after Enter key pressed
            var input = new Bridge.Html5.InputElement()
            {
                Id = "number",
                Type = InputType.Text,
                Placeholder = "Enter a number to store...",
                Style =
                {
                    Margin = "5px"
                }
            };

            input.AddEventListener(EventType.KeyPress, InputKeyPress);
            div.AppendChild(input);

            // Add a Save button to save entered number into Storage
            var buttonSave = new Bridge.Html5.ButtonElement()
            {
                Id = "save",
                InnerHTML = "Save"
            };

            buttonSave.AddEventListener(EventType.Click, Save);
            div.AppendChild(buttonSave);

            // Add a Restore button to get saved number and populate
            // the text input with its value
            var buttonRestore = new Bridge.Html5.ButtonElement()
            {
                Id = "restore",
                InnerHTML = "Restore",
                Style =
                {
                    Margin = "5px"
                }
            };

            buttonRestore.AddEventListener(EventType.Click, Restore);
            div.AppendChild(buttonRestore);

            // Do not forget add the elements on the page
            Document.Body.AppendChild(div);

            // It is good to get the text element focused
            input.Focus();
        }
示例#3
0
文件: Demo.cs 项目: phaethom/Demos
        public static void Main()
        {
            var button = new ButtonElement
            {
                InnerHTML = "Submit",
                OnClick = (ev) =>
                {
                    Global.Alert("Welcome to Bridge.NET");
                }
            };

            Document.Body.AppendChild(button);
        }
示例#4
0
        public static Element[] CreateDateTimeField()
        {
            var label = new LabelElement
            {
                HtmlFor = "dateTimeInput",
                InnerHTML = "Server Date and Time:"
            };

            var div = new DivElement
            {
                ClassName = "input-group"
            };

            var spanPrefix = new SpanElement
            {
                ClassName = "input-group-addon glyphicon glyphicon-time"
            };

            var spanSuffix = new SpanElement
            {
                ClassName = "input-group-btn"
            };

            var button = new ButtonElement
            {
                Type = ButtonType.Button,
                ClassName = "btn btn-primary",
                InnerHTML = "<span class=\"glyphicon glyphicon-refresh\"></span>",
                OnClick = Html5App.UpdateButton_Click
            };

            var input = new InputElement
            {
                Id = "dateTimeInput",
                Type = InputType.Text,
                ClassName = "form-control",
                Placeholder = "Click update...",
                ReadOnly = true,
                Name = "datetime"
            };

            spanSuffix.AppendChild(button);

            div.AppendChild(spanPrefix);
            div.AppendChild(input);
            div.AppendChild(spanSuffix);

            return new Element[] { label, div };
        }
示例#5
0
文件: Demo.cs 项目: phaethom/Demos
        public static void Main()
        {
            Console.Log("Demo. Logged on console.");

            var spanEl = new SpanElement()
            {
                InnerHTML = "If you can read this line, then bridge is working!"
            };

            Document.Body.AppendChild(spanEl);

            var button = new ButtonElement
            {
                InnerHTML = "Show Bridge.NET message",
                OnClick = (ev) =>
                {
                    Global.Alert("Welcome to Bridge.NET");
                }
            };

            Document.Body.AppendChild(button);
        }
示例#6
0
        public static void TestUseCase(Assert assert)
        {
            assert.Expect(3);

            var root = Document.GetElementById("qunit-fixture");

            var button1 = new ButtonElement();
            button1.InnerHTML = "Button 1";
            button1.Id = "button1";
            button1.Style.Color = HTMLColor.Green;

            root.AppendChild(button1);

            var b1 = Document.GetElementById("button1");
            assert.Equal(b1.Style.Color, "green", "b1.Style.Color green");

            var button2 = new ButtonElement();
            button2.InnerHTML = "Button 2";
            button2.Id = "button2";
            button2.Style.BackgroundColor = "yellow";

            root.AppendChild(button2);

            var b2 = Document.GetElementById("button2");
            assert.Equal(b2.Style.BackgroundColor, HTMLColor.Yellow, "b2.Style.BackgroundColor HTMLColor.Yellow");

            var hexColor = "#FFEEAA";
            var divElement1 = new DivElement();
            divElement1.InnerHTML = "Div 1";
            divElement1.Id = "div1";
            divElement1.Style.Color = hexColor;

            root.AppendChild(divElement1);

            var div1 = Document.GetElementById("div1");
            assert.Equal(div1.Style.Color, "rgb(255, 238, 170)", "div1.Style.Color " + hexColor);
        }
示例#7
0
        public void Initialize()
        {
            ConsoleLog = Document.GetElementById<DivElement>("consoleLog");

            WebSocketSupportImage = Document.GetElementById<ImageElement>("wsSupportImg");

            WebSocketSupported = Document.GetElementById<DivElement>("webSocketSupp");

            WebSocketNotSupported = Document.GetElementById<DivElement>("noWebSocketSupp");

            UseSecureWebSocketInput = Document.GetElementById<InputElement>("secureCb");
            UseSecureWebSocketInput.Checked = false;
            UseSecureWebSocketInput.OnClick += OnClick_UseSecureWebSocket;

            LocationInput = Document.GetElementById<InputElement>("wsUri");

            MessageInput = Document.GetElementById<InputElement>("sendMessage");

            ConnectButton = Document.GetElementById<ButtonElement>("connect");
            ConnectButton.OnClick += OnClick_ConnectButton;

            DisconnectButton = Document.GetElementById<ButtonElement>("disconnect");
            DisconnectButton.OnClick += OnClick_DisconnectButton;

            SendButton = Document.GetElementById<ButtonElement>("send");
            SendButton.OnClick += OnClick_SendButton;

            ClearLogButton = Document.GetElementById<ButtonElement>("clearLogBut");
            ClearLogButton.OnClick += OnClick_ClearLogButton;

            Window.OnBeforeUnload += (e) => { if (OnViewShuttingUp != null) { OnViewShuttingUp(this, new EventArgs()); } };

            if (OnViewInitialized != null)
            {
                OnViewInitialized(this, new EventArgs());
            }
        }
示例#8
0
        public static ModalDlg Make(string titleText, string bodyText, string id)
        {
            DivElement myModal = new DivElement();
            myModal.ClassName = "modal fade";
            myModal.Id = id;
            myModal.SetAttribute("role", "dialog");
            jQuery jq = new jQuery(myModal).On("hidden.bs.modal", OnHidden);

            DivElement modalDlg = new DivElement();
            modalDlg.ClassName = "modal-dialog-sm";
            myModal.AppendChild(modalDlg);

            DivElement modalContent = new DivElement();
            modalContent.ClassName = "modal-content";
            modalDlg.AppendChild(modalContent);

            DivElement modalHeader = new DivElement();
            modalHeader.ClassName = "modal-header";
            modalContent.AppendChild(modalHeader);

            ButtonElement button = new ButtonElement();
            button.SetAttribute("type", "button");
            button.ClassName = "close";
            button.SetAttribute("data-dismiss", "modal");
            button.InnerHTML = "&times;";
            modalHeader.AppendChild(button);

            HeadingElement title = new HeadingElement(HeadingType.H4);
            title.ClassName = "modal-title";
            title.InnerHTML = titleText;
            modalHeader.AppendChild(title);

            DivElement modalBody = new DivElement();
            modalBody.ClassName = "modal-body";
            modalContent.AppendChild(modalBody);

            ParagraphElement bodyContent = new ParagraphElement();
            bodyContent.InnerHTML = bodyText;
            modalBody.AppendChild(bodyContent);

            DivElement footer = new DivElement();
            footer.ClassName = "modal-footer";

            ButtonElement footerButton = new ButtonElement();
            footerButton.SetAttribute("type", "button");
            footerButton.ClassName = "btn btn-default";
            footerButton.SetAttribute("data-dismiss", "modal");
            footerButton.InnerHTML = "Close";

            footer.AppendChild(footerButton);
            modalContent.AppendChild(footer);

            Document.Body.AppendChild(myModal);

            ModalDlg dlg = new ModalDlg();
            dlg.TopElement = myModal;
            dlg.Body = modalBody;
            dlg.Title = title;
            dlg.BodyContent = bodyContent;
            dlg.Footer = footer;
            dlg.id = id;
            return dlg;
        }