1 #include "stdafx.h" 2 #include "FilterHelper.h" 3 #include "MusicPlayer2.h" 4 #include "Playlist.h" 5 #include "Lyric.h" 6 #include "AudioCommon.h" 7 GetAudioFileFilter()8wstring FilterHelper::GetAudioFileFilter() 9 { 10 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_SUPPORTED_AUDIO_FORMAT") + BulidExtFilter(CAudioCommon::m_all_surpported_extensions); 11 for (const auto& format : CAudioCommon::m_surpported_format) 12 { 13 filter += format.description; 14 filter.push_back(L'|'); 15 filter += format.extensions_list; 16 filter.push_back(L'|'); 17 } 18 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 19 return filter; 20 } 21 GetLyricFileFilter()22wstring FilterHelper::GetLyricFileFilter() 23 { 24 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_LYRIC_FILE") + BulidExtFilter(CLyrics::m_surpported_lyric); 25 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_LRC_FILE") + L"|*.lrc|"; 26 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_TXT_FILE") + L"|*.txt|"; 27 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 28 return filter; 29 } 30 GetSF2FileFilter()31wstring FilterHelper::GetSF2FileFilter() 32 { 33 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_SF2_FILE") + L"|*.SF2|"; 34 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 35 return filter; 36 } 37 GetListenTimeFilter()38wstring FilterHelper::GetListenTimeFilter() 39 { 40 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_CSV_FILE") + L"|*.csv|"; 41 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 42 return filter; 43 } 44 GetPlaylistSelectFilter()45wstring FilterHelper::GetPlaylistSelectFilter() 46 { 47 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_SUPPORTED_PLAYLIST_FILE") + BulidExtFilter(CPlaylistFile::m_surpported_playlist); 48 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_PLAYLIST_FILE") + L"|*" + PLAYLIST_EXTENSION + L"|"; 49 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_M3U_FILE") + L"|*.m3u|"; 50 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_M3U8_FILE") + L"|*.m3u8|"; 51 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 52 return filter; 53 } 54 GetPlaylistSaveAsFilter()55wstring FilterHelper::GetPlaylistSaveAsFilter() 56 { 57 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_M3U_FILE") + L"|*.m3u|"; 58 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_M3U8_FILE") + L"|*.m3u8|"; 59 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_PLAYLIST_FILE") + L"|*" + PLAYLIST_EXTENSION + L"|"; 60 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 61 return filter; 62 } 63 GetImageFileFilter()64wstring FilterHelper::GetImageFileFilter() 65 { 66 const vector<wstring> surpported_image = { L"jpg", L"jpeg", L"png", L"bmp", L"gif" }; 67 wstring filter = theApp.m_str_table.LoadText(L"TXT_FILTER_IMAGE_FILE") + BulidExtFilter(surpported_image); 68 filter += theApp.m_str_table.LoadText(L"TXT_FILTER_ALL_FILES") + L"|*.*||"; 69 return filter; 70 } 71 BulidExtFilter(const vector<wstring> & ext_list)72wstring FilterHelper::BulidExtFilter(const vector<wstring>& ext_list) 73 { 74 ASSERT(!ext_list.empty()); 75 wstring str{ L"|" }; 76 for (const wstring& ext : ext_list) 77 { 78 ASSERT(!ext.empty()); 79 str += L"*." + ext + L';'; 80 } 81 str.back() = L'|'; 82 return str; 83 } 84 85