SetClient.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. // SetClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "newclient.h"
  5. #include "SetClient.h"
  6. #include "SetClientRecordPlan.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSetClient dialog
  14. extern CLIENTPARAM ClientParam;
  15. extern void WriteClientConfig();
  16. BOOL DeleteDirectory(LPCTSTR DirName);
  17. int nUseCard;
  18. CSetClient::CSetClient(CWnd* pParent /*=NULL*/)
  19. : CDialog(CSetClient::IDD, pParent)
  20. {
  21. //{{AFX_DATA_INIT(CSetClient)
  22. m_bAutoRecord = FALSE;
  23. m_bCyclePlay = FALSE;
  24. m_bCycleRecord = FALSE;
  25. m_bUseCard = FALSE;
  26. m_iCycleTime = 0;
  27. m_iFileInterVal = 0;
  28. m_csLoadPath = _T("");
  29. m_csLogPath = _T("");
  30. m_csPICPath = _T("");
  31. m_ctCheckServerTime = 0;
  32. m_bCheckServerTime = FALSE;
  33. //}}AFX_DATA_INIT
  34. }
  35. void CSetClient::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CSetClient)
  39. DDX_Control(pDX, IDC_COMBOVIDEOFORMAT, m_VideoFormatCombo);
  40. DDX_Control(pDX, IDC_COMBO2, m_StopRecordDriverCtrl);
  41. DDX_Control(pDX, IDC_COMBO1, m_StartRecordDriverCtrl);
  42. DDX_Control(pDX, IDC_CHKUSECARD, m_UseCardCtrl);
  43. DDX_Control(pDX, IDC_CHKCYCLERECORD, m_CycleRecordCtrl);
  44. DDX_Control(pDX, IDC_CHKCYCLEPLAY, m_CyclePlayCtrl);
  45. DDX_Control(pDX, IDC_CHKAUTORECORD, m_AutoRecordCtrl);
  46. DDX_Check(pDX, IDC_CHKAUTORECORD, m_bAutoRecord);
  47. DDX_Check(pDX, IDC_CHKCYCLEPLAY, m_bCyclePlay);
  48. DDX_Check(pDX, IDC_CHKCYCLERECORD, m_bCycleRecord);
  49. DDX_Check(pDX, IDC_CHKUSECARD, m_bUseCard);
  50. DDX_Text(pDX, IDC_EDITCYCLETIME, m_iCycleTime);
  51. DDX_Text(pDX, IDC_EDITFILEINTERVAL, m_iFileInterVal);
  52. DDX_Text(pDX, IDC_EDITLOADPATH, m_csLoadPath);
  53. DDX_Text(pDX, IDC_EDITLOGPATH, m_csLogPath);
  54. DDX_Text(pDX, IDC_EDITPICPATH, m_csPICPath);
  55. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER, m_ctCheckServerTime);
  56. DDX_Check(pDX, IDC_CHECKSYSTIME, m_bCheckServerTime);
  57. //}}AFX_DATA_MAP
  58. }
  59. BEGIN_MESSAGE_MAP(CSetClient, CDialog)
  60. //{{AFX_MSG_MAP(CSetClient)
  61. ON_BN_CLICKED(IDC_BUTSELFILEPATH, OnButselfilepath)
  62. ON_BN_CLICKED(IDC_BUTSELLOGPATH, OnButsellogpath)
  63. ON_BN_CLICKED(IDC_BUTSELPICPATH, OnButselpicpath)
  64. ON_BN_CLICKED(IDC_BUTTONSETTIME, OnButtonsettime)
  65. ON_BN_CLICKED(IDC_CHKAUTORECORD, OnChkautorecord)
  66. ON_BN_CLICKED(IDC_CHKCYCLEPLAY, OnChkcycleplay)
  67. ON_BN_CLICKED(IDC_CHECKSYSTIME, OnChecksystime)
  68. ON_BN_CLICKED(IDCLOCALOK, OnClocalok)
  69. ON_BN_CLICKED(IDC_CHKUSECARD, OnChkusecard)
  70. //}}AFX_MSG_MAP
  71. END_MESSAGE_MAP()
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CSetClient message handlers
  74. BOOL CSetClient::OnInitDialog()
  75. {
  76. CDialog::OnInitDialog();
  77. // TODO: Add extra initialization here
  78. int i, j;
  79. CRect rc(0, 0, 0, 0);
  80. GetParent()->GetClientRect(&rc);
  81. ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc);
  82. MoveWindow(&rc);
  83. CString csHardDriver;
  84. CNewclientApp* pApp = (CNewclientApp*)AfxGetApp();
  85. for(i = 0; i < (int)(pApp->m_iDriverNum); i++)
  86. {
  87. csHardDriver.Format("%c%s", pApp->m_cHardDriver[i], ":\\");
  88. m_StartRecordDriverCtrl.AddString(csHardDriver);
  89. m_StopRecordDriverCtrl.AddString(csHardDriver);
  90. }
  91. m_bCyclePlay = ClientParam.m_bCyclePlay;
  92. if(m_bCyclePlay)
  93. {
  94. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
  95. }
  96. else
  97. {
  98. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
  99. }
  100. m_iCycleTime = ClientParam.m_iCycleTime;
  101. m_bUseCard = ClientParam.m_bUseCard;
  102. m_VideoFormatCombo.SetCurSel(ClientParam.m_bNTSC);
  103. UpdateData(FALSE);
  104. OnChkusecard();
  105. m_bAutoRecord = ClientParam.m_bAutoRecord;
  106. if(m_bAutoRecord)
  107. GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
  108. m_bCycleRecord = ClientParam.m_bCycleRecord;
  109. m_iFileInterVal = ClientParam.m_iRecordFileInterval;
  110. i = ClientParam.m_iStartRecordDriver;
  111. m_StartRecordDriverCtrl.SetCurSel(i);
  112. j = ClientParam.m_iEndRecordDriver;
  113. m_StopRecordDriverCtrl.SetCurSel(j);
  114. m_csLoadPath = ClientParam.m_csDownLoadPath;
  115. m_csPICPath = ClientParam.m_csPictureSavePath;
  116. m_csLogPath = ClientParam.m_csLogSavePath;
  117. m_bCheckServerTime = ClientParam.m_bCheckServerTime;
  118. CTime ctTime(2000, 1, 1, ClientParam.m_iCheckServerTime/10000, (ClientParam.m_iCheckServerTime%10000)/100, ClientParam.m_iCheckServerTime%100);
  119. m_ctCheckServerTime = ctTime;
  120. if(m_bCheckServerTime)
  121. {
  122. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
  123. }
  124. else
  125. {
  126. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
  127. }
  128. UpdateData(FALSE);
  129. return TRUE; // return TRUE unless you set the focus to a control
  130. // EXCEPTION: OCX Property Pages should return FALSE
  131. }
  132. void CSetClient::OnButselfilepath()
  133. {
  134. // TODO: Add your control notification handler code here
  135. CString Str = F_GetDirectoryPath();
  136. if(Str != "")
  137. {
  138. m_csLoadPath = Str;
  139. UpdateData(FALSE);
  140. }
  141. }
  142. void CSetClient::OnButsellogpath()
  143. {
  144. // TODO: Add your control notification handler code here
  145. CString Str = F_GetDirectoryPath();
  146. if(Str != "")
  147. {
  148. m_csLogPath = Str;
  149. UpdateData(FALSE);
  150. }
  151. }
  152. void CSetClient::OnButselpicpath()
  153. {
  154. // TODO: Add your control notification handler code here
  155. CString Str = F_GetDirectoryPath();
  156. if(Str != "")
  157. {
  158. m_csPICPath = Str;
  159. UpdateData(FALSE);
  160. }
  161. }
  162. void CSetClient::OnButtonsettime()
  163. {
  164. // TODO: Add your control notification handler code here
  165. CSetClientRecordPlan SetClientRecordPlanDlg;
  166. SetClientRecordPlanDlg.DoModal();
  167. }
  168. void CSetClient::OnChkautorecord()
  169. {
  170. // TODO: Add your control notification handler code here
  171. UpdateData(TRUE);
  172. if(m_AutoRecordCtrl.GetCheck() == 1)
  173. GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
  174. else
  175. GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(FALSE);
  176. }
  177. CString CSetClient::F_GetDirectoryPath()
  178. {
  179. LPITEMIDLIST pidlRoot=NULL;
  180. SHGetSpecialFolderLocation(m_hWnd,CSIDL_DRIVES,&pidlRoot);
  181. BROWSEINFO bi; //必须传入的参数,下面就是这个结构的参数的初始化
  182. CString strDisplayName; //用来得到,你选择的活页夹路径,相当于提供一个缓冲区
  183. bi.hwndOwner=GetSafeHwnd(); //得到父窗口Handle值
  184. bi.pidlRoot=pidlRoot; //这个变量就是我们在上面得到的.
  185. bi.pszDisplayName=strDisplayName.GetBuffer(MAX_PATH+1); //得到缓冲区指针
  186. bi.lpszTitle="文件夹"; //设置标题
  187. bi.ulFlags=BIF_RETURNONLYFSDIRS; //设置标志
  188. bi.lpfn=NULL;
  189. bi.lParam=0;
  190. bi.iImage=0; //上面这个是一些无关的参数的设置,最好设置起来,
  191. LPITEMIDLIST lpIDList= SHBrowseForFolder(&bi); //打开对话框
  192. strDisplayName.ReleaseBuffer(); //和上面的GetBuffer()相对应
  193. char pPath[MAX_PATH];
  194. CString Str;
  195. if(lpIDList)
  196. {
  197. SHGetPathFromIDList (lpIDList, pPath);
  198. Str=pPath;
  199. }
  200. return Str;
  201. }
  202. void CSetClient::OnChkcycleplay()
  203. {
  204. // TODO: Add your control notification handler code here
  205. UpdateData(TRUE);
  206. if(m_CyclePlayCtrl.GetCheck() == 1)
  207. {
  208. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
  209. }
  210. else
  211. {
  212. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
  213. }
  214. UpdateData(FALSE);
  215. }
  216. void CSetClient::OnChecksystime()
  217. {
  218. // TODO: Add your control notification handler code here
  219. UpdateData(TRUE);
  220. if(m_bCheckServerTime)
  221. {
  222. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
  223. }
  224. else
  225. {
  226. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
  227. }
  228. UpdateData(FALSE);
  229. }
  230. void CSetClient::OnClocalok()
  231. {
  232. // TODO: Add your control notification handler code here
  233. int i, j;
  234. UpdateData(TRUE);
  235. if( (m_iFileInterVal < 1) || (m_iFileInterVal > 60) )
  236. {
  237. AfxMessageBox("非法的文件打包时间!");
  238. return;
  239. }
  240. if( (m_csLoadPath == "") || (m_csPICPath == "") || (m_csLogPath == "") )
  241. {
  242. AfxMessageBox("请选择文件保存路径!");
  243. return;
  244. }
  245. i = m_StartRecordDriverCtrl.GetCurSel();
  246. j = m_StopRecordDriverCtrl.GetCurSel();
  247. if(i > j)
  248. {
  249. AfxMessageBox("起始驱动器和终止驱动器不匹配!");
  250. return;
  251. }
  252. if(m_iCycleTime < 5)
  253. m_iCycleTime = 5;
  254. ClientParam.m_bCyclePlay = m_bCyclePlay;
  255. ClientParam.m_iCycleTime = m_iCycleTime;
  256. if(ClientParam.m_bUseCard != m_bUseCard)
  257. {
  258. if(!ClientParam.m_bUseCard)
  259. {
  260. nUseCard = 1;
  261. }
  262. else
  263. {
  264. nUseCard = 2;
  265. }
  266. }
  267. ClientParam.m_bUseCard = m_bUseCard;
  268. ClientParam.m_bNTSC = m_VideoFormatCombo.GetCurSel();
  269. ClientParam.m_bAutoRecord = m_bAutoRecord;
  270. ClientParam.m_bCycleRecord = m_bCycleRecord;
  271. ClientParam.m_iRecordFileInterval = m_iFileInterVal;
  272. ClientParam.m_iStartRecordDriver = i;
  273. ClientParam.m_iEndRecordDriver = j;
  274. ClientParam.m_csDownLoadPath = m_csLoadPath;
  275. ClientParam.m_csPictureSavePath = m_csPICPath;
  276. ClientParam.m_csLogSavePath = m_csLogPath;
  277. ClientParam.m_bCheckServerTime = m_bCheckServerTime;
  278. ClientParam.m_iCheckServerTime = m_ctCheckServerTime.GetHour()*10000 + m_ctCheckServerTime.GetMinute()*100 + m_ctCheckServerTime.GetSecond();
  279. CreateDirectory(m_csLoadPath, NULL);
  280. CreateDirectory(m_csPICPath, NULL);
  281. CreateDirectory(m_csLogPath, NULL);
  282. WriteClientConfig();
  283. }
  284. void CSetClient::OnCancel()
  285. {
  286. // TODO: Add extra cleanup here
  287. //CDialog::OnCancel();
  288. }
  289. void CSetClient::OnChkusecard()
  290. {
  291. // TODO: Add your control notification handler code here
  292. UpdateData(TRUE);
  293. if (m_bUseCard)
  294. {
  295. GetDlgItem(IDC_COMBOVIDEOFORMAT)->EnableWindow(TRUE);
  296. }
  297. else
  298. {
  299. GetDlgItem(IDC_COMBOVIDEOFORMAT)->EnableWindow(FALSE);
  300. }
  301. UpdateData(FALSE);
  302. }