/// <summary> /// Repopulates the team projects and children teams /// returns a started Task so it can be awaited on /// </summary> private static Task <List <TeamProjectViewModel> > UpdateTeamProjects() { Task <List <TeamProjectViewModel> > t = Task.Run <List <TeamProjectViewModel> >(() => { List <TeamProjectViewModel> result = new List <TeamProjectViewModel>(); try { var projects = FileIssueHelpers.GetProjectsAsync().Result; foreach (var project in projects.OrderBy(project => project.Name)) { var vm = new TeamProjectViewModel(project, new List <TeamProjectViewModel>()); result.Add(vm); } PopulateTreeviewWithTeams(result); return(result); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); return(null); } #pragma warning restore CA1031 // Do not catch general exception types }); return(t); }
/// <summary> /// Change the expanded and visibility properties on the view model and its children /// based on whether they pass the given filter /// </summary> /// <param name="node"></param> /// <param name="filter"></param> private void ModifyVisibility(TeamProjectViewModel node, Func <TeamProjectViewModel, bool> filter) { var matched = filter(node); node.Children.ForEach(c => ModifyVisibility(c, filter)); node.Expanded = node.Children.Any(c => c.Visibility == Visibility.Visible); bool shouldBeVisible = matched || node.Expanded; node.Visibility = shouldBeVisible ? Visibility.Visible : Visibility.Collapsed; // if a TreeViewItem previously selected by the user is now // hidden due to our search filter, we should deselect it. if (shouldBeVisible == false) { node.Selected = false; } }
/// <summary> /// Repopulates the team projects and children teams /// returns a started Task so it can be awaited on /// </summary> private static Task <List <TeamProjectViewModel> > UpdateTeamProjects() { Task <List <TeamProjectViewModel> > t = Task.Run <List <TeamProjectViewModel> >(() => { List <TeamProjectViewModel> result = new List <TeamProjectViewModel>(); try { var projects = FileIssueHelpers.GetProjectsAsync().Result; foreach (var project in projects.OrderBy(project => project.Name)) { var vm = new TeamProjectViewModel(project, new List <TeamProjectViewModel>()); result.Add(vm); } PopulateTreeviewWithTeams(result); return(result); } catch (Exception) { return(null); } }); return(t); }