MainFrm.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. // MainFrm.h : CMainFrame 类的接口
  2. //
  3. #pragma once
  4. #include "TRAYICON.H"
  5. #include "ViewManager.h"
  6. #include "WindowManager.h"
  7. #include "DlgBmp.h"
  8. #include "ChildFrm.h"
  9. #include "OOExToolBar.h"
  10. #include "DlgDevice.h"
  11. #include "DlgComport.h"
  12. #include "IDEDoc.h"
  13. #include "RealEventDlg.h"
  14. #include "Dlg_ToolBar.h"
  15. #include "Dlg_ZuTaiAdd.h"
  16. #define WM_MY_NEW_ALERT WM_USER + 102
  17. #define VIEW_MAX_NUM 1000 //画面最大数
  18. typedef struct tag_PIC_VAR {
  19. CString sPicPath;
  20. CString sCaption[1000];
  21. int nType[1000];//0:m_bVariant 1:m_strDynShow
  22. } PIC_VAR;
  23. class CMDIAutoHideFrame;
  24. class CMainFrame : public CMDIAutoHideFrame
  25. {
  26. DECLARE_DYNAMIC(CMainFrame)
  27. public:
  28. CMainFrame();
  29. // 属性
  30. public:
  31. //////////////////////////////////
  32. // Tab View 变量
  33. CViewManager m_wndViewManager;
  34. CMDIClient m_MDIClient;
  35. ////////////////////////////////
  36. //TrayIcon相关变量
  37. CTrayIcon m_trayIcon; // my tray icon
  38. BOOL m_bShutdown; // OK to terminate TRAYTEST
  39. BOOL m_bShowTrayNotifications; // display info in main window
  40. //左边树形
  41. CcHnDockPageBar m_wndDockPageBar1;
  42. CTreeCtrl m_wndTree;
  43. //通知列表
  44. CDockPageBar m_wndDockPageBar2;
  45. CRealEventDlg* m_dlgEvent;
  46. //上面工具栏
  47. CDockPageBar m_wndDockPageBar3;
  48. CDlg_ToolBar *m_pToolBar;
  49. WINDOWPLACEMENT m_wpPrev;
  50. CRect m_FullScreenWindowRect;
  51. CMenu m_OrgMenu;
  52. CRect m_mainRect;
  53. CStatusBar m_wndStatusBar;
  54. ////////////////////////////////////
  55. // 子窗体
  56. CChildFrame *m_pViewIDE[MAX_VIEW_NUM];
  57. CFormView *m_pActiveView;
  58. int m_nViewCount;
  59. CIDEDoc *m_pDoc;
  60. CDlgDevice m_wndDevice;
  61. CDlgComport m_wndComport;
  62. CDlg_ZuTaiAdd *m_pDlgZuTaiAdd;
  63. HTREEITEM m_hSerialGroup[MAX_SERIAL_NUM]; //串口组
  64. HTREEITEM m_hSerialDev[MAX_SERIAL_NUM][MAX_DEVICE_NUM]; //串口设备
  65. HTREEITEM m_hNetworkDev[MAX_NETWORK_NUM]; //以太网设备
  66. HANDLE m_hViewPollThread;
  67. protected: // 控件条嵌入成员
  68. CToolBar m_wndToolBar;
  69. CToolBar m_wndDrawToolBar;
  70. CToolBar m_wndDrawAlignBar;
  71. //COOBmpToolBar m_wndRunToolBar;
  72. bool m_bHideLeft;
  73. CDlgBmp* m_dlgControl;
  74. CImageList m_wndImageList;
  75. private:
  76. HTREEITEM m_hMonitor; //监控站
  77. HTREEITEM m_hIOGroup; //IO
  78. HTREEITEM m_hScript; //脚本设置
  79. HTREEITEM m_hActionWithAlarm; //报警联动
  80. HTREEITEM m_hVariant; //数据字典
  81. public:
  82. HTREEITEM m_hSerial; //232设置
  83. HTREEITEM m_hEtherNet; //以太网设置
  84. private:
  85. HTREEITEM m_hAnalog; //变量
  86. HTREEITEM m_hSystem; //系统参数
  87. HTREEITEM m_hCurrent; //当前所选
  88. CPoint m_mousePoint;
  89. HTREEITEM m_hScriptGroup[MAX_SCRIPT_NUM]; //脚本
  90. int m_nPortNum, m_nDeviceNum; //串口数和设备数
  91. int m_nScripts;
  92. // 操作
  93. public:
  94. static DWORD WINAPI ViewPollThread( void *pData );
  95. void OnEditCommond();
  96. void ManageHisData();
  97. void LoadEventPara();
  98. void StoreEventPara();
  99. void SetEventPara();
  100. void StoreRunPara(BOOL bStartRun);
  101. void HideRunBar();
  102. void AddIDEView(CString strDesc, CString strPath);
  103. int GetIDEViewIndex(CString strPath);
  104. void AddDevice();
  105. void DeleteDev(int nIsHint);
  106. void InitTreeInfo(void);
  107. int FinishedAddDevice(int nIsDelete, CString strUid);
  108. private:
  109. BOOL InstallIcons();
  110. void FileSearch(HTREEITEM hItem, CString strPath, CString strFileName, int nLayer);
  111. BOOL DirSearch(CString strPath, CString strFileName);
  112. BOOL FindTreeItem(HTREEITEM hSrcItem, HTREEITEM hDestItem);
  113. void OnRun();
  114. int GetIDEViewFreeIndex(CString strPath);
  115. bool ShowView(void);
  116. void DeleteDirectory(CString strDir);
  117. void LoadRunPara();
  118. void SetRunPara();
  119. public:
  120. int GetNetworkChannelIndex();
  121. int GetFreeSerialTreeItem();
  122. int GetFreeNetworkTreeItem();
  123. int GetIndexSerialTreeItem(CString strSrc);
  124. int GetIndexNetworkTreeItem(CString strSrc);
  125. int ShowDevProperty(HTREEITEM hSelectedItem);
  126. void ShowCaptionMenu(BOOL bShow);
  127. // 重写
  128. public:
  129. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  130. // 实现
  131. public:
  132. virtual ~CMainFrame();
  133. #ifdef _DEBUG
  134. virtual void AssertValid() const;
  135. virtual void Dump(CDumpContext& dc) const;
  136. #endif
  137. // 生成的消息映射函数
  138. protected:
  139. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  140. #if USE_TRAYICON
  141. afx_msg LRESULT OnTrayNotification(WPARAM wp, LPARAM lp);
  142. afx_msg LRESULT OnTaskBarCreated(WPARAM wp, LPARAM lp);
  143. #endif
  144. DECLARE_MESSAGE_MAP()
  145. public:
  146. afx_msg void OnClose();
  147. afx_msg void OnSuperEnd();
  148. afx_msg void OnTrayOpen();
  149. protected:
  150. virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  151. public:
  152. afx_msg void OnAdddevoce();
  153. afx_msg void OnUpdateAdddevoce(CCmdUI *pCmdUI);
  154. afx_msg void OnZuTaiAdd();
  155. afx_msg void OnUpdateZuTaiAdd(CCmdUI *pCmdUI);
  156. afx_msg void OnDeleteport();
  157. afx_msg void OnUpdateDeleteport(CCmdUI *pCmdUI);
  158. afx_msg void OnAddPort();
  159. afx_msg void OnUpdateAddPort(CCmdUI *pCmdUI);
  160. afx_msg void OnAddScript();
  161. afx_msg void OnUpdateAddScript(CCmdUI *pCmdUI);
  162. afx_msg void OnAddview();
  163. afx_msg void OnUpdateAddview(CCmdUI *pCmdUI);
  164. afx_msg void OnAddview2();
  165. afx_msg void OnUpdateAddview2(CCmdUI *pCmdUI);
  166. afx_msg void OnEditSort();
  167. afx_msg void OnUpdateEditSort(CCmdUI *pCmdUI);
  168. afx_msg void OnDeletedevice();
  169. afx_msg void OnUpdateDeletedevice(CCmdUI *pCmdUI);
  170. afx_msg void OnDeleteview();
  171. afx_msg void OnUpdateDeleteview(CCmdUI *pCmdUI);
  172. afx_msg void OnModifyViewName();
  173. afx_msg void OnUpdateModifyViewName(CCmdUI *pCmdUI);
  174. afx_msg void OnDeletescript();
  175. afx_msg void OnUpdateDeletescript(CCmdUI *pCmdUI);
  176. afx_msg void OnSetscript();
  177. afx_msg void OnUpdateSetscript(CCmdUI *pCmdUI);
  178. afx_msg void OnEditscript();
  179. afx_msg void OnUpdateEditscript(CCmdUI *pCmdUI);
  180. afx_msg void OnDestroy();
  181. afx_msg void OnUsers();
  182. afx_msg void OnUpdateUsers(CCmdUI* pCmdUI);
  183. afx_msg void OnEditPwdTool();
  184. afx_msg void OnUpdateEditPwd(CCmdUI* pCmdUI);
  185. afx_msg void OnSysPara();
  186. afx_msg void OnUpdateSysPare(CCmdUI* pCmdUI);
  187. afx_msg void OnEventmanage();
  188. afx_msg void OnEvent();
  189. afx_msg void OnUpdateEvent(CCmdUI* pCmdUI);
  190. afx_msg void OnSummaryLog();
  191. afx_msg void OnUpdateSummaryLog(CCmdUI* pCmdUI);
  192. afx_msg void OnControldialog();
  193. afx_msg void OnTimer(UINT nIDEvent);
  194. afx_msg void OnUserManager();
  195. afx_msg void OnEditPwd();
  196. afx_msg void OnSingleAnalog();
  197. afx_msg void OnUpdateSingleAnalog(CCmdUI* pCmdUI);
  198. afx_msg void OnGroupManager();
  199. afx_msg void OnSystemLog();
  200. afx_msg void OnUpdateSystemLog(CCmdUI* pCmdUI);
  201. afx_msg void OnNoticeRec();
  202. afx_msg void OnUpdateNoticeRec(CCmdUI* pCmdUI);
  203. afx_msg void OnUpdatePrint(CCmdUI* pCmdUI);
  204. public:
  205. bool m_bEvent;
  206. bool m_bPrint;
  207. bool m_bUsers;
  208. bool m_bSysPare;
  209. bool m_bAnalog;
  210. bool m_bDeviceLog;
  211. bool m_bSystemLog;
  212. bool m_bNoticeRec;
  213. bool m_bEditPwd;
  214. void MyExpandTree(HTREEITEM hTreeItem);
  215. void GetCurPicVarToSArray( CString sPicPath );
  216. protected:
  217. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  218. PIC_VAR m_PIC_VAR[VIEW_MAX_NUM];
  219. bool GetPicIndexByPicPath( int &iIndex,CString sPicPath );
  220. bool GetPicPathByVarName( CString &sPicPath,CString sVarName );
  221. void InsertPicPathToStruct( int iIndex,CString sPicPath );
  222. bool VarIsExistInPic( int iIndex,CString sVarName,int &iInsertIndex );
  223. void GetVarFromGSAddToStruct( int iIndex,CString sGS );
  224. BOOL IsValidChar(char chr);
  225. void OnFullScreen() ;
  226. WINDOWPLACEMENT m_OldWndPlacement; //用来保存原窗口位置 
  227. BOOL m_FullScreen;//全屏显示标志
  228. CRect m_FullScreenRect; //表示全屏显示时的窗口位置
  229. CString m_sPath;
  230. int GetLevel( CString sContent );
  231. CString GetPreStr( CString sContent );
  232. CString GetLastStr( CString sContent );
  233. void InsertToCStringArray( CStringArray &SA,int iInsertIndex,CString sContent,CString sPath );
  234. void FileSearchCHN( CStringArray &SA,CStringArray &SATemp,int iInsertIndex, CString strPath, CString strFileName, int nLayer);
  235. void AddViewToTree( HTREEITEM hItem, CStringArray &SA );
  236. public:
  237. bool MakeFolderExist( CString DirectoryName );
  238. bool CreateDirectoryCHN( CString DirectoryName );
  239. bool ExistFolder( CString FilePath );
  240. void CopyDirectory( CString sScrPath,CString sDescPath );
  241. void GetPicPathByTree( HTREEITEM hItemSelect,CString &sPath );
  242. };