MainFrm.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. // MainFrm.h: CMainFrame 类的接口
  12. //
  13. #pragma once
  14. #include "FileView.h"
  15. #include "ClassView.h"
  16. #include "OutputWnd.h"
  17. #include "IRControlWnd.h"
  18. #include "CalendarBar.h"
  19. #include "Resource.h"
  20. #include "SATHelperDoc.h"
  21. #include "SATHelperView.h"
  22. #include "ChildFrm.h"
  23. #include "DeviceView.h"
  24. #include "UB530View.h"
  25. #include "filehelper.h"
  26. #include "DevicesWnd.h"
  27. //////////////////////////////////////////////////////////////////////////
  28. #include "TrayIcon.h"
  29. #define USE_TRAYICON 1
  30. // 状态栏消息;
  31. #define MSG_STATUS_BAR (WM_USER + 101)
  32. class COutlookBar : public CMFCOutlookBar
  33. {
  34. virtual BOOL AllowShowOnPaneMenu() const { return TRUE; }
  35. virtual void GetPaneName(CString& strName) const { BOOL bNameValid = strName.LoadString(IDS_OUTLOOKBAR); ASSERT(bNameValid); if (!bNameValid) strName.Empty(); }
  36. };
  37. class CMainFrame : public CMDIFrameWndEx
  38. {
  39. DECLARE_DYNAMIC(CMainFrame)
  40. public:
  41. CMainFrame() noexcept;
  42. // 特性
  43. public:
  44. CSATHelperDoc* m_pDoc;
  45. CFormView* m_pActiveView;
  46. CChildFrame* m_pViewIDE[10];
  47. CChildFrame* m_pUB530View;
  48. CChildFrame* m_pDeviceView;
  49. // 操作
  50. public:
  51. // 重写
  52. public:
  53. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  54. // 实现
  55. public:
  56. virtual ~CMainFrame();
  57. #ifdef _DEBUG
  58. virtual void AssertValid() const;
  59. virtual void Dump(CDumpContext& dc) const;
  60. #endif
  61. protected: // 控件条嵌入成员
  62. CMFCRibbonBar m_wndRibbonBar;
  63. CMFCRibbonApplicationButton m_MainButton;
  64. CMFCToolBarImages m_PanelImages;
  65. CMFCRibbonStatusBar m_wndStatusBar;
  66. #if __DOCKINGBAR__
  67. #if __FC_WIN__
  68. CFileView m_wndFileView;
  69. CClassView m_wndClassView;
  70. #endif
  71. #if __OUT_PUT_WIN__
  72. COutputWnd m_wndOutput;
  73. #endif
  74. CIRControlWnd m_wndIRControl;
  75. CDevicesWnd m_wndDevices;
  76. #endif
  77. #if __OUTLOOKBAR__
  78. COutlookBar m_wndNavigationBar;
  79. CMFCShellTreeCtrl m_wndTree;
  80. CCalendarBar m_wndCalendar;
  81. #endif
  82. #if __CAPTIONBAR__
  83. CMFCCaptionBar m_wndCaptionBar;
  84. #endif
  85. // 生成的消息映射函数
  86. protected:
  87. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  88. afx_msg void OnWindowManager();
  89. afx_msg void OnApplicationLook(UINT id);
  90. afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI);
  91. afx_msg void OnViewCaptionBar();
  92. afx_msg void OnUpdateViewCaptionBar(CCmdUI* pCmdUI);
  93. afx_msg void OnOptions();
  94. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  95. afx_msg LRESULT OnMsgStatusBar(WPARAM wParam, LPARAM lParam);
  96. afx_msg void OnClose();
  97. void OnTraymenuExit();
  98. DECLARE_MESSAGE_MAP()
  99. #if __DOCKINGBAR__
  100. BOOL CreateDockingWindows();
  101. void SetDockingWindowIcons(BOOL bHiColorIcons);
  102. #endif
  103. #if __OUTLOOKBAR__
  104. BOOL CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth);
  105. #endif
  106. #if __CAPTIONBAR__
  107. BOOL CreateCaptionBar();
  108. #endif
  109. int FindFocusedOutlookWnd(CMFCOutlookBarTabCtrl** ppOutlookWnd);
  110. CMFCOutlookBarTabCtrl* FindOutlookParent(CWnd* pWnd);
  111. CMFCOutlookBarTabCtrl* m_pCurrOutlookWnd;
  112. CMFCOutlookBarPane* m_pCurrOutlookPage;
  113. public:
  114. #if USE_TRAYICON
  115. void InitTrayIcon();
  116. // 托盘是否显示;
  117. BOOL m_isNotify;
  118. // 启动程序时,隐藏或显示对话框,在消息处理程序OnNcPaint()中使用;
  119. BOOL m_bShowNc;
  120. // 是否响应托盘消息;
  121. BOOL m_bNoticeTray;
  122. // 托盘工作类;
  123. ITrayIcon m_trayIcon;
  124. BOOL m_bAutoRuning;
  125. afx_msg LRESULT OnTrayNotification(WPARAM wp, LPARAM lp);
  126. afx_msg LRESULT OnTaskBarCreated(WPARAM wp, LPARAM lp);
  127. void TaskNotifyIcon(); // 托盘的工作内容;
  128. void TrayRight();
  129. #endif
  130. CMFCRibbonButton* GetRibbonButton(int uId) {
  131. return DYNAMIC_DOWNCAST(CMFCRibbonButton, m_wndRibbonBar.FindByID(uId));
  132. }
  133. // 设置状态栏文本;
  134. void SetRibbonStatusBarText(CString strText, int uId) {
  135. if (IsWindow(m_wndStatusBar))
  136. {
  137. CMFCRibbonBaseElement* pElement = m_wndStatusBar.FindByID(uId);
  138. if (pElement)
  139. {
  140. pElement->SetText(strText);
  141. pElement->Redraw();
  142. }
  143. }
  144. }
  145. public:
  146. virtual BOOL PreTranslateMessage(MSG* pMsg);
  147. //afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
  148. afx_msg LRESULT OnRibbonChanged(WPARAM wParam, LPARAM lParam);
  149. // 是否遥控截图;
  150. BOOL m_bShotIR;
  151. public:
  152. //////////////////////////////////////////////////////////////////////////
  153. // 读取baidu.cfg配置文件内容;
  154. typedef struct __COUNT_INFO__
  155. {
  156. std::string app_id;
  157. std::string api_key;
  158. std::string secret_key;
  159. std::string ret_count;
  160. }CountInfo, * pCountInfo;
  161. typedef struct __BAIDU_CFG__
  162. {
  163. std::string cur_count;
  164. std::string reset_time;
  165. std::map<std::string, __COUNT_INFO__> list_count;
  166. }BaiduCfg, * pBaiduCfg;
  167. BaiduCfg m_bdcfg;
  168. TCHAR m_szBaiduCfgPath[MAX_PATH];
  169. void ReadBaiduCfg(BaiduCfg& bdcfg);
  170. //////////////////////////////////////////////////////////////////////////
  171. // 读取resource_run.cfg配置文件内容;
  172. typedef struct __RS_RUN_CFG__
  173. {
  174. std::string sound_list; // 声音级别;
  175. std::string sound1;
  176. std::string sound2;
  177. std::string full_cut; // 是否全步骤截图;('True/False')
  178. //....
  179. std::string tg39_port;
  180. std::string tv_port;
  181. std::string sat_home;
  182. std::string sat_result_dir;
  183. std::string chroma22293;
  184. //...
  185. std::string menutree_chip;
  186. std::string menutree_style;
  187. std::string menutree_channel;
  188. //...
  189. std::string chroma1;
  190. std::string chroma2;
  191. // 是否监听电视;
  192. bool bWatchTV;
  193. }RsRunCfg, * pRsRunCfg;
  194. RsRunCfg m_rscfg;
  195. TCHAR m_szRsCfgPath[MAX_PATH];
  196. void ReadRsRunCfg(RsRunCfg& rscfg);
  197. //////////////////////////////////////////////////////////////////////////
  198. // 读取menutree目录;
  199. typedef struct __UI_TREE__
  200. {
  201. std::string ui;
  202. std::vector<std::string> vtSubUI;
  203. }UITree, * pUITree;
  204. std::map<std::string, std::vector<UITree>> m_map_tree;
  205. // 当前选中的MenuTree路径;
  206. TCHAR m_szCurMenuTreeDir[MAX_PATH];
  207. void ReadTreePath();
  208. // 解析json;
  209. void ParseJson();
  210. // 运行设备;
  211. void RunDevice();
  212. std::vector<std::string> m_vtCOM;
  213. void InitCombobox_port();
  214. BOOL IsPortInserted(CMFCRibbonComboBox* pCommbox, LPCTSTR lpPort);
  215. afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData);
  216. public:
  217. void InitDevicePanel();
  218. // 全步骤截图;
  219. afx_msg void OnCheckFullCut();
  220. afx_msg void OnUpdateCheckFullCut(CCmdUI* pCmdUI);
  221. // 有声按钮;
  222. afx_msg void OnHadSound();
  223. afx_msg void OnUpdateHadSound(CCmdUI* pCmdUI);
  224. // 声音默认按钮;
  225. afx_msg void OnDefSound();
  226. afx_msg void OnUpdateDefSound(CCmdUI* pCmdUI);
  227. // 声音等级编辑框;
  228. // OCR账号下拉框;
  229. afx_msg void OnComboxOcr();
  230. afx_msg void OnUpdateComboxOcr(CCmdUI* pCmdUI);
  231. // MenuTree项目下拉框;
  232. afx_msg void OnComboProduct();
  233. afx_msg void OnUpdateComboProduct(CCmdUI* pCmdUI);
  234. // MenuTree UI下拉框;
  235. afx_msg void OnComboUi();
  236. afx_msg void OnUpdateComboUi(CCmdUI* pCmdUI);
  237. // MenuTree 子UI下拉框;
  238. afx_msg void OnComboSubUi();
  239. afx_msg void OnUpdateComboSubUi(CCmdUI* pCmdUI);
  240. // 信号仪1下拉框;
  241. afx_msg void OnCombo1_22293();
  242. afx_msg void OnUpdateCombo1_22293(CCmdUI* pCmdUI);
  243. // 信号仪2下拉框;
  244. afx_msg void OnCombo2_22293();
  245. afx_msg void OnUpdateCombo2_22293(CCmdUI* pCmdUI);
  246. // 信号仪1CheckBox;
  247. afx_msg void OnCheck1_22293();
  248. afx_msg void OnUpdateCheck1_22293(CCmdUI* pCmdUI);
  249. // 信号仪2CheckBox;
  250. afx_msg void OnCheck2_22293();
  251. afx_msg void OnUpdateCheck2_22293(CCmdUI* pCmdUI);
  252. afx_msg void OnCombo2Tv();
  253. afx_msg void OnUpdateCombo2Tv(CCmdUI* pCmdUI);
  254. afx_msg void OnCheckWatchtv();
  255. afx_msg void OnUpdateCheckWatchtv(CCmdUI* pCmdUI);
  256. afx_msg void OnTraymenuLogin();
  257. afx_msg void OnCheckEnabletw();
  258. afx_msg void OnUpdateCheckEnabletw(CCmdUI* pCmdUI);
  259. afx_msg void OnComboTwport();
  260. afx_msg void OnUpdateComboTwport(CCmdUI* pCmdUI);
  261. afx_msg void OnCheckRcontrol();
  262. afx_msg void OnUpdateCheckRcontrol(CCmdUI* pCmdUI);
  263. afx_msg void OnCheckActuator();
  264. afx_msg void OnUpdateCheckActuator(CCmdUI* pCmdUI);
  265. };