コード例 #1
0
        private void DeletePinnedRepo(PinnedRepoElement el)
        {
            ViewModel.DeletePinnedRepositoryCommand.Execute(el.PinnedRepo);

            if (_favoriteRepoSection.Count == 1)
            {
                Root.Remove(_favoriteRepoSection);
                _favoriteRepoSection = null;
            }
            else
            {
                _favoriteRepoSection.Remove(el);
            }
        }
コード例 #2
0
        private void DeletePinnedRepo(PinnedRepoElement el)
        {
            el.DeleteCommand.ExecuteNow();

            if (_favoriteRepoSection.Elements.Count == 1)
            {
                Root.Remove(_favoriteRepoSection);
                _favoriteRepoSection = null;
            }
            else
            {
                _favoriteRepoSection.Remove(el);
            }
        }
コード例 #3
0
ファイル: MenuView.cs プロジェクト: k4124k/CodeHub
		private void DeletePinnedRepo(PinnedRepoElement el)
		{
			ViewModel.DeletePinnedRepositoryCommand.Execute(el.PinnedRepo);

			if (_favoriteRepoSection.Elements.Count == 1)
			{
				Root.Remove(_favoriteRepoSection);
				_favoriteRepoSection = null;
			}
			else
			{
				_favoriteRepoSection.Remove(el);
			}
		}
コード例 #4
0
ファイル: MenuViewController.cs プロジェクト: zeroyou/CodeHub
        private void CreateMenuRoot()
        {
            var username = ViewModel.Account.Username;

            Title = username;
            ICollection <Section> sections = new LinkedList <Section>();

            sections.Add(new Section
            {
                new MenuElement("Profile", () => ViewModel.GoToProfileCommand.Execute(null), Octicon.Person.ToImage()),
                (_notifications = new MenuElement("Notifications", () => ViewModel.GoToNotificationsCommand.Execute(null), Octicon.Inbox.ToImage())
                {
                    NotificationNumber = ViewModel.Notifications
                }),
                new MenuElement("News", () => ViewModel.GoToNewsCommand.Execute(null), Octicon.RadioTower.ToImage()),
                new MenuElement("Issues", () => ViewModel.GoToMyIssuesCommand.Execute(null), Octicon.IssueOpened.ToImage())
            });

            Uri avatarUri;

            Uri.TryCreate(ViewModel.Account.AvatarUrl, UriKind.Absolute, out avatarUri);

            var eventsSection = new Section {
                HeaderView = new MenuSectionView("Events")
            };

            eventsSection.Add(new MenuElement(username, () => ViewModel.GoToMyEvents.Execute(null), Octicon.Rss.ToImage(), avatarUri));
            if (ViewModel.Organizations != null && ViewModel.Account.ShowOrganizationsInEvents)
            {
                foreach (var org in ViewModel.Organizations)
                {
                    Uri.TryCreate(org.AvatarUrl, UriKind.Absolute, out avatarUri);
                    eventsSection.Add(new MenuElement(org.Login, () => ViewModel.GoToOrganizationEventsCommand.Execute(org.Login), Octicon.Rss.ToImage(), avatarUri));
                }
            }
            sections.Add(eventsSection);

            var repoSection = new Section()
            {
                HeaderView = new MenuSectionView("Repositories")
            };

            repoSection.Add(new MenuElement("Owned", GoToOwnedRepositories, Octicon.Repo.ToImage()));
            repoSection.Add(new MenuElement("Starred", GoToStarredRepositories, Octicon.Star.ToImage()));
            repoSection.Add(new MenuElement("Trending", GoToTrendingRepositories, Octicon.Pulse.ToImage()));
            repoSection.Add(new MenuElement("Search", GoToSearch, Octicon.Search.ToImage()));
            sections.Add(repoSection);

            if (ViewModel.PinnedRepositories.Any())
            {
                _favoriteRepoSection = new Section {
                    HeaderView = new MenuSectionView("Favorite Repositories")
                };
                foreach (var pinnedRepository in ViewModel.PinnedRepositories)
                {
                    var element = new PinnedRepoElement(pinnedRepository);
                    element.Clicked.Subscribe(_ => GoToRepository(pinnedRepository.Owner, pinnedRepository.Name));
                    _favoriteRepoSection.Add(element);
                }

                sections.Add(_favoriteRepoSection);
            }
            else
            {
                _favoriteRepoSection = null;
            }

            var orgSection = new Section()
            {
                HeaderView = new MenuSectionView("Organizations")
            };

            if (ViewModel.Organizations != null && ViewModel.Account.ExpandOrganizations)
            {
                foreach (var org in ViewModel.Organizations)
                {
                    Uri.TryCreate(org.AvatarUrl, UriKind.Absolute, out avatarUri);
                    orgSection.Add(new MenuElement(org.Login, () => ViewModel.GoToOrganizationCommand.Execute(org.Login), Images.Avatar, avatarUri));
                }
            }
            else
            {
                orgSection.Add(new MenuElement("Organizations", () => ViewModel.GoToOrganizationsCommand.Execute(null), Octicon.Organization.ToImage()));
            }

            //There should be atleast 1 thing...
            if (orgSection.Elements.Count > 0)
            {
                sections.Add(orgSection);
            }

            var gistsSection = new Section()
            {
                HeaderView = new MenuSectionView("Gists")
            };

            gistsSection.Add(new MenuElement("My Gists", GoToOwnedGists, Octicon.Gist.ToImage()));
            gistsSection.Add(new MenuElement("Starred", GoToStarredGists, Octicon.Star.ToImage()));
            gistsSection.Add(new MenuElement("Public", GoToPublicGists, Octicon.Globe.ToImage()));
            sections.Add(gistsSection);
//
            var infoSection = new Section()
            {
                HeaderView = new MenuSectionView("Info & Preferences")
            };

            sections.Add(infoSection);
            infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.Execute(null), Octicon.Gear.ToImage()));

            if (ViewModel.ShouldShowUpgrades)
            {
                infoSection.Add(new MenuElement("Upgrades", GoToUpgrades, Octicon.Lock.ToImage()));
            }

            infoSection.Add(new MenuElement("Feedback & Support", GoToSupport, Octicon.CommentDiscussion.ToImage()));
            infoSection.Add(new MenuElement("Accounts", ProfileButtonClicked, Octicon.Person.ToImage()));

            Root.Reset(sections);
        }