MainFrm.h 7.7 KB

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