Example #1
0
 static NSSet MakeSetFromTags(string [] tags)
 {
     var x = new NSString [tags.Length];
     for (int i = 0; i < tags.Length; i++)
         x [i] = new NSString (tags [i]);
     return new NSSet (x);
 }
Example #2
0
        public static void RequestSharedWebCredential(string domainName, string account, Action<string[], NSError> handler)
        {
            // do not check domain an account because they can be null
            Action<NSArray, NSError> onComplete = (NSArray a, NSError e) => {
                // get a string [] for the user rather than an ugly NSArray
                var array = NSArray.StringArrayFromHandle (a.Handle);
                handler (array, e);
            };
            // we need to create our own block literal.
            unsafe {
                BlockLiteral *block_ptr_onComplete;
                BlockLiteral block_onComplete;
                block_onComplete = new BlockLiteral ();
                block_ptr_onComplete = &block_onComplete;
                block_onComplete.SetupBlock (ArrayErrorActionTrampoline.Handler, onComplete);

                NSString nsDomain = null;
                if (domainName != null)
                    nsDomain = new NSString (domainName);

                NSString nsAccount = null;
                if (account != null)
                    nsAccount = new NSString (account);

                SecRequestSharedWebCredential ((nsDomain == null)? IntPtr.Zero : nsDomain.Handle, (nsAccount == null)? IntPtr.Zero : nsAccount.Handle,
                    (IntPtr) block_ptr_onComplete);
                block_ptr_onComplete->CleanupBlock ();
                if (nsDomain != null)
                    nsDomain.Dispose ();
                if (nsAccount != null)
                    nsAccount.Dispose ();
            }
        }
Example #3
0
        public static NSWindowDepth BestDepth(NSString colorspace, nint bitsPerSample, nint bitsPerPixel, bool planar, ref bool exactMatch)
        {
            if (colorspace == null)
                throw new ArgumentNullException ("colorspace");

            return NSBestDepth (colorspace.Handle, bitsPerSample, bitsPerPixel, planar, ref exactMatch);
        }
Example #4
0
        public static void AddSharedWebCredential(string domainName, string account, string password, Action<NSError> handler)
        {
            if (domainName == null)
                throw new ArgumentNullException ("domainName");
            if (account == null)
                throw new ArgumentNullException ("account");
            // we need to create our own block literal. We can reuse the SDActionArity1V12 which is generated and takes a
            // NSError because a CFError is a toll-free bridget to CFError
            unsafe {
                BlockLiteral *block_ptr_onComplete;
                BlockLiteral block_onComplete;
                block_onComplete = new BlockLiteral ();
                block_ptr_onComplete = &block_onComplete;
                block_onComplete.SetupBlock (ActionTrampoline.Handler, handler);

                using (var nsDomain = new NSString (domainName))
                using (var nsAccount = new NSString (account)) {
                    if (password == null) {  // we are removing a password
                        SecAddSharedWebCredential (nsDomain.Handle, nsAccount.Handle, IntPtr.Zero, (IntPtr) block_ptr_onComplete);
                    } else {
                        using (var nsPassword = new NSString (password)) {
                            SecAddSharedWebCredential (nsDomain.Handle, nsAccount.Handle, nsPassword.Handle, (IntPtr) block_ptr_onComplete);
                        }
                    }
                    block_ptr_onComplete->CleanupBlock ();
                }
            }
        }
Example #5
0
        public void RegisterClassForCell(Type cellType, NSString reuseIdentifier)
        {
            if (cellType == null)
                throw new ArgumentNullException ("cellType");

            RegisterClassForCell (Class.GetHandle (cellType), reuseIdentifier);
        }
Example #6
0
 public bool RemoveTag(CGImageMetadataTag parent, NSString path)
 {
     IntPtr p = parent == null ? IntPtr.Zero : parent.Handle;
     if (path == null)
         throw new ArgumentNullException ("path");
     return CGImageMetadataRemoveTagWithPath (Handle, p, path.Handle);
 }
Example #7
0
		static CVPixelBuffer ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreVideoLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				PixelFormatTypeKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPixelFormatTypeKey");
				MemoryAllocatorKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferMemoryAllocatorKey");
				WidthKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferWidthKey");
				HeightKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferHeightKey");
				ExtendedPixelsLeftKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsLeftKey");
				ExtendedPixelsTopKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsTopKey");
				ExtendedPixelsRightKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsRightKey");
				ExtendedPixelsBottomKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsBottomKey");
				BytesPerRowAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferBytesPerRowAlignmentKey");
				CGBitmapContextCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferCGBitmapContextCompatibilityKey");
				CGImageCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferCGImageCompatibilityKey");
				OpenGLCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferOpenGLCompatibilityKey");
				IOSurfacePropertiesKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferIOSurfacePropertiesKey");
				PlaneAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPlaneAlignmentKey");
				CVImageBufferType = GetTypeID ();
				MetalCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferMetalCompatibilityKey");
#if !MONOMAC
				OpenGLESCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferOpenGLESCompatibilityKey");
#endif
			}
			finally {
				Dlfcn.dlclose (handle);
			}
		}
Example #8
0
        public UISegmentedControl(object [] args)
            : base(NSObjectFlag.Empty)
        {
            if (args == null)
                throw new ArgumentNullException ("args");

            NSObject [] nsargs = new NSObject [args.Length];

            for (int i = 0; i < args.Length; i++){
                object a = args [i];

                if (a == null)
                    throw new ArgumentNullException (String.Format ("Element {0} in args is null", i));

                if (a is string)
                    nsargs [i] = new NSString ((string) a);
                else if (a is UIImage)
                    nsargs [i] = (UIImage) a;
                else
                    throw new ArgumentException (String.Format ("non-string or UIImage at position {0} with type {1}", i, a.GetType ()));
            }
            using (NSArray nsa = NSArray.FromNSObjects (nsargs)){
                Handle = InitWithItems (nsa.Handle);
            }
        }
Example #9
0
 internal VTVideoEncoder(NSNumber codecType, NSString codecName, NSString displayName, NSString encoderId, NSString encoderName)
 {
     CodecType = codecType.Int32Value;
     CodecName = codecName;
     DisplayName = displayName;
     EncoderId = encoderId;
     EncoderName = encoderName;
 }
Example #10
0
        public void SetString(string value, string defaultName)
        {
            NSString str = new NSString (value);

            SetObjectForKey (str, defaultName);

            str.Dispose ();
        }
Example #11
0
 public CFException(string description, NSString domain, nint code, string failureReason, string recoverySuggestion)
     : base(description)
 {
     Code                = code;
     Domain              = domain;
     FailureReason       = failureReason;
     RecoverySuggestion  = recoverySuggestion;
 }
Example #12
0
		public static bool IsDeclared (string utType)
		{
			if (utType == null)
				throw new ArgumentNullException ("utType");

			using (var x = new NSString (utType)) 
				return UTTypeIsDeclared (x.Handle) != 0;
		}
Example #13
0
 public bool Remove(NSScriptCommandArgumentDescription arg)
 {
     if (arg == null)
         throw new ArgumentNullException ("arg");
     using (var nsName = new NSString (arg.Name)) {
         return Arguments?.Remove (nsName) ?? false;
     }
 }
Example #14
0
        public static string ToString(NSDictionary address, bool addCountryName)
        {
            if (address == null)
                throw new ArgumentNullException ("address");

            using (NSString s = new NSString (ABCreateStringWithAddressDictionary (address.Handle, addCountryName)))
                return s.ToString ();
        }
Example #15
0
        static NSHttpCookieStorage()
        {
            var handle = Libraries.Foundation.Handle;
            if (handle == IntPtr.Zero)
                return;

            CookiesChangedNotification = Dlfcn.GetStringConstant (handle, "NSHTTPCookieManagerAcceptPolicyChangedNotification");
            AcceptPolicyChangedNotification = Dlfcn.GetStringConstant (handle, "NSHTTPCookieManagerCookiesChangedNotification");
        }
Example #16
0
 public CGImageMetadataTag CopyTagMatchingImageProperty(NSString dictionaryName, NSString propertyName)
 {
     if (dictionaryName == null)
         throw new ArgumentNullException ("dictionaryName");
     if (propertyName == null)
         throw new ArgumentNullException ("propertyName");
     IntPtr result = CGImageMetadataCopyTagMatchingImageProperty (Handle, dictionaryName.Handle, propertyName.Handle);
     return result == IntPtr.Zero ? null : new CGImageMetadataTag (result);
 }
Example #17
0
 public bool SetTag(CGImageMetadataTag parent, NSString path, CGImageMetadataTag tag)
 {
     IntPtr p = parent == null ? IntPtr.Zero : parent.Handle;
     if (path == null)
         throw new ArgumentNullException ("path");
     if (tag == null)
         throw new ArgumentNullException ("tag");
     return CGImageMetadataSetTagWithPath (Handle, p, path.Handle, tag.Handle);
 }
Example #18
0
 public static Class GlobalGetClass(string codedName)
 {
     if (codedName == null)
         throw new ArgumentNullException ("codedName");
     using (var nsname = new NSString (codedName))
         return new Class (
                 XamCore.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (
                     class_ptr, Selector.GetHandle ("classForClassName:"), nsname.Handle));
 }
Example #19
0
 public NSObject this[NSString key]
 {
     get {
         return ObjectForKey (key);
     }
     set {
         SetObjectForKey (value, key);
     }
 }
Example #20
0
        static UIImagePickerController()
        {
            var handle = Libraries.UIKit.Handle;

            MediaType  = Dlfcn.GetStringConstant (handle, "UIImagePickerControllerMediaType");
            OriginalImage = Dlfcn.GetStringConstant (handle, "UIImagePickerControllerOriginalImage");
            EditedImage = Dlfcn.GetStringConstant (handle, "UIImagePickerControllerEditedImage");
            CropRect = Dlfcn.GetStringConstant (handle, "UIImagePickerControllerCropRect");
            MediaURL = Dlfcn.GetStringConstant (handle, "UIImagePickerControllerMediaURL");
        }
Example #21
0
        public static void GlobalSetClass(Class kls, string codedName)
        {
            if (codedName == null)
                throw new ArgumentNullException ("codedName");
            if (kls == null)
                throw new ArgumentNullException ("kls");

            using (var nsname = new NSString (codedName))
                XamCore.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle ("setClass:forClassName:"), kls.Handle, nsname.Handle);
        }
Example #22
0
 public override void Flush()
 {
     try {
         using (var ns = new NSString (sb.ToString ()))
             NSLog (format.Handle, ns.Handle);
         sb.Length = 0;
     }
     catch (Exception) {
     }
 }
Example #23
0
        public static void AddSuitePreferencesToApp(string applicationId, string suiteId)
        {
            if (applicationId == null) {
                throw new ArgumentNullException (applicationId);
            }

            using (var nsApplicationId = new NSString (applicationId)) {
                AddSuitePreferencesToApp (nsApplicationId, suiteId);
            }
        }
Example #24
0
 public void Add(NSScriptCommandArgumentDescription arg)
 {
     if (arg == null)
         throw new ArgumentNullException ("arg");
     if (Arguments == null)
         Arguments = new NSMutableDictionary ();
     using (var nsName = new NSString (arg.Name)) {
         Arguments.Add (nsName, arg.Dictionary);
     }
 }
Example #25
0
		static public NSLayoutConstraint [] FromVisualFormat (string format, NSLayoutFormatOptions formatOptions, params object [] viewsAndMetrics)
		{
			NSMutableDictionary views = null, metrics = null;
			var count = viewsAndMetrics.Length;
			if (count != 0){
				if ((count % 2) != 0)
					throw new ArgumentException ("You should provide pairs and values, the parameter passed is not even", "viewsAndMetrics");

				for (int i = 0; i < count; i+=2){
					var key = viewsAndMetrics [i];
					NSString nskey;

					if (key is string)
						nskey = new NSString ((string)key);
					else if (key is NSString)
						nskey = (NSString) key;
					else 
						throw new ArgumentException (String.Format ("Item at {0} is not a string or an NSString", i), "viewsAndMetrics");
					
					var value = viewsAndMetrics [i+1];
					if (value is View){
						if (views == null)
							views = new NSMutableDictionary ();
						views [nskey] = (NSObject) value;
						continue;
					} else if (value is INativeObject && Messaging.bool_objc_msgSend_IntPtr (((INativeObject) value).Handle, Selector.GetHandle ("isKindOfClass:"), Class.GetHandle (typeof (View)))) {
						if (views == null)
							views = new NSMutableDictionary ();
						views.LowlevelSetObject (((INativeObject) value).Handle, nskey.Handle);
						continue;
					}
#if !MONOMAC
					// This requires UILayoutSupport class which is not exist on Mac
					else if (value is INativeObject && Messaging.bool_objc_msgSend_IntPtr (((INativeObject) value).Handle, Selector.GetHandle ("conformsToProtocol:"), Protocol.GetHandle (typeof (UILayoutSupport).Name))) {
						if (views == null)
							views = new NSMutableDictionary ();
						views.LowlevelSetObject (((INativeObject) value).Handle, nskey.Handle);
						continue;
					}
#endif // !MONOMAC

					var number = AsNumber (value);
					if (number == null)
						throw new ArgumentException (String.Format ("Item at {0} is not a number or a view", i+1), "viewsAndMetrics");
					if (metrics == null)
						metrics = new NSMutableDictionary ();
					metrics [nskey] = number;
				}
			}
			if (views == null)
				throw new ArgumentException ("You should at least provide a pair of name, view", "viewAndMetrics");
			
			return FromVisualFormat (format, formatOptions, metrics, views);
		}
Example #26
0
 public bool RegisterNamespace(NSString xmlns, NSString prefix, out NSError error)
 {
     if (xmlns == null)
         throw new ArgumentNullException ("xmlns");
     if (prefix == null)
         throw new ArgumentNullException ("prefix");
     IntPtr err;
     bool result = CGImageMetadataRegisterNamespaceForPrefix (Handle, xmlns.Handle, prefix.Handle, out err);
     error = err == IntPtr.Zero ? null : new NSError (err);
     return result;
 }
Example #27
0
        public static void GlobalSetClassName(string name, Class kls)
        {
            if (name == null)
                throw new ArgumentNullException ("name");
            if (kls == null)
                throw new ArgumentNullException ("kls");

            var nsname = new NSString (name);
            XamCore.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle ("setClassName:forClass:"), nsname.Handle, kls.Handle);
            nsname.Dispose ();
        }
Example #28
0
        public NSObject AddObserver(NSString aName, Action<NSNotification> notify, NSObject fromObject)
        {
            if (notify == null)
                throw new ArgumentNullException ("notify");

            var proxy = new InternalNSNotificationHandler (this, notify);

            AddObserver (proxy, new Selector (postSelector), aName, fromObject);

            return proxy;
        }
Example #29
0
        public static void SaveToPhotosAlbum(string path, SaveStatus status)
        {
            if (path == null)
                throw new ArgumentNullException ("path");
            if (status == null)
                throw new ArgumentNullException ("status");
            UIApplication.EnsureUIThread ();
            var dis = new UIVideoStatusDispatcher (status);

            using (var ns = new NSString (path))
                UISaveVideoAtPathToSavedPhotosAlbum (ns.Handle, dis.Handle, Selector.GetHandle (UIVideoStatusDispatcher.callbackSelector), IntPtr.Zero);
        }
Example #30
0
		static internal AVLayerVideoGravity KeyToEnum (NSString key, bool clamp = true)
		{
			if (key == AVPlayerLayer.GravityResize)
				return AVLayerVideoGravity.Resize;
			if (key == AVPlayerLayer.GravityResizeAspectFill)
				return AVLayerVideoGravity.ResizeAspectFill;
			if (key == AVPlayerLayer.GravityResizeAspect)
				return AVLayerVideoGravity.ResizeAspect;
			if (clamp)
				return AVLayerVideoGravity.ResizeAspect;
			return (AVLayerVideoGravity) (-1);
		}
Example #31
0
 public static bool GetPromisedItemResourceValue(NSUrl This, NSObject value, NSString key, out NSError error)
 {
     return(This.GetPromisedItemResourceValue(out value, key, out error));
 }
Example #32
0
        public bool TryGetResource(NSString nsUrlResourceKey, out NSObject value)
        {
            NSError error;

            return(GetResourceValue(out value, nsUrlResourceKey, out error));
        }
Example #33
0
 public NSObject AddObserver(NSString aName, Action <NSNotification> notify)
 {
     return(AddObserver(aName, notify, null));
 }
 protected void SetStringValue(NSString key, string value)
 {
     SetStringValue(key, value == null ? (NSString)null : new NSString(value));
 }
Example #35
0
        public bool SetResource(NSString nsUrlResourceKey, NSObject value)
        {
            NSError error;

            return(SetResourceValue(value, nsUrlResourceKey, out error));
        }
Example #36
0
 public static NSString LocalizedFormat(string format, params object [] args)
 {
     using (var ns = new NSString(format))
         return(LocalizedFormat(ns, args));
 }
Example #37
0
 public bool SetResource(string key, NSObject value, out NSError error)
 {
     using (var nsKey = new NSString(key))
         return(SetResourceValue(value, nsKey, out error));
 }