diff --git a/README.md b/README.md index e2a3807..50f85c1 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,10 @@ Tagged: **`[XAMARIN]`** **`[SVGKit]`** **`[Xamarin.iOS]`** **`[iOS]`** ###Building `SushiHangover.SVGKit.Binding` -#####`xbuild` or `msbuild` based: +#####`msbuild` based: - xbuild /p:SolutionDir=./ /target:Clean /p:Configuration=Release SushiHangover.SVGKit/SushiHangover.SVGKit.csproj - xbuild /p:SolutionDir=./ /target:Build /p:Configuration=Release SushiHangover.SVGKit/SushiHangover.SVGKit.csproj + msbuild /p:SolutionDir=./ /target:Clean /p:Configuration=Release SushiHangover.SVGKit/SushiHangover.SVGKit.csproj + msbuild /p:SolutionDir=./ /target:Build /p:Configuration=Release SushiHangover.SVGKit/SushiHangover.SVGKit.csproj #####Building `Target:Release` also builds the Nuget package: diff --git a/SVGKit b/SVGKit index 29b55f9..8949b61 160000 --- a/SVGKit +++ b/SVGKit @@ -1 +1 @@ -Subproject commit 29b55f9846b11d27fb22cf0ad164a4025de12c34 +Subproject commit 8949b61e7ae25529678e34a548288cc838061674 diff --git a/SVGKit.SampleApp/ViewController.cs b/SVGKit.SampleApp/ViewController.cs index a1e8e98..a413c94 100644 --- a/SVGKit.SampleApp/ViewController.cs +++ b/SVGKit.SampleApp/ViewController.cs @@ -1,39 +1,88 @@ using System; using UIKit; using SushiHangover.SVGKit; +using CoreAnimation; +using CoreGraphics; +using CoreFoundation; +using Foundation; namespace SVGKit.SampleApp { - public partial class ViewController : UIViewController - { - protected ViewController(IntPtr handle) : base(handle) - { - // Note: this .ctor should not contain any initialization logic. - } - - public override void ViewDidLoad() - { - base.ViewDidLoad(); - - var image = new SVGKImage("Media/Sushi.svg"); - var imageView = new SVGKFastImageView(image); - imageView.Frame = View.Frame; - View.Add(imageView); - } - - public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations() - { - return UIInterfaceOrientationMask.LandscapeLeft; - } - - public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation() - { - return UIInterfaceOrientation.LandscapeLeft; - } - - public override bool ShouldAutorotate() - { - return false; - } - } + public static class Extension + { + public static UIColor Inverse(this UIColor color) + { + try + { + var cgcolor = color.CGColor; + if (cgcolor.NumberOfComponents == 1) + return color; + + var comps = cgcolor.Components; + var newComps = new nfloat[comps.Length]; + var i = comps.Length - 1; + newComps[i] = comps[i]; + while (i-- > -0) + { + newComps[i] = 1 - comps[i]; + } + using (var newCGColor = new CGColor(cgcolor.ColorSpace, newComps)) + { + var newUIColor = UIColor.FromCGColor(newCGColor); + return newUIColor; + } + } + catch + { + return UIColor.Black; + } + } + } + + public partial class ViewController : UIViewController + { + NSTimer timer; + + protected ViewController(IntPtr handle) : base(handle) + { + // Note: this .ctor should not contain any initialization logic. + } + + public override void ViewDidLoad() + { + base.ViewDidLoad(); + + void RecurseLayers(CALayer[] layers) + { + foreach (var layer in layers) + { + if (layer is CAShapeLayer && (layer as CAShapeLayer).FillColor != null) + (layer as CAShapeLayer).FillColor = UIColor.FromCGColor((layer as CAShapeLayer).FillColor).Inverse().CGColor; + if (layer.Sublayers != null) + RecurseLayers(layer.Sublayers); + } + } + //var imageView = new SVGKLayeredImageView(new SVGKImage("Media/Sushi.svg")); + var imageView = new SVGKFastImageView(new SVGKImage("Media/Sushi.svg")); + imageView.Frame = View.Bounds; + View.Add(imageView); + //timer = NSTimer.CreateRepeatingScheduledTimer(2, (_) => InvokeOnMainThread(() => RecurseLayers(imageView.Layer.Sublayers))); + } + + + public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations() + { + return UIInterfaceOrientationMask.LandscapeLeft; + } + + public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation() + { + return UIInterfaceOrientation.LandscapeLeft; + } + + public override bool ShouldAutorotate() + { + return false; + } + } } diff --git a/SushiHangover.SVGKit/Additions/SVGKLayeredImageView.cs b/SushiHangover.SVGKit/Additions/SVGKLayeredImageView.cs new file mode 100644 index 0000000..e2aec78 --- /dev/null +++ b/SushiHangover.SVGKit/Additions/SVGKLayeredImageView.cs @@ -0,0 +1,59 @@ +using System; +using System; +using System.Drawing; +using System.Diagnostics; +using System.ComponentModel; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using UIKit; +using GLKit; +using Metal; +using MapKit; +using Photos; +using ModelIO; +using SceneKit; +using Contacts; +using Security; +using Messages; +using AudioUnit; +using CoreVideo; +using CoreMedia; +using QuickLook; +using CoreImage; +using SpriteKit; +using Foundation; +using CoreMotion; +using ObjCRuntime; +using AddressBook; +using MediaPlayer; +using GameplayKit; +using CoreGraphics; +using CoreLocation; +using AVFoundation; +using NewsstandKit; +using FileProvider; +using CoreAnimation; +using CoreFoundation; + +namespace SushiHangover.SVGKit +{ + public unsafe partial class SVGKLayeredImageView : SVGKImageView + { + [Export("initWithSVGKImage:")] + public SVGKLayeredImageView(SVGKImage im) : base (im) + { + if (im == null) + throw new ArgumentNullException("im"); + IsDirectBinding = GetType().Assembly == global::ApiDefinitions.Messaging.this_assembly; + if (IsDirectBinding) + { + InitializeHandle(global::ApiDefinitions.Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, Selector.GetHandle("initWithSVGKImage:"), im.Handle), "initWithSVGKImage:"); + } + else + { + InitializeHandle(global::ApiDefinitions.Messaging.IntPtr_objc_msgSendSuper_IntPtr(this.SuperHandle, Selector.GetHandle("initWithSVGKImage:"), im.Handle), "initWithSVGKImage:"); + } + } + } +} diff --git a/SushiHangover.SVGKit/ApiDefinitions.cs b/SushiHangover.SVGKit/ApiDefinitions.cs index 1fc70ce..7475ac1 100644 --- a/SushiHangover.SVGKit/ApiDefinitions.cs +++ b/SushiHangover.SVGKit/ApiDefinitions.cs @@ -1056,7 +1056,7 @@ interface IDocumentStyle } // @protocol DocumentCSS - [Protocol, Model] + [Protocol] interface IDocumentCSS : IDocumentStyle { // @required -(CSSStyleDeclaration *)getOverrideStyle:(Element *)element pseudoElt:(NSString *)pseudoElt; @@ -1096,7 +1096,7 @@ interface MediaList interface NSCharacterSet_SVGKExtensions { // +(NSCharacterSet *)SVGWhitespaceCharacterSet; - [Static] + //[Static] [Export("SVGWhitespaceCharacterSet")] //[Verify (MethodToProperty)] NSCharacterSet SVGWhitespaceCharacterSet(); @@ -2478,7 +2478,7 @@ interface SVGKPattern // @interface SVGKLayeredImageView : SVGKImageView [BaseType (typeof(SVGKImageView))] - interface SVGKLayeredImageView + interface SVGKLayeredImageView : SVGKImageView { } diff --git a/SushiHangover.SVGKit/SVGKit.nuspec b/SushiHangover.SVGKit/SVGKit.nuspec index b723ac8..27d3e3c 100644 --- a/SushiHangover.SVGKit/SVGKit.nuspec +++ b/SushiHangover.SVGKit/SVGKit.nuspec @@ -2,13 +2,13 @@ SushiHangover.SVGKit.Binding - 1.0.3 + 1.0.4 This is a Xamarin.iOS binding project for SVGKit v2.x SushiHangover.SVGKit.Binding en-US - 2016 - SushiHangover/RobertN + 2016/2017 - SushiHangover/RobertN SushiHangover https://github.com/sushihangover/SVGKit.Binding https://raw.githubusercontent.com/sushihangover/SVGKit.Binding/master/Media/icon.png diff --git a/SushiHangover.SVGKit/SushiHangover.SVGKit.csproj b/SushiHangover.SVGKit/SushiHangover.SVGKit.csproj index 997e1fd..438202c 100644 --- a/SushiHangover.SVGKit/SushiHangover.SVGKit.csproj +++ b/SushiHangover.SVGKit/SushiHangover.SVGKit.csproj @@ -36,6 +36,7 @@ + @@ -45,7 +46,7 @@ - + Static True CocoaLumberjack CoreText CoreImage QuartzCore CoreGraphics @@ -59,6 +60,9 @@ + + + \ No newline at end of file