async void ProcessMetadataItems() { Console.WriteLine("ProcessMetadataItems"); NSMetadataItem[] metadataItems = documentMetadataQuery.Results; // We only expect a single result to be returned by our NSMetadataQuery since we query for a specific file. if (metadataItems.Length == 1) { var url = (NSUrl)metadataItems [0].ValueForAttribute(NSMetadataQuery.ItemURLKey); if (document != null) { document.Close(null); } document = new ListDocument(url); var success = await document.OpenAsync(); if (!success) { Console.WriteLine("Couldn't open document: {0}.", document.FileUrl.AbsoluteString); return; } ResetContentSize(); TableView.ReloadData(); } }
public void CreateAndSaveWithCompletionHandler(UIOperationHandler completionHandler) { List list = new List(); list.Color = Color.Value; ListDocument document = new ListDocument(Url); document.List = list; document.Save(Url, UIDocumentSaveOperation.ForCreating, completionHandler); }
async void FetchInfo(TaskCompletionSource <object> tcs) { ListDocument document = new ListDocument(Url); bool success = await document.OpenAsync(); if (success) { Color = document.List.Color; Name = document.LocalizedName; tcs.SetResult(null); document.Close(null); } else { tcs.SetException(new InvalidOperationException("Your attempt to open the document failed.")); } }
public async void ConfigureWith(ListInfo listInfo) { await listInfo.FetchInfoAsync(); if (document != null) { document.DocumentDeleted -= OnListDocumentWasDeleted; document.Close(null); } document = new ListDocument(listInfo.Url); document.DocumentDeleted += OnListDocumentWasDeleted; NavigationItem.Title = listInfo.Name; TextAttributes = new UIStringAttributes { Font = UIFont.PreferredHeadline, ForegroundColor = AppColors.ColorFrom(listInfo.Color.Value) }; }