fork download
using System;
using System.Threading.Tasks;
using System.Windows;
using SkiaSharp;
using SkiaSharp.Views.Desktop;

namespace SkiaSharpSample
{
	/// <summary>
	/// MainWindow.xaml の相互作用ロジック
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
		}

		private int x;

		private async void Window_Loaded(object sender, RoutedEventArgs e)
		{
			while ( true )
			{
				for ( int i = 0; i <= 600; ++i )
				{
					x = i;
					this.canvas.InvalidateVisual();
					await Task.Delay( TimeSpan.FromSeconds( 1 ) );
				}
			}
		}

		private void OnPaintSample(object sender, SKPaintSurfaceEventArgs e )
		{
			Render( e.Surface.Canvas );
		}

		public void Render(SKCanvas canvas)
		{
			if ( x == 0 )
			{
				canvas.Clear();
			}

			SKPaint thickLinePaint = new SKPaint
			{
				Style = SKPaintStyle.Stroke,
				Color = SKColors.Orange,
				StrokeWidth = 1
			};

//			for ( int x = 0; x <= 600; x++ )
			{
				canvas.DrawLine(x, 0, x, 100, thickLinePaint);
				// ここ ←待機出来ない
			}
		}

	}
}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.100

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Package source with Name: nuget.org disabled successfully.
Package source with Name: local added successfully.
/home/rJM921/Project/Program.cs(4,7): error CS0246: The type or namespace name 'SkiaSharp' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(5,7): error CS0246: The type or namespace name 'SkiaSharp' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(12,36): error CS0246: The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(21,51): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(34,45): error CS0246: The type or namespace name 'SKPaintSurfaceEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(39,22): error CS0246: The type or namespace name 'SKCanvas' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]



/home/rJM921/Project/Program.cs(4,7): error CS0246: The type or namespace name 'SkiaSharp' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(5,7): error CS0246: The type or namespace name 'SkiaSharp' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(12,36): error CS0246: The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(21,51): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(34,45): error CS0246: The type or namespace name 'SKPaintSurfaceEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
/home/rJM921/Project/Program.cs(39,22): error CS0246: The type or namespace name 'SKCanvas' could not be found (are you missing a using directive or an assembly reference?) [/home/rJM921/Project/Project.csproj]
    0 Warning(s)
    6 Error(s)

Time Elapsed 00:00:03.56
stdout
Standard output is empty