private void mnuClearUnpinnedItems_Click(object sender, EventArgs e) { foreach (string strFile in GlobalOptions.ReadMRUList()) { GlobalOptions.RemoveFromMRUList(strFile); } }
private void LoadCharacters() { TreeNode objFavouriteNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_FavouriteCharacters")) { Tag = "Favourite" }; TreeNode objRecentNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_RecentCharacters")) { Tag = "Recent" }; TreeNode objWatchNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_WatchFolder")) { Tag = "Watch" }; bool blnAddRecent = true; bool blnAddFavourite = true; bool blnAddWatch = true; foreach (string strFile in GlobalOptions.ReadMRUList("stickymru").Where(File.Exists)) { if (blnAddFavourite) { treCharacterList.Nodes.Add(objFavouriteNode); blnAddFavourite = false; } CacheCharacter(strFile, objFavouriteNode); } foreach (string strFile in GlobalOptions.ReadMRUList().Where(File.Exists)) { if (blnAddRecent) { treCharacterList.Nodes.Add(objRecentNode); blnAddRecent = false; } CacheCharacter(strFile, objRecentNode); } if (!string.IsNullOrEmpty(GlobalOptions.CharacterRosterPath) && Directory.Exists(GlobalOptions.CharacterRosterPath)) { string[] objFiles = Directory.GetFiles(GlobalOptions.CharacterRosterPath); //Make sure we're not loading a character that was already loaded by the MRU list. if (objFiles.Length > 0) { foreach (string strFile in objFiles.Where(strFile => strFile.EndsWith(".chum5"))) { var cache = lstCharacterCache.FirstOrDefault(objCache => objCache.FilePath == strFile); if (cache != null) { foreach (TreeNode rootNode in treCharacterList.Nodes) { if (rootNode.Nodes.Cast <TreeNode>().Any(childNode => Convert.ToInt32(childNode.Tag) == lstCharacterCache.IndexOf(cache))) { goto Loaded; } } } if (blnAddWatch) { treCharacterList.Nodes.Add(objWatchNode); blnAddWatch = false; } CacheCharacter(strFile, objWatchNode); Loaded :; } } } treCharacterList.ExpandAll(); }
private void mnuClearUnpinnedItems_Click(object sender, EventArgs e) { GlobalOptions.RemoveFromMRUList(GlobalOptions.ReadMRUList()); }
/// <summary> /// Populate the MRU items. /// </summary> public void PopulateMRUToolstripMenu() { List <string> strStickyMRUList = GlobalOptions.ReadMRUList("stickymru"); List <string> strMRUList = GlobalOptions.ReadMRUList(); for (int i = 0; i < 10; i++) { ToolStripMenuItem objStickyItem; ToolStripMenuItem objItem; switch (i) { case 0: objStickyItem = mnuStickyMRU0; objItem = mnuMRU0; break; case 1: objStickyItem = mnuStickyMRU1; objItem = mnuMRU1; break; case 2: objStickyItem = mnuStickyMRU2; objItem = mnuMRU2; break; case 3: objStickyItem = mnuStickyMRU3; objItem = mnuMRU3; break; case 4: objStickyItem = mnuStickyMRU4; objItem = mnuMRU4; break; case 5: objStickyItem = mnuStickyMRU5; objItem = mnuMRU5; break; case 6: objStickyItem = mnuStickyMRU6; objItem = mnuMRU6; break; case 7: objStickyItem = mnuStickyMRU7; objItem = mnuMRU7; break; case 8: objStickyItem = mnuStickyMRU8; objItem = mnuMRU8; break; case 9: objStickyItem = mnuStickyMRU9; objItem = mnuMRU9; break; default: continue; } if (i < strStickyMRUList.Count) { objStickyItem.Visible = true; objStickyItem.Text = strStickyMRUList[i]; mnuFileMRUSeparator.Visible = true; } else { objStickyItem.Visible = false; } if (i < strMRUList.Count) { objItem.Visible = true; if (i == 9) { objItem.Text = "1&0 " + strMRUList[i]; } else { objItem.Text = "&" + (i + 1).ToString() + " " + strMRUList[i]; } mnuFileMRUSeparator.Visible = true; } else { objItem.Visible = false; } } }
private void LoadCharacters() { List <string> lstFavorites = GlobalOptions.ReadMRUList("stickymru"); TreeNode objFavouriteNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_FavouriteCharacters", GlobalOptions.Language)) { Tag = "Favourite" }; List <string> lstRecents = GlobalOptions.ReadMRUList(); List <string> lstWatch = new List <string>(); TreeNode objWatchNode = null; if (!string.IsNullOrEmpty(GlobalOptions.CharacterRosterPath) && Directory.Exists(GlobalOptions.CharacterRosterPath)) { string[] objFiles = Directory.GetFiles(GlobalOptions.CharacterRosterPath, "*.chum5"); for (int i = 0; i < objFiles.Length; ++i) { string strFile = objFiles[i]; // Make sure we're not loading a character that was already loaded by the MRU list. if (lstFavorites.Contains(strFile) || lstRecents.Contains(strFile)) { continue; } int intCachedCharacterIndex = _lstCharacterCache.FindIndex(x => x.FilePath == strFile); if (intCachedCharacterIndex != -1) { foreach (TreeNode rootNode in treCharacterList.Nodes) { foreach (TreeNode objChildNode in rootNode.Nodes) { if (Convert.ToInt32(objChildNode.Tag) == intCachedCharacterIndex) { goto CharacterAlreadyLoaded; } } } } lstWatch.Add(strFile); CharacterAlreadyLoaded :; } } if (lstWatch.Count > 0) { objWatchNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_WatchFolder", GlobalOptions.Language)) { Tag = "Watch" }; } // Add any characters that are open to the displayed list so we can have more than 10 characters listed foreach (CharacterShared objCharacterForm in Program.MainForm.OpenCharacterForms) { string strFile = objCharacterForm.CharacterObject.FileName; // Make sure we're not loading a character that was already loaded by the MRU list. if (lstFavorites.Contains(strFile) || lstRecents.Contains(strFile) || lstWatch.Contains(strFile)) { continue; } int intCachedCharacterIndex = _lstCharacterCache.FindIndex(x => x.FilePath == strFile); if (intCachedCharacterIndex != -1) { foreach (TreeNode rootNode in treCharacterList.Nodes) { foreach (TreeNode objChildNode in rootNode.Nodes) { if (Convert.ToInt32(objChildNode.Tag) == intCachedCharacterIndex) { goto CharacterAlreadyLoaded; } } } } lstRecents.Add(strFile); CharacterAlreadyLoaded :; } TreeNode objRecentNode = null; if (lstRecents.Count > 0) { objRecentNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_RecentCharacters", GlobalOptions.Language)) { Tag = "Recent" }; } TreeNode[] lstFavoritesNodes = new TreeNode[lstFavorites.Count]; object lstFavoritesNodesLock = new object(); TreeNode[] lstRecentsNodes = new TreeNode[lstRecents.Count]; object lstRecentsNodesLock = new object(); TreeNode[] lstWatchNodes = new TreeNode[lstWatch.Count]; object lstWatchNodesLock = new object(); Parallel.Invoke( () => { if (objFavouriteNode != null) { Parallel.For(0, lstFavorites.Count, i => { string strFile = lstFavorites[i]; TreeNode objNode = CacheCharacter(strFile); lock (lstFavoritesNodesLock) lstFavoritesNodes[i] = objNode; }); for (int i = 0; i < lstFavoritesNodes.Length; i++) { TreeNode objNode = lstFavoritesNodes[i]; if (objNode != null) { objFavouriteNode.Nodes.Add(objNode); } } } }, () => { if (objRecentNode != null) { Parallel.For(0, lstRecents.Count, i => { string strFile = lstRecents[i]; TreeNode objNode = CacheCharacter(strFile); lock (lstRecentsNodesLock) lstRecentsNodes[i] = objNode; }); for (int i = 0; i < lstRecentsNodes.Length; i++) { TreeNode objNode = lstRecentsNodes[i]; if (objNode != null) { objRecentNode.Nodes.Add(objNode); } } } }, () => { if (objWatchNode != null) { Parallel.For(0, lstWatch.Count, i => { string strFile = lstWatch[i]; TreeNode objNode = CacheCharacter(strFile); lock (lstWatchNodesLock) lstWatchNodes[i] = objNode; }); for (int i = 0; i < lstWatchNodes.Length; i++) { TreeNode objNode = lstWatchNodes[i]; if (objNode != null) { objWatchNode.Nodes.Add(objNode); } } } }); treCharacterList.Nodes.Add(objFavouriteNode); if (objRecentNode != null) { treCharacterList.Nodes.Add(objRecentNode); } if (objWatchNode != null) { treCharacterList.Nodes.Add(objWatchNode); } treCharacterList.ExpandAll(); }
private void LoadCharacters() { List <string> lstFavorites = GlobalOptions.ReadMRUList("stickymru"); TreeNode objFavouriteNode = null; if (lstFavorites.Count > 0) { objFavouriteNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_FavouriteCharacters")) { Tag = "Favourite" }; } List <string> lstRecents = GlobalOptions.ReadMRUList(); TreeNode objRecentNode = null; if (lstRecents.Count > 0) { objRecentNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_RecentCharacters")) { Tag = "Recent" }; } List <string> lstWatch = new List <string>(); TreeNode objWatchNode = null; if (!string.IsNullOrEmpty(GlobalOptions.CharacterRosterPath) && Directory.Exists(GlobalOptions.CharacterRosterPath)) { string[] objFiles = Directory.GetFiles(GlobalOptions.CharacterRosterPath); //Make sure we're not loading a character that was already loaded by the MRU list. if (objFiles.Length > 0) { foreach (string strFile in objFiles.Where(strFile => strFile.EndsWith(".chum5"))) { CharacterCache objCachedCharacter = _lstCharacterCache.FirstOrDefault(x => x.FilePath == strFile); if (objCachedCharacter != null) { foreach (TreeNode rootNode in treCharacterList.Nodes) { foreach (TreeNode objChildNode in rootNode.Nodes) { if (Convert.ToInt32(objChildNode.Tag) == _lstCharacterCache.IndexOf(objCachedCharacter)) { goto CharacterAlreadyLoaded; } } } } lstWatch.Add(strFile); CharacterAlreadyLoaded :; } } } if (lstWatch.Count > 0) { objWatchNode = new TreeNode(LanguageManager.GetString("Treenode_Roster_WatchFolder")) { Tag = "Watch" }; } TreeNode[] lstFavoritesNodes = new TreeNode[lstFavorites.Count]; object lstFavoritesNodesLock = new object(); TreeNode[] lstRecentsNodes = new TreeNode[lstRecents.Count]; object lstRecentsNodesLock = new object(); TreeNode[] lstWatchNodes = new TreeNode[lstWatch.Count]; object lstWatchNodesLock = new object(); Parallel.Invoke( () => { if (objFavouriteNode != null) { Parallel.For(0, lstFavorites.Count, i => { string strFile = lstFavorites[i]; TreeNode objNode = CacheCharacter(strFile); lock (lstFavoritesNodesLock) lstFavoritesNodes[i] = objNode; }); } for (int i = 0; i < lstFavoritesNodes.Length; i++) { TreeNode objNode = lstFavoritesNodes[i]; if (objNode != null) { objFavouriteNode.Nodes.Add(objNode); } } }, () => { if (objRecentNode != null) { Parallel.For(0, lstRecents.Count, i => { string strFile = lstRecents[i]; TreeNode objNode = CacheCharacter(strFile); lock (lstRecentsNodesLock) lstRecentsNodes[i] = objNode; }); } for (int i = 0; i < lstRecentsNodes.Length; i++) { TreeNode objNode = lstRecentsNodes[i]; if (objNode != null) { objRecentNode.Nodes.Add(objNode); } } }, () => { if (objWatchNode != null) { Parallel.For(0, lstWatch.Count, i => { string strFile = lstWatch[i]; TreeNode objNode = CacheCharacter(strFile); lock (lstWatchNodesLock) lstWatchNodes[i] = objNode; }); } for (int i = 0; i < lstWatchNodes.Length; i++) { TreeNode objNode = lstWatchNodes[i]; if (objNode != null) { objWatchNode.Nodes.Add(objNode); } } }); if (objFavouriteNode != null) { treCharacterList.Nodes.Add(objFavouriteNode); } if (objRecentNode != null) { treCharacterList.Nodes.Add(objRecentNode); } if (objWatchNode != null) { treCharacterList.Nodes.Add(objWatchNode); } treCharacterList.ExpandAll(); }