public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                var             row  = indexPath.Row;
                UITableViewCell cell = tableView.DequeueReusableCell(cellID);

                if (cell == null)
                {
                    cell                 = new UITableViewCell(UITableViewCellStyle.Default, cellID);
                    cell.Accessory       = UITableViewCellAccessory.DisclosureIndicator;
                    cell.ImageView.Image = UIImageCache.GetUIImage("Images/appbar.folder.rest.png");
                }

                cell.TextLabel.Text = controller.Folders[row].Name;

                return(cell);
            }
Beispiel #2
0
        public static UIColor FromString(string color)
        {
            if (color == null)
            {
                return(UIColor.Clear);
            }
            if (color.StartsWith("Images/", true, CultureInfo.InvariantCulture))
            {
                return(UIColor.FromPatternImage(UIImageCache.GetUIImage(color)));
            }

            if (color.StartsWith("#"))
            {                   // hex template
                                // strip hash
                color = color.Substring(1);
                int red, green, blue, alpha;
                // handle #rrggbb
                if (color.Length == 6)
                {
                    red   = Convert.ToInt32(color.Substring(0, 2), 16);
                    green = Convert.ToInt32(color.Substring(2, 2), 16);
                    blue  = Convert.ToInt32(color.Substring(4, 2), 16);
                    return(UIColor.FromRGB(red, green, blue));
                }
                // handle #AArrggbb
                if (color.Length == 8)
                {
                    alpha = Convert.ToInt32(color.Substring(0, 2), 16);
                    red   = Convert.ToInt32(color.Substring(2, 2), 16);
                    green = Convert.ToInt32(color.Substring(4, 2), 16);
                    blue  = Convert.ToInt32(color.Substring(6, 2), 16);
                    return(UIColor.FromRGBA(red, green, blue, alpha));
                }
                // can't recognize the format - return black
                return(UIColor.Black);
            }
            else
            {                   // color string
                return(FromName(color));
            }
        }
Beispiel #3
0
        private void CreateAddButtons()
        {
            if (AddButtons == null)
            {
                AddButtons = new ButtonListElement[3];
            }

            // get all the lists
            var entityRefItems = App.ViewModel.GetListsOrderedBySelectedCount();

            lists = new List <ClientEntity>();
            foreach (var entityRefItem in entityRefItems)
            {
                var entityType = entityRefItem.GetFieldValue(FieldNames.EntityType).Value;
                var entityID   = new Guid(entityRefItem.GetFieldValue(FieldNames.EntityRef).Value);
                if (entityType == typeof(Folder).Name && App.ViewModel.Folders.Any(f => f.ID == entityID))
                {
                    lists.Add(App.ViewModel.Folders.Single(f => f.ID == entityID));
                }
                if (entityType == typeof(Item).Name && App.ViewModel.Items.Any(i => i.ID == entityID))
                {
                    lists.Add(App.ViewModel.Items.Single(i => i.ID == entityID));
                }
            }

            // create a list of buttons - one for each list
            buttonList = (from it in lists
                          select new Button()
            {
                Background = "Images/darkgreybutton.png",
                Caption = it.Name,
                Clicked = AddButton_Click
            }).ToList();

            // clear the button rows
            for (int i = 0; i < AddButtons.Length; i++)
            {
                AddButtons[i] = null;
            }

            // assemble the buttons into rows (maximum of six buttons and two rows)
            // if there are three or less buttons, one row
            // otherwise distribute evenly across two rows
            int count = Math.Min(buttonList.Count, MaxLists);
            int firstrow = count, secondrow = 0, addButtonsRow = 0;

            if (count > MaxLists / 2)
            {
                firstrow  = count / 2;
                secondrow = count - firstrow;
            }
            if (firstrow > 0)
            {
                AddButtons[addButtonsRow++] = new ButtonListElement()
                {
                    buttonList.Take(firstrow)
                };
            }
            if (secondrow > 0)
            {
                AddButtons[addButtonsRow++] = new ButtonListElement()
                {
                    buttonList.Skip(firstrow).Take(secondrow)
                };
            }

            // create a last "row" of buttons containing only one "More..." button which will bring up the folder/list page
            AddButtons[addButtonsRow] = new ButtonListElement()
            {
                new Button()
                {
                    Background = "Images/darkgreybutton.png",
                    Caption    = "More...",
                    Clicked    = (s, e) =>
                    {
                        // assemble a page which contains a hierarchy of every folder and list, grouped by folder
                        var title = String.IsNullOrEmpty(Name.Value) ? "Navigate to:" : "Add " + Name.Value + " to:";
                        ListsRootElement = new ThemedRootElement(title)
                        {
                            from f in App.ViewModel.Folders
                            orderby f.Name ascending
                                 select new Section()
                            {
                                new StyledStringElement(f.Name, delegate
                                {
                                    AddItem(f, null);
                                    // increment the selected count for this folder and sync if this isn't an actual Add
                                    ListMetadataHelper.IncrementListSelectedCount(App.ViewModel.PhoneClientFolder, f);
                                    // (do not sync for operations against $ClientSettings)
                                    //if (String.IsNullOrWhiteSpace(Name.Value))
                                    //    App.ViewModel.SyncWithService();
                                })
                                {
                                    Image = UIImageCache.GetUIImage("Images/appbar.folder.rest.png")
                                },
                                from li in f.Items
                                where li.IsList == true && li.ItemTypeID != SystemItemTypes.Reference
                                orderby li.Name ascending
                                select(Element) new StyledStringElement("        " + li.Name, delegate
                                {
                                    AddItem(f, li);
                                    // increment the selected count for this list and sync if this isn't an actual Add
                                    ListMetadataHelper.IncrementListSelectedCount(App.ViewModel.PhoneClientFolder, li);
                                    // (do not sync for operations against $ClientSettings)
                                    //if (String.IsNullOrWhiteSpace(Name.Value))
                                    //    App.ViewModel.SyncWithService();
                                })
                                {
                                    Image = UIImageCache.GetUIImage("Images/179-notepad.png")
                                }
                            }
                        };
                        var dvc = new DialogViewController(ListsRootElement, true);
                        dvc.TableView.BackgroundColor      = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground);
                        dvc.NavigationItem.HidesBackButton = false;
                        dialogViewController.NavigationController.PushViewController(dvc, true);
                    }
                }
            };
        }