예제 #1
0
        public void SymbolExists()
        {
            var failed_api = new HashSet <string> ();

            Errors = 0;
            int c = 0, n = 0;

            foreach (MethodInfo mi in pinvokeQuery)
            {
                if (LogProgress)
                {
                    Console.WriteLine("{0}. {1}", c++, mi);
                }

                var dllimport = mi.GetCustomAttribute <DllImportAttribute> ();

                string libname = dllimport.Value;
                switch (libname)
                {
                case "__Internal":
                    continue;

                case "System.Native":
                case "System.Security.Cryptography.Native.Apple":
                case "System.Net.Security.Native":
                    if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None)
                    {
                        continue;
                    }
#if __IOS__
                    libname = MonoNativeConfig.GetPInvokeLibraryName(MonoNativeFlavor.Compat, MonoNativeConfig.LinkMode);
#else
                    libname = null;
#endif
                    break;
                }

                if (SkipLibrary(libname))
                {
                    continue;
                }

                string path = FindLibrary(libname, requiresFullPath: true);

                string name = dllimport.EntryPoint ?? mi.Name;
                if (Skip(name))
                {
                    continue;
                }

                IntPtr lib = Dlfcn.dlopen(path, 0);
                if (Dlfcn.GetIndirect(lib, name) == IntPtr.Zero && !failed_api.Contains(name))
                {
                    ReportError("Could not find the field '{0}' in {1}", name, path);
                    failed_api.Add(name);
                }
                Dlfcn.dlclose(lib);
                n++;
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} functions validated: {2}", Errors, n, string.Join(", ", failed_api));
        }
예제 #2
0
        // we just want to confirm the symbol exists so `dlsym` can be disabled
        protected void Check(Assembly a)
        {
            Errors = 0;
            ErrorData.Clear();
            int n = 0;

            foreach (var t in a.GetTypes())
            {
                foreach (var m in t.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
                {
                    if ((m.Attributes & MethodAttributes.PinvokeImpl) == 0)
                    {
                        continue;
                    }

                    var dllimport = m.GetCustomAttribute <DllImportAttribute> ();

                    string name = dllimport.EntryPoint ?? m.Name;
                    switch (name)
                    {
                    // known not to be present in ARM64
                    case "objc_msgSend_stret":
                    case "objc_msgSendSuper_stret":
                        // the linker normally removes them (IntPtr.Size optimization)
                        continue;
                    }

                    string path = dllimport.Value;
                    switch (path)
                    {
                    case "__Internal":
                        // load from executable
                        path = null;
                        break;

                    case "libc":
                        // we still have some rogue/not-fully-qualified DllImport
                        path = "/usr/lib/libSystem.dylib";
                        break;

                    case "System.Native":
                    case "System.Security.Cryptography.Native.Apple":
                    case "System.Net.Security.Native":
                        if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None)
                        {
                            continue;
                        }
#if __IOS__
                        path = MonoNativeConfig.GetPInvokeLibraryName(MonoNativeFlavor.Compat, MonoNativeConfig.LinkMode);
#else
                        path = null;
#endif
                        break;
                    }

                    var lib = Dlfcn.dlopen(path, 0);
                    var h   = Dlfcn.dlsym(lib, name);
                    if (h == IntPtr.Zero)
                    {
                        ReportError("Could not find the symbol '{0}' in {1}", name, path);
                    }
                    Dlfcn.dlclose(lib);
                    n++;
                }
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} symbol lookups{2}", Errors, n, Errors == 0 ? string.Empty : ":\n" + ErrorData.ToString() + "\n");
        }
예제 #3
0
 static void Main(string[] args)
 => Xamarin.iOS.HotRestart.Application.Run(args, (string frameworkPath) => Dlfcn.dlopen(frameworkPath, 0), () => TerminateApplication());
예제 #4
0
 static FontTypefaceHandler()
 {
     AppKit_libraryHandler = Dlfcn.dlopen("/System/Library/Frameworks/AppKit.framework/AppKit", 0);
 }
예제 #5
0
 public static IntPtr LoadLibrary(string libname)
 {
     return(Dlfcn.dlopen(libname, 0));
 }
using System;
using System.Collections.Generic;
using Foundation;
using ObjCRuntime;
using Xamarin.Forms;
using ToolbarCustomFont.iOS;
using Xamarin.Forms.Platform.iOS;
using UIKit;

[assembly: ExportRenderer(typeof (NavigationPage), typeof (CustomFontNavigationPageRenderer))]
namespace ToolbarCustomFont.iOS
{
    // https://blog.xamarin.com/custom-fonts-in-ios/
   public class CustomFontNavigationPageRenderer : NavigationRenderer
 {
      public CustomFontNavigationPageRenderer()
      {
      }

     const string customFontName = "fontawesome";
       nfloat customFontSize = 16;

       public override void ViewWillAppear(bool animated)
     {
          base.ViewWillAppear(animated);

            if (this.NavigationBar == null) return;

           SetNavBarStyle();
//            SetNavBarTitle();
          SetNavBarItems();
      }

     public override void ViewDidAppear(bool animated)
      {
          base.ViewDidAppear(animated);
          if (this.NavigationBar == null) return;
            var navPage = this.Element;
            if (navPage == null) return;
       }

     private void SetNavBarStyle()
      {
          NavigationBar.ShadowImage = new UIImage();
         NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
         UINavigationBar.Appearance.ShadowImage = new UIImage();
            UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
        }

     private void SetNavBarItems()
      {
          var navPage = this.Element as NavigationPage;

         if (navPage == null) return;

          var textAttributes = new UITextAttributes()
            {
              Font = UIFont.FromName(customFontName, customFontSize)
         } ;

           var textAttributesHighlighted = new UITextAttributes()
         {
              TextColor = Color.Black.ToUIColor(),
               Font = UIFont.FromName(customFontName, customFontSize)
         } ;
            
           var theFont = UIFont.FromName(customFontName, customFontSize);
         var nsDictSegmentFont = GetFontNSDictionaryReversed(theFont);
            var segmentTextAttributes = new MyUITextAttributes(nsDictSegmentFont);

            UISegmentedControl.Appearance.SetTitleTextAttributes(segmentTextAttributes, UIControlState.Normal);
            UISegmentedControl.Appearance.SetTitleTextAttributes(segmentTextAttributes, UIControlState.Selected);

            UIBarButtonItem.Appearance.SetTitleTextAttributes(textAttributes,
             UIControlState.Normal);
            UIBarButtonItem.Appearance.SetTitleTextAttributes(textAttributesHighlighted,
               UIControlState.Highlighted);
       }

        // assembles a reversed dictionary to workaround bug in iOS
     public NSDictionary GetFontNSDictionaryReversed(UIFont font)
       {
            var handle = Dlfcn.dlopen("/System/Library/Frameworks/UIKit.framework/UIKit", 0);
            var nsfontattributename = "NSFontAttributeName";
            //var nsfontattributename = "UITextAttributeFont";  // deprecated
            NSString UITextAttributeFont = Dlfcn.GetStringConstant(handle, nsfontattributename);

           var valuekeys = new List<NSObject>();
            if (font != null)
            {
                valuekeys.Add(font);
                valuekeys.Add(UITextAttributeFont);
            }
            return new NSDictionary(valuekeys[0], valuekeys[0]);
        }

//     private void SetNavBarTitle()
//        {
//            var navPage = this.Element as NavigationPage;
//
//         if (navPage == null) return;
//
//          this.NavigationBar.TitleTextAttributes = new UIStringAttributes
//          {
//                Font = UIFont.FromName(customFontName, customFontSize),
//          } ;
//      }
  }

    public class MyUITextAttributes : UITextAttributes
    {
        private NSDictionary myDictionary;

        public MyUITextAttributes(NSDictionary newDictionary)
        {
            this.myDictionary = newDictionary;
        }

        public new NSDictionary Dictionary
        {
            get
            {
                return ToDictionary();
            }
        }

        public new NSDictionary ToDictionary()
        {
            return myDictionary;
        }

    }
}
예제 #7
0
        static UTType()
        {
            var handle = Dlfcn.dlopen(Constants.MobileCoreServicesLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }

            try {
                ExportedTypeDeclarationsKey = Dlfcn.GetStringConstant(handle, "kUTExportedTypeDeclarationsKey");
                ImportedTypeDeclarationsKey = Dlfcn.GetStringConstant(handle, "kUTImportedTypeDeclarationsKey");
                IdentifierKey       = Dlfcn.GetStringConstant(handle, "kUTTypeIdentifierKey");
                TagSpecificationKey = Dlfcn.GetStringConstant(handle, "kUTTypeTagSpecificationKey");
                ConformsToKey       = Dlfcn.GetStringConstant(handle, "kUTTypeConformsToKey");
                DescriptionKey      = Dlfcn.GetStringConstant(handle, "kUTTypeDescriptionKey");
                IconFileKey         = Dlfcn.GetStringConstant(handle, "kUTTypeIconFileKey");
                ReferenceURLKey     = Dlfcn.GetStringConstant(handle, "kUTTypeReferenceURLKey");
                VersionKey          = Dlfcn.GetStringConstant(handle, "kUTTypeVersionKey");

                TagClassFilenameExtension = Dlfcn.GetStringConstant(handle, "kUTTagClassFilenameExtension");
                TagClassMIMEType          = Dlfcn.GetStringConstant(handle, "kUTTagClassMIMEType");
#if MONOMAC
                TagClassNSPboardType = Dlfcn.GetStringConstant(handle, "kUTTagClassNSPboardType");
                TagClassOSType       = Dlfcn.GetStringConstant(handle, "kUTTagClassOSType");
#endif
                Item             = Dlfcn.GetStringConstant(handle, "kUTTypeItem");
                Content          = Dlfcn.GetStringConstant(handle, "kUTTypeContent");
                CompositeContent = Dlfcn.GetStringConstant(handle, "kUTTypeCompositeContent");
                Application      = Dlfcn.GetStringConstant(handle, "kUTTypeApplication");
                Message          = Dlfcn.GetStringConstant(handle, "kUTTypeMessage");
                Contact          = Dlfcn.GetStringConstant(handle, "kUTTypeContact");
                Archive          = Dlfcn.GetStringConstant(handle, "kUTTypeArchive");
                DiskImage        = Dlfcn.GetStringConstant(handle, "kUTTypeDiskImage");

                Data        = Dlfcn.GetStringConstant(handle, "kUTTypeData");
                Directory   = Dlfcn.GetStringConstant(handle, "kUTTypeDirectory");
                Resolvable  = Dlfcn.GetStringConstant(handle, "kUTTypeResolvable");
                SymLink     = Dlfcn.GetStringConstant(handle, "kUTTypeSymLink");
                MountPoint  = Dlfcn.GetStringConstant(handle, "kUTTypeMountPoint");
                AliasFile   = Dlfcn.GetStringConstant(handle, "kUTTypeAliasFile");
                AliasRecord = Dlfcn.GetStringConstant(handle, "kUTTypeAliasRecord");
                URL         = Dlfcn.GetStringConstant(handle, "kUTTypeURL");
                FileURL     = Dlfcn.GetStringConstant(handle, "kUTTypeFileURL");

                Text                   = Dlfcn.GetStringConstant(handle, "kUTTypeText");
                PlainText              = Dlfcn.GetStringConstant(handle, "kUTTypePlainText");
                UTF8PlainText          = Dlfcn.GetStringConstant(handle, "kUTTypeUTF8PlainText");
                UTF16ExternalPlainText = Dlfcn.GetStringConstant(handle, "kUTTypeUTF16ExternalPlainText");
                UTF16PlainText         = Dlfcn.GetStringConstant(handle, "kUTTypeUTF16PlainText");
                RTF                      = Dlfcn.GetStringConstant(handle, "kUTTypeRTF");
                HTML                     = Dlfcn.GetStringConstant(handle, "kUTTypeHTML");
                XML                      = Dlfcn.GetStringConstant(handle, "kUTTypeXML");
                SourceCode               = Dlfcn.GetStringConstant(handle, "kUTTypeSourceCode");
                CSource                  = Dlfcn.GetStringConstant(handle, "kUTTypeCSource");
                ObjectiveCSource         = Dlfcn.GetStringConstant(handle, "kUTTypeObjectiveCSource");
                CPlusPlusSource          = Dlfcn.GetStringConstant(handle, "kUTTypeCPlusPlusSource");
                ObjectiveCPlusPlusSource = Dlfcn.GetStringConstant(handle, "kUTTypeObjectiveCPlusPlusSource");
                CHeader                  = Dlfcn.GetStringConstant(handle, "kUTTypeCHeader");
                CPlusPlusHeader          = Dlfcn.GetStringConstant(handle, "kUTTypeCPlusPlusHeader");
                JavaSource               = Dlfcn.GetStringConstant(handle, "kUTTypeJavaSource");

                PDF      = Dlfcn.GetStringConstant(handle, "kUTTypePDF");
                RTFD     = Dlfcn.GetStringConstant(handle, "kUTTypeRTFD");
                FlatRTFD = Dlfcn.GetStringConstant(handle, "kUTTypeFlatRTFD");
                TXNTextAndMultimediaData = Dlfcn.GetStringConstant(handle, "kUTTypeTXNTextAndMultimediaData");
                WebArchive = Dlfcn.GetStringConstant(handle, "kUTTypeWebArchive");

                Image          = Dlfcn.GetStringConstant(handle, "kUTTypeImage");
                JPEG           = Dlfcn.GetStringConstant(handle, "kUTTypeJPEG");
                JPEG2000       = Dlfcn.GetStringConstant(handle, "kUTTypeJPEG2000");
                TIFF           = Dlfcn.GetStringConstant(handle, "kUTTypeTIFF");
                PICT           = Dlfcn.GetStringConstant(handle, "kUTTypePICT");
                GIF            = Dlfcn.GetStringConstant(handle, "kUTTypeGIF");
                PNG            = Dlfcn.GetStringConstant(handle, "kUTTypePNG");
                QuickTimeImage = Dlfcn.GetStringConstant(handle, "kUTTypeQuickTimeImage");
                AppleICNS      = Dlfcn.GetStringConstant(handle, "kUTTypeAppleICNS");
                BMP            = Dlfcn.GetStringConstant(handle, "kUTTypeBMP");
                ICO            = Dlfcn.GetStringConstant(handle, "kUTTypeICO");

                AudiovisualContent = Dlfcn.GetStringConstant(handle, "kUTTypeAudiovisualContent");
                Movie                    = Dlfcn.GetStringConstant(handle, "kUTTypeMovie");
                Video                    = Dlfcn.GetStringConstant(handle, "kUTTypeVideo");
                Audio                    = Dlfcn.GetStringConstant(handle, "kUTTypeAudio");
                QuickTimeMovie           = Dlfcn.GetStringConstant(handle, "kUTTypeQuickTimeMovie");
                MPEG                     = Dlfcn.GetStringConstant(handle, "kUTTypeMPEG");
                MPEG4                    = Dlfcn.GetStringConstant(handle, "kUTTypeMPEG4");
                MP3                      = Dlfcn.GetStringConstant(handle, "kUTTypeMP3");
                MPEG4Audio               = Dlfcn.GetStringConstant(handle, "kUTTypeMPEG4Audio");
                AppleProtectedMPEG4Audio = Dlfcn.GetStringConstant(handle, "kUTTypeAppleProtectedMPEG4Audio");

                Folder    = Dlfcn.GetStringConstant(handle, "kUTTypeFolder");
                Volume    = Dlfcn.GetStringConstant(handle, "kUTTypeVolume");
                Package   = Dlfcn.GetStringConstant(handle, "kUTTypePackage");
                Bundle    = Dlfcn.GetStringConstant(handle, "kUTTypeBundle");
                Framework = Dlfcn.GetStringConstant(handle, "kUTTypeFramework");

                ApplicationBundle = Dlfcn.GetStringConstant(handle, "kUTTypeApplicationBundle");
                ApplicationFile   = Dlfcn.GetStringConstant(handle, "kUTTypeApplicationFile");

                VCard = Dlfcn.GetStringConstant(handle, "kUTTypeVCard");

                InkText = Dlfcn.GetStringConstant(handle, "kUTTypeInkText");
            }
            finally {
                Dlfcn.dlclose(handle);
            }
        }
예제 #8
0
 static DispatchData()
 {
     lib  = Dlfcn.dlopen(Constants.libcLibrary, 0);
     free = Marshal.ReadIntPtr(Dlfcn.dlsym(lib, "_dispatch_data_destructor_free"));
 }
예제 #9
0
        static CodeEditorHandler()
        {
            var path = Path.Combine(NSBundle.MainBundle.PrivateFrameworksPath, "Scintilla.framework", "Scintilla");

            Dlfcn.dlopen(path, 4);
        }
예제 #10
0
        // we just want to confirm the symbol exists so `dlsym` can be disabled
        protected void Check(Assembly a)
        {
            Errors = 0;
            ErrorData.Clear();
            int n = 0;

            foreach (var t in a.GetTypes())
            {
                foreach (var m in t.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
                {
                    if ((m.Attributes & MethodAttributes.PinvokeImpl) == 0)
                    {
                        continue;
                    }

                    var dllimport = m.GetCustomAttribute <DllImportAttribute> ();

                    string name = dllimport.EntryPoint ?? m.Name;
                    switch (name)
                    {
                    // known not to be present in ARM64
                    case "objc_msgSend_stret":
                    case "objc_msgSendSuper_stret":
                        // the linker normally removes them (IntPtr.Size optimization)
                        continue;
                    }

                    string path = dllimport.Value;
                    switch (path)
                    {
                    case "__Internal":
                        // load from executable
                        path = null;
                        break;

#if NET
                    case "libSystem.Globalization.Native":
                        // Globalization hasn't been implemented yet: https://github.com/xamarin/xamarin-macios/issues/8906
                        if (name.StartsWith("GlobalizationNative_", StringComparison.Ordinal))
                        {
                            continue;
                        }
                        break;

                    case "libhostpolicy":
                        // There's no libhostpolicy library.
                        // https://github.com/dotnet/runtime/issues/38543
                        continue;

                    case "libSystem.Native":
                        path += ".dylib";
                        break;

                    case "QCall":
                        if (name.StartsWith("LogThreadPool", StringComparison.Ordinal))
                        {
                            continue;
                        }
                        break;
#endif
                    case "libc":
                        // we still have some rogue/not-fully-qualified DllImport
                        path = "/usr/lib/libSystem.dylib";
                        break;

                    case "System.Native":
                    case "System.Security.Cryptography.Native.Apple":
                    case "System.Net.Security.Native":
                        if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None)
                        {
                            continue;
                        }
#if __IOS__
                        path = MonoNativeConfig.GetPInvokeLibraryName(MonoNativeFlavor.Compat, MonoNativeConfig.LinkMode);
#else
                        path = null;
#endif
                        break;
                    }

                    var lib = Dlfcn.dlopen(path, 0);
                    var h   = Dlfcn.dlsym(lib, name);
                    if (h == IntPtr.Zero)
                    {
                        ReportError("Could not find the symbol '{0}' in {1} for the P/Invoke {2}.{3} in {4}", name, path, t.FullName, m.Name, a.GetName().Name);
                    }
                    Dlfcn.dlclose(lib);
                    n++;
                }
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} symbol lookups{2}", Errors, n, Errors == 0 ? string.Empty : ":\n" + ErrorData.ToString() + "\n");
        }
예제 #11
0
        // we just want to confirm the symbol exists so `dlsym` can be disabled
        protected void Check(Assembly a)
        {
            Errors = 0;
            ErrorData.Clear();
            int n = 0;

            foreach (var t in a.GetTypes())
            {
                foreach (var m in t.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
                {
                    if ((m.Attributes & MethodAttributes.PinvokeImpl) == 0)
                    {
                        continue;
                    }

                    var dllimport = m.GetCustomAttribute <DllImportAttribute> ();

                    string name = dllimport.EntryPoint ?? m.Name;
                    switch (name)
                    {
                    // known not to be present in ARM64
                    case "objc_msgSend_stret":
                    case "objc_msgSendSuper_stret":
                        // the linker normally removes them (IntPtr.Size optimization)
                        continue;
                    }

                    string path = dllimport.Value;
                    switch (path)
                    {
                    case "__Internal":
                        // load from executable
                        path = null;
                        break;

#if NET
                    case "libSystem.Globalization.Native":
                        // load from executable (like __Internal above since it's part of the static library)
                        path = null;
                        break;

                    case "libSystem.Native":
                        path += ".dylib";
                        break;
#endif
                    case "libc":
                        // we still have some rogue/not-fully-qualified DllImport
                        path = "/usr/lib/libSystem.dylib";
                        break;

                    case "System.Native":
                    case "System.Security.Cryptography.Native.Apple":
                    case "System.Net.Security.Native":
                        if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None)
                        {
                            continue;
                        }
#if __IOS__
                        path = MonoNativeConfig.GetPInvokeLibraryName(MonoNativeFlavor.Compat, MonoNativeConfig.LinkMode);
#else
                        path = null;
#endif
                        break;
                    }

                    var lib = Dlfcn.dlopen(path, 0);
                    var h   = Dlfcn.dlsym(lib, name);
                    if (h == IntPtr.Zero)
                    {
                        ReportError("Could not find the symbol '{0}' in {1} for the P/Invoke {2}.{3} in {4}", name, path, t.FullName, m.Name, a.GetName().Name);
                    }
                    else if (path != null)
                    {
                        // Verify that the P/Invoke points to the right library.
                        Dl_info info  = default(Dl_info);
                        var     found = dladdr(h, out info);
                        if (found != 0)
                        {
                            // Resolve symlinks in both cases
                            var dllImportPath = ResolveLibrarySymlinks(path);
                            var foundLibrary  = ResolveLibrarySymlinks(Marshal.PtrToStringAuto(info.dli_fname));
                            if (Skip(name, ref dllImportPath, ref foundLibrary))
                            {
                                // Skipped
                            }
                            else if (foundLibrary != dllImportPath)
                            {
                                ReportError($"Found the symbol '{name}' in the library '{foundLibrary}', but the P/Invoke {t.FullName}.{m.Name} in {a.GetName ().Name} claims it's in '{dllimport.Value}'.");
                            }
                        }
                        else
                        {
                            Console.WriteLine($"Unable to find the library for the symbol '{name}' claimed to be in {path} for the P/Invoke {t.FullName}.{m.Name} in {a.GetName ().Name} (rv: {found})");
                        }
                    }

                    Dlfcn.dlclose(lib);
                    n++;
                }
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} symbol lookups{2}", Errors, n, Errors == 0 ? string.Empty : ":\n" + ErrorData.ToString() + "\n");
        }
예제 #12
0
        // On load, construct the CIRawFilter
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var asset = Asset;

            if (asset == null)
            {
                return;
            }

            // Setup options to request original image.
            var options = new PHImageRequestOptions {
                Version     = PHImageRequestOptionsVersion.Original,
                Synchronous = true
            };

            // Request the image data and UTI type for the image.
            PHImageManager.DefaultManager.RequestImageData(asset, options, (imageData, dataUTI, _, __) => {
                if (imageData == null || dataUTI == null)
                {
                    return;
                }

                // Create a CIRawFilter from original image data.
                // UTI type is passed in to provide the CIRawFilter with a hint about the UTI type of the Raw file.
                //var rawOptions = [String (kCGImageSourceTypeIdentifierHint) : dataUTI ]
                var rawOptions     = new NSMutableDictionary();
                var imageIOLibrary = Dlfcn.dlopen("/System/Library/Frameworks/ImageIO.framework/ImageIO", 0);
                var key            = Dlfcn.GetIntPtr(imageIOLibrary, "kCGImageSourceTypeIdentifierHint");
                rawOptions.LowlevelSetObject(dataUTI, key);

                ciRawFilter = CIFilter.CreateRawFilter(imageData, rawOptions);
                if (ciRawFilter == null)
                {
                    return;
                }

                // Get the native size of the image produced by the CIRawFilter.
                var sizeValue = ciRawFilter.ValueForKey(Keys.kCIOutputNativeSizeKey) as CIVector;
                if (sizeValue != null)
                {
                    imageNativeSize = new CGSize(sizeValue.X, sizeValue.Y);
                }

                // Record the original value of the temperature, and setup the editing slider.
                var tempValue = (NSNumber)ciRawFilter.ValueForKey(Keys.kCIInputNeutralTemperatureKey);
                if (tempValue != null)
                {
                    originalTemp = tempValue.FloatValue;
                    TempSlider.SetValue(tempValue.FloatValue, animated: false);
                }

                // Record the original value of the tint, and setup the editing slider.
                var tintValue = (NSNumber)ciRawFilter.ValueForKey(Keys.kCIInputNeutralTintKey);
                if (tintValue != null)
                {
                    originalTint = tintValue.FloatValue;
                    TintSlider.SetValue(tintValue.FloatValue, animated: false);
                }
            });

            // Create EAGL context used to render the CIImage produced by the CIRawFilter to display.
            ImageView.Context = new EAGLContext(EAGLRenderingAPI.OpenGLES3);
            ciContext         = CIContext.FromContext(ImageView.Context, new CIContextOptions {
                CIImageFormat = CIImage.FormatRGBAh
            });
        }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionCtx)
        {
            SlidingViewController sliding = this.SlidingViewController;
            // Get constant from uikit
            IntPtr   handle = Dlfcn.dlopen(MonoTouch.Constants.UIKitLibrary, 0);
            NSString UITransitionContextToViewControllerKey = Dlfcn.GetStringConstant(handle, "UITransitionContextToViewControllerKey");

            Dlfcn.dlclose(handle);
            // Get controllers
            UIViewController topController       = sliding.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextTopViewControllerKey);
            UIViewController toController        = sliding.GetViewControllerForKey(UITransitionContextToViewControllerKey);
            RectangleF       topViewInitialFrame = sliding.GetInitialFrameForViewController(topController);
            RectangleF       topViewFinalFrame   = sliding.GetFinalFrameForViewController(topController);

            // Update top view frame
            topController.View.Frame = topViewInitialFrame;
            // Reset layer transforms
            CATransform3D transform = CATransform3D.Identity;

            transform.m34 = -0.002f;
            sliding.ContainerView.Layer.SublayerTransform = transform;

            UIViewController underController;
            float            revealWidth = 0f;
            bool             resetting   = false;

            if (topController == toController)
            {
                underController = sliding.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextUnderLeftControllerKey);
                revealWidth     = sliding.GetInitialFrameForViewController(topController).X;
                resetting       = true;
            }
            else
            {
                underController = sliding.GetViewControllerForKey(UITransitionContextToViewControllerKey);
                revealWidth     = sliding.GetFinalFrameForViewController(topController).X;
                resetting       = false;
            }

            RectangleF underViewInitialFrame = sliding.GetInitialFrameForViewController(underController);
            RectangleF underViewFinalFrame   = sliding.GetFinalFrameForViewController(underController);

            underController.View.Frame = underViewInitialFrame.IsEmpty ? underViewFinalFrame : underViewInitialFrame;
            underController.View.RemoveFromSuperview();

            float      underViewHalfwayPoint = revealWidth / 2;
            RectangleF leftSideFrame         = new RectangleF(0, 0, underViewHalfwayPoint, underController.View.Bounds.Height);
            RectangleF rightSideFrame        = new RectangleF(underViewHalfwayPoint, 0, underViewHalfwayPoint, underController.View.Bounds.Height);

            UIView leftSideView  = underController.View.ResizableSnapshotView(leftSideFrame, true, UIEdgeInsets.Zero);
            UIView rightSideView = underController.View.ResizableSnapshotView(rightSideFrame, true, UIEdgeInsets.Zero);

            leftSideView.Layer.AnchorPoint = new PointF(0f, 0.5f);
            leftSideView.Frame             = leftSideFrame;

            rightSideView.Layer.Frame       = rightSideFrame;
            rightSideView.Layer.AnchorPoint = new PointF(1F, 0F);

            if (resetting)
            {
                this.UnfoldLayers(leftSideView.Layer, rightSideView.Layer);
            }
            else
            {
                this.FoldLayers(leftSideView.Layer, rightSideView.Layer);
            }

            sliding.ContainerView.Layer.InsertSublayerBelow(leftSideView.Layer, topController.View.Layer);
            sliding.ContainerView.Layer.InsertSublayerBelow(rightSideView.Layer, topController.View.Layer);

            // Animate panel
            UIView.Animate(
                this.TransitionDuration(transitionCtx),
                new NSAction(
                    delegate()
            {
                UIView.SetAnimationCurve(UIViewAnimationCurve.Linear);
                if (this.CoordinatorAnimations != null)
                {
                    this.CoordinatorAnimations(transitionCtx);
                }
                topController.View.Frame = topViewFinalFrame;

                if (resetting)
                {
                    this.FoldLayers(leftSideView.Layer, rightSideView.Layer);
                }
                else
                {
                    this.UnfoldLayers(leftSideView.Layer, rightSideView.Layer);
                }
            }
                    ),
                new NSAction(
                    delegate()
            {
                sliding.ContainerView.Layer.SublayerTransform = CATransform3D.Identity;
                leftSideView.RemoveFromSuperview();
                rightSideView.RemoveFromSuperview();

                bool topViewReset        = (resetting && !sliding.TransitionWasCancelled) || (!resetting && sliding.TransitionWasCancelled);
                topController.View.Frame = sliding.TransitionWasCancelled ? sliding.GetInitialFrameForViewController(topController) : sliding.GetFinalFrameForViewController(topController);

                if (topViewReset)
                {
                    underController.View.RemoveFromSuperview();
                }
                else
                {
                    underController.View.Frame = sliding.TransitionWasCancelled ? sliding.GetInitialFrameForViewController(underController) : sliding.GetFinalFrameForViewController(underController);
                    sliding.ContainerView.InsertSubviewBelow(underController.View, topController.View);
                }

                if (this.CoordinatorCompletion != null)
                {
                    this.CoordinatorCompletion(transitionCtx);
                }
                sliding.CompleteTransition(true);
            }
                    )
                );
        }