Add ButtonSample

This commit is contained in:
Frank A. Krueger 2017-06-14 23:38:58 -07:00
parent dfa658d075
commit 9cee30ead9
3 changed files with 38 additions and 8 deletions

View File

@ -8,6 +8,10 @@ namespace Ooui
{
}
public static void Publish (string path, Func<object> ctor)
{
}
public static Element GetElementAtPath (string path)
{
throw new System.Collections.Generic.KeyNotFoundException ($"{path} does not exist");

29
Samples/ButtonSample.cs Normal file
View File

@ -0,0 +1,29 @@
using System;
using Ooui;
namespace Samples
{
public class ButtonSample
{
Button MakeButton ()
{
var button = new Button ($"Click me!");
var count = 0;
button.Clicked += (s, e) => {
count++;
button.Text = $"Clicked {count} times";
};
return button;
}
public void Publish ()
{
var b = MakeButton ();
UI.Publish ("/shared-button", b);
UI.Publish ("/button", MakeButton);
}
}
}

View File

@ -8,14 +8,11 @@ namespace Samples
static int Main (string[] args)
{
var server = new Server ();
var button = new Button() {
Title = "The best button",
Name = "TestButton",
Value = "Click Me",
Text = "I am a button, click me!"
};
server.Publish ("/button", button);
server.RunAsync ("http://*:8080/").Wait ();
server.RunAsync ("http://*:8080/");
new ButtonSample ().Publish ();
Console.ReadLine ();
return 0;
}
}