void CreateRegularConstraints() { if (regularConstraints?.Length > 0 && sharedConstraints?.Count > 0) { return; } UILayoutGuide leadingMercuryGuide = NewLayoutGuide("leadingMercuryGuide"); UILayoutGuide leadingVenusGuide = NewLayoutGuide("leadingVenusGuide"); UILayoutGuide leadingEarthGuide = NewLayoutGuide("leadingEarthGuide"); UILayoutGuide leadingMarsGuide = NewLayoutGuide("leadingMarsGuide"); UILayoutGuide leadingJupiterGuide = NewLayoutGuide("leadingJupiterGuide"); UILayoutGuide leadingSaturnGuide = NewLayoutGuide("leadingSaturnGuide"); UILayoutGuide leadingUranusGuide = NewLayoutGuide("leadingUranusGuide"); UILayoutGuide leadingNeptuneGuide = NewLayoutGuide("leadingNeptuneGuide"); UILayoutGuide trailingMercuryGuide = NewLayoutGuide("trailingMercuryGuide"); UILayoutGuide trailingVenusGuide = NewLayoutGuide("trailingVenusGuide"); UILayoutGuide trailingEarthGuide = NewLayoutGuide("trailingEarthGuide"); UILayoutGuide trailingMarsGuide = NewLayoutGuide("trailingMarsGuide"); UILayoutGuide trailingJupiterGuide = NewLayoutGuide("trailingJupiterGuide"); UILayoutGuide trailingSaturnGuide = NewLayoutGuide("trailingSaturnGuide"); UILayoutGuide trailingUranusGuide = NewLayoutGuide("trailingUranusGuide"); UILayoutGuide trailingNeptuneGuide = NewLayoutGuide("trailingNeptuneGuide"); IUILayoutSupport topLayoutGuide = TopLayoutGuide; var planetsAndGuides = NSDictionary.FromObjectsAndKeys(new object[] { mercury, venus, earth, mars, jupiter, saturn, uranus, neptune, leadingMercuryGuide, leadingVenusGuide, leadingEarthGuide, leadingMarsGuide, leadingJupiterGuide, leadingSaturnGuide, leadingUranusGuide, leadingNeptuneGuide, trailingMercuryGuide, trailingVenusGuide, trailingEarthGuide, trailingMarsGuide, trailingJupiterGuide, trailingSaturnGuide, trailingUranusGuide, trailingNeptuneGuide, topLayoutGuide }, new object[] { "mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "leadingMercuryGuide", "leadingVenusGuide", "leadingEarthGuide", "leadingMarsGuide", "leadingJupiterGuide", "leadingSaturnGuide", "leadingUranusGuide", "leadingNeptuneGuide", "trailingMercuryGuide", "trailingVenusGuide", "trailingEarthGuide", "trailingMarsGuide", "trailingJupiterGuide", "trailingSaturnGuide", "trailingUranusGuide", "trailingNeptuneGuide", "topLayoutGuide" }); var topToBottom = NSLayoutConstraint.FromVisualFormat("V:|[topLayoutGuide]-[leadingMercuryGuide]-" + "[leadingVenusGuide]-[leadingEarthGuide]-[leadingMarsGuide]-" + "[leadingJupiterGuide][leadingSaturnGuide][leadingUranusGuide]-" + "[leadingNeptuneGuide]-20-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, planetsAndGuides); sharedConstraints = new List <NSLayoutConstraint> (topToBottom); SetLayoutIdentifierForArray((NSString)"topToBottom", NSArray.FromObjects(topToBottom)); NewHorizontalArray("|[leadingMercuryGuide][mercury][trailingMercuryGuide]|", "hMercury", planetsAndGuides); NewHorizontalArray("|[leadingVenusGuide][venus][trailingVenusGuide]|", "hVenus", planetsAndGuides); NewHorizontalArray("|[leadingEarthGuide][earth][trailingEarthGuide]|", "hEarth", planetsAndGuides); NewHorizontalArray("|[leadingMarsGuide][mars][trailingMarsGuide]|", "hMars", planetsAndGuides); NewHorizontalArray("|[leadingJupiterGuide][jupiter][trailingJupiterGuide]|", "hJupiter", planetsAndGuides); NewHorizontalArray("|[leadingSaturnGuide][saturn][trailingSaturnGuide]|", "hSaturn", planetsAndGuides); NewHorizontalArray("|[leadingUranusGuide][uranus][trailingUranusGuide]|", "hUranus", planetsAndGuides); NewHorizontalArray("|[leadingNeptuneGuide][neptune][trailingNeptuneGuide]|", "hNeptune", planetsAndGuides); sharedConstraints.Add(GuideHeightToPlanet(leadingMercuryGuide, mercury, "guideHeightToMercury")); sharedConstraints.Add(GuideHeightToPlanet(leadingVenusGuide, venus, "guideHeightToVenus")); sharedConstraints.Add(GuideHeightToPlanet(leadingEarthGuide, earth, "guideHeightToEarth")); sharedConstraints.Add(GuideHeightToPlanet(leadingMarsGuide, mars, "guideHeightToMars")); sharedConstraints.Add(GuideHeightToPlanet(leadingJupiterGuide, jupiter, "guideHeightToJupiter")); sharedConstraints.Add(GuideHeightToPlanet(leadingSaturnGuide, saturn, "guideHeightToSaturn")); sharedConstraints.Add(GuideHeightToPlanet(leadingUranusGuide, uranus, "guideHeightToUranus")); sharedConstraints.Add(GuideHeightToPlanet(leadingNeptuneGuide, neptune, "guideHeightToNeptune")); mercuryLeadingToTrailing = leadingMercuryGuide.WidthAnchor.ConstraintEqualToAnchor(trailingMercuryGuide.WidthAnchor, .02f); venusLeadingToTrailing = leadingVenusGuide.WidthAnchor.ConstraintEqualToAnchor(trailingVenusGuide.WidthAnchor, .03f); earthLeadingToTrailing = leadingEarthGuide.WidthAnchor.ConstraintEqualToAnchor(trailingEarthGuide.WidthAnchor, .06f); marsLeadingToTrailing = leadingMarsGuide.WidthAnchor.ConstraintEqualToAnchor(trailingMarsGuide.WidthAnchor, .1f); jupiterLeadingToTrailing = leadingJupiterGuide.WidthAnchor.ConstraintEqualToAnchor(trailingJupiterGuide.WidthAnchor, .2f); saturnLeadingToTrailing = leadingSaturnGuide.WidthAnchor.ConstraintEqualToAnchor(trailingSaturnGuide.WidthAnchor, 1f); uranusLeadingToTrailing = leadingUranusGuide.WidthAnchor.ConstraintEqualToAnchor(trailingUranusGuide.WidthAnchor, 2.7f); neptuneLeadingToTrailing = leadingNeptuneGuide.WidthAnchor.ConstraintEqualToAnchor(trailingNeptuneGuide.WidthAnchor, 10f); mercuryLeadingToTrailing.SetIdentifier("leadingTrailingAnchorMercury"); venusLeadingToTrailing.SetIdentifier("leadingTrailingAnchorVenus"); earthLeadingToTrailing.SetIdentifier("leadingTrailingAnchorEarth"); marsLeadingToTrailing.SetIdentifier("leadingTrailingAnchorMars"); jupiterLeadingToTrailing.SetIdentifier("leadingTrailingAnchorJupiter"); saturnLeadingToTrailing.SetIdentifier("leadingTrailingAnchorSaturn"); uranusLeadingToTrailing.SetIdentifier("leadingTrailingAnchorUranus"); neptuneLeadingToTrailing.SetIdentifier("leadingTrailingAnchorNeptune"); regularConstraints = new [] { mercuryLeadingToTrailing, venusLeadingToTrailing, earthLeadingToTrailing, marsLeadingToTrailing, saturnLeadingToTrailing, jupiterLeadingToTrailing, uranusLeadingToTrailing, neptuneLeadingToTrailing }; }
private NSArray ConvertToNSArray(Object[] nsArray) { return(NSArray.FromObjects(nsArray)); }
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)); } }
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::XamCore.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); }
public NSMutableOrderedSet(params object [] objs) : this(NSArray.FromObjects(objs)) { }
/// <summary> /// On element changed event /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs <ScandItCamera> e) { base.OnElementChanged(e); //assign new elemnt value to scanned it camera _scanedItCamera = e.NewElement; if (Control == null) { try { var scanLicense = new ScanditLicense(); scanLicense.AppKey = ScanditAppKey; ScanSettings scanSettings = ScanSettings.DefaultSettings(); //set code duplication filter if (_scanedItCamera.AllowDuplicate) { scanSettings.CodeDuplicateFilter = 1500; //1.5 sec delay for duplication scanning } else { scanSettings.CodeDuplicateFilter = -1; } //Bar code symbologies scanSettings.SetSymbologyEnabled(Symbology.EAN13, true); scanSettings.SetSymbologyEnabled(Symbology.QR, true); scanSettings.SetSymbologyEnabled(Symbology.UPC12, true); scanSettings.SetSymbologyEnabled(Symbology.Code128, true); scanSettings.SetSymbologyEnabled(Symbology.Code39, true); scanSettings.SetSymbologyEnabled(Symbology.EAN8, true); //update code 128 settings var code128Settings = scanSettings.SettingsForSymbology(Symbology.Code128); var countArray = NSArray.FromObjects(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40); code128Settings.ActiveSymbolCounts = new NSSet(countArray); //apply scan settings _picker = new BarcodePicker(scanSettings); _picker.OverlayView.SetBeepEnabled(true); _picker.OverlayView.SetVibrateEnabled(true); _picker.OverlayView.SetCameraSwitchVisibility(CameraSwitchVisibility.Never); _picker.OverlayView.GuiStyle = GuiStyle.None; //to set picker gui style if (_scanedItCamera.ShowFocus) { _picker.OverlayView.GuiStyle = GuiStyle.Default; } else { _picker.OverlayView.GuiStyle = GuiStyle.None; } _picker.DidScan += DidScan; //set native control as picker view SetNativeControl(_picker.View); //enable action for start and stop scanning if (_scanedItCamera != null) { _scanedItCamera.StartScanning = StartScanning; _scanedItCamera.StopScanning = StopScanning; } } catch (Exception ex) { Debug.WriteLine(ex); } } }
public int SendReliableData(NSData data, RealTimeParticipant [] participants) { var array = NSArray.FromObjects(participants); return(_SendReliableData(data, array)); }
public nint QueueRemoveItems(nuint[] itemIDs, NSObject customData) { var arr = NSArray.FromObjects(itemIDs); return(QueueRemoveItems(arr, customData)); }
public void SendUnreliableData(NSData data, RealTimeParticipant [] participants) { var array = NSArray.FromObjects(participants); _SendUnreliableData(data, array); }
public void SendUnreliableData(NSData data, string [] participantsId) { var array = NSArray.FromObjects(participantsId); _SendUnreliableData(data, array); }
public int SendReliableData(NSData data, string [] participantsId) { var array = NSArray.FromObjects(participantsId); return(_SendReliableData(data, array)); }
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)); } } } }
protected void AdvancedHudActionForRow(int row) { switch (row) { case 0: hud.SetCaption("This HUD will auto-hide in 2 seconds."); hud.BlockTouches = true; hud.Show(); hud.HideAfter(2.0); break; case 1: hud.SetCaption("This HUD will update in 2 seconds."); hud.BlockTouches = true; hud.SetActivity(true); hud.Show(); NSTimer.CreateScheduledTimer(2.0, () => { UpdatedHud(); }); break; case 2: { float progress = 0.08f; //NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(tick:) userInfo:nil repeats:YES]; //[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; NSTimer timer = new NSTimer(); timer = NSTimer.CreateRepeatingScheduledTimer(0.02, () => { progress += 0.01f; hud.SetProgress(progress); if (progress >= 1) { progress = 0; timer.Invalidate(); hud.Hide(); NSTimer.CreateScheduledTimer(0.2, () => { ResetProgress(); }); } }); hud.SetCaption("Performing operation..."); hud.SetProgress(0.08f); hud.BlockTouches = true; hud.Show(); break; } case 3: { string[] captions = new [] { "Display #1", "Display #2", "Display #3" }; // Would love to just use UIImage but breaks when using a "null" image. NSArray images = NSArray.FromObjects("", "", UIImage.FromBundle("19-check")); NSNumber[] positions = new NSNumber[] { new NSNumber(2), new NSNumber(1), new NSNumber(2) }; NSNumber[] flags = new NSNumber[] { new NSNumber(false), new NSNumber(true), new NSNumber(false) }; hud.AddToQueue(captions, images, positions, flags); hud.StartQueue(); NSTimer.CreateScheduledTimer(2.0, () => { ShowNextDisplayInQueue(); }); break; } } }
public MediaQueueItem(MediaInformation mediaInformation, bool autoplay, double startTime, double playbackDuration, double preloadTime, nuint[] activeTrackIDs, NSObject customData) { var activeTracksIdsObjC = NSArray.FromObjects(activeTrackIDs); Handle = _InitWithMediaInformation(mediaInformation, autoplay, startTime, playbackDuration, preloadTime, activeTracksIdsObjC, customData); }
void PublishPost(NSObject sender) { // Prevents multiple posting, locks as soon as a post is made PostButton.Enabled = false; UIActivityIndicatorView indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray); indicator.StartAnimating(); PostButton.CustomView = indicator; // Hides the keyboards and dispatches a UI update to show the upload progress HiddenText.EndEditing(true); TagField.EndEditing(true); ProgressBar.Hidden = false; // Creates post record type and initizalizes all of its values CKRecord newRecord = new CKRecord(Post.RecordType); newRecord [Post.FontKey] = (NSString)ImageLabel.Font.Name; // TODO: https://trello.com/c/wEJdLrtO RecordId -> Id newRecord [Post.ImageRefKey] = new CKReference(ImageRecord.Record.RecordId, CKReferenceAction.DeleteSelf); newRecord [Post.TextKey] = (NSString)HiddenText.Text; string[] tags = TagField.Text.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); newRecord [Post.TagsKey] = NSArray.FromObjects(tags); Post newPost = new Post(newRecord); newPost.ImageRecord = ImageRecord; // Only upload image record if it is not on server, otherwise just upload the new post record CKRecord[] recordsToSave = ImageRecord.IsOnServer ? new CKRecord[] { newRecord } : new CKRecord[] { newRecord, ImageRecord.Record }; // TODO: https://trello.com/c/A9T8Spyp second param is null CKModifyRecordsOperation saveOp = new CKModifyRecordsOperation(recordsToSave, new CKRecordID[0]); saveOp.PerRecordProgress = (CKRecord record, double progress) => { // Image record type is probably going to take the longest to upload. Reflect it's progress in the progress bar if (record.RecordType == Image.RecordType) { InvokeOnMainThread(() => { var val = (float)(progress * 0.95); ProgressBar.SetProgress(val, true); }); } }; // When completed it notifies the tableView to add the post we just uploaded, displays error if it didn't work saveOp.Completed = (CKRecord[] savedRecords, CKRecordID[] deletedRecordIDs, NSError operationError) => { Error errorResponse = HandleError(operationError); switch (errorResponse) { case Error.Success: // Tells delegate to update so it can display our new post InvokeOnMainThread(() => { DismissViewController(true, null); MainController.Submit(newPost); }); break; case Error.Retry: CKErrorInfo errorInfo = new CKErrorInfo(operationError.UserInfo); nint retryAfter = errorInfo.RetryAfter.HasValue ? errorInfo.RetryAfter.Value : 3; Console.WriteLine("Error: {0}. Recoverable, retry after {1} seconds", operationError.Description, retryAfter); Task.Delay((int)retryAfter * 1000).ContinueWith(_ => PublishPost(sender)); break; case Error.Ignore: Console.WriteLine("Error saving record: {0}", operationError.Description); string errorTitle = "Error"; string dismissButton = "Okay"; string errorMessage = operationError.Code == (long)CKErrorCode.NotAuthenticated ? "You must be logged in to iCloud in order to post" : "Unrecoverable error with the upload, check console logs"; InvokeOnMainThread(() => { UIAlertController alert = UIAlertController.Create(errorTitle, errorMessage, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(dismissButton, UIAlertActionStyle.Cancel, null)); PostButton.Enabled = true; PresentViewController(alert, true, null); ProgressBar.Hidden = true; PostButton.CustomView = null; }); break; default: throw new NotImplementedException(); } }; CKContainer.DefaultContainer.PublicCloudDatabase.AddOperation(saveOp); }
public nint QueueRemoveItems(nuint[] itemIDs) { var arr = NSArray.FromObjects(itemIDs); return(QueueRemoveItems(arr)); }
MGLShape ShapeFromAnnotation(FormsMB.Annotation annotation) { MGLShape shape = null; if (annotation is PointAnnotation) { shape = new MGLPointAnnotation() { Coordinate = ((PointAnnotation)annotation).Coordinate.ToCLCoordinate(), }; } else if (annotation is PolylineAnnotation) { var polyline = annotation as PolylineAnnotation; shape = PolyLineWithCoordinates(polyline.Coordinates.ToArray()); var notifiyCollection = polyline.Coordinates as INotifyCollectionChanged; if (notifiyCollection != null) { notifiyCollection.CollectionChanged += (sender, e) => { //TODO Move to a separated method if (e.Action == NotifyCollectionChangedAction.Add) { foreach (Position pos in e.NewItems) { var coord = TypeConverter.FromPositionToCoordinate(pos); NSArray nsarray = NSArray.FromObjects(coord); (shape as MGLPolyline).AppendCoordinates(nsarray, 1); } } else if (e.Action == NotifyCollectionChangedAction.Remove) { (shape as MGLPolyline).RemoveCoordinatesInRange(new NSRange(e.OldStartingIndex, e.OldItems.Count)); } }; } } else if (annotation is MultiPolylineAnnotation) { var polyline = annotation as MultiPolylineAnnotation; if (polyline.Coordinates == null || polyline.Coordinates.Length == 0) { return(null); } var lines = new MGLPolyline[polyline.Coordinates.Length]; for (var i = 0; i < polyline.Coordinates.Length; i++) { if (polyline.Coordinates[i].Length == 0) { continue; } lines[i] = PolyLineWithCoordinates(polyline.Coordinates[i]); } shape = MGLMultiPolyline.MultiPolylineWithPolylines(lines); } if (shape != null) { if (annotation.Title != null) { shape.Title = annotation.Title; } if (annotation.SubTitle != null) { shape.Subtitle = annotation.SubTitle; } if (!string.IsNullOrEmpty(annotation.Id)) { shape.SetId(annotation.Id); } } return(shape); }
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 (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); }
public void SetCurrentSuggestions(IList <Suggestion> suggestions) { var array = NSArray.FromObjects(suggestions.Select(toDictionary).ToArray()); userDefaults[new NSString(suggestionsKey)] = array; }