/// <summary> /// 出力設定ノードを解析して設定値を取得する。 /// </summary> /// <param name="node">出力設定ノード</param> /// <param name="setting">ExportSettingオブジェクト</param> private static void LoadConfigNode(XmlNode node, ExportSetting setting) { foreach (XmlNode subNode in node.ChildNodes) { try { switch (subNode.Name) { case GeneratorSettingFileDefs.NodeCharaChipSize: { XmlAttribute wAttr = subNode.Attributes["width"]; XmlAttribute hAttr = subNode.Attributes["height"]; if ((wAttr != null) && (hAttr != null)) { setting.CharaChipSize = new System.Drawing.Size(Int32.Parse(wAttr.Value), Int32.Parse(hAttr.Value)); } } break; case GeneratorSettingFileDefs.NodeExportPath: XmlAttribute pathAttr = subNode.Attributes["path"]; setting.ExportFilePath = pathAttr.Value; break; } } catch (Exception) { // 各項目の例外は無視する。 } } }
/// <summary> /// この設定をリセットし、初期状態にする。 /// </summary> public void Reset() { foreach (Character character in characters) { character.Reset(); } ExportSetting = new ExportSetting(); }
/// <summary> /// 出力設定ノードを追加する。 /// </summary> /// <param name="doc">XmlDocumentオブジェクト</param> /// <param name="parent">親要素</param> /// <param name="setting">出力設定</param> private static void AddConfigNode(XmlDocument doc, XmlElement parent, ExportSetting setting) { XmlElement chipSizeElem = doc.CreateElement(GeneratorSettingFileDefs.NodeCharaChipSize); chipSizeElem.SetAttribute("width", setting.CharaChipSize.Width.ToString()); chipSizeElem.SetAttribute("height", setting.CharaChipSize.Height.ToString()); parent.AppendChild(chipSizeElem); XmlElement exportPathElem = doc.CreateElement(GeneratorSettingFileDefs.NodeExportPath); exportPathElem.SetAttribute("path", setting.ExportFilePath); parent.AppendChild(exportPathElem); }
/// <summary> /// 指定したキャラクタ数で新しいインスタンスを構築する。 /// </summary> public GeneratorSetting(int horizontalCount, int verticalCount) { int count = horizontalCount * verticalCount; if (count <= 0) { throw new ArgumentException("Character count is invalid."); } HorizontalCount = horizontalCount; VerticalCount = verticalCount; characters = new Character[count]; for (int i = 0; i < characters.Length; i++) { characters[i] = new Character(); } ExportSetting = new ExportSetting(); }
/// <summary> /// settingに設定をコピーする。 /// </summary> /// <param name="setting">ExportSettingオブジェクト</param> public void CopyTo(ExportSetting setting) { setting.CharaChipSize = CharaChipSize; setting.ExportFilePath = ExportFilePath; }