本文整理汇总了C#中RootElement.Add方法的典型用法代码示例。如果您正苦于以下问题:C# RootElement.Add方法的具体用法?C# RootElement.Add怎么用?C# RootElement.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RootElement
的用法示例。
在下文中一共展示了RootElement.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateTable
/// <summary>
/// Populates the page with sessions, grouped by time slot
/// that are marked as 'favorite'
/// </summary>
protected override void PopulateTable()
{
// get the sessions from the database
var sessions = BL.Managers.SessionManager.GetSessions ();
var favs = BL.Managers.FavoritesManager.GetFavorites();
// extract IDs from Favorites query
List<string> favoriteIDs = new List<string>();
foreach (var f in favs) favoriteIDs.Add (f.SessionKey);
// build list, matching the Favorite.SessionKey with actual
// Session.Key rows - which might have moved if the data changed
var root = new RootElement ("Favorites") {
from s in sessions
where favoriteIDs.Contains(s.Key)
group s by s.Start.Ticks into g
orderby g.Key
select new Section (new DateTime (g.Key).ToString ("dddd HH:mm")) {
from hs in g
select (Element) new SessionElement (hs)
}};
if(root.Count == 0) {
var section = new Section("No favorites") {
new StyledStringElement("Touch the star to favorite a session")
};
root.Add(section);
}
Root = root;
}
示例2: Core
private void Core()
{
var rootStyles = new RootElement ("Add New Styles");
var styleHeaderElement = new Section ("Style Header");
var manualEntryRootElement = new RootElement ("Manual Entry");
styleHeaderElement.Add (manualEntryRootElement);
var quickFillElement = new Section ("Quick Fill");
var womenTops = new RootElement ("Womens Tops");
var womenOutwear = new RootElement ("Womens Outerwear");
var womenSweaters = new RootElement ("Womens Sweaters");
quickFillElement.AddAll (new [] { womenTops, womenOutwear, womenSweaters });
rootStyles.Add (new [] { styleHeaderElement, quickFillElement });
// DialogViewController derives from UITableViewController, so access all stuff from it
var rootDialog = new DialogViewController (rootStyles);
rootDialog.NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Bordered, null);
EventHandler handler = (s, e) => {
if(_popover != null)
_popover.Dismiss(true);
};
rootDialog.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, handler), true);
rootDialog.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Create", UIBarButtonItemStyle.Bordered, null), true);
NavigationPopoverContentViewController = new UINavigationController (rootDialog);
}
示例3: RenderIssue
public void RenderIssue()
{
if (ViewModel.Issue == null)
return;
var avatar = new Avatar(ViewModel.Issue.ReportedBy?.Avatar);
NavigationItem.RightBarButtonItem.Enabled = true;
HeaderView.Text = ViewModel.Issue.Title;
HeaderView.SetImage(avatar.ToUrl(), Images.Avatar);
HeaderView.SubText = ViewModel.Issue.Content ?? "Updated " + ViewModel.Issue.UtcLastUpdated.Humanize();
RefreshHeaderView();
var split = new SplitButtonElement();
split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
split.AddButton("Watches", ViewModel.Issue.FollowerCount.ToString());
var root = new RootElement(Title);
root.Add(new Section { split });
var secDetails = new Section();
if (!string.IsNullOrEmpty(ViewModel.Issue.Content))
{
_descriptionElement.LoadContent(new MarkdownRazorView { Model = ViewModel.Issue.Content }.GenerateString());
secDetails.Add(_descriptionElement);
}
_split1.Button1.Text = ViewModel.Issue.Status;
_split1.Button2.Text = ViewModel.Issue.Priority;
secDetails.Add(_split1);
_split2.Button1.Text = ViewModel.Issue.Metadata.Kind;
_split2.Button2.Text = ViewModel.Issue.Metadata.Component ?? "No Component";
secDetails.Add(_split2);
_split3.Button1.Text = ViewModel.Issue.Metadata.Version ?? "No Version";
_split3.Button2.Text = ViewModel.Issue.Metadata.Milestone ?? "No Milestone";
secDetails.Add(_split3);
var assigneeElement = new StyledStringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "Unassigned", UITableViewCellStyle.Value1) {
Image = AtlassianIcon.User.ToImage(),
Accessory = UITableViewCellAccessory.DisclosureIndicator
};
assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null);
secDetails.Add(assigneeElement);
root.Add(secDetails);
if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content)))
{
root.Add(new Section { _commentsElement });
}
var addComment = new StyledStringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() };
addComment.Tapped += AddCommentTapped;
root.Add(new Section { addComment });
Root = root;
}
示例4: CreateTable
private void CreateTable()
{
var application = Mvx.Resolve<IApplicationService>();
var vm = (SettingsViewModel)ViewModel;
var currentAccount = application.Account;
var showOrganizationsInEvents = new TrueFalseElement("Show Teams under Events", currentAccount.ShowTeamEvents, e =>
{
currentAccount.ShowTeamEvents = e.Value;
application.Accounts.Update(currentAccount);
});
var showOrganizations = new TrueFalseElement("List Teams & Groups in Menu", currentAccount.ExpandTeamsAndGroups, e =>
{
currentAccount.ExpandTeamsAndGroups = e.Value;
application.Accounts.Update(currentAccount);
});
var repoDescriptions = new TrueFalseElement("Show Repo Descriptions", currentAccount.RepositoryDescriptionInList, e =>
{
currentAccount.RepositoryDescriptionInList = e.Value;
application.Accounts.Update(currentAccount);
});
var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, UIKit.UITableViewCellStyle.Value1)
{
Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator,
};
startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);
//Assign the root
var root = new RootElement(Title);
root.Add(new Section());
root.Add(new Section { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
root.Add(new Section { new StyledStringElement("Source Code", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://github.com/thedillonb/CodeBucket"))) });
root.Add(new Section(String.Empty, "Thank you for downloading. Enjoy!")
{
new StyledStringElement("Follow On Twitter", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/Codebucketapp"))),
new StyledStringElement("Rate This App", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codebucket/id551531422?mt=8"))),
new StyledStringElement("App Version", NSBundle.MainBundle.InfoDictionary.ValueForKey(new NSString("CFBundleVersion")).ToString())
});
root.UnevenRows = true;
Root = root;
}
示例5: BuildRoot
private RootElement BuildRoot(string url)
{
var root = new RootElement (String.Empty);
var section = new Section("TodoItems");
root.Add (section);
var result = GetAzureResult (url);
foreach (JsonObject item in result) {
section.Add (new StringElement(item["text"]));
}
return root;
}
示例6: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// create from view
var dialogListView = new DialogListView(this);
SetContentView(dialogListView);
RootElement root = new RootElement("Elements");
Section section = new Section();
root.Add(section);
foreach (var item in _names) {
section.Add(new StringElement(item.LastName, item.FirstName, "custom_string_element"));
}
dialogListView.Root = root;
}
示例7: InitializeRoot
RootElement InitializeRoot()
{
RootElement root = new RootElement("Elements");
Section section = new Section("Section");
root.Add(section);
section.Add(new EntryElement("Label 1", "Value 1"));
section.Add(new EntryElement("Label 2", "Value 2"));
section.Add(new EntryElement("Label 3", "Value 3"));
section.Add(new EntryElement("Label 4", "Value 4"));
section.Add(new EntryElement("Label 5", "Value 5"));
section.Add(new EntryElement("Label 6", "Value 6"));
section.Add(new WebContentElement("http://www.google.com")
{
WebContent = "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>"
});
//section.Add(new EntryElement("Label 7", "Value 7"));
return root;
}
示例8: CreateTable
private void CreateTable()
{
var application = Mvx.Resolve<IApplicationService>();
var vm = (SettingsViewModel)ViewModel;
var currentAccount = application.Account;
var showOrganizationsInEvents = new TrueFalseElement("Show Teams under Events", currentAccount.ShowTeamEvents, e =>
{
currentAccount.ShowTeamEvents = e.Value;
application.Accounts.Update(currentAccount);
});
var showOrganizations = new TrueFalseElement("List Teams & Groups in Menu", currentAccount.ExpandTeamsAndGroups, e =>
{
currentAccount.ExpandTeamsAndGroups = e.Value;
application.Accounts.Update(currentAccount);
});
var repoDescriptions = new TrueFalseElement("Show Repo Descriptions", currentAccount.RepositoryDescriptionInList, e =>
{
currentAccount.RepositoryDescriptionInList = e.Value;
application.Accounts.Update(currentAccount);
});
var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, UIKit.UITableViewCellStyle.Value1)
{
Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator,
};
startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);
//Assign the root
var root = new RootElement(Title);
root.Add(new Section("Apperance") { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
Root = root;
}
示例9: Populate
private void Populate(object callbacks, object o, RootElement root)
{
MemberInfo last_radio_index = null;
var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance);
Section section = null;
foreach (var mi in members)
{
Type mType = GetTypeForMember(mi);
if (mType == null)
continue;
string caption = null;
object[] attrs = mi.GetCustomAttributes(false);
bool skip = false;
foreach (var attr in attrs)
{
if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
skip = true;
else if (attr is CaptionAttribute)
caption = ((CaptionAttribute)attr).Caption;
else if (attr is SectionAttribute)
{
if (section != null)
root.Add(section);
var sa = attr as SectionAttribute;
section = new Section(sa.Caption, sa.Footer);
}
}
if (skip)
continue;
if (caption == null)
caption = MakeCaption(mi.Name);
if (section == null)
section = new Section();
Element element = null;
if (mType == typeof(string))
{
PasswordAttribute pa = null;
AlignmentAttribute align = null;
EntryAttribute ea = null;
object html = null;
Action invoke = null;
bool multi = false;
foreach (object attr in attrs)
{
if (attr is PasswordAttribute)
pa = attr as PasswordAttribute;
else if (attr is EntryAttribute)
ea = attr as EntryAttribute;
else if (attr is MultilineAttribute)
multi = true;
else if (attr is HtmlAttribute)
html = attr;
else if (attr is AlignmentAttribute)
align = attr as AlignmentAttribute;
if (attr is OnTapAttribute)
{
string mname = ((OnTapAttribute)attr).Method;
if (callbacks == null)
{
throw new Exception(
"Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor");
}
var method = callbacks.GetType().GetMethod(mname);
if (method == null)
throw new Exception("Did not find method " + mname);
invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); };
}
}
var value = (string)GetValue(mi, o);
if (pa != null)
element = new EntryElement(caption, pa.Placeholder, value, true);
else if (ea != null)
element = new EntryElement(caption, ea.Placeholder, value) { KeyboardType = ea.KeyboardType };
else if (multi)
element = new MultilineElement(caption, value);
else if (html != null)
element = new HtmlElement(caption, value);
else
{
var selement = new StringElement(caption, value);
element = selement;
if (align != null)
selement.Alignment = align.Alignment;
}
if (invoke != null)
//.........这里部分代码省略.........
示例10: CreateMenuRoot
protected override void CreateMenuRoot()
{
var username = ViewModel.Account.Username;
Title = username;
var root = new RootElement(username);
root.Add(new Section
{
new MenuElement("Profile", () => ViewModel.GoToProfileCommand.Execute(null), AtlassianIcon.User.ToImage()),
});
var eventsSection = new Section { HeaderView = new MenuSectionView("Events") };
eventsSection.Add(new MenuElement(username, () => ViewModel.GoToMyEvents.Execute(null), AtlassianIcon.Blogroll.ToImage()));
if (ViewModel.Teams != null && ViewModel.Account.ShowTeamEvents)
ViewModel.Teams.ForEach(team => eventsSection.Add(new MenuElement(team, () => ViewModel.GoToTeamEventsCommand.Execute(team), AtlassianIcon.Blogroll.ToImage())));
root.Add(eventsSection);
var repoSection = new Section() { HeaderView = new MenuSectionView("Repositories") };
repoSection.Add(new MenuElement("Owned", () => ViewModel.GoToOwnedRepositoriesCommand.Execute(null), AtlassianIcon.Devtoolsrepository.ToImage()));
repoSection.Add(new MenuElement("Shared", () => ViewModel.GoToSharedRepositoriesCommand.Execute(null), AtlassianIcon.Spacedefault.ToImage()));
repoSection.Add(new MenuElement("Watched", () => ViewModel.GoToStarredRepositoriesCommand.Execute(null), AtlassianIcon.Star.ToImage()));
repoSection.Add(new MenuElement("Explore", () => ViewModel.GoToExploreRepositoriesCommand.Execute(null), AtlassianIcon.Search.ToImage()));
root.Add(repoSection);
if (ViewModel.PinnedRepositories.Any())
{
_favoriteRepoSection = new Section() { HeaderView = new MenuSectionView("Favorite Repositories") };
foreach (var pinnedRepository in ViewModel.PinnedRepositories)
_favoriteRepoSection.Add(new PinnedRepoElement(pinnedRepository, ViewModel.GoToRepositoryCommand));
root.Add(_favoriteRepoSection);
}
else
{
_favoriteRepoSection = null;
}
if (ViewModel.Account.ExpandTeamsAndGroups)
{
if (ViewModel.Groups?.Count > 0)
{
var groupsTeamsSection = new Section { HeaderView = new MenuSectionView("Groups") };
ViewModel.Groups.ForEach(x => groupsTeamsSection.Add(new MenuElement(x.Name, () => ViewModel.GoToGroupCommand.Execute(x), AtlassianIcon.Group.ToImage())));
root.Add(groupsTeamsSection);
}
if (ViewModel.Teams?.Count > 0)
{
var groupsTeamsSection = new Section { HeaderView = new MenuSectionView("Teams") };
ViewModel.Teams.ForEach(x => groupsTeamsSection.Add(new MenuElement(x, () => ViewModel.GoToTeamCommand.Execute(x), AtlassianIcon.Userstatus.ToImage())));
root.Add(groupsTeamsSection);
}
}
else
{
var groupsTeamsSection = new Section() { HeaderView = new MenuSectionView("Collaborations") };
groupsTeamsSection.Add(new MenuElement("Groups", () => ViewModel.GoToGroupsCommand.Execute(null), AtlassianIcon.Group.ToImage()));
groupsTeamsSection.Add(new MenuElement("Teams", () => ViewModel.GoToTeamsCommand.Execute(null), AtlassianIcon.Userstatus.ToImage()));
root.Add(groupsTeamsSection);
}
var infoSection = new Section() { HeaderView = new MenuSectionView("Info & Preferences") };
root.Add(infoSection);
infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.Execute(null), AtlassianIcon.Configure.ToImage()));
infoSection.Add(new MenuElement("Feedback & Support", () => ViewModel.GoToFeedbackCommand.Execute(null), AtlassianIcon.Comment.ToImage()));
infoSection.Add(new MenuElement("Accounts", () => ProfileButtonClicked(this, System.EventArgs.Empty), AtlassianIcon.User.ToImage()));
Root = root;
}
示例11: Render
public void Render()
{
if (ViewModel.Commits == null || ViewModel.Commit == null)
return;
var titleMsg = (ViewModel.Commit.Message ?? string.Empty).Split(new [] { '\n' }, 2).FirstOrDefault();
var avatarUrl = ViewModel.Commit.Author?.User?.Links?.Avatar?.Href;
var node = ViewModel.Node.Substring(0, ViewModel.Node.Length > 10 ? 10 : ViewModel.Node.Length);
Title = node;
HeaderView.Text = titleMsg ?? node;
HeaderView.SubText = "Commited " + (ViewModel.Commit.Date).Humanize();
HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar);
RefreshHeaderView();
var split = new SplitButtonElement();
split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
split.AddButton("Participants", ViewModel.Commit.Participants.Count.ToString());
split.AddButton("Approvals", ViewModel.Commit.Participants.Count(x => x.Approved).ToString());
var commitModel = ViewModel.Commits;
var root = new RootElement(Title) { UnevenRows = Root.UnevenRows };
root.Add(new Section { split });
var detailSection = new Section();
root.Add(detailSection);
var user = ViewModel.Commit.Author?.User?.DisplayName ?? ViewModel.Commit.Author.Raw ?? "Unknown";
detailSection.Add(new MultilinedElement(user, ViewModel.Commit.Message)
{
CaptionColor = Theme.CurrentTheme.MainTextColor,
ValueColor = Theme.CurrentTheme.MainTextColor,
BackgroundColor = UIColor.White
});
if (ViewModel.ShowRepository)
{
var repo = new StyledStringElement(ViewModel.Repository) {
Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator,
Lines = 1,
Font = StyledStringElement.DefaultDetailFont,
TextColor = StyledStringElement.DefaultDetailColor,
Image = Images.Repo
};
repo.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(null);
detailSection.Add(repo);
}
if (_viewSegment.SelectedSegment == 0)
{
var paths = ViewModel.Commits.GroupBy(y =>
{
var filename = "/" + y.File;
return filename.Substring(0, filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1);
}).OrderBy(y => y.Key);
foreach (var p in paths)
{
var fileSection = new Section(p.Key);
foreach (var x in p)
{
var y = x;
var file = x.File.Substring(x.File.LastIndexOf('/') + 1);
var sse = new ChangesetElement(file, x.Type, x.Diffstat.Added, x.Diffstat.Removed);
sse.Tapped += () => ViewModel.GoToFileCommand.Execute(y);
fileSection.Add(sse);
}
root.Add(fileSection);
}
}
else if (_viewSegment.SelectedSegment == 1)
{
var commentSection = new Section();
foreach (var comment in ViewModel.Comments)
{
var name = comment.User.DisplayName ?? comment.User.Username;
var imgUri = new Avatar(comment.User.Links?.Avatar?.Href);
commentSection.Add(new NameTimeStringElement(name, comment.Content.Raw, comment.CreatedOn, imgUri.ToUrl(), Images.Avatar));
}
if (commentSection.Elements.Count > 0)
root.Add(commentSection);
var addComment = new StyledStringElement("Add Comment") { Image = Images.Pencil };
addComment.Tapped += AddCommentTapped;
root.Add(new Section { addComment });
}
else if (_viewSegment.SelectedSegment == 2)
{
var likeSection = new Section();
likeSection.AddAll(ViewModel.Commit.Participants.Where(x => x.Approved).Select(l => {
var el = new UserElement(l.User.DisplayName, string.Empty, string.Empty, l.User.Links.Avatar.Href);
el.Tapped += () => ViewModel.GoToUserCommand.Execute(l.User.Username);
return el;
}));
if (likeSection.Elements.Count > 0)
root.Add(likeSection);
//.........这里部分代码省略.........
示例12: Render
public void Render()
{
if (ViewModel.PullRequest == null)
return;
var avatarUrl = ViewModel.PullRequest.Author?.Links?.Avatar?.Href;
HeaderView.Text = ViewModel.PullRequest.Title;
HeaderView.SubText = "Updated " + ViewModel.PullRequest.UpdatedOn.Humanize();
HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar);
RefreshHeaderView();
var split = new SplitButtonElement();
split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
split.AddButton("Participants", ViewModel.PullRequest.Participants.Count.ToString());
var root = new RootElement(Title);
root.Add(new Section { split });
var secDetails = new Section();
if (!string.IsNullOrWhiteSpace(ViewModel.Description))
{
if (_descriptionElement == null)
{
_descriptionElement = new WebElement("description");
_descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute;
}
_descriptionElement.LoadContent(new MarkdownRazorView { Model = ViewModel.Description }.GenerateString());
secDetails.Add(_descriptionElement);
}
var merged = ViewModel.Merged;
_split1.Value.Text1 = ViewModel.PullRequest.CreatedOn.ToString("MM/dd/yy");
_split1.Value.Text2 = merged ? "Merged" : "Not Merged";
secDetails.Add(_split1);
root.Add(secDetails);
root.Add(new Section {
new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), Images.Commit),
});
if (!merged)
{
Action mergeAction = async () =>
{
try
{
await this.DoWorkAsync("Merging...", ViewModel.Merge);
}
catch (Exception e)
{
MonoTouch.Utilities.ShowAlert("Unable to Merge", e.Message);
}
};
root.Add(new Section { new StyledStringElement("Merge", mergeAction, Images.Fork) });
}
var comments = ViewModel.Comments
.Where(x => !string.IsNullOrEmpty(x.Content.Raw) && x.Inline == null)
.OrderBy(x => (x.CreatedOn))
.Select(x =>
{
var name = x.User.DisplayName ?? x.User.Username ?? "Unknown";
var avatar = new Avatar(x.User.Links?.Avatar?.Href);
return new CommentViewModel(name, x.Content.Html, x.CreatedOn, avatar.ToUrl());
}).ToList();
if (comments.Count > 0)
{
if (_commentsElement == null)
{
_commentsElement = new WebElement("comments");
_commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute;
}
_commentsElement.LoadContent(new CommentsRazorView { Model = comments.ToList() }.GenerateString());
root.Add(new Section { _commentsElement });
}
var addComment = new StyledStringElement("Add Comment") { Image = Images.Pencil };
addComment.Tapped += AddCommentTapped;
root.Add(new Section { addComment });
Root = root;
}
示例13: CreateMenuRoot
protected override void CreateMenuRoot()
{
var username = ViewModel.Account.Username;
Title = username;
var root = new RootElement(username);
root.Add(new Section
{
new MenuElement("Profile", () => ViewModel.GoToProfileCommand.Execute(null), Images.Person),
});
var eventsSection = new Section { HeaderView = new MenuSectionView("Events") };
eventsSection.Add(new MenuElement(username, () => ViewModel.GoToMyEvents.Execute(null), Images.Event));
if (ViewModel.Teams != null && ViewModel.Account.ShowTeamEvents)
ViewModel.Teams.ForEach(team => eventsSection.Add(new MenuElement(team, () => ViewModel.GoToTeamEventsCommand.Execute(team), Images.Event)));
root.Add(eventsSection);
var repoSection = new Section() { HeaderView = new MenuSectionView("Repositories") };
repoSection.Add(new MenuElement("Owned", () => ViewModel.GoToOwnedRepositoriesCommand.Execute(null), Images.Repo));
repoSection.Add(new MenuElement("Shared", () => ViewModel.GoToSharedRepositoriesCommand.Execute(null), Images.BookLink));
repoSection.Add(new MenuElement("Watched", () => ViewModel.GoToStarredRepositoriesCommand.Execute(null), Images.Star));
repoSection.Add(new MenuElement("Explore", () => ViewModel.GoToExploreRepositoriesCommand.Execute(null), Images.Explore));
root.Add(repoSection);
if (ViewModel.PinnedRepositories.Any())
{
_favoriteRepoSection = new Section() { HeaderView = new MenuSectionView("Favorite Repositories") };
foreach (var pinnedRepository in ViewModel.PinnedRepositories)
_favoriteRepoSection.Add(new PinnedRepoElement(pinnedRepository, ViewModel.GoToRepositoryCommand));
root.Add(_favoriteRepoSection);
}
else
{
_favoriteRepoSection = null;
}
var groupsTeamsSection = new Section() { HeaderView = new MenuSectionView("Collaborations") };
if (ViewModel.Account.ExpandTeamsAndGroups)
{
if (ViewModel.Groups != null)
ViewModel.Groups.ForEach(x => groupsTeamsSection.Add(new MenuElement(x.Name, () => ViewModel.GoToGroupCommand.Execute(x), Images.Group)));
if (ViewModel.Teams != null)
ViewModel.Teams.ForEach(x => groupsTeamsSection.Add(new MenuElement(x, () => ViewModel.GoToTeamCommand.Execute(x), Images.Team)));
}
else
{
groupsTeamsSection.Add(new MenuElement("Groups", () => ViewModel.GoToGroupsCommand.Execute(null), Images.Group));
groupsTeamsSection.Add(new MenuElement("Teams", () => ViewModel.GoToTeamsCommand.Execute(null), Images.Team));
}
//There should be atleast 1 thing...
if (groupsTeamsSection.Elements.Count > 0)
root.Add(groupsTeamsSection);
var infoSection = new Section() { HeaderView = new MenuSectionView("Info & Preferences") };
root.Add(infoSection);
infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.Execute(null), Images.Cog));
infoSection.Add(new MenuElement("Feedback & Support", () => ViewModel.GoToFeedbackCommand.Execute(null), Images.Flag));
infoSection.Add(new MenuElement("Accounts", () => ProfileButtonClicked(this, System.EventArgs.Empty), Images.User));
Root = root;
}
示例14: Render
public void Render(RepositoryDetailedModel model)
{
Title = model.Name;
var avatar = new Avatar(model.Logo).ToUrl(128);
var root = new RootElement(Title) { UnevenRows = true };
HeaderView.SubText = string.IsNullOrWhiteSpace(model.Description) ? "Updated " + model.UtcLastUpdated.Humanize() : model.Description;
HeaderView.SetImage(avatar, Images.RepoPlaceholder);
RefreshHeaderView();
var split = new SplitButtonElement();
split.AddButton("Followers", model.FollowersCount.ToString());
split.AddButton("Forks", model.ForkCount.ToString());
var sec1 = new Section();
sec1.Add(new SplitElement(new SplitElement.Row {
Text1 = model.IsPrivate ? "Private" : "Public",
Image1 = model.IsPrivate ? Images.Locked : Images.Unlocked,
Text2 = string.IsNullOrEmpty(model.Language) ? "N/A" : model.Language,
Image2 = Images.Language
}));
//Calculate the best representation of the size
string size;
if (model.Size / 1024f < 1)
size = string.Format("{0:0.##}B", model.Size);
else if ((model.Size / 1024f / 1024f) < 1)
size = string.Format("{0:0.##}KB", model.Size / 1024f);
else
size = string.Format("{0:0.##}MB", model.Size / 1024f / 1024f);
//
// sec1.Add(new SplitElement(new SplitElement.Row {
// Text1 = model + (model.HasIssues == 1 ? " Issue" : " Issues"),
// Image1 = Images.Flag,
// Text2 = model.ForkCount.ToString() + (model.ForkCount == 1 ? " Fork" : " Forks"),
// Image2 = Images.Fork
// }));
//
sec1.Add(new SplitElement(new SplitElement.Row {
Text1 = (model.UtcCreatedOn).ToString("MM/dd/yy"),
Image1 = Images.Create,
Text2 = size,
Image2 = Images.Size
}));
var owner = new StyledStringElement("Owner", model.Owner) { Image = Images.Person, Accessory = UITableViewCellAccessory.DisclosureIndicator };
owner.Tapped += () => ViewModel.GoToOwnerCommand.Execute(null);
sec1.Add(owner);
if (model.ForkOf != null)
{
var parent = new StyledStringElement("Forked From", model.ForkOf.Name) { Image = Images.Fork, Accessory = UITableViewCellAccessory.DisclosureIndicator };
parent.Tapped += () => ViewModel.GoToForkParentCommand.Execute(model.ForkOf);
sec1.Add(parent);
}
var followers = new StyledStringElement("Watchers", "" + model.FollowersCount) { Image = Images.Star, Accessory = UITableViewCellAccessory.DisclosureIndicator };
followers.Tapped += () => ViewModel.GoToStargazersCommand.Execute(null);
sec1.Add(followers);
var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.Execute(null), Images.Event);
var sec2 = new Section { events };
if (model.HasWiki)
sec2.Add(new StyledStringElement("Wiki", () => ViewModel.GoToWikiCommand.Execute(null), Images.Pencil));
if (model.HasIssues)
sec2.Add(new StyledStringElement("Issues", () => ViewModel.GoToIssuesCommand.Execute(null), Images.Flag));
if (ViewModel.HasReadme)
sec2.Add(new StyledStringElement("Readme", () => ViewModel.GoToReadmeCommand.Execute(null), Images.File));
var sec3 = new Section
{
new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), Images.Commit),
new StyledStringElement("Pull Requests", () => ViewModel.GoToPullRequestsCommand.Execute(null), Images.Hand),
new StyledStringElement("Source", () => ViewModel.GoToSourceCommand.Execute(null), Images.Script),
};
root.Add(new[] { new Section { split }, sec1, sec2, sec3 });
if (!String.IsNullOrEmpty(ViewModel.Repository.Website))
{
root.Add(new Section
{
new StyledStringElement("Website", () => ViewModel.GoToUrlCommand.Execute(ViewModel.Repository.Website), Images.Webpage)
});
}
Root = root;
}
示例15: ViewWillAppear
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
var root = new RootElement(Title);
var accountSection = new Section();
var accounts = PopulateAccounts();
accountSection.AddAll(accounts);
root.Add(accountSection);
Root = root;
CheckEntries();
}