static private AContentItem CreateFromCsv(string[] tokens) { if (tokens.Length < 2) { return(null); } string name = tokens[0].Trim().ToUpper(); string parentName = tokens[1].ToUpper(); if (name.Length == 0 || parentName.Length == 0) { return(null); } if (!resourceDic.ContainsKey(parentName)) { return(null); } AContentFile parent = resourceDic[parentName]; if (parent is BaseImage) { BaseImage parentImage = parent as BaseImage; parentImage.Load(Config.TextDrawingMode == TextDrawingMode.WINAPI); if (!parentImage.Enabled) { return(null); } Rectangle rect = new Rectangle(new Point(0, 0), parentImage.Bitmap.Size); bool noresize = false; if (tokens.Length >= 6) { int[] rectValue = new int[4]; bool sccs = true; for (int i = 0; i < 4; i++) { sccs &= int.TryParse(tokens[i + 2], out rectValue[i]); } if (sccs) { rect = new Rectangle(rectValue[0], rectValue[1], rectValue[2], rectValue[3]); } if (tokens.Length >= 7) { string[] keywordTokens = tokens[6].Split('|'); foreach (string keyword in keywordTokens) { switch (keyword.Trim().ToUpper()) { case "NORESIZE": throw new NotImplCodeEE(); noresize = true; break; } } } } CroppedImage image = new CroppedImage(name, parentImage, rect, noresize); return(image); } return(null); }
static private AContentItem CreateFromCsv(string[] tokens, string dir) { if (tokens.Length < 2) { return(null); } string name = tokens[0].Trim().ToUpper(); // string parentName = dir + tokens[1].ToUpper(); //画像ファイル名 if (name.Length == 0 || parentName.Length == 0) { return(null); } if (!resourceDic.ContainsKey(parentName)) { string filepath = parentName; if (!File.Exists(filepath)) { return(null); } Bitmap bmp = new Bitmap(filepath); if (bmp == null) { return(null); } ConstImage img = new ConstImage(parentName); img.CreateFrom(bmp, Config.TextDrawingMode == TextDrawingMode.WINAPI); if (!img.IsCreated) { return(null); } resourceDic.Add(parentName, img); } AContentFile parent = resourceDic[parentName]; if (parent is ConstImage) { ConstImage parentImage = parent as ConstImage; if (!parentImage.IsCreated) { return(null); } Rectangle rect = new Rectangle(new Point(0, 0), parentImage.Bitmap.Size); Point pos = new Point(); if (tokens.Length >= 6) { int[] rectValue = new int[4]; bool sccs = true; for (int i = 0; i < 4; i++) { sccs &= int.TryParse(tokens[i + 2], out rectValue[i]); } if (sccs) { rect = new Rectangle(rectValue[0], rectValue[1], rectValue[2], rectValue[3]); } if (tokens.Length >= 8) { sccs = true; for (int i = 0; i < 2; i++) { sccs &= int.TryParse(tokens[i + 6], out rectValue[i]); } if (sccs) { pos = new Point(rectValue[0], rectValue[1]); } } //if(tokens.Length >= 7) //{ // string[] keywordTokens = tokens[6].Split('|'); // foreach(string keyword in keywordTokens) // { // switch(keyword.Trim().ToUpper()) // { // case "NORESIZE": // throw new NotImplCodeEE(); // } // } //} } ASprite image = new SpriteF(name, parentImage, rect, pos); return(image); } return(null); }