1 #pragma once 2 #include "BaseDialog.h" 3 4 // CTagSelBaseDlg 对话框 5 6 class CTagSelBaseDlg : public CBaseDialog 7 { 8 DECLARE_DYNAMIC(CTagSelBaseDlg) 9 10 public: 11 CTagSelBaseDlg(bool original_str_disable, CWnd* pParent = nullptr); // 标准构造函数 12 virtual ~CTagSelBaseDlg(); 13 14 // DoModal之前外部设置一个Formular(可选),窗口初始化时会被设为当前选中 SetInitInsertFormular(const wstring & formular)15 void SetInitInsertFormular(const wstring& formular) { m_init_insert_formular = formular; }; 16 // DoModal之后获取当前选中的Formular GetFormularSelected()17 wstring GetFormularSelected() const { return m_formular_selected; }; 18 19 // 根据formular从文件名(参数不要输入扩展名)猜测标签 20 static void GetTagFromFileName(const wstring& formular, const wstring& file_name, SongInfo& song_info); 21 // 根据formular字符串从标签生成文件名(不含扩展名) 22 static wstring FileNameFromTag(wstring formular, const SongInfo& song_info); 23 24 static const wstring FORMULAR_TITLE; 25 static const wstring FORMULAR_ARTIST; 26 static const wstring FORMULAR_ALBUM; 27 static const wstring FORMULAR_TRACK; 28 static const wstring FORMULAR_YEAR; 29 static const wstring FORMULAR_GENRE; 30 static const wstring FORMULAR_COMMENT; 31 static const wstring FORMULAR_ORIGINAL; 32 static const vector<wstring> default_formular; 33 34 // 对话框数据 35 #ifdef AFX_DESIGN_TIME 36 enum { IDD = IDD_TAG_MODE_SELECT_DIALOG }; 37 #endif 38 39 private: 40 void SaveConfig() const; 41 void LoadConfig(); 42 43 // 使用m_default_formular初始化列表下拉列表,并选中第一项 44 void InitComboList(); 45 bool IsStringContainsFormular(const wstring& str) const; 46 void InsertFormular(const wstring& str_formular); 47 void OnTagBtnClicked(const wstring& tag); 48 49 wstring m_formular_selected; 50 bool m_original_str_disable{}; // 不显示此窗口的所有%(Original)相关功能 51 52 bool m_insert_when_clicked{}; 53 vector<wstring> m_default_formular; 54 protected: 55 wstring m_init_insert_formular; 56 CComboBox m_format_combo; 57 58 // 从CBaseDialog继承的虚方法 59 // virtual CString GetDialogName() const = 0; IsRememberDialogSizeEnable()60 virtual bool IsRememberDialogSizeEnable() const override final { return false; }; 61 // 派生类需要覆写InitializeControls设置标题和IDC_INFO_STATIC控件文本后调用基类 62 virtual bool InitializeControls() override; 63 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 64 65 DECLARE_MESSAGE_MAP() 66 public: 67 virtual BOOL OnInitDialog(); 68 afx_msg void OnBnClickedTitleButton(); 69 afx_msg void OnBnClickedArtistButton(); 70 afx_msg void OnBnClickedAlbumButton(); 71 afx_msg void OnBnClickedTrackButton(); 72 afx_msg void OnBnClickedYearButton(); 73 afx_msg void OnBnClickedGenreButton(); 74 afx_msg void OnBnClickedCommentButton(); 75 afx_msg void OnBnClickedOriginalButton(); 76 afx_msg void OnCbnSelchangeCombo1(); 77 afx_msg void OnBnClickedInsertRadio(); 78 afx_msg void OnBnClickedCopyRadio(); 79 afx_msg void OnDestroy(); 80 virtual void OnOK(); 81 }; 82