public static void レーン配置を設定する(string レーン配置名) { using (Log.Block(FDKUtilities.現在のメソッド名)) { if (レーン配置リスト.ContainsKey(レーン配置名)) { 現在のレーン配置 = レーン配置リスト[レーン配置名]; } else { Log.ERROR($"指定されたレーン配置名「{レーン配置名}」が存在しません。"); if (0 < レーン配置リスト.Count) { 現在のレーン配置 = レーン配置リスト.ElementAt(0).Value; Log.WARNING($"既定のレーン配置名「{現在のレーン配置.配置名}」を選択しました。"); } else { throw new Exception("既定のレーン配置名を選択しようとしましたが、存在しません。"); } } Log.Info($"レーン配置「{現在のレーン配置.配置名}」を選択しました。"); } }
// 生成と終了(static) public static void 初期化する() { using (Log.Block(FDKUtilities.現在のメソッド名)) { // レーン配置フォルダから、レーン配置に適合する設定ファイルを検索。 var root = new VariablePath(@"$(System)images\演奏\レーン配置"); レーン配置リスト = new Dictionary <string, レーン配置>(); foreach (var fileInfo in new DirectoryInfo(root.数なしパス).GetFiles("Type*.yaml", SearchOption.TopDirectoryOnly)) { var 拡張子なしのファイル名 = Path.GetFileNameWithoutExtension(fileInfo.Name); レーン配置リスト[拡張子なしのファイル名] = new レーン配置 { 配置名 = 拡張子なしのファイル名 }; } // 各設定ファイルから設定を読み込む。 foreach (var kvp in レーン配置リスト) { var 設定ファイルパス = new VariablePath(Path.Combine(root.数なしパス, kvp.Key + ".yaml")); try { var yaml = File.ReadAllText(設定ファイルパス.数なしパス); var deserializer = new Deserializer(); var yamlMap = deserializer.Deserialize <YAMLマップ>(yaml); kvp.Value.表示レーンの左端位置dpx = yamlMap.左端位置; kvp.Value.表示レーンの幅dpx = yamlMap.幅; kvp.Value.レーンライン = new RectangleF[yamlMap.レーンライン.Length]; for (int i = 0; i < yamlMap.レーンライン.Length; i++) { if (4 == yamlMap.レーンライン[i].Length) { kvp.Value.レーンライン[i] = new RectangleF(yamlMap.レーンライン[i][0], yamlMap.レーンライン[i][1], yamlMap.レーンライン[i][2], yamlMap.レーンライン[i][3]); } } kvp.Value.レーン色 = new Color4(Convert.ToUInt32(yamlMap.レーン色, 16)); kvp.Value.レーンライン色 = new Color4(Convert.ToUInt32(yamlMap.レーンライン色, 16)); Log.Info($"{設定ファイルパス.変数付きパス} ... 完了"); } catch (Exception e) { Log.Info($"{設定ファイルパス.変数付きパス} ... 失敗 [{Folder.絶対パスをフォルダ変数付き絶対パスに変換して返す( e.Message )}]"); } } レーン配置を設定する("TypeA"); } }