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; }
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; }
void CreateUI() { System.Threading.Thread.Sleep (2000); if (spinner != null){ spinner.RemoveFromSuperview (); spinner = null; } var profileRect = new RectangleF (PadX, 0, View.Bounds.Width-PadX, 100); var shortProfileView = new ShortProfileView (profileRect, user.Id, false); shortProfileView.PictureTapped += delegate { PictureViewer.Load (this, user.Id); }; shortProfileView.UrlTapped += delegate { WebViewController.OpenUrl (this, user.Url); }; var main = new Section (shortProfileView); if (!String.IsNullOrEmpty (user.Description)){ main.Add (new StyledMultilineElement (user.Description) { Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, Font = UIFont.SystemFontOfSize (14), }); }; var tweetsUrl = String.Format ("http://api.twitter.com/1/statuses/user_timeline.json?skip_user=true&id={0}", user.Id); var favoritesUrl = String.Format ("http://api.twitter.com/1/favorites.json?id={0}", user.Id); var followersUrl = String.Format ("http://api.twitter.com/1/statuses/followers.json?id={0}", user.Id); var friendsUrl = String.Format ("http://api.twitter.com/1/statuses/friends.json?id={0}", user.Id); #if false followButton = new StyledStringElement (FollowText, ToggleFollow){ Alignment = UITextAlignment.Center, TextColor = UIColor.FromRGB (0x32, 0x4f, 0x85) }; #endif var sfollow = new Section () { new ActivityElement () }; Root = new RootElement (user.Screenname){ main, new Section () { TimelineRootElement.MakeTimeline (user.Screenname, Locale.Format ("{0:#,#} tweets", user.StatusesCount), tweetsUrl, user), TimelineRootElement.MakeFavorites (user.Screenname, Locale.Format ("{0:#,#} favorites", user.FavCount), favoritesUrl, null), new UserRootElement (user, Locale.Format ("{0:#,#} friends", user.FriendsCount), friendsUrl), new UserRootElement (user, Locale.Format ("{0:#,#} followers", user.FollowersCount), followersUrl), }, sfollow, }; var created = user.CreatedAt; if (created.HasValue){ Root.Add (new Section (null, Locale.Format ("Joined on {0}", created.Value.ToLongDateString ()))); } string url = String.Format ("http://api.twitter.com/1/friendships/show.json?target_id={0}&source_screen_name={1}", user.Id, OAuth.PercentEncode (TwitterAccount.CurrentAccount.Username)); TwitterAccount.CurrentAccount.Download (url, res => { TableView.BeginUpdates (); Root.Remove (sfollow); if (res != null) ParseFollow (res); TableView.EndUpdates (); }); }