private void InitRecentProjects() { RecentProjects.Clear(); XmlDocument doc = new XmlDocument(); var path = App.LocalRPAStudioDir + @"\Config\RecentProjects.xml"; doc.Load(path); var rootNode = doc.DocumentElement; var maxShowCount = Convert.ToInt32(rootNode.GetAttribute("MaxShowCount")); var projectNodes = rootNode.SelectNodes("Project"); foreach (XmlNode dir in projectNodes) { var filePath = (dir as XmlElement).GetAttribute("FilePath"); var name = (dir as XmlElement).GetAttribute("Name"); var description = (dir as XmlElement).GetAttribute("Description"); var item = new RecentProjectItem(); item.ProjectFilePath = filePath; item.ProjectName = name; item.ProjectDescription = description; RecentProjects.Add(item); maxShowCount--; if (maxShowCount == 0) { break; } } }
private void RecentFilesUpdated() { recent.Items.Clear(); foreach (FileInfo file in RecentProjects.Get()) { string projectTitle = "<Could not read campaign title>"; try { projectTitle = Json.Load <CampaignFile>(file).Metadata.Title; } finally { Button button; recent.Items.Add(new StackLayout() { Style = "no-padding vertical", Spacing = 2, Items = { (button = new Button() { Text = $"{projectTitle} ({file.Directory.FullName})" }) }, ContextMenu = new ContextMenu() { Items = { new ButtonMenuItem((sender, e) => RecentProjects.Remove(file)) { Text = "Remove", Image = Resources.GetIcon("CloseRed.ico") }, new ButtonMenuItem((sender, e) => RecentProjects.Clear()) { Text = "Clear all", Image = Resources.GetIcon("CloseGray.ico") } } } }); button.Click += (sender, e) => { RecentProjects.Update(file); editor.LoadFile(file); }; } } }
internal void LoadRecentProjects() { lock (RecentProjects) { RecentProjects.Clear(); foreach (var mruFile in GameStudioSettings.GetMostRecentlyUsed()) { RecentProjects.Add(new RecentProjectViewModel(this, mruFile)); } } }
private void LoadRecentProjects(XmlElement recentFiles) { try { int iChild, iRecentProject; string path, pathLower; XmlNode file; int numChildNodes = recentFiles.ChildNodes.Count; if (numChildNodes == 0) { return; } //清空ArrayList中之前所有的文件 RecentProjects.Clear(); for (iChild = 0; iChild < numChildNodes; iChild++) { file = recentFiles.ChildNodes[iChild]; path = Path.GetFullPath(file.InnerText); //获取绝对路径 //消除重复的条目 pathLower = path.ToLower(); iRecentProject = 0; while (iRecentProject < RecentProjects.Count && RecentProjects[iRecentProject].ToString().ToLower() != pathLower) { iRecentProject++; } //添加没有被删除的近期项目完整路径 if (iRecentProject == RecentProjects.Count && File.Exists(path)) { RecentProjects.Add(path); } } Program.frmMain.BuildRecentProjectsMenu(); } catch (Exception ex) { m_ErrorMsg += "在LoadRecentProjects方法中出现错误:" + ex.ToString(); m_ErrorOccured = true; return; } }