-
-
Notifications
You must be signed in to change notification settings - Fork 10
hello world
First, ensure everything is ready to start developping.
Create a new empty C# project and add the Crow NuGet package and one backend. For now, other backend than Cairo are experimental.
mkdir helloworld
cd helloworld
dotnet new console
dotnet add package Crow --prerelease
dotnet add package Crow.CairoBackend --prerelease
The resulting .csproj
file should look something like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Crow" Version="1.0.1-beta"/>
<PackageReference Include="Crow.CairoBackend" Version="1.0.1-beta" />
</ItemGroup>
</Project>
The Interface class is the crow application base class, it controls inputs (keyboard, mouse, ....) and rendering.
static void Main(string[] args) {
using (Interface app = new Interface ()) {
app.Initialized += (sender, e)
=> app.LoadIMLFragment (@"<Label Text='Hello World' />");
app.Run ();
}
At this point, you have a working Crow Application loading a simple Label
.
Usualy, the main application class will be derived from the Interface
class:
class MyApplication : Interface {
static void Main (string[] args) {
using (MyApplication app = new MyApplication ())
app.Run ();
Then, instead of using the Initialized
event to load ui components, you may override the OnInitialized
Method of the Interface
:
protected override void OnInitialized () {
base.OnInitialized ();//the base method just raises the Initilized event.
LoadIMLFragment (@"<Label Text='Hello World' />");
}
Ui components may be also directly instantiated in code instead of using IML, target Interface
must be specified on manual widget creation:
AddWidget (new Label (this) { Text = "Hello World" });