diff --git a/ExtLibs/MissionPlanner.Drawing/Graphics.cs b/ExtLibs/MissionPlanner.Drawing/Graphics.cs index 0a5e61cdd8..9cbceffcf4 100644 --- a/ExtLibs/MissionPlanner.Drawing/Graphics.cs +++ b/ExtLibs/MissionPlanner.Drawing/Graphics.cs @@ -1606,7 +1606,8 @@ public static Graphics FromHwnd(IntPtr windowHandle) { Console.WriteLine("FromHwnd"); - return new Graphics(SKSurface.CreateNull(1, 1)); + if(HwndToGraphics == null) + return new Graphics(SKSurface.CreateNull(1, 1)); //get client rect //hwnd to hdc diff --git a/ExtLibs/Xamarin/SkiaTest/Program.cs b/ExtLibs/Xamarin/SkiaTest/Program.cs index 5b3ab08738..e460b3e175 100644 --- a/ExtLibs/Xamarin/SkiaTest/Program.cs +++ b/ExtLibs/Xamarin/SkiaTest/Program.cs @@ -478,6 +478,11 @@ protected override void OnSkiaPaint(SKSurface e) { int x = XplatUI.driver.MousePosition.X, y = XplatUI.driver.MousePosition.Y; + if (Application.OpenForms[cnt - 1].IsDisposed) + { + cnt--; + continue; + } var hwnd = Hwnd.ObjectFromHandle(Application.OpenForms[cnt - 1].Handle); if (x < hwnd.X || y < hwnd.Y || x > hwnd.x+hwnd.width || y > hwnd.y+hwnd.height) { diff --git a/MissionPlannerLib.csproj b/MissionPlannerLib.csproj index f1a27e8119..3564e7f6ed 100644 --- a/MissionPlannerLib.csproj +++ b/MissionPlannerLib.csproj @@ -402,20 +402,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/example22-fontsize.cs b/plugins/example22-fontsize.cs new file mode 100644 index 0000000000..a613dd769b --- /dev/null +++ b/plugins/example22-fontsize.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace MissionPlanner.plugins +{ + public class example22_fontsize : Plugin.Plugin + { + public override string Name => "fontsize"; + + public override string Version => "0"; + + public override string Author => "me"; + + public override bool Exit() + { + return true; + } + + public override bool Init() + { + Debugger.Break(); + Console.WriteLine("Font name: " + SystemFonts.DefaultFont.Name); + Console.WriteLine("Font size: " + SystemFonts.DefaultFont.Size); + + var s = TextRenderer.MeasureText("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890", SystemFonts.DefaultFont); + int width = (int)Math.Round((float)s.Width / 62f); + + Console.WriteLine(s + " " + width); + + Console.WriteLine("AutoScaleDimensions " + Host.MainForm.AutoScaleDimensions); + Console.WriteLine("AutoScaleMode " + Host.MainForm.AutoScaleMode); + return false; + } + + public override bool Loaded() + { + return false; + } + } +}