Ejemplo n.º 1
0
        private static void savePattern(PatternEntry patternEntry)
        {
            var filename = getJsonFilename(patternEntry.InputFile);
            var json     = JsonConvert.SerializeObject(patternEntry, Formatting.Indented);

            File.WriteAllText(filename, json);
        }
Ejemplo n.º 2
0
        private static bool docxToGlyphs(PatternEntry patternEntry)
        {
            var docxFile = Path.Combine(Path.GetDirectoryName(patternEntry.InputFile), Path.GetFileNameWithoutExtension(patternEntry.InputFile) + ".docx");

            if (!File.Exists(docxFile) ||
                File.GetLastWriteTimeUtc(docxFile) <= patternEntry.DocxLastModified)
            {
                return(false);
            }

            patternEntry.RefreshDocxLastModified();

            using var reader    = new WordReader(docxFile);
            patternEntry.Glyphs = reader.GetGlyphs().ToGlyphEntries();

            return(true);
        }
Ejemplo n.º 3
0
        private static bool xlsxToSprite(PatternEntry patternEntry)
        {
            if (patternEntry?.Sprite is not null &&
                File.GetLastWriteTimeUtc(patternEntry.InputFile) <= patternEntry.XlsxLastModified)
            {
                return(false);
            }

            patternEntry.RefreshXlsxLastModified();

            patternEntry.Sprite = SpriteExtractor
                                  .GetSprite(patternEntry.InputFile)
                                  .ToSpriteEntry();

            if (patternEntry?.Sprite is not null && string.IsNullOrWhiteSpace(patternEntry.Sprite.Name))
            {
                patternEntry.Sprite.Name = Path.GetFileNameWithoutExtension(patternEntry.InputFile);
            }

            return(true);
        }
Ejemplo n.º 4
0
 public static Pattern ToPattern(this PatternEntry patternEntry) => new(patternEntry.InputFile)
Ejemplo n.º 5
0
 public static void RefreshDocxLastModified(this PatternEntry patternEntry)
 => refreshLastModified(
     Path.Combine(Path.GetDirectoryName(patternEntry.InputFile), Path.GetFileNameWithoutExtension(patternEntry.InputFile) + ".docx"),
     patternEntry.DocxLastModified,
     dt => patternEntry.DocxLastModified = dt);
Ejemplo n.º 6
0
 public static void RefreshXlsxLastModified(this PatternEntry patternEntry)
 => refreshLastModified(
     patternEntry.InputFile,
     patternEntry.XlsxLastModified,
     dt => patternEntry.XlsxLastModified = dt);