MainFrm.h 8.0 KB

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