├── .gitignore
├── LICENSE.txt
├── README.md
├── Sample
├── Sample.Droid
│ ├── Assets
│ │ └── AboutAssets.txt
│ ├── MainActivity.cs
│ ├── Properties
│ │ ├── AndroidManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── AboutResources.txt
│ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ ├── drawable-xhdpi
│ │ │ └── icon.png
│ │ ├── drawable-xxhdpi
│ │ │ └── icon.png
│ │ ├── drawable
│ │ │ └── icon.png
│ │ ├── layout
│ │ │ ├── Tabbar.axml
│ │ │ └── Toolbar.axml
│ │ └── values
│ │ │ └── styles.xml
│ ├── Sample.Droid.csproj
│ └── packages.config
├── Sample.iOS
│ ├── AppDelegate.cs
│ ├── Entitlements.plist
│ ├── Info.plist
│ ├── Main.cs
│ ├── Resources
│ │ ├── Images.xcassets
│ │ │ └── AppIcons.appiconset
│ │ │ │ └── Contents.json
│ │ ├── LaunchScreen.xib
│ │ └── icon.png
│ ├── Sample.iOS.csproj
│ └── packages.config
├── Sample.sln
└── Sample
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Resources
│ ├── colours.svg
│ ├── flower.jpg
│ ├── icon.png
│ ├── ios-star.svg
│ └── tiger.svg
│ ├── Sample.csproj
│ ├── ViewModels
│ └── MainPageViewModel.cs
│ └── Views
│ ├── MainPage.xaml
│ └── MainPage.xaml.cs
├── SvgImageSource.Droid
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── AboutResources.txt
│ └── values
│ │ └── Strings.xml
├── SvgImage.cs
├── SvgImageSource.Droid.csproj
├── SvgImageSourceHandler.cs
└── packages.config
├── SvgImageSource.iOS
├── Properties
│ └── AssemblyInfo.cs
├── SvgImage.cs
├── SvgImageSource.iOS.csproj
├── SvgImageSourceHandler.cs
└── packages.config
├── SvgImageSource.sln
├── SvgImageSource
├── Properties
│ └── AssemblyInfo.cs
├── StreamWrapper.cs
├── SvgImageSource.cs
├── SvgImageSource.csproj
└── SvgUtility.cs
└── nuget
├── AzurePipelines.nuspec
├── SvgImageSource_mac.nuspec
├── nuget.exe
└── pack.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | .vs/
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.sln.docstates
10 | *.userprefs
11 |
12 | # ignore Xamarin.Android Resource.Designer.cs files
13 | **/*.Droid/**/[Rr]esource.[Dd]esigner.cs
14 | **/*.Android/**/[Rr]esource.[Dd]esigner.cs
15 | **/Android/**/[Rr]esource.[Dd]esigner.cs
16 |
17 | # Xamarin Components
18 | Components/
19 |
20 | # Build results
21 | [Dd]ebug/
22 | [Dd]ebugPublic/
23 | [Rr]elease/
24 | x64/
25 | build/
26 | bld/
27 | [Bb]in/
28 | [Oo]bj/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | #NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | *_i.c
44 | *_p.c
45 | *_i.h
46 | *.ilk
47 | *.meta
48 | *.obj
49 | *.pch
50 | *.pdb
51 | *.pgc
52 | *.pgd
53 | *.rsp
54 | *.sbr
55 | *.tlb
56 | *.tli
57 | *.tlh
58 | *.tmp
59 | *.tmp_proj
60 | *.log
61 | *.vspscc
62 | *.vssscc
63 | .builds
64 | *.pidb
65 | *.svclog
66 | *.scc
67 |
68 | # Chutzpah Test files
69 | _Chutzpah*
70 |
71 | # Visual C++ cache files
72 | ipch/
73 | *.aps
74 | *.ncb
75 | *.opensdf
76 | *.sdf
77 | *.cachefile
78 |
79 | # Visual Studio profiler
80 | *.psess
81 | *.vsp
82 | *.vspx
83 |
84 | # TFS 2012 Local Workspace
85 | $tf/
86 |
87 | # Guidance Automation Toolkit
88 | *.gpState
89 |
90 | # ReSharper is a .NET coding add-in
91 | _ReSharper*/
92 | *.[Rr]e[Ss]harper
93 | *.DotSettings.user
94 |
95 | # JustCode is a .NET coding addin-in
96 | .JustCode
97 |
98 | # TeamCity is a build add-in
99 | _TeamCity*
100 |
101 | # DotCover is a Code Coverage Tool
102 | *.dotCover
103 |
104 | # NCrunch
105 | *.ncrunch*
106 | _NCrunch_*
107 | .*crunch*.local.xml
108 |
109 | # MightyMoose
110 | *.mm.*
111 | AutoTest.Net/
112 |
113 | # Web workbench (sass)
114 | .sass-cache/
115 |
116 | # Installshield output folder
117 | [Ee]xpress/
118 |
119 | # DocProject is a documentation generator add-in
120 | DocProject/buildhelp/
121 | DocProject/Help/*.HxT
122 | DocProject/Help/*.HxC
123 | DocProject/Help/*.hhc
124 | DocProject/Help/*.hhk
125 | DocProject/Help/*.hhp
126 | DocProject/Help/Html2
127 | DocProject/Help/html
128 |
129 | # Click-Once directory
130 | publish/
131 |
132 | # Publish Web Output
133 | *.[Pp]ublish.xml
134 | *.azurePubxml
135 |
136 | # NuGet Packages Directory
137 | packages/
138 | ## TODO: If the tool you use requires repositories.config uncomment the next line
139 | #!packages/repositories.config
140 |
141 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
142 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
143 | !packages/build/
144 |
145 | # Windows Azure Build Output
146 | csx/
147 | *.build.csdef
148 |
149 | # Windows Store app package directory
150 | AppPackages/
151 |
152 | # Others
153 | sql/
154 | *.Cache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | .DS_Store
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file to a newer
170 | # Visual Studio version. Backup files are not needed, because we have git ;-)
171 | _UpgradeReport_Files/
172 | Backup*/
173 | UpgradeLog*.XML
174 | UpgradeLog*.htm
175 |
176 | # SQL Server files
177 | *.mdf
178 | *.ldf
179 |
180 | # Business Intelligence projects
181 | *.rdl.data
182 | *.bim.layout
183 | *.bim_*.settings
184 |
185 | # Microsoft Fakes
186 | FakesAssemblies/
187 | project.lock.json
188 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 kamu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SvgImageSource for Xamarin.Forms
2 |
3 | This is a package to add SvgImageSource to Xamarin.Forms as new ImageSource. Thereby Xamarin.Forms.Image will become able to display a SVG image without particular modified.
4 |
5 | **Now version is pre release.**
6 | Using this library have to install more than or equal Xamarin.Forms 2.4.0.266 -pre1.
7 |
8 | ## Nuget Installation
9 |
10 | https://www.nuget.org/packages/Xamarin.Forms.Svg/
11 |
12 | ```bash
13 | Install-Package Xamain.Forms.Svg -pre
14 | ```
15 |
16 | You need to install this nuget package to PCL project and each platform project.
17 |
18 | ## Preparing to use
19 |
20 | ### iOS AppDelegate.cs.
21 |
22 | ```csharp
23 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
24 | {
25 | global::Xamarin.Forms.Forms.Init();
26 |
27 | Xamarin.Forms.Svg.iOS.SvgImage.Init(); //need to write here
28 |
29 | LoadApplication(new App(new iOSInitializer()));
30 |
31 | return base.FinishedLaunching(app, options);
32 | }
33 | ```
34 |
35 | ### Android MainActivity.cs
36 |
37 | ```csharp
38 | protected override void OnCreate(Bundle bundle)
39 | {
40 | ...
41 | global::Xamarin.Forms.Forms.Init(this, bundle);
42 |
43 | Xamarin.Forms.Svg.Droid.SvgImage.Init(); //need to write here
44 |
45 | LoadApplication(new App(new AndroidInitializer()));
46 | }
47 | ```
48 |
49 | ### PCL
50 |
51 | In case specifying svg's resource with only Xaml, following code has to be written in App.xaml.cs.
52 |
53 | ```csharp
54 | public App()
55 | {
56 | InitializeComponent();
57 |
58 | SvgImageSource.RegisterAssembly();
59 | //SvgImageSource.RegisterAssembly(typeof(typehavingresource)); in case other assembly
60 | }
61 | ```
62 |
63 | ## How to use
64 |
65 | ```csharp
66 | public ImageSource Image { get; set; }
67 |
68 | public SomeViewModel(){
69 | //specify resource's path
70 | Image = SvgImageSource.FromSvg("Resource.some.svg");
71 | //specify color
72 | Image = SvgImageSource.FromSvg("Resource.some.svg", Color.Red);
73 | //specify width height
74 | Image = SvgImageSource.FromSvg("Resourece.some.svg", 150, 50)
75 | }
76 | ```
77 |
78 | ```xml
79 |
80 | ```
81 | Resource path is found by backward match.
82 |
83 |
84 | ### only Xaml
85 |
86 | ```xml
87 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | ```
100 |
101 | ## License
102 |
103 | MIT Licensed.
104 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with your package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 | using Prism;
5 | using Prism.Ioc;
6 |
7 | namespace Sample.Droid
8 | {
9 | [Activity(Label = "Sample.Droid", Icon = "@drawable/icon",Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
10 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
11 | {
12 | protected override void OnCreate(Bundle bundle)
13 | {
14 | TabLayoutResource = Resource.Layout.Tabbar;
15 | ToolbarResource = Resource.Layout.Toolbar;
16 |
17 | base.OnCreate(bundle);
18 |
19 | global::Xamarin.Forms.Forms.Init(this, bundle);
20 |
21 | Xamarin.Forms.Svg.Droid.SvgImage.Init();
22 |
23 | LoadApplication(new App(new AndroidInitializer()));
24 | }
25 | }
26 |
27 | public class AndroidInitializer : IPlatformInitializer
28 | {
29 | public void RegisterTypes(IContainerRegistry containerRegistry)
30 | {
31 |
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using Android.App;
4 |
5 | // Information about this assembly is defined by the following attributes.
6 | // Change them to the values specific to your project.
7 |
8 | [assembly: AssemblyTitle("Sample.Droid")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("")]
13 | [assembly: AssemblyCopyright("kamusoft")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
19 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
20 |
21 | [assembly: AssemblyVersion("1.0.0")]
22 |
23 | // The following attributes are used to specify the signing key for the assembly,
24 | // if desired. See the Mono documentation for more information about signing.
25 |
26 | //[assembly: AssemblyDelaySign(false)]
27 | //[assembly: AssemblyKeyFile("")]
28 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample.Droid/Resources/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample.Droid/Resources/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample.Droid/Resources/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample.Droid/Resources/drawable/icon.png
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/layout/Tabbar.axml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/layout/Toolbar.axml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Resources/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/Sample.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {346B7F68-2775-472A-A693-EF333F750619}
8 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
9 | Library
10 | Sample.Droid
11 | Sample.Droid
12 | v8.1
13 | True
14 | Resources\Resource.designer.cs
15 | Resource
16 | Properties\AndroidManifest.xml
17 | Resources
18 | Assets
19 | true
20 |
21 |
22 | true
23 | full
24 | false
25 | bin\Debug
26 | DEBUG;
27 | prompt
28 | 4
29 | None
30 |
31 |
32 | true
33 | pdbonly
34 | true
35 | bin\Release
36 | prompt
37 | 4
38 | true
39 | false
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 | ..\packages\System.Reactive.Interfaces.3.1.1\lib\netstandard1.0\System.Reactive.Interfaces.dll
55 |
56 |
57 | ..\packages\System.Reactive.Core.3.1.1\lib\netstandard1.3\System.Reactive.Core.dll
58 |
59 |
60 | ..\packages\System.Reactive.Linq.3.1.1\lib\netstandard1.3\System.Reactive.Linq.dll
61 |
62 |
63 | ..\packages\System.Reactive.PlatformServices.3.1.1\lib\netstandard1.3\System.Reactive.PlatformServices.dll
64 |
65 |
66 | ..\packages\Prism.Core.7.0.0.396\lib\netstandard2.0\Prism.dll
67 |
68 |
69 | ..\packages\Unity.5.5.5\lib\netstandard2.0\CommonServiceLocator.dll
70 |
71 |
72 | ..\packages\Unity.5.5.5\lib\netstandard2.0\Unity.Abstractions.dll
73 |
74 |
75 | ..\packages\Unity.5.5.5\lib\netstandard2.0\Unity.Container.dll
76 |
77 |
78 | ..\packages\Unity.5.5.5\lib\netstandard2.0\Unity.ServiceLocation.dll
79 |
80 |
81 | ..\packages\Prism.Forms.7.0.0.396\lib\netstandard2.0\Prism.Forms.dll
82 |
83 |
84 | ..\packages\Prism.Unity.Forms.7.0.0.396\lib\netstandard2.0\Prism.Unity.Forms.dll
85 |
86 |
87 | ..\packages\ReactiveProperty.4.2.2\lib\MonoAndroid\ReactiveProperty.Android.dll
88 |
89 |
90 | ..\packages\ReactiveProperty.4.2.2\lib\MonoAndroid\ReactiveProperty.dll
91 |
92 |
93 | ..\packages\Xamarin.Android.Support.Annotations.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll
94 |
95 |
96 | ..\packages\Xamarin.Android.Arch.Core.Common.1.0.0\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll
97 |
98 |
99 | ..\packages\Xamarin.Android.Arch.Lifecycle.Common.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll
100 |
101 |
102 | ..\packages\Xamarin.Android.Arch.Lifecycle.Runtime.1.0.3\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll
103 |
104 |
105 | ..\packages\Xamarin.Android.Support.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll
106 |
107 |
108 | ..\packages\Xamarin.Android.Support.Core.UI.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll
109 |
110 |
111 | ..\packages\Xamarin.Android.Support.Core.Utils.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll
112 |
113 |
114 | ..\packages\Xamarin.Android.Support.Fragment.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll
115 |
116 |
117 | ..\packages\Xamarin.Android.Support.Media.Compat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll
118 |
119 |
120 | ..\packages\Xamarin.Android.Support.Transition.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll
121 |
122 |
123 | ..\packages\Xamarin.Android.Support.v4.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll
124 |
125 |
126 | ..\packages\Xamarin.Android.Support.v7.CardView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.CardView.dll
127 |
128 |
129 | ..\packages\Xamarin.Android.Support.v7.Palette.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.Palette.dll
130 |
131 |
132 | ..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll
133 |
134 |
135 | ..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll
136 |
137 |
138 | ..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll
139 |
140 |
141 | ..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll
142 |
143 |
144 | ..\packages\Xamarin.Android.Support.Design.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll
145 |
146 |
147 | ..\packages\Xamarin.Android.Support.v7.MediaRouter.27.0.2\lib\MonoAndroid81\Xamarin.Android.Support.v7.MediaRouter.dll
148 |
149 |
150 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\FormsViewGroup.dll
151 |
152 |
153 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Core.dll
154 |
155 |
156 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll
157 |
158 |
159 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Platform.dll
160 |
161 |
162 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll
163 |
164 |
165 | ..\packages\SkiaSharp.1.60.0\lib\MonoAndroid\SkiaSharp.dll
166 |
167 |
168 | ..\packages\SkiaSharp.Svg.1.60.0\lib\netstandard2.0\SkiaSharp.Extended.Svg.dll
169 |
170 |
171 | ..\packages\NGraphics.0.4.0\lib\MonoAndroid10\NGraphics.Android.dll
172 |
173 |
174 | ..\packages\NGraphics.0.4.0\lib\MonoAndroid10\NGraphics.dll
175 |
176 |
177 |
178 |
179 | {2DB58246-77D5-4190-B0A0-F125B538309B}
180 | Sample
181 |
182 |
183 | {52EEAF44-C994-4359-B6C9-C20250ACB298}
184 | SvgImageSource
185 |
186 |
187 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}
188 | SvgImageSource.Droid
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
--------------------------------------------------------------------------------
/Sample/Sample.Droid/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 | using Prism;
3 | using Prism.Ioc;
4 | using UIKit;
5 |
6 | namespace Sample.iOS
7 | {
8 | // The UIApplicationDelegate for the application. This class is responsible for launching the
9 | // User Interface of the application, as well as listening (and optionally responding) to
10 | // application events from iOS.
11 | [Register("AppDelegate")]
12 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
13 | {
14 | //
15 | // This method is invoked when the application has loaded and is ready to run. In this
16 | // method you should instantiate the window, load the UI into it and then make the window
17 | // visible.
18 | //
19 | // You have 17 seconds to return from this method, or iOS will terminate your application.
20 | //
21 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
22 | {
23 | global::Xamarin.Forms.Forms.Init();
24 | Xamarin.Forms.Svg.iOS.SvgImage.Init();
25 |
26 | LoadApplication(new App(new iOSInitializer()));
27 |
28 | return base.FinishedLaunching(app, options);
29 | }
30 | }
31 |
32 | public class iOSInitializer : IPlatformInitializer
33 | {
34 | public void RegisterTypes(IContainerRegistry containerRegistry)
35 | {
36 |
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | Sample
7 | CFBundleIdentifier
8 | kamusoft.sample
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1.0
13 | LSRequiresIPhoneOS
14 |
15 | MinimumOSVersion
16 | 9.3
17 | UIDeviceFamily
18 |
19 | 1
20 | 2
21 |
22 | UILaunchStoryboardName
23 | LaunchScreen
24 | UIRequiredDeviceCapabilities
25 |
26 | armv7
27 |
28 | UISupportedInterfaceOrientations
29 |
30 | UIInterfaceOrientationPortrait
31 | UIInterfaceOrientationLandscapeLeft
32 | UIInterfaceOrientationLandscapeRight
33 |
34 | UISupportedInterfaceOrientations~ipad
35 |
36 | UIInterfaceOrientationPortrait
37 | UIInterfaceOrientationPortraitUpsideDown
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | XSAppIconAssets
42 | Resources/Images.xcassets/AppIcons.appiconset
43 | CFBundleName
44 | Sample
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace Sample.iOS
9 | {
10 | public class Application
11 | {
12 | // This is the main entry point of the application.
13 | static void Main(string[] args)
14 | {
15 | // if you want to use a different Application Delegate class from "AppDelegate"
16 | // you can specify it here.
17 | UIApplication.Main(args, null, "AppDelegate");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Resources/Images.xcassets/AppIcons.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "size": "29x29",
5 | "scale": "1x",
6 | "idiom": "iphone"
7 | },
8 | {
9 | "size": "29x29",
10 | "scale": "2x",
11 | "idiom": "iphone"
12 | },
13 | {
14 | "size": "29x29",
15 | "scale": "3x",
16 | "idiom": "iphone"
17 | },
18 | {
19 | "size": "40x40",
20 | "scale": "2x",
21 | "idiom": "iphone"
22 | },
23 | {
24 | "size": "40x40",
25 | "scale": "3x",
26 | "idiom": "iphone"
27 | },
28 | {
29 | "size": "57x57",
30 | "scale": "1x",
31 | "idiom": "iphone"
32 | },
33 | {
34 | "size": "57x57",
35 | "scale": "2x",
36 | "idiom": "iphone"
37 | },
38 | {
39 | "size": "60x60",
40 | "scale": "2x",
41 | "idiom": "iphone"
42 | },
43 | {
44 | "size": "60x60",
45 | "scale": "3x",
46 | "idiom": "iphone"
47 | },
48 | {
49 | "size": "29x29",
50 | "scale": "1x",
51 | "idiom": "ipad"
52 | },
53 | {
54 | "size": "29x29",
55 | "scale": "2x",
56 | "idiom": "ipad"
57 | },
58 | {
59 | "size": "40x40",
60 | "scale": "1x",
61 | "idiom": "ipad"
62 | },
63 | {
64 | "size": "40x40",
65 | "scale": "2x",
66 | "idiom": "ipad"
67 | },
68 | {
69 | "size": "50x50",
70 | "scale": "1x",
71 | "idiom": "ipad"
72 | },
73 | {
74 | "size": "50x50",
75 | "scale": "2x",
76 | "idiom": "ipad"
77 | },
78 | {
79 | "size": "72x72",
80 | "scale": "1x",
81 | "idiom": "ipad"
82 | },
83 | {
84 | "size": "72x72",
85 | "scale": "2x",
86 | "idiom": "ipad"
87 | },
88 | {
89 | "size": "76x76",
90 | "scale": "1x",
91 | "idiom": "ipad"
92 | },
93 | {
94 | "size": "76x76",
95 | "scale": "2x",
96 | "idiom": "ipad"
97 | },
98 | {
99 | "size": "120x120",
100 | "scale": "1x",
101 | "idiom": "car"
102 | }
103 | ],
104 | "info": {
105 | "version": 1,
106 | "author": "xcode"
107 | }
108 | }
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Resources/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample.iOS/Resources/icon.png
--------------------------------------------------------------------------------
/Sample/Sample.iOS/Sample.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | iPhoneSimulator
7 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}
8 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
9 | Exe
10 | Sample.iOS
11 | Sample.iOS
12 | Resources
13 |
14 |
15 | true
16 | full
17 | false
18 | bin\iPhoneSimulator\Debug
19 | DEBUG;ENABLE_TEST_CLOUD;
20 | prompt
21 | 4
22 | iPhone Developer
23 | true
24 | true
25 | true
26 | true
27 | 13206
28 | None
29 | i386, x86_64
30 | HttpClientHandler
31 | x86
32 |
33 |
34 | pdbonly
35 | true
36 | bin\iPhone\Release
37 | prompt
38 | 4
39 | iPhone Developer
40 | true
41 | Entitlements.plist
42 | SdkOnly
43 | ARMv7, ARM64
44 | HttpClientHandler
45 | x86
46 |
47 |
48 | pdbonly
49 | true
50 | bin\iPhoneSimulator\Release
51 | prompt
52 | 4
53 | iPhone Developer
54 | true
55 | true
56 | None
57 | i386, x86_64
58 | HttpClientHandler
59 | x86
60 |
61 |
62 | true
63 | full
64 | false
65 | bin\iPhone\Debug
66 | DEBUG;ENABLE_TEST_CLOUD;
67 | prompt
68 | 4
69 | iPhone Developer
70 | true
71 | true
72 | true
73 | true
74 | true
75 | Entitlements.plist
76 | SdkOnly
77 | ARMv7, ARM64
78 | HttpClientHandler
79 | x86
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll
88 |
89 |
90 |
91 |
92 | ..\packages\System.Reactive.Core.3.1.1\lib\netstandard1.3\System.Reactive.Core.dll
93 |
94 |
95 | ..\packages\System.Reactive.Linq.3.1.1\lib\netstandard1.3\System.Reactive.Linq.dll
96 |
97 |
98 | ..\packages\System.Reactive.PlatformServices.3.1.1\lib\netstandard1.3\System.Reactive.PlatformServices.dll
99 |
100 |
101 | ..\packages\Prism.Core.7.0.0.396\lib\netstandard2.0\Prism.dll
102 |
103 |
104 | ..\packages\Unity.5.5.5\lib\netstandard2.0\CommonServiceLocator.dll
105 |
106 |
107 | ..\packages\Unity.5.5.5\lib\netstandard2.0\Unity.Abstractions.dll
108 |
109 |
110 | ..\packages\Unity.5.5.5\lib\netstandard2.0\Unity.Container.dll
111 |
112 |
113 | ..\packages\Unity.5.5.5\lib\netstandard2.0\Unity.ServiceLocation.dll
114 |
115 |
116 | ..\packages\Prism.Forms.7.0.0.396\lib\netstandard2.0\Prism.Forms.dll
117 |
118 |
119 | ..\packages\Prism.Unity.Forms.7.0.0.396\lib\netstandard2.0\Prism.Unity.Forms.dll
120 |
121 |
122 | ..\packages\ReactiveProperty.4.2.2\lib\Xamarin.iOS10\ReactiveProperty.dll
123 |
124 |
125 | ..\packages\ReactiveProperty.4.2.2\lib\Xamarin.iOS10\ReactiveProperty.iOS.dll
126 |
127 |
128 | ..\packages\System.Reactive.Interfaces.3.1.1\lib\netstandard1.0\System.Reactive.Interfaces.dll
129 |
130 |
131 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll
132 |
133 |
134 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll
135 |
136 |
137 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll
138 |
139 |
140 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll
141 |
142 |
143 | ..\packages\SkiaSharp.1.60.0\lib\XamariniOS\SkiaSharp.dll
144 |
145 |
146 | ..\packages\SkiaSharp.Svg.1.60.0\lib\netstandard2.0\SkiaSharp.Extended.Svg.dll
147 |
148 |
149 |
150 |
151 | {2DB58246-77D5-4190-B0A0-F125B538309B}
152 | Sample
153 |
154 |
155 | {52EEAF44-C994-4359-B6C9-C20250ACB298}
156 | SvgImageSource
157 |
158 |
159 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}
160 | SvgImageSource.iOS
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/Sample/Sample.iOS/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Sample/Sample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{2DB58246-77D5-4190-B0A0-F125B538309B}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.iOS", "Sample.iOS\Sample.iOS.csproj", "{4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Droid", "Sample.Droid\Sample.Droid.csproj", "{346B7F68-2775-472A-A693-EF333F750619}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgImageSource", "..\SvgImageSource\SvgImageSource.csproj", "{52EEAF44-C994-4359-B6C9-C20250ACB298}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgImageSource.Droid", "..\SvgImageSource.Droid\SvgImageSource.Droid.csproj", "{D594E0E9-0616-4537-86D7-4A70E59C03F1}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgImageSource.iOS", "..\SvgImageSource.iOS\SvgImageSource.iOS.csproj", "{9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
21 | Release|iPhone = Release|iPhone
22 | Release|iPhoneSimulator = Release|iPhoneSimulator
23 | Debug|iPhone = Debug|iPhone
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
31 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
32 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Release|iPhone.ActiveCfg = Release|Any CPU
33 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Release|iPhone.Build.0 = Release|Any CPU
34 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
35 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
36 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
37 | {2DB58246-77D5-4190-B0A0-F125B538309B}.Debug|iPhone.Build.0 = Debug|Any CPU
38 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
39 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
40 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Release|Any CPU.ActiveCfg = Release|iPhone
41 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Release|Any CPU.Build.0 = Release|iPhone
42 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
43 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
44 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Release|iPhone.ActiveCfg = Release|iPhone
45 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Release|iPhone.Build.0 = Release|iPhone
46 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
47 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
48 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Debug|iPhone.ActiveCfg = Debug|iPhone
49 | {4F72DBDE-0259-4476-AC2D-DA4D167E2A7A}.Debug|iPhone.Build.0 = Debug|iPhone
50 | {346B7F68-2775-472A-A693-EF333F750619}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {346B7F68-2775-472A-A693-EF333F750619}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {346B7F68-2775-472A-A693-EF333F750619}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {346B7F68-2775-472A-A693-EF333F750619}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {346B7F68-2775-472A-A693-EF333F750619}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
55 | {346B7F68-2775-472A-A693-EF333F750619}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
56 | {346B7F68-2775-472A-A693-EF333F750619}.Release|iPhone.ActiveCfg = Release|Any CPU
57 | {346B7F68-2775-472A-A693-EF333F750619}.Release|iPhone.Build.0 = Release|Any CPU
58 | {346B7F68-2775-472A-A693-EF333F750619}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
59 | {346B7F68-2775-472A-A693-EF333F750619}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
60 | {346B7F68-2775-472A-A693-EF333F750619}.Debug|iPhone.ActiveCfg = Debug|Any CPU
61 | {346B7F68-2775-472A-A693-EF333F750619}.Debug|iPhone.Build.0 = Debug|Any CPU
62 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Debug|Any CPU.Build.0 = Debug|Any CPU
64 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Release|Any CPU.ActiveCfg = Release|Any CPU
65 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Release|Any CPU.Build.0 = Release|Any CPU
66 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
67 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
68 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Release|iPhone.ActiveCfg = Release|Any CPU
69 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Release|iPhone.Build.0 = Release|Any CPU
70 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
71 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
72 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Debug|iPhone.ActiveCfg = Debug|Any CPU
73 | {52EEAF44-C994-4359-B6C9-C20250ACB298}.Debug|iPhone.Build.0 = Debug|Any CPU
74 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
76 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
77 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|Any CPU.Build.0 = Release|Any CPU
78 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
79 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
80 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|iPhone.ActiveCfg = Release|Any CPU
81 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|iPhone.Build.0 = Release|Any CPU
82 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
83 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
84 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|iPhone.ActiveCfg = Debug|Any CPU
85 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|iPhone.Build.0 = Debug|Any CPU
86 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
88 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
89 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|Any CPU.Build.0 = Release|Any CPU
90 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
91 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
92 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|iPhone.ActiveCfg = Release|Any CPU
93 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|iPhone.Build.0 = Release|Any CPU
94 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
95 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
96 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
97 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|iPhone.Build.0 = Debug|Any CPU
98 | EndGlobalSection
99 | EndGlobal
100 |
--------------------------------------------------------------------------------
/Sample/Sample/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Sample/Sample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Prism;
2 | using Prism.Ioc;
3 | using Prism.Unity;
4 | using Sample.Views;
5 | using Xamarin.Forms.Svg;
6 | using Xamarin.Forms;
7 |
8 | namespace Sample
9 | {
10 | public partial class App : PrismApplication
11 | {
12 | public App(IPlatformInitializer initializer = null) : base(initializer) { }
13 |
14 |
15 | protected override void OnInitialized()
16 | {
17 | InitializeComponent();
18 |
19 | SvgImageSource.RegisterAssembly();
20 |
21 | NavigationService.NavigateAsync("/NavigationPage/MainPage");
22 | }
23 |
24 | protected override void RegisterTypes(IContainerRegistry containerRegistry)
25 | {
26 | containerRegistry.RegisterForNavigation();
27 | containerRegistry.RegisterForNavigation();
28 | }
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/Sample/Sample/Resources/colours.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
--------------------------------------------------------------------------------
/Sample/Sample/Resources/flower.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample/Resources/flower.jpg
--------------------------------------------------------------------------------
/Sample/Sample/Resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/Sample/Sample/Resources/icon.png
--------------------------------------------------------------------------------
/Sample/Sample/Resources/ios-star.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/Sample/Sample/Sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Sample/Sample/ViewModels/MainPageViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using Prism.Mvvm;
5 | using Reactive.Bindings;
6 | using Xamarin.Forms;
7 | using Xamarin.Forms.Svg;
8 |
9 | namespace Sample.ViewModels
10 | {
11 | public class MainPageViewModel : BindableBase
12 | {
13 | public ReactiveProperty Image { get; } = new ReactiveProperty();
14 | public ReactiveProperty Image2 { get; } = new ReactiveProperty();
15 | public ReactiveProperty Image3 { get; } = new ReactiveProperty();
16 | public ReactiveProperty Image4 { get; } = new ReactiveProperty();
17 | public ReactiveProperty Image5 { get; } = new ReactiveProperty();
18 | public ReactiveProperty Image6 { get; } = new ReactiveProperty();
19 | public ReactiveProperty Image7 { get; } = new ReactiveProperty();
20 | public ReactiveProperty Image8 { get; } = new ReactiveProperty();
21 | public ReactiveProperty Image9 { get; } = new ReactiveProperty();
22 | public ReactiveProperty Image10 { get; } = new ReactiveProperty();
23 | public ReactiveCommand ChangeCommand { get; } = new ReactiveCommand();
24 | public ReactiveProperty ImagePath { get; } = new ReactiveProperty();
25 |
26 | int toggle = 0;
27 |
28 | public MainPageViewModel()
29 | {
30 | ImagePath.Value = "ios-star.svg";
31 | //var asm = this.GetType().Assembly;
32 | //var path = asm.GetManifestResourceNames()
33 | // .FirstOrDefault(x => x.EndsWith("flower.jpg", StringComparison.CurrentCultureIgnoreCase));
34 | //Func stream = () => asm.GetManifestResourceStream(path);
35 |
36 | //var svgPath = asm.GetManifestResourceNames()
37 | // .FirstOrDefault(x => x.EndsWith("tiger.svg", StringComparison.CurrentCultureIgnoreCase));
38 | //Func svgStream = () => asm.GetManifestResourceStream(svgPath);
39 |
40 | //Image = SvgImageSource.FromSvg("Resource.tiger.svg",50,50);
41 | //Image.Value = SvgImageSource.FromSvg("ios-star.svg",50,50);
42 |
43 | ChangeCommand.Subscribe(_ =>
44 | {
45 | if (toggle == 0)
46 | {
47 | ImagePath.Value = "colours.svg";
48 | toggle++;
49 | }
50 | else{
51 | ImagePath.Value = "ios-star.svg";
52 | toggle--;
53 | }
54 |
55 | //switch(toggle){
56 | // case 0:
57 | // Image.Value = SvgImageSource.FromSvg("ios-star.svg");
58 | // Image2.Value = SvgImageSource.FromSvg("tiger.svg");
59 | // Image3.Value = SvgImageSource.FromSvg("colours.svg");
60 | // Image4.Value = SvgImageSource.FromSvg("colours.svg",120,120,Color.Green);
61 | // Image5.Value = SvgImageSource.FromSvg("tiger.svg",50,50);
62 | // Image6.Value = SvgImageSource.FromSvg("ios-star.svg");
63 | // Image7.Value = SvgImageSource.FromSvg("ios-star.svg");
64 | // Image8.Value = SvgImageSource.FromSvg("ios-star.svg");
65 | // Image9.Value = SvgImageSource.FromSvg("ios-star.svg");
66 | // Image10.Value = SvgImageSource.FromSvg("ios-star.svg");
67 |
68 | // //Image.Value = SvgImageSource.FromResource("ios-star.svg");
69 | // //Image2.Value = SvgImageSource.FromResource("ios-star.svg",50,50,Color.Red);
70 | // //Image3.Value = SvgImageSource.FromStream(svgStream,100,100,Color.Blue);
71 | // //Image4.Value = SvgImageSource.FromUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg",120,120,Color.Green);
72 | // //Image5.Value = SvgImageSource.FromResource("tiger.svg",50,50);
73 | // //Image6.Value = SvgImageSource.FromResource("ios-star.svg");
74 | // //Image7.Value = SvgImageSource.FromResource("ios-star.svg");
75 | // //Image8.Value = SvgImageSource.FromResource("ios-star.svg");
76 | // //Image9.Value = SvgImageSource.FromResource("ios-star.svg");
77 | // //Image10.Value = SvgImageSource.FromResource("ios-star.svg");
78 | // //Image.Value = CachedImageSource.FromSvg("colours.svg",100,100,Color.Blue);
79 | // //Image2.Value = CachedImageSource.FromSvg("colours.svg", 50, 50, Color.Red);
80 | // break;
81 | // case 1:
82 | // Image.Value = SvgImageSource.FromSvg("ios-star.svg");
83 | // Image2.Value = SvgImageSource.FromSvg("tiger.svg");
84 | // Image3.Value = SvgImageSource.FromSvg("colours.svg");
85 | // Image4.Value = SvgImageSource.FromSvg("colours.svg", 120, 120, Color.Green);
86 | // Image5.Value = SvgImageSource.FromSvg("tiger.svg", 50, 50);
87 | // Image6.Value = SvgImageSource.FromSvg("ios-star.svg");
88 | // Image7.Value = SvgImageSource.FromSvg("ios-star.svg");
89 | // Image8.Value = SvgImageSource.FromSvg("ios-star.svg");
90 | // Image9.Value = SvgImageSource.FromSvg("ios-star.svg");
91 | // Image10.Value = SvgImageSource.FromSvg("ios-star.svg");
92 | // toggle = -1;
93 | // break;
94 | // case 2:
95 |
96 | // break;
97 | // case 3:
98 | // //https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg
99 | // //Image.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg",50,50, Color.FromHex("#80FFFF00"));
100 | // //Image2.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg", 100, 100, Color.DarkOrange);
101 | // //Image3.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg",50,50, Color.FromHex("#80FFFF00"));
102 | // //Image4.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg", 100, 100, Color.DarkOrange);
103 | // //Image5.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg",50,50, Color.FromHex("#80FFFF00"));
104 | // //Image6.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg", 100, 100, Color.DarkOrange);
105 | // //Image7.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg",50,50, Color.FromHex("#80FFFF00"));
106 | // //Image8.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg", 100, 100, Color.DarkOrange);
107 | // //Image9.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg", 50,50,Color.FromHex("#80FFFF00"));
108 | // //Image10.Value = SvgImageSource.FromSvgUri("https://dl.dropbox.com/s/d2ijcomn07tfy56/adjust.svg", 100, 100, Color.DarkOrange);
109 | // break;
110 | // case 4:
111 | // //Image.Value = SvgImageSource.FromStream(stream);
112 | // //Image2.Value = SvgImageSource.FromStream(stream);
113 | // //Image3.Value = SvgImageSource.FromStream(stream);
114 | // //Image4.Value = SvgImageSource.FromStream(stream);
115 | // //Image5.Value = SvgImageSource.FromStream(stream);
116 | // //Image6.Value = SvgImageSource.FromStream(stream);
117 | // //Image7.Value = SvgImageSource.FromStream(stream);
118 | // //Image8.Value = SvgImageSource.FromStream(stream);
119 | // //Image9.Value = SvgImageSource.FromStream(stream);
120 | // //Image10.Value = SvgImageSource.FromStream(stream);
121 | // break;
122 | // case 5:
123 | // //https://dl.dropbox.com/s/khdn0tpgjngdw4r/tiger.svg
124 | // //Image.Value = SvgImageSource.FromSvgStream(svgStream,200,200,Color.Default);
125 | // //Image2.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
126 | // //Image3.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
127 | // //Image4.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
128 | // //Image5.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
129 | // //Image6.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Default);
130 | // //Image7.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
131 | // //Image8.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
132 | // //Image9.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Green);
133 | // //Image10.Value = SvgImageSource.FromSvgStream(svgStream,50,50,Color.Red);
134 | // break;
135 | // case 6:
136 | // //Image.Value = SvgImageSource.FromNativeFile("icon.png");
137 | // //Image2.Value = SvgImageSource.FromNativeFile("icon.png");
138 | // //Image3.Value = SvgImageSource.FromNativeFile("icon.png");
139 | // //Image4.Value = SvgImageSource.FromNativeFile("icon.png");
140 | // //Image5.Value = SvgImageSource.FromNativeFile("icon.png");
141 | // //Image6.Value = SvgImageSource.FromNativeFile("icon.png");
142 | // //Image7.Value = SvgImageSource.FromNativeFile("icon.png");
143 | // //Image8.Value = SvgImageSource.FromNativeFile("icon.png");
144 | // //Image9.Value = SvgImageSource.FromNativeFile("icon.png");
145 | // //Image10.Value = SvgImageSource.FromNativeFile("icon.png");
146 | // toggle = -1;
147 | // break;
148 | //}
149 |
150 | //toggle++;
151 |
152 | });
153 |
154 | //ChangeCommand.Execute();
155 | }
156 |
157 | }
158 | }
--------------------------------------------------------------------------------
/Sample/Sample/Views/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Sample/Sample/Views/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms;
2 |
3 | namespace Sample.Views
4 | {
5 | public partial class MainPage : ContentPage
6 | {
7 | public MainPage()
8 | {
9 | InitializeComponent();
10 | }
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("SvgImageSource.Droid")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.0")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | SvgImageSource.Droid
4 |
5 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/SvgImage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.Content;
3 |
4 | namespace Xamarin.Forms.Svg.Droid
5 | {
6 | ///
7 | /// Svg image.
8 | ///
9 | public static class SvgImage
10 | {
11 | ///
12 | /// Init this instance.
13 | ///
14 | public static void Init(Context context)
15 | {
16 | Internals.Registrar.Registered.Register(typeof(SvgImageSource), typeof(SvgImageSourceHandler));
17 |
18 | using (var display = context.Resources.DisplayMetrics)
19 | {
20 | SvgImageSource.ScreenScale = display.Density;
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/SvgImageSource.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}
8 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
9 | Library
10 | Xamarin.Forms.Svg.Droid
11 | SvgImageSource.Droid
12 | v8.1
13 | Resources\Resource.designer.cs
14 | Resource
15 | Resources
16 | Assets
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug
23 | DEBUG;
24 | prompt
25 | 4
26 | None
27 | latest
28 |
29 |
30 | true
31 | pdbonly
32 | true
33 | bin\Release
34 | prompt
35 | 4
36 | bin\Release\SvgImageSource.Droid.xml
37 | true
38 | false
39 | latest
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ..\packages\Xamarin.Android.Support.Annotations.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Annotations.dll
48 |
49 |
50 | ..\packages\Xamarin.Android.Support.Compat.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Compat.dll
51 |
52 |
53 | ..\packages\Xamarin.Android.Support.Core.UI.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Core.UI.dll
54 |
55 |
56 | ..\packages\Xamarin.Android.Support.Core.Utils.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Core.Utils.dll
57 |
58 |
59 | ..\packages\Xamarin.Android.Support.Media.Compat.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Media.Compat.dll
60 |
61 |
62 | ..\packages\Xamarin.Android.Support.Fragment.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Fragment.dll
63 |
64 |
65 | ..\packages\Xamarin.Android.Support.Transition.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Transition.dll
66 |
67 |
68 | ..\packages\Xamarin.Android.Support.v4.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v4.dll
69 |
70 |
71 | ..\packages\Xamarin.Android.Support.v7.CardView.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.CardView.dll
72 |
73 |
74 | ..\packages\Xamarin.Android.Support.v7.Palette.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.Palette.dll
75 |
76 |
77 | ..\packages\Xamarin.Android.Support.v7.RecyclerView.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.dll
78 |
79 |
80 | ..\packages\Xamarin.Android.Support.Vector.Drawable.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Vector.Drawable.dll
81 |
82 |
83 | ..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.dll
84 |
85 |
86 | ..\packages\Xamarin.Android.Support.v7.AppCompat.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.AppCompat.dll
87 |
88 |
89 | ..\packages\Xamarin.Android.Support.Design.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Design.dll
90 |
91 |
92 | ..\packages\Xamarin.Android.Support.v7.MediaRouter.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.MediaRouter.dll
93 |
94 |
95 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\FormsViewGroup.dll
96 |
97 |
98 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Core.dll
99 |
100 |
101 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll
102 |
103 |
104 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Platform.dll
105 |
106 |
107 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll
108 |
109 |
110 | ..\packages\SkiaSharp.1.60.0\lib\MonoAndroid\SkiaSharp.dll
111 |
112 |
113 | ..\packages\SkiaSharp.Svg.1.60.0\lib\netstandard2.0\SkiaSharp.Extended.Svg.dll
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | {B264FB6A-2A37-46A1-8EB7-6287422360D4}
132 | SvgImageSource
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/SvgImageSourceHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Android.Content;
4 | using Android.Graphics;
5 | using Xamarin.Forms.Platform.Android;
6 |
7 | namespace Xamarin.Forms.Svg.Droid
8 | {
9 | ///
10 | /// Svg image source handler.
11 | ///
12 | public class SvgImageSourceHandler : IImageSourceHandler
13 | {
14 | ///
15 | /// Loads the image async.
16 | ///
17 | /// The image async.
18 | /// Imagesource.
19 | /// Context.
20 | /// Cancelation token.
21 | public async Task LoadImageAsync(ImageSource imagesource, Context context, CancellationToken cancelationToken = default(CancellationToken))
22 | {
23 | var svgImageSource = imagesource as SvgImageSource;
24 |
25 | using (var stream = await svgImageSource.GetImageStreamAsync(cancelationToken).ConfigureAwait(false))
26 | {
27 | if (stream == null)
28 | {
29 | return null;
30 | }
31 | return await BitmapFactory.DecodeStreamAsync(stream);
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/SvgImageSource.Droid/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SvgImageSource.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("SvgImageSource.iOS")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/SvgImageSource.iOS/SvgImage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UIKit;
3 |
4 | namespace Xamarin.Forms.Svg.iOS
5 | {
6 | ///
7 | /// Svg image.
8 | ///
9 | public static class SvgImage
10 | {
11 | ///
12 | /// Init this instance.
13 | ///
14 | public static void Init()
15 | {
16 | Internals.Registrar.Registered.Register(typeof(SvgImageSource), typeof(SvgImageSourceHandler));
17 |
18 | // gets screen's scale here. can't use MainScreen.Scale in LoadImageAsync because of not being main thread.
19 | SvgImageSource.ScreenScale = (float)UIScreen.MainScreen.Scale;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SvgImageSource.iOS/SvgImageSource.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}
8 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
9 | Library
10 | Xamarin.Forms.Svg.iOS
11 | SvgImageSource.iOS
12 | Resources
13 |
14 |
15 | true
16 | full
17 | false
18 | bin\Debug
19 | DEBUG;
20 | prompt
21 | 4
22 | iPhone Developer
23 | true
24 | true
25 | true
26 | 19634
27 | false
28 | SdkOnly
29 | HttpClientHandler
30 | latest
31 |
32 |
33 | true
34 | pdbonly
35 | true
36 | bin\Release
37 |
38 | prompt
39 | 4
40 | bin\Release\SvgImageSource.iOS.xml
41 | iPhone Developer
42 | true
43 | SdkOnly
44 | HttpClientHandler
45 | latest
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll
54 |
55 |
56 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll
57 |
58 |
59 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll
60 |
61 |
62 | ..\packages\Xamarin.Forms.3.0.0.482510\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll
63 |
64 |
65 | ..\packages\SkiaSharp.1.60.0\lib\XamariniOS\SkiaSharp.dll
66 |
67 |
68 | ..\packages\SkiaSharp.Svg.1.60.0\lib\netstandard2.0\SkiaSharp.Extended.Svg.dll
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | {B264FB6A-2A37-46A1-8EB7-6287422360D4}
82 | SvgImageSource
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/SvgImageSource.iOS/SvgImageSourceHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Foundation;
4 | using UIKit;
5 | using Xamarin.Forms.Internals;
6 | using Xamarin.Forms.Platform.iOS;
7 | using System.Collections.Generic;
8 | using System.Collections.Concurrent;
9 | using System;
10 |
11 | namespace Xamarin.Forms.Svg.iOS
12 | {
13 | ///
14 | /// Svg image source handler.
15 | ///
16 | public class SvgImageSourceHandler : IImageSourceHandler
17 | {
18 | ///
19 | /// Loads the image async.
20 | ///
21 | /// The image async.
22 | /// Imagesource.
23 | /// Cancelation token.
24 | /// Scale.
25 | public async Task LoadImageAsync(ImageSource imagesource, CancellationToken cancelationToken = default(CancellationToken), float scale = 1)
26 | {
27 | var svgImageSource = imagesource as SvgImageSource;
28 |
29 | using (var stream = await svgImageSource.GetImageStreamAsync(cancelationToken).ConfigureAwait(false))
30 | {
31 | if (stream == null)
32 | {
33 | return null;
34 | }
35 | return UIImage.LoadFromData(NSData.FromStream(stream), SvgImageSource.ScreenScale);
36 | }
37 | }
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/SvgImageSource.iOS/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SvgImageSource.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgImageSource", "SvgImageSource\SvgImageSource.csproj", "{B264FB6A-2A37-46A1-8EB7-6287422360D4}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgImageSource.iOS", "SvgImageSource.iOS\SvgImageSource.iOS.csproj", "{9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgImageSource.Droid", "SvgImageSource.Droid\SvgImageSource.Droid.csproj", "{D594E0E9-0616-4537-86D7-4A70E59C03F1}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | Release|iPhoneSimulator = Release|iPhoneSimulator
15 | EndGlobalSection
16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 | {B264FB6A-2A37-46A1-8EB7-6287422360D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {B264FB6A-2A37-46A1-8EB7-6287422360D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {B264FB6A-2A37-46A1-8EB7-6287422360D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {B264FB6A-2A37-46A1-8EB7-6287422360D4}.Release|Any CPU.Build.0 = Release|Any CPU
21 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|Any CPU.Build.0 = Release|Any CPU
25 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
26 | {9E5E35F4-F9AE-4E17-B2AE-6A068AF80B6E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
27 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {D594E0E9-0616-4537-86D7-4A70E59C03F1}.Release|Any CPU.Build.0 = Release|Any CPU
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/SvgImageSource/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 |
5 | [assembly: InternalsVisibleTo("SvgImageSource.iOS")]
6 | [assembly: InternalsVisibleTo("SvgImageSource.Droid")]
7 |
--------------------------------------------------------------------------------
/SvgImageSource/StreamWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace Xamarin.Forms.Svg
5 | {
6 | public class StreamWrapper : Stream
7 | {
8 | Stream _wrapped;
9 | IDisposable _additionalDisposable;
10 |
11 | public StreamWrapper(Stream wrapped, IDisposable additionalDisposable = default)
12 | {
13 | if (wrapped == null)
14 | throw new ArgumentNullException("wrapped");
15 |
16 | _wrapped = wrapped;
17 | _additionalDisposable = additionalDisposable;
18 | }
19 |
20 | public override bool CanRead
21 | {
22 | get { return _wrapped.CanRead; }
23 | }
24 |
25 | public override bool CanSeek
26 | {
27 | get { return _wrapped.CanSeek; }
28 | }
29 |
30 | public override bool CanWrite
31 | {
32 | get { return _wrapped.CanWrite; }
33 | }
34 |
35 | public override long Length
36 | {
37 | get { return _wrapped.Length; }
38 | }
39 |
40 | public override long Position
41 | {
42 | get { return _wrapped.Position; }
43 | set { _wrapped.Position = value; }
44 | }
45 |
46 | public override void Flush()
47 | {
48 | _wrapped.Flush();
49 | }
50 |
51 | public override int Read(byte[] buffer, int offset, int count)
52 | {
53 | return _wrapped.Read(buffer, offset, count);
54 | }
55 |
56 | public override long Seek(long offset, SeekOrigin origin)
57 | {
58 | return _wrapped.Seek(offset, origin);
59 | }
60 |
61 | public override void SetLength(long value)
62 | {
63 | _wrapped.SetLength(value);
64 | }
65 |
66 | public override void Write(byte[] buffer, int offset, int count)
67 | {
68 | _wrapped.Write(buffer, offset, count);
69 | }
70 |
71 | protected override void Dispose(bool disposing)
72 | {
73 | _wrapped.Dispose();
74 |
75 | _additionalDisposable?.Dispose();
76 | _additionalDisposable = null;
77 |
78 | base.Dispose(disposing);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/SvgImageSource/SvgImageSource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Net.Http;
5 | using System.Reflection;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using Xamarin.Forms.Internals;
9 |
10 | namespace Xamarin.Forms.Svg
11 | {
12 | ///
13 | /// Svg image source.
14 | ///
15 | public class SvgImageSource : ImageSource
16 | {
17 | internal static float ScreenScale;
18 |
19 | ///
20 | /// The stream func property.
21 | ///
22 | public static BindableProperty StreamFuncProperty =
23 | BindableProperty.Create(
24 | nameof(StreamFunc),
25 | typeof(Func>),
26 | typeof(SvgImageSource),
27 | default(Func>),
28 | defaultBindingMode: BindingMode.OneWay
29 | );
30 |
31 | ///
32 | /// Gets or sets the stream func.
33 | ///
34 | /// The stream func.
35 | public Func> StreamFunc
36 | {
37 | get { return (Func>)GetValue(StreamFuncProperty); }
38 | set { SetValue(StreamFuncProperty, value); }
39 | }
40 |
41 | ///
42 | /// The source property.
43 | ///
44 | public static BindableProperty SourceProperty =
45 | BindableProperty.Create(
46 | nameof(Source),
47 | typeof(string),
48 | typeof(SvgImageSource),
49 | default(string),
50 | defaultBindingMode: BindingMode.OneWay
51 | );
52 |
53 | ///
54 | /// Gets or sets the source.
55 | ///
56 | /// The source.
57 | public string Source
58 | {
59 | get { return (string)GetValue(SourceProperty); }
60 | set { SetValue(SourceProperty, value); }
61 | }
62 |
63 | ///
64 | /// The width property.
65 | ///
66 | public static BindableProperty WidthProperty =
67 | BindableProperty.Create(
68 | nameof(Width),
69 | typeof(double),
70 | typeof(SvgImageSource),
71 | default(double),
72 | defaultBindingMode: BindingMode.OneWay
73 | );
74 |
75 | ///
76 | /// Gets or sets the width.
77 | ///
78 | /// The width.
79 | public double Width
80 | {
81 | get { return (double)GetValue(WidthProperty); }
82 | set { SetValue(WidthProperty, value); }
83 | }
84 |
85 | ///
86 | /// The height property.
87 | ///
88 | public static BindableProperty HeightProperty =
89 | BindableProperty.Create(
90 | nameof(Height),
91 | typeof(double),
92 | typeof(SvgImageSource),
93 | default(double),
94 | defaultBindingMode: BindingMode.OneWay
95 | );
96 |
97 | ///
98 | /// Gets or sets the height.
99 | ///
100 | /// The height.
101 | public double Height
102 | {
103 | get { return (double)GetValue(HeightProperty); }
104 | set { SetValue(HeightProperty, value); }
105 | }
106 |
107 | ///
108 | /// The color property.
109 | ///
110 | public static BindableProperty ColorProperty =
111 | BindableProperty.Create(
112 | nameof(Color),
113 | typeof(Color),
114 | typeof(SvgImageSource),
115 | default(Color),
116 | defaultBindingMode: BindingMode.OneWay
117 | );
118 |
119 | ///
120 | /// Gets or sets the color.
121 | ///
122 | /// The color.
123 | public Color Color
124 | {
125 | get { return (Color)GetValue(ColorProperty); }
126 | set { SetValue(ColorProperty, value); }
127 | }
128 |
129 | static Assembly AssemblyCache;
130 |
131 | static Lazy _lazyClient = new Lazy();
132 | static HttpClient _httpClient => _lazyClient.Value;
133 |
134 | ///
135 | /// Registers the assembly.
136 | ///
137 | /// Type having resource.
138 | public static void RegisterAssembly(Type typeHavingResource = null)
139 | {
140 | if (typeHavingResource == null)
141 | {
142 | #if NETSTANDARD2_0
143 | AssemblyCache = Assembly.GetCallingAssembly();
144 | #else
145 | MethodInfo callingAssemblyMethod = typeof(Assembly).GetTypeInfo().GetDeclaredMethod("GetCallingAssembly");
146 | if (callingAssemblyMethod != null)
147 | {
148 | AssemblyCache = (Assembly)callingAssemblyMethod.Invoke(null, new object[0]);
149 | }
150 | #endif
151 | }
152 | else
153 | {
154 | AssemblyCache = typeHavingResource.GetTypeInfo().Assembly;
155 | }
156 | }
157 |
158 | ///
159 | /// Froms the svg.
160 | ///
161 | /// The svg.
162 | /// Resource.
163 | /// Width.
164 | /// Height.
165 | /// Color.
166 | [Obsolete("FromSvg is obsolete. Please use FromSvgResource instead.")]
167 | public static ImageSource FromSvg(string resource, double width, double height, Color color = default(Color))
168 | {
169 | #if NETSTANDARD2_0
170 | AssemblyCache = AssemblyCache ?? Assembly.GetCallingAssembly();
171 | #endif
172 | if (AssemblyCache == null)
173 | {
174 | return null;
175 | }
176 |
177 | return new SvgImageSource { StreamFunc = GetResourceStreamFunc(resource), Source = resource, Width = width, Height = height, Color = color };
178 | }
179 |
180 | ///
181 | /// Froms the svg.
182 | ///
183 | /// The svg.
184 | /// Resource.
185 | /// Color.
186 | [Obsolete("FromSvg is obsolete. Please use FromSvgResource instead.")]
187 | public static ImageSource FromSvg(string resource, Color color = default(Color))
188 | {
189 | #if NETSTANDARD2_0
190 | AssemblyCache = AssemblyCache ?? Assembly.GetCallingAssembly();
191 | #endif
192 | if (AssemblyCache == null)
193 | {
194 | return null;
195 | }
196 |
197 | return new SvgImageSource { StreamFunc = GetResourceStreamFunc(resource), Source = resource, Color = color };
198 | }
199 |
200 |
201 | ///
202 | /// Froms the svg.
203 | ///
204 | /// The svg.
205 | /// Resource.
206 | /// Width.
207 | /// Height.
208 | /// Color.
209 | public static ImageSource FromSvgResource(string resource, double width, double height, Color color = default(Color))
210 | {
211 | #if NETSTANDARD2_0
212 | AssemblyCache = AssemblyCache ?? Assembly.GetCallingAssembly();
213 | #endif
214 | if (AssemblyCache == null)
215 | {
216 | return null;
217 | }
218 |
219 | return new SvgImageSource { StreamFunc = GetResourceStreamFunc(resource), Source = resource, Width = width, Height = height, Color = color };
220 | }
221 |
222 | ///
223 | /// Froms the svg.
224 | ///
225 | /// The svg.
226 | /// Resource.
227 | /// Color.
228 | public static ImageSource FromSvgResource(string resource, Color color = default(Color))
229 | {
230 | #if NETSTANDARD2_0
231 | AssemblyCache = AssemblyCache ?? Assembly.GetCallingAssembly();
232 | #endif
233 | if (AssemblyCache == null)
234 | {
235 | return null;
236 | }
237 |
238 | return new SvgImageSource { StreamFunc = GetResourceStreamFunc(resource), Source = resource, Color = color };
239 |
240 | }
241 |
242 | ///
243 | /// Froms the svg URI.
244 | ///
245 | /// The svg URI.
246 | /// URI.
247 | /// Width.
248 | /// Height.
249 | /// Color.
250 | public static ImageSource FromSvgUri(string uri, double width, double height, Color color)
251 | {
252 | return new SvgImageSource { StreamFunc = GethttpStreamFunc(uri), Source = uri, Width = width, Height = height, Color = color };
253 | }
254 |
255 | ///
256 | /// Froms the svg stream.
257 | ///
258 | /// The svg stream.
259 | /// Stream func.
260 | /// Width.
261 | /// Height.
262 | /// Color.
263 | /// Key.
264 | public static ImageSource FromSvgStream(Func streamFunc, double width, double height, Color color, string key = null)
265 | {
266 | key = key ?? streamFunc.GetHashCode().ToString();
267 | return new SvgImageSource { StreamFunc = token => Task.Run(streamFunc), Width = width, Height = height, Color = color };
268 | }
269 |
270 | static Func> GetResourceStreamFunc(string resource)
271 | {
272 | var realResource = GetRealResource(resource);
273 | if (realResource == null)
274 | {
275 | return null;
276 | }
277 | return token => Task.Run(() => AssemblyCache.GetManifestResourceStream(realResource), token);
278 |
279 | }
280 |
281 | static Func> GethttpStreamFunc(string uri)
282 | {
283 | return token => Task.Run(async () =>
284 | {
285 | var response = await _httpClient.GetAsync(uri, token);
286 | if (!response.IsSuccessStatusCode)
287 | {
288 | Log.Warning("HTTP Request", $"Could not retrieve {uri}, status code {response.StatusCode}");
289 | return null;
290 | }
291 | // the HttpResponseMessage needs to be disposed of after the calling code is done with the stream
292 | // otherwise the stream may get disposed before the caller can use it
293 | return new StreamWrapper(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), response) as Stream;
294 | }, token);
295 | }
296 |
297 | static string GetRealResource(string resource)
298 | {
299 | return AssemblyCache.GetManifestResourceNames()
300 | .FirstOrDefault(x => x.EndsWith(resource, StringComparison.CurrentCultureIgnoreCase));
301 | }
302 |
303 | ///
304 | /// Ons the property changed.
305 | ///
306 | /// Property name.
307 | protected override void OnPropertyChanged(string propertyName)
308 | {
309 | if (propertyName == StreamFuncProperty.PropertyName)
310 | {
311 | OnSourceChanged();
312 | }
313 | else if(propertyName == SourceProperty.PropertyName)
314 | {
315 | if(string.IsNullOrEmpty(Source)){
316 | return;
317 | }
318 |
319 | if(Uri.TryCreate(Source,UriKind.Absolute,out var uri)){
320 | StreamFunc = GethttpStreamFunc(Source);
321 | }
322 | else{
323 | StreamFunc = GetResourceStreamFunc(Source);
324 | }
325 |
326 | //OnSourceChanged();
327 | }
328 | base.OnPropertyChanged(propertyName);
329 | }
330 |
331 | internal virtual async Task GetImageStreamAsync(CancellationToken userToken)
332 | {
333 |
334 | OnLoadingStarted();
335 | userToken.Register(CancellationTokenSource.Cancel);
336 |
337 | Stream imageStream = null;
338 | try
339 | {
340 | using (var stream = await StreamFunc(CancellationTokenSource.Token).ConfigureAwait(false))
341 | {
342 | if (stream == null)
343 | {
344 | OnLoadingCompleted(false);
345 | return null;
346 | }
347 | imageStream = await SvgUtility.CreateImage(stream, Width, Height, Color);
348 | }
349 |
350 | OnLoadingCompleted(false);
351 | }
352 | catch (OperationCanceledException oex)
353 | {
354 | OnLoadingCompleted(true);
355 | System.Diagnostics.Debug.WriteLine($"cancel exception {oex.Message}");
356 | throw;
357 | }
358 |
359 | return imageStream;
360 | }
361 | }
362 | }
363 |
--------------------------------------------------------------------------------
/SvgImageSource/SvgImageSource.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | Xamarin.Forms.Svg
6 |
7 |
8 |
9 | true
10 | portable
11 | bin\Release\netstandard2.0\SvgImageSource.xml
12 | latest
13 |
14 |
15 | latest
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | AzurePipelines.nuspec
30 |
31 |
32 |
--------------------------------------------------------------------------------
/SvgImageSource/SvgUtility.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using SkiaSharp;
5 |
6 | namespace Xamarin.Forms.Svg
7 | {
8 | ///
9 | /// Svg utility.
10 | ///
11 | public static class SvgUtility
12 | {
13 | ///
14 | /// Creates the image.
15 | ///
16 | /// The image.
17 | /// Stream.
18 | /// Width.
19 | /// Height.
20 | /// Color.
21 | public static Task CreateImage(Stream stream, double width, double height, Color color)
22 | {
23 | var screenScale = SvgImageSource.ScreenScale;
24 |
25 | var svg = new SkiaSharp.Extended.Svg.SKSvg();
26 | svg.Load(stream);
27 |
28 | var size = CalcSize(svg.Picture.CullRect.Size, width, height);
29 | var scale = CalcScale(svg.Picture.CullRect.Size, size, screenScale);
30 | var matrix = SKMatrix.MakeScale(scale.Item1, scale.Item2);
31 |
32 | using (var bitmap = new SKBitmap((int)(size.Width * screenScale), (int)(size.Height * screenScale)))
33 | using (var canvas = new SKCanvas(bitmap))
34 | using (var paint = new SKPaint())
35 | {
36 | if (!color.IsDefault)
37 | {
38 | paint.ColorFilter = SKColorFilter.CreateBlendMode(ToSKColor(color), SKBlendMode.SrcIn);
39 | }
40 |
41 | canvas.Clear(SKColors.Transparent); // very very important!
42 | canvas.DrawPicture(svg.Picture, ref matrix, paint);
43 |
44 | using (var image = SKImage.FromBitmap(bitmap))
45 | using (var encoded = image.Encode())
46 | {
47 | var imageStream = new MemoryStream();
48 | encoded.SaveTo(imageStream);
49 | imageStream.Position = 0;
50 | return Task.FromResult(imageStream as Stream);
51 | }
52 | }
53 | }
54 |
55 | ///
56 | /// Tos the SKC olor.
57 | ///
58 | /// The SKC olor.
59 | /// Color.
60 | public static SKColor ToSKColor(Color color)
61 | {
62 | return new SKColor((byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255), (byte)(color.A * 255));
63 | }
64 |
65 | ///
66 | /// Calculates the size.
67 | ///
68 | /// The size.
69 | /// Size.
70 | /// Width.
71 | /// Height.
72 | public static SKSize CalcSize(SkiaSharp.SKSize size, double width, double height)
73 | {
74 | double w;
75 | double h;
76 | if (width <= 0 && height <= 0)
77 | {
78 | return size;
79 | }
80 | else if (width <= 0)
81 | {
82 | h = height;
83 | w = height * (size.Width / size.Height);
84 | }
85 | else if (height <= 0)
86 | {
87 | w = width;
88 | h = width * (size.Height / size.Width);
89 | }
90 | else
91 | {
92 | w = width;
93 | h = height;
94 | }
95 |
96 | return new SkiaSharp.SKSize((float)w, (float)h);
97 | }
98 |
99 | ///
100 | /// Calculates the scale.
101 | ///
102 | /// The scale.
103 | /// Original size.
104 | /// Scaled size.
105 | /// Screen scale.
106 | public static Tuple CalcScale(SkiaSharp.SKSize originalSize, SkiaSharp.SKSize scaledSize, float screenScale)
107 | {
108 | var sx = scaledSize.Width * screenScale / originalSize.Width;
109 | var sy = scaledSize.Height * screenScale / originalSize.Height;
110 |
111 | return new Tuple((float)sx, (float)sy);
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/nuget/AzurePipelines.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Xamarin.Forms.Svg
5 | 1.0.0
6 | SvgImageSource for Xamarin.Forms
7 | kamu
8 | kamu
9 | https://github.com/muak/SvgImageSource
10 | https://github.com/muak/SvgImageSource/blob/master/LICENSE.txt
11 | false
12 | This is a package that adds SvgImageSource to Xamarin.Forms as new ImageSource. Thereby Xamarin.Forms.Image will can be displayed a SVG image without modified.
13 |
14 |
15 | ## New Features
16 |
17 | * .NETStandard2.0 Supported
18 | * Svg Uri Supported
19 | * Svg Stream Supported
20 |
21 | ## Breaking changes
22 |
23 | * Renderering library is changed from NGraphics to SkiaSharp.
24 | * Resource property name is changed to "Source" in SvgImageSource.
25 | * Init method 1st argument must be set Context on Android.
26 |
27 | ## Bug fixes
28 |
29 | * Fixed SVG from URI not loading #5.
30 |
31 |
32 | Xamarin.Forms TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop
33 | en-US
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/nuget/SvgImageSource_mac.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Xamarin.Forms.Svg
5 | 1.0.0-pre4
6 | SvgImageSource for Xamarin.Forms
7 | kamu
8 | kamu
9 | https://github.com/muak/SvgImageSource
10 | https://github.com/muak/SvgImageSource/blob/master/LICENSE.txt
11 | false
12 | This is a package that adds SvgImageSource to Xamarin.Forms as new ImageSource. Thereby Xamarin.Forms.Image will can be displayed a SVG image without modified.
13 |
14 |
15 | ## New Features
16 |
17 | * .NETStandard2.0 Supported
18 | * Svg Uri Supported
19 | * Svg Stream Supported
20 |
21 | ## Breaking changes
22 |
23 | * Renderering library is changed from NGraphics to SkiaSharp.
24 | * Resource property name is changed to "Source" in SvgImageSource.
25 | * Init method 1st argument must be set Context on Android.
26 |
27 | Xamarin.Forms SVG Image ImageSource
28 | en-US
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/nuget/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muak/SvgImageSource/922a0dbbbf0b175d6a5ee5766d2891ebb5b93fdf/nuget/nuget.exe
--------------------------------------------------------------------------------
/nuget/pack.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | mono --runtime=v4.0 nuget.exe pack SvgImageSource_mac.nuspec -symbols -Prop Configuration=Release -verbosity detailed -basepath ./ -OutputDirectory ~/projects/nuget
3 |
--------------------------------------------------------------------------------