public string FileCheck(string header) { /** * * 이 코드 안에서 팝업 타이틀 검증과 음소거에 대한 채크를 모두 수행합니다. * 타이틀이 업데이트인경우, 파일이 존재하지 않는경우, 칸코레 뷰어가 음소거인 경우,사운드출력을 할 수 없는 경우는 Empty을 return합니다 * * 그 외의 경우는 exe파일이 존재하는 기본 루트 폴더의 경로를 반환합니다. * 파일은 MP3파일이 우선권을 가지며 그 다음으로 WAV파일, 해당 경로에 파일이 없는경우에는 루트 폴더에서 알림음을 찾습니다 * mp3인지 wav인지는 SoundOutput에서 찾습니다. string의 형태이고 파일명이 정해져있으므로 파일명을 기준으로 구별합니다. * **/ string SelFolder = ""; var table = new Dictionary <string, string> { { Resources.Expedition_NotificationMessage_Title, "expedition" }, // 원정 { Resources.Repairyard_NotificationMessage_Title, "repair" }, // 수리 { Resources.ReSortie_NotificationMessage_Title, "Rejuvenated" }, // 피로회복 { "대파알림", "critical" }, // 대파 { Resources.Dockyard_NotificationMessage_Title, "Dockyard" }, // 건조 { "추격확인", "Yasen" }, // 야전 돌입 여부 선택 { "전투종료", "BattleEnd" } // 전투 종료 }; if (table.ContainsKey(header)) { SelFolder = table[header]; } else { // return string.Empty;//해당되는 헤더가 없을 경우 empty을 반환 SelFolder = header; } var path = Path.Combine(Main_folder, SelFolder); if (!Directory.Exists(path)) { return(string.Empty); //폴더검사해서 폴더가 없으면 empty 출력 } VolumeViewModel checkVolume = new VolumeViewModel(); if (!checkVolume.IsExistSoundDevice()) { return(string.Empty); } List <string> FileList = Directory.GetFiles(path, "*.wav", SearchOption.AllDirectories) .Concat(Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories)) .ToList(); if (!checkVolume.IsMute && FileList.Count > 0) { Random Rnd = new Random(); return(FileList[Rnd.Next(0, FileList.Count)]); } else { return(string.Empty); //파일이 없는 경우나 음소거인 경우 } }
public string FileCheck(string header) { /** * * 이 코드 안에서 팝업 타이틀 검증과 음소거에 대한 채크를 모두 수행합니다. * 타이틀이 업데이트인경우, 파일이 존재하지 않는경우, 칸코레 뷰어가 음소거인 경우,사운드출력을 할 수 없는 경우는 Empty을 return합니다 * * 그 외의 경우는 exe파일이 존재하는 기본 루트 폴더의 경로를 반환합니다. * 파일은 MP3파일이 우선권을 가지며 그 다음으로 WAV파일, 해당 경로에 파일이 없는경우에는 루트 폴더에서 알림음을 찾습니다 * mp3인지 wav인지는 SoundOutput에서 찾습니다. string의 형태이고 파일명이 정해져있으므로 파일명을 기준으로 구별합니다. * **/ string SelFolder = ""; if (header == Resources.Expedition_NotificationMessage_Title) { SelFolder = "\\expedition"; //원정 } else if (header == Resources.Repairyard_NotificationMessage_Title) { SelFolder = "\\repair"; //수리 } else if (header == Resources.ReSortie_NotificationMessage_Title) { SelFolder = "\\Rejuvenated"; //피로회복 } else if (header == "대파알림") { SelFolder = "\\critical"; //대파 } else if (header == Resources.Dockyard_NotificationMessage_Title) { SelFolder = "\\Dockyard"; //건조 } else { return(string.Empty); //해당되는 헤더가 없을 경우 empty을 반환 } if (!Directory.Exists(Main_folder + SelFolder)) { return(string.Empty); //폴더검사해서 폴더가 없으면 empty 출력 } VolumeViewModel checkVolume = new VolumeViewModel(); if (!checkVolume.IsExistSoundDevice()) { return(string.Empty); } List <string> FileList = Directory.GetFiles(Main_folder + SelFolder, "*.wav", SearchOption.AllDirectories) .Concat(Directory.GetFiles(Main_folder + SelFolder, "*.mp3", SearchOption.AllDirectories)).ToList(); if (!checkVolume.IsMute && FileList.Count > 0) { Random Rnd = new Random(); return(FileList[Rnd.Next(0, FileList.Count)]); } else { return(string.Empty); //파일이 없는 경우나 음소거인 경우 } }