public void UpdateDocumentColor(NSUrl documentUrl, ListColor newColor)
        {
            ListInfo listInfo = new ListInfo(documentUrl);

            int index = listInfos.IndexOf(listInfo);

            if (index != -1)
            {
                listInfo       = listInfos[index];
                listInfo.Color = newColor;

                NSIndexPath indexPath = NSIndexPath.FromRowSection(index, 0);
                ListCell    cell      = (ListCell)TableView.CellAt(indexPath);
                cell.ListColorView.BackgroundColor = AppColors.ColorFrom(newColor);
            }
        }
        void RemoveListInfo(ListInfo listInfo, Action <int> completionHandler)
        {
            int index = listInfos.IndexOf(listInfo);

            if (index < 0)
            {
                return;
            }

            listInfos.RemoveAt(index);

            if (completionHandler != null)
            {
                completionHandler(index);
            }
        }
        void InsertListInfo(ListInfo listInfo, Action <int> completionHandler)
        {
            ComparisionComparer <ListInfo> comparer = new ComparisionComparer <ListInfo>((left, right) => {
                return(left.Name.CompareTo(right.Name));
            });
            // read more about return value http://msdn.microsoft.com/en-us/library/ftfdbfx6(v=vs.110).aspx
            int index = listInfos.BinarySearch(listInfo, comparer);

            index = index >= 0 ? index : ~index;

            listInfos.Insert(index, listInfo);

            if (completionHandler != null)
            {
                completionHandler(index);
            }
        }
Esempio n. 4
0
        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)
            };
        }
        public void SaveAction(NSObject sender)
        {
            ListInfo listInfo = new ListInfo(FileUrl);

            listInfo.Color = selectedColor;
            listInfo.Name  = selectedTitle;

            listInfo.CreateAndSaveWithCompletionHandler(success => {
                if (success)
                {
                    MasterController.OnNewListInfo(listInfo);
                }
                else
                {
                    // In your app, you should handle this error gracefully.
                    Console.WriteLine("Unable to create new document at URL: {0}", FileUrl.AbsoluteString);
                    throw new InvalidProgramException();
                }
                DismissViewController(true, null);
            });
        }
        // ListInfo objects may originate from local URLs or NSMetadataItems representing document in the cloud.
        void InsertListInfoWithProvider(NSUrl provider, Action <int> completionHandler)
        {
            ListInfo listInfo = new ListInfo(provider);

            InsertListInfo(listInfo, completionHandler);
        }
        void RemoveListInfo(NSUrl url, Action <int> completionHandler)
        {
            ListInfo listInfo = new ListInfo(url);

            RemoveListInfo(listInfo, completionHandler);
        }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            ListInfo listInfo = listInfos[indexPath.Row];

            SelectListWithListInfo(listInfo);
        }