1- using LVGLSharp ;
1+ using LVGLSharp ;
22using LVGLSharp . Interop ;
3- #if LINUX
4- using LVGLSharp . Runtime . Linux ;
5- #else
6- using LVGLSharp . Runtime . Windows ;
7- #endif
8- using SixLabors . Fonts ;
93using System . Diagnostics ;
104using System . IO . Ports ;
11- using System . Reflection . Emit ;
125using System . Runtime . CompilerServices ;
136using System . Runtime . InteropServices ;
147using System . Text ;
@@ -24,9 +17,9 @@ unsafe class Program
2417 static lv_obj_t * send_btn ;
2518 static lv_obj_t * clear_btn ;
2619 static lv_obj_t * hex_switch ;
27- static IWindow window ;
28- static SerialPort serialPort ;
29- static List < string > serialPorts ;
20+ static IWindow ? window ;
21+ static SerialPort ? serialPort ;
22+ static List < string > serialPorts = [ ] ;
3023 static List < string > bauds = [ "9600" , "19200" , "38400" , "57600" , "115200" ] ;
3124
3225 static lv_obj_t * root ;
@@ -35,22 +28,12 @@ unsafe class Program
3528
3629 static void Main ( string [ ] args )
3730 {
38- #if LINUX
39- window = new LinuxView ( dpi : 96f ) ;
40- #else
41- window = new Win32Window ( "LVGLSharp" , 710 , 470 ) ;
42- #endif
31+ window = PlatformWindowFactory . Create ( ) ;
4332 window . Init ( ) ;
4433
45- #if LINUX
46- root = LinuxView . root ;
47- key_inputGroup = LinuxView . key_inputGroup ;
48- SendTextAreaFocusCb = LinuxView . SendTextAreaFocusCb ;
49- #else
50- root = Win32Window . root ;
51- key_inputGroup = Win32Window . key_inputGroup ;
52- SendTextAreaFocusCb = Win32Window . SendTextAreaFocusCb ;
53- #endif
34+ root = window . Root ;
35+ key_inputGroup = window . KeyInputGroup ;
36+ SendTextAreaFocusCb = window . SendTextAreaFocusCallback ;
5437
5538 InitUI ( ) ;
5639
@@ -278,11 +261,7 @@ static void InitUI()
278261 lv_group_add_obj ( key_inputGroup , send_textarea ) ;
279262 lv_obj_set_height ( send_textarea , 50 ) ;
280263
281- #if LINUX
282- lv_obj_t * kb = lv_keyboard_create ( lv_scr_act ( ) ) ;
283- lv_obj_set_size ( kb , 670 , 200 ) ;
284- lv_keyboard_set_textarea ( kb , send_textarea ) ;
285- #endif
264+ window ? . AttachTextInput ( send_textarea ) ;
286265
287266 // 发送按钮
288267 send_btn = lv_btn_create ( send_container ) ;
0 commit comments