|
1 | | - # LVGLSharp.Forms |
| 1 | +# LVGLSharp.Forms |
2 | 2 |
|
3 | 3 | [中文](./README.md) | English |
4 | 4 |
|
5 | | -## Our goal is to achieve "what you see is what you get" (WYSIWYG), ensuring that the results designed in the editor appear as closely as possible on Linux as they do on Windows. It is currently still in the experimental phase and not yet functional for regular use. |
| 5 | +**LVGLSharp.Forms** is a cross-platform WinForms API compatibility layer that uses [LVGL](https://github.com/lvgl/lvgl) as the underlying rendering engine. The goal is to achieve **WYSIWYG (What You See Is What You Get)** — UI designed with the Visual Studio Windows Forms Designer on Windows will render with high fidelity on Linux (arm / arm64 / x64) and other embedded platforms. |
6 | 6 |
|
7 | | -## Thanks to the project [LVGLSharp](https://github.com/imxcstar/LVGLSharp) by imxcstar for providing the underlying support. |
| 7 | +> ⚠️ This project is currently in the experimental phase and is not yet suitable for production use. |
8 | 8 |
|
9 | | -## Thanks to ClangSharpPInvokeGenerator, all API interoperability of LVGL is now supported. |
| 9 | +--- |
10 | 10 |
|
11 | | -### The following is a preview of an win-x64, linux-arm application that has undergone AOT (without dependencies) |
| 11 | +## ✨ Features |
12 | 12 |
|
13 | | - |
| 13 | +- 🖥️ **WinForms API Compatibility**: An API surface closely mirroring `System.Windows.Forms`, making it easy to migrate existing code. |
| 14 | +- 🔤 **Full LVGL API Interop**: Auto-generated P/Invoke bindings via ClangSharpPInvokeGenerator covering the entire LVGL C API. |
| 15 | +- 🚀 **NativeAOT Support**: Publish as self-contained native executables with no managed runtime dependency (validated on win-x64 and linux-arm). |
| 16 | +- 🌍 **Cross-Platform**: Supports Windows (x64) and Linux (x64 / arm / arm64). |
| 17 | +- 🧩 **Built-in Common Controls**: Button, Label, TextBox, CheckBox, RadioButton, ComboBox, ListBox, ProgressBar, TrackBar, NumericUpDown, PictureBox, Panel, GroupBox, FlowLayoutPanel, TableLayoutPanel, RichTextBox, and more. |
| 18 | +- 🎨 **Custom Drawing Types**: The `LVGLSharp.Darwing` namespace provides `Size`, `Point`, `Color`, and other types without any dependency on `System.Drawing`, ensuring true cross-platform portability. |
14 | 19 |
|
15 | | - |
| 20 | +--- |
16 | 21 |
|
17 | | -## Reference |
| 22 | +## 📷 Preview |
18 | 23 |
|
19 | | -https://github.com/lvgl/lvgl |
| 24 | +The following screenshots show an application published with NativeAOT for win-x64 / linux-arm (no external dependencies required): |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## 📦 NuGet Packages |
| 33 | + |
| 34 | +| Package | Description | |
| 35 | +|---------|-------------| |
| 36 | +| `LVGLSharp.Forms` | WinForms API compatibility layer (core package) | |
| 37 | +| `LVGLSharp.Interop` | LVGL P/Invoke bindings (auto-generated) | |
| 38 | +| `LVGLSharp.Native` | Platform-native LVGL libraries (win-x64, linux-arm, etc.) | |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## 🚀 Quick Start |
| 43 | + |
| 44 | +### 1. Create a Project |
| 45 | + |
| 46 | +Create a Windows Forms App (.NET) in Visual Studio, then replace the `System.Windows.Forms` reference with `LVGLSharp.Forms`. |
| 47 | + |
| 48 | +### 2. Entry Point |
| 49 | + |
| 50 | +```csharp |
| 51 | +using LVGLSharp.Forms; |
| 52 | + |
| 53 | +Application.SetHighDpiMode(HighDpiMode.SystemAware); |
| 54 | +Application.EnableVisualStyles(); |
| 55 | +Application.SetCompatibleTextRenderingDefault(false); |
| 56 | +Application.Run(new frmMain()); |
| 57 | +``` |
| 58 | + |
| 59 | +### 3. Run on Linux |
| 60 | + |
| 61 | +Publish using NativeAOT: |
| 62 | + |
| 63 | +```bash |
| 64 | +dotnet publish -r linux-arm64 -c Release |
| 65 | +``` |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 🏗️ Project Structure |
| 70 | + |
| 71 | +``` |
| 72 | +src/ |
| 73 | +├── LVGLSharp.WinForms/ # WinForms API compatibility layer (core) |
| 74 | +│ ├── Forms/ # Control implementations (Control, Form, Button, etc.) |
| 75 | +│ ├── Darwing/ # Cross-platform drawing types (Size, Point, Color, etc.) |
| 76 | +│ └── Runtime/ # Platform runtime (Windows / Linux) |
| 77 | +├── LVGLSharp.Interop/ # LVGL P/Invoke auto-generated bindings |
| 78 | +├── LVGLSharp.Native/ # Platform-native libraries |
| 79 | +├── LVGLSharp.Core/ # Shared core library |
| 80 | +└── Demos/ |
| 81 | + └── WinFormsDemo/ # Demo application |
| 82 | +libs/ |
| 83 | +└── lvgl/ # LVGL source code (submodule) |
| 84 | +``` |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## 🙏 Acknowledgements |
| 89 | + |
| 90 | +- **[imxcstar / LVGLSharp](https://github.com/imxcstar/LVGLSharp)**: Provides the foundational low-level LVGL .NET wrapper that this project is built upon. |
| 91 | +- **[LVGL](https://github.com/lvgl/lvgl)**: A lightweight, high-performance embedded GUI library. |
| 92 | +- **[ClangSharpPInvokeGenerator](https://github.com/dotnet/ClangSharp)**: Used to auto-generate the complete LVGL P/Invoke bindings. |
| 93 | +- **[SixLabors.ImageSharp](https://github.com/SixLabors/ImageSharp)**: Cross-platform image processing library. |
| 94 | +- **[SixLabors.Fonts](https://github.com/SixLabors/Fonts)**: Cross-platform font parsing library. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## 📄 License |
| 99 | + |
| 100 | +This project is licensed under the [MIT License](./LICENSE.txt). |
0 commit comments