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)
|
public static Element GetElementAtPath (string path)
|
||||||
{
|
{
|
||||||
throw new System.Collections.Generic.KeyNotFoundException ($"{path} does not exist");
|
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)
|
static int Main (string[] args)
|
||||||
{
|
{
|
||||||
var server = new Server ();
|
var server = new Server ();
|
||||||
var button = new Button() {
|
server.RunAsync ("http://*:8080/");
|
||||||
Title = "The best button",
|
|
||||||
Name = "TestButton",
|
new ButtonSample ().Publish ();
|
||||||
Value = "Click Me",
|
|
||||||
Text = "I am a button, click me!"
|
Console.ReadLine ();
|
||||||
};
|
|
||||||
server.Publish ("/button", button);
|
|
||||||
server.RunAsync ("http://*:8080/").Wait ();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue