Insert() public method

Inserts a new section into the RootElement
This inserts the specified list of sections (a params argument) into the root using the Fade animation.
public Insert ( int idx, Section section ) : void
idx int /// The index where the section is added ///
section Section
return void
		public override void LoadView ()
		{
			base.LoadView ();

			var root = new RootElement ("TARP Banks");

			var section = new Section ()
			{
				(usOnlyToggle = new BooleanElement("Show only US banks", false))
			};
			root.Add (section);

			//make a section from the banks. Keep a reference to it
			root.Add ((bankListSection = BuildBankSection (usOnlyToggle.Value)));

			//if the toggle changes, reload the items
			usOnlyToggle.ValueChanged += (sender, e) => {
				var newListSection = BuildBankSection(usOnlyToggle.Value);

				root.Remove(bankListSection, UITableViewRowAnimation.Fade);
				root.Insert(1, UITableViewRowAnimation.Fade, newListSection);
				bankListSection = newListSection;

			};


			Root = root;
		}
Example #2
0
        private RootElement CreateRootElement()
        {
            var captionLabel = UIHelper.CreateLabel (
                "cross copy",
                true,
                32,
                32,
                UITextAlignment.Center,
                UIColor.Black
                );
            UILabel subcaptionLabel = UIHelper.CreateLabel (
                WELCOME_LABEL_TEXT,
                false,
                14,
                85,
                UITextAlignment.Center,
                lightTextColor
                );
            subcaptionLabel.Tag = 3;

            captionLabel.Frame = new Rectangle (0, 10, 320, 40);
            subcaptionLabel.Frame = new Rectangle (20, 55, 280, 100);
            UIView header = new UIView (new Rectangle (0, 0, 300, 145));
            header.AddSubviews (captionLabel, subcaptionLabel);

            var root = new RootElement ("Secrets")
            {
                new Section (header),
                (secretsSection = new Section ("Secrets")),
                new Section ()
                {
                    (secretEntry = new AdvancedEntryElement ("Secret", "enter new phrase", "", null))
                }
            };

            secretsSection.AddAll (from s in AppDelegate.HistoryData.Secrets select (Element)CreateImageButtonStringElement (s));

            secretEntry.AutocapitalizationType = UITextAutocapitalizationType.None;
            secretEntry.ShouldReturn += delegate {

                if (String.IsNullOrEmpty (secretEntry.Value))
                    return false;

                var newSecret = new Secret (secretEntry.Value);
                AppDelegate.HistoryData.Secrets.Add (newSecret);

                if (root.Count == 2)
                    root.Insert (1, secretsSection);

                secretsSection.Insert (
                    secretsSection.Elements.Count,
                    UITableViewRowAnimation.Fade,
                    CreateImageButtonStringElement (newSecret)
                    );
                secretEntry.Value = "";
                secretEntry.ResignFirstResponder (false);
                DisplaySecretDetail (newSecret);

                return true;
            };
            secretEntry.ReturnKeyType = UIReturnKeyType.Go;
            if (secretsSection.Count == 0) {
                secretEntry.BecomeFirstResponder (true);
                root.RemoveAt (1);
            }
            return root;
        }
Example #3
0
        private RootElement RenderEditItem(Item item, bool renderListInfo)
        {
            // get itemType for this item
            ItemType itemType = null;
            try
            {
                itemType = App.ViewModel.ItemTypes.Single(it => it.ID == item.ItemTypeID);
            }
            catch (Exception)
            {
                // if can't find the folder type, use the first
                itemType = App.ViewModel.ItemTypes[0];
            }

            // render the primary fields
            Section primarySection = RenderEditItemFields(item, itemType, true);

            // HACK: insert a dummy element inside the primary section.  This dummy element
            // implements IElementSizing and returns a 0-sized cell (so it is invisible).
            // This is to work around an issue in MT.Dialog where it doesn't honor IElementSizing
            // on elements that are added after a dialog is already drawn.  This element must be
            // inserted after the first element but before the last element, to avoid losing the
            // rounded rectangle look of the first and last elements of a Section.
            if (primarySection.Count > 0)
                primarySection.Insert(1, new DummyElement());

            // render more button
            var moreButton = new Button() { Background = "Images/darkgreybutton.png", Caption = "more details" };
            var sse = new ButtonListElement() { Margin = 0f };
            sse.Buttons.Add(moreButton);
            var moreSection = new Section() { sse };

            // render save/delete buttons
            var actionButtons = new ButtonListElement()
            {
                //new Button() { Caption = "Save", Background = "Images/greenbutton.png", Clicked = SaveButton_Click },
                new Button() { Caption = "Delete", Background = "Images/redbutton.png", Clicked = DeleteButton_Click },
            };
            actionButtons.Margin = 0f;

            // create the dialog with the primary section
            RootElement editRoot = new RootElement(item.Name)
            {
                primarySection,
                moreSection,
                new Section() { actionButtons },
            };

            moreButton.Clicked += (s, e) =>
            {
                // remove the "more" button
                editRoot.Remove(moreSection);

                // render the non-primary fields as a new section
                editRoot.Insert(1, RenderEditItemFields(item, itemType, false));

                // create a separate section with the advanced information (parent, type)
                var advancedSection = new Section();

                Field field = new Field() { Name = "ParentID", DisplayName = "List", DisplayType = DisplayTypes.Lists };
                advancedSection.Add(RenderEditItemField(item, field));

                field = new Field() { Name = "ItemTypeID", DisplayName = "Type", DisplayType = DisplayTypes.ItemTypes };
                advancedSection.Add(RenderEditItemField(item, field));

                editRoot.Insert(2, advancedSection);
            };

            return editRoot;
        }
        private void AddItems(RootElement root, List<ChangesetModel> changes)
        {
            var sec = new Section();
            changes.ForEach(x => {
                var desc = (x.Message ?? "").Replace("\n", " ").Trim();
                var el = new NameTimeStringElement { Name = x.Author, Time = (x.Utctimestamp), String = desc, Lines = 4 };
                el.Tapped += () => NavigationController.PushViewController(new ChangesetInfoController(User, Slug, x.Node), true);
                sec.Add(el);
            });

            if (sec.Count > 0)
            {
                InvokeOnMainThread(delegate {
                    root.Insert(root.Count - 1, sec);
                });
            }
        }