Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from master #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 97 additions & 1 deletion SVG/SVG.sln

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions SVG/SVG/SVG.Forms.Plugin.Abstractions/ColorPair.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Xamarin.Forms;
using System.Collections.ObjectModel;

namespace SVG.Forms.Plugin.Abstractions
{
public class ColorPairs : ObservableCollection<ColorPair>
{

}

public class ColorPair
{
public Color OldColor { get; set; }
public Color NewColor { get; set; }

public ColorPair( Color in_OldColor, Color in_NewColor ) : this( )
{
OldColor = in_OldColor;
NewColor = in_NewColor;
}

public ColorPair( )
{

}
}
}
13 changes: 13 additions & 0 deletions SVG/SVG/SVG.Forms.Plugin.Abstractions/ISvgImageRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SVG.Forms.Plugin.Abstractions
{
public interface ISvgImageRenderer
{
void Render( );
}
}
Original file line number Diff line number Diff line change
@@ -1,75 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{14C534B6-1984-41A9-A384-D3A5508588E3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SVG.Forms.Plugin.Abstractions</RootNamespace>
<AssemblyName>SVG.Forms.Plugin.Abstractions</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\SVG.Forms.Plugin.Abstractions.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="SvgImage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Core, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.1.4.4.6392\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.1.4.4.6392\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Xaml, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.1.4.4.6392\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.1.4.4.6392\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.1.4.4.6392\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Xamarin.Forms.1.4.4.6392\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.1.4.4.6392\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
</Target>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{14C534B6-1984-41A9-A384-D3A5508588E3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SVG.Forms.Plugin.Abstractions</RootNamespace>
<AssemblyName>SVG.Forms.Plugin.Abstractions</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>32acdf3c</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\SVG.Forms.Plugin.Abstractions.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="ColorPair.cs" />
<Compile Include="ISvgImageRenderer.cs" />
<Compile Include="SvgImage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SvgImageRendererExtensions.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="NGraphics.Custom">
<HintPath>ext_bin\NGraphics.Custom.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Core, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Forms.Xaml, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.1.5.0.6404-pre3\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
</Target>
<!-- 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>
129 changes: 100 additions & 29 deletions SVG/SVG/SVG.Forms.Plugin.Abstractions/SvgImage.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,109 @@
using System.Reflection;
using Xamarin.Forms;
using Xamarin.Forms;

namespace SVG.Forms.Plugin.Abstractions
{
public class SvgImage : Image
{
/// <summary>
/// The path to the svg file
/// </summary>
public static readonly BindableProperty SvgPathProperty =
BindableProperty.Create("SvgPath", typeof(string), typeof(SvgImage), default(string));
public class SvgImage : Image
{
private bool _IsTemplateLoaded = false;

#region Properties
/// <summary>
/// The path to the svg file
/// </summary>
public static readonly BindableProperty SvgPathProperty = BindableProperty.Create("SvgPath", typeof(string), typeof(SvgImage), default(string));

/// <summary>
/// The path to the svg file
/// </summary>
public string SvgPath
{
get { return (string)GetValue(SvgPathProperty); }
set { SetValue(SvgPathProperty, value); }
}
/// <summary>
/// The path to the svg file
/// </summary>
public string SvgPath
{
get { return (string)GetValue(SvgPathProperty); }
set { SetValue(SvgPathProperty, value); }
}

/// <summary>
/// The assembly containing the svg file
/// </summary>
public static readonly BindableProperty SvgAssemblyProperty =
BindableProperty.Create("SvgAssembly", typeof(Assembly), typeof(SvgImage), default(Assembly));
/// <summary>
/// The assembly containing the svg file
/// </summary>
public static readonly BindableProperty SvgAssemblyProperty = BindableProperty.Create("SvgAssembly", typeof(Assembly), typeof(SvgImage), default(Assembly));

/// <summary>
/// The assembly containing the svg file
/// </summary>
public Assembly SvgAssembly
{
get { return (Assembly)GetValue(SvgAssemblyProperty); }
set { SetValue(SvgAssemblyProperty, value); }
}
/// <summary>
/// The assembly containing the svg file
/// </summary>
public Assembly SvgAssembly
{
get { return (Assembly)GetValue(SvgAssemblyProperty); }
set { SetValue(SvgAssemblyProperty, value); }
}

/// <summary>
/// Colors to replace upon render.
/// </summary>
public static readonly BindableProperty ReplacementColorsProperty = BindableProperty.Create<SvgImage, ColorPairs>(w => w.ReplacementColors, null, BindingMode.Default, null, OnReplacementColorsPropertyChanged, null, null, null);
/// <summary>
/// Colors to replace upon render.
/// </summary>
public ColorPairs ReplacementColors
{
get { return (ColorPairs)GetValue(ReplacementColorsProperty); }
set { SetValue(ReplacementColorsProperty, value); }
}
#endregion

#region Startup
public SvgImage( ) : base( )
{
if( ReplacementColors == null )
ReplacementColors = new ColorPairs( );

ApplyTemplate( );
}

private void ApplyTemplate( )
{
_IsTemplateLoaded = true;
OnReplacementColorsChanged( );
}
#endregion

#region Property Changes
private static void OnReplacementColorsPropertyChanged( BindableObject d, ColorPairs in_OldValue, ColorPairs in_NewValue )
{
SvgImage element = d as SvgImage;

if( element == null )
return;

if( in_OldValue != null )
in_OldValue.CollectionChanged -= element.ColorPairs_CollectionChanged;

if( in_NewValue != null )
{
in_NewValue.CollectionChanged -= element.ColorPairs_CollectionChanged;
in_NewValue.CollectionChanged += element.ColorPairs_CollectionChanged;
}

if( in_NewValue == in_OldValue )
return;

element.OnReplacementColorsChanged( );
}

private void ColorPairs_CollectionChanged( object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e )
{
// inefficient for now, should go by whats added and what is not --bwc
OnReplacementColorsChanged( );
}

private void OnReplacementColorsChanged( )
{
if( !_IsTemplateLoaded )
return;

//ISvgImageRenderer renderer = RendererFactory.GetRenderer(this) as ISvgImageRenderer;
//if( renderer != null )
// renderer.Render( );
}
#endregion
}
}
Loading