-
Notifications
You must be signed in to change notification settings - Fork 0
GettingStartedDev
Yannik Höflich edited this page Sep 3, 2023
·
2 revisions
- Create a new .NET 7 library project in Visual Studio
- Install the extension library with one of the following ways.
- Open the NuGet explorer and search for
MatrixWeb.Extensions. Install the newest version - Use the following command in the package manager console:
NuGet\Install-Package MatrixWeb.Extensions
- Open the NuGet explorer and search for
Create a public class with any name:
public class MyScreen{
}The next step is to implement the interface IScreenGenerator:
public class MyScreen: IScreenGenerator{
public Text Name { get; }
public Text Description { get; }
public bool RequiresInternet { get; }
public TimeSpan ScreenTime { get; set; }
public bool IsEnabled { get; }
public Task<Screen> GenerateImageAsync() { }
}Now set the default values:
public class MyScreen: IScreenGenerator{
public Text Name { get; } = "My first screen";
public Text Description { get; } = "This is my first screen, I developed!";
public bool RequiresInternet { get; } = false;
public TimeSpan ScreenTime { get; set; } = TimeSpan.FromSeconds(1);
public bool IsEnabled { get; } = true;
public Task<Screen> GenerateImageAsync() { }
}Now the most important part. Generate the Screen in GenerateImageAsync:
public Task<Screen> GenerateImageAsync() {
var img = new Image<Rgb24>(16, 16, Color.Red);
return new Screen(img, ScreenTime)
}Now build the project in Release mode.
Copy the .dll file from the project folder /bin/Release/net7.0 into the extensions folder, drom the MatrixWeb application. The dll must be in its own folder, that has the same name as the .dll file.
Now you can run MatrixWeb and the screen show up.