8e1da8c190 | ||
---|---|---|
.vscode | ||
Documentation | ||
Ooui | ||
Samples | ||
Tests | ||
.editorconfig | ||
.gitignore | ||
LICENSE | ||
Ooui.sln | ||
README.md |
README.md
Ooui
Ooui (pronounced weeee!) is a small cross-platform UI library for .NET that uses web technologies.
It presents a classic object-oriented UI API that controls a dumb browser. With Ooui, you get the full power of your favorite .NET programming language plus the ability to interact with your app using any device.
Try it out!
dotnet restore
dotnet run --project Samples/Samples.csproj
Then open your browser to http://localhost:8080
Quick Example
using Ooui;
// Create the UI
var button = new Button($"Click me!");
// Add some logic to it
var count = 0;
button.Clicked += (s, e) => {
count++;
button.Text = $"Clicked {count} times";
};
// Publishing makes an object available at a given URL
// The user should be directed to http://localhost:8080/button
UI.Publish("/button", button);
With just that code, the user will be presented with a silly click counting button.
In fact, any number of users can hit that URL and start interacting with the same button. That's right, automatic collaboration!
If you want each user to get their own button, then you will Publish
a function to create it instead:
Button MakeButton() {
var button = new Button($"Click me!");
var count = 0;
button.Clicked += (s, e) => {
count++;
button.Text = $"Clicked {count} times";
};
return button;
}
UI.Publish("/button", MakeButton);
Now every user (well, every load of the page) will get their own button.
How it works
When the user requests a page, Ooui will connect to the client using a Web Socket. This socket is used to keep an in-memory model of the UI (the one you work with as a programmer) in sync with the actual UI shown to the user in their browser. This is done using a simple messaging protocol with JSON packets.
When the user clicks or otherwise interacts with the UI, those events are sent back over the web socket so that your code can deal with them.
Comparison
UI Library | Ooui | Xamarin.Forms | ASP.NET MVC |
---|---|---|---|
How big is it? | 50 KB | 2,000 KB | 5,000 KB |
Where does it run? | Everywhere | iOS, Android, Mac, Windows | Windows, Linux, Mac |
How do I make a button? | new Button() |
new Button() |
<button /> |
Does it use native controls? | No, HTML5 controls | Yes! | HTML5 controls |
What controls are available? | All of those in HTML5 | Xamarin.Forms controls | All of those in HTML5 |
Which architecture will you force me to use? | None, you're free | MVVM | MVC/MVVM |
What's the templating language? | C# | XAML | Razor |
How do I style things? | CSS baby! | XAML resources | CSS |
Is there databinding? | No :-( | Yes! | Debatable |
Do I need to run a server? | Nope | Heck no | Yes |
Is it web scale? | How much money do you have? | What's the web? | Sure |