예제 #1
0
 private void HandleLoadedSyncedProject(ProjectBase project)
 {
     if (NeedsXnbs(project))
     {
         AddXnbsToProject(project);
     }
 }
예제 #2
0
        public static bool IsOrphaned(ProjectItem buildItem, ProjectBase owner)
        {
            bool considerBuildItem = (buildItem.ItemType == "Compile" || buildItem.ItemType == "Content" || buildItem.ItemType == "None");

            if(!considerBuildItem)
            {
                if (owner is VisualStudioProject)
                {
                    var asVisualStudioProject = owner as VisualStudioProject;

                    if (!considerBuildItem && buildItem.ItemType == asVisualStudioProject.DefaultContentAction)
                    {
                        considerBuildItem = true;
                    }
                }
            }

            if (considerBuildItem)
            {
                // characters like '%' are encoded, so we have to decode them:
                string relativeName = System.Web.HttpUtility.UrlDecode( buildItem.UnevaluatedInclude);
                string fullName = owner.MakeAbsolute(relativeName);
                return !FileManager.FileExists(fullName) && buildItem.ItemType != "ProjectReference";
            }
            return false;
        }
예제 #3
0
        bool NeedsXnbs(ProjectBase project)
        {
            return project is IosMonogameProject || 
                project is Windows8MonoGameProject ||
                project is AndroidProject;

        }
예제 #4
0
        public static void OpenInVisualStudio(ProjectBase project)
        {
            string solutionName = ProjectSyncer.LocateSolution(project.FullFileName);

            string fileToOpen = null;

            if (string.IsNullOrEmpty(solutionName))
            {
                if (!PluginManager.OpenProject(project.FullFileName))
                {
                    fileToOpen = ProjectManager.ProjectBase.FullFileName;
                }
            }
            else
            {
                if (!PluginManager.OpenSolution(solutionName))
                {
                    fileToOpen = solutionName;
                }
            }


            if (!string.IsNullOrEmpty(fileToOpen))
            {
                var startedProcess = Process.Start(fileToOpen);

                if (startedProcess != null && startedProcess.ProcessName == "Glue")
                {
                    MessageBox.Show("Your machine has the file\n\n" + fileToOpen + "\n\nassociated with Glue.  " +
                        "It should probably be associated with a programming IDE like Visual Studio");
                }
            }
        }
예제 #5
0
 private void HandleLoadedSyncedProject(ProjectBase obj)
 {
     if (NeedsCopiedXnbs(obj))
     {
         foreach (var rfs in ObjectFinder.Self.GetAllReferencedFiles())
         {
             TryCopyingBuiltFile(ProjectManager.MakeAbsolute(rfs.Name), ErrorReportingStyle.GlueOutput);
         }
     }
 }
예제 #6
0
        public static ProjectBase LoadXnaProjectFor(ProjectBase masterProject, string fileName)
        {
            ProjectBase project = CreateProject(fileName);

            project.Load(fileName);

            project.MasterProjectBase = masterProject;

            project.IsContentProject = true;

            return project;

        }
예제 #7
0
        /// <summary>
        /// Adds the argument fileToAddAbsolute to the argument projectBase.  This function does not
        /// save the project nor does it modify synced projects.
        /// </summary>
        /// <param name="project">The project to add the file to.</param>
        /// <param name="fileToAddAbsolute">The file to add.</param>
        /// <returns>Whether the file was added.  This may be false if the file really is not a code file
        /// or if the file has already been added to the project.</returns>
        public bool AddFileToCodeProjectIfNotAlreadyAdded(ProjectBase project, string fileToAddAbsolute)
        {
            bool wasAdded = false;
            // If the file is absolute, shouldn't we make it relative?  Why are we sending "false" as the argument?
            //if (!project.IsFilePartOfProject(fileToAddAbsolute, BuildItemMembershipType.Any, false))
            if (!project.IsFilePartOfProject(fileToAddAbsolute, BuildItemMembershipType.Any, true))
            {
                wasAdded = AddFileToCodeProject(project, fileToAddAbsolute);
                
            }

            return wasAdded;
        }
예제 #8
0
        private void AddXnbsToProject(ProjectBase project)
        {
            bool wasAnythingChanged = false;

            // We need to loop through all of the items in the 
            // base project, see if they are audio files (this is all
            // we look at for now) then add them.
            IEnumerable<BuildItem> items = ProjectManager.ProjectBase.ContentProject.EvaluatedItems.Cast<BuildItem>();
            foreach (BuildItem buildItem in items.Where((item)=>
                ShouldAssociatedXnbBeCopied(item.Include, project)))
            {
                wasAnythingChanged |= AddAudioBuildItemToProject(project, buildItem);

            }

            if (wasAnythingChanged)
            {
                // We don't need to save the ContentProject
                // because there isn't one for W8
                project.Save(project.FullFileName);
            }
        }
예제 #9
0
        private List<string> GetEngineProjects(ProjectBase project)
        {
            var result = new List<string>();
            string str;

            if (project is FsbProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\FlatSilverBall\FlatRedBall.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) +
                      @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\SilverArcade.SilverSprite.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) +
                      @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\SilverArcade.SilverSprite.Core.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is MdxProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMDX\FRB.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is AndroidProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\FlatRedBallAndroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\MonoGame\ThirdParty\Lidgren.Network\Lidgren.Network.Android.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is WindowsPhoneProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallWindowsPhone.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is Xna360Project)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallXbox360.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.Content.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is Xna4_360Project)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallXbox4_360.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.ContentXna4.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is Xna4Project)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallXbox4.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.ContentXna4.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is XnaProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBall.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.Content.csproj";
                CheckFile(str);
                result.Add(str);
            }

            return result;
        }
예제 #10
0
 public override void SyncTo(ProjectBase projectBase, bool performTranslation)
 {
     throw new NotImplementedException();
 }
예제 #11
0
        private void LinkDlls(ProjectBase project)
        {
            var librariesPath = FileManager.GetDirectory(project.FullFileName) + @"Libraries\";
            string str, strPdb, engineStr, enginePdb;

            if (project is FsbProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if(str.Contains("FlatRedBall.dll"))
                    {
                        if(File.Exists(str))
                            File.Delete(str);
                        if(File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\FlatSilverBall\Bin\Debug\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\FlatSilverBall\Bin\Debug\FlatRedBall.pdb", IntPtr.Zero);
                    }else if(str.Contains("SilverArcade.SilverSprite.Core.dll"))
                    {
                        if(File.Exists(str))
                            File.Delete(str);
                        if(File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite.Core\Bin\Debug\SilverArcade.SilverSprite.Core.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite.Core\Bin\Debug\SilverArcade.SilverSprite.Core.pdb", IntPtr.Zero);
                    }else if(str.Contains("SilverArcade.SilverSprite.dll"))
                    {
                        if(File.Exists(str))
                            File.Delete(str);
                        if(File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\Bin\Debug\SilverArcade.SilverSprite.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\Bin\Debug\SilverArcade.SilverSprite.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is MdxProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBallMdx.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMDX\bin\Debug\FlatRedBallMdx.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMDX\bin\Debug\FlatRedBallMdx.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is AndroidProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid\bin\Debug\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid\bin\Debug\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("MonoGame.Framework.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\MonoGame\MonoGame.Framework\bin\Debug\MonoGame.Framework.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\MonoGame\MonoGame.Framework\bin\Debug\MonoGame.Framework.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("Lidgren.Network.Android.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\MonoGame\ThirdParty\Lidgren.Network\bin\Debug\Lidgren.Network.Android.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallAndroid\MonoGame\ThirdParty\Lidgren.Network\bin\Debug\Lidgren.Network.Android.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is WindowsPhoneProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Windows Phone\Debug\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Windows Phone\Debug\FlatRedBall.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is Xna4_360Project)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Xbox 360\Debug\XNA4\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Xbox 360\Debug\XNA4\FlatRedBall.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is Xna4Project)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna4.0\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna4.0\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("FlatRedBall.Content.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\Xna4.0\FlatRedBall.Content.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\Xna4.0\FlatRedBall.Content.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is XnaProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna3.1\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna3.1\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("FlatRedBall.Content.dll"))
                    {
                        if (File.Exists(str))
                            File.Delete(str);
                        if (File.Exists(strPdb))
                            File.Delete(strPdb);

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\FlatRedBall.Content.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\FlatRedBall.Content.pdb", IntPtr.Zero);
                    }
                }
            }
        }
        public void Setup()
        {
            executionEnvironment = new ExecutionEnvironment();

            project = new ConcreteProject();
        }
예제 #13
0
 public void SaveUserData(ProjectBase userProject)
 {
     //throw new NotImplementedException();
 }
예제 #14
0
        internal static void ReactToSyncedProjectLoad(ProjectBase projectBase)
        {
            SaveRelativeDirectory();

            CallMethodOnPlugin(
                delegate(PluginBase plugin)
                {
                    if (plugin.ReactToLoadedSyncedProject != null)
                        plugin.ReactToLoadedSyncedProject(projectBase);
                },
                "ReactToSyncedProjectLoad");

            ResumeRelativeDirectory("ReactToSyncedProjectLoad");
        }
예제 #15
0
        public bool AddFileToCodeProject(ProjectBase project, string fileToAddAbsolute)
        {
            bool wasAdded = false;

            string relativeFileName = FileManager.MakeRelative(
                fileToAddAbsolute,
                FileManager.GetDirectory(project.FullFileName));
            relativeFileName = relativeFileName.Replace("/", "\\");

            if (fileToAddAbsolute.EndsWith(".cs"))
            {
                // This should be a code item
                project.AddCodeBuildItem(relativeFileName);

                wasAdded = true;
            }
            return wasAdded;
        }
예제 #16
0
        public virtual string GenerateFilter(ProjectBase Project, string RootPath)
        {
            CPPProject project = (CPPProject)Project;

            XmlDocument document = new XmlDocument();

            XmlElement projectElement = document.CreateElement("Project");

            {
                document.AppendChild(projectElement);

                projectElement.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
                projectElement.SetAttribute("ToolsVersion", "4.0");

                XmlElement itemGroup = CreateElement("ItemGroup", projectElement);
                {
                    List <string> files = new List <string>();
                    files.AddRange(project.IncludeFiles);
                    files.AddRange(project.CompileFiles);
                    files.AddRange(project.ExtraFiles);

                    List <string> filtersName = new List <string>();

                    foreach (string file in files)
                    {
                        string filterName = GetFilterName(file, RootPath);

                        string[] parts = filterName.Split(EnvironmentHelper.PathSeparator);

                        string filter = string.Empty;
                        for (int i = 0; i < parts.Length; ++i)
                        {
                            if (i != 0)
                            {
                                filter += EnvironmentHelper.PathSeparator;
                            }

                            filter += parts[i];

                            if (filtersName.Contains(filter))
                            {
                                continue;
                            }

                            filtersName.Add(filter);
                        }
                    }

                    foreach (string filterName in filtersName)
                    {
                        XmlElement filter = CreateElement("Filter", itemGroup);
                        {
                            filter.SetAttribute("Include", filterName);

                            XmlElement identifier = CreateElement("UniqueIdentifier", filter);
                            identifier.InnerText = "{" + Guid.NewGuid() + "}";
                        }
                    }
                }

                XmlElement includeFiles = CreateElement("ItemGroup", projectElement);
                AddStringListToEllementAsAttributeAndFilter(includeFiles, "ClInclude", "Include", project.IncludeFiles, RootPath);

                XmlElement compileFiles = CreateElement("ItemGroup", projectElement);
                AddStringListToEllementAsAttributeAndFilter(includeFiles, "ClCompile", "Include", project.CompileFiles, RootPath);

                XmlElement noneFiles = CreateElement("ItemGroup", projectElement);
                AddStringListToEllementAsAttributeAndFilter(noneFiles, "None", "Include", project.ExtraFiles, RootPath);
            }

            return(projectElement.OwnerDocument.OuterXml);
        }
예제 #17
0
        public override string Generate(ProjectBase Project, bool WithBeutyConfigurationName)
        {
            CPPProject project = (CPPProject)Project;

            XmlElement projectElement = CreateProjectElement();

            {
                if (ToolsVersion >= ToolsVersions.v14_1)
                {
                    XmlElement winSDKVersion = CreateElement("WindowsTargetPlatformVersion", CreateElement("PropertyGroup", projectElement));
                    winSDKVersion.InnerText = InstalledWindowsKitVersion;
                }

                projectElement.SetAttribute("ToolsVersion", ToolsVersion.ToString().Substring(1).Replace('_', '.'));

                XmlElement itemGroup = CreateElement("ItemGroup", projectElement);
                {
                    for (int i = 0; i < project.Profiles.Length; ++i)
                    {
                        XmlElement projectConfiguration = CreateElement("ProjectConfiguration", itemGroup);
                        {
                            CPPProject.Profile profile = (CPPProject.Profile)project.Profiles[i];

                            projectConfiguration.SetAttribute("Include", GetConfigurationAndPlatform(profile, WithBeutyConfigurationName));

                            XmlElement configuration = CreateElement("Configuration", projectConfiguration);
                            configuration.InnerText = GetConfiguration(profile, WithBeutyConfigurationName);

                            XmlElement platform = CreateElement("Platform", projectConfiguration);
                            platform.InnerText = GetPlatformType(profile);
                        }
                    }
                }

                XmlElement includeFiles = CreateElement("ItemGroup", projectElement);
                AddStringListToEllementAsAttribute(includeFiles, "ClInclude", "Include", project.IncludeFiles);

                XmlElement compileFiles = CreateElement("ItemGroup", projectElement);
                AddStringListToEllementAsAttribute(includeFiles, "ClCompile", "Include", project.CompileFiles);

                XmlElement noneFiles = CreateElement("ItemGroup", projectElement);
                AddStringListToEllementAsAttribute(noneFiles, "None", "Include", project.ExtraFiles);

                XmlElement import = CreateElement("Import", projectElement);
                import.SetAttribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");

                for (int i = 0; i < project.Profiles.Length; ++i)
                {
                    CPPProject.Profile profile = (CPPProject.Profile)project.Profiles[i];

                    XmlElement popertyGroup = CreateElement("PropertyGroup", projectElement);
                    {
                        popertyGroup.SetAttribute("Condition", "'$(Configuration)|$(Platform)'=='" + GetConfigurationAndPlatform(profile, WithBeutyConfigurationName) + "'");

                        XmlElement configurationType = CreateElement("ConfigurationType", popertyGroup);
                        configurationType.InnerText = GetOutputType(profile);

                        XmlElement platformToolset = CreateElement("PlatformToolset", popertyGroup);
                        platformToolset.InnerText = ToolsVersion.ToString().Replace("_", "");
                    }

                    popertyGroup = CreateElement("PropertyGroup", projectElement);
                    {
                        popertyGroup.SetAttribute("Condition", "'$(Configuration)|$(Platform)'=='" + GetConfigurationAndPlatform(profile, WithBeutyConfigurationName) + "'");

                        if (profile.OutputType == ProjectBase.ProfileBase.OutputTypes.Makefile)
                        {
                            XmlElement nmakeBuildCommandLine = CreateElement("NMakeBuildCommandLine", popertyGroup);
                            nmakeBuildCommandLine.InnerText = profile.NMakeBuildCommandLine;

                            XmlElement nmakeRebuildCommandLine = CreateElement("NMakeReBuildCommandLine", popertyGroup);
                            nmakeRebuildCommandLine.InnerText = profile.NMakeReBuildCommandLine;

                            XmlElement nmakeCleanCommandLine = CreateElement("NMakeCleanCommandLine", popertyGroup);
                            nmakeCleanCommandLine.InnerText = profile.NMakeCleanCommandLine;

                            XmlElement nmakeIncludeSearchPath = CreateElement("NMakeIncludeSearchPath", popertyGroup);
                            nmakeIncludeSearchPath.InnerText = GetFlattenStringList(profile.IncludeDirectories);

                            XmlElement nmakeOutput = CreateElement("NMakeOutput", popertyGroup);
                            nmakeOutput.InnerText = profile.OutputPath;

                            XmlElement nmakePreprocessorDefinitions = CreateElement("NMakePreprocessorDefinitions", popertyGroup);
                            nmakePreprocessorDefinitions.InnerText = GetFlattenStringList(profile.PreprocessorDefinitions);
                        }
                        else
                        {
                            XmlElement outDir = CreateElement("OutDir", popertyGroup);
                            outDir.InnerText = profile.OutputPath;

                            XmlElement targetName = CreateElement("TargetName", popertyGroup);
                            targetName.InnerText = profile.AssemblyName;
                        }

                        XmlElement intDir = CreateElement("IntDir", popertyGroup);
                        intDir.InnerText = profile.IntermediatePath;
                    }
                }

                import = CreateElement("Import", projectElement);
                import.SetAttribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");

                for (int i = 0; i < project.Profiles.Length; ++i)
                {
                    CPPProject.Profile profile = (CPPProject.Profile)project.Profiles[i];

                    if (profile.OutputType == ProjectBase.ProfileBase.OutputTypes.Makefile)
                    {
                        continue;
                    }

                    XmlElement itemDefinitionGroup = CreateElement("ItemDefinitionGroup", projectElement);
                    {
                        itemDefinitionGroup.SetAttribute("Condition", "'$(Configuration)|$(Platform)'=='" + GetConfigurationAndPlatform(profile, WithBeutyConfigurationName) + "'");

                        XmlElement clCompile = CreateElement("ClCompile", itemDefinitionGroup);
                        {
                            XmlElement runtimeLibrary = CreateElement("RuntimeLibrary", clCompile);
                            runtimeLibrary.InnerText = profile.RuntimeLibrary.ToString();

                            XmlElement additionalIncludeDirectories = CreateElement("AdditionalIncludeDirectories", clCompile);
                            if (Array.IndexOf(profile.IncludeDirectories, "%(AdditionalIncludeDirectories)") == -1)
                            {
                                profile.AddIncludeDirectories("%(AdditionalIncludeDirectories)");
                            }
                            additionalIncludeDirectories.InnerText  = GetFlattenStringList(profile.IncludeDirectories);
                            additionalIncludeDirectories.InnerText += GetFlattenStringList(profile.IncludeLibraryDirectories);

                            XmlElement preprocessorDefinitions = CreateElement("PreprocessorDefinitions", clCompile);
                            if (Array.IndexOf(profile.PreprocessorDefinitions, "%(PreprocessorDefinitions)") == -1)
                            {
                                profile.AddPreprocessorDefinition("%(PreprocessorDefinitions)");
                            }
                            preprocessorDefinitions.InnerText = GetFlattenStringList(profile.PreprocessorDefinitions);

                            XmlElement optimization = CreateElement("Optimization", clCompile);
                            optimization.InnerText = profile.Optimization.ToString();

                            XmlElement minimalRebuild = CreateElement("MinimalRebuild", clCompile);
                            minimalRebuild.InnerText = profile.MinimalRebuild.ToString();
                        }

                        XmlElement importTargets = CreateElement("Import", projectElement);
                        importTargets.SetAttribute("Project", "$(VCTargetsPath)/Microsoft.Cpp.props");

                        XmlElement link = CreateElement("Link", itemDefinitionGroup);
                        {
                            XmlElement generateDebugInformation = CreateElement("GenerateDebugInformation", link);
                            generateDebugInformation.InnerText = profile.GenerateDebugInformation.ToString();

                            XmlElement additionalLibraryDirectories = CreateElement("AdditionalLibraryDirectories", link);
                            if (Array.IndexOf(profile.IncludeLibraryDirectories, "%(AdditionalLibraryDirectories)") == -1)
                            {
                                profile.AddIncludeLibraryDirectories("%(AdditionalLibraryDirectories)");
                            }
                            additionalLibraryDirectories.InnerText = GetFlattenStringList(profile.AdditionalLibraryDirectories);

                            XmlElement additionalLibraries = CreateElement("AdditionalDependencies", link);
                            if (Array.IndexOf(profile.IncludeLibraries, "%(AdditionalDependencies)") == -1)
                            {
                                profile.AddIncludeLibraries("%(AdditionalDependencies)");
                            }
                            additionalLibraries.InnerText = GetFlattenStringList(profile.IncludeLibraries);
                        }
                    }
                }

                import = CreateElement("Import", projectElement);
                import.SetAttribute("Project", "$(VCTargetsPath)/Microsoft.Cpp.targets");
            }

            return(projectElement.OwnerDocument.OuterXml);
        }
 public void PutProject(ProjectBase ObjProjectToUpdate)
 {
 }
예제 #19
0
 bool GetIfSupportsOrientation(ProjectBase projectBase)
 {
     return(projectBase is IosMonogameProject ||
            projectBase is AndroidProject ||
            projectBase is UwpProject);
 }
예제 #20
0
        private bool FixContentPipelineProjectValues(List <ReferencedFileSave> rfsList, ProjectBase contentProjectBase)
        {
            bool hasMadeChanges = false;

            if (contentProjectBase != null)
            {
                foreach (ReferencedFileSave rfs in rfsList)
                {
                    var item = contentProjectBase.GetItem(rfs.Name);


                    if (item != null)
                    {
                        if (rfs.UseContentPipeline)
                        {
                            if (rfs.TextureFormat == Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessorOutputFormat.DxtCompressed &&
                                !item.HasMetadata("ProcessorParameters_TextureProcessorOutputFormat"))
                            {
                                hasMadeChanges = true;
                                // Gotta make this thing use the DxtCompression
                                ContentPipelineHelper.UpdateTextureFormatFor(rfs);
                            }
                        }
                    }
                }
            }

            return(hasMadeChanges);
        }
예제 #21
0
        public static void CreateNewSyncedProject()
        {
            if (ProjectManager.ProjectBase == null)
            {
                MessageBox.Show(@"Can not create a new Synced Project because there is no open project.");
                return;
            }



            // Gotta find the .sln of this project so we can put the synced project in there
            var directory = GlueState.Self.CurrentSlnFileName?.GetDirectoryContainingThis();

            Process process = NewProjectHelper.RunNewProjectCreator(directory,
                                                                    GlueState.Self.ProjectNamespace, creatingSyncedProject: true);

            if (process != null)
            {
                while (!process.HasExited)
                {
                    Thread.Sleep(100);
                }

                string createdProject = GetCreatedProjectName(process);

                ProjectBase newProjectBase = null;

                if (!String.IsNullOrEmpty(createdProject))
                {
                    // The return value could be null if the project being added
                    // already exists as a synced project, but this should never be
                    // the case here.
                    newProjectBase = ProjectManager.AddSyncedProject(createdProject);
                    ProjectManager.SyncedProjects[ProjectManager.SyncedProjects.Count - 1].SaveAsRelativeSyncedProject = true;

                    GluxCommands.Self.SaveGlux();

                    // These are now part of the engine, so don't do anything here.
                    // Wait, these may be part of old templates, so let's keep this here.
                    if (File.Exists(newProjectBase.Directory + "Screens/Screen.cs"))
                    {
                        newProjectBase.RemoveItem(newProjectBase.Directory + "Screens/Screen.cs");
                        File.Delete(newProjectBase.Directory + "Screens/Screen.cs");
                    }

                    if (File.Exists(newProjectBase.Directory + "Screens/ScreenManager.cs"))
                    {
                        newProjectBase.RemoveItem(newProjectBase.Directory + "Screens/ScreenManager.cs");
                        File.Delete(newProjectBase.Directory + "Screens/ScreenManager.cs");
                    }

                    // Remove Game1.cs so that it will just use the same Game1 of the master project.
                    if (File.Exists(newProjectBase.Directory + "Game1.cs"))
                    {
                        newProjectBase.RemoveItem(newProjectBase.Directory + "Game1.cs");
                        File.Delete(newProjectBase.Directory + "Game1.cs");
                    }

                    // This line is slow. Not sure why..maybe the project is saving after every file is added?
                    // I could make it an async call but I want to figure out why it's slow at the core.
                    newProjectBase.SyncTo(ProjectManager.ProjectBase, false);

                    ProjectManager.SaveProjects();
                }
            }
        }
예제 #22
0
 public HomeViewModel()
 {
     P       = new ProjectBase();
     WaterIn = new WaterList();
     Calc    = new Calc(P, WaterIn);
 }
        static bool GetIfIsUnreferenced(BuildItem item, ProjectBase project, List<string> referencedFiles, out string nameToInclude)
        {
            bool isUnreferenced = false;

            string itemName = item.Include.ToLower().Replace(@"\", @"/");
            nameToInclude = item.Include;

            // no extensions are unsupported.  What do we do with the content pipeline?
            if (!string.IsNullOrEmpty(FileManager.GetExtension(itemName)))
            {

                if (itemName.StartsWith(".."))
                {
                    itemName = FileManager.Standardize(item.Include, project.ContentProject.Directory).ToLower();
                    if (itemName.ToLower().StartsWith(ProjectManager.ContentProject.Directory.ToLower() + ProjectManager.ContentProject.ContentDirectory.ToLower()))
                        itemName = itemName.Replace(ProjectManager.ContentProject.Directory.ToLower() + ProjectManager.ContentProject.ContentDirectory.ToLower(), "");

                    nameToInclude = FileManager.Standardize(item.Include, project.ContentProject.Directory);
                    if (nameToInclude.ToLower().StartsWith(ProjectManager.ContentProject.Directory.ToLower() + ProjectManager.ContentProject.ContentDirectory.ToLower()))
                        nameToInclude = nameToInclude.Substring((ProjectManager.ContentProject.Directory + ProjectManager.ContentProject.ContentDirectory).Length);
                }

                //if (nameToInclude.StartsWith(ContentProject.Directory + ContentProject.ContentDirectory))
                //{
                //    nameToInclude = nameToInclude.Substring((ContentProject.Directory + ContentProject.ContentDirectory).Length);
                //}

                bool isContent = ProjectManager.IsContent(itemName);

                isUnreferenced = isContent &&
                    File.Exists(ProjectManager.ContentProject.Directory + ProjectManager.ContentProject.ContentDirectory + nameToInclude) &&
                    !referencedFiles.Contains(itemName);

            }
            return isUnreferenced;
        }
예제 #24
0
 public MSBuildAssemblyReference(XmlElement xe, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache, string name, string priv, string hintpath, string extension)
     : base(new DummyXmlElement(xe.OwnerDocument), referencesResolver, parent, gacCache)
 {
     if (extension == null || extension.Length == 0)
     {
         extension = ".dll";
     }
     if (name.Contains(","))
     {
         //fully specified reference. Hmmm - just ignore it for now.
         name = name.Split(',')[0];
         //if (hintpath.Length == 0)  //hintpath workaround
         //    hintpath = "." + Path.DirectorySeparatorChar + name + extension; // ".dll";
     }
     _name         = name;
     _helper       = new MSBuildReferenceHelper(priv, false);
     _hintpath     = hintpath;
     _assemblyFile = ResolveAssemblyReference();
 }
예제 #25
0
        public static void SyncProjects(ProjectBase sourceProjectBase, ProjectBase projectBaseToModify, bool performTranslation)
        {
            // July 18, 2011
            // We used to pass
            // in the sourceProject
            // and the sourceContentProject
            // separately, but now the sourceProject
            // has a reference to the sourceContentProject,
            // so there's no need to do that.  I'm adding this
            // comment just in case at some point we were actually
            // passing in the two separately for some reason...although
            // I think it was done because this code was originally written
            // before ProjectBase had a ContentProject property.

            projectBaseToModify.SyncTo(sourceProjectBase, performTranslation);
        }
예제 #26
0
        private static bool AddAudioBuildItemToProject(ProjectBase project, ProjectItem buildItem)
        {
            bool wasAnythingChanged = false;
            // This item needs an associated entry in the project
            // The item will be relative to the main project as opposed
            // to the content project, inside the CopiedXnbs directory:
            string copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
                               buildItem.UnevaluatedInclude;

            var link = buildItem.GetLink();

            if (!string.IsNullOrEmpty(link))
            {
                copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
                            link;
            }

            copiedXnb = FileManager.RemoveDotDotSlash(copiedXnb);

            string extension = FileManager.GetExtension(buildItem.UnevaluatedInclude);

            bool isIos     = project is IosMonogameProject;
            bool isAndroid = project is AndroidProject;

            string whatToAddToProject = null;

            //
            bool copyOriginalFile = (isIos || isAndroid) && FileManager.GetExtension(buildItem.UnevaluatedInclude) != "wav";

            if (copyOriginalFile)
            {
                // Jan 1, 2014
                // Not sure why
                // we were making
                // this file absolute
                // using the synced project's
                // directory.  The file will be
                // shared by synced and original
                // projects so the file needs to be
                // made absolute according to that project.
                //whatToAddToProject = project.MakeAbsolute("content/" + buildItem.Include);
                whatToAddToProject = ProjectManager.MakeAbsolute("content/" + buildItem.UnevaluatedInclude, true);
            }
            else
            {
                whatToAddToProject = copiedXnb;
            }
            // Both sound and music files have XNBs associated with them so let's add that:
            whatToAddToProject = FileManager.RemoveExtension(whatToAddToProject) + ".xnb";
            copiedXnb          = FileManager.RemoveExtension(copiedXnb) + ".xnb";


            var item = project.GetItem(whatToAddToProject, true);

            if (item == null)
            {
                item = project.AddContentBuildItem(whatToAddToProject, SyncedProjectRelativeType.Linked, false);

                string linkToSet = null;

                if (!string.IsNullOrEmpty(buildItem.GetLink()))
                {
                    linkToSet = "Content\\" + FileManager.RemoveExtension(buildItem.GetLink()) + ".xnb";
                }
                else
                {
                    linkToSet = "Content\\" + FileManager.RemoveExtension(buildItem.UnevaluatedInclude) + ".xnb";
                }

                if (project is AndroidProject)
                {
                    linkToSet = "Assets\\" + linkToSet;
                }

                item.SetMetadataValue("Link", linkToSet);


                PluginManager.ReceiveOutput("Added " + buildItem.EvaluatedInclude + " through the file " + whatToAddToProject);
                wasAnythingChanged = true;
            }

            wasAnythingChanged |= FixLink(item, project);


            if (isIos && extension == "mp3")
            {
                if (FileManager.FileExists(copiedXnb))
                {
                    ReplaceWmaReferenceToMp3ReferenceInXnb(copiedXnb, whatToAddToProject);
                }
            }

            // I think we want to tell the user that the XNB is missing so they know to build the PC project
            if (!FileManager.FileExists(copiedXnb))
            {
                PluginManager.ReceiveError("XNB file is missing - try rebuilding PC project: " + copiedXnb);
            }

            // Music files also have a wma file:
            if ((extension == "mp3" || extension == "wma") &&
                // iOS doesn't ignore MP3, so it's already there.
                !isIos)
            {
                if (isIos)
                {
                    whatToAddToProject = "Content\\" + buildItem.UnevaluatedInclude;
                }
                else
                {
                    whatToAddToProject = FileManager.RemoveExtension(whatToAddToProject) + ".wma";
                }

                var item2 = project.GetItem(whatToAddToProject, true);

                if (item2 == null)
                {
                    item2 = project.AddContentBuildItem(whatToAddToProject, SyncedProjectRelativeType.Linked, false);
                    item2.SetMetadataValue("Link", "Content\\" + FileManager.RemoveExtension(buildItem.UnevaluatedInclude) + "." + FileManager.GetExtension(whatToAddToProject));

                    PluginManager.ReceiveOutput("Added " + buildItem.EvaluatedInclude + " through the file " + whatToAddToProject);
                    wasAnythingChanged = true;
                }

                wasAnythingChanged |= FixLink(item2, project);
            }
            return(wasAnythingChanged);
        }
예제 #27
0
 public override ProjectReferenceBase CreateProjectReference(ProjectBase project, bool isPrivateSpecified, bool isPrivate)
 {
     return(new MSBuildProjectReference(ReferencesResolver, this, project, isPrivateSpecified, isPrivate));
 }
예제 #28
0
        /// <summary>
        /// Adds the argument fileRelativeToProject to the argument project if it's not already part of the project.
        /// </summary>
        /// <param name="project"></param>
        /// <param name="fileName"></param>
        /// <param name="useContentPipeline">Whether this file must be part of the content pipeline. See internal notes on this variable.</param>
        /// <param name="shouldLink"></param>
        /// <param name="parentFile"></param>
        /// <returns>Whether the project was modified.</returns>
        public bool UpdateFileMembershipInProject(ProjectBase project, string fileName, bool useContentPipeline, bool shouldLink, string parentFile = null, bool recursive = true, List <string> alreadyReferencedFiles = null)
        {
            bool wasProjectModified = false;

            ///////////////////Early Out/////////////////////
            if (project == null || GlueState.Self.CurrentMainProject == null)
            {
                return(wasProjectModified);
            }

            /////////////////End Early Out//////////////////

            string fileToAddAbsolute = GlueCommands.Self.GetAbsoluteFileName(fileName, isContent: true);

            fileToAddAbsolute = fileToAddAbsolute.Replace("/", "\\");

            bool isFileAlreadyPartOfProject = false;

            bool needsToBeInContentProject = ShouldFileBeInContentProject(fileToAddAbsolute);

            BuildItemMembershipType bimt = BuildItemMembershipType.CopyIfNewer;

            // useContentPipeline can come from the parent file, if it uses content pipeline. But there may be other cases where we want to force content pepeline

            if (!useContentPipeline)
            {
                useContentPipeline = GetIfShouldUseContentPipeline(fileToAddAbsolute);
            }

            if (useContentPipeline)
            {
                bimt = BuildItemMembershipType.CompileOrContentPipeline;
            }
            else if (!project.ContentProject.ContentCopiedToOutput)
            {
                bimt = BuildItemMembershipType.Content;
            }

            if (!needsToBeInContentProject)
            {
                isFileAlreadyPartOfProject = project.IsFilePartOfProject(fileName, BuildItemMembershipType.CompileOrContentPipeline);
            }

            string fileRelativeToContent = FileManager.MakeRelative(
                fileToAddAbsolute,
                FileManager.GetDirectory(project.ContentProject.FullFileName));

            fileRelativeToContent = fileRelativeToContent.Replace("/", "\\");

            if (!isFileAlreadyPartOfProject && needsToBeInContentProject)
            {
                // Here we're going to get the absolute file name.
                // We want to get the file name

                isFileAlreadyPartOfProject = project.ContentProject.IsFilePartOfProject(fileRelativeToContent, bimt);

                if (!isFileAlreadyPartOfProject)
                {
                    var buildItem = project.ContentProject.GetItem(fileRelativeToContent);
                    if (buildItem != null)
                    {
                        // The item is here but it's using the wrong build types.  Let's
                        // remove it and readd it so that it gets added with the right options.
                        // Let's remove it and say it's not part of the project so it gets removed and readded
                        project.ContentProject.RemoveItem(fileRelativeToContent);
                    }
                }
            }


            bool shouldSkipAdd = useContentPipeline &&
                                 project.ContentProject is VisualStudioProject &&
                                 !((VisualStudioProject)project.ContentProject).AllowContentCompile;

            bool shouldRemoveFile = shouldSkipAdd &&
                                    project.ContentProject.IsFilePartOfProject(fileRelativeToContent, bimt);

            if (shouldRemoveFile)
            {
                // It's using content pipeline, so we use XNBs not PNGs
                var buildItem = project.ContentProject.GetItem(fileRelativeToContent);
                if (buildItem != null)
                {
                    // The item is here but it's using the wrong build types.  Let's
                    // remove it and readd it so that it gets added with the right options.
                    // Let's remove it and say it's not part of the project so it gets removed and readded
                    project.ContentProject.RemoveItem(fileRelativeToContent);
                }
            }


            if (!isFileAlreadyPartOfProject && !shouldSkipAdd)
            {
                wasProjectModified = true;

                if (needsToBeInContentProject)
                {
                    AddFileToContentProject(project, useContentPipeline, shouldLink, fileToAddAbsolute);
                }
                else
                {
                    ProjectManager.CodeProjectHelper.AddFileToCodeProject(project, fileToAddAbsolute);
                }
            }

            var listOfReferencedFiles = new List <string>();

            // Glue is going to assume .cs files can't reference content:
            if (!fileToAddAbsolute.EndsWith(".cs"))
            {
                FileReferenceManager.Self.GetFilesReferencedBy(fileToAddAbsolute, TopLevelOrRecursive.TopLevel, listOfReferencedFiles);

                if (alreadyReferencedFiles != null)
                {
                    listOfReferencedFiles = listOfReferencedFiles.Except(alreadyReferencedFiles).ToList();
                }
            }

            bool shouldAddChildren = true;


            if (fileName.EndsWith(".x") || useContentPipeline)
            {
                shouldAddChildren = false;
            }


            if (shouldAddChildren && listOfReferencedFiles != null && recursive)
            {
                for (int i = 0; i < listOfReferencedFiles.Count; i++)
                {
                    string file = listOfReferencedFiles[i];

                    if (file.Contains(@"../"))
                    {
                        string message = "The file\n\n" + fileToAddAbsolute + "\n\nincludes the file\n\n" + file + "\n\n" +
                                         "This file should not contain ../ in the path.  This likely happened if you saved the file " +
                                         "in a FRBDK tool and didn't select the \"Copy to relative\" option.\n\nYou should probably shut " +
                                         "down Glue, fix this problem, then re-open your project.";

                        System.Windows.Forms.MessageBox.Show(message);
                    }
                    else
                    {
                        wasProjectModified |= UpdateFileMembershipInProject(project, file, useContentPipeline, shouldLink, fileToAddAbsolute, recursive: true, alreadyReferencedFiles: listOfReferencedFiles);
                    }
                }
            }

            return(wasProjectModified);
        }
예제 #29
0
        public GraphicWindow(ProjectBase myBase)
        {
            InitializeComponent();
            ItemCollection <Author> authors = myBase.authors;

            if (authors.Count == 0)
            {
                return;
            }
            int max = authors.Max(x => x.Books.Count);

            for (int i = 1; i <= authors.Count; i++)
            {
                Line ln = new Line();
                ln.X1     = 50 + 1.0 * 530 * i / authors.Count;
                ln.X2     = 50 + 1.0 * 530 * i / authors.Count;
                ln.Y1     = 425;
                ln.Y2     = 435;
                ln.Stroke = Brushes.Black;
                field.Children.Add(ln);
                RotateTransform r = new RotateTransform()
                {
                    Angle = 25
                };
                TextBlock t = new TextBlock()
                {
                    RenderTransform = r
                };
                t.Foreground = Brushes.BlueViolet;
                t.Text       = authors[i - 1].Name;
                t.Margin     = new Thickness(30 + 1.0 * 530 * i / authors.Count, 445, 0, 0);
                field.Children.Add(t);
            }

            for (int i = 1; i <= max; i++)
            {
                Line ln = new Line();
                ln.Y1     = 430 - 1.0 * 350 * i / authors.Count;
                ln.Y2     = 430 - 1.0 * 350 * i / authors.Count;
                ln.X1     = 45;
                ln.X2     = 55;
                ln.Stroke = Brushes.Black;
                field.Children.Add(ln);
                TextBlock t = new TextBlock();
                t.Text   = i.ToString();
                t.Margin = new Thickness(35, 420 - 1.0 * 350 * i / authors.Count, 0, 0);
                field.Children.Add(t);
            }

            Polyline pl = new Polyline()
            {
                Stroke          = Brushes.Red,
                StrokeThickness = 3,
            };

            Panel.SetZIndex(pl, 1);
            for (int i = 1; i <= authors.Count; i++)
            {
                pl.Points.Add(new Point(50 + 1.0 * 530 * i / authors.Count, 430 - 350.0 * authors[i - 1].Books.Count / authors.Count));
            }
            for (int i = 1; i <= authors.Count; i++)
            {
                Ellipse el = new Ellipse();
                el.Fill   = Brushes.Blue;
                el.Width  = 10;
                el.Height = 10;
                Panel.SetZIndex(el, 2);
                el.Margin = new Thickness(45 + 1.0 * 530 * i / authors.Count, 425 - 350.0 * authors[i - 1].Books.Count / authors.Count, 0, 0);
                field.Children.Add(el);
            }
            field.Children.Add(pl);
        }
예제 #30
0
        private static void AddOrRemoveIndividualRfs(ReferencedFileSave rfs, List <string> filesInModifiedRfs, ref bool shouldRemoveAndAdd, ProjectBase projectBase)
        {
            List <ProjectBase> projectsAlreadyModified = new List <ProjectBase>();

            bool usesContentPipeline = rfs.UseContentPipeline || rfs.GetAssetTypeInfo() != null && rfs.GetAssetTypeInfo().MustBeAddedToContentPipeline;

            if (rfs.GetAssetTypeInfo() != null && rfs.GetAssetTypeInfo().MustBeAddedToContentPipeline&& rfs.UseContentPipeline == false)
            {
                rfs.UseContentPipeline = true;
                MessageBox.Show("The file " + rfs.Name + " must use the content pipeline");
            }
            else
            {
                string absoluteName = ProjectManager.MakeAbsolute(rfs.Name, true);

                shouldRemoveAndAdd = usesContentPipeline && !projectBase.IsFilePartOfProject(absoluteName, BuildItemMembershipType.CompileOrContentPipeline) ||
                                     !usesContentPipeline && !projectBase.IsFilePartOfProject(absoluteName, BuildItemMembershipType.CopyIfNewer);

                if (shouldRemoveAndAdd)
                {
                    projectBase.RemoveItem(absoluteName);
                    projectBase.AddContentBuildItem(absoluteName, SyncedProjectRelativeType.Contained, usesContentPipeline);
                    projectsAlreadyModified.Add(projectBase);

                    #region Loop through all synced projects and add or remove the file referenced by the RFS

                    foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                    {
                        ProjectBase syncedContentProjectBase = syncedProject;
                        if (syncedProject.ContentProject != null)
                        {
                            syncedContentProjectBase = syncedProject.ContentProject;
                        }

                        if (!projectsAlreadyModified.Contains(syncedContentProjectBase))
                        {
                            projectsAlreadyModified.Add(syncedContentProjectBase);
                            syncedContentProjectBase.RemoveItem(absoluteName);

                            if (syncedContentProjectBase.SaveAsAbsoluteSyncedProject)
                            {
                                syncedContentProjectBase.AddContentBuildItem(absoluteName, SyncedProjectRelativeType.Contained, usesContentPipeline);
                            }
                            else
                            {
                                syncedContentProjectBase.AddContentBuildItem(absoluteName, SyncedProjectRelativeType.Linked, usesContentPipeline);
                            }
                        }
                    }
                    #endregion

                    List <string> filesReferencedByAsset =
                        FileReferenceManager.Self.GetFilesReferencedBy(absoluteName, EditorObjects.Parsing.TopLevelOrRecursive.Recursive);

                    for (int i = 0; i < filesReferencedByAsset.Count; i++)
                    {
                        if (!filesInModifiedRfs.Contains(filesReferencedByAsset[i]))
                        {
                            filesInModifiedRfs.Add(filesReferencedByAsset[i]);
                        }
                    }
                }
            }
        }
예제 #31
0
        private static bool FixLink(BuildItem item, ProjectBase project)
        {
            bool didFix = false;

            string oldLink = item.GetLink();
            string newLink = project.ProcessLink(oldLink);

            if (oldLink != newLink)
            {
                item.SetLink(newLink);
                didFix = true;
            }


            return didFix;
        }
예제 #32
0
        private static void AddAndRemoveModifiedRfsFiles(List <ReferencedFileSave> rfses, List <string> filesInModifiedRfs, ProjectBase projectBase, bool usesContentPipeline)
        {
            if (filesInModifiedRfs.Count != 0)
            {
                for (int i = 0; i < filesInModifiedRfs.Count; i++)
                {
                    filesInModifiedRfs[i] = ProjectManager.MakeRelativeContent(filesInModifiedRfs[i]).ToLower();
                }

                List <ReferencedFileSave> allReferencedFiles = ObjectFinder.Self.GetAllReferencedFiles();
                foreach (ReferencedFileSave rfsToRemove in rfses)
                {
                    allReferencedFiles.Remove(rfsToRemove);
                }

                RemoveFilesFromListReferencedByRfses(filesInModifiedRfs, allReferencedFiles);

                #region Loop through all files to add/remove

                foreach (string fileToAddOrRemove in filesInModifiedRfs)
                {
                    List <ProjectBase> projectsAlreadyModified = new List <ProjectBase>();

                    // There are files referenced by the RFS that aren't referenced by others

                    // If moving to content pipeline, remove the files from the project.
                    // If moving to copy if newer, add the files back to the project.
                    string absoluteFileName = ProjectManager.MakeAbsolute(fileToAddOrRemove, true);

                    projectsAlreadyModified.Add(projectBase);

                    #region Uses the content pipeline, remove the file from all projects
                    if (usesContentPipeline)
                    {
                        // Remove this file - it'll automatically be handled by the content pipeline
                        projectBase.RemoveItem(absoluteFileName);

                        foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                        {
                            ProjectBase syncedContentProjectBase = syncedProject;
                            if (syncedProject.ContentProject != null)
                            {
                                syncedContentProjectBase = syncedProject.ContentProject;
                            }

                            if (!projectsAlreadyModified.Contains(syncedContentProjectBase))
                            {
                                projectsAlreadyModified.Add(syncedContentProjectBase);

                                syncedContentProjectBase.RemoveItem(absoluteFileName);
                            }
                        }
                    }
                    #endregion

                    #region Does not use the content pipeline - add the file if necessary

                    else
                    {
                        // This file may have alraedy been part of the project for whatever reason, so we
                        // want to make sure it's not already part of it when we try to add it
                        if (!projectBase.IsFilePartOfProject(absoluteFileName, BuildItemMembershipType.CopyIfNewer))
                        {
                            projectBase.AddContentBuildItem(absoluteFileName, SyncedProjectRelativeType.Contained, false);
                        }
                        foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                        {
                            ProjectBase syncedContentProjectBase = syncedProject;
                            if (syncedProject.ContentProject != null)
                            {
                                syncedContentProjectBase = syncedProject.ContentProject;
                            }

                            if (!projectsAlreadyModified.Contains(syncedContentProjectBase))
                            {
                                projectsAlreadyModified.Add(syncedContentProjectBase);

                                if (syncedContentProjectBase.SaveAsAbsoluteSyncedProject)
                                {
                                    syncedContentProjectBase.AddContentBuildItem(absoluteFileName, SyncedProjectRelativeType.Contained, false);
                                }
                                else
                                {
                                    if (!projectBase.IsFilePartOfProject(absoluteFileName, BuildItemMembershipType.CopyIfNewer))
                                    {
                                        syncedContentProjectBase.AddContentBuildItem(absoluteFileName, SyncedProjectRelativeType.Linked, false);
                                    }
                                }
                            }
                        }
                    }

                    #endregion
                }
                #endregion
            }
        }
예제 #33
0
        private static bool AddOrRemoveIndividualRfs(ReferencedFileSave rfs, List<string> filesInModifiedRfs, ref bool shouldRemoveAndAdd, ProjectBase projectBase)
        {

            List<ProjectBase> projectsAlreadyModified = new List<ProjectBase>();

            bool usesContentPipeline = rfs.UseContentPipeline || rfs.GetAssetTypeInfo() != null && rfs.GetAssetTypeInfo().MustBeAddedToContentPipeline;

            if (rfs.GetAssetTypeInfo() != null && rfs.GetAssetTypeInfo().MustBeAddedToContentPipeline && rfs.UseContentPipeline == false)
            {
                rfs.UseContentPipeline = true;
                MessageBox.Show("The file " + rfs.Name + " must use the content pipeline");

            }
            else
            {
                string absoluteName = ProjectManager.MakeAbsolute(rfs.Name, true);

                shouldRemoveAndAdd = usesContentPipeline && !projectBase.IsFilePartOfProject(absoluteName, BuildItemMembershipType.CompileOrContentPipeline) ||
                    !usesContentPipeline && !projectBase.IsFilePartOfProject(absoluteName, BuildItemMembershipType.CopyIfNewer);

                if (shouldRemoveAndAdd)
                {
                    projectBase.RemoveItem(absoluteName);
                    projectBase.AddContentBuildItem(absoluteName, SyncedProjectRelativeType.Contained, usesContentPipeline);
                    projectsAlreadyModified.Add(projectBase);

                    #region Loop through all synced projects and add or remove the file referenced by the RFS

                    foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                    {

                        ProjectBase syncedContentProjectBase = syncedProject;
                        if (syncedProject.ContentProject != null)
                        {
                            syncedContentProjectBase = syncedProject.ContentProject;
                        }

                        if (!projectsAlreadyModified.Contains(syncedContentProjectBase))
                        {
                            projectsAlreadyModified.Add(syncedContentProjectBase);
                            syncedContentProjectBase.RemoveItem(absoluteName);

                            if (syncedContentProjectBase.SaveAsAbsoluteSyncedProject)
                            {
                                syncedContentProjectBase.AddContentBuildItem(absoluteName, SyncedProjectRelativeType.Contained, usesContentPipeline);

                            }
                            else
                            {
                                syncedContentProjectBase.AddContentBuildItem(absoluteName, SyncedProjectRelativeType.Linked, usesContentPipeline);
                            }
                        }
                    }
                    #endregion

                    List<string> filesReferencedByAsset = 
                        FileReferenceManager.Self.GetFilesReferencedBy(absoluteName, EditorObjects.Parsing.TopLevelOrRecursive.Recursive);

                    for (int i = 0; i < filesReferencedByAsset.Count; i++)
                    {
                        if (!filesInModifiedRfs.Contains(filesReferencedByAsset[i]))
                        {
                            filesInModifiedRfs.Add(filesReferencedByAsset[i]);
                        }
                    }
                }
            }
            return usesContentPipeline;
        }
        private static void MoveReferencedFileToDirectory(ReferencedFileSave referencedFileSave, string targetDirectory)
        {
            // Things to do:
            // 1 Move the TreeNode from one parent TreeNode to another UPDATE:  We will just refresh the UI for the Element or GlobalContent
            // 2 Move the file from one folder to another
            // 3 Remove the BuildItems from the project and add them back in the VisualStudio project
            // 4 Change the ReferencedFileSave's name
            // 5 Re-generate the containing Element (Screen or Entity)
            // 6 Save everything

            string oldNodeText = referencedFileSave.Name.Replace("/", "\\");



            string newNodeText = FlatRedBall.IO.FileManager.MakeRelative(targetDirectory, ProjectManager.ProjectBase.GetAbsoluteContentFolder()) + FileManager.RemovePath(referencedFileSave.Name);

            newNodeText = newNodeText.Replace("/", "\\");

            string oldFileName = ProjectManager.MakeAbsolute(referencedFileSave.Name, true);
            string targetFile  = targetDirectory + FileManager.RemovePath(oldFileName);

            bool canMove = true;

            // There's so much error checking and validation that we
            // could/should do here, but man, I just can't spend forever
            // on it because I need to get the game I'm working on moving forward
            // But I'm going to at least improve it a little bit by having the referenced
            // files get copied over.
            Dictionary <string, string> mOldNewDependencyFileDictionary = new Dictionary <string, string>();
            List <string> referencedFiles  = ContentParser.GetFilesReferencedByAsset(oldFileName, TopLevelOrRecursive.Recursive);
            string        oldDirectoryFull = FileManager.GetDirectory(oldFileName);

            foreach (string file in referencedFiles)
            {
                string relativeToRfs = FileManager.MakeRelative(file, FileManager.GetDirectory(oldFileName));

                string targetReferencedFileName = targetDirectory + relativeToRfs;

                mOldNewDependencyFileDictionary.Add(file, targetReferencedFileName);

                if (!FileManager.IsRelativeTo(targetReferencedFileName, targetDirectory))
                {
                    MessageBox.Show("The file\n\n" + file + "\n\nis not relative to the file being moved, so it cannot be moved.  You must manually move these files and manually update the file reference.");
                    canMove = false;
                    break;
                }
            }


            if (canMove && File.Exists(targetFile))
            {
                MessageBox.Show("There is already a file by this name located in the directory you're trying to move to.");
                canMove = false;
            }
            if (canMove)
            {
                foreach (KeyValuePair <string, string> kvp in mOldNewDependencyFileDictionary)
                {
                    if (File.Exists(kvp.Value))
                    {
                        MessageBox.Show("Can't move the file because a dependency will be moved to\n\n" + kvp.Value + "\n\nand a file already exists there.");
                        canMove = false;
                        break;
                    }
                }
            }

            if (canMove)
            {
                // 1 Move the TreeNode from one parent TreeNode to another
                //treeNodeMoving.Parent.Nodes.Remove(treeNodeMoving);
                //targetNode.Nodes.Add(treeNodeMoving);
                // This is updated at the bottom of this method



                // 2 Move the file from one folder to another
                File.Move(oldFileName, targetFile);
                foreach (KeyValuePair <string, string> kvp in mOldNewDependencyFileDictionary)
                {
                    File.Move(kvp.Key, kvp.Value);
                }


                // 3 Remove the BuildItems from the project and add them back in the VisualStudio project
                ProjectBase projectBase = ProjectManager.ProjectBase;
                if (ProjectManager.ContentProject != null)
                {
                    projectBase = ProjectManager.ContentProject;
                }

                ProjectManager.RemoveItemFromProject(projectBase, oldNodeText, false);
                projectBase.AddContentBuildItem(targetFile);
                foreach (KeyValuePair <string, string> kvp in mOldNewDependencyFileDictionary)
                {
                    string fileFileRelativeToProject = FileManager.MakeRelative(kvp.Key, projectBase.Directory);

                    ProjectManager.RemoveItemFromProject(projectBase, fileFileRelativeToProject, false);
                    projectBase.AddContentBuildItem(kvp.Value);
                }
                // TODO:  This should also check to see if something else is referencing this content.
                // I'm going to write it to not make this check now since I'm just getting the initial system set up



                // 4 Change the ReferencedFileSave's name
                referencedFileSave.SetNameNoCall(newNodeText.Replace("\\", "/"));
                // No need for this, it'll get updated automatically
                // treeNodeMoving.Text = newNodeText;



                // 5 Re-generate the containing Element (Screen or Entity)
                if (EditorLogic.CurrentElement != null)
                {
                    CodeWriter.GenerateCode(EditorLogic.CurrentElement);
                }
                else
                {
                    ContentLoadWriter.UpdateLoadGlobalContentCode();
                }


                // The new 1:  Update
                if (EditorLogic.CurrentElement != null)
                {
                    EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();
                }
                else
                {
                    ElementViewWindow.UpdateGlobalContentTreeNodes(false);
                }


                // 6 Save everything
                GluxCommands.Self.SaveGlux();
                ProjectManager.SaveProjects();
            }
        }
예제 #35
0
        public override void SyncTo(ProjectBase projectBase, bool performTranslation)
        {
#if GLUE
            ProjectBase sourceContentProject = projectBase.ContentProject;

            AddCodeBuildItems(projectBase);

            if(performTranslation)
                PerformPendingTranslations();

            string contentDirectory = FileManager.GetDirectory(sourceContentProject.FullFileName);

            foreach (BuildItem bi in sourceContentProject.EvaluatedItems)
            {
                if (!IsFilePartOfProject("Content\\" + bi.Include, BuildItemMembershipType.Content) &&
                    bi.HasMetadata("CopyToOutputDirectory"))
                {
                    string copyAction = bi.GetMetadata("CopyToOutputDirectory");

                    if (copyAction == "PreserveNewest")
                    {

                        AddContentBuildItem(contentDirectory + bi.Include);
                    }

                }
            }

            Save(FullFileName);
#endif
        }
예제 #36
0
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (!validDate())
            {
                MessageBox.Show("日期或数字格式不对!", "警告");
                return;
            }

            if (isCreate)
            {
                if (MessageBox.Show("确认新建项目?", "温馨提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                {
                    return;
                }
                //新建项目
                if (!isSubProject)
                {
                    //非子项目
                    dataContent = new DataClassesProjectClassifyDataContext();
                    var pb = dataContent.ProjectBase.Where(p => p.ProjectNo.Trim().Equals(ProjectNo.Text.Trim()) && p.ProjectNo.Trim() != "");
                    if (pb.Count() > 0)
                    {
                        MessageBox.Show("院编号重复,已经录入该项目?", "错误");
                        return;
                    }
                    ProjectBase projectBase = new ProjectBase();
                    projectBase.ProjectClassifyID = projectClassifyID;
                    projectBase.ProjectNo         = ProjectNo.Text.Trim();
                    projectBase.ContractNo        = ContractNo.Text.Trim();
                    projectBase.FirstParty        = FirstParty.Text.Trim();
                    projectBase.SecondParty       = SecondParty.Text.Trim();
                    projectBase.SetupYear         = SetupYear.Text.Trim();
                    projectBase.ProjectName       = ProjectName.Text.Trim();
                    if (!String.IsNullOrEmpty(StartDate.Text.Trim()))
                    {
                        projectBase.StartDate = DateTime.Parse(StartDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(PlanFinishDate.Text.Trim()))
                    {
                        projectBase.PlanFinishDate = DateTime.Parse(PlanFinishDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(FinishDate.Text.Trim()))
                    {
                        projectBase.FinishDate = DateTime.Parse(FinishDate.Text.Trim());
                    }
                    projectBase.Principal = Principal.Text.Trim();
                    if (!String.IsNullOrEmpty(SumMoney.Text.Trim()))
                    {
                        projectBase.SumMoney = Convert.ToDecimal(SumMoney.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Ministry.Text.Trim()))
                    {
                        projectBase.Ministry = Convert.ToDecimal(Ministry.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Transportation.Text))
                    {
                        projectBase.Transportation = Convert.ToDecimal(Transportation.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Science.Text.Trim()))
                    {
                        projectBase.Science = Convert.ToDecimal(Science.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(SupportEngineering.Text.Trim()))
                    {
                        projectBase.SupportEngineering = Convert.ToDecimal(SupportEngineering.Text);
                    }
                    if (!String.IsNullOrEmpty(Other.Text.Trim()))
                    {
                        projectBase.Other = Convert.ToDecimal(Other.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(AuthrizeMoney.Text.Trim()))
                    {
                        projectBase.AuthorizeMoney = Convert.ToDecimal(AuthrizeMoney.Text.Trim());
                    }
                    projectBase.AnchoredDepartment = AnchoredDepartment.Text.Trim();
                    if ((bool)(IsKnot1.IsChecked))
                    {
                        projectBase.IsKnot = "验收";
                    }
                    if ((bool)(IsKnot2.IsChecked))
                    {
                        projectBase.IsKnot = "鉴定";
                    }
                    if ((bool)(IsKnot3.IsChecked))
                    {
                        projectBase.IsKnot = "尚未结题";
                    }
                    if ((bool)(IsKnot5.IsChecked))
                    {
                        projectBase.IsKnot = "结清";
                    }
                    projectBase.IsMainResearch = IsMainSearch.IsChecked;
                    projectBase.IsFiled        = IsFiled.IsChecked;
                    projectBase.Note           = Note.Text.Trim();
                    dataContent.ProjectBase.InsertOnSubmit(projectBase);
                    dataContent.SubmitChanges();
                    ProjectID = projectBase.ProjectId;
                    ((MainWindow)(this.Owner)).ProjectID = projectID;
                }
                else
                {
                    //子项目
                    dataContent = new DataClassesProjectClassifyDataContext();
                    var pb = dataContent.ProjectBase.Where(p => p.ProjectNo.Trim().Equals(ProjectNo.Text.Trim()) && p.ProjectNo.Trim() != "");
                    if (pb.Count() > 0)
                    {
                        MessageBox.Show("院编号重复,已经录入该项目?", "错误");
                        return;
                    }
                    ProjectBase projectBase = new ProjectBase();
                    projectBase.ParentID    = ParentID;
                    projectBase.ProjectNo   = ProjectNo.Text.Trim();
                    projectBase.ContractNo  = ContractNo.Text.Trim();
                    projectBase.FirstParty  = FirstParty.Text.Trim();
                    projectBase.SecondParty = SecondParty.Text.Trim();
                    projectBase.SetupYear   = SetupYear.Text.Trim();
                    projectBase.ProjectName = ProjectName.Text.Trim();
                    if (!String.IsNullOrEmpty(StartDate.Text.Trim()))
                    {
                        projectBase.StartDate = DateTime.Parse(StartDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(PlanFinishDate.Text.Trim()))
                    {
                        projectBase.PlanFinishDate = DateTime.Parse(PlanFinishDate.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(FinishDate.Text.Trim()))
                    {
                        projectBase.FinishDate = DateTime.Parse(FinishDate.Text.Trim());
                    }
                    projectBase.Principal = Principal.Text.Trim();
                    if (!String.IsNullOrEmpty(SumMoney.Text.Trim()))
                    {
                        projectBase.SumMoney = Convert.ToDecimal(SumMoney.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Ministry.Text.Trim()))
                    {
                        projectBase.Ministry = Convert.ToDecimal(Ministry.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Transportation.Text))
                    {
                        projectBase.Transportation = Convert.ToDecimal(Transportation.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(Science.Text.Trim()))
                    {
                        projectBase.Science = Convert.ToDecimal(Science.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(SupportEngineering.Text.Trim()))
                    {
                        projectBase.SupportEngineering = Convert.ToDecimal(SupportEngineering.Text);
                    }
                    if (!String.IsNullOrEmpty(Other.Text.Trim()))
                    {
                        projectBase.Other = Convert.ToDecimal(Other.Text.Trim());
                    }
                    if (!String.IsNullOrEmpty(AuthrizeMoney.Text.Trim()))
                    {
                        projectBase.AuthorizeMoney = Convert.ToDecimal(AuthrizeMoney.Text.Trim());
                    }
                    projectBase.AnchoredDepartment = AnchoredDepartment.Text.Trim();
                    if ((bool)(IsKnot1.IsChecked))
                    {
                        projectBase.IsKnot = "验收";
                    }
                    if ((bool)(IsKnot2.IsChecked))
                    {
                        projectBase.IsKnot = "鉴定";
                    }
                    if ((bool)(IsKnot3.IsChecked))
                    {
                        projectBase.IsKnot = "尚未结题";
                    }
                    if ((bool)(IsKnot5.IsChecked))
                    {
                        projectBase.IsKnot = "结清";
                    }
                    projectBase.IsMainResearch = IsMainSearch.IsChecked;
                    projectBase.IsFiled        = IsFiled.IsChecked;
                    projectBase.Note           = Note.Text.Trim();
                    dataContent.ProjectBase.InsertOnSubmit(projectBase);
                    dataContent.SubmitChanges();
                    ProjectID = projectBase.ProjectId;
                    ((MainWindow)(this.Owner)).ProjectID = projectID;
                }
            }
            else
            {
                //修改项目
                if (dataContent == null)
                {
                    dataContent = new DataClassesProjectClassifyDataContext();
                }
                var pb = dataContent.ProjectBase.Where(p => p.ProjectNo.Trim().Equals(ProjectNo.Text.Trim()) && p.ProjectNo.Trim() != "" && p.ProjectId != projectID);
                if (pb.Count() > 0)
                {
                    MessageBox.Show("项目编号重复!", "错误");
                    return;
                }
                ProjectBase projectBase = dataContent.ProjectBase.Single(p => p.ProjectId.Equals(ProjectID));
                projectBase.ProjectNo   = ProjectNo.Text.Trim();
                projectBase.ContractNo  = ContractNo.Text.Trim();
                projectBase.FirstParty  = FirstParty.Text.Trim();
                projectBase.SecondParty = SecondParty.Text.Trim();
                projectBase.SetupYear   = SetupYear.Text.Trim();
                projectBase.ProjectName = ProjectName.Text.Trim();
                if (!String.IsNullOrEmpty(StartDate.Text.Trim()))
                {
                    projectBase.StartDate = DateTime.Parse(StartDate.Text.Trim());
                }
                if (!String.IsNullOrEmpty(PlanFinishDate.Text.Trim()))
                {
                    projectBase.PlanFinishDate = DateTime.Parse(PlanFinishDate.Text.Trim());
                }
                if (!String.IsNullOrEmpty(FinishDate.Text.Trim()))
                {
                    projectBase.FinishDate = DateTime.Parse(FinishDate.Text.Trim());
                }
                projectBase.Principal = Principal.Text.Trim();
                if (!String.IsNullOrEmpty(SumMoney.Text.Trim()))
                {
                    projectBase.SumMoney = Convert.ToDecimal(SumMoney.Text.Trim());
                }
                if (!String.IsNullOrEmpty(Ministry.Text.Trim()))
                {
                    projectBase.Ministry = Convert.ToDecimal(Ministry.Text.Trim());
                }
                if (!String.IsNullOrEmpty(Transportation.Text))
                {
                    projectBase.Transportation = Convert.ToDecimal(Transportation.Text.Trim());
                }
                if (!String.IsNullOrEmpty(Science.Text.Trim()))
                {
                    projectBase.Science = Convert.ToDecimal(Science.Text.Trim());
                }
                if (!String.IsNullOrEmpty(SupportEngineering.Text.Trim()))
                {
                    projectBase.SupportEngineering = Convert.ToDecimal(SupportEngineering.Text);
                }
                if (!String.IsNullOrEmpty(Other.Text.Trim()))
                {
                    projectBase.Other = Convert.ToDecimal(Other.Text.Trim());
                }
                if (!String.IsNullOrEmpty(AuthrizeMoney.Text.Trim()))
                {
                    projectBase.AuthorizeMoney = Convert.ToDecimal(AuthrizeMoney.Text.Trim());
                }
                projectBase.AnchoredDepartment = AnchoredDepartment.Text.Trim();
                if ((bool)(IsKnot1.IsChecked))
                {
                    projectBase.IsKnot = "验收";
                }
                if ((bool)(IsKnot2.IsChecked))
                {
                    projectBase.IsKnot = "鉴定";
                }
                if ((bool)(IsKnot3.IsChecked))
                {
                    projectBase.IsKnot = "尚未结题";
                }
                if ((bool)(IsKnot5.IsChecked))
                {
                    projectBase.IsKnot = "结清";
                }
                projectBase.IsMainResearch = IsMainSearch.IsChecked;
                projectBase.IsFiled        = IsFiled.IsChecked;
                projectBase.Note           = Note.Text.Trim();
                dataContent.SubmitChanges();
            }
            ((MainWindow)(this.Owner)).DialogR = true;
            this.Close();
        }
예제 #37
0
 private string GetVersion(ProjectBase project)
 {
     var vsProject = project as VisualStudioProject;
     return vsProject != null ? vsProject.NeededVisualStudioVersion : "9.0";
 }
        private static void AddCodeforFileLoad(ReferencedFileSave referencedFile, ref ICodeBlock codeBlock, 
            bool loadsUsingGlobalContentManager, ref bool directives, bool isProjectSpecific, 
            ref string fileName, ProjectBase project, LoadType loadType, string containerName)
        {
            if (project != null)
            {

                if (ProjectManager.IsContent(fileName))
                {
                    fileName = (ProjectManager.ContentProject.ContainedFilePrefix + fileName).ToLower();
                }

                if (isProjectSpecific)
                {
                    if (directives == true)
                    {
                        codeBlock = codeBlock.End()
                            .Line("#elif " + project.PrecompilerDirective)
                            .CodeBlockIndented();
                    }
                    else
                    {
                        directives = true;
                        codeBlock = codeBlock
                            .Line("#if " + project.PrecompilerDirective)
                            .CodeBlockIndented();
                    }
                }
                else
                {
                    if (directives == true)
                    {
                        codeBlock = codeBlock.End()
                            .Line("#else")
                            .CodeBlockIndented();
                    }
                }

                if (referencedFile.IsDatabaseForLocalizing)
                {
                    GenerateCodeForLocalizationDatabase(referencedFile, codeBlock, fileName, loadType);
                }
                else
                {
                    AssetTypeInfo ati = referencedFile.GetAssetTypeInfo();

                    // I think we can set the field rather than the property, and then Set() the MRE if necessary afterwards:
                    //string variableName = referencedFile.GetInstanceName();

                    string variableName = null;
                    if (NeedsFullProperty(referencedFile, containerName))
                    {
                        variableName = "m" + referencedFile.GetInstanceName();
                    }
                    else
                    {
                        variableName = referencedFile.GetInstanceName();
                    }

                    if (!referencedFile.IsCsvOrTreatedAsCsv && ati != null)
                    {
                        // If it's not a CSV, then we only support loading if the load type is complete
                        // I don't know if I'll want to change this (or if I can) in the future.
                        if (loadType == LoadType.CompleteLoad)
                        {
                            GenerateInitializationForAssetTypeInfoRfs(referencedFile, codeBlock, loadsUsingGlobalContentManager, variableName, fileName, ati, project);
                        }
                    }
                    else if(referencedFile.IsCsvOrTreatedAsCsv)
                    {
                        GenerateInitializationForCsvRfs(referencedFile, codeBlock, variableName, fileName, loadType);
                    }
                }


                NamedObjectSaveCodeGenerator.WriteTextSpecificInitialization(referencedFile, codeBlock);
            }
        }
예제 #39
0
 private void HandleLoadedSyncedProject(ProjectBase project)
 {
     BuildLogic.Self.RefreshBuiltFilesFor(project, viewModel.UseContentPipelineOnPngs);
 }
        private static void GenerateInitializationForAssetTypeInfoRfs(ReferencedFileSave referencedFile, ICodeBlock codeBlock, bool loadsUsingGlobalContentManager, string variableName, string fileName, AssetTypeInfo ati, ProjectBase project)
        {
            string typeName = ati.RuntimeTypeName;
            var vsProject = project as VisualStudioProject;
            var isContentPipeline = (vsProject == null || vsProject.AllowContentCompile) &&
                                    (ati.MustBeAddedToContentPipeline || referencedFile.UseContentPipeline);

            if (isContentPipeline)
            {
                fileName = FileManager.RemoveExtension(fileName);
            }

            bool isSharedStatic = referencedFile.IsSharedStatic;


            string referencedFileName = referencedFile.Name;
            bool containedByGlobalContentFiles = GlobalContentFilesDictionary.ContainsKey(referencedFileName);

            var referencedFileContainerType = referencedFile.GetContainerType();

            if (isSharedStatic &&
                containedByGlobalContentFiles && 
                loadsUsingGlobalContentManager &&
                referencedFileContainerType != ContainerType.None)
            {
                string globalRfsVariable = GlobalContentFilesDictionary[referencedFile.Name].GetInstanceName();

                codeBlock.Line(string.Format("{0} = GlobalContent.{1};",
                                                variableName, globalRfsVariable));
            }
            else
            {
                ContentLoadWriter.GetLoadCallsForRfs(
                    referencedFile, fileName, ati, variableName, codeBlock, loadsUsingGlobalContentManager && referencedFile.IsSharedStatic, isContentPipeline);
            }
        }
        private static void AddIfUnreferenced(BuildItem item, ProjectBase project, List<string> referencedFiles, List<ProjectSpecificFile> unreferencedFiles)
        {
            string nameToInclude;
            bool isUnreferenced = GetIfIsUnreferenced(item, project, referencedFiles, out nameToInclude);

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

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

                    lock (mLastAddedUnreferencedFiles)
                    {
                        mLastAddedUnreferencedFiles.Add(projectSpecificFile);
                    }
                }
                unreferencedFiles.Add(new ProjectSpecificFile()
                {
                    FilePath = nameToInclude,
                    ProjectId = project.ProjectId
                });
            }
        }
예제 #42
0
        private static ContentItem GetContentItem(ReferencedFileSave referencedFileSave, ProjectBase project, bool createEvenIfProjectTypeNotSupported)
        {
            var fullFileName = GlueCommands.FileCommands.GetFullFileName(referencedFileSave);

            return(GetContentItem(fullFileName, project, createEvenIfProjectTypeNotSupported));
        }
예제 #43
0
        private static bool TryHandleSpecificProjectFileChange(string changedFile, ProjectBase project)
        {
            string standardizedProject = FileManager.Standardize(project.FullFileName).ToLower();
            string standardizedContentProject = null;
            bool handled = false;

            if (project.ContentProject != null)
            {
                standardizedContentProject = FileManager.Standardize(project.ContentProject.FullFileName).ToLower();
            }



            if (standardizedProject == changedFile.ToLower())
            {
                if (project == ProjectManager.ProjectBase)
                {

                    TaskManager.Self.OnUiThread(()=>ProjectLoader.Self.LoadProject(ProjectManager.ProjectBase.FullFileName));
                }
                else
                {
                    // Just reload the synced project
                    if (ProjectManager.SyncedProjects.Contains(project))
                    {
                        ProjectManager.RemoveSyncedProject(project);
                    }

                    ProjectLoader.AddSyncedProjectToProjectManager(project.FullFileName);
                }
                handled = true;
            }
            else if (!string.IsNullOrEmpty(standardizedContentProject) &&
                standardizedContentProject == changedFile.ToLower())
            {

                if (project == ProjectManager.ContentProject)
                {
                    TaskManager.Self.OnUiThread(()=>ProjectLoader.Self.LoadProject(ProjectManager.ProjectBase.FullFileName));
                }
                else
                {
                    // Reload the synced content project
                }
                handled = true;
            }


            if (handled)
            {
                PluginManager.ReceiveOutput("Handled changed project file for project: " + changedFile);
            }

            return handled;
        }
예제 #44
0
        private void TryAddXnbReferencesAndBuild(ReferencedFileSave referencedFile, ProjectBase project, bool save)
        {
            var fullFileName = GlueCommands.FileCommands.GetFullFileName(referencedFile);

            TryAddXnbReferencesAndBuild(fullFileName, project, save);
        }
 public ProjectBasePartialViewModel(ProjectBase projectBase)
 {
     _projectBase = projectBase;
 }
예제 #46
0
        public static void TryRemoveXnbReferences(ProjectBase project, ReferencedFileSave referencedFile, bool save = true)
        {
            var fullFileName = GlueCommands.FileCommands.GetFullFileName(referencedFile);

            TryRemoveXnbReferences(project, fullFileName, save);
        }
예제 #47
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);
            }
        }
예제 #48
0
        public bool ShouldAssociatedXnbBeCopied(string fileName, ProjectBase project)
        {
            // On Android we (currently) only copy WAV's. MP3s work fine without XNB:
            if (project is AndroidProject)
            {
                return FileManager.GetExtension(fileName) == "wav";

            }
            else
            {

                return FileManager.GetExtension(fileName) == "wav" ||
                    // Why don't we include WMA?
                    FileManager.GetExtension(fileName) == "mp3";
            }
        }
예제 #49
0
 public override void SyncTo(ProjectBase projectBase, bool performTranslation)
 {
     throw new NotImplementedException();
 }
예제 #50
0
 public void FinalWindow(ProjectBase userData, WindowTabControlBase userWindow)
 {
     //throw new NotImplementedException();
 }
예제 #51
0
        private bool FixContentPipelineProjectValues(List<ReferencedFileSave> rfsList, ProjectBase contentProjectBase)
        {
            bool hasMadeChanges = false;

            if (contentProjectBase != null)
            {
                foreach (ReferencedFileSave rfs in rfsList)
                {
                    var item = contentProjectBase.GetItem(rfs.Name);


                    if (item != null)
                    {
                        if (rfs.UseContentPipeline)
                        {
                            if (rfs.TextureFormat == Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessorOutputFormat.DxtCompressed &&
                                !item.HasMetadata("ProcessorParameters_TextureProcessorOutputFormat"))
                            {
                                hasMadeChanges = true;
                                // Gotta make this thing use the DxtCompression
                                ContentPipelineHelper.UpdateTextureFormatFor(rfs);
                            }
                        }
                    }
                }
            }

            return hasMadeChanges;
        }
        private List <string> GetEngineProjects(ProjectBase project)
        {
            var    result = new List <string>();
            string str;

            if (project is FsbProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\FlatSilverBall\FlatRedBall.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) +
                      @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\SilverArcade.SilverSprite.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) +
                      @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\SilverArcade.SilverSprite.Core.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is MdxProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMDX\FRB.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is MonoDroidProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\MonoGame\ThirdParty\Lidgren.Network\Lidgren.Network.Android.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is WindowsPhoneProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallWindowsPhone.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is Xna360Project)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallXbox360.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.Content.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is Xna4_360Project)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallXbox4_360.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.ContentXna4.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is Xna4Project)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBallXbox4.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.ContentXna4.csproj";
                CheckFile(str);
                result.Add(str);
            }
            else if (project is XnaProject)
            {
                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\FlatRedBall.csproj";
                CheckFile(str);
                result.Add(str);

                str = CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\FlatRedBall.Content.csproj";
                CheckFile(str);
                result.Add(str);
            }

            return(result);
        }
예제 #53
0
        private static bool AddAudioBuildItemToProject(ProjectBase project, BuildItem buildItem)
        {
            bool wasAnythingChanged = false;
            // This item needs an associated entry in the project
            // The item will be relative to the main project as opposed
            // to the content project, inside the CopiedXnbs directory:
            string copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
                buildItem.Include;

            var link = buildItem.GetLink();
            if(!string.IsNullOrEmpty( link ))
            {
                copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
                    link;
            }

            copiedXnb = FileManager.RemoveDotDotSlash(copiedXnb);

            string extension = FileManager.GetExtension(buildItem.Include);

            bool isIos = project is IosMonogameProject;
            bool isAndroid = project is AndroidProject;

            string whatToAddToProject = null;

            // 
            bool copyOriginalFile = (isIos || isAndroid) && FileManager.GetExtension(buildItem.Include) != "wav";

            if (copyOriginalFile)
            {
                // Jan 1, 2014
                // Not sure why
                // we were making
                // this file absolute
                // using the synced project's
                // directory.  The file will be
                // shared by synced and original
                // projects so the file needs to be
                // made absolute according to that project.
                //whatToAddToProject = project.MakeAbsolute("content/" + buildItem.Include);
                whatToAddToProject = ProjectManager.MakeAbsolute("content/" + buildItem.Include, true);
            }
            else
            {
                whatToAddToProject = copiedXnb;
            }
            // Both sound and music files have XNBs associated with them so let's add that:
            whatToAddToProject = FileManager.RemoveExtension(whatToAddToProject) + ".xnb";
            copiedXnb = FileManager.RemoveExtension(copiedXnb) + ".xnb";


            var item = project.GetItem(whatToAddToProject, true);
            if (item == null)
            {
                item = project.AddContentBuildItem(whatToAddToProject, SyncedProjectRelativeType.Linked, false);

                string linkToSet = null;

                if (!string.IsNullOrEmpty(buildItem.GetLink()))
                {
                    linkToSet = "Content\\" + FileManager.RemoveExtension(buildItem.GetLink()) + ".xnb";
                }
                else
                {
                    linkToSet = "Content\\" + FileManager.RemoveExtension(buildItem.Include) + ".xnb";
                }

                if(project is AndroidProject)
                {
                    linkToSet = "Assets\\" + linkToSet;
                }

                item.SetMetadata("Link", linkToSet);


                PluginManager.ReceiveOutput("Added " + buildItem.Include + " through the file " + whatToAddToProject);
                wasAnythingChanged = true;
            }

            wasAnythingChanged |= FixLink(item, project);


            if (isIos && extension == "mp3")
            {
                if (FileManager.FileExists(copiedXnb))
                {
                    ReplaceWmaReferenceToMp3ReferenceInXnb(copiedXnb, whatToAddToProject);
                }
                
            }

            // I think we want to tell the user that the XNB is missing so they know to build the PC project
            if(!FileManager.FileExists(copiedXnb))
            {

                PluginManager.ReceiveError("XNB file is missing - try rebuilding PC project: " + copiedXnb);
            }

            // Music files also have a wma file:
            if ((extension == "mp3" || extension == "wma") && 
                // iOS doesn't ignore MP3, so it's already there.
                !isIos)
            {
                if (isIos)
                {
                    whatToAddToProject = "Content\\" + buildItem.Include;
                }
                else
                {
                    whatToAddToProject = FileManager.RemoveExtension(whatToAddToProject) + ".wma";
                }

                var item2 = project.GetItem(whatToAddToProject, true);

                if (item2 == null)
                {
                    item2 = project.AddContentBuildItem(whatToAddToProject, SyncedProjectRelativeType.Linked, false);
                    item2.SetMetadata("Link", "Content\\" + FileManager.RemoveExtension(buildItem.Include) + "." + FileManager.GetExtension(whatToAddToProject));

                    PluginManager.ReceiveOutput("Added " + buildItem.Include + " through the file " + whatToAddToProject);
                    wasAnythingChanged = true;
                }

                wasAnythingChanged |= FixLink(item2, project);
            }
            return wasAnythingChanged;
        }
예제 #54
0
 internal static void RemoveItemFromProject(ProjectBase projectBaseToRemoveFrom, string itemName)
 {
     RemoveItemFromProject(projectBaseToRemoveFrom, itemName, true);
 }
예제 #55
0
        private bool SkipContentBuildItem(ProjectItem bi, ProjectBase containingProject)
        {
            bool shouldSkipContent = false;

            if (bi.ItemType == "Folder" || bi.ItemType == "_DebugSymbolsOutputPath" || bi.ItemType == "Reference")
            {
                // Skip trying to add the folder.  We don't need to do this because if it
                // contains anything, then the contained objects will automatically put themselves in a folder
                shouldSkipContent = true;

            }

            if (!shouldSkipContent)
            {
                if (bi.ItemType != "Compile" && bi.ItemType != "None")
                {
                    // but wait, the containing project may embed its content, so if so we need to check that
                    if (containingProject is CombinedEmbeddedContentProject &&
                        ((CombinedEmbeddedContentProject)containingProject).DefaultContentAction == bi.ItemType)
                    {
                        // Looks like it really is content
                        shouldSkipContent = false;
                    }
                    else
                    {
                        shouldSkipContent = true;
                    }
                }
            }

            if (!shouldSkipContent)
            {
                string extension = FileManager.GetExtension(bi.UnevaluatedInclude);

                if (ExtensionsToIgnore.Contains(extension))
                {
                    shouldSkipContent = true;
                }
            }


            // Now that we have checked if we should process this, we want to check if we should exclude it
            if(!shouldSkipContent)
            {
                var rfs = ObjectFinder.Self.GetReferencedFileSaveFromFile(bi.UnevaluatedInclude);

                if(rfs != null && rfs.ProjectsToExcludeFrom.Contains(this.Name))
                {
                    shouldSkipContent = true;
                }
            }



            return shouldSkipContent;
        }
예제 #56
0
 public static bool UpdateFileMembershipInProject(ProjectBase project, string fileRelativeToProject, bool useContentPipeline, bool shouldLink, string parentFile = null)
 {
     return(GlueCommands.Self.ProjectCommands.UpdateFileMembershipInProject(project, fileRelativeToProject, useContentPipeline, shouldLink, parentFile));
 }
        private void LinkDlls(ProjectBase project)
        {
            var    librariesPath = FileManager.GetDirectory(project.FullFileName) + @"Libraries\";
            string str, strPdb, engineStr, enginePdb;

            if (project is FsbProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\FlatSilverBall\Bin\Debug\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\FlatSilverBall\Bin\Debug\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("SilverArcade.SilverSprite.Core.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite.Core\Bin\Debug\SilverArcade.SilverSprite.Core.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite.Core\Bin\Debug\SilverArcade.SilverSprite.Core.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("SilverArcade.SilverSprite.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\Bin\Debug\SilverArcade.SilverSprite.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatSilverBall\SilverSpriteSource\SilverArcade.SilverSprite\Bin\Debug\SilverArcade.SilverSprite.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is MdxProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBallMdx.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMDX\bin\Debug\FlatRedBallMdx.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMDX\bin\Debug\FlatRedBallMdx.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is MonoDroidProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid\bin\Debug\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\FlatRedBallMonoDroid\FlatRedBallMonoDroid\bin\Debug\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("MonoGame.Framework.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\MonoGame\MonoGame.Framework\bin\Debug\MonoGame.Framework.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\MonoGame\MonoGame.Framework\bin\Debug\MonoGame.Framework.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("Lidgren.Network.Android.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\MonoGame\ThirdParty\Lidgren.Network\bin\Debug\Lidgren.Network.Android.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallMonoDroid\MonoGame\ThirdParty\Lidgren.Network\bin\Debug\Lidgren.Network.Android.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is WindowsPhoneProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Windows Phone\Debug\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Windows Phone\Debug\FlatRedBall.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is Xna4_360Project)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Xbox 360\Debug\XNA4\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\Xbox 360\Debug\XNA4\FlatRedBall.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is Xna4Project)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna4.0\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna4.0\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("FlatRedBall.Content.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\Xna4.0\FlatRedBall.Content.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\Xna4.0\FlatRedBall.Content.pdb", IntPtr.Zero);
                    }
                }
            }
            else if (project is XnaProject)
            {
                foreach (var dll in project.LibraryDlls)
                {
                    str    = librariesPath + dll;
                    strPdb = str.Remove(str.Length - 4) + ".pdb";

                    if (str.Contains("FlatRedBall.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna3.1\FlatRedBall.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall\bin\x86\Debug\Xna3.1\FlatRedBall.pdb", IntPtr.Zero);
                    }
                    else if (str.Contains("FlatRedBall.Content.dll"))
                    {
                        if (File.Exists(str))
                        {
                            File.Delete(str);
                        }
                        if (File.Exists(strPdb))
                        {
                            File.Delete(strPdb);
                        }

                        CreateHardLinkWithCheck(str, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\FlatRedBall.Content.dll", IntPtr.Zero);
                        CreateHardLinkWithCheck(strPdb, CleanBaseDirectory(_settings.SelectedEngineDirectory) + @"\FlatRedBallXNA\FlatRedBall.Content\bin\x86\Debug\FlatRedBall.Content.pdb", IntPtr.Zero);
                    }
                }
            }
        }
예제 #58
0
        private static void AddAndRemoveModifiedRfsFiles(List<ReferencedFileSave> rfses, List<string> filesInModifiedRfs, ProjectBase projectBase, bool usesContentPipeline)
        {
            #region If the modified file has files it references, we may need to add or remove them.  Do that here

            if (filesInModifiedRfs.Count != 0)
            {

                for (int i = 0; i < filesInModifiedRfs.Count; i++)
                {
                    filesInModifiedRfs[i] = ProjectManager.MakeRelativeContent(filesInModifiedRfs[i]).ToLower();
                }

                List<ReferencedFileSave> allReferencedFiles = ObjectFinder.Self.GetAllReferencedFiles();
                foreach (ReferencedFileSave rfsToRemove in rfses)
                {
                    allReferencedFiles.Remove(rfsToRemove);
                }

                RemoveFilesFromListReferencedByRfses(filesInModifiedRfs, allReferencedFiles);

                #region Loop through all files to add/remove

                foreach (string fileToAddOrRemove in filesInModifiedRfs)
                {

                    List<ProjectBase> projectsAlreadyModified = new List<ProjectBase>();

                    // There are files referenced by the RFS that aren't referenced by others

                    // If moving to content pipeline, remove the files from the project.
                    // If moving to copy if newer, add the files back to the project.
                    string absoluteFileName = ProjectManager.MakeAbsolute(fileToAddOrRemove, true);

                    projectsAlreadyModified.Add(projectBase);

                    #region Uses the content pipeline, remove the file from all projects
                    if (usesContentPipeline)
                    {
                        // Remove this file - it'll automatically be handled by the content pipeline
                        projectBase.RemoveItem(absoluteFileName);

                        foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                        {

                            ProjectBase syncedContentProjectBase = syncedProject;
                            if (syncedProject.ContentProject != null)
                            {
                                syncedContentProjectBase = syncedProject.ContentProject;
                            }

                            if (!projectsAlreadyModified.Contains(syncedContentProjectBase))
                            {
                                projectsAlreadyModified.Add(syncedContentProjectBase);

                                syncedContentProjectBase.RemoveItem(absoluteFileName);
                            }
                        }
                    }
                    #endregion

                    #region Does not use the content pipeline - add the file if necessary

                    else
                    {

                        // This file may have alraedy been part of the project for whatever reason, so we
                        // want to make sure it's not already part of it when we try to add it
                        if (!projectBase.IsFilePartOfProject(absoluteFileName, BuildItemMembershipType.CopyIfNewer))
                        {
                            projectBase.AddContentBuildItem(absoluteFileName, SyncedProjectRelativeType.Contained, false);
                        }
                        foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                        {
                            ProjectBase syncedContentProjectBase = syncedProject;
                            if (syncedProject.ContentProject != null)
                            {
                                syncedContentProjectBase = syncedProject.ContentProject;
                            }

                            if (!projectsAlreadyModified.Contains(syncedContentProjectBase))
                            {
                                projectsAlreadyModified.Add(syncedContentProjectBase);

                                if (syncedContentProjectBase.SaveAsAbsoluteSyncedProject)
                                {
                                    syncedContentProjectBase.AddContentBuildItem(absoluteFileName, SyncedProjectRelativeType.Contained, false);
                                }
                                else
                                {
                                    if (!projectBase.IsFilePartOfProject(absoluteFileName, BuildItemMembershipType.CopyIfNewer))
                                    {
                                        syncedContentProjectBase.AddContentBuildItem(absoluteFileName, SyncedProjectRelativeType.Linked, false);
                                    }
                                }
                            }
                        }
                    }

                    #endregion
                }
                #endregion
            }

            #endregion

            #region Save the synced projects

            foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
            {

                ProjectBase syncedContentProjectBase = syncedProject;
                if (syncedProject.ContentProject != null)
                {
                    syncedContentProjectBase = syncedProject.ContentProject;
                }

                syncedContentProjectBase.Save(syncedContentProjectBase.FullFileName);
            }

            #endregion
        }
        private bool RemoveReferenceFromProject(string SelectedFileName, ProjectBase projectBase)
        {
            string itemToRemove = SelectedFileName;

            if (!string.IsNullOrEmpty(itemToRemove) && FileManager.IsRelative(itemToRemove))
            {
                itemToRemove = GlueState.Self.ContentDirectory + SelectedFileName;
            }

            return projectBase.RemoveItem(itemToRemove);
        }
        private string GetVersion(ProjectBase project)
        {
            var vsProject = project as VisualStudioProject;

            return(vsProject != null ? vsProject.NeededVisualStudioVersion : "9.0");
        }