static void RecurseAddDirectories(string path, IList nodes, List<Skin> skins) { var di = new DirectoryInfo(path); foreach (FileInfo file in di.GetFiles("*.png", SearchOption.TopDirectoryOnly)) { var skin = new Skin(file); nodes.Add(skin); if (_tempToSelect == null) _tempToSelect = skin; else if (GlobalSettings.LastSkin == skin.File.ToString()) _tempToSelect = skin; skins.Add(skin); } foreach (DirectoryInfo dir in di.GetDirectories()) { if ((dir.Attributes & FileAttributes.Hidden) != 0) continue; var folderNode = new FolderNode(dir.FullName); RecurseAddDirectories(dir.FullName, folderNode.Nodes, skins); nodes.Add(folderNode); } }
public static void LoadSkins() { var skins = new List<Skin>(); var rootNodes = new List<TreeNode>(); if (Editor.HasOneRoot) RecurseAddDirectories(Editor.RootFolderString, rootNodes, skins); else { foreach (string x in GlobalSettings.SkinDirectories) { var expanded = MacroHandler.ReplaceMacros(x); var folder = new FolderNode(expanded); RecurseAddDirectories(expanded, folder.Nodes, skins); rootNodes.Add(folder); } } Program.Context.SplashForm.Invoke((Action<List<TreeNode>>)Editor.MainForm.BeginFinishedLoadingSkins, rootNodes); var invalidSkins = new List<Skin>(); foreach (Skin s in skins) { if (!s.SetImages()) invalidSkins.Add(s); } skins.RemoveAll((s) => invalidSkins.Contains(s)); Program.Context.SplashForm.Invoke((Action<List<Skin>, TreeNode>)Editor.MainForm.FinishedLoadingSkins, skins, _tempToSelect); }
public static void LoadSkins() { var skins = new List <Skin>(); var rootNodes = new List <TreeNode>(); if (Editor.HasOneRoot) { RecurseAddDirectories(Editor.RootFolderString, rootNodes, skins); } else { foreach (string x in GlobalSettings.SkinDirectories) { var expanded = MacroHandler.ReplaceMacros(x); var folder = new FolderNode(new DirectoryInfo(expanded).Name); RecurseAddDirectories(expanded, folder.Nodes, skins); rootNodes.Add(folder); } } Program.Context.SplashForm.Invoke((Action <List <TreeNode> >)Editor.MainForm.BeginFinishedLoadingSkins, rootNodes); var invalidSkins = new List <Skin>(); foreach (Skin s in skins) { if (!s.SetImages()) { invalidSkins.Add(s); } } skins.RemoveAll((s) => invalidSkins.Contains(s)); Program.Context.SplashForm.Invoke((Action <List <Skin>, TreeNode>)Editor.MainForm.FinishedLoadingSkins, skins, _tempToSelect); }
public void PerformNewFolder() { if (!treeView1.Enabled) return; string folderLocation; TreeNodeCollection collection; if (_rightClickedNode == null || _rightClickedNode.Parent == null) _rightClickedNode = treeView1.SelectedNode; GetFolderLocationAndCollectionForNode(treeView1, _rightClickedNode, out folderLocation, out collection); if (collection == null || string.IsNullOrEmpty(folderLocation)) return; string newFolderName = "New Folder"; while (Directory.Exists(folderLocation + newFolderName)) newFolderName = newFolderName.Insert(0, GetLanguageString("C_NEW")); Directory.CreateDirectory(folderLocation + newFolderName); var newNode = new FolderNode(folderLocation + newFolderName); collection.Add(newNode); newNode.EnsureVisible(); treeView1.SelectedNode = newNode; treeView1.Invalidate(); PerformNameChange(); }