Ejemplo n.º 1
0
 internal VTVideoEncoder(NSNumber codecType, NSString codecName, NSString displayName, NSString encoderId, NSString encoderName)
 {
     CodecType = codecType.Int32Value;
     CodecName = codecName;
     DisplayName = displayName;
     EncoderId = encoderId;
     EncoderName = encoderName;
 }
Ejemplo n.º 2
0
 static NSNumber[] Convert(double [] values)
 {
     if (values == null)
         return null;
     NSNumber[] array = new NSNumber [values.Length];
     for (int i = 0 ; i < array.Length; i++)
         array [i] = NSNumber.FromDouble (values [i]);
     return array;
 }
Ejemplo n.º 3
0
 static nfloat? NFloatValue(NSNumber number)
 {
     if (number == null)
         return null;
     else if (IntPtr.Size == 4)
         return (nfloat)number.FloatValue;
     else
         return (nfloat)number.DoubleValue;
 }
Ejemplo n.º 4
0
 public bool SupportsAssetResourceTypes(params PHAssetResourceType [] resourceTypes)
 {
     var l = resourceTypes.Length;
     if (l == 0)
         return false;
     var a = new NSNumber [l];
     for (int i = 0; i < l; i++)
         a [i] = new NSNumber ((int) resourceTypes [i]);
     return _SupportsAssetResourceTypes (a);
 }
Ejemplo n.º 5
0
 public SKKeyframeSequence(NSObject [] values, NSNumber [] times)
     : this(values, NSArray.FromNSObjects (times))
 {
 }
Ejemplo n.º 6
0
        internal NSDictionary ToDictionary()
        {
            int n = 0;
            if (DirectionsMode.HasValue) n++;
            #if !WATCH
            if (MapType.HasValue) n++;
            #endif
            if (MapCenter.HasValue) n++;
            if (MapSpan.HasValue) n++;
            #if !WATCH
            if (ShowTraffic.HasValue) n++;
            if (Camera != null) n++;
            #endif
            if (n == 0)
                return null;

            var keys = new NSObject [n];
            var values = new NSObject [n];
            int i = 0;
            if (DirectionsMode.HasValue){
                keys [i] = MKMapItem.MKLaunchOptionsDirectionsModeKey;
                NSString v = MKMapItem.MKLaunchOptionsDirectionsModeDriving;
                switch (DirectionsMode.Value){
                case MKDirectionsMode.Driving:
                    v = MKMapItem.MKLaunchOptionsDirectionsModeDriving;
                    break;
                case MKDirectionsMode.Transit:
                    v = MKMapItem.MKLaunchOptionsDirectionsModeTransit;
                    break;
                case MKDirectionsMode.Walking:
                    v = MKMapItem.MKLaunchOptionsDirectionsModeWalking;
                    break;
                }
                values [i++] = v;
            }

            #if !WATCH // MapType: __WATCHOS_PROHIBITED
            if (MapType.HasValue){
                keys [i] = MKMapItem.MKLaunchOptionsMapTypeKey;
                values [i++] = new NSNumber ((int) MapType.Value);
            }
            #endif
            if (MapCenter.HasValue){
                keys [i] = MKMapItem.MKLaunchOptionsMapCenterKey;
                values [i++] = NSValue.FromMKCoordinate (MapCenter.Value);
            }
            if (MapSpan.HasValue){
                keys [i] = MKMapItem.MKLaunchOptionsMapSpanKey;
                values [i++] = NSValue.FromMKCoordinateSpan (MapSpan.Value);
            }
            #if !WATCH // ShowsTraffic: __WATCHOS_PROHIBITED
            if (ShowTraffic.HasValue){
                keys [i] = MKMapItem.MKLaunchOptionsShowsTrafficKey;
                values [i++] = new NSNumber (ShowTraffic.Value);
            }
            #endif
            #if !WATCH // MKLaunchOptionsCameraKey is allowed in WatchOS, but there's no MKMapCamera type.
            if (Camera != null) {
                keys [i] = MKMapItem.MKLaunchOptionsCameraKey;
                values [i++] = Camera;
            }
            #endif
            return NSDictionary.FromObjectsAndKeys (values, keys);
        }
Ejemplo n.º 7
0
        internal NSDictionary ToDictionary()
        {
            NSFileType?type;
            NSString   v    = null;
            var        dict = new NSMutableDictionary();

            if (AppendOnly.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(AppendOnly.Value), NSFileManager.AppendOnly);
            }
            if (Busy.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(Busy.Value), NSFileManager.Busy);
            }
#if XAMCORE_2_0
            if (ExtensionHidden.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(ExtensionHidden.Value), NSFileManager.ExtensionHidden);
            }
#else
            if (FileExtensionHidden.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(FileExtensionHidden.Value), NSFileManager.ExtensionHidden);
            }
#endif
            if (CreationDate != null)
            {
                dict.SetObject(CreationDate, NSFileManager.CreationDate);
            }
            if (OwnerAccountName != null)
            {
                dict.SetObject(new NSString(OwnerAccountName), NSFileManager.OwnerAccountName);
            }
            if (GroupOwnerAccountName != null)
            {
                dict.SetObject(new NSString(GroupOwnerAccountName), NSFileManager.GroupOwnerAccountName);
            }
            if (SystemNumber.HasValue)
            {
                dict.SetObject(NSNumber.FromLong(SystemNumber.Value), NSFileManager.SystemNumber);
            }
            if (DeviceIdentifier.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(DeviceIdentifier.Value), NSFileManager.DeviceIdentifier);
            }
#if XAMCORE_2_0
            if (GroupOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(GroupOwnerAccountID.Value), NSFileManager.GroupOwnerAccountID);
            }
#else
            if (FileGroupOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(FileGroupOwnerAccountID.Value), NSFileManager.GroupOwnerAccountID);
            }
#endif
            if (Immutable.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(Immutable.Value), NSFileManager.Immutable);
            }
            if (ModificationDate != null)
            {
                dict.SetObject(ModificationDate, NSFileManager.ModificationDate);
            }
#if XAMCORE_2_0
            if (OwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(OwnerAccountID.Value), NSFileManager.OwnerAccountID);
            }
#else
            if (FileOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(FileOwnerAccountID.Value), NSFileManager.OwnerAccountID);
            }
#endif
            if (HfsCreatorCode.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(HfsCreatorCode.Value), NSFileManager.HfsCreatorCode);
            }
            if (HfsTypeCode.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(HfsTypeCode.Value), NSFileManager.HfsTypeCode);
            }
            if (PosixPermissions.HasValue)
            {
                dict.SetObject(NSNumber.FromInt16((short)PosixPermissions.Value), NSFileManager.PosixPermissions);
            }
#if XAMCORE_2_0
            if (ReferenceCount.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(ReferenceCount.Value), NSFileManager.ReferenceCount);
            }
            if (SystemFileNumber.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(SystemFileNumber.Value), NSFileManager.SystemFileNumber);
            }
            if (Size.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt64(Size.Value), NSFileManager.Size);
            }

            type = Type;
#else
            if (FileReferenceCount.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(FileReferenceCount.Value), NSFileManager.ReferenceCount);
            }
            if (FileSystemFileNumber.HasValue)
            {
                dict.SetObject(NSNumber.FromUnsignedLong(FileSystemFileNumber.Value), NSFileManager.SystemFileNumber);
            }
            if (FileSize.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt64(FileSize.Value), NSFileManager.Size);
            }

            type = FileType;
#endif

            if (type.HasValue)
            {
                v = null;
                switch (type.Value)
                {
                case NSFileType.Directory:
                    v = NSFileManager.TypeDirectory; break;

                case NSFileType.Regular:
                    v = NSFileManager.TypeRegular; break;

                case NSFileType.SymbolicLink:
                    v = NSFileManager.TypeSymbolicLink; break;

                case NSFileType.Socket:
                    v = NSFileManager.TypeSocket; break;

                case NSFileType.CharacterSpecial:
                    v = NSFileManager.TypeCharacterSpecial; break;

                case NSFileType.BlockSpecial:
                    v = NSFileManager.TypeBlockSpecial; break;

                default:
                    v = NSFileManager.TypeUnknown; break;
                }
                dict.SetObject(v, NSFileManager.NSFileType);
            }

#if !MONOMAC
            if (ProtectionKey.HasValue)
            {
                v = null;
                switch (ProtectionKey.Value)
                {
                case NSFileProtection.None:
                    v = NSFileManager.FileProtectionNone; break;

                case NSFileProtection.Complete:
                    v = NSFileManager.FileProtectionComplete; break;

                case NSFileProtection.CompleteUnlessOpen:
                    v = NSFileManager.FileProtectionCompleteUnlessOpen; break;

                case NSFileProtection.CompleteUntilFirstUserAuthentication:
                    v = NSFileManager.FileProtectionCompleteUntilFirstUserAuthentication; break;
                }
                dict.SetObject(v, NSFileManager.FileProtectionKey);
            }
#endif
            return(dict);
        }
Ejemplo n.º 8
0
        public NSDictionary ToDictionary()
        {
            var n = 0;
            if (ShapeType.HasValue) n++;
            if (KeepAsCompound.HasValue) n++;
            if (Scale.HasValue) n++;

            if (n == 0)
                return null;

            var i = 0;
            var keys = new NSString [n];
            var values = new NSObject [n];

            if (ShapeType.HasValue) {
                keys [i] = SCNPhysicsShapeOptionsKeys.Type;
                switch (ShapeType.Value) {
                case SCNPhysicsShapeType.BoundingBox:
                    values [i] = SCNPhysicsShapeOptionsTypes.BoundingBox;
                    break;
                case SCNPhysicsShapeType.ConcavePolyhedron:
                    values [i] = SCNPhysicsShapeOptionsTypes.ConcavePolyhedron;
                    break;
                case SCNPhysicsShapeType.ConvexHull:
                default:
                    values [i] = SCNPhysicsShapeOptionsTypes.ConvexHull;
                    break;
                }
            }

            if (KeepAsCompound.HasValue) {
                keys [i] = SCNPhysicsShapeOptionsKeys.KeepAsCompound;
                values [i] = new NSNumber (KeepAsCompound.Value);
            }

            if (Scale.HasValue) {
                keys [i] = SCNPhysicsShapeOptionsKeys.Scale;
                values [i] = NSValue.FromVector (Scale.Value);
            }

            return NSDictionary.FromObjectsAndKeys (values, keys);
        }
Ejemplo n.º 9
0
        public static NSObject FromObject(object obj)
        {
            if (obj == null)
            {
                return(NSNull.Null);
            }
            var t = obj.GetType();

            if (t == typeof(NSObject) || t.IsSubclassOf(typeof(NSObject)))
            {
                return((NSObject)obj);
            }

            switch (Type.GetTypeCode(t))
            {
            case TypeCode.Boolean:
                return(new NSNumber((bool)obj));

            case TypeCode.Char:
                return(new NSNumber((ushort)(char)obj));

            case TypeCode.SByte:
                return(new NSNumber((sbyte)obj));

            case TypeCode.Byte:
                return(new NSNumber((byte)obj));

            case TypeCode.Int16:
                return(new NSNumber((short)obj));

            case TypeCode.UInt16:
                return(new NSNumber((ushort)obj));

            case TypeCode.Int32:
                return(new NSNumber((int)obj));

            case TypeCode.UInt32:
                return(new NSNumber((uint)obj));

            case TypeCode.Int64:
                return(new NSNumber((long)obj));

            case TypeCode.UInt64:
                return(new NSNumber((ulong)obj));

            case TypeCode.Single:
                return(new NSNumber((float)obj));

            case TypeCode.Double:
                return(new NSNumber((double)obj));

            case TypeCode.String:
                return(new NSString((string)obj));

            default:
                if (t == typeof(IntPtr))
                {
                    return(NSValue.ValueFromPointer((IntPtr)obj));
                }
#if !NO_SYSTEM_DRAWING
                if (t == typeof(SizeF))
                {
                    return(NSValue.FromSizeF((SizeF)obj));
                }
                else if (t == typeof(RectangleF))
                {
                    return(NSValue.FromRectangleF((RectangleF)obj));
                }
                else if (t == typeof(PointF))
                {
                    return(NSValue.FromPointF((PointF)obj));
                }
#endif
#if XAMCORE_2_0
                if (t == typeof(nint))
                {
                    return(NSNumber.FromNInt((nint)obj));
                }
                else if (t == typeof(nuint))
                {
                    return(NSNumber.FromNUInt((nuint)obj));
                }
                else if (t == typeof(nfloat))
                {
                    return(NSNumber.FromNFloat((nfloat)obj));
                }
                else if (t == typeof(CGSize))
                {
                    return(NSValue.FromCGSize((CGSize)obj));
                }
                else if (t == typeof(CGRect))
                {
                    return(NSValue.FromCGRect((CGRect)obj));
                }
                else if (t == typeof(CGPoint))
                {
                    return(NSValue.FromCGPoint((CGPoint)obj));
                }
#endif

#if !MONOMAC
                if (t == typeof(CGAffineTransform))
                {
                    return(NSValue.FromCGAffineTransform((CGAffineTransform)obj));
                }
                else if (t == typeof(UIEdgeInsets))
                {
                    return(NSValue.FromUIEdgeInsets((UIEdgeInsets)obj));
                }
#if !WATCH
                else if (t == typeof(CATransform3D))
                {
                    return(NSValue.FromCATransform3D((CATransform3D)obj));
                }
#endif
#endif
                // last chance for types like CGPath, CGColor... that are not NSObject but are CFObject
                // see https://bugzilla.xamarin.com/show_bug.cgi?id=8458
                INativeObject native = (obj as INativeObject);
                if (native != null)
                {
                    return(Runtime.GetNSObject(native.Handle));
                }
                return(null);
            }
        }
Ejemplo n.º 10
0
		internal NSMutableDictionary ToDictionary ()
		{
			var dict = new NSMutableDictionary ();

			if (LossyCompressionQuality.HasValue)
				dict.LowlevelSetObject (new NSNumber (LossyCompressionQuality.Value), kLossyCompressionQuality);
			if (DestinationBackgroundColor != null)
				dict.LowlevelSetObject (DestinationBackgroundColor.Handle, kBackgroundColor);

			// new in iOS 7 and 10.8
			if (Metadata != null) {
				dict.LowlevelSetObject (Metadata.Handle, kMetadata);
				// default are false
				if (MergeMetadata)
					dict.LowlevelSetObject (CFBoolean.True.Handle, kMergeMetadata);
				if (ShouldExcludeXMP)
					dict.LowlevelSetObject (CFBoolean.True.Handle, kShouldExcludeXMP);
			} else {
				// DateTime is exclusive of metadata (which includes its own)
				if (DateTime.HasValue)
					dict.LowlevelSetObject ((NSDate) DateTime, kDateTime);
			}

			if (Orientation.HasValue) {
				using (var n = new NSNumber (Orientation.Value))
					dict.LowlevelSetObject (n.Handle, kOrientation);
			}

			// new in iOS 8 and 10.10 
			if (ImageMaxPixelSize.HasValue && (kImageMaxPixelSize != IntPtr.Zero)) {
				using (var n = new NSNumber (ImageMaxPixelSize.Value))
					dict.LowlevelSetObject (n.Handle, kOrientation);
			}

			// new in iOS 8 and 10.10 - default is false
			if (EmbedThumbnail && (kEmbedThumbnail != IntPtr.Zero))
				dict.LowlevelSetObject (CFBoolean.True.Handle, kEmbedThumbnail);

			// new in iOS 8 and 10.10 - default is false
			if (ShouldExcludeGPS && (kShouldExcludeGPS != IntPtr.Zero))
				dict.LowlevelSetObject (CFBoolean.True.Handle, kShouldExcludeGPS);

			if (OptimizeColorForSharing && (kOptimizeColorForSharing != IntPtr.Zero))
				dict.LowlevelSetObject (CFBoolean.True.Handle, kOptimizeColorForSharing);

			return dict;
		}
Ejemplo n.º 11
0
		internal NSMutableDictionary ToDictionary ()
		{
			var dict = new NSMutableDictionary ();

			// new in iOS 7 and 10.8
			if (Metadata != null) {
				dict.LowlevelSetObject (Metadata.Handle, kMetadata);
				// default are false
				if (MergeMetadata)
					dict.LowlevelSetObject (CFBoolean.True.Handle, kMergeMetadata);
				if (ShouldExcludeXMP)
					dict.LowlevelSetObject (CFBoolean.True.Handle, kShouldExcludeXMP);
			} else {
				// DateTime is exclusive of metadata (which includes its own)
				if (DateTime.HasValue)
					dict.LowlevelSetObject ((NSDate) DateTime, kDateTime);
			}

			// new in iOS 8 and 10.10 - default is false
			if (ShouldExcludeGPS && (kShouldExcludeGPS != IntPtr.Zero))
				dict.LowlevelSetObject (CFBoolean.True.Handle, kShouldExcludeGPS);

			if (Orientation.HasValue) {
				using (var n = new NSNumber (Orientation.Value))
					dict.LowlevelSetObject (n.Handle, kOrientation);
			}
			
			return dict;
		}
Ejemplo n.º 12
0
        static AccessoryInfo[] ExtractAccessoryInfo(IntPtr ptr, NSString id, NSString description)
        {
            using (var array = new CFArray (ptr)) {
                var res = new AccessoryInfo [array.Count];
                for (int i = 0; i < res.Length; ++i) {
                    var dict = array.GetValue (i);
                    var n = new NSNumber (CFDictionary.GetValue (dict, id.Handle));
                    var desc = CFString.FetchString (CFDictionary.GetValue (dict, description.Handle));

                    res [i] = new AccessoryInfo ((int) n, desc);
                    id.Dispose ();
                }
                return res;
            }
        }
Ejemplo n.º 13
0
 public CMMemoryPool(TimeSpan ageOutPeriod)
 {
     using (var n = new NSNumber (ageOutPeriod.TotalSeconds))
     using (var dict = new NSDictionary (AgeOutPeriodSelector, n)) {
         handle = CMMemoryPoolCreate (dict.Handle);
     }
 }
Ejemplo n.º 14
0
 public CTFontDescriptor WithFeature(NSNumber featureTypeIdentifier, NSNumber featureSelectorIdentifier)
 {
     if (featureTypeIdentifier == null)
         throw new ArgumentNullException ("featureTypeIdentifier");
     if (featureSelectorIdentifier == null)
         throw new ArgumentNullException ("featureSelectorIdentifier");
     return CreateDescriptor (CTFontDescriptorCreateCopyWithFeature (handle, featureTypeIdentifier.Handle, featureSelectorIdentifier.Handle));
 }
Ejemplo n.º 15
0
 CTFontDescriptor WithFeature(FontFeatureGroup featureGroup, int featureSelector)
 {
     using (NSNumber t = new NSNumber ((int) featureGroup), f = new NSNumber (featureSelector)) {
         return CreateDescriptor (CTFontDescriptorCreateCopyWithFeature (handle, t.Handle, f.Handle));
     }
 }
Ejemplo n.º 16
0
 public CTFontDescriptor WithVariation(uint variationIdentifier, nfloat variationValue)
 {
     using (var id = new NSNumber (variationIdentifier))
         return CreateDescriptor (CTFontDescriptorCreateCopyWithVariation  (handle,
                     id.Handle, variationValue));
 }