Example #1
0
        public static void DecideUse(NSObject decisionToken)
        {
            if (decisionToken == null)
                throw new ArgumentNullException ("token");

            XamCore.ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selUse);
        }
Example #2
0
 public static void RemoveDoubleAction(NSObject target, EventHandler doubleHandler)
 {
     ActionDispatcher ctarget = target as ActionDispatcher;
     if (ctarget == null)
         return;
     ctarget.DoubleActivated -= doubleHandler;
 }
Example #3
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 #4
0
        IntPtr InitNSThread(NSObject target, Selector selector, NSObject argument)
        {
            if (target == null)
                throw new ArgumentNullException ("target");
            if (selector == null)
                throw new ArgumentNullException ("selector");

            return xamarin_init_nsthread (IsDirectBinding ? this.Handle : this.SuperHandle, IsDirectBinding, target.Handle, selector.Handle, argument == null ? IntPtr.Zero : argument.Handle);
        }
Example #5
0
 static CGRect RectangleFFrom(NSObject key, NSNotification n)
 {
     if (n == null || n.UserInfo == null)
         throw new ArgumentNullException ("n");
     var val = n.UserInfo [key] as NSValue;
     if (val != null)
         return val.CGRectValue;
     return CGRect.Empty;
 }
Example #6
0
        internal static Class GetClass(NSObject instance, string parameterName)
        {
            if (instance == null)
                throw new ArgumentNullException (parameterName);

            var klass = instance.Class;
            if ((klass == null) || (klass.Handle == IntPtr.Zero))
                throw new ArgumentException ("Not an type exposed to ObjC", parameterName);

            return klass;
        }
Example #7
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 #8
0
        void RemoveObserversFromList(NSObject observer, string aName, NSObject anObject)
        {
            for (int i = __mt_ObserverList_var.Count - 1; i >= 0; i--) {
                ObservedData od = __mt_ObserverList_var [i];

                if (observer != od.Observer)
                    continue;

                if (aName != null && aName != od.Name)
                    continue;

                if (anObject != null && anObject != od.Object)
                    continue;

                __mt_ObserverList_var.RemoveAt (i);
            }
        }
Example #9
0
 public void PresentController(string [] names, string [] contexts)
 {
     NSObject[] array = null;
     try {
         if (contexts != null) {
             array = new NSObject [contexts.Length];
             for (int i = 0; i < array.Length; i++)
                 array [i] = new NSString (contexts [i]);
         }
         PresentController (names, array);
     }
     finally {
         if (array != null) {
             foreach (var ns in array)
                 ns.Dispose ();
         }
     }
 }
Example #10
0
 public NSObject AddObserver(string aName, Action <NSNotification> notify, NSObject fromObject)
 {
     return(AddObserver(new NSString(aName), notify, fromObject));
 }
Example #11
0
		public static NSLayoutConstraint Create (NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation)
		{
			return NSLayoutConstraint.Create (view1, attribute1, relation, null, NSLayoutAttribute.NoAttribute, 1.0f, 0f);
		}
Example #12
0
 public static void ReleaseNative(IntPtr handle)
 {
     NSObject.DangerousRelease(handle);
 }
Example #13
0
 // typedef uint32_t UIAccessibilityNotifications
 public static void PostNotification(UIAccessibilityPostNotification notification, NSObject argument)
 {
     PostNotification (NotificationEnumToInt (notification), argument);
 }
Example #14
0
 internal void SetValue(string key, NSObject value)
 {
     using (var nskey = new NSString (key)){
         SetValueForKey (value, nskey);
     }
 }
Example #15
0
 public void AddObserver(NSObject observer, Selector aSelector, string aName, string anObject)
 {
 }
Example #16
0
		public static NSString LocalizedFormat (NSString format, params object [] args)
		{
			int argc = args.Length;
			var nso = new NSObject [argc];
			for (int i = 0; i < argc; i++)
				nso [i] = NSObject.FromObject (args [i]);
				
			return LocalizedFormat (format, nso);
		}
Example #17
0
        public VTStatus SetProperty(NSString propertyKey, NSObject value)
        {
            if (propertyKey == null)
                throw new ArgumentNullException ("propertyKey");

            return VTSessionSetProperty (handle, propertyKey.Handle, value != null ? value.Handle : IntPtr.Zero);
        }
Example #18
0
 public void SetArray(string key, NSObject [] value)
 {
     _SetArray (value, key);
 }
Example #19
0
 static extern void NSShowAnimationEffect(nuint animationEffect, CGPoint centerLocation, CGSize size, NSObject animationDelegate, Selector didEndSelector, IntPtr contextInfo);
Example #20
0
 public static void ShowAnimationEffect(NSAnimationEffect animationEffect, CGPoint centerLocation, CGSize size, NSObject animationDelegate, Selector didEndSelector, IntPtr contextInfo)
 {
     NSShowAnimationEffect ((nuint)(ulong)animationEffect, centerLocation, size, animationDelegate, didEndSelector, contextInfo);
 }
Example #21
0
 public virtual void PerformSelector(Selector sel, NSObject obj, float delay)
 {
     PerformSelector(sel, obj, (double)delay);
 }
Example #22
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);
        }
Example #23
0
 // This solves the duplicate selector export problem while not breaking the API.
 public static NSLayoutConstraint Create(NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation, 
     NSObject view2, NSLayoutAttribute attribute2, nfloat multiplier, nfloat constant)
 {
     return Create ((INativeObject) view1, attribute1, relation, view2, attribute2, multiplier, constant);
 }
Example #24
0
        internal NSDictionary ToDictionary()
        {
            int n = 0;
            var font = Font;
            if (font != null)
                n++;
            var text_color = TextColor;
            if (text_color != null)
                n++;
            var text_shadow_color = TextShadowColor;
            if (text_shadow_color != null)
                n++;
            var text_shadow_offset = TextShadowOffset;
            if (text_shadow_offset.Horizontal != 0 || text_shadow_offset.Vertical != 0)
                n++;
            if (n == 0)
                return new NSDictionary ();

            var keys = new NSObject [n];
            var values = new NSObject [n];
            n = 0;
            if (font != null){
                keys [n] = UITextAttributesConstants.Font;
                values [n] = font;
                n++;
            }
            if (text_color != null){
                keys [n] = UITextAttributesConstants.TextColor;
                values [n] = text_color;
                n++;
            }
            if (text_shadow_color != null){
                keys [n] = UITextAttributesConstants.TextShadowColor;
                values [n] = text_shadow_color;
                n++;
            }
            if (text_shadow_offset.Horizontal != 0 || text_shadow_offset.Vertical != 0){
                keys [n] = UITextAttributesConstants.TextShadowOffset;
                values [n] = NSValue.FromUIOffset (text_shadow_offset);
            }
            using (NSArray avalues = NSArray.FromObjects (values),
                   akeys = NSArray.FromObjects (keys)){
                return NSDictionary.FromObjectsAndKeysInternal (avalues, akeys);
            }
        }
Example #25
0
		public static NSString LocalizedFormat (NSString format, NSObject [] args)
		{
			switch (args.Length){
			case 0:
				return new NSString (xamarin_localized_string_format (format.Handle));
			case 1:
				return new NSString (xamarin_localized_string_format_1 (format.Handle, args[0].Handle));
			case 2:
				return new NSString (xamarin_localized_string_format_2 (format.Handle, args[0].Handle, args[1].Handle));
			case 3:
				return new NSString (xamarin_localized_string_format_3 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle));
			case 4:
				return new NSString (xamarin_localized_string_format_4 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle, args[3].Handle));
			case 5:
				return new NSString (xamarin_localized_string_format_5 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle, args[3].Handle, args[4].Handle));
			case 6:
				return new NSString (xamarin_localized_string_format_6 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle, args[3].Handle, args[4].Handle, args[5].Handle));
			case 7:
				return new NSString (xamarin_localized_string_format_7 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle, args[3].Handle, args[4].Handle, args[5].Handle, args[6].Handle));
			case 8:
				return new NSString (xamarin_localized_string_format_8 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle, args[3].Handle, args[4].Handle, args[5].Handle, args[6].Handle, args[7].Handle));
			case 9:
				return new NSString (xamarin_localized_string_format_9 (format.Handle, args[0].Handle, args[1].Handle, args[2].Handle, args[3].Handle, args[4].Handle, args[5].Handle, args[6].Handle, args[7].Handle, args[8].Handle));
			default:
				throw new Exception ("Unsupported number of arguments, maximum number is 9");
			}
		}
Example #26
0
 public SKKeyframeSequence(NSObject [] values, NSNumber [] times)
     : this(values, NSArray.FromNSObjects (times))
 {
 }
Example #27
0
 public void RemoveObserver(NSObject observer, string aName, string anObject)
 {
 }
Example #28
0
 public void AddObserver(NSObject observer, Selector aSelector, string aname, NSObject anObject)
 {
     AddObserver(observer, aSelector, new NSString(aname), anObject);
 }
Example #29
0
 public void SetWebScriptValueAtIndex(int /* unsigned int */ index, NSObject value)
 {
     SetWebScriptValueAtIndexvalue (index, value);
 }
Example #30
0
 public bool SetValueMatchingImageProperty(NSString dictionaryName, NSString propertyName, NSObject value)
 {
     if (value == null)
         throw new ArgumentNullException ("value");
     return SetValueMatchingImageProperty (dictionaryName, propertyName, value.Handle);
 }
Example #31
0
 public static void PostNotification(int notification, NSObject argument)
 {
     UIAccessibilityPostNotification (notification, argument == null ? IntPtr.Zero : argument.Handle);
 }
Example #32
0
		public static NSLayoutConstraint Create (NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation, nfloat multiplier, nfloat constant)
		{
			return NSLayoutConstraint.Create (view1, attribute1, relation, null, NSLayoutAttribute.NoAttribute, multiplier, constant);
		}
Example #33
0
 public SKKeyframeSequence(NSObject [] values, double [] times)
     : this(values, Convert (times))
 {
 }
Example #34
0
 public bool SetValue(CGImageMetadataTag parent, NSString path, NSObject value)
 {
     if (value == null)
         throw new ArgumentNullException ("value");
     return SetValue (parent, path, value.Handle);
 }