Skip to content

Commit

Permalink
example22- fontsize
Browse files Browse the repository at this point in the history
SkiaTest: tweak for exception
  • Loading branch information
meee1 committed Aug 14, 2023
1 parent 4f13e5a commit 1cbc963
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ExtLibs/MissionPlanner.Drawing/Graphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions ExtLibs/Xamarin/SkiaTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
44 changes: 44 additions & 0 deletions MissionPlannerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -402,20 +402,64 @@

<Compile Include="ExtLibs\Comms\System.IO.Ports\WinSerialStream.cs" />

<Compile Include="plugins\example-watchbutton.cs" />

<Compile Include="plugins\example.cs" />

<Compile Include="plugins\example10-canlogfile.cs" />

<Compile Include="plugins\example11-trace.cs" />

<Compile Include="plugins\example12-forwarding.cs" />

<Compile Include="plugins\example13-herelink2.cs" />

<Compile Include="plugins\example14-mass.cs" />

<Compile Include="plugins\example15-leds.cs" />

<Compile Include="plugins\example16-donate.cs" />

<Compile Include="plugins\example17-menuremove.cs" />

<Compile Include="plugins\example18-externalapi.cs" />

<Compile Include="plugins\example19-multiforward.cs" />

<Compile Include="plugins\example2-menu.cs" />

<Compile Include="plugins\example2.cs" />

<Compile Include="plugins\example20-multiplepositions.cs" />

<Compile Include="plugins\example21-persistentsimple.cs" />

<Compile Include="plugins\example22-fontsize.cs" />

<Compile Include="plugins\example3-fencedist.cs" />

<Compile Include="plugins\example3.cs" />

<Compile Include="plugins\example4-herelink.cs" />

<Compile Include="plugins\example4.cs" />

<Compile Include="plugins\example5-latencytracker.cs" />

<Compile Include="plugins\example5.cs" />

<Compile Include="plugins\example6-mapicondesc.cs" />

<Compile Include="plugins\example6.cs" />

<Compile Include="plugins\example7-canrtcm.cs" />

<Compile Include="plugins\example7.cs" />

<Compile Include="plugins\example8-modechange.cs" />

<Compile Include="plugins\example8.cs" />

<Compile Include="plugins\example9-hudonoff.cs" />

<Compile Include="plugins\generator.cs" />
Expand Down
44 changes: 44 additions & 0 deletions plugins/example22-fontsize.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit 1cbc963

Please sign in to comment.