public GameFolderItemCollection SortFolders(string sortBy) { GameFolderItemCollection sortedCollection; if (sortBy.ToLower() == "size") { sortedCollection = new GameFolderItemCollection(GameFolders.Count); for (int i = 0; i < GameFolders.Count; i++) { var item = GameFolders[i]; var currentIndex = i; while (currentIndex > 0 && sortedCollection[currentIndex - 1].folderSize < item.folderSize) { currentIndex--; } sortedCollection.Insert(currentIndex, item); } } else { sortedCollection = GameFolders; } return(sortedCollection); }
private void OnSortIndexChanged(object sender, EventArgs e) { if (folderTreeView.SelectedNode != null) { flowLayoutPanel1.Controls.Clear(); FolderTreeNode node = (FolderTreeNode)folderTreeView.SelectedNode; GameFolderItemCollection test = node.SortFolders(comboBox1.SelectedItem.ToString()); foreach (GameFolderItem testItem in test) { flowLayoutPanel1.Controls.Add(testItem); } } }
public FolderTreeNode(string folderPath, string folderName = "") : base() { GameFolders = new GameFolderItemCollection(); this.FolderPath = folderPath; if (String.IsNullOrEmpty(folderName)) { this.Name = folderPath.Substring(folderPath.LastIndexOf('\\') + 1); } else { this.Name = folderName; } this.Text = folderName; }