IRControlWnd.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面
  2. // (“Fluent UI”)。该示例仅供参考,
  3. // 用以补充《Microsoft 基础类参考》和
  4. // MFC C++ 库软件随附的相关电子文档。
  5. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。
  6. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问
  7. // https://go.microsoft.com/fwlink/?LinkId=238214.
  8. //
  9. // 版权所有(C) Microsoft Corporation
  10. // 保留所有权利。
  11. //#include "DlgIRControl.h"
  12. #include <map>
  13. #pragma once
  14. // 按钮id起始值;
  15. #define BTNID 11000
  16. #define WM_IR_SHOT_IMG WM_USER + 10012
  17. // layout.xml item;
  18. typedef struct __BTN_INFO__
  19. {
  20. std::string name;
  21. int width;
  22. int height;
  23. DWORD color;
  24. CMFCButton *pBTN = nullptr;
  25. bool bEnable = false;
  26. }BtnInfo, *pBtnInfo;
  27. class CIRControlToolBar : public CMFCToolBar
  28. {
  29. public:
  30. virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler)
  31. {
  32. CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler);
  33. }
  34. virtual BOOL AllowShowOnList() const { return FALSE; }
  35. };
  36. class CIRControlWnd : public CDockablePane
  37. {
  38. // 构造
  39. public:
  40. CIRControlWnd() noexcept;
  41. void AdjustLayout();
  42. // 特性
  43. public:
  44. protected:
  45. CFont m_fntPropList;
  46. // 重启服务端进程;
  47. CMFCButton m_btnRestart;
  48. // 信号集文件;
  49. CComboBox m_wndSignalCombo;
  50. // 选择通用遥控器;
  51. CMFCButton m_wndSignalCheck;
  52. #if __PANE_DLG__
  53. CDlgIRControl m_dlgIRControl;
  54. #endif
  55. CMFCButton m_btnSwitchRemote;
  56. CMFCButton m_btnFindinfraRed;
  57. CMFCButton m_btnFindBluetooth;
  58. // TREE一级选项;
  59. CComboBox m_cbTree1;
  60. // TREE二级选项;
  61. CComboBox m_cbTree2;
  62. // TREE三级;
  63. CComboBox m_cbTree3;
  64. int CreateCtrl();
  65. // 实现
  66. public:
  67. virtual ~CIRControlWnd();
  68. // 去掉关闭按钮;但组合多个pane时无效;
  69. virtual BOOL CanBeClosed() const { return FALSE; };
  70. // 禁止拖动Pane;
  71. virtual BOOL FloatPane(CRect rectFloat, AFX_DOCK_METHOD dockMethod = DM_UNKNOWN, bool bShow = true) { return FALSE; }
  72. // 禁用停靠,双击底部无效(不会停靠)
  73. virtual BOOL CanFloat() const { return FALSE; };
  74. // 禁用大小;//崩溃;
  75. //virtual BOOL IsResizable() const {return FALSE;}
  76. protected:
  77. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  78. afx_msg void OnSize(UINT nType, int cx, int cy);
  79. afx_msg void OnExpandAllProperties();
  80. afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI);
  81. afx_msg void OnSortProperties();
  82. afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI);
  83. afx_msg void OnProperties1();
  84. afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI);
  85. afx_msg void OnProperties2();
  86. afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI);
  87. afx_msg void OnSetFocus(CWnd* pOldWnd);
  88. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  89. // 下拉框选项变化事件;
  90. afx_msg void OnCbnSelchangeSignal();
  91. afx_msg void OnCbnSelchangeTree1();
  92. afx_msg void OnCbnSelchangeTree2();
  93. afx_msg void OnCbnSelchangeTree3();
  94. DECLARE_MESSAGE_MAP()
  95. void SetPropListFont();
  96. int m_nComboHeight;
  97. // 重启红老鼠;
  98. void StartIRDevice(BOOL bReStart = TRUE);
  99. // 禁用信号按钮;
  100. void DisableSignalBtn() {
  101. for (std::vector<BtnInfo>::iterator it = m_vtBtnInfo.begin(); it != m_vtBtnInfo.end(); it++)
  102. {
  103. it->bEnable = false;
  104. }
  105. }
  106. public:
  107. // 重载信号文件;
  108. void ReLoadSignalXml();
  109. std::map<UINT, BtnInfo&> m_map_btn;
  110. std::vector<std::string> m_vtsignal_gen;
  111. std::vector<std::string> m_vtsignal_pro;
  112. std::vector<std::string> m_vtsignal_tw;
  113. void LoadSignals();
  114. std::vector<BtnInfo> m_vtBtnInfo;
  115. void Loadlayout(std::vector<BtnInfo> &vt);
  116. afx_msg void OnPaint();
  117. // 单击按钮;
  118. afx_msg void OnSignalBtnClick(UINT uId);
  119. // 更新按钮状态;
  120. afx_msg void OnUpdateSignalBtn(CCmdUI* pCmdUI);
  121. // 更新checkbox状态;
  122. afx_msg void OnUpdateCheckBox(CCmdUI * pCmdUI);
  123. afx_msg void OnCheckBoxClicked();
  124. // 更新重启按钮状态;
  125. afx_msg void OnUpdateBtnRestartProc(CCmdUI* pCmdUI);
  126. afx_msg void OnBtnRestartProcClicked();
  127. // 选择遥控器;
  128. afx_msg void OnUpdateSwitchRemote(CCmdUI* pCmdUI);
  129. afx_msg void OnSwitchRemoteClicked();
  130. afx_msg void OnUpdateFindFindinfraRed(CCmdUI* pCmdUI);
  131. afx_msg void OnFindFindinfraRedClicked();
  132. afx_msg void OnUpdateFindBluetooth(CCmdUI* pCmdUI);
  133. afx_msg void OnFindBluetoothClicked();
  134. // 更新按钮实际状态;
  135. void UpdateSignalBtnStatus();
  136. // 自动根据Combobox选项长度设置宽度;
  137. void AutoSetDroppedWidth(CComboBox* pCombobox);
  138. // CCombobox添加水平滚动条;
  139. void AddHScroll(CComboBox* pCombobox);
  140. //////////////////////////////////////////////////////////////////////////
  141. // 读取resource_run.cfg配置文件内容;
  142. typedef struct __RS_RUN_CFG__
  143. {
  144. std::string sound_list; // 声音级别;
  145. std::string sound1;
  146. std::string sound2;
  147. std::string full_cut; // 是否全步骤截图;('True/False')
  148. //....
  149. std::string tg39_port;
  150. std::string tv_port;
  151. std::string sat_home;
  152. std::string sat_result_dir;
  153. std::string chroma22293;
  154. //...
  155. std::string menutree_chip;
  156. std::string menutree_style;
  157. std::string menutree_channel;
  158. //...
  159. std::string chroma1;
  160. std::string chroma2;
  161. // 是否监听电视;
  162. bool bWatchTV;
  163. }RsRunCfg, * pRsRunCfg;
  164. RsRunCfg m_rscfg;
  165. void ReadResourceRunCfg();
  166. // 读取menutree目录;
  167. typedef struct __UI_TREE__
  168. {
  169. std::string ui;
  170. std::vector<std::string> vtSubUI;
  171. }UITree, * pUITree;
  172. std::map<std::string, std::vector<UITree>> m_map_tree;
  173. // 当前选中的MenuTree路径;
  174. TCHAR m_szCurMenuTreeDir[MAX_PATH];
  175. // 初始化MenuTree下拉框;
  176. void LoadMenuTreePath();
  177. void InitMenuTreeCombobox();
  178. // 遥控截图自定义消息;
  179. BOOL m_bSendKey;
  180. afx_msg LRESULT OnIRShotImg(WPARAM wparam, LPARAM lparam);
  181. };