/// <summary> /// Loads applications and groups within the current group /// as child tree nodes /// </summary> public void LoadChildren() { if (hasLoadedChildren) return; this.Nodes.Clear(); var children = GroupApplicationService.GetApplicationsInGroup(Application.Id); foreach (var child in children) { var group = child as EvolutionGroup; if (group != null) { var groupNode = new GroupTreeNode(group, GroupApplicationService); groupNode.Nodes.Add("Dummy"); this.Nodes.Add(groupNode); groupNode.LoadAvatar(); } else { var appNode = new ApplicationTreeNode(child); appNode.NodeFont = new Font(SystemFonts.DefaultFont, FontStyle.Regular); this.Nodes.Add(appNode); } } hasLoadedChildren = true; }
/// <summary> /// Event handler fired when the search button is clicked /// </summary> private void searchButton_Click(object sender, EventArgs e) { //Provide an indication that something's happening searchButton.Text = "Searching..."; searchButton.Enabled = false; //Empty existing search results searchApplicationTree.Nodes.Clear(); try { var results = GroupApplicationService.Search(searchTextBox.Text); if (results.Count() == 0) { // If there are no results, clear the image list to ensure // the message gets no default icon //searchApplicationTree.ImageList.Images.Clear(); searchApplicationTree.Nodes.Add("No results"); } else foreach (var app in results) { var group = app as EvolutionGroup; if (group == null) { var appNode = new ApplicationTreeNode(app); searchApplicationTree.Nodes.Add(appNode); } else { var groupNode = new GroupTreeNode(group, GroupApplicationService); searchApplicationTree.Nodes.Add(groupNode); groupNode.LoadAvatar(); } } } catch { // If there are no results, clear the image list to ensure // the message gets no default icon searchApplicationTree.ImageList.Images.Clear(); searchApplicationTree.Nodes.Add("An error occured whilst searching for applications"); } finally { // Reset the search button searchButton.Text = "Search"; searchButton.Enabled = true; } }