SetClient.cpp 11 KB

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