From dd25a27555b31c3faca32a3d89db806f68b720eb Mon Sep 17 00:00:00 2001 From: Chris Tacke Date: Thu, 25 Apr 2024 08:04:55 -0500 Subject: [PATCH] clean up desktop samples --- Source/Meadow.Desktop/HMI_Views/MeadowApp.cs | 7 +++- Source/Meadow.Desktop/HMI_Views/Program.cs | 5 --- .../PixelDisplay/MeadowAppDesktop.cs | 17 ++++------ Source/Meadow.Desktop/PixelDisplay/Program.cs | 5 --- .../Touchscreen_Demo/CircleDemo.cs | 2 ++ .../Touchscreen_Demo/DisplayController.cs | 32 ------------------- .../Touchscreen_Demo/MeadowApp.cs | 9 ++++-- .../Touchscreen_Demo/Program.cs | 5 --- 8 files changed, 21 insertions(+), 61 deletions(-) delete mode 100644 Source/Meadow.Desktop/Touchscreen_Demo/DisplayController.cs diff --git a/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs b/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs index d3ae82fd..db3c177c 100644 --- a/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs +++ b/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs @@ -47,6 +47,11 @@ public override Task Run() private void ExecutePlatformDisplayRunner() { - (Device.Display as SilkDisplay).Run(); + if (Device.Display is SilkDisplay sd) + { + sd.Run(); + } + MeadowOS.TerminateRun(); + System.Environment.Exit(0); } } \ No newline at end of file diff --git a/Source/Meadow.Desktop/HMI_Views/Program.cs b/Source/Meadow.Desktop/HMI_Views/Program.cs index 3a28d03f..6a702d32 100644 --- a/Source/Meadow.Desktop/HMI_Views/Program.cs +++ b/Source/Meadow.Desktop/HMI_Views/Program.cs @@ -7,11 +7,6 @@ public class Program { public static async Task Main(string[] args) { -#if WINDOWS - System.Windows.Forms.Application.EnableVisualStyles(); - System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); - ApplicationConfiguration.Initialize(); -#endif await MeadowOS.Start(args); } } \ No newline at end of file diff --git a/Source/Meadow.Desktop/PixelDisplay/MeadowAppDesktop.cs b/Source/Meadow.Desktop/PixelDisplay/MeadowAppDesktop.cs index cc1f934e..5c77b628 100644 --- a/Source/Meadow.Desktop/PixelDisplay/MeadowAppDesktop.cs +++ b/Source/Meadow.Desktop/PixelDisplay/MeadowAppDesktop.cs @@ -44,21 +44,16 @@ public override Task Run() public override Task OnShutdown() { -#if WINDOWS - System.Windows.Forms.Application.Exit(); -#endif return Task.CompletedTask; } private void ExecutePlatformDisplayRunner() { - (Device.Display as SilkDisplay).Run(); -#if WINDOWS - System.Windows.Forms.Application.Run(Device.Display as System.Windows.Forms.Form); -#endif - // if (Device.Display is GtkDisplay gtk) - // { - // gtk.Run(); - // } + if (Device.Display is SilkDisplay sd) + { + sd.Run(); + } + MeadowOS.TerminateRun(); + System.Environment.Exit(0); } } diff --git a/Source/Meadow.Desktop/PixelDisplay/Program.cs b/Source/Meadow.Desktop/PixelDisplay/Program.cs index 98cfe2e8..6b5495e0 100644 --- a/Source/Meadow.Desktop/PixelDisplay/Program.cs +++ b/Source/Meadow.Desktop/PixelDisplay/Program.cs @@ -5,11 +5,6 @@ public class Program { public static async Task Main(string[] args) { -#if WINDOWS -// System.Windows.Forms.Application.EnableVisualStyles(); -// System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); -// ApplicationConfiguration.Initialize(); -#endif await MeadowOS.Start(args); } } diff --git a/Source/Meadow.Desktop/Touchscreen_Demo/CircleDemo.cs b/Source/Meadow.Desktop/Touchscreen_Demo/CircleDemo.cs index b4c7c2f9..8f78becc 100644 --- a/Source/Meadow.Desktop/Touchscreen_Demo/CircleDemo.cs +++ b/Source/Meadow.Desktop/Touchscreen_Demo/CircleDemo.cs @@ -24,6 +24,7 @@ public CircleDemo(DisplayScreen display, ITouchScreen touchscreen) { _touchscreen = touchscreen; _display = display; + _display.BackgroundColor = Color.White; } public void Start() @@ -60,6 +61,7 @@ private void Touchscreen_TouchUp(ITouchScreen sender, TouchPoint point) { _inflateTimer?.Change(-1, -1); _currentCircle = null; + _display.Invalidate(); } private Color GetRandomColor() diff --git a/Source/Meadow.Desktop/Touchscreen_Demo/DisplayController.cs b/Source/Meadow.Desktop/Touchscreen_Demo/DisplayController.cs deleted file mode 100644 index 5d64d51b..00000000 --- a/Source/Meadow.Desktop/Touchscreen_Demo/DisplayController.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Meadow; -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; - -namespace Touchscreen_Demo -{ - public class DisplayController - { - protected DisplayScreen DisplayScreen { get; set; } - - public DisplayController(IPixelDisplay display) - { - DisplayScreen = new DisplayScreen(display) - { - BackgroundColor = Color.FromHex("14607F") - }; - - DisplayScreen.Controls.Add(new Label( - left: 0, - top: 0, - width: DisplayScreen.Width, - height: DisplayScreen.Height) - { - Text = "Hello World", - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - Font = new Font12x20() - }); - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/Touchscreen_Demo/MeadowApp.cs b/Source/Meadow.Desktop/Touchscreen_Demo/MeadowApp.cs index 9b6a9da5..de1762a7 100644 --- a/Source/Meadow.Desktop/Touchscreen_Demo/MeadowApp.cs +++ b/Source/Meadow.Desktop/Touchscreen_Demo/MeadowApp.cs @@ -15,7 +15,7 @@ public override Task Initialize() var touchscreen = Device.Display as ITouchScreen; var display = new DisplayScreen( Device.Display, - touchScreen: touchscreen); + touchScreen: touchscreen); _demo = new CircleDemo(display, touchscreen); @@ -34,6 +34,11 @@ public override Task Run() private void ExecutePlatformDisplayRunner() { - (Device.Display as SilkDisplay).Run(); + if (Device.Display is SilkDisplay sd) + { + sd.Run(); + } + MeadowOS.TerminateRun(); + System.Environment.Exit(0); } } \ No newline at end of file diff --git a/Source/Meadow.Desktop/Touchscreen_Demo/Program.cs b/Source/Meadow.Desktop/Touchscreen_Demo/Program.cs index 4fc3f562..d6977ed3 100644 --- a/Source/Meadow.Desktop/Touchscreen_Demo/Program.cs +++ b/Source/Meadow.Desktop/Touchscreen_Demo/Program.cs @@ -7,11 +7,6 @@ public class Program { public static async Task Main(string[] args) { -#if WINDOWS - System.Windows.Forms.Application.EnableVisualStyles(); - System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); - ApplicationConfiguration.Initialize(); -#endif await MeadowOS.Start(args); } } \ No newline at end of file