public void Start() { reloadProjectList(); ProjectToken token = _history.LastAccessed; bool projectLoaded = false; while (token != null) { if (LoadProject(token)) { projectLoaded = true; break; } else { token = _history.Next(token); } } if (!projectLoaded) { _conductor.OpenScreen <NewProjectSubject>(); } }
private void handleProjectLoadFailure(ProjectToken projectToken) { var message = new ProjectLoadFailureMessage { ErrorMessage = "Error loading project with filename: {0} \r\n\r\n Additional Information: {0}".ToFormat(projectToken.Filename), ProjectToken = projectToken }; handleProjectLoadFailure(message); }
public void ShowProjects(ProjectToken[] projects) { projectList.Children.Clear(); projects.Each(p => { var link = new Link(p.Name, () => _controller.LoadProject(p)); projectList.Children.Add(link); }); }
public bool Equals(ProjectToken obj) { if (ReferenceEquals(null, obj)) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } return(Equals(obj.Name, Name) && Equals(obj.Filename, Filename)); }
public void Store(ProjectToken token) { if (_projects.Contains(token)) { _projects.Remove(token); } _projects.Insert(0, token); while (_projects.Count > 4) { _projects.RemoveAt(4); } }
public void save_and_load_history() { var history = new ProjectHistory(); var theLastProject = new ProjectToken { Filename = "something", Name = "else" }; history.Store(theLastProject); persistor.SaveHistory(history); IProjectHistory history2 = persistor.LoadHistory(); history2.LastAccessed.ShouldEqual(theLastProject); }
public virtual bool LoadProject(ProjectToken token) { if (token == null) { return(false); } try { var project = _persistor.LoadFromFile(token.Filename); if (project == null) { handleProjectLoadFailure(token); return(false); } token.Name = project.Name; project.SelectWorkspaces(token.SelectedWorkspaces ?? new string[0]); ActivateProject(project); _history.MarkAsLastAccessed(token); _persistor.SaveHistory(_history); reloadProjectList(); _project = project; return(true); } catch (Exception e) { handleProjectLoadFailure(new ProjectLoadFailureMessage { ErrorMessage = "Error loading project with filename: {0}".ToFormat(token.Filename) + "\r\n" + e, ProjectToken = token }); return(false); } }
public void mark_as_last_accessed_from_empty() { var token = new ProjectToken { Filename = "project4.xml", Name = "project4" }; var history = new ProjectHistory(); history.MarkAsLastAccessed(token); history.Projects.Length.ShouldEqual(1); history.LastAccessed.ShouldBeTheSameAs(token); }
public void Remove(ProjectToken projectToken) { _projects.Remove(projectToken); }
/// <summary> /// Gets the next project in the history that is after the given token. /// </summary> /// <param name="token"></param> /// <returns></returns> public ProjectToken Next(ProjectToken token) { return Projects.FirstOrDefault(x => Array.IndexOf(Projects, x) > Array.IndexOf(Projects, token)); }
public void MarkAsLastAccessed(ProjectToken token) { _projects.Remove(token); _projects.Insert(0, token); }
public bool Equals(ProjectToken obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return Equals(obj.Name, Name) && Equals(obj.Filename, Filename); }
public void Store(ProjectToken token) { if (token.Filename.IsEmpty()) return; if (_projects.Contains(token)) { _projects.Remove(token); } _projects.Insert(0, token); while (_projects.Count > 4) { _projects.RemoveAt(4); } }
public void SetUp() { _history = new ProjectHistory(); _projectToken1 = new ProjectToken { Filename = "project1.xml", Name = "project1" }; _projectToken2 = new ProjectToken { Filename = "project2.xml", Name = "project2" }; _projectToken3 = new ProjectToken { Filename = "project3.xml", Name = "project3" }; _history.Store(_projectToken3); _history.Store(_projectToken2); _history.Store(_projectToken1); }
public void mark_as_last_accessed_when_the_project_is_not_the_most_recent_project() { var token = new ProjectToken { Filename = "project4.xml", Name = "project4" }; var history = new ProjectHistory(); history.Store(new ProjectToken { Filename = "project1.xml", Name = "project1" }); history.Store(new ProjectToken { Filename = "project2.xml", Name = "project2" }); history.Store(new ProjectToken { Filename = "project3.xml", Name = "project3" }); history.Store(token); history.MarkAsLastAccessed(token); history.LastAccessed.ShouldBeTheSameAs(token); history.Projects.Length.ShouldEqual(4); }
public void mark_as_last_accessed_when_the_project_is_already_the_most_recent_project() { var token = new ProjectToken { Filename = "project4.xml", Name = "project4" }; var history = new ProjectHistory(); history.Store(token); history.Store(new ProjectToken { Filename = "project1.xml", Name = "project1" }); history.Store(new ProjectToken { Filename = "project2.xml", Name = "project2" }); history.Store(new ProjectToken { Filename = "project3.xml", Name = "project3" }); history.MarkAsLastAccessed(token); }
/// <summary> /// Gets the next project in the history that is after the given token. /// </summary> /// <param name="token"></param> /// <returns></returns> public ProjectToken Next(ProjectToken token) { return(Projects.FirstOrDefault(x => Array.IndexOf(Projects, x) > Array.IndexOf(Projects, token))); }