Wednesday, January 16, 2013

C# code to switch lights thru web-interface

Using the WebBrowser controll in Visual Studio 2010 it's really easy to make a interface to access the web and send data.

The code below is what makes up the desktop app that uses my python web interface to switch lights.

private void button1_Click(object sender, EventArgs e)
        {
            webBrowser1.Navigate("http://192.168.1.6:8080/?turn=on");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            webBrowser1.Navigate("http://192.168.1.6:8080/?turn=off");
        }

The app is just a web browser that navigates to my web-interface with the click of the buttons. Displaying the web interface in the small browser window.

No comments:

Post a Comment