1 #pragma once 2 #include "BaseDialog.h" 3 #include "IPlayerCore.h" 4 #include "ListCtrlEx.h" 5 #include "PlayerProgressBar.h" 6 #include "BrowseEdit.h" 7 8 9 //单个文件转换进度的消息 10 //wParam: 文件在m_file_list列表中的索引 11 //lParam: 转换的进度。0~100: 已完成的百分比; 101: 已完成; 102: 已跳过; <0:出错 12 #define WM_CONVERT_PROGRESS (WM_USER+111) 13 //全部文件转换已完成的消息 14 #define WM_CONVERT_COMPLETE (WM_USER+112) 15 16 #define ALBUM_COVER_NAME_ENCODE L"TempAlbumCover-MusicPlayer2-CkV8E0YI" 17 18 // CFormatConvertDlg 对话框 19 20 class CFormatConvertDlg : public CBaseDialog 21 { 22 DECLARE_DYNAMIC(CFormatConvertDlg) 23 24 public: 25 CFormatConvertDlg(CWnd* pParent = nullptr); // 标准构造函数 26 CFormatConvertDlg(const vector<SongInfo>& items, CWnd* pParent = nullptr); 27 virtual ~CFormatConvertDlg(); 28 29 //工作线程函数 30 static UINT ThreadFunc(LPVOID lpParam); 31 32 // 对话框数据 33 #ifdef AFX_DESIGN_TIME 34 enum { IDD = IDD_FORMAT_CONVERT_DIALOG }; 35 #endif 36 37 protected: 38 //控件变量 39 CListCtrlEx m_file_list_ctrl; 40 CComboBox m_encode_format_combo; 41 CPlayerProgressBar m_progress_bar; 42 CComboBox m_freq_comb; 43 CBrowseEdit m_out_dir_edit; 44 CBrowseEdit m_out_name_edit; 45 46 vector<SongInfo> m_file_list; // 要转换格式的文件列表 47 wstring m_out_dir; // 输出目录 48 wstring m_out_name; // 输出文件名格式字符串 49 EncodeFormat m_encode_format{ EncodeFormat::MP3 }; 50 CWinThread* m_pThread{}; //格式转换的线程 51 52 bool m_encoder_succeed; 53 bool m_thread_runing{}; 54 55 MP3EncodePara m_mp3_encode_para; //MP3编码参数 56 OggEncodePara m_ogg_encode_para; //OGG编码参数 57 WmaEncodePara m_wma_encode_para; //wma编码参数 58 FlacEncodePara m_flac_encode_para; //FLAC编码参数 59 60 int m_item_selected; 61 62 //选项数据 63 bool m_write_tag; //向目标文件写入标签信息 64 bool m_write_album_cover; //向目标文件写入专辑封面 65 int m_file_exist_action; //当目标文件存在时的动作(0: 自动重命名; 1: 忽略; 2: 覆盖) 66 bool m_add_file_serial_num; //为目标文件添加数字编号 67 bool m_convert_freq{ false }; //是否转换采样频率 68 wstring m_freq_sel{}; //采样频率下拉列表中的选中项 69 bool m_open_output_dir{ false }; //转换完成后打开输出目录 70 71 vector<pair<wstring, int>> m_freq_map; 72 73 virtual CString GetDialogName() const override; 74 virtual bool InitializeControls() override; 75 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 76 77 void LoadConfig(); 78 void SaveConfig() const; 79 void LoadEncoderConfig(); 80 void SaveEncoderConfig() const; 81 82 void EnableControls(bool enable); 83 void SetEncodeConfigBtnState(); 84 void ShowFileList(); 85 bool InitEncoder(); 86 //编码单个文件(在线程函数中调用) 87 //file_index: 编码的文件在m_file_list中的索引 88 static bool EncodeSingleFile(CFormatConvertDlg* pthis, int file_index); 89 90 void SetProgressInfo(int progress); 91 int GetFreq(); 92 93 DECLARE_MESSAGE_MAP() 94 public: 95 virtual BOOL OnInitDialog(); 96 afx_msg void OnCbnSelchangeOutFormatCombo(); 97 afx_msg void OnBnClickedStartConvertButton(); 98 //afx_msg void OnBnClickedBrowseButton(); 99 protected: 100 afx_msg LRESULT OnConvertProgress(WPARAM wParam, LPARAM lParam); 101 afx_msg LRESULT OnConvertComplete(WPARAM wParam, LPARAM lParam); 102 public: 103 virtual void OnCancel(); 104 virtual void OnOK(); 105 afx_msg void OnClose(); 106 afx_msg void OnBnClickedEncoderConfigButton(); 107 afx_msg void OnBnClickedCopyTagCheck(); 108 afx_msg void OnBnClickedCopyAlbumCoverCheck(); 109 afx_msg void OnCbnSelchangeTargetFileExistCombo(); 110 afx_msg void OnBnClickedAddNumberCheck(); 111 afx_msg void OnNMRClickSongList1(NMHDR *pNMHDR, LRESULT *pResult); 112 afx_msg void OnAddFile(); 113 afx_msg void OnDeleteSelect(); 114 afx_msg void OnClearList(); 115 afx_msg void OnMoveUp(); 116 afx_msg void OnMoveDown(); 117 virtual BOOL PreTranslateMessage(MSG* pMsg); 118 afx_msg void OnEditTagInfo(); 119 afx_msg void OnInitMenu(CMenu* pMenu); 120 afx_msg void OnNMDblclkSongList1(NMHDR *pNMHDR, LRESULT *pResult); 121 afx_msg void OnBnClickedChangeFreqCheck(); 122 afx_msg void OnCbnSelchangeFreqCombo(); 123 protected: 124 afx_msg LRESULT OnEditBrowseChanged(WPARAM wParam, LPARAM lParam); 125 public: 126 afx_msg void OnBnClickedOpenTargetDirCheck(); 127 }; 128