xref: /MusicPlayer2/MusicPlayer2/LyricBatchDownloadDlg.h (revision 86e2c9c227ea58a4f87dda2d9ffa8cbe422b3071)
1 #pragma once
2 #include "Common.h"
3 #include "Player.h"
4 #include "LyricDownloadCommon.h"
5 #include "LyricDownloadDlg.h"
6 #include "ListCtrlEx.h"
7 #include "PlayerProgressBar.h"
8 #include "BaseDialog.h"
9 
10 // CLyricBatchDownloadDlg 对话框
11 
12 class CLyricBatchDownloadDlg : public CBaseDialog
13 {
14 	DECLARE_DYNAMIC(CLyricBatchDownloadDlg)
15 
16 public:
17 	CLyricBatchDownloadDlg(CWnd* pParent = NULL);   // 标准构造函数
18 	virtual ~CLyricBatchDownloadDlg();
19 
20 // 对话框数据
21 #ifdef AFX_DESIGN_TIME
22 	enum { IDD = IDD_LYRIC_BATCH_DOWN_DIALOG };
23 #endif
24 
25 #define WM_BATCH_DOWNLOAD_COMPLATE (WM_USER+103)		//歌词批量下载完成消息
26 
27 	//用于向多下载线程传递数据的结构体
28 	struct ThreadInfo
29 	{
30 		CListCtrl* list_ctrl;
31 		CStatic* static_ctrl;
32         CPlayerProgressBar* progress_bar;
33 		const vector<SongInfo>* playlist;
34 		bool skip_exist;
35 		bool download_translate;
36 		bool save_to_song_folder;
37 		CodeType save_code;
38 		HWND hwnd;
39 		//bool exit;
40 	};
41 
42 	//工作线程函数
43 	static UINT ThreadFunc(LPVOID lpParam);
44 
45 	ThreadInfo m_thread_info;
46 
47 	static bool SaveLyric(const wchar_t* path, const wstring& lyric_wcs, CodeType code_type, bool* char_cannot_convert);		//保存歌词,如果将歌词保存为ANSI格式时有无法转换的Unicode字符,则char_cannot_convert置为true
48 
49 protected:
50 	CButton m_skip_exist_check;
51 	CComboBox m_save_code_combo;
52 	CListCtrlEx m_song_list_ctrl;
53 	CButton m_download_translate_chk;
54 	CStatic m_info_static;
55     CPlayerProgressBar m_progress_bar;
56 
57 	bool m_skip_exist{ true };		//跳过已有歌词的曲目
58 	CodeType m_save_code{};		//保存的编码格式
59 	bool m_download_translate{ false };		//是否下载歌词翻译
60 	bool m_save_to_song_folder{ true };		//是否保存到歌曲所在目录
61 	const vector<SongInfo>& m_playlist{ CPlayer::GetInstance().GetPlayList() };	//播放列表的引用
62 
63 	bool m_lyric_path_not_exit{ false };
64 
65 	CWinThread* m_pThread{};		//下载歌词的线程
66 
67     virtual CString GetDialogName() const override;
68     virtual bool InitializeControls() override;
69     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
70 
71     void SaveConfig() const;
72 	void LoadConfig();
73 
74 	void EnableControls(bool enable);		//启用或禁用控件
75 
76 	DECLARE_MESSAGE_MAP()
77 public:
78 	virtual BOOL OnInitDialog();
79 	afx_msg void OnBnClickedStartDownload();
80 	afx_msg void OnBnClickedSkipExistCheck();
81 	afx_msg void OnDestroy();
82 	afx_msg void OnCbnSelchangeCombo1();
83 	afx_msg void OnBnClickedDownloadTrasnlateCheck2();
84 protected:
85 	afx_msg LRESULT OnBatchDownloadComplate(WPARAM wParam, LPARAM lParam);
86 public:
87 	afx_msg void OnClose();
88 	virtual void OnCancel();
89 	virtual void OnOK();
90 	afx_msg void OnBnClickedSaveToSongFolder();
91 	afx_msg void OnBnClickedSaveToLyricFolder();
92 };
93