Exemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="recentProjects"></param>
 /// <param name="currentRecentProject"></param>
 /// <returns></returns>
 public static Recent Create(ImmutableArray<RecentProject> recentProjects, RecentProject currentRecentProject)
 {
     return new Recent()
     {
         RecentProjects = recentProjects,
         CurrentRecentProject = currentRecentProject
     };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Load recent project files.
        /// </summary>
        /// <param name="path"></param>
        public void LoadRecent(string path)
        {
            if (_serializer == null)
                return;

            try
            {
                var json = Utf8TextFile.Read(path);
                var recent = _serializer.Deserialize<Recent>(json);

                if (recent != null)
                {
                    var remove = recent.RecentProjects.Where(x => System.IO.File.Exists(x.Path) == false).ToList();
                    var builder = recent.RecentProjects.ToBuilder();

                    foreach (var file in remove)
                    {
                        builder.Remove(file);
                    }

                    RecentProjects = builder.ToImmutable();

                    if (recent.CurrentRecentProject != null
                        && System.IO.File.Exists(recent.CurrentRecentProject.Path))
                    {
                        CurrentRecentProject = recent.CurrentRecentProject;
                    }
                    else
                    {
                        CurrentRecentProject = _recentProjects.FirstOrDefault();
                    }
                }
            }
            catch (Exception ex)
            {
                if (_editor.Log != null)
                {
                    _editor.Log.LogError("{0}{1}{2}",
                        ex.Message,
                        Environment.NewLine,
                        ex.StackTrace);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add recent project file.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="name"></param>
        private void AddRecent(string path, string name)
        {
            var q = _recentProjects.Where(x => x.Path.ToLower() == path.ToLower()).ToList();
            var builder = _recentProjects.ToBuilder();

            if (q.Count() > 0)
            {
                foreach (var r in q)
                {
                    builder.Remove(r);
                }
            }

            builder.Insert(0, RecentProject.Create(name, path));

            RecentProjects = builder.ToImmutable();
            CurrentRecentProject = _recentProjects.FirstOrDefault();
        }