Add ButtonSample
This commit is contained in:
parent
dfa658d075
commit
9cee30ead9
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue