зеркало из https://github.com/mono/SkiaSharp.git
Added the code for the Desktop sample
This commit is contained in:
Родитель
8b3d47c211
Коммит
8f124bc19d
|
@ -77,6 +77,14 @@
|
|||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenTK.1.1.2349.61993\lib\NET40\OpenTK.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenTK.GLControl.1.1.2349.61993\lib\NET40\OpenTK.GLControl.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SkiaSharp, Version=1.54.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SkiaSharp.1.54.0\lib\net45\SkiaSharp.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -104,6 +112,7 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
|
@ -129,6 +138,12 @@
|
|||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\views\SkiaSharp.Views.Desktop\SkiaSharp.Views.Desktop.csproj">
|
||||
<Project>{E5A90865-C185-45AD-88D1-6DA7D6004B03}</Project>
|
||||
<Name>SkiaSharp.Views.Desktop</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="packages\SkiaSharp.1.54.0\build\net45\SkiaSharp.targets" Condition="Exists('packages\SkiaSharp.1.54.0\build\net45\SkiaSharp.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
|
|
@ -7,7 +7,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicSkiaSharp", "BasicSkia
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Views.Desktop", "..\..\..\views\SkiaSharp.Views.Desktop\SkiaSharp.Views.Desktop.csproj", "{E5A90865-C185-45AD-88D1-6DA7D6004B03}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharp.Views.OpenTK", "..\..\..\views\SkiaSharp.Views.OpenTK\SkiaSharp.Views.OpenTK.shproj", "{6D28C491-7D4A-44C3-959B-01A9913BFF52}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
..\..\..\views\SkiaSharp.Views.OpenTK\SkiaSharp.Views.OpenTK.projitems*{6d28c491-7d4a-44c3-959b-01a9913bff52}*SharedItemsImports = 13
|
||||
..\..\..\views\SkiaSharp.Views.OpenTK\SkiaSharp.Views.OpenTK.projitems*{e5a90865-c185-45ad-88d1-6da7d6004b03}*SharedItemsImports = 4
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
|
|
|
@ -1,47 +1,130 @@
|
|||
namespace BasicSkiaSharp
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(998, 697);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.softwareControl = new SkiaSharp.Views.SKControl();
|
||||
this.hardwareControl = new SkiaSharp.Views.SKGLControl();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// softwareControl
|
||||
//
|
||||
this.softwareControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.softwareControl.Location = new System.Drawing.Point(24, 61);
|
||||
this.softwareControl.Margin = new System.Windows.Forms.Padding(12);
|
||||
this.softwareControl.Name = "softwareControl";
|
||||
this.softwareControl.Size = new System.Drawing.Size(463, 612);
|
||||
this.softwareControl.TabIndex = 0;
|
||||
this.softwareControl.Text = "skControl1";
|
||||
this.softwareControl.PaintSurface += new System.EventHandler<SkiaSharp.Views.SKPaintSurfaceEventArgs>(this.softwareControl_PaintSurface);
|
||||
//
|
||||
// hardwareControl
|
||||
//
|
||||
this.hardwareControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.hardwareControl.BackColor = System.Drawing.Color.Black;
|
||||
this.hardwareControl.Location = new System.Drawing.Point(511, 61);
|
||||
this.hardwareControl.Margin = new System.Windows.Forms.Padding(12);
|
||||
this.hardwareControl.Name = "hardwareControl";
|
||||
this.hardwareControl.Size = new System.Drawing.Size(463, 612);
|
||||
this.hardwareControl.TabIndex = 1;
|
||||
this.hardwareControl.VSync = false;
|
||||
this.hardwareControl.PaintSurface += new System.EventHandler<SkiaSharp.Views.SKPaintGLSurfaceEventArgs>(this.hardwareControl_PaintSurface);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.Location = new System.Drawing.Point(180, 12);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(151, 37);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Software";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.Location = new System.Drawing.Point(660, 12);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(164, 37);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Hardware";
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.hardwareControl, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label2, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.softwareControl, 0, 1);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(12);
|
||||
this.tableLayoutPanel1.RowCount = 2;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(998, 697);
|
||||
this.tableLayoutPanel1.TabIndex = 4;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(998, 697);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
private SkiaSharp.Views.SKControl softwareControl;
|
||||
private SkiaSharp.Views.SKGLControl hardwareControl;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp.Views;
|
||||
|
||||
namespace BasicSkiaSharp
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// the real draw method
|
||||
private static void Draw(SKSurface surface, SKSize size)
|
||||
{
|
||||
const int stroke = 4;
|
||||
const int curve = 20;
|
||||
const int textSize = 60;
|
||||
const int shrink = stroke / -2;
|
||||
|
||||
var canvas = surface.Canvas;
|
||||
|
||||
canvas.Clear(SKColors.Transparent);
|
||||
|
||||
using (var paint = new SKPaint())
|
||||
{
|
||||
paint.IsAntialias = true;
|
||||
paint.TextSize = textSize;
|
||||
|
||||
paint.Color = SKColors.Orchid;
|
||||
var r = SKRect.Create(SKPoint.Empty, size);
|
||||
canvas.DrawRoundRect(r, curve, curve, paint);
|
||||
|
||||
paint.Color = SKColors.GreenYellow;
|
||||
canvas.DrawText("Hello WinForms World!", 30, textSize + 10, paint);
|
||||
|
||||
paint.Color = SKColors.Orange.WithAlpha(100);
|
||||
canvas.DrawOval(SKRect.Create(50, 50, 100, 100), paint);
|
||||
|
||||
paint.IsStroke = true;
|
||||
paint.StrokeWidth = stroke;
|
||||
paint.Color = SKColors.Black;
|
||||
r.Inflate(shrink, shrink);
|
||||
canvas.DrawRoundRect(r, curve - stroke, curve - stroke, paint);
|
||||
}
|
||||
}
|
||||
|
||||
// from the software view
|
||||
private void softwareControl_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
|
||||
{
|
||||
Draw(e.Surface, e.Info.Size);
|
||||
}
|
||||
|
||||
// from the software view
|
||||
private void hardwareControl_PaintSurface(object sender, SKPaintGLSurfaceEventArgs e)
|
||||
{
|
||||
Draw(e.Surface, new SKSize(e.RenderTarget.Width, e.RenderTarget.Height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="OpenTK" version="1.1.2349.61993" targetFramework="net45" />
|
||||
<package id="OpenTK.GLControl" version="1.1.2349.61993" targetFramework="net45" />
|
||||
<package id="SkiaSharp" version="1.54.0" targetFramework="net45" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче