### Installing kmscube for Testing Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash script installs the kmscube tool, which can be used to verify that the DRM environment is set up correctly. Running `kmscube` should display a colored cube if the environment is properly configured. ```bash sudo apt-get install kmscube sudo kmscube ``` -------------------------------- ### Installing Required Linux Packages Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash script updates the package list, upgrades existing packages, reboots the system, and installs necessary libraries for DRM support, including libgbm1, libgl1-mesa-dri, libegl1-mesa, and libinput10. ```bash sudo apt update sudo apt upgrade sudo reboot sudo apt-get install libgbm1 libgl1-mesa-dri libegl1-mesa libinput10 ``` -------------------------------- ### Installing libfontconfig1 to Resolve SkiaSharp Error Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash command installs the `libfontconfig1` library, which is required by SkiaSharp. This resolves the `System.DllNotFoundException` related to `libSkiaSharp`. ```bash sudo apt-get install -y libfontconfig1 ``` -------------------------------- ### Installing and Running kmscube Test Tool Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md These commands install the kmscube tool, which is used to verify that the DRM environment is correctly set up. If a colored cube appears when running kmscube, the environment is properly installed. ```bash sudo apt-get install kmscube sudo kmscube ``` -------------------------------- ### Adding Avalonia.LinuxFramebuffer NuGet Package Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This command adds the Avalonia.LinuxFramebuffer NuGet package to the project, which is required for DRM support in Avalonia applications. ```bash dotnet add package Avalonia.LinuxFramebuffer ``` -------------------------------- ### Publishing the Avalonia App for Linux (Alternative) Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This command publishes the Avalonia application for Linux for x64 architecture. ```bash dotnet publish demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj -c Release -r linu-x64 ``` -------------------------------- ### Publishing Avalonia Application for Linux Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash command publishes the Avalonia application for Linux x64 with self-contained and single-file options enabled. It creates a standalone executable that includes all necessary dependencies. ```bash dotnet publish demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj -c Release -r linux-x64 --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true ``` -------------------------------- ### Installing Required Linux Packages Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This set of commands updates the package list, upgrades existing packages, reboots the system, and installs necessary libraries for DRM support, including libgbm1, mesa drivers, and libinput. ```bash sudo apt update sudo apt upgrade sudo reboot sudo apt-get install libgbm1 libgl1-mesa-dri libegl1-mesa libinput10 ``` -------------------------------- ### Installing libfontconfig1 dependency on Linux Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This command installs the `libfontconfig1` library, which is a dependency for SkiaSharp on Linux systems. It resolves the `System.DllNotFoundException` related to `libSkiaSharp` by providing the necessary font configuration library. ```bash sudo apt-get install -y libfontconfig1 ``` -------------------------------- ### Installing Semi.Avalonia Package Source: https://github.com/irihitech/semi.avalonia/blob/main/README.md This command adds the Semi.Avalonia package to your project using the dotnet CLI. This is the first step in integrating the Semi Design theme into your Avalonia application. ```bash dotnet add package Semi.Avalonia ``` -------------------------------- ### Installing Additional Semi.Avalonia Packages Source: https://github.com/irihitech/semi.avalonia/blob/main/README.md These commands add the ColorPicker, DataGrid, and TreeDataGrid packages to your project using the dotnet CLI. These packages provide additional controls that are distributed separately. ```bash dotnet add package Semi.Avalonia.ColorPicker dotnet add package Semi.Avalonia.DataGrid dotnet add package Semi.Avalonia.TreeDataGrid ``` -------------------------------- ### Enabling AOT Compilation in csproj Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This XML snippet enables Ahead-of-Time (AOT) compilation and includes native libraries for self-extraction in the project file. This improves performance and reduces startup time. ```xml true true ``` -------------------------------- ### Publishing Avalonia Application for Linux with AOT Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash command publishes the Avalonia application for Linux x64 with AOT compilation enabled. It compiles the application to native code for better performance. ```bash dotnet publish demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj -c Release -r linu-x64 ``` -------------------------------- ### Implementing StartLinuxDrm in Main Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This C# code snippet modifies the `Main` method to use `StartLinuxDrm` when the `--drm` argument is provided. It also includes a `SilenceConsole` method to suppress console output. The `StartLinuxDrm` method initializes Avalonia with DRM support, optionally specifying the DRM card and scaling factor. ```csharp public static int Main(string[] args) { var builder = BuildAvaloniaApp(); if (args.Contains("--drm")) { SilenceConsole(); // By default, Avalonia will try to detect output card automatically. // But you can specify one, for example "/dev/dri/card1". return builder.StartLinuxDrm(args: args, card: null, scaling: 1.0); } return builder.StartWithClassicDesktopLifetime(args); } private static void SilenceConsole() { new Thread(() => { Console.CursorVisible = false; while (true) Console.ReadKey(true); }) { IsBackground = true }.Start(); } ``` -------------------------------- ### Running the Published Avalonia Application with DRM Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This command runs the published Avalonia application with DRM support, using sudo to ensure proper permissions. ```bash sudo ./Semi.Avalonia.Demo.Drm --drm ``` -------------------------------- ### Publishing the Avalonia App for Linux Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This command publishes the Avalonia application for Linux as a single file, including native libraries for self-extraction. This is suitable for x64 architecture. ```bash dotnet publish demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj -c Release -r linux-x64 --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true ``` -------------------------------- ### Installing Semi.Avalonia NuGet Package Source: https://github.com/irihitech/semi.avalonia/blob/main/README_CN.md This command adds the Semi.Avalonia package to your project using the .NET CLI. This package contains the core theme and styles for Avalonia UI applications. ```bash dotnet add package Semi.Avalonia ``` -------------------------------- ### Adding Avalonia.LinuxFramebuffer NuGet Package Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This command adds the Avalonia.LinuxFramebuffer NuGet package to the project, which is required for DRM support in Avalonia applications. ```bash dotnet add package Avalonia.LinuxFramebuffer ``` -------------------------------- ### Running Avalonia Application with DRM Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash command executes the published Avalonia application with DRM support. The `sudo` command is required to grant the application necessary permissions to access DRM resources. The `--drm` argument tells the application to use the DRM backend. ```bash sudo ./Semi.Avalonia.Demo.Drm --drm ``` -------------------------------- ### Adding Execute Permission to the Executable Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This bash command adds execute permissions to the Avalonia application executable. This resolves the "Permission denied" error when trying to run the application. ```bash sudo chmod +x ./Semi.Avalonia.Demo.Drm ``` -------------------------------- ### Installing Additional Semi.Avalonia Packages Source: https://github.com/irihitech/semi.avalonia/blob/main/README_CN.md These commands add the Semi.Avalonia.ColorPicker, Semi.Avalonia.DataGrid, and Semi.Avalonia.TreeDataGrid packages to your project using the .NET CLI. These packages provide additional styles for specific controls. ```bash dotnet add package Semi.Avalonia.ColorPicker dotnet add package Semi.Avalonia.DataGrid dotnet add package Semi.Avalonia.TreeDataGrid ``` -------------------------------- ### Granting execute permission to a file Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This command grants execute permission to the specified file. This is used to resolve 'Permission denied' errors when trying to run an executable file. ```bash sudo chmod +x ./Semi.Avalonia.Demo.Drm ``` -------------------------------- ### Specifying DRM Card in Avalonia Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README_CN.md This C# code snippet shows how to specify the DRM card to use in the Avalonia application. The `StartLinuxDrm` method is called with the `card` parameter set to `null`, which means Avalonia will automatically detect the correct card. This is the recommended approach. ```csharp return builder.StartLinuxDrm(args: args, card: null, scaling: 1.0); ``` -------------------------------- ### Adding StartLinuxDrm Code to Main Method Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This C# code snippet modifies the Main method to use StartLinuxDrm when the --drm argument is present. It also includes a SilenceConsole method to hide the console window. ```csharp public static int Main(string[] args) { var builder = BuildAvaloniaApp(); if (args.Contains("--drm")) { SilenceConsole(); // By default, Avalonia will try to detect output card automatically. // But you can specify one, for example "/dev/dri/card1". return builder.StartLinuxDrm(args: args, card: null, scaling: 1.0); } return builder.StartWithClassicDesktopLifetime(args); } private static void SilenceConsole() { new Thread(() => { Console.CursorVisible = false; while (true) Console.ReadKey(true); }) { IsBackground = true }.Start(); } ``` -------------------------------- ### Adding AOT Publishing Properties to csproj Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This XML snippet adds properties to the csproj file to enable Ahead-of-Time (AOT) compilation and include native libraries for self-extraction during publishing. ```xml true true ``` -------------------------------- ### Initializing LinuxDrm with automatic graphics card detection Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Drm/README.md This C# code snippet initializes the LinuxDrm platform with automatic graphics card detection. Setting the `card` parameter to `null` enables Avalonia to automatically detect the correct graphics card path, resolving issues where the graphics card path is incorrect or the device cannot be opened. ```csharp return builder.StartLinuxDrm(args: args, card: null, scaling: 1.0); ``` -------------------------------- ### Applying Additional Semi.Avalonia Themes Source: https://github.com/irihitech/semi.avalonia/blob/main/README.md This XAML snippet demonstrates how to apply the ColorPicker, DataGrid, and TreeDataGrid themes in your Avalonia application. These themes are required to style the corresponding controls. ```xaml ``` -------------------------------- ### Exposing Resources with the R Class in Android Source: https://github.com/irihitech/semi.avalonia/blob/main/demo/Semi.Avalonia.Demo.Android/Resources/AboutResources.txt This code snippet demonstrates how the 'R' class exposes resource IDs for drawables, layouts, and strings in an Android application. The 'R' class is automatically generated by the build system when resources are included in the project. ```C# public class R { public class drawable { public const int icon = 0x123; } public class layout { public const int main = 0x456; } public class strings { public const int first_string = 0xabc; public const int second_string = 0xbcd; } } ``` -------------------------------- ### Applying Additional Themes in Avalonia XAML Source: https://github.com/irihitech/semi.avalonia/blob/main/README_CN.md This XAML snippet demonstrates how to apply the ColorPickerSemiTheme, DataGridSemiTheme, and TreeDataGridSemiTheme to your Avalonia application. These themes provide specific styles for the ColorPicker, DataGrid, and TreeDataGrid controls, respectively. ```xaml ``` -------------------------------- ### Applying SemiTheme in Avalonia XAML Source: https://github.com/irihitech/semi.avalonia/blob/main/README_CN.md This XAML snippet demonstrates how to apply the SemiTheme to your Avalonia application. It references the Semi namespace and adds the SemiTheme to the Application.Styles collection, setting the locale to Chinese (zh-CN). ```xaml ``` -------------------------------- ### Including Semi Design Styles in Avalonia Application Source: https://github.com/irihitech/semi.avalonia/blob/main/README.md This XAML snippet demonstrates how to include the Semi Design styles in your Avalonia application. It sets the Locale to "zh-CN". ```xaml ```