コード例 #1
0
        public virtual NSData AuthenticationDataForComponents(NSArray components)
        {
            NSUInteger idx1;
            int idx2;
            NSUInteger count = components.Count;
            byte checksum = 0;

            // Compute authentication data for the components in the
            // given array.  There are two types of components, NSPorts
            // and NSDatas.  You should ignore a component of a type
            // which you don't understand.

            // Here, we compute a trivial 1 byte checksum over all the
            // bytes in the NSData objects in the array.
            for (idx1 = 0; idx1 < count; idx1++) {
                NSObject item = components.ObjectAtIndex (idx1).CastTo<NSObject> ();
                if (!item.IsKindOfClass (NSData.NSDataClass)) {
                    continue;
                }
                NSData data = item.CastTo<NSData> ();
                byte[] buffer = data.GetBuffer ();
                for (idx2 = 0; idx2 < buffer.Length; idx2++) {
                    checksum ^= buffer[idx2];
                }
            }

            return new NSData (new byte[] { checksum }).Autorelease<NSData> ();
        }
		public override void DidChangeAnnotation (PSPDFAnnotation annotation, PSPDFAnnotation originalAnnotation, NSArray keyPaths, NSDictionary options)
		{
			if(annotation is IKSAnnotation)
			{
				Console.WriteLine("Custom annotation changed: " + annotation);
			}
		}
コード例 #3
0
        void SetLayoutIdentifierForArray (NSString identifier, NSArray constraintsArray)
		{
			for (nuint i = 0; i < constraintsArray.Count; i++) {
				var constraint = constraintsArray.GetItem<NSLayoutConstraint> (i);
				constraint.SetIdentifier (identifier);
			}
        }
コード例 #4
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			TableView = new UITableView (this.View.Frame, UITableViewStyle.Grouped);
			TableView.Delegate = this.TableView.Delegate;
			TableView.DataSource = this.TableView.DataSource;
			this.View.AddSubview (this.TableView);
			TableView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

			UIColor tableViewBackgroundColor = new UIColor (110.0F / 255.0F, 113.0F / 255.0F, 115.0F / 255.0F, 1.0F);
			UIColor barColor = new UIColor (161.0F / 255.0F, 164.0F / 255.0F, 166.0F / 255.0F, 1.0F);

			this.TableView.BackgroundColor = tableViewBackgroundColor;
			this.TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
			this.View.BackgroundColor = new UIColor (161.0F / 255.0F, 164.0F / 255.0F, 166.0F / 255.0F, 1.0F);
			//if(this.NavigationController.NavigationBar RespondsToSelector(UIAppearance.SelectorAppearance)){
			this.NavigationController.NavigationBar.BarTintColor = barColor;

			UIColor titleColor = new UIColor (55.0F / 255.0F, 70.0F / 255.0F, 77.0F / 255.0F, 1.0F);

			this.NavigationController.NavigationBar.SetTitleTextAttributes (new UITextAttributes (){ TextColor = titleColor });

			this.DrawerWidths = NSArray.FromStrings (new string[] { "160", "200", "240", "280", "320" });
			SizeF logoSize = new SizeF (58F, 62F);
			MMLogoView logo = new MMLogoView (this.View.Frame);
			logo.Frame = new RectangleF (this.TableView.Bounds.GetMidX () - logoSize.Width / 2.0F, -logoSize.Height - logoSize.Height / 4.0F, logoSize.Width, logoSize.Height);
			logo.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
			this.TableView.AddSubview (logo);
			this.View.BackgroundColor = UIColor.Clear;
		}
コード例 #5
0
        public override void ViewDidLoad()
        {
            colors = NSArray.FromNSObjects (UIColor.Red, UIColor.Orange, UIColor.Yellow,
                                            UIColor.Green, UIColor.Blue, UIColor.Purple);

            View.BackgroundColor = colors.GetItem<UIColor> (colorIndex);
            colorIndex = (colorIndex + 1) % colors.Count;
        }
コード例 #6
0
        /// <summary>
        /// <para>Displays one or more certificates in a modal sheet.</para>
        /// <para>Original signature is '- (void)beginSheetForWindow:(NSWindow *)docWindow modalDelegate:(id)delegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo certificates:(NSArray *)certificates showGroup:(BOOL)showGroup'</para>
        /// <para>Available in Mac OS X v10.3 and later.</para>
        /// </summary>
        /// <param name="docWindow">The parent window to which the sheet is attached.</param>

        /// <param name="modalDelegate">The delegate object in which the method specified in the didEndSelector parameter is implemented.</param>
        /// <param name="contextInfo">A pointer to data that is passed to the delegate method. You can use this data pointer for any purpose you wish.</param>
        /// <param name="certificates">The certificates to display. Pass an NSArray containing one or more objects of type SecCertificateRef in this parameter. The first certificate in the array must be the leaf certificate. The other certificates (if any) can be included in any order.</param>
        /// <param name="showGroup">Specifies whether additional certificates (other than the leaf certificate) are displayed.</param>
        public void BeginSheetForWindowModalDelegateDidEndSelectorContextInfoCertificatesShowGroup(NSWindow docWindow, SheetDidEndReturnCodeContextInfoEventHandler<SFCertificateTrustPanel> modalDelegate, IntPtr contextInfo, NSArray certificates,
                                                                                                   bool showGroup)
        {

            SFCertificateTrustPanelSheetDispatcher sheetDispatcher = new SFCertificateTrustPanelSheetDispatcher(modalDelegate);
            ObjectiveCRuntime.SendMessage(this, "beginSheetForWindow:modalDelegate:didEndSelector:contextInfo:certificates:showGroup:", docWindow, sheetDispatcher, ObjectiveCRuntime.Selector("panelDidEnd:returnCode:contextInfo:"), contextInfo, certificates,
                                          showGroup);
        }
コード例 #7
0
        public override id InitWithCoder(NSCoder decoder)
        {
            id self = this;

            base.InitWithCoder(decoder);

            OrderedObjects = (NSArray)decoder.DecodeObjectForKey("orderedObjects");

            return self;
        }
コード例 #8
0
 private void allocateMemoryWithLoopSize(UInt32 loopSize, UInt32 blockSize)
 {
     for (UInt32 i = 0; i < loopSize; i++) {
         NSData data = new NSMutableData(blockSize);
         NSArray array = new NSMutableArray((Int32)blockSize);
         NSSet set = new NSMutableSet((Int32)blockSize);
         this.dataProp = data;
         this.arrayProp = array;
         this.setProp = set;
     }
 }
コード例 #9
0
        static SCNMatrix4[] FromNSArray(NSArray nsa)
        {
            if (nsa == null)
                return null;

            var count = nsa.Count;
            var ret = new SCNMatrix4 [count];
            for (nuint i = 0; i < count; i++)
                ret [i] = Runtime.GetNSObject<NSValue> (nsa.ValueAt (i)).SCNMatrix4Value;

            return ret;
        }
コード例 #10
0
ファイル: Extras.cs プロジェクト: kingyond/Xamarin-v3
        public static NSArray PostprocessAnnotationInLegacyFormat(PSPDFAnnotation [] annotations)
        {
            var objs = new List<NSObject>();

            foreach (var annotation in annotations)
                objs.Add(annotation);

            NSArray arry = NSArray.FromNSObjects(objs.ToArray ());
            var resArray = new NSArray (_PostprocessAnnotationInLegacyFormat (arry.Handle));

            return resArray;
        }
            public override void DidRangeBeacons(ESTBeaconManager manager, NSArray[] beacons, ESTBeaconRegion region)
            {
                if(beacons.Length > 0)
                {
                    if(selectedBeacon == null)
                    {
                        // initialy pick closest beacon
                        selectedBeacon = (ESTBeacon)beacons.GetValue(0);
                    }
                    else
                    {
                        for(int i=0;i<beacons.Length;i++)
                        {
                            ESTBeacon cBeacon = (ESTBeacon)beacons.GetValue(i);
                            // update beacon if same as selected initially
                            if(selectedBeacon.Ibeacon.Major.UInt16Value == cBeacon.Ibeacon.Major.UInt16Value
                                && selectedBeacon.Ibeacon.Minor.UInt16Value == cBeacon.Ibeacon.Minor.UInt16Value)
                            {
                                selectedBeacon = cBeacon;
                            }
                        }
                    }

                    // beacon array is sorted based on distance
                    // closest beacon is the first one
                    string labelTextStr = String.Format("Beacon: {0} \nMajor: {1}, Minor: {2}\nRSSI: {3}\nRegion: ",
                        selectedBeacon.Ibeacon.ProximityUuid.AsString(),
                        selectedBeacon.Ibeacon.Major.UInt16Value,
                        selectedBeacon.Ibeacon.Minor.UInt16Value,
                        selectedBeacon.Ibeacon.Rssi
                        );

                    // calculate and set new y position
                    switch(selectedBeacon.Ibeacon.Proximity)
                    {
                        case CLProximity.Unknown:
                            labelTextStr += "Unknown";
                        break;
                        case CLProximity.Immediate:
                            labelTextStr += "Immediate";
                        break;
                        case CLProximity.Near:
                            labelTextStr += "Near";
                        break;
                        case CLProximity.Far:
                            labelTextStr += "Far";
                        break;
                    }

                    NSString labelText = new NSString(labelTextStr);
                    _distanceLabel.Text = labelText;
                }
            }
コード例 #12
0
        public virtual void Awake(NSArray rootObjects, IBObjectContainer objects, NSDictionary context)
        {
            NSEnumerator en;
            id obj;
            NSMutableArray topLevelObjects = (NSMutableArray)context.ObjectForKey((id)NS.NibTopLevelObjects);
            id owner = context.ObjectForKey(NS.NibOwner);
            id first = null;
            id app = null;

            // Get the file's owner and NSApplication object references...
            if (((NSCustomObject)rootObjects.ObjectAtIndex(1)).ClassName.IsEqualToString(@"FirstResponder"))
                first = ((NSCustomObject)rootObjects.ObjectAtIndex(1)).RealObject;
            else
                NS.Log(@"%s:first responder missing\n", "Awake");

            if (((NSCustomObject)rootObjects.ObjectAtIndex(2)).ClassName.IsEqualToString(@"NSApplication"))
                app = ((NSCustomObject)rootObjects.ObjectAtIndex(2)).RealObject;
            else
                NS.Log(@"%s:NSApplication missing\n", "Awake");

            // Use the owner as first root object
            ((NSCustomObject)rootObjects.ObjectAtIndex(0)).SetRealObject(owner);
            en = rootObjects.ObjectEnumerator();
            while ((obj = en.NextObject()) != null)
            {
                if (obj.RespondsToSelector(new SEL("NibInstantiate")))
                {
                    obj = (id)Objc.MsgSend(obj, "NibInstantiate", null);
                }

                // IGNORE file's owner, first responder and NSApplication instances...
                if ((obj != null) && (obj != owner) && (obj != first) && (obj != app))
                {
                    topLevelObjects.AddObject(obj);
                    // All top level objects must be released by the caller to avoid
                    // leaking, unless they are going to be released by other nib
                    // objects on behalf of the owner.
                    //RETAIN(obj);
                }

                //FIXME
                //if ((obj.IsKindOfClass(NSMenu.Class)) &&
                //    (((NSMenu)obj _isMainMenu]))
                //  {
                //    // add the menu...
                //    NSApp._setMainMenu(obj);
                //  }
            }

            // Load connections and awaken objects
            Objc.MsgSend(objects, "NibInstantiate", null);
        }
コード例 #13
0
		public static NSArray ParseArray(XmlNode node)
		{
			NSArray array = new NSArray();
			int count = node.ChildNodes.Count;
			for (int i = 0; i < count; i++) {
				object result = Parse(node.ChildNodes[i]);
				if (result != null)
				{
					array.Add(result);
				}		
			}
            return array;
        }
コード例 #14
0
		static Dictionary<string, NSObject>[] ParseShortcuts (NSArray items)
		{
			var count = (int)items.Count;
			var result = new Dictionary<string, NSObject>[count];
			for (int i = 0; i < count; i++) {
				var nDict = items.GetItem<NSDictionary> ((nuint)i);
				var dict = result [i] = new Dictionary<string, NSObject> ();
				foreach (var kvp in nDict)
					dict [(NSString)kvp.Key] = kvp.Value;
			}

			return result;
		}
コード例 #15
0
        public virtual bool AuthenticateComponentsWithData(NSArray components, NSData authenticationData)
        {
            // Verify the authentication data against the components.  A good
            // authenticator would have a way of verifying the signature without
            // recomputing it.  We don't, in this example, so just recompute.
            NSData recomputedSignature = this.AuthenticationDataForComponents (components);

            // If the two NSDatas are not equal, authentication failure!
            if (!recomputedSignature.IsEqual (authenticationData)) {
                Console.WriteLine ("received signature {0} doesn't match computed signature {1}", authenticationData, recomputedSignature);
                return false;
            }
            return true;
        }
コード例 #16
0
        static NSArray ToNSArray(SCNMatrix4 [] items)
        {
            if (items == null)
                return new NSArray (true);

            var count = items.Length;
            var buf = Marshal.AllocHGlobal ((IntPtr)(count * IntPtr.Size));

            for (nint i = 0; i < count; i++) {
                var item = NSValue.FromSCNMatrix4 (items [i]);
                var h = item == null ? NSNull.Null.Handle : item.Handle;
                Marshal.WriteIntPtr (buf, (int)(i * IntPtr.Size), h);
            }

            var nsa = new NSArray (NSArray.FromObjects (buf, count));
            Marshal.FreeHGlobal (buf);

            return nsa;
        }
コード例 #17
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			

			controls = new NSMutableArray ();

			// Fetching data from plist files

			string controlListPathString 	= NSBundle.MainBundle.BundlePath+"/ControlList.plist";
			controlDict 					= new NSDictionary();
			controlDict 					= NSDictionary.FromFile(controlListPathString);
			NSString controlDictKey 		= new NSString ("Control");
		    controlDictArray 				= controlDict.ValueForKey (controlDictKey) as NSArray;

			this.PrepareControlList ();

			// Register the TableView's data source
			TableView.Source = new AllControlsViewSource (this);

		}
コード例 #18
0
        UIImage[] GetImageArray(IntPtr handle)
        {
            using (var array = new NSArray (handle)) {
                var ret = new UIImage [array.Count];
                for (uint i = 0; i < ret.Length; i++) {
                    var obj = Runtime.GetNSObject (array.ValueAt (i));
                    var data = obj as NSData;
                    UIImage img;

                    if (data != null) {
                        img = new UIImage (data);
                    } else {
                        img = (UIImage) obj;
                    }

                    ret [i] = img;
                }

                return ret;
            }
        }
コード例 #19
0
        public NSArray AllKeywords()
        {
            NSArray array = new NSArray();
            array.Autorelease();

            if (this._allKeywords == null)
            {
                uint i, count;

                this._allKeywords = this._builtInKeywords.MutableCopy<NSMutableArray>();

                count = array.Count;
                for (i = 0; i < count; i++)
                {
                    if (this._allKeywords.IndexOfObject(array.ObjectAtIndex(i)) == NSUInteger.NSNotFound)
                    {
                        this._allKeywords.AddObject(array.ObjectAtIndex(i));
                    }
                }

                this._allKeywords.SortUsingSelector(ObjectiveCRuntime.Selector("compare:"));
            }
            return this._allKeywords;
        }
コード例 #20
0
        public override void DidRangeBeacons(ESTBeaconManager manager, NSArray[] beacons, ESTBeaconRegion region)
        {
            ESTBeacon beacon = (ESTBeacon)beacons.GetValue (0);

            if (beacon.Ibeacon.Proximity == CLProximity.Near) {
                label.Text = "It's Near";
                imageView.Image = UIImage.FromFile ("near_image.PNG");
            }

            if (beacon.Ibeacon.Proximity == CLProximity.Far) {
                label.Text = "It's Far";
                imageView.Image = UIImage.FromFile ("far_image.PNG");
            }

            if (beacon.Ibeacon.Proximity == CLProximity.Immediate) {
                label.Text = "It's Immediate";
                imageView.Image = UIImage.FromFile ("immediate_image.PNG");
            }

            if (beacon.Ibeacon.Proximity == CLProximity.Unknown) {
                label.Text = "It's Unknown";
                imageView.Image = UIImage.FromFile ("unknown_image.PNG");
            }
        }
コード例 #21
0
 public MPMediaItemCollection GetCollection(xint index)
 {
     using (var array = new NSArray(Messaging.IntPtr_objc_msgSend(Handle, Selector.GetHandle("collections"))))
         return(array.GetItem <MPMediaItemCollection> (index));
 }
コード例 #22
0
        public static NSObject [] GetExtensionKeysCommonWithImageBuffers()
        {
            var arr = CMVideoFormatDescriptionGetExtensionKeysCommonWithImageBuffers();

            return(NSArray.ArrayFromHandle <NSString> (arr));
        }
コード例 #23
0
 public MPMediaItem GetItem(xint index)
 {
     using (var array = new NSArray(Messaging.IntPtr_objc_msgSend(Handle, Selector.GetHandle("items"))))
         return(array.GetItem <MPMediaItem> (index));
 }
コード例 #24
0
ファイル: PListObject.cs プロジェクト: zheref/monodevelop
        internal static PObject Conv(NSObject val)
        {
            if (val == null)
            {
                return(null);
            }
            if (val is NSDictionary)
            {
                var result = new PDictionary();
                foreach (var pair in (NSDictionary)val)
                {
                    string k = pair.Key.ToString();
                    result[k] = Conv(pair.Value);
                }
                return(result);
            }

            if (val is NSArray)
            {
                var result = new PArray();
                var arr    = NSArray.ArrayFromHandle <NSObject> (((NSArray)val).Handle);
                if (arr == null)
                {
                    return(null);
                }
                foreach (var f in arr)
                {
                    if (f != null)
                    {
                        result.Add(Conv(f));
                    }
                }
                return(result);
            }

            if (val is NSString)
            {
                return(((NSString)val).ToString());
            }
            if (val is NSNumber)
            {
                var nr  = (NSNumber)val;
                var str = Marshal.PtrToStringAnsi(MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend(val.Handle, selObjCType));
                if (str == "c" || str == "C" || str == "B")
                {
                    return(nr.BoolValue);
                }
                return(nr.Int32Value);
            }
            if (val is NSDate)
            {
                return(PDate.referenceDate + TimeSpan.FromSeconds(((NSDate)val).SecondsSinceReferenceDate));
            }

            if (val is NSData)
            {
                var data  = (NSData)val;
                var bytes = new byte[data.Length];
                Marshal.Copy(data.Bytes, bytes, 0, (int)data.Length);
                return(bytes);
            }

            throw new NotSupportedException(val.ToString());
        }
コード例 #25
0
        internal NSDictionary ToDictionary()
        {
            int n = 0;

            if (Enhance.HasValue && Enhance.Value == false)
            {
                n++;
            }
            if (RedEye.HasValue && RedEye.Value == false)
            {
                n++;
            }
            if (ImageOrientation.HasValue)
            {
                n++;
            }
            if (Features != null && Features.Length != 0)
            {
                n++;
            }
            if (AutoAdjustCrop.HasValue && AutoAdjustCrop.Value == true)
            {
                n++;
            }
            if (AutoAdjustLevel.HasValue && AutoAdjustLevel.Value == true)
            {
                n++;
            }
            if (n == 0)
            {
                return(null);
            }

            NSMutableDictionary dict = new NSMutableDictionary();

            if (Enhance.HasValue && Enhance.Value == false)
            {
                dict.LowlevelSetObject(CFBoolean.False.Handle, CIImage.AutoAdjustEnhanceKey.Handle);
            }
            if (RedEye.HasValue && RedEye.Value == false)
            {
                dict.LowlevelSetObject(CFBoolean.False.Handle, CIImage.AutoAdjustRedEyeKey.Handle);
            }
            if (Features != null && Features.Length != 0)
            {
                dict.LowlevelSetObject(NSArray.FromObjects(Features), CIImage.AutoAdjustFeaturesKey.Handle);
            }
            if (ImageOrientation.HasValue)
            {
                dict.LowlevelSetObject(new NSNumber((int)ImageOrientation.Value), global::ImageIO.CGImageProperties.Orientation.Handle);
            }
            if (AutoAdjustCrop.HasValue && AutoAdjustCrop.Value == true)
            {
                dict.LowlevelSetObject(CFBoolean.True.Handle, CIImage.AutoAdjustCrop.Handle);
            }
            if (AutoAdjustLevel.HasValue && AutoAdjustLevel.Value == true)
            {
                dict.LowlevelSetObject(CFBoolean.True.Handle, CIImage.AutoAdjustLevel.Handle);
            }

#if false
            for (i = 0; i < n; i++)
            {
                Console.WriteLine("{0} {1}-{2}", i, keys [i], values [i]);
            }
#endif
            return(dict);
        }
コード例 #26
0
ファイル: IssueTest.cs プロジェクト: deriyuval/plist-cil
 public static void TestIssue30()
 {
     #pragma warning disable 219
     NSArray arr = (NSArray)PropertyListParser.Parse(new FileInfo("test-files/issue30.plist"));
     #pragma warning restore 219
 }
コード例 #27
0
ファイル: TreeViewBackend.cs プロジェクト: TilmanGriesel/xwt
 public override bool OutlineViewwriteItemstoPasteboard(NSOutlineView outlineView, NSArray items, NSPasteboard pboard)
 {
     return(false);
 }
コード例 #28
0
ファイル: NSView.cs プロジェクト: smartmobili/CocoaBuilder
        public virtual void SetSubviews(NSArray newSubviews)
        {
            NSEnumerator en;
            NSView aView;
            NSMutableArray uniqNew = NSMutableArray.Array();

            if (null == newSubviews)
            {
                NSException.Raise(@"NSInvalidArgumentException" ,@"Setting nil as new subviews.");
            }

            // Use a copy as we remove from the subviews array
            en = NSArray.ArrayWithArray(_sub_views).ObjectEnumerator();
            while ((aView = (NSView)en.NextObject()) != null)
            {
                if (false == newSubviews.ContainsObject(aView))
                {
                    aView.RemoveFromSuperview();
                }
            }

            en = newSubviews.ObjectEnumerator();
            while ((aView = (NSView)en.NextObject()) != null)
            {
                id supersub = aView.Superview;

                if (supersub != null && supersub != this)
                {
                    NSException.Raise(@"NSInvalidArgumentException" ,@"Superviews of new subviews must be either nil or receiver.");
                }

                if (uniqNew.ContainsObject(aView))
                {
                    NSException.Raise(@"NSInvalidArgumentException" ,@"Duplicated new subviews.");
                }

                if (false == _sub_views.ContainsObject(aView))
                {
                    this.AddSubview(aView);
                }

                uniqNew.AddObject(aView);
            }

            _sub_views = uniqNew;

            // The order of the subviews may have changed
            this.SetNeedsDisplay(true);
        }
コード例 #29
0
 public void EnumerateDraggingItems(NSDraggingItemEnumerationOptions enumOpts, NSView view, NSArray classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator)
 {
     EnumerateDraggingItems (enumOpts, view, classArray.Handle, searchOptions, enumerator);
 }
コード例 #30
0
        internal NSDictionary ToDictionary()
        {
            var dict = new NSMutableDictionary();

            if (ElapsedPlaybackTime.HasValue)
            {
                dict.Add(MPNowPlayingInfoCenter.PropertyElapsedPlaybackTime, new NSNumber(ElapsedPlaybackTime.Value));
            }
            if (PlaybackRate.HasValue)
            {
                dict.Add(MPNowPlayingInfoCenter.PropertyPlaybackRate, new NSNumber(PlaybackRate.Value));
            }
            if (PlaybackQueueIndex.HasValue)
            {
                dict.Add(MPNowPlayingInfoCenter.PropertyPlaybackQueueIndex, new NSNumber(PlaybackQueueIndex.Value));
            }
            if (PlaybackQueueCount.HasValue)
            {
                dict.Add(MPNowPlayingInfoCenter.PropertyPlaybackQueueCount, new NSNumber(PlaybackQueueCount.Value));
            }
            if (ChapterNumber.HasValue)
            {
                dict.Add(MPNowPlayingInfoCenter.PropertyChapterNumber, new NSNumber(ChapterNumber.Value));
            }
            if (ChapterCount.HasValue)
            {
                dict.Add(MPNowPlayingInfoCenter.PropertyChapterCount, new NSNumber(ChapterCount.Value));
            }
            if (DefaultPlaybackRate.HasValue)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyDefaultPlaybackRate, new NSNumber(DefaultPlaybackRate.Value));
            }

            if (AvailableLanguageOptions != null && AvailableLanguageOptions.Length != 0)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyAvailableLanguageOptions, NSArray.FromObjects(AvailableLanguageOptions));
            }
            if (CurrentLanguageOptions != null && CurrentLanguageOptions.Length != 0)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyCurrentLanguageOptions, NSArray.FromObjects(CurrentLanguageOptions));
            }
            if (CollectionIdentifier != null)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyCollectionIdentifier, new NSString(CollectionIdentifier));
            }
            if (ExternalContentIdentifier != null)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyExternalContentIdentifier, new NSString(ExternalContentIdentifier));
            }
            if (ExternalUserProfileIdentifier != null)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyExternalUserProfileIdentifier, new NSString(ExternalUserProfileIdentifier));
            }
            if (PlaybackProgress.HasValue)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyPlaybackProgress, new NSNumber(PlaybackProgress.Value));
            }
            if (MediaType.HasValue)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyMediaType, new NSNumber((int)MediaType.Value));
            }
            if (IsLiveStream.HasValue)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyIsLiveStream, new NSNumber(IsLiveStream.Value));
            }
            if (AssetUrl != null)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyAssetUrl, AssetUrl);
            }
            if (CurrentPlaybackDate != null)
            {
                Add(dict, MPNowPlayingInfoCenter.PropertyCurrentPlaybackDate, CurrentPlaybackDate);
            }

            if (AlbumTrackCount.HasValue)
            {
                dict.Add(MPMediaItem.AlbumTrackCountProperty, new NSNumber(AlbumTrackCount.Value));
            }
            if (AlbumTrackNumber.HasValue)
            {
                dict.Add(MPMediaItem.AlbumTrackNumberProperty, new NSNumber(AlbumTrackNumber.Value));
            }
            if (DiscCount.HasValue)
            {
                dict.Add(MPMediaItem.DiscCountProperty, new NSNumber(DiscCount.Value));
            }
            if (DiscNumber.HasValue)
            {
                dict.Add(MPMediaItem.DiscNumberProperty, new NSNumber(DiscNumber.Value));
            }
            if (PersistentID.HasValue)
            {
                dict.Add(MPMediaItem.PersistentIDProperty, new NSNumber(PersistentID.Value));
            }
            if (PlaybackDuration.HasValue)
            {
                dict.Add(MPMediaItem.PlaybackDurationProperty, new NSNumber(PlaybackDuration.Value));
            }

            if (AlbumTitle != null)
            {
                dict.Add(MPMediaItem.AlbumTitleProperty, new NSString(AlbumTitle));
            }
            if (Artist != null)
            {
                dict.Add(MPMediaItem.ArtistProperty, new NSString(Artist));
            }
            if (Artwork != null)
            {
                dict.Add(MPMediaItem.ArtworkProperty, Artwork);
            }
            if (Composer != null)
            {
                dict.Add(MPMediaItem.ComposerProperty, new NSString(Composer));
            }
            if (Genre != null)
            {
                dict.Add(MPMediaItem.GenreProperty, new NSString(Genre));
            }
            if (Title != null)
            {
                dict.Add(MPMediaItem.TitleProperty, new NSString(Title));
            }

            return(dict);
        }
コード例 #31
0
 public void SetValues(INativeObject [] value)
 {
     _Values = NSArray.FromNSObjects(value);
 }
コード例 #32
0
        internal MPNowPlayingInfo(NSDictionary source)
        {
            if (source == null)
            {
                return;
            }

            NSObject result;

            if (source.TryGetValue(MPNowPlayingInfoCenter.PropertyElapsedPlaybackTime, out result))
            {
                ElapsedPlaybackTime = (result as NSNumber).DoubleValue;
            }
            if (source.TryGetValue(MPNowPlayingInfoCenter.PropertyPlaybackRate, out result))
            {
                PlaybackRate = (result as NSNumber).DoubleValue;
            }
            if (source.TryGetValue(MPNowPlayingInfoCenter.PropertyPlaybackQueueIndex, out result))
            {
                PlaybackQueueIndex = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPNowPlayingInfoCenter.PropertyPlaybackQueueCount, out result))
            {
                PlaybackQueueCount = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPNowPlayingInfoCenter.PropertyChapterNumber, out result))
            {
                ChapterNumber = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPNowPlayingInfoCenter.PropertyChapterCount, out result))
            {
                ChapterCount = (int)(result as NSNumber).UInt32Value;
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyDefaultPlaybackRate, out result))
            {
                DefaultPlaybackRate = (double)(result as NSNumber).DoubleValue;
            }

            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyAvailableLanguageOptions, out result))
            {
                AvailableLanguageOptions = NSArray.ArrayFromHandle <MPNowPlayingInfoLanguageOptionGroup> (result.Handle);
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyCurrentLanguageOptions, out result))
            {
                CurrentLanguageOptions = NSArray.ArrayFromHandle <MPNowPlayingInfoLanguageOption> (result.Handle);
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyCollectionIdentifier, out result))
            {
                CollectionIdentifier = (string)(result as NSString);
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyExternalContentIdentifier, out result))
            {
                ExternalContentIdentifier = (string)(result as NSString);
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyExternalUserProfileIdentifier, out result))
            {
                ExternalUserProfileIdentifier = (string)(result as NSString);
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyPlaybackProgress, out result))
            {
                PlaybackProgress = (float)(result as NSNumber).FloatValue;
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyMediaType, out result))
            {
                MediaType = (MPNowPlayingInfoMediaType)(result as NSNumber).UInt32Value;
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyIsLiveStream, out result))
            {
                IsLiveStream = (bool)(result as NSNumber).BoolValue;
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyAssetUrl, out result))
            {
                AssetUrl = result as NSUrl;
            }
            if (TryGetValue(source, MPNowPlayingInfoCenter.PropertyCurrentPlaybackDate, out result))
            {
                CurrentPlaybackDate = result as NSDate;
            }

            if (source.TryGetValue(MPMediaItem.AlbumTrackCountProperty, out result))
            {
                AlbumTrackCount = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPMediaItem.AlbumTrackNumberProperty, out result))
            {
                AlbumTrackNumber = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPMediaItem.DiscCountProperty, out result))
            {
                DiscCount = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPMediaItem.DiscNumberProperty, out result))
            {
                DiscNumber = (int)(result as NSNumber).UInt32Value;
            }
            if (source.TryGetValue(MPMediaItem.PersistentIDProperty, out result))
            {
                PersistentID = (result as NSNumber).UInt64Value;
            }
            if (source.TryGetValue(MPMediaItem.PlaybackDurationProperty, out result))
            {
                PlaybackDuration = (result as NSNumber).DoubleValue;
            }

            if (source.TryGetValue(MPMediaItem.AlbumTitleProperty, out result))
            {
                AlbumTitle = (string)(result as NSString);
            }
            if (source.TryGetValue(MPMediaItem.ArtistProperty, out result))
            {
                Artist = (string)(result as NSString);
            }
            if (source.TryGetValue(MPMediaItem.ArtworkProperty, out result))
            {
                Artwork = result as MPMediaItemArtwork;
            }
            if (source.TryGetValue(MPMediaItem.ComposerProperty, out result))
            {
                Composer = (string)(result as NSString);
            }
            if (source.TryGetValue(MPMediaItem.GenreProperty, out result))
            {
                Genre = (string)(result as NSString);
            }
            if (source.TryGetValue(MPMediaItem.TitleProperty, out result))
            {
                Title = (string)(result as NSString);
            }
        }
コード例 #33
0
        static internal AudioSessionOutputRouteKind [] GetOutputRoutes(NSArray arr)
        {
            if (arr == null || arr.Count == 0)
            {
                return(null);
            }

            var result = new AudioSessionOutputRouteKind [arr.Count];

            for (uint i = 0; i < arr.Count; i++)
            {
                var dict = new NSDictionary((IntPtr)arr.ValueAt(i));

                result [i] = AudioSessionOutputRouteKind.None;

                if (dict == null || dict.Count == 0)
                {
                    continue;
                }

                var val = (NSString)dict [AudioRouteKey_Type];

                if (val == null)
                {
                    continue;
                }

                if (val == OutputRoute_LineOut)
                {
                    result [i] = AudioSessionOutputRouteKind.LineOut;
                }
                else if (val == OutputRoute_Headphones)
                {
                    result [i] = AudioSessionOutputRouteKind.Headphones;
                }
                else if (val == OutputRoute_BluetoothHFP)
                {
                    result [i] = AudioSessionOutputRouteKind.BluetoothHFP;
                }
                else if (val == OutputRoute_BluetoothA2DP)
                {
                    result [i] = AudioSessionOutputRouteKind.BluetoothA2DP;
                }
                else if (val == OutputRoute_BuiltInReceiver)
                {
                    result [i] = AudioSessionOutputRouteKind.BuiltInReceiver;
                }
                else if (val == OutputRoute_BuiltInSpeaker)
                {
                    result [i] = AudioSessionOutputRouteKind.BuiltInSpeaker;
                }
                else if (val == OutputRoute_USBAudio)
                {
                    result [i] = AudioSessionOutputRouteKind.USBAudio;
                }
                else if (val == OutputRoute_HDMI)
                {
                    result [i] = AudioSessionOutputRouteKind.HDMI;
                }
                else if (val == OutputRoute_AirPlay)
                {
                    result [i] = AudioSessionOutputRouteKind.AirPlay;
                }
                else
                {
                    result [i] = (AudioSessionOutputRouteKind)val.Handle;
                }
            }
            return(result);
        }
コード例 #34
0
        FavoritesManager()
        {
            var userDefaults = NSUserDefaults.StandardUserDefaults;

            var mapData = userDefaults.DataForKey(accessoryToCharacteristicIdentifierMappingKey);

            if (mapData != null)
            {
                var rawDictionary = NSKeyedUnarchiver.UnarchiveObject(mapData) as NSDictionary;
                if (rawDictionary != null)
                {
                    foreach (var kvp in rawDictionary)
                    {
                        accessoryToCharacteristicIdentifiers [(NSUuid)kvp.Key] = new List <NSUuid> (NSArray.FromArray <NSUuid> ((NSArray)kvp.Value));
                    }
                }
            }
        }
コード例 #35
0
ファイル: extra.cs プロジェクト: thecookie/monotouch-bindings
        public static void LogInAsync(NSArray permissions, NSAction callback)
        {
            var d = new NSActionDispatcher(callback);

            LogInAsync(permissions, d, NSActionDispatcher.Selector);
        }
コード例 #36
0
 public static void LinkUserAsync(ParseUser user, NSArray permissions, NSAction callback)
 {
     var d = new NSActionDispatcher (callback);
     LinkUserAsync (user, permissions, d, NSActionDispatcher.Selector);
 }
コード例 #37
0
ファイル: extra.cs プロジェクト: thecookie/monotouch-bindings
        public static void LinkUserAsync(ParseUser user, NSArray permissions, NSAction callback)
        {
            var d = new NSActionDispatcher(callback);

            LinkUserAsync(user, permissions, d, NSActionDispatcher.Selector);
        }
コード例 #38
0
ファイル: PListObject.cs プロジェクト: zheref/monodevelop
 public override NSObject Convert()
 {
     return(NSArray.FromNSObjects(list.Select(x => x.Convert()).ToArray()));
 }
コード例 #39
0
 public IExtractor(NSArray _object, int i)
 {
     this._object = _object;
     this.i       = i;
 }
コード例 #40
0
ファイル: CIImage.cs プロジェクト: roblillack/maccore
        static CIFilter[] WrapFilters(NSArray filters)
        {
            if (filters == null)
                return new CIFilter [0];

            uint count = filters.Count;
            if (count == 0)
                return new CIFilter [0];
            var ret = new CIFilter [count];
            for (uint i = 0; i < count; i++){
                IntPtr filterHandle = filters.ValueAt (i);
                string filterName = CIFilter.GetFilterName (filterHandle);

                ret [i] = CIFilter.FromName (filterName, filterHandle);
            }
            return ret;
        }
コード例 #41
0
ファイル: TreeViewBackend.cs プロジェクト: TilmanGriesel/xwt
 public override string[] FilesDropped(NSOutlineView outlineView, NSUrl dropDestination, NSArray items)
 {
     throw new NotImplementedException();
 }
コード例 #42
0
		static internal AudioSessionOutputRouteKind [] GetOutputRoutes (NSArray arr)
		{
			if (arr == null || arr.Count == 0)
				return null;
			
			var result = new AudioSessionOutputRouteKind [arr.Count];
			for (uint i = 0; i < arr.Count; i++) {
				var dict = new NSDictionary ((IntPtr) arr.ValueAt (i));
				
				result [i] = AudioSessionOutputRouteKind.None;
				
				if (dict == null || dict.Count == 0)
					continue;
				
				var val = (NSString) dict [AudioRouteKey_Type];
				
				if (val == null)
					continue;
				
				if (val == OutputRoute_LineOut) {
					result [i] = AudioSessionOutputRouteKind.LineOut;
				} else if (val == OutputRoute_Headphones) {
					result [i] = AudioSessionOutputRouteKind.Headphones;
				} else if (val == OutputRoute_BluetoothHFP) {
					result [i] = AudioSessionOutputRouteKind.BluetoothHFP;
				} else if (val == OutputRoute_BluetoothA2DP) {
					result [i] = AudioSessionOutputRouteKind.BluetoothA2DP;
				} else if (val == OutputRoute_BuiltInReceiver) {
					result [i] = AudioSessionOutputRouteKind.BuiltInReceiver;
				} else if (val == OutputRoute_BuiltInSpeaker) {
					result [i] = AudioSessionOutputRouteKind.BuiltInSpeaker;
				} else if (val == OutputRoute_USBAudio) {
					result [i] = AudioSessionOutputRouteKind.USBAudio;
				} else if (val == OutputRoute_HDMI) {
					result [i] = AudioSessionOutputRouteKind.HDMI;
				} else if (val == OutputRoute_AirPlay) {
					result [i] = AudioSessionOutputRouteKind.AirPlay;
				} else
					result [i] = (AudioSessionOutputRouteKind) val.Handle;
			}
			return result;
		}
コード例 #43
0
ファイル: NECompat.cs プロジェクト: tondat/xamarin-macios
 public unsafe virtual Task <global::Security.SecTrust> EvaluateTrustAsync(NWTcpConnection connection, NSArray peerCertificateChain)
 {
     return(NWTcpConnectionAuthenticationDelegate_Extensions.EvaluateTrustAsync(this, connection, peerCertificateChain));
 }
コード例 #44
0
 public SKKeyframeSequence(NSObject [] values, NSNumber [] times) :
     this(values, NSArray.FromNSObjects(times))
 {
 }
コード例 #45
0
 public static string[] CountryNames()
 {
     return(NSArray.StringArrayFromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("countryNames"))));
 }
コード例 #46
0
        public void ArrayTest()
        {
            var obj = new ArrayTrampolines();

            string[] arr = new string [] { "abc" };
            int      c;

            c = Messaging.int_objc_msgSend_IntPtr(obj.Handle, new Selector("Test_StringArray:").Handle, NSArray.FromStrings(arr).Handle);

            Assert.That(c == 1, "#a1");
            Assert.That(arr [0] == "abc");              // array elements aren't copied back out (maybe they should be?)

            arr = NSArray.StringArrayFromHandle(Messaging.IntPtr_objc_msgSend(obj.Handle, new Selector("Test_StringArrayReturn").Handle));

            Assert.That(arr.Length == 1, "#b1");
            Assert.That(arr [0] == "def", "#b2");

            arr = NSArray.StringArrayFromHandle(Messaging.IntPtr_objc_msgSend(obj.Handle, new Selector("Test_StringArrayNullReturn").Handle));
            Assert.IsNull(arr, "#c1");

            c = Messaging.int_objc_msgSend_IntPtr(obj.Handle, new Selector("Test_StringArray:").Handle, IntPtr.Zero);
            Assert.AreEqual(-1, c, "#d1");
        }
コード例 #47
0
ファイル: Extensions.cs プロジェクト: rdavisau/hello-ios13
 public static IEnumerable <T> AsEnumerable <T>(this NSArray arr)
     where T : NSObject
 => Enumerable
 .Range(0, (int)((NSArray)arr).Count)
 .Select(i => arr.GetItem <T>((nuint)i));
コード例 #48
0
        public static IMTLDevice [] GetAllDevices()
        {
            var rv = MTLCopyAllDevices();

            return(NSArray.ArrayFromHandle <IMTLDevice> (rv));
        }
コード例 #49
0
		/* Could not test what sort of unique CFNumberRef value it's

		[Since (5,0)]
		static public int InputSource {
			get {
				return GetInt (AudioSessionProperty.InputSource);
			}
			set {
				SetInt (AudioSessionProperty.InputSource, value);
			}
		}

		[Since (5,0)]
		static public int OutputDestination {
			get {
				return GetInt (AudioSessionProperty.OutputDestination);
			}
			set {
				SetInt (AudioSessionProperty.OutputDestination, value);
			}
		}

		*/

		static internal AudioSessionInputRouteKind GetInputRoute (NSArray arr)
		{
			if (arr == null || arr.Count == 0)
				return AudioSessionInputRouteKind.None;
			
			var dict = new NSDictionary (arr.ValueAt (0));
			
			if (dict == null || dict.Count == 0)
				return AudioSessionInputRouteKind.None;
			
			var val = (NSString) dict [AudioRouteKey_Type];
			
			if (val == null)
				return AudioSessionInputRouteKind.None;
			
			if (val == InputRoute_LineIn) {
				return AudioSessionInputRouteKind.LineIn;
			} else if (val == InputRoute_BuiltInMic) {
				return AudioSessionInputRouteKind.BuiltInMic;
			} else if (val == InputRoute_HeadsetMic) {
				return AudioSessionInputRouteKind.HeadsetMic;
			} else if (val == InputRoute_BluetoothHFP) {
				return AudioSessionInputRouteKind.BluetoothHFP;
			} else if (val == InputRoute_USBAudio) {
				return AudioSessionInputRouteKind.USBAudio;
			} else {
				return (AudioSessionInputRouteKind) val.Handle;
			}
		}
コード例 #50
0
        public T [] ObjectsAt <T> (NSIndexSet indexes) where T : NSObject
        {
            var nsarr = _ObjectsAt(indexes);

            return(NSArray.ArrayFromHandle <T> (nsarr));
        }
コード例 #51
0
 public LPConversationEntity[] GetConversations(NSPredicate predicate)
 {
     return(NSArray.ArrayFromHandle <LPConversationEntity>(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, Selector.GetHandle("getConversations:"), predicate == null ? IntPtr.Zero : predicate.Handle)));
 }
コード例 #52
0
 public T[] GetValuesAs <T> () where T : class, INativeObject
 {
     return(NSArray.FromArrayNative <T> (_Values));
 }
コード例 #53
0
		private static Object[] ConvertToArray(NSArray nsArray) {
			Object[] arr = new Object[nsArray.Count];
			for (uint i = 0; i < nsArray.Count; i++) {
				var o = ObjCRuntime.Runtime.GetNSObject(nsArray.ValueAt(i));
				if(o is NSArray) {
					arr[i] = ConvertToArray((o as NSArray));
				} else if (o is NSDictionary) {

				} else if (o is NSMutableDictionary) {
					arr[i] = ConvertToDictionary((o as NSMutableDictionary));
				} if(o is NSString) {
					arr[i] = (o as NSString).Description;
				} else if(o is NSNumber) {
					arr[i] = (o as NSNumber).Int16Value;
				}
			}

			return arr;
		}
コード例 #54
0
 public LPConversationEntity[] GetLatestClosedConversation(nint conversationsCount)
 {
     return(NSArray.ArrayFromHandle <LPConversationEntity>(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_nint(this.Handle, Selector.GetHandle("getLatestClosedConversation:"), conversationsCount)));
 }
コード例 #55
0
ファイル: NSView.cs プロジェクト: smartmobili/CocoaBuilder
        public static NSArray GSSetDragTypes(NSView obj, NSArray types)
        {
            uint	count = (uint)types.Count;
            NSString[] strings = new NSString[count];
            NSArray	t = null;
            uint	i = 0;

            /*
             * Make a new array with copies of the type strings so we don't get
             * them mutated by someone else.
             */
            types.GetObjects(strings);
            for (i = 0; i < count; i++)
            {
                strings[i] = strings[i].Copy();
            }
            /*
             * Store it.
             */
            //[typesLock lock];
            //NSMapInsert(typesMap, (void*)(gsaddr)obj, (void*)(gsaddr)t);
            //[typesLock unlock];
            return t;
        }
コード例 #56
0
ファイル: ABPerson.cs プロジェクト: cwensley/monomac
        public ABPerson[] GetLinkedPeople()
        {
            var linked = ABPersonCopyArrayOfAllLinkedPeople(Handle);

            return(NSArray.ArrayFromHandle(linked, l => new ABPerson(l, null)));
        }
コード例 #57
0
ファイル: iCal.cs プロジェクト: Monobjc/monobjc-samples
 public virtual void PrintWithPropertiesPrintDialog(NSArray x, Id withProperties, Boolean printDialog)
 {
     ObjectiveCRuntime.SendMessage(this, "print:withProperties:printDialog:", x, withProperties, printDialog);
 }
コード例 #58
0
 public static T [] GetShuffledArray <T> (this NSArray This) where T : class, INativeObject
 {
     return(NSArray.ArrayFromHandle <T> (Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("shuffledArray"))));
 }
コード例 #59
0
 public static void LogInAsync(NSArray permissions, NSAction callback)
 {
     var d = new NSActionDispatcher (callback);
     LogInAsync (permissions, d, NSActionDispatcher.Selector);
 }
コード例 #60
0
        static unsafe bool TrampolineRegistrationHandler(IntPtr block, /* NSArray */ IntPtr errors, bool done)
        {
            var del = BlockLiteral.GetTarget <CTFontRegistrationHandler> (block);

            return(del != null?del(NSArray.ArrayFromHandle <NSError> (errors), done) : true);
        }