Exemplo n.º 1
0
        public CollectionItem(ProjectBase projectInfo, List<ProjectCollectionTag> tagsData) : this()
        {
            _tagsData = tagsData;
            Project = projectInfo;

            _miniZoom = new DispatcherTimer { Interval = new TimeSpan(0, 0, 1) };
            _miniZoom.Tick += MiniZoomTick;

            Redraw();
        }
 public static bool LoadFromFile(string fileName, out ProjectBase obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an ProjectBase object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output ProjectBase object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out ProjectBase obj, out System.Exception exception)
 {
     exception = null;
     obj = default(ProjectBase);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string input, out ProjectBase obj)
 {
     System.Exception exception = null;
     return Deserialize(input, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an ProjectBase object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output ProjectBase object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out ProjectBase obj, out System.Exception exception)
 {
     exception = null;
     obj = default(ProjectBase);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Exemplo n.º 6
0
        private void CreateDirInTree(List<FolderItem> foldersTree, ProjectBase project)
        {

            var dirName = Path.GetDirectoryName(project.FullPath);
            if (dirName == null)
                return;
            var relativeDir = dirName.Substring(_projectCollection.RootDir.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
            var directories = relativeDir.Split(Path.DirectorySeparatorChar);

            var rootItem = foldersTree[0];

            var dir = GetDir(rootItem, directories, 0);
            project.Folder = dir;
            if (dir.Projects == null)
                dir.Projects = new List<ProjectBase>();
            dir.Projects.Add(project);
        }
Exemplo n.º 7
0
        private void TreeScan(DirectoryInfo parentDir, BackgroundWorker curWorker)
        {
            curWorker.ReportProgress(0, parentDir.FullName);


            //            var existDir = _projectCollection.Directory.FirstOrDefault(d => d.Name == dirName);
            foreach (var f in parentDir.GetFiles("*" + SolutionFileExt))
            {
                // Если проект уже найден
                if (_existProjects.Contains(f.FullName.ToLower()))
                    continue;
                /*var dirName = parentDir.FullName;
                dirName = NormalizePath(dirName);


                    if (dirName == _rootDirPath)
                    {

                    }
                    else
                    {
                        var relativeDir = dirName.Substring(_rootDirPath.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                        // Ищем среди каталогов нужный, если он существует
                        if (existDir != null)
                        {
                        }
                        else // если родительский каталог не найдн, создаём его
                        {
                            var directories = relativeDir.Split(Path.DirectorySeparatorChar);
                            var createdPath = string.Empty;
                            ProjectCollectionDirectory lastDir = null;
                            foreach (var directory in directories)
                            {
                                if (string.IsNullOrEmpty(createdPath))
                                    createdPath = directory;
                                else
                                    createdPath = Path.Combine(createdPath, directory);
                                var existParentDir = _projectCollection.Directory.FirstOrDefault(d => d.Path == createdPath);
                                if (existParentDir == null)
                                {

                                    var newDir = new ProjectCollectionDirectory
                                    {
                                        Id = createdPath.GetHashCode(),//(ulong) ((DateTime.Now.ToBinary() % 1000000000000)),
                                        Name = directory,
                                        Path = createdPath,
                                    };
                                    if (lastDir != null)
                                        newDir.ParentId = lastDir.Id;
                                    else
                                        newDir.ParentId = -1;

                                    _projectCollection.Directory.Add(newDir);
                                    lastDir = newDir;
                                }
                                else
                                    lastDir = existParentDir;
                            }

                            existDir = lastDir;
                        }
                    }*/
                //Debug.Assert(existDir != null);
                var newSolution = new SolutionBase
                {
                    CategoryId = -1,//existDir?.Id ?? 
                    Name = f.Name,
                    FullPath = f.FullName,

                };
                ScanFolder(newSolution, parentDir);

                _projectCollection.Project.Add(newSolution);
                _existProjects.Add(newSolution.FullPath.ToLower());

                //TbTest.Text += f.FullName + Environment.NewLine;
            }
            foreach (var f in parentDir.GetFiles("*" + ProjectFileExt))
            {
                if (_existProjects.Contains(f.FullName.ToLower()))
                    continue;

                //Debug.Assert(existDir != null);
                var newProject = new ProjectBase
                {
                    CategoryId = -1,//existDir?.Id ?? 
                    Name = f.Name,
                    FullPath = f.FullName,

                };
                ScanFolder(newProject, parentDir);

                _projectCollection.Project.Add(newProject);
                _existProjects.Add(newProject.FullPath.ToLower());

            }
            foreach (var d in parentDir.GetDirectories())
            {
                //var relativeDir = d.FullName.Substring(_rootDirPath.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                TreeScan(d, curWorker);
            }
        }
Exemplo n.º 8
0
        private static void ScanFolder(ProjectBase project, DirectoryInfo parentDir)
        {
            var filesInFolder = new FilesInFolder();
            var readmes = parentDir.GetFiles("readme.md");
            if (readmes.Length > 0)
            {
                filesInFolder.Readme = readmes[0];
            }

            var screenshots = parentDir.GetFiles("screenshot.png");
            if (screenshots.Length > 0)
            {
                filesInFolder.Screenshot = screenshots[0];
            }

            if (filesInFolder.Readme != null)
            {
                project.ReadmePath = filesInFolder.Readme.FullName;
                project.Value = File.ReadAllText(filesInFolder.Readme.FullName);
            }
            if (filesInFolder.Screenshot != null)
                project.ImagePath = filesInFolder.Screenshot.FullName;
        }
Exemplo n.º 9
0
        private void OnFileDrop(object sender, RoutedEventArgs e)
        {
            var dfc = (DropFileControl) sender;

            var fullProjectPath = dfc.DroppedFile;

            var ext = Path.GetExtension(fullProjectPath);
            var dirName = Path.GetDirectoryName(fullProjectPath);
            var dirInfo = new DirectoryInfo(dirName);
            var name = Path.GetFileNameWithoutExtension(fullProjectPath);


            ProjectBase newProject = null;
            if (ext == SolutionFileExt)
            {
                newProject = new SolutionBase();
                _projectCollection.Solution.Add((SolutionBase)newProject);
            }
            else if (ext == ProjectFileExt)
            {
                newProject = new ProjectBase();
                _projectCollection.Project.Add(newProject);
            }
            if (newProject == null) return;
            newProject.CategoryId = -1;
            newProject.Name = name;
            newProject.FullPath = fullProjectPath;

            ScanFolder(newProject, dirInfo);

            var item = new CollectionItem(newProject, _projectCollection.Tags);
            _collectionItems.Add(item);
            _existProjects.Add(newProject.FullPath.ToLower());

            CreateDirInTree(_folders, newProject);


            RefreshView();
            RefreshFolders();
        }
 public static bool LoadFromFile(string fileName, out ProjectBase obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
 public static bool Deserialize(string input, out ProjectBase obj)
 {
     System.Exception exception = null;
     return(Deserialize(input, out obj, out exception));
 }