Example #1
0
        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>();
            }
        }
Example #2
0
        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);
        }
Example #3
0
        public void ShowProjects(ProjectToken[] projects)
        {
            projectList.Children.Clear();

            projects.Each(p =>
            {
                var link = new Link(p.Name, () => _controller.LoadProject(p));
                projectList.Children.Add(link);
            });
        }
Example #4
0
 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));
 }
Example #5
0
        public void Store(ProjectToken token)
        {
            if (_projects.Contains(token))
            {
                _projects.Remove(token);
            }

            _projects.Insert(0, token);

            while (_projects.Count > 4)
            {
                _projects.RemoveAt(4);
            }
        }
Example #6
0
        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);
        }
Example #8
0
        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);
        }
Example #10
0
 public void Remove(ProjectToken projectToken)
 {
     _projects.Remove(projectToken);
 }
Example #11
0
 /// <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));
 }
Example #12
0
 public void MarkAsLastAccessed(ProjectToken token)
 {
     _projects.Remove(token);
     _projects.Insert(0, token);
 }
Example #13
0
 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);
 }
Example #14
0
        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);
        }
Example #18
0
 public void MarkAsLastAccessed(ProjectToken token)
 {
     _projects.Remove(token);
     _projects.Insert(0, token);
 }
Example #19
0
 public void Remove(ProjectToken projectToken)
 {
     _projects.Remove(projectToken);
 }
Example #20
0
 /// <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)));
 }