Skip to content

Commit

Permalink
Add the WPF backend for Xamarin.Forms (#917)
Browse files Browse the repository at this point in the history
Add a new NuGet
- add a targets file to the nuget to warn if the platform packages were not installed

Update the pipeline:
- use build artifacts everywhere
- just disable tizen for Windows
  • Loading branch information
mattleibow committed Jul 26, 2019
1 parent ec5f04f commit e6b7934
Show file tree
Hide file tree
Showing 69 changed files with 2,533 additions and 163 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ output/
tools/
*.VC.db
**/Resources/Resource.designer.cs
*.binlog

# User-specific files
*.suo
Expand Down Expand Up @@ -244,6 +245,7 @@ _Pvt_Extensions

## Build generated
build/
!**/nuget/build/
DerivedData

## Various settings
Expand Down
1 change: 1 addition & 0 deletions VERSIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SkiaSharp.Views.Gtk3 nuget 1.68.1
SkiaSharp.Views.WindowsForms nuget 1.68.1
SkiaSharp.Views.WPF nuget 1.68.1
SkiaSharp.Views.Forms nuget 1.68.1
SkiaSharp.Views.Forms.WPF nuget 1.68.1
SkiaSharp.HarfBuzz nuget 1.68.1
HarfBuzzSharp nuget 2.5.3
HarfBuzzSharp.NativeAssets.Linux nuget 2.5.3
15 changes: 12 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var TRACKED_NUGETS = new Dictionary<string, Version> {
{ "SkiaSharp.Views.WindowsForms", new Version (1, 57, 0) },
{ "SkiaSharp.Views.WPF", new Version (1, 57, 0) },
{ "SkiaSharp.Views.Forms", new Version (1, 57, 0) },
{ "SkiaSharp.Views.Forms.WPF", new Version (1, 57, 0) },
{ "HarfBuzzSharp", new Version (1, 0, 0) },
{ "HarfBuzzSharp.NativeAssets.Linux", new Version (1, 0, 0) },
{ "SkiaSharp.HarfBuzz", new Version (1, 57, 0) },
Expand Down Expand Up @@ -230,10 +231,15 @@ Task ("samples")
// create the samples archive
CreateSamplesDirectory ("./samples/", "./output/samples/");
DeleteFiles ("./output/samples/README.md");
MoveFile ("./output/samples/README.zip.md", "./output/samples/README.md");
Zip ("./output/samples/", "./output/samples.zip");
// create the preview samples archive
var suffix = string.IsNullOrEmpty (BUILD_NUMBER)
? $"{PREVIEW_LABEL}"
: $"{PREVIEW_LABEL}.{BUILD_NUMBER}";
CreateSamplesDirectory ("./samples/", "./output/samples-preview/", suffix);
Zip ("./output/samples-preview/", "./output/samples-preview.zip");
// build the newly migrated samples
CleanDirectories ($"{PACKAGE_CACHE_PATH}/skiasharp*");
CleanDirectories ($"{PACKAGE_CACHE_PATH}/harfbuzzsharp*");
Expand Down Expand Up @@ -266,6 +272,9 @@ Task ("samples")
}
}
CleanDirectory ("./output/samples/");
DeleteDirectory ("./output/samples/");
CleanDirectory ("./output/samples-preview/");
DeleteDirectory ("./output/samples-preview/");
});

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -562,7 +571,7 @@ var envVarsWhitelist = new [] {
"processor_identifier", "node_name", "node_labels", "branch_name",
"os", "build_url", "build_number", "number_of_processors",
"node_label", "build_id", "git_sha", "git_branch_name",
"feature_name", "msbuild_exe", "python_exe",
"feature_name", "msbuild_exe", "python_exe", "preview_label",
"home", "userprofile", "nuget_packages",
"android_sdk_root", "android_ndk_root",
"android_home", "android_ndk_home", "tizen_studio_home"
Expand Down
8 changes: 6 additions & 2 deletions cake/UtilsManaged.cake
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ var DecompressArchive = new Action<FilePath, DirectoryPath> ((archive, outputDir
}
});

void CreateSamplesDirectory (DirectoryPath samplesDirPath, DirectoryPath outputDirPath)
void CreateSamplesDirectory (DirectoryPath samplesDirPath, DirectoryPath outputDirPath, string versionSuffix = "")
{
samplesDirPath = MakeAbsolute (samplesDirPath);
outputDirPath = MakeAbsolute (outputDirPath);
Expand Down Expand Up @@ -227,9 +227,10 @@ void CreateSamplesDirectory (DirectoryPath samplesDirPath, DirectoryPath outputD
if (!string.IsNullOrWhiteSpace (version)) {
Debug ($"Substituting project reference {relFilePath} for project {rel}.");
var name = projItem.Name.Namespace + "PackageReference";
var suffix = string.IsNullOrEmpty (versionSuffix) ? "" : $"-{versionSuffix}";
projItem.AddAfterSelf (new XElement (name, new object[] {
new XAttribute("Include", packagingGroup),
new XAttribute("Version", version),
new XAttribute("Version", version + suffix),
}));
} else {
Warning ($"Unable to find version information for package '{packagingGroup}'.");
Expand Down Expand Up @@ -271,6 +272,9 @@ void CreateSamplesDirectory (DirectoryPath samplesDirPath, DirectoryPath outputD
CopyFile (file, dest);
}
}

DeleteFiles ($"{outputDirPath}/README.md");
MoveFile ($"{outputDirPath}/README.zip.md", $"{outputDirPath}/README.md");
}

FilePath GetFullPath (FilePath root, FilePath path)
Expand Down
55 changes: 55 additions & 0 deletions nuget/SkiaSharp.Views.Forms.WPF.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>

<!-- package -->
<id>SkiaSharp.Views.Forms.WPF</id>
<title>SkiaSharp for Xamarin.Forms (WPF)</title>
<version>1.0.0</version>
<description>
SkiaSharp for Xamarin.Forms is a set of views that can be used to draw on the screen.
</description>
<summary>
SkiaSharp for Xamarin.Forms is a set of views that can be used to draw on the screen.
</summary>
<releaseNotes>
Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release notes.
</releaseNotes>
<projectUrl>https://go.microsoft.com/fwlink/?linkid=868515</projectUrl>
<iconUrl>https://go.microsoft.com/fwlink/?linkid=868516</iconUrl>
<tags>ui xamarin.forms xamarin graphics ios android linux windows uwp tvos macos tizen cross-platform skiasharp</tags>

<!-- legal -->
<licenseUrl>https://go.microsoft.com/fwlink/?linkid=868514</licenseUrl>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>

<dependencies>
<dependency id="Xamarin.Forms" version="4.0.0.540366" />
<dependency id="Xamarin.Forms.Platform.WPF" version="4.0.0.540366" />
<dependency id="SkiaSharp" version="1.0.0" />
<dependency id="SkiaSharp.Views.Desktop.Common" version="1.0.0" />
<dependency id="SkiaSharp.Views.WindowsForms" version="1.0.0" />
<dependency id="SkiaSharp.Views.WPF" version="1.0.0" />
<dependency id="SkiaSharp.Views.Forms" version="1.0.0" />
<dependency id="OpenTK" version="3.0.1" />
<dependency id="OpenTK.GLControl" version="3.0.1" />
</dependencies>

</metadata>
<files>

<!-- SkiaSharp.Views.Forms.dll -->
<file src="lib/net45/SkiaSharp.Views.Forms.dll" />
<file src="lib/net45/SkiaSharp.Views.Forms.xml" />

<!-- the build bits -->
<file src="build/net45/SkiaSharp.Views.Forms.WPF.props" />

<!-- legal -->
<file src="LICENSE.txt" />

</files>
</package>
9 changes: 8 additions & 1 deletion nuget/SkiaSharp.Views.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<copyright>© Microsoft Corporation. All rights reserved.</copyright>

<dependencies>
<group>
<group targetFramework="netstandard1.3">
<dependency id="Xamarin.Forms" version="4.0.0.540366" />
<dependency id="SkiaSharp" version="1.0.0" />
</group>
Expand Down Expand Up @@ -56,6 +56,10 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<dependency id="SkiaSharp" version="1.0.0" />
<dependency id="SkiaSharp.Views" version="1.0.0" />
</group>
<group targetFramework="net45">
<dependency id="Xamarin.Forms" version="4.0.0.540366" />
<dependency id="SkiaSharp" version="1.0.0" />
</group>
</dependencies>

</metadata>
Expand All @@ -75,6 +79,9 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<file src="lib/tizen40/SkiaSharp.Views.Forms.dll" />
<file src="lib/tizen40/SkiaSharp.Views.Forms.xml" />

<!-- the build bits -->
<file src="build/net45/SkiaSharp.Views.Forms.targets" />

<!-- legal -->
<file src="LICENSE.txt" />

Expand Down
2 changes: 2 additions & 0 deletions nuget/SkiaSharp.Views.WindowsForms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<dependencies>
<dependency id="SkiaSharp" version="1.0.0" />
<dependency id="SkiaSharp.Views.Desktop.Common" version="1.0.0" />
<dependency id="OpenTK" version="3.0.1" />
<dependency id="OpenTK.GLControl" version="3.0.1" />
</dependencies>

</metadata>
Expand Down
6 changes: 6 additions & 0 deletions samples/Basic/Xamarin.Forms/SkiaSharpSample.WPF/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions samples/Basic/Xamarin.Forms/SkiaSharpSample.WPF/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="SkiaSharpSample.WPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SkiaSharpSample.WPF"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions samples/Basic/Xamarin.Forms/SkiaSharpSample.WPF/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace SkiaSharpSample.WPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
13 changes: 13 additions & 0 deletions samples/Basic/Xamarin.Forms/SkiaSharpSample.WPF/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<forms:FormsApplicationPage x:Class="SkiaSharpSample.WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:forms="clr-namespace:Xamarin.Forms.Platform.WPF;assembly=Xamarin.Forms.Platform.WPF"
xmlns:local="clr-namespace:SkiaSharpSample.WPF"
mc:Ignorable="d"
Title="SkiaSharpSample.WPF" Height="600" Width="800">
<Grid>

</Grid>
</forms:FormsApplicationPage>
30 changes: 30 additions & 0 deletions samples/Basic/Xamarin.Forms/SkiaSharpSample.WPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Xamarin.Forms;
using Xamarin.Forms.Platform.WPF;

namespace SkiaSharpSample.WPF
{
public partial class MainWindow : FormsApplicationPage
{
public MainWindow()
{
InitializeComponent();

Forms.Init();
LoadApplication(new SkiaSharpSample.App());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SkiaSharpSample.WPF")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkiaSharpSample.WPF")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit e6b7934

Please sign in to comment.