コード例 #1
0
        private static void AddIfUnreferenced(ProjectItem item, ProjectBase project, List <FilePath> referencedFiles, List <ProjectSpecificFile> unreferencedFiles)
        {
            string nameToInclude;
            bool   isUnreferenced = GetIfIsUnreferenced(item, project, referencedFiles, out nameToInclude);

            if (isUnreferenced)
            {
                nameToInclude = ProjectManager.ContentProject.GetAbsoluteContentFolder() + nameToInclude;
                nameToInclude = nameToInclude.Replace(@"/", @"\");

                if (!mListBeforeAddition.Contains(nameToInclude.ToLower()))
                {
                    var projectSpecificFile = new ProjectSpecificFile()
                    {
                        FilePath    = nameToInclude.ToLower(),
                        ProjectName = project.Name
                    };

                    lock (mLastAddedUnreferencedFiles)
                    {
                        mLastAddedUnreferencedFiles.Add(projectSpecificFile);
                    }
                }
                unreferencedFiles.Add(new ProjectSpecificFile()
                {
                    FilePath    = nameToInclude,
                    ProjectName = project.Name
                });
            }
        }
コード例 #2
0
        private void BtnAddNewFileClick(object sender, System.EventArgs e)
        {
            if (!ProjectTypeIsValid())
            {
                return;
            }

            var nfw = new CustomizableNewFileWindow();

            foreach (var ati in AvailableAssetTypes.Self.AllAssetTypes)
            {
                if (!string.IsNullOrEmpty(ati.Extension) && !string.IsNullOrEmpty(ati.QualifiedSaveTypeName))
                {
                    nfw.AddOption(ati);
                }

                // special case .txt
                if (ati.Extension == "txt")
                {
                    nfw.AddOption(ati);
                }
            }

            // Also add CSV files
            //nfw.AddOption(new AssetTypeInfo("csv", "", null, "Spreadsheet (.csv)", "", ""));
            nfw.AddOption(AvailableAssetTypes.Self.AllAssetTypes.First(item => item.FriendlyName == "Spreadsheet (.csv)"));

            var dialogResult = nfw.ShowDialog();

            if (dialogResult == true)
            {
                AssetTypeInfo resultAssetTypeInfo = nfw.ResultAssetTypeInfo;
                bool          make2D = nfw.GetOptionFor(resultAssetTypeInfo) == "2D";

                string name = nfw.ResultName;

                string createdFile = PluginManager.CreateNewFile(resultAssetTypeInfo, make2D, FileManager.GetDirectoryKeepRelative(Rfs.Name), name);

                //var createdFile = resultAssetTypeInfo.CreateNewFile(FileManager.GetDirectoryKeepRelative(Rfs.Name) + name, "", make2D);
                createdFile = ProjectManager.MakeRelativeContent(createdFile);

                var psf = new ProjectSpecificFile
                {
                    ProjectName = cboProjectType.Text,
                    FilePath    = createdFile
                };

                Value.Add(psf);
                Rfs.ProjectSpecificFiles = Value;
                GlueCommands.Self.ProjectCommands.UpdateFileMembershipInProject(Rfs);
                ProjectManager.SaveProjects();
                GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();

                RefreshList();
            }
        }
        private void BtnAddExistingFileClick(object sender, System.EventArgs e)
        {
            if (!ProjectTypeIsValid())
            {
                return;
            }

            var openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }



            string projectDirectory = ProjectManager.ContentProject.GetAbsoluteContentFolder();
            string directoryThatFileShouldBeRelativeTo = ProjectManager.ContentDirectory + FileManager.GetDirectoryKeepRelative(Rfs.Name);
            string fileToAdd;

            if (!FileManager.IsRelativeTo(openFileDialog.FileName, projectDirectory))
            {
                fileToAdd = directoryThatFileShouldBeRelativeTo + FileManager.RemovePath(openFileDialog.FileName);
                fileToAdd = FileManager.MakeRelative(fileToAdd, projectDirectory);
                FileHelper.RecursivelyCopyContentTo(openFileDialog.FileName,
                                                    FileManager.GetDirectory(openFileDialog.FileName),
                                                    directoryThatFileShouldBeRelativeTo);
            }

            else
            {
                fileToAdd = FileManager.MakeRelative(openFileDialog.FileName, ProjectManager.ContentProject.GetAbsoluteContentFolder());
            }

            var psf = new ProjectSpecificFile
            {
                ProjectName = cboProjectType.Text,
                FilePath    = fileToAdd
            };

            Value.Add(psf);
            Rfs.ProjectSpecificFiles = Value;
            GlueCommands.Self.ProjectCommands.UpdateFileMembershipInProject(Rfs);
            ProjectManager.SaveProjects();
            GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();
            RefreshList();
        }
コード例 #4
0
        private void FillAllFilesWithFilesInList(List <string> allFiles, ReferencedFileSave[] referencedFileList,
                                                 TopLevelOrRecursive topLevelOrRecursive, ProjectOrDisk projectOrFile)
        {
            foreach (var rfs in referencedFileList)
            {
                allFiles.Add(rfs.Name);

                AddFilesReferenced(rfs.Name, allFiles, topLevelOrRecursive, projectOrFile);

                for (int i = 0; i < rfs.ProjectSpecificFiles.Count; i++)
                {
                    ProjectSpecificFile psf = rfs.ProjectSpecificFiles[i];

                    allFiles.Add(psf.FilePath);

                    AddFilesReferenced(psf.FilePath, allFiles, topLevelOrRecursive, projectOrFile);
                }
            }
        }