public void SetValues(INativeObject [] value) { _Values = NSArray.FromNSObjects(value); }
public CNContactFetchRequest(params NSString [] keysToFetch) : this(NSArray.FromNSObjects(keysToFetch)) { }
public override NSObject Convert() { return(NSArray.FromNSObjects(list.Select(x => x.Convert()).ToArray())); }
public static GLKTextureInfo?CubeMapFromUrls(NSUrl [] urls, GLKTextureOperations?textureOperations, out NSError error) { using (var array = NSArray.FromNSObjects(urls)) return(CubeMapFromFiles(array, textureOperations?.Dictionary, out error)); }
public PSPDFInkAnnotation(NSArray <NSValue> [] lines) : base(NSObjectFlag.Empty) { var objs = NSArray.FromNSObjects(lines); Handle = InitWithLines(objs.Handle); }
public void SetObject(NSNumber obj, params nint[] indices) { using (var arr = NSArray.FromNSObjects <nint> (NSNumber.FromNInt, indices)) SetObjectInternal(obj, arr.GetHandle()); }
public static void EnumerateDraggingItems(this INSDraggingInfo self, NSDraggingItemEnumerationOptions enumOpts, NSView view, INSPasteboardReading [] classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator) { using var nsa_classArray = NSArray.FromNSObjects(classArray); self.EnumerateDraggingItems(enumOpts, view, nsa_classArray.Handle, searchOptions, enumerator); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.Layer = new CALayer(); View.Layer.BackgroundColor = NSColor.White.CGColor; // create the sub views var greenView = new NSView(); greenView.Layer = new CALayer(); greenView.Layer.BackgroundColor = NSColor.Green.CGColor; greenView.Layer.BorderColor = NSColor.Black.CGColor; greenView.Layer.BorderWidth = 2; View.AddSubview(greenView); var redView = new NSView(); redView.Layer = new CALayer(); redView.Layer.BackgroundColor = NSColor.Red.CGColor; redView.Layer.BorderColor = NSColor.Black.CGColor; redView.Layer.BorderWidth = 2; View.AddSubview(redView); var blueView = new NSView(); blueView.Layer = new CALayer(); blueView.Layer.BackgroundColor = NSColor.Blue.CGColor; blueView.Layer.BorderColor = NSColor.Black.CGColor; blueView.Layer.BorderWidth = 2; View.AddSubview(blueView); // create the constraints var padding = 10; var superview = View; // basic constraints greenView.MakeConstraints(make => { make.Top.And.Left.EqualTo(superview).Offset(padding); // chain .Top and .Left make.Bottom.EqualTo(blueView.Top()).Offset(-padding); make.Right.EqualTo(redView.Left()).Offset(-padding); make.Width.EqualTo(redView.Width()); make.Height.EqualTo(redView.Height()); make.Height.EqualTo(blueView.Height()); }); // .With and .And are semantic and optional redView.MakeConstraints(make => { make.Top.EqualTo(superview.Top()).With.Offset(padding); // with .Width make.Left.EqualTo(greenView.Right()).Offset(padding); // no .Width make.Bottom.EqualTo(blueView.Top()).And.Offset(-padding); // with .And make.Right.EqualTo(superview.Right()).Offset(-padding); // no .And make.Width.EqualTo(greenView.Width()); make.Height.EqualTo(NSArray.FromNSObjects(new[] { greenView, blueView })); // can pass array of views }); blueView.MakeConstraints(make => { make.Top.EqualTo(greenView.Bottom()).Offset(padding); make.Left.EqualTo(superview.Left()).Offset(padding); make.Bottom.EqualTo(superview.Bottom()).Offset(-padding); make.Right.EqualTo(superview.Right()).Offset(-padding); make.Height.EqualTo(NSArray.FromNSObjects(new[] { greenView.Height(), redView.Height() })); // can pass array of attributes }); // demonstrate update growingButton = new NSButton(); growingButton.Title = "Grow Me!"; growingButton.Layer = new CALayer(); growingButton.Layer.BackgroundColor = NSColor.White.CGColor; growingButton.Layer.BorderColor = NSColor.Green.CGColor; growingButton.Layer.BorderWidth = 3; View.AddSubview(growingButton); growingButton.AddGestureRecognizer(new NSClickGestureRecognizer(_ => { buttonSize = new CGSize(buttonSize.Width * 1.3f, buttonSize.Height * 1.3f); // tell constraints they need updating View.NeedsUpdateConstraints = true; // update constraints now View.UpdateConstraintsForSubtreeIfNeeded(); View.LayoutSubtreeIfNeeded(); })); // demonstrate remake movingButton = new NSButton(); movingButton.Title = "Move Me!"; movingButton.Layer = new CALayer(); movingButton.Layer.BackgroundColor = NSColor.White.CGColor; movingButton.Layer.BorderColor = NSColor.Green.CGColor; movingButton.Layer.BorderWidth = 3; View.AddSubview(movingButton); movingButton.AddGestureRecognizer(new NSClickGestureRecognizer(_ => { topLeft = !topLeft; // tell constraints they need updating View.NeedsUpdateConstraints = true; // update constraints now View.UpdateConstraintsForSubtreeIfNeeded(); View.LayoutSubtreeIfNeeded(); })); }
nuint Invoke(UICellAccessory [] accessories) { using var nsa_accessories = accessories == null ? null : NSArray.FromNSObjects(accessories); return(invoker(BlockPointer, nsa_accessories.GetHandle())); }
private void AddEarthquakesToList(List <Earthquake> earthquakes) { var entity = NSEntityDescription.EntityForName("Earthquake", managedObjectContext); var fetchRequest = new NSFetchRequest(); fetchRequest.Entity = entity; var date = (NSPropertyDescription)entity.PropertiesByName.ValueForKey(new NSString("date")); var location = (NSPropertyDescription)entity.PropertiesByName.ValueForKey(new NSString("location")); fetchRequest.PropertiesToFetch = new NSPropertyDescription[] { date, location }; fetchRequest.ResultType = NSFetchRequestResultType.DictionaryResultType; NSError error; foreach (var earthquake in earthquakes) { var arguments = new NSObject[] { earthquake.Location, earthquake.Date }; fetchRequest.Predicate = NSPredicate.FromFormat(@"location = %@ AND date = %@", arguments); var fetchedItems = NSArray.FromNSObjects(managedObjectContext.ExecuteFetchRequest(fetchRequest, out error)); if (fetchedItems.Count == 0) { if (string.IsNullOrEmpty(entity.Description)) { continue; } var managedEarthquake = new ManagedEarthquake(entity, managedObjectContext) { Magnitude = earthquake.Magnitude, Location = earthquake.Location, Date = earthquake.Date, USGSWebLink = earthquake.USGSWebLink, Latitude = earthquake.Latitude, Longitude = earthquake.Longitude }; managedObjectContext.InsertObject(managedEarthquake); } var gregorian = new NSCalendar(NSCalendarType.Gregorian); var offsetComponents = new NSDateComponents(); offsetComponents.Day = -14; // 14 days back from today NSDate twoWeeksAgo = gregorian.DateByAddingComponents(offsetComponents, NSDate.Now, NSCalendarOptions.None); // use the same fetchrequest instance but switch back to NSManagedObjectResultType fetchRequest.ResultType = NSFetchRequestResultType.ManagedObject; fetchRequest.Predicate = NSPredicate.FromFormat(@"date < %@", new NSObject[] { twoWeeksAgo }); var olderEarthquakes = NSArray.FromObjects(managedObjectContext.ExecuteFetchRequest(fetchRequest, out error)); for (int i = 0; i < olderEarthquakes.Count; i++) { managedObjectContext.DeleteObject(olderEarthquakes.GetItem <ManagedEarthquake> (i)); } if (managedObjectContext.HasChanges) { if (!managedObjectContext.Save(out error)) { Console.WriteLine(string.Format("Unresolved error {0}", error.LocalizedDescription)); } } } }
public SKKeyframeSequence(NSObject [] values, NSNumber [] times) : this(values, NSArray.FromNSObjects(times)) { }
RTCMediaConstraints DefaultPeerConnectionConstraints() { NSArray optionalConstraints = NSArray.FromNSObjects(new RTCPair("DtlsSrtpKeyAgreement", "true")); return(new RTCMediaConstraints(null, optionalConstraints)); }
RTCMediaConstraints DefaultOfferConstraints() { NSArray mandatoryConstraints = NSArray.FromNSObjects(new RTCPair("OfferToReceiveAudio", "true"), new RTCPair("OfferToReceiveVideo", "true")); return(new RTCMediaConstraints(mandatoryConstraints, null)); }
public NSMutableOrderedSet(params NSObject [] objs) : this(NSArray.FromNSObjects(objs)) { }
public static ProcessSerialNumber OpenApplication(ApplicationStartInfo application) { if (application == null) { throw new ArgumentNullException("application"); } if (string.IsNullOrEmpty(application.Application) || !System.IO.Directory.Exists(application.Application)) { throw new ArgumentException("Application is not valid"); } var appParams = new LSApplicationParameters(); if (application.NewInstance) { appParams.flags |= LSLaunchFlags.NewInstance; } if (application.Async) { appParams.flags |= LSLaunchFlags.Async; } NSArray argv = null; if (application.Args != null && application.Args.Length > 0) { var args = application.Args; NSObject[] arr = new NSObject[args.Length]; for (int i = 0; i < args.Length; i++) { arr[i] = new NSString(args[i]); } argv = NSArray.FromNSObjects(arr); appParams.argv = argv.Handle; } NSDictionary dict = null; if (application.Environment.Count > 0) { dict = new NSMutableDictionary(); foreach (var kvp in application.Environment) { dict.SetValueForKey(new NSString(kvp.Value), new NSString(kvp.Key)); } appParams.environment = dict.Handle; } var cfUrl = global::CoreFoundation.CFUrl.FromFile(application.Application); ProcessSerialNumber psn; try { appParams.application = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FSRef))); if (!CoreFoundation.CFURLGetFSRef(cfUrl.Handle, appParams.application)) { throw new Exception("Could not create FSRef from CFUrl"); } var status = LSOpenApplication(ref appParams, out psn); if (status != OSStatus.Ok) { throw new LaunchServicesException((int)status); } } finally { if (appParams.application != IntPtr.Zero) { Marshal.FreeHGlobal(appParams.application); } appParams.application = IntPtr.Zero; if (dict != null) { dict.Dispose(); //also ensures the NSDictionary is kept alive for the params } if (argv != null) { argv.Dispose(); //also ensures the NSArray is kept alive for the params } } return(psn); }
public static void SendEvent(BranchEvent e) { Dictionary <string, object> eventDict = e.ToDictionary(); if (eventDict == null) { return; } IOSNativeBranch.BranchEvent branchEvent = null; if (eventDict.ContainsKey("event_name")) { branchEvent = new IOSNativeBranch.BranchEvent(eventDict["event_name"].ToString()); } else { return; } if (eventDict.ContainsKey("transaction_id")) { branchEvent.TransactionID = eventDict ["transaction_id"].ToString(); } if (eventDict.ContainsKey("customer_event_alias")) { branchEvent.Alias = eventDict["customer_event_alias"].ToString(); } if (eventDict.ContainsKey("affiliation")) { branchEvent.Affiliation = eventDict ["affiliation"].ToString(); } if (eventDict.ContainsKey("coupon")) { branchEvent.Coupon = eventDict ["coupon"].ToString(); } if (eventDict.ContainsKey("currency")) { branchEvent.Currency = eventDict ["currency"].ToString(); } if (eventDict.ContainsKey("tax")) { branchEvent.Tax = new NSDecimalNumber(eventDict["tax"].ToString()); } if (eventDict.ContainsKey("revenue")) { branchEvent.Revenue = new NSDecimalNumber(eventDict["revenue"].ToString()); } if (eventDict.ContainsKey("description")) { branchEvent.EventDescription = eventDict ["description"].ToString(); } if (eventDict.ContainsKey("shipping")) { branchEvent.Shipping = new NSDecimalNumber(eventDict["shipping"].ToString()); } if (eventDict.ContainsKey("search_query")) { branchEvent.SearchQuery = eventDict ["search_query"].ToString(); } if (eventDict.ContainsKey("custom_data")) { Dictionary <string, string> dict = eventDict[@"custom_data"] as Dictionary <string, string>; NSMutableDictionary <NSString, NSString> tempDict = new NSMutableDictionary <NSString, NSString>(); foreach (string key in dict.Keys) { tempDict.Add(new NSString(key), new NSString(dict[key])); } branchEvent.CustomData = new NSDictionary <NSString, NSString>(tempDict.Keys, tempDict.Values); } if (eventDict.ContainsKey("content_items")) { List <string> array = eventDict["content_items"] as List <string>; NSMutableDictionary <NSObject, NSObject> tempDict = new NSMutableDictionary <NSObject, NSObject>(); int i = 1; foreach (string buoJson in array) { tempDict.Add(NSObject.FromObject(i), ToNativeUniversalObject(new BranchUniversalObject(buoJson))); ++i; } branchEvent.ContentItems = NSArray.FromNSObjects <NSObject>(tempDict.Values); } branchEvent.LogEvent(); }
public NSNumber GetObject(params nint[] indices) { using (var arr = NSArray.FromNSObjects <nint> (NSNumber.FromNInt, indices)) return(GetObjectInternal(arr.GetHandle())); }
public void BeginLoadCubeMap(NSUrl [] urls, NSDictionary?textureOperations, DispatchQueue queue, GLKTextureLoaderCallback onComplete) { using (var array = NSArray.FromNSObjects(urls)) BeginLoadCubeMap(array, textureOperations, queue, onComplete); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.White; // create the sub views var greenView = new UIView(); greenView.BackgroundColor = UIColor.Green; greenView.Layer.BorderColor = UIColor.Black.CGColor; greenView.Layer.BorderWidth = 2; View.AddSubview(greenView); var redView = new UIView(); redView.BackgroundColor = UIColor.Red; redView.Layer.BorderColor = UIColor.Black.CGColor; redView.Layer.BorderWidth = 2; View.AddSubview(redView); var blueView = new UIView(); blueView.BackgroundColor = UIColor.Blue; blueView.Layer.BorderColor = UIColor.Black.CGColor; blueView.Layer.BorderWidth = 2; View.AddSubview(blueView); // create the constraints var padding = 10; var superview = View; // basic constraints greenView.MakeConstraints(make => { make.Top.And.Left.EqualTo(superview).Offset(padding); // chain .Top and .Left make.Bottom.EqualTo(blueView.Top()).Offset(-padding); make.Right.EqualTo(redView.Left()).Offset(-padding); make.Width.EqualTo(redView.Width()); make.Height.EqualTo(redView.Height()); make.Height.EqualTo(blueView.Height()); }); // .With and .And are semantic and optional redView.MakeConstraints(make => { make.Top.EqualTo(superview.Top()).With.Offset(padding); // with .Width make.Left.EqualTo(greenView.Right()).Offset(padding); // no .Width make.Bottom.EqualTo(blueView.Top()).And.Offset(-padding); // with .And make.Right.EqualTo(superview.Right()).Offset(-padding); // no .And make.Width.EqualTo(greenView.Width()); make.Height.EqualTo(NSArray.FromNSObjects(new [] { greenView, blueView })); // can pass array of views }); blueView.MakeConstraints(make => { make.Top.EqualTo(greenView.Bottom()).Offset(padding); make.Left.EqualTo(superview.Left()).Offset(padding); make.Bottom.EqualTo(superview.Bottom()).Offset(-padding); make.Right.EqualTo(superview.Right()).Offset(-padding); make.Height.EqualTo(NSArray.FromNSObjects(new [] { greenView.Height(), redView.Height( ) })); // can pass array of attributes }); // demonstrate update growingButton = new UIButton(UIButtonType.System); growingButton.SetTitle("Grow Me!", UIControlState.Normal); growingButton.BackgroundColor = UIColor.White; growingButton.Layer.BorderColor = UIColor.Green.CGColor; growingButton.Layer.BorderWidth = 3; View.AddSubview(growingButton); growingButton.TouchUpInside += delegate { buttonSize = new CGSize(buttonSize.Width * 1.3f, buttonSize.Height * 1.3f); // tell constraints they need updating View.SetNeedsUpdateConstraints(); // update constraints now so we can animate the change View.UpdateConstraintsIfNeeded(); UIView.Animate(0.4, () => View.LayoutIfNeeded()); }; // demonstrate remake movingButton = new UIButton(UIButtonType.System); movingButton.SetTitle("Move Me!", UIControlState.Normal); movingButton.BackgroundColor = UIColor.White; movingButton.Layer.BorderColor = UIColor.Green.CGColor; movingButton.Layer.BorderWidth = 3; View.AddSubview(movingButton); movingButton.TouchUpInside += delegate { topLeft = !topLeft; // tell constraints they need updating View.SetNeedsUpdateConstraints(); // update constraints now so we can animate the change View.UpdateConstraintsIfNeeded(); UIView.Animate(0.4, () => View.LayoutIfNeeded()); }; }
public SUAppcast ToAppcast() { return(new SUAppcast(NSArray.FromNSObjects(_appcastItems.Select(i => i.ToAppcastItem()).ToArray()))); }