public void Compile()
        {
            if (Target.InputPaths.Count != 1)
            {
                throw new ContentFileException(Target.RawTarget.Name, "One input file expected");
            }

            if (Target.OutputPaths.Count != 1)
            {
                throw new ContentFileException(Target.RawTarget.Name, "One output file expected");
            }

            ParsedPath     pinboardPath = Target.InputPaths[0];
            ParsedPath     jsonPath     = Target.OutputPaths[0];
            PinboardFileV1 pinboard     = PinboardFileCache.Load(pinboardPath);

            Rectangle[] rectangles = new Rectangle[pinboard.RectInfos.Count + 1];

            rectangles[0] = new Rectangle(pinboard.ScreenRectInfo.X, pinboard.ScreenRectInfo.Y, pinboard.ScreenRectInfo.Width, pinboard.ScreenRectInfo.Height);

            for (int i = 0; i < pinboard.RectInfos.Count; i++)
            {
                rectangles[i + 1] = new Rectangle(pinboard.RectInfos[i].X, pinboard.RectInfos[i].Y, pinboard.RectInfos[i].Width, pinboard.RectInfos[i].Height);
            }

            if (!Directory.Exists(jsonPath.VolumeAndDirectory))
            {
                Directory.CreateDirectory(jsonPath.VolumeAndDirectory);
            }

            // TODO: Write out the file
            throw new NotImplementedException();
        }
Esempio n. 2
0
        public void Compile()
        {
            ParsedPath stringsFileName = Target.InputFiles.Where(f => f.Extension == ".strings").First();
            ParsedPath xnbFileName     = Target.OutputFiles.Where(f => f.Extension == ".xnb").First();
            ParsedPath csFileName      = Target.OutputFiles.Where(f => f.Extension == ".cs").First();

            string className;

            Target.Properties.GetOptionalValue("ClassName", out className, stringsFileName.File + "Strings");

            StringsContent stringsData = CreateStringsData(className, StringsFileReaderV1.ReadFile(stringsFileName));

            string[] strings = stringsData.Strings.Select(s => s.Value).ToArray();

            if (!Directory.Exists(xnbFileName.VolumeAndDirectory))
            {
                Directory.CreateDirectory(xnbFileName.VolumeAndDirectory);
            }

            XnbFileWriterV5.WriteFile(strings, xnbFileName);

            if (!Directory.Exists(csFileName.VolumeAndDirectory))
            {
                Directory.CreateDirectory(csFileName.VolumeAndDirectory);
            }

            using (TextWriter writer = new StreamWriter(csFileName))
            {
                WriteCsOutput(writer, stringsData);
            }
        }
Esempio n. 3
0
        public void Compile()
        {
            ParsedPath          resxPath    = Target.InputPaths.Where(f => f.Extension == ".resx").First();
            ParsedPath          stringsPath = Target.OutputPaths.Where(f => f.Extension == ".strings").First();
            List <ResourceItem> resources   = ReadResources(resxPath);
            XmlWriterSettings   xmlSettings = new XmlWriterSettings();

            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "\t";

            using (XmlWriter xmlWriter = XmlWriter.Create(stringsPath, xmlSettings))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("Strings");

                foreach (ResourceItem resource in resources)
                {
                    if (resource.DataType == typeof(string))
                    {
                        string value = resource.ValueString;

                        xmlWriter.WriteStartElement("String");
                        xmlWriter.WriteAttributeString("Name", resource.Name);
                        xmlWriter.WriteString(value);
                        xmlWriter.WriteEndElement();
                    }
                }

                xmlWriter.WriteEndElement();
            }
        }
Esempio n. 4
0
        public void Save(ParsedPath fileName)
        {
            using (var writer = new StreamWriter(fileName))
            {
                writer.Write("\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n");
                writer.Write("# Visual Studio 2012\r\n");

                foreach (var project in this.projects)
                {
                    var projectPath = project.Path.MakeRelativePath(fileName).ToString("\\");
                    var prefix      = ".\\";

                    if (projectPath.StartsWith(prefix))
                    {
                        projectPath = projectPath.Substring(prefix.Length);
                    }

                    writer.Write("Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"\r\n{4}EndProject\r\n",
                                 project.TypeGuid, project.Name,
                                 projectPath,
                                 project.ProjectGuid, project.Content);
                }

                writer.Write("Global\r\n");

                writer.Write("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n");
                foreach (var solutionConfig in this.solutionConfigs)
                {
                    writer.Write("\t\t{0}|{1} = {0}|{1}\r\n", solutionConfig.Configuration, solutionConfig.Platform);
                }
                writer.Write("\tEndGlobalSection\r\n");

                writer.Write("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n");
                foreach (var projectConfig in this.projectConfigs)
                {
                    writer.Write("\t\t{0}.{1}|{2}.ActiveCfg = {3}|{4}\r\n",
                                 projectConfig.Guid,
                                 projectConfig.SolutionConfiguration.Configuration,
                                 projectConfig.SolutionConfiguration.Platform,
                                 projectConfig.ProjectConfiguration.Configuration,
                                 projectConfig.ProjectConfiguration.Platform);
                    writer.Write("\t\t{0}.{1}|{2}.Build.0 = {3}|{4}\r\n",
                                 projectConfig.Guid,
                                 projectConfig.SolutionConfiguration.Configuration,
                                 projectConfig.SolutionConfiguration.Platform,
                                 projectConfig.ProjectConfiguration.Configuration,
                                 projectConfig.ProjectConfiguration.Platform);
                }
                writer.Write("\tEndGlobalSection\r\n");

                foreach (var globalSection in this.globalSections)
                {
                    writer.Write("\tGlobalSection({0}) = {1}\r\n", globalSection.Name, globalSection.Order);
                    writer.Write(globalSection.Content);
                    writer.Write("\tEndGlobalSection\r\n");
                }

                writer.Write("EndGlobal\r\n");
            }
        }
Esempio n. 5
0
        internal static IList <ParsedPath> GetFullScriptReferencesPaths(ParsedPath scriptPath, ScriptInfo scriptInfo, RuntimeInfo runtimeInfo)
        {
            List <ParsedPath>           paths = new List <ParsedPath>();
            Dictionary <string, string> dict  = new Dictionary <string, string>();

            dict.Add("FxInstallPath", runtimeInfo.FxInstallPath);
            dict.Add("FxReferenceAssemblyPath", runtimeInfo.FxReferenceAssemblyPath);
            dict.Add("ClrInstallPath", runtimeInfo.ClrInstallPath);
            dict.Add("ScriptPath", scriptPath.VolumeAndDirectory);
            dict.Add("CodeRunnerPath", new ParsedPath(Process.GetCurrentProcess().MainModule.FileName, PathType.File).VolumeAndDirectory);

            string reference = String.Empty;

            try
            {
                for (int i = 0; i < scriptInfo.References.Count; i++)
                {
                    reference = scriptInfo.References[i];

                    string     fullReference = StringUtility.ReplaceTags(reference, "$(", ")", dict);
                    ParsedPath path          = new ParsedPath(fullReference, PathType.File).MakeFullPath(scriptPath);

                    paths.Add(path);
                }
            }
            catch (ArgumentException e)
            {
                // Could be bad crap in the reference paths
                throw new ScriptInfoException(CodeRunnerResources.BadReferencePaths(reference, e.Message));
            }

            return(paths);
        }
Esempio n. 6
0
 public static PinboardFileV1 ReadFile(ParsedPath contentFile)
 {
     using (XmlReader reader = XmlReader.Create(contentFile))
     {
         return(new PinboardFileReaderV1(reader).ReadPinboardXml());
     }
 }
Esempio n. 7
0
        public static PinboardFileV1 Load(ParsedPath pinboardFileName)
        {
            PinboardFileV1 data = null;

            if (pinboardFiles == null)
            {
                pinboardFiles = new Dictionary <ParsedPath, PinboardFileV1>();
            }

            if (pinboardFiles.TryGetValue(pinboardFileName, out data))
            {
                return(data);
            }

            try
            {
                data = PinboardFileReaderV1.ReadFile(pinboardFileName);
            }
            catch
            {
                throw new ContentFileException("Unable to read pinboard file '{0}'".CultureFormat(pinboardFileName));
            }

            pinboardFiles.Add(pinboardFileName, data);

            return(data);
        }
Esempio n. 8
0
        public void Load(ParsedPath contentPath)
        {
            try
            {
                var node = new TsonParser().Parse(File.ReadAllText(contentPath));

                throw new NotImplementedException();
            }
            catch (Exception e)
            {
                TsonParseException   tpe = e as TsonParseException;
                ContentFileException cfe = e as ContentFileException;

                if (tpe != null)
                {
                    throw new ContentFileException("Bad TSON", tpe);
                }
                else if (cfe != null)
                {
                    throw;
                }
                else
                {
                    throw new ContentFileException(e);
                }
            }
        }
    public async Task <ParsedPath[]> GetPhysicalFileStateInternal(string logicalFilePath, CancellationToken cancel)
    {
        List <ParsedPath> ret = new List <ParsedPath>();

        ParsedPath parsed = new ParsedPath(this, logicalFilePath, 0);

        FileSystemEntity[] dirEntities = await UnderlayFileSystem.EnumDirectoryAsync(parsed.DirectoryPath, false, EnumDirectoryFlags.NoGetPhysicalSize, cancel);

        var relatedFiles = dirEntities.Where(x => x.IsDirectory == false);

        foreach (var f in relatedFiles)
        {
            if (f.Name.StartsWith(parsed.OriginalFileNameWithoutExtension, PathParser.PathStringComparison))
            {
                try
                {
                    ParsedPath parsedForFile = new ParsedPath(this, f.FullPath, f);
                    if (parsed.LogicalFilePath._IsSame(parsedForFile.LogicalFilePath, PathParser.PathStringComparison))
                    {
                        ret.Add(parsedForFile);
                    }
                }
                catch { }
            }
        }

        ret.Sort((x, y) => x.FileNumber.CompareTo(y.FileNumber));

        return(ret.ToArray());
    }
Esempio n. 10
0
        public void Test(Operation operation, object objectToApplyTo)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            if (objectToApplyTo == null)
            {
                throw new ArgumentNullException(nameof(objectToApplyTo));
            }

            var parsedPath = new ParsedPath(operation.path);
            var visitor    = new ObjectVisitor(parsedPath, ContractResolver, AdapterFactory);

            var target = objectToApplyTo;

            if (!visitor.TryVisit(ref target, out var adapter, out var errorMessage))
            {
                var error = CreatePathNotFoundError(objectToApplyTo, operation.path, operation, errorMessage);
                ErrorReporter(error);
                return;
            }

            if (!adapter.TryTest(target, parsedPath.LastSegment, ContractResolver, operation.value, out errorMessage))
            {
                var error = CreateOperationFailedError(objectToApplyTo, operation.path, operation, errorMessage);
                ErrorReporter(error);
                return;
            }
        }
        public void Compile()
        {
            IEnumerable <ParsedPath> pinboardFileNames         = Target.InputPaths.Where(f => f.Extension == ".pinboard");
            IEnumerable <ParsedPath> distinctPinboardFileNames = pinboardFileNames.Distinct <ParsedPath>(new FileNameEqualityComparer());

            Dictionary <ParsedPath, PinboardFileV1> pinboards = ReadPinboardFiles(pinboardFileNames);

            ReconcilePinboards(pinboardFileNames, distinctPinboardFileNames, pinboards);

            TextWriter writer;
            ParsedPath csFileName = Target.OutputPaths.Where(f => f.Extension == ".cs").First();

            Context.WriteMessage("Writing output file '{0}'", csFileName);

            if (!Directory.Exists(csFileName.VolumeAndDirectory))
            {
                Directory.CreateDirectory(csFileName.VolumeAndDirectory);
            }

            using (writer = new StreamWriter(csFileName, false, Encoding.UTF8))
            {
                RectanglesContent rectangleData = CreateRectangleData(distinctPinboardFileNames, pinboards);

                WriteCsOutput(writer, rectangleData);
            }
        }
Esempio n. 12
0
 public static void WriteFile(object rootObject, ParsedPath xnbFile)
 {
     using (FileStream fileStream = new FileStream(xnbFile, FileMode.Create))
     {
         new XnbFileWriterV5(fileStream).Write(rootObject);
     }
 }
Esempio n. 13
0
 public void PathWithInvalidEscapeSequenceShouldFail(string path)
 {
     Assert.Throws <JsonPatchException>(() =>
     {
         var parsedPath = new ParsedPath(path);
     });
 }
Esempio n. 14
0
 public void AddWellKnownProperties(
     ParsedPath buildContentInstallDir,
     ParsedPath contentFileDir)
 {
     this.Set("BuildContentInstallDir", buildContentInstallDir.ToString());
     this.Set("InputDir", contentFileDir.ToString());
     this.Set("OutputDir", contentFileDir.ToString());
 }
Esempio n. 15
0
        public void ParsingValidPathShouldSucceed(string path, string[] expected)
        {
            // Arrange & Act
            var parsedPath = new ParsedPath(path);

            // Assert
            Assert.Equal(expected, parsedPath.Segments);
        }
Esempio n. 16
0
 private string ReadAllXmlWithoutHeader(ParsedPath svgPath)
 {
     using (XmlReader reader = XmlReader.Create(svgPath))
     {
         reader.MoveToContent();
         return(reader.ReadOuterXml());
     }
 }
Esempio n. 17
0
        public void Compile()
        {
            IEnumerable <ParsedPath> svgPaths = Target.InputFiles.Where(f => f.Extension == ".svg");
            ParsedPath pdfPath = Target.OutputFiles.Where(f => f.Extension == ".pdf").First();
            ParsedPath xnbPath = Target.OutputFiles.Where(f => f.Extension == ".xnb").First();

            // TODO: Ensure that pdf and xnb have the same root directories (and volumes)

            int numRows;
            int numCols;

            this.Target.Properties.GetOptionalValue("Rows", out numRows, 1);
            this.Target.Properties.GetOptionalValue("Columns", out numCols, 1);

            ParsedPath nUpSvgPath = null;

            try
            {
                if (svgPaths.Count() > 1)
                {
                    nUpSvgPath = pdfPath.WithFileAndExtension(
                        String.Format("{0}_{1}x{2}.svg", pdfPath.File, numRows, numCols));

                    CreateNupSvg(svgPaths, nUpSvgPath, numRows, numCols);
                }

                if (!Directory.Exists(pdfPath.VolumeAndDirectory))
                {
                    Directory.CreateDirectory(pdfPath.VolumeAndDirectory);
                }

                ImageTools.SvgToPdfWithInkscape(nUpSvgPath == null ? svgPaths.First() : nUpSvgPath, pdfPath);
            }
            finally
            {
                if (nUpSvgPath != null)
                {
                    File.Delete(nUpSvgPath);
                }
            }

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

            pdfInfo.Add(this.Target.Properties.GetRequiredValue("Pinboard"));
            pdfInfo.Add(this.Target.Properties.GetRequiredValue("Rectangle"));
            pdfInfo.Add(numRows.ToString());
            pdfInfo.Add(numCols.ToString());

            if (!Directory.Exists(xnbPath.VolumeAndDirectory))
            {
                Directory.CreateDirectory(xnbPath.VolumeAndDirectory);
            }

            XnbFileWriterV5.WriteFile(pdfInfo, xnbPath);
        }
Esempio n. 18
0
        private bool StartDevenvAndWait(VisualStudioInfo vsInfo, ParsedPath solutionFile)
        {
            // Now try and start devenv
            Process process = null;

            // Clear undocumented MS build environment variables that will confuse VS if set
            Environment.SetEnvironmentVariable("COMPLUS_INSTALLROOT", "");
            Environment.SetEnvironmentVariable("COMPLUS_VERSION", "");

            try
            {
                if (this.Verbose)
                {
                    Output.Message(MessageImportance.Low, ScaffoldResources.StartingVS);
                }

                ProcessStartInfo startInfo = new ProcessStartInfo(
                    vsInfo.DevEnvExe, "\"" + solutionFile + "\" \"" + this.ScriptPath + "\"");

                startInfo.WorkingDirectory = solutionFile.VolumeAndDirectory;
                startInfo.UseShellExecute  = false;

                process = Process.Start(startInfo);
            }
            catch (Win32Exception e)
            {
                Output.Error(ScaffoldResources.UnableToStartVS, solutionFile, e.Message);
                return(false);
            }

            // Devenv has started.  Wait for it to exit.
            if (process != null)
            {
                if (this.Verbose && this.Wait)
                {
                    Output.Message(MessageImportance.Low, ScaffoldResources.WaitingForVS);
                }

                // At this point we free the server/parent scaffold process so that it can
                // exit and return control of the console to the user.  Any logging after this
                // point might silently fail if the remote build engine decides to away, but that's OK.
                Output.Outputter.OutputCustomEvent(new RemoteOutputEventArgs(true));

                process.WaitForExit();
                process.Close();
                process = null;
            }
            else
            {
                Output.Error(ScaffoldResources.VSDidNotStart);
                return(false);
            }

            return(true);
        }
Esempio n. 19
0
        static BitmapContent CreateBitmapContent(
            double bitmapWidth,
            double bitmapHeight,
            string fontName,
            FontSlant fontSlant,
            FontWeight fontWeight,
            double fontSize,
            List <CharacterData> cds,
            ParsedPath pngFile)
        {
            using (ImageSurface surface = new ImageSurface(Format.Argb32, (int)bitmapWidth, (int)bitmapHeight))
            {
                using (Context g = new Context(surface))
                {
                    SetupContext(g, fontName, fontSlant, fontWeight, fontSize);
                    double x = 0;

                    for (int i = 0; i < cds.Count; i++)
                    {
                        CharacterData cd = cds[i];

                        if (cd.Location.Width == 0)
                        {
                            continue;
                        }

                        g.MoveTo(x + cd.Bearing.X, cd.Bearing.Y);
                        g.ShowText(cd.Character);
#if DEBUG
                        g.Save();
                        g.Color     = new Color(1.0, 0, 0, 0.5);
                        g.Antialias = Antialias.None;
                        g.LineWidth = 1;
                        g.MoveTo(x + 0.5, 0.5);
                        g.LineTo(x + cd.Location.Width - 0.5, 0);
                        g.LineTo(x + cd.Location.Width - 0.5, cd.Location.Height - 0.5);
                        g.LineTo(x + 0.5, cd.Location.Height - 0.5);
                        g.LineTo(x + 0.5, 0.5);
                        g.Stroke();
                        g.Restore();
#endif
                        x += cd.Location.Width;
                    }

                    g.Restore();
                }

                if (pngFile != null)
                {
                    surface.WriteToPng(pngFile);
                }

                return(new BitmapContent(SurfaceFormat.Color, surface.Width, surface.Height, surface.Data));
            }
        }
Esempio n. 20
0
        private ParsedPath GetSlnForProject(ParsedPath csprojPath)
        {
            var files = DirectoryUtility.GetFiles(csprojPath.WithFileAndExtension("*.sln"), SearchScope.RecurseParentDirectories);

            if (files.Count == 0)
            {
                throw new PopperToolExeception("Cannot find .sln for project '{0}'".InvariantFormat(csprojPath));
            }

            return(files[0]);
        }
Esempio n. 21
0
        private static string CachifyScriptPath(ParsedPath scriptPath)
        {
            Debug.Assert(scriptPath.IsFullPath);

            StringBuilder sb = new StringBuilder(scriptPath.VolumeDirectoryAndFile + ".exe");

            sb.Replace('\\', '_');
            sb.Replace(':', '_');
            sb.Replace(' ', '_');

            return(sb.ToString());
        }
Esempio n. 22
0
        public void EnsureFileNameAndLineNumber(ParsedPath fileName, int lineNumber)
        {
            if (!HasFileName)
            {
                this.FileName = fileName;
            }

            if (!HasLineNumber)
            {
                this.LineNumber = lineNumber;
            }
        }
Esempio n. 23
0
        public void Compile()
        {
            ParsedPath svgFileName = Target.InputPaths.Where(f => f.Extension == ".svg").First();
            ParsedPath pngFileName = Target.OutputPaths.Where(f => f.Extension == ".png").First();

            if (!Directory.Exists(pngFileName.VolumeAndDirectory))
            {
                Directory.CreateDirectory(pngFileName.VolumeAndDirectory);
            }

            ImageTools.SvgToPngWithInkscape(svgFileName, pngFileName, this.Width, this.Height);
        }
Esempio n. 24
0
        private bool ReadVersionFile(ParsedPath versionFileName)
        {
            XDocument versionDoc         = XDocument.Load(versionFileName);
            var       buildValueTypeAttr = versionDoc.Root.Attribute("BuildValueType");

            if (buildValueTypeAttr == null)
            {
                this.buildValueType = BuildValueType.JDate;
            }
            else
            {
                this.buildValueType = (BuildValueType)Enum.Parse(typeof(BuildValueType), buildValueTypeAttr.Value, ignoreCase: true);
            }

            tags = versionDoc.Root.Elements().Where(x => x.Name != "Files").ToDictionary <XElement, string, string>(
                x => x.Name.ToString(), x => x.Value);

            if (!tags.ContainsKey("Major") || !tags.ContainsKey("Minor") ||
                !tags.ContainsKey("Build") || !tags.ContainsKey("Revision"))
            {
                WriteError("Version file must at least contain at least Major, Minor, Build, Revision tags");
                return(false);
            }

            string timeZoneId;

            if (tags.TryGetValue("TimeZone", out timeZoneId))
            {
                try
                {
                    this.timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("TimeZone '{0}' was not found".CultureFormat(timeZoneId), ex);
                }
            }

            this.today = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, this.timeZoneInfo);

            var filesNode = versionDoc.Root.Element("Files");

            if (filesNode == null)
            {
                WriteError("Version file must contain a Files node");
                return(false);
            }

            fileList = filesNode.Descendants().Select(x => (string)x).ToArray();

            return(true);
        }
Esempio n. 25
0
        private SlnDocument(ParsedPath filePath, string content)
        {
            projects        = new List <SlnProject>();
            globalSections  = new List <SlnGlobalSection>();
            solutionConfigs = new List <SlnConfiguration>();
            projectConfigs  = new List <SlnProjectConfiguration>();

            Regex slnProjectRegex = new Regex("Project\\(\"(?'type'{.*?})\"\\) = \"(?'name'.*?)\", \"(?'path'.*?)\", \"(?'guid'{.*?})\"[\\t\\r ]*\\n(?'content'(.*\\n)*?)EndProject[\\t\\r ]*\\n",
                                              RegexOptions.Multiline | RegexOptions.ExplicitCapture);
            MatchCollection matches = slnProjectRegex.Matches(content);

            foreach (Match match in matches)
            {
                this.projects.Add(new SlnProject
                {
                    TypeGuid    = match.Groups["type"].Value,
                    Name        = match.Groups["name"].Value,
                    Path        = new ParsedFilePath(match.Groups["path"].Value).MakeFullPath(filePath),
                    ProjectGuid = match.Groups["guid"].Value,
                    Content     = match.Groups["content"].Value
                });
            }

            Regex slnGlobalSectionRegex = new Regex("[\\t ]*GlobalSection\\((?'name'.*?)\\) = (?'order'(pre|post)Solution)[\\t\\r ]*\\n(?'content'([\\t ]*.*[\\t ]*\\n)+?)[\\t ]*EndGlobalSection[\\t\\r ]*\\n",
                                                    RegexOptions.Multiline | RegexOptions.ExplicitCapture);

            matches = slnGlobalSectionRegex.Matches(content);

            foreach (Match match in matches)
            {
                var name         = match.Groups["name"].Value;
                var groupContent = match.Groups["content"].Value;

                if (name == "SolutionConfigurationPlatforms")
                {
                    ParseSolutionConfigurationPlatforms(groupContent);
                }
                else if (name == "ProjectConfigurationPlatforms")
                {
                    ParseProjectConfigurationPlatforms(groupContent);
                }
                else
                {
                    this.globalSections.Add(new SlnGlobalSection
                    {
                        Name    = name,
                        Order   = match.Groups["order"].Value,
                        Content = groupContent
                    });
                }
            }
        }
Esempio n. 26
0
 public RuntimeInfo(
     string clrVersion,
     ParsedPath clrInstallPath,
     string fxVersion,
     ParsedPath fxInstallPath,
     ParsedPath fxRefAsmPath)
 {
     this.ClrVersion              = clrVersion;
     this.ClrInstallPath          = clrInstallPath;
     this.FxVersion               = fxVersion;
     this.FxInstallPath           = fxInstallPath;
     this.FxReferenceAssemblyPath = fxRefAsmPath;
 }
Esempio n. 27
0
 public bool TryParseOriginalPath(string physicalPath, [NotNullWhen(true)] out ParsedPath?parsed)
 {
     try
     {
         parsed = new ParsedPath(this, physicalPath);
         return(true);
     }
     catch
     {
         parsed = null;
         return(false);
     }
 }
Esempio n. 28
0
        private ParsedPath CreateTempDirectory()
        {
            // Create a temporary directory in which to put our scaffold project
            ParsedPath projectDir;
            Random     rand = new Random();

            do
            {
                projectDir = new ParsedPath(String.Format("{0}Scaffold_{1:X8}", this.ScriptPath.VolumeAndDirectory, rand.Next()), PathType.Directory);
            }while (Directory.Exists(projectDir));

            Directory.CreateDirectory(projectDir);
            return(projectDir);
        }
Esempio n. 29
0
        public static void CompressPngToTexture2DContent(
            ParsedPath pngFileName,
            string compressionType,
            out Texture2DContent textureContent)
        {
            PngFile pngFile = PngFileReader.ReadFile(pngFileName);

            SquishMethod? squishMethod  = null;
            SurfaceFormat surfaceFormat = SurfaceFormat.Color;

            switch (compressionType.ToLower())
            {
            case "dxt1":
                squishMethod  = SquishMethod.Dxt1;
                surfaceFormat = SurfaceFormat.Dxt1;
                break;

            case "dxt3":
                squishMethod  = SquishMethod.Dxt3;
                surfaceFormat = SurfaceFormat.Dxt3;
                break;

            case "dxt5":
                squishMethod  = SquishMethod.Dxt5;
                surfaceFormat = SurfaceFormat.Dxt5;
                break;

            default:
            case "none":
                surfaceFormat = SurfaceFormat.Color;
                break;
            }

            BitmapContent bitmapContent;

            if (surfaceFormat != SurfaceFormat.Color)
            {
                byte[] rgbaData = Squish.CompressImage(
                    pngFile.RgbaData, pngFile.Width, pngFile.Height,
                    squishMethod.Value, SquishFit.IterativeCluster, SquishMetric.Default, SquishExtra.None);

                bitmapContent = new BitmapContent(surfaceFormat, pngFile.Width, pngFile.Height, rgbaData);
            }
            else
            {
                bitmapContent = new BitmapContent(SurfaceFormat.Color, pngFile.Width, pngFile.Height, pngFile.RgbaData);
            }

            textureContent = new Texture2DContent(bitmapContent);
        }
Esempio n. 30
0
        public void Compile()
        {
            ParsedPath pngFileName = Target.InputFiles.Where(f => f.Extension == ".png").First();
            ParsedPath xnbFileName = Target.OutputFiles.Where(f => f.Extension == ".xnb").First();

            string           compressionType;
            Texture2DContent textureContent;

            Target.Properties.GetOptionalValue("CompressionType", out compressionType, "None");

            ImageTools.CompressPngToTexture2DContent(pngFileName, compressionType, out textureContent);

            XnbFileWriterV5.WriteFile(textureContent, xnbFileName);
        }