/// <summary> /// /// </summary> /// <param name="_id"></param> /// <param name="dayfileName"></param> /// <param name="nightfileName"></param> public Picture(string _id, string dayfileName, string nightfileName) { this.id = _id; ISurfaceLoader[,] sl = new ISurfaceLoader[4, 2]; sl[0, 0] = new BitmapSurfaceLoader(dayfileName); sl[0, 1] = new BitmapSurfaceLoader(nightfileName); this.loaders = init(sl); }
/// <summary> /// /// </summary> /// <param name="pic"></param> /// <param name="_id"></param> public Picture(XmlElement pic, string _id) { this.id = _id; // // obtain the size of the bitmap string baseFileName = XmlUtil.Resolve(pic, pic.Attributes["src"].Value).LocalPath; // this.size = getBitmapSize(baseFileName); ISurfaceLoader[,] specifiedLoaders = new ISurfaceLoader[4, 2]; specifiedLoaders[0, 0] = new BitmapSurfaceLoader(baseFileName); specifiedLoaders[0, 1] = getNightOverride(pic); foreach (XmlElement ovr in pic.SelectNodes("override")) { string when = ovr.Attributes["when"].Value; int s; switch (when) { case "spring": s = 0; break; case "summer": s = 1; break; case "autumn": case "fall": s = 2; break; case "winter": s = 3; break; case "night": s = -1; break; default: throw new FormatException("when='" + when + "' is an unknown override format"); //! throw new FormatException("when='"+when+"'は未知のオーバーライド形式です"); } if (s >= 0) { XmlAttribute src = ovr.Attributes["src"]; if (src != null) { ISurfaceLoader overrideLoader = new BitmapSurfaceLoader( XmlUtil.Resolve(ovr, src.Value).LocalPath); specifiedLoaders[s, 0] = overrideLoader; } specifiedLoaders[s, 1] = getNightOverride(ovr); } } this.loaders = init(specifiedLoaders); }