This commit is contained in:
Matthew Leibowitz 2016-09-26 23:27:29 +02:00
Родитель ea92bc48e7
Коммит 602057eba8
18 изменённых файлов: 847 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,125 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharpSample.UWPSample", "SkiaSharpSample.UWPSample\SkiaSharpSample.UWPSample.csproj", "{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SkiaSharp.Views", "SkiaSharp.Views", "{6B67133E-E932-4567-9052-2689AEDF76C6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkiaSharp.Views.Interop.UWP", "..\..\source\SkiaSharp.Views\SkiaSharp.Views.Interop.UWP\SkiaSharp.Views.Interop.UWP.vcxproj", "{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharp.Views.Shared", "..\..\source\SkiaSharp.Views\SkiaSharp.Views.Shared\SkiaSharp.Views.Shared.shproj", "{5A67972C-1C04-4913-9950-06A03BFE9533}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Views.UWP", "..\..\source\SkiaSharp.Views\SkiaSharp.Views.UWP\SkiaSharp.Views.UWP.csproj", "{8BB20362-91A2-4206-944D-634070EAC6F3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SkiaSharp", "SkiaSharp", "{384970C2-6392-4134-91D5-BE9AB7209DF9}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Binding", "..\..\binding\Binding\Binding.shproj", "{9C502B9A-25D4-473F-89BD-5A13DDE16354}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.UWP", "..\..\binding\SkiaSharp.UWP\SkiaSharp.UWP.csproj", "{BAB615AA-956E-4079-B260-DD7B1F52EC7D}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharpSample.Shared", "..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.shproj", "{509B233A-35A0-41CA-A585-0B1A9F79D470}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharpSample.Platform.Shared", "..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.shproj", "{0CC41AB0-0C4C-4DAA-8F10-A249725EBF5D}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.projitems*{0cc41ab0-0c4c-4daa-8f10-a249725ebf5d}*SharedItemsImports = 13
..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems*{509b233a-35a0-41ca-a585-0b1a9f79d470}*SharedItemsImports = 13
..\..\source\SkiaSharp.Views\SkiaSharp.Views.Shared\SkiaSharp.Views.Shared.projitems*{5a67972c-1c04-4913-9950-06a03bfe9533}*SharedItemsImports = 13
..\..\source\SkiaSharp.Views\SkiaSharp.Views.Shared\SkiaSharp.Views.Shared.projitems*{8bb20362-91a2-4206-944d-634070eac6f3}*SharedItemsImports = 4
..\..\binding\Binding\Binding.projitems*{9c502b9a-25d4-473f-89bd-5a13dde16354}*SharedItemsImports = 13
..\..\binding\Binding\Binding.projitems*{bab615aa-956e-4079-b260-dd7b1f52ec7d}*SharedItemsImports = 4
..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.projitems*{bfc6b190-a17c-4538-b2c6-eeda46d87efe}*SharedItemsImports = 4
..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems*{bfc6b190-a17c-4538-b2c6-eeda46d87efe}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|Any CPU.ActiveCfg = Debug|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|ARM.ActiveCfg = Debug|ARM
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|ARM.Build.0 = Debug|ARM
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|ARM.Deploy.0 = Debug|ARM
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|x64.ActiveCfg = Debug|x64
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|x64.Build.0 = Debug|x64
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|x64.Deploy.0 = Debug|x64
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|x86.ActiveCfg = Debug|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|x86.Build.0 = Debug|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Debug|x86.Deploy.0 = Debug|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|Any CPU.ActiveCfg = Release|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|ARM.ActiveCfg = Release|ARM
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|ARM.Build.0 = Release|ARM
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|ARM.Deploy.0 = Release|ARM
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|x64.ActiveCfg = Release|x64
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|x64.Build.0 = Release|x64
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|x64.Deploy.0 = Release|x64
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|x86.ActiveCfg = Release|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|x86.Build.0 = Release|x86
{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}.Release|x86.Deploy.0 = Release|x86
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|Any CPU.ActiveCfg = Debug|Win32
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|ARM.ActiveCfg = Debug|ARM
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|ARM.Build.0 = Debug|ARM
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|x64.ActiveCfg = Debug|x64
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|x64.Build.0 = Debug|x64
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|x86.ActiveCfg = Debug|Win32
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Debug|x86.Build.0 = Debug|Win32
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|Any CPU.ActiveCfg = Release|Win32
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|ARM.ActiveCfg = Release|ARM
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|ARM.Build.0 = Release|ARM
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|x64.ActiveCfg = Release|x64
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|x64.Build.0 = Release|x64
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|x86.ActiveCfg = Release|Win32
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C}.Release|x86.Build.0 = Release|Win32
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|ARM.Build.0 = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|x64.ActiveCfg = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|x64.Build.0 = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|x86.ActiveCfg = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Debug|x86.Build.0 = Debug|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|ARM.ActiveCfg = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|ARM.Build.0 = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|x64.ActiveCfg = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|x64.Build.0 = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|x86.ActiveCfg = Release|Any CPU
{8BB20362-91A2-4206-944D-634070EAC6F3}.Release|x86.Build.0 = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|ARM.Build.0 = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|x64.ActiveCfg = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|x64.Build.0 = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|x86.ActiveCfg = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Debug|x86.Build.0 = Debug|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|Any CPU.Build.0 = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|ARM.ActiveCfg = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|ARM.Build.0 = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|x64.ActiveCfg = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|x64.Build.0 = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|x86.ActiveCfg = Release|Any CPU
{BAB615AA-956E-4079-B260-DD7B1F52EC7D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{162D75E5-B52A-4B43-B896-5D3F3A7AB90C} = {6B67133E-E932-4567-9052-2689AEDF76C6}
{5A67972C-1C04-4913-9950-06A03BFE9533} = {6B67133E-E932-4567-9052-2689AEDF76C6}
{8BB20362-91A2-4206-944D-634070EAC6F3} = {6B67133E-E932-4567-9052-2689AEDF76C6}
{9C502B9A-25D4-473F-89BD-5A13DDE16354} = {384970C2-6392-4134-91D5-BE9AB7209DF9}
{BAB615AA-956E-4079-B260-DD7B1F52EC7D} = {384970C2-6392-4134-91D5-BE9AB7209DF9}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,8 @@
<Application
x:Class="SkiaSharpSample.UWPSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SkiaSharpSample.UWPSample"
RequestedTheme="Light">
</Application>

Просмотреть файл

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace SkiaSharpSample.UWPSample
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 17 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.0 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 569 B

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.8 KiB

Просмотреть файл

@ -0,0 +1,98 @@
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:views="using:SkiaSharp.Views"
xmlns:sample="using:SkiaSharpSample"
xmlns:local="using:SkiaSharpSample.UWPSample"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SkiaSharpSample.UWPSample.MainPage"
mc:Ignorable="d">
<Page.Resources>
<CollectionViewSource x:Name="samplesViewSource" IsSourceGrouped="True" />
<Style x:Key="ShellButton" TargetType="ButtonBase">
<Setter Property="Background" Value="Transparent" />
<!--<Setter Property="BorderBrush" Value="{x:Null}" />-->
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="Width" Value="{ThemeResource SplitViewCompactPaneThemeLength}" />
<Setter Property="Height" Value="{ThemeResource SplitViewCompactPaneThemeLength}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
</Style>
<SolidColorBrush x:Key="XamarinLightBlue" Color="#3498DB" />
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{ThemeResource SplitViewCompactPaneThemeLength}" />
<RowDefinition />
</Grid.RowDefinitions>
<SplitView Name="splitView" DisplayMode="Overlay" OpenPaneLength="320" Grid.Row="1">
<SplitView.Pane>
<!-- the samples menu -->
<ListView ItemsSource="{x:Bind samplesViewSource.View}" SelectionChanged="OnSampleSelected">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="local:GroupedSamples">
<TextBlock Text="{x:Bind Name}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemTemplate>
<DataTemplate x:DataType="sample:SampleBase">
<TextBlock Text="{x:Bind Title}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</SplitView.Pane>
<SplitView.Content>
<!-- the samples canvas -->
<Grid Tapped="OnSampleTapped">
<views:SKXamlCanvas x:Name="canvas" Grid.Row="1" PaintSurface="OnPaintCanvas" />
<!--<views:SKSwapChainPanel x:Name="glview" Grid.Row="1" Visibility="Collapsed" />-->
</Grid>
</SplitView.Content>
</SplitView>
</Grid>
<CommandBar x:Name="commandBar" Background="{StaticResource XamarinLightBlue}" Foreground="White">
<!-- the toolbar items -->
<AppBarButton Icon="Repair" Label="Configure Backend" IsCompact="True" Foreground="White">
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem Text="Memory" Tag="Memory" Click="OnBackendSelected" />
<MenuFlyoutItem Text="OpenGL" Tag="OpenGL" Click="OnBackendSelected" />
<MenuFlyoutItem Text="Vulkan" Tag="Vulkan" Click="OnBackendSelected" />
</MenuFlyout>
</Button.Flyout>
</AppBarButton>
<AppBarButton Icon="Pictures" Label="Toggle Sample Slideshow" IsCompact="True" Foreground="White"
Click="OnToggleSlideshow" />
<CommandBar.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- the hamburger menu -->
<ToggleButton IsChecked="{Binding IsPaneOpen, ElementName=splitView, Mode=TwoWay}" IsTabStop="False"
IsThreeState="False" ClickMode="Press" Style="{StaticResource ShellButton}" Foreground="White">
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE700;" />
</ToggleButton>
<!-- the title bar -->
<TextBlock x:Name="titleBar" Text="SkiaSharp for Windows" Grid.Column="1" Margin="12,0,0,0"
VerticalAlignment="Center" HorizontalAlignment="Left" />
</Grid>
</CommandBar.Content>
</CommandBar>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,232 @@
using SkiaSharp;
using SkiaSharp.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Foundation.Metadata;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace SkiaSharpSample.UWPSample
{
public sealed partial class MainPage : Page
{
private static Color XamarinLightBlue = Color.FromArgb(0xff, 0x34, 0x98, 0xdb);
private static Color XamarinDarkBlue = Color.FromArgb(0xff, 0x2c, 0x3e, 0x50);
private CancellationTokenSource cancellations;
private IList<SampleBase> samples;
private IList<GroupedSamples> sampleGroups;
private SampleBase sample;
public MainPage()
{
this.InitializeComponent();
if (ApiInformation.IsTypePresent(typeof(StatusBar).FullName))
{
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundColor = XamarinLightBlue;
statusBar.ForegroundColor = Colors.White;
statusBar.BackgroundOpacity = 1;
}
if (ApiInformation.IsTypePresent(typeof(ApplicationViewTitleBar).FullName))
{
var titlebar = ApplicationView.GetForCurrentView().TitleBar;
titlebar.BackgroundColor = XamarinLightBlue;
titlebar.ForegroundColor = Colors.White;
titlebar.ButtonBackgroundColor = XamarinLightBlue;
titlebar.ButtonForegroundColor = Colors.White;
titlebar.ButtonHoverBackgroundColor = XamarinDarkBlue;
titlebar.ButtonHoverForegroundColor = Colors.White;
}
samples = SamplesManager.GetSamples(SamplePlatforms.iOS).ToList();
sampleGroups = Enum.GetValues(typeof(SampleCategories))
.Cast<SampleCategories>()
.Select(c => new GroupedSamples(c, samples.Where(s => s.Category.HasFlag(c))))
.Where(g => g.Count > 0)
.OrderBy(g => g.Category == SampleCategories.Showcases ? string.Empty : g.Name)
.ToList();
SamplesInitializer.Init();
samplesViewSource.Source = sampleGroups;
//foreach (var category in sampleGroups)
//{
// // create the menu item
// var menu = new MenuItem { Header = category.Name };
// foreach (var sample in category.Samples)
// {
// // create the sample item
// var menuItem = new MenuItem
// {
// Header = sample.Title,
// Tag = sample
// };
// menuItem.Click += OnSampleSelected;
// menu.Items.Add(menuItem);
// }
// // add to the menu bar
// samplesList.Items.Add(menu);
//}
SetSample(samples.First(s => s.Category.HasFlag(SampleCategories.Showcases)));
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
cancellations?.Cancel();
cancellations = null;
}
private void OnSampleSelected(object sender, SelectionChangedEventArgs e)
{
var sample = e.AddedItems?.FirstOrDefault() as SampleBase;
SetSample(sample);
}
private void OnBackendSelected(object sender, RoutedEventArgs e)
{
var menu = sender as MenuFlyoutItem;
var backend = (SampleBackends)Enum.Parse(typeof(SampleBackends), menu.Tag.ToString());
switch (backend)
{
case SampleBackends.Memory:
//glhost.Visibility = Visibility.Collapsed;
canvas.Visibility = Visibility.Visible;
break;
case SampleBackends.OpenGL:
//glhost.Visibility = Visibility.Visible;
canvas.Visibility = Visibility.Collapsed;
break;
default:
var msg = new MessageDialog("This functionality is not yet implemented.", "Configure Backend");
msg.Commands.Add(new UICommand("OK"));
msg.ShowAsync();
break;
}
}
private void OnToggleSlideshow(object sender, RoutedEventArgs e)
{
if (cancellations != null)
{
// cancel the old loop
cancellations.Cancel();
cancellations = null;
}
else
{
// start a new loop
cancellations = new CancellationTokenSource();
var token = cancellations.Token;
Task.Run(async delegate
{
try
{
// get the samples in a list
var sortedSamples = sampleGroups.SelectMany(g => g).Distinct().ToList();
var lastSample = sortedSamples.First();
while (!token.IsCancellationRequested)
{
// display the sample
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => SetSample(lastSample));
// wait a bit
await Task.Delay(3000, token);
// select the next one
var idx = sortedSamples.IndexOf(lastSample) + 1;
if (idx >= sortedSamples.Count)
{
idx = 0;
}
lastSample = sortedSamples[idx];
}
}
catch (TaskCanceledException)
{
// we are expecting this
}
});
}
}
private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e)
{
OnPaintSurface(e.Surface.Canvas, e.Info.Width, e.Info.Height);
}
private void SetSample(SampleBase newSample)
{
sample = newSample;
// set the title
titleBar.Text = sample?.Title ?? "SkiaSharp for Windows";
// prepare the sample
sample?.Init(() =>
{
// refresh the view
canvas.Invalidate();
//glhost.Child?.Invalidate();
});
// refresh the view
canvas.Invalidate();
//glhost.Child?.Invalidate();
}
private void OnPaintSurface(SKCanvas canvas, int width, int height)
{
sample?.DrawSample(canvas, width, height);
}
private void OnSampleTapped(object sender, TappedRoutedEventArgs e)
{
sample?.Tap();
}
}
public class GroupedSamples : ObservableCollection<SampleBase>
{
private static readonly Regex EnumSplitRexeg = new Regex("(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])");
public GroupedSamples(SampleCategories category, IEnumerable<SampleBase> samples)
{
Category = category;
Name = EnumSplitRexeg.Replace(category.ToString(), " $1");
foreach (var sample in samples.OrderBy(s => s.Title))
{
Add(sample);
}
}
public SampleCategories Category { get; private set; }
public string Name { get; private set; }
}
}

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="792efd03-834f-4a7f-9997-56d6cc91b3d7" Publisher="CN=mattl" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="792efd03-834f-4a7f-9997-56d6cc91b3d7" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>SkiaSharpSample.UWPSample</DisplayName>
<PublisherDisplayName>mattl</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="SkiaSharpSample.UWPSample.App">
<uap:VisualElements DisplayName="SkiaSharp for Windows" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="This is a sample app demonstrating some of the many features of SkiaSharp. The source code is available at: http://github.com/mono/SkiaSharp" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" ShortName="SkiaSharp">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#F8F8F8" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>

Просмотреть файл

@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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.UWPSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkiaSharpSample.UWPSample")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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")]
[assembly: ComVisible(false)]

Просмотреть файл

@ -0,0 +1,31 @@
<!--
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
developers. However, you can modify these parameters to modify the behavior of the .NET Native
optimizer.
Runtime Directives are documented at http://go.microsoft.com/fwlink/?LinkID=391919
To fully enable reflection for App1.MyClass and all of its public/private members
<Type Name="App1.MyClass" Dynamic="Required All"/>
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
<Namespace Name="DataClasses.ViewModels" Seralize="All" />
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
</Application>
</Directives>

Просмотреть файл

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{BFC6B190-A17C-4538-B2C6-EEDA46D87EFE}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SkiaSharpSample.UWPSample</RootNamespace>
<AssemblyName>SkiaSharpSample.UWPSample</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>SkiaSharpSample.UWPSample_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<Content Include="..\..\SkiaSharpSample.Shared\Media\content-font.ttf">
<Link>Assets\Media\content-font.ttf</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="SkiaSharpSample.UWPSample_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\native-builds\lib\uwp\x86\libSkiaSharp.dll">
<Link>libSkiaSharp.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\binding\SkiaSharp.UWP\SkiaSharp.UWP.csproj">
<Project>{bab615aa-956e-4079-b260-dd7b1f52ec7d}</Project>
<Name>SkiaSharp.UWP</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\source\SkiaSharp.Views\SkiaSharp.Views.Interop.UWP\SkiaSharp.Views.Interop.UWP.vcxproj">
<Project>{162d75e5-b52a-4b43-b896-5d3f3a7ab90c}</Project>
<Name>SkiaSharp.Views.Interop.UWP</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\source\SkiaSharp.Views\SkiaSharp.Views.UWP\SkiaSharp.Views.UWP.csproj">
<Project>{8bb20362-91a2-4206-944d-634070eac6f3}</Project>
<Name>SkiaSharp.Views.UWP</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<SDKReference Include="WindowsDesktop, Version=10.0.10240.0">
<Name>Windows Desktop Extensions for the UWP</Name>
</SDKReference>
<SDKReference Include="WindowsMobile, Version=10.0.10240.0">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
</ItemGroup>
<ItemGroup />
<Import Project="..\..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.projitems" Label="Shared" />
<Import Project="..\..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,17 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"PCLStorage": "1.0.2"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}