/// <summary> /// Pushes a project into the recent projects list. /// Pinned projects will not be removed. /// </summary> /// <param name="project"></param> public void PushRecentProject(StudioProject project) { var existing = RecentProjects.FindIndex(i => i.ID.Equals(project.Guid)); if (existing == -1) { logger.Info("Adding {0} to the recent project list.", project.Name); var info = new RecentProjectInfo { ID = project.Guid, Name = project.Name, Path = Path.Combine(project.ProjectDirectory, StudioProject.PROJECT_FILE), IsPinned = false }; // If the list if at capacity if (RecentProjects.Count >= RecentProjectsListCapacity) { // Remove the last unpinned entry var unpinned = RecentProjects.FindLastIndex(i => !i.IsPinned); if (unpinned != -1) { RecentProjects.RemoveAt(unpinned); RecentProjects.Insert(0, info); FirePropertyChanged("RecentProjects"); logger.Trace("Recent projects list at capacity, removed the last unpinned."); } else { logger.Trace("Recent projects list at capacity, no unpinned entries to remove."); } } else { RecentProjects.Insert(0, info); FirePropertyChanged("RecentProjects"); } } else { logger.Info("Moving {0} to the top of the RecentProjects list.", project.Name); var info = RecentProjects[existing]; RecentProjects.RemoveAt(existing); RecentProjects.Insert(0, info); } }
void TabChanged(int tab) { if (tab == 0) { for (int i = 0; i < Preferences.Recents.Count; i++) { RecentProjectInfo viewer = new RecentProjectInfo(Preferences.Recents[i]); viewer.Opened += ReadFile; viewer.Removed += Remove; viewer.Showed += App.URL; Recents.Children.Add(viewer); } } else { Recents.Children.Clear(); } }
/// <summary> /// Pushes a project into the recent projects list. /// Pinned projects will not be removed. /// </summary> /// <param name="project"></param> public void PushRecentProject(StudioProject project) { var existing = RecentProjects.FindIndex(i => i.ID.Equals(project.Guid)); if (existing == -1) { logger.Info("Adding {0} to the recent project list.", project.Name); var info = new RecentProjectInfo { ID = project.Guid, Name = project.Name, Path = Path.Combine(project.ProjectDirectory, StudioProject.PROJECT_FILE), IsPinned = false }; // If the list if at capacity if (RecentProjects.Count >= RecentProjectsListCapacity) { // Remove the last unpinned entry var unpinned = RecentProjects.FindLastIndex(i => !i.IsPinned); if (unpinned != -1) { RecentProjects.RemoveAt(unpinned); RecentProjects.Insert(0, info); FirePropertyChanged("RecentProjects"); logger.Trace("Recent projects list at capacity, removed the last unpinned."); } else logger.Trace("Recent projects list at capacity, no unpinned entries to remove."); } else { RecentProjects.Insert(0, info); FirePropertyChanged("RecentProjects"); } } else { logger.Info("Moving {0} to the top of the RecentProjects list.", project.Name); var info = RecentProjects[existing]; RecentProjects.RemoveAt(existing); RecentProjects.Insert(0, info); } }
void Remove(RecentProjectInfo sender, string path) { Preferences.RecentsRemove(path); Dispatcher.UIThread.Post(() => Recents.Children.Remove(sender), DispatcherPriority.MinValue); }