This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using SkiaSharp; | |
using SkiaSharp.Views.Desktop; | |
namespace HiDarran | |
{ | |
public partial class HiDarran : System.Windows.Forms.Form | |
{ | |
private readonly SKControl skView; | |
private bool runRenderLoop = true; | |
public HiDarran() | |
{ | |
Text = "Hi Darran"; | |
ClientSize = new System.Drawing.Size(800, 450); | |
skView = new SKControl(); | |
skView.Dock = System.Windows.Forms.DockStyle.Fill; | |
Controls.Add(skView); | |
skView.PaintSurface += SkView_PaintSurface; | |
_ = PresentLoop(); | |
} | |
private async Task PresentLoop() | |
{ | |
while (runRenderLoop) | |
{ | |
skView.Invalidate(); | |
await Task.Delay(16).ConfigureAwait(true); | |
} | |
} | |
private void SkView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) | |
{ | |
e.Surface.Canvas.Clear(SKColors.White); | |
e.Surface.Canvas.DrawText("Hi Darran!", 100, 100, new SKPaint() { Color = SKColors.Black, TextSize = 25 }); | |
e.Surface.Canvas.DrawText(DateTime.Now.ToString(), 200, 200, new SKPaint() { Color = SKColors.Black, TextSize = 25 }); | |
} | |
protected override void Dispose(bool disposing) | |
{ | |
if (disposing) | |
{ | |
runRenderLoop = false; | |
skView.Dispose(); | |
} | |
base.Dispose(disposing); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | |
<PropertyGroup> | |
<OutputType>WinExe</OutputType> | |
<TargetFramework>netcoreapp3.1</TargetFramework> | |
<UseWindowsForms>true</UseWindowsForms> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="SkiaSharp" Version="2.80.2" /> | |
<PackageReference Include="SkiaSharp.Views.WindowsForms" Version="2.80.2" /> | |
</ItemGroup> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace HiDarran | |
{ | |
static class Program | |
{ | |
/// <summary> | |
/// The main entry point for the application. | |
/// </summary> | |
[STAThread] | |
static void Main() | |
{ | |
Application.SetHighDpiMode(HighDpiMode.SystemAware); | |
Application.EnableVisualStyles(); | |
Application.SetCompatibleTextRenderingDefault(false); | |
Application.Run(new HiDarran()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment