Example #1
0
 protected void SetArrayValue(NSString key, INativeObject[] values)
 {
     if (NullCheckAndRemoveKey(key, values == null))
     {
         CFMutableDictionary.SetValue(Dictionary.Handle, key.Handle, CFArray.FromNativeObjects(values).Handle);
     }
 }
Example #2
0
        public IDictionary <IOHIDElement, IOHIDValue> GetValues(IOHIDElement[] elements)
        {
            ThrowIfDisposed();
            if (elements == null)
            {
                throw new ArgumentNullException("elements");
            }
            var elementArray = CFArray.FromNativeObjects(elements);

            IOHIDElement[] keys        = new IOHIDElement[elements.Length];
            IOHIDValue[]   values      = new IOHIDValue[elements.Length];
            CFDictionary   multiple    = CFDictionary.FromObjectsAndKeys(values, keys);
            var            multipleRef = multiple.Handle;
            var            result      = IOHIDDeviceCopyValueMultiple(Handle, elementArray.Handle, ref multipleRef);

            IOObject.ThrowIfError(result);
            var dict = new Dictionary <IOHIDElement, IOHIDValue> (multiple.Count);

            IntPtr[] keyRefs, valueRefs;
            multiple.GetKeysAndValues(out keyRefs, out valueRefs);
            for (int i = 0; i < multiple.Count; i++)
            {
                dict.Add(new IOHIDElement(keyRefs [i], true), new IOHIDValue(valueRefs [i], true));
            }
            CFType.Release(multiple.Handle);
            return(dict);
        }
Example #3
0
        public static bool MatchFontDescriptors(CTFontDescriptor[] descriptors, NSSet mandatoryAttributes, Func <CTFontDescriptorMatchingState, IntPtr, bool> progressHandler)
        {
            var ma = mandatoryAttributes == null ? IntPtr.Zero : mandatoryAttributes.Handle;

            // FIXME: SIGSEGV probably due to mandatoryAttributes mismatch
            using (var ar = CFArray.FromNativeObjects(descriptors)) {
                return(CTFontDescriptorMatchFontDescriptorsWithProgressHandler(ar.Handle, ma, progressHandler));
            }
        }
Example #4
0
 public SecStatusCode SetAnchorCertificates(SecCertificate[] array)
 {
     if (array == null)
     {
         return(SecTrustSetAnchorCertificates(handle, IntPtr.Zero));
     }
     using (var certs = CFArray.FromNativeObjects(array)) {
         return(SecTrustSetAnchorCertificates(handle, certs.Handle));
     }
 }
Example #5
0
        static IntPtr Create(CGColorSpace?colorspace, CGColor [] colors)
        {
            if (colors is null)
            {
                throw new ArgumentNullException(nameof(colors));
            }

            using (var array = CFArray.FromNativeObjects(colors))
                return(CGGradientCreateWithColors(colorspace.GetHandle(), array.Handle, null));
        }
        public CTFontCollection?WithFontDescriptors(CTFontDescriptor[]?queryDescriptors, CTFontCollectionOptions?options)
        {
            using var descriptors = queryDescriptors is null ? null : CFArray.FromNativeObjects(queryDescriptors);
            var h = CTFontCollectionCreateCopyWithFontDescriptors(Handle, descriptors.GetHandle(), options.GetHandle());

            if (h == IntPtr.Zero)
            {
                return(null);
            }
            return(new CTFontCollection(h, true));
        }
Example #7
0
        public CGGradient(CGColorSpace colorspace, CGColor [] colors)
        {
            if (colors == null)
            {
                throw new ArgumentNullException("colors");
            }

            IntPtr csh = colorspace == null ? IntPtr.Zero : colorspace.handle;

            using (var array = CFArray.FromNativeObjects(colors))
                handle = CGGradientCreateWithColors(csh, array.Handle, null);
        }
Example #8
0
        static IntPtr Create(CGColorSpace?colorspace, CGColor [] colors, nfloat []?locations)
        {
            // colors is __nullable but would return a `nil` instance back,
            // which is not something we can handle nicely from a .NET constructor
            if (colors is null)
            {
                throw new ArgumentNullException(nameof(colors));
            }

            using (var array = CFArray.FromNativeObjects(colors))
                return(CGGradientCreateWithColors(colorspace.GetHandle(), array.Handle, locations));
        }
Example #9
0
 public CTFontCollection(CTFontDescriptor[] queryDescriptors, CTFontCollectionOptions options)
 {
     using (var descriptors = queryDescriptors == null
                                 ? null
                                 : CFArray.FromNativeObjects(queryDescriptors))
         handle = CTFontCollectionCreateWithFontDescriptors(
             descriptors == null ? IntPtr.Zero : descriptors.Handle,
             options == null ? IntPtr.Zero : options.Dictionary.Handle);
     if (handle == IntPtr.Zero)
     {
         throw ConstructorError.Unknown(this);
     }
 }
Example #10
0
        public CGGradient(CGColorSpace colorspace, CGColor [] colors, nfloat [] locations)
        {
            // colors is __nullable but would return a `nil` instance back,
            // which is not something we can handle nicely from a .NET constructor
            if (colors == null)
            {
                throw new ArgumentNullException("colors");
            }

            IntPtr csh = colorspace == null ? IntPtr.Zero : colorspace.handle;

            using (var array = CFArray.FromNativeObjects(colors))
                handle = CGGradientCreateWithColors(csh, array.Handle, locations);
        }
Example #11
0
        protected void SetArrayValue(NSString key, INativeObject[] values)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (values == null)
            {
                RemoveValue(key);
                return;
            }

            CFMutableDictionary.SetValue(Dictionary.Handle, key.Handle, CFArray.FromNativeObjects(values).Handle);
        }
Example #12
0
        public CTFontCollection WithFontDescriptors(CTFontDescriptor[] queryDescriptors, CTFontCollectionOptions options)
        {
            IntPtr h;

            using (var descriptors = queryDescriptors == null
                                        ? null
                                        : CFArray.FromNativeObjects(queryDescriptors)) {
                h = CTFontCollectionCreateCopyWithFontDescriptors(
                    handle,
                    descriptors == null ? IntPtr.Zero : descriptors.Handle,
                    options == null ? IntPtr.Zero : options.Dictionary.Handle);
            }
            if (h == IntPtr.Zero)
            {
                return(null);
            }
            return(new CTFontCollection(h, true));
        }
Example #13
0
 void Initialize(SecCertificate[] array, SecPolicy policy)
 {
     using (var certs = CFArray.FromNativeObjects(array)) {
         Initialize(certs.Handle, policy);
     }
 }
 static IntPtr Create(CTFontDescriptor []?queryDescriptors, CTFontCollectionOptions?options)
 {
     using var descriptors = queryDescriptors is null ? null : CFArray.FromNativeObjects(queryDescriptors);
     return(CTFontCollectionCreateWithFontDescriptors(descriptors.GetHandle(), options.GetHandle()));
 }
Example #15
0
 SecStatusCode SetAnchorCertificates(SecCertificate[] array)
 {
     using (var certs = CFArray.FromNativeObjects(array)) {
         return(SecTrustSetAnchorCertificates(Handle, certs.Handle));
     }
 }