RemoteTimePlay.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. // RemoteTimePlay.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "RemoteTimePlay.h"
  6. #include "mdlProject.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRemoteTimePlay dialog
  14. CRemoteTimePlay::CRemoteTimePlay(CWnd* pParent /*=NULL*/)
  15. : CDialog(CRemoteTimePlay::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CRemoteTimePlay)
  18. m_ctDateStart = 0;
  19. m_ctDateStop = 0;
  20. m_ctTimeStart = 0;
  21. m_ctTimeStop = 0;
  22. //}}AFX_DATA_INIT
  23. m_hPlayEnableIcon = AfxGetApp()->LoadIcon(IDI_PLAY_ENABLE);
  24. m_hPlayDisableIcon = AfxGetApp()->LoadIcon(IDI_PLAY_DISABLE);
  25. m_hPauseEnableIcon = AfxGetApp()->LoadIcon(IDI_PAUSE_ENABLE);
  26. m_hPauseDisableIcon = AfxGetApp()->LoadIcon(IDI_PAUSE_DISABLE);
  27. m_hStopEnableIcon = AfxGetApp()->LoadIcon(IDI_STOP_ENABLE);
  28. m_hStopDisableIcon = AfxGetApp()->LoadIcon(IDI_STOP_DISABLE);
  29. m_hSoundStartIcon= AfxGetApp()->LoadIcon(IDI_SOUND_ENABLE);
  30. m_hSoundStopIcon= AfxGetApp()->LoadIcon(IDI_SOUND_DISABLE);
  31. m_hGotoTailDisableIcon = AfxGetApp()->LoadIcon(IDI_GOTOEND_DISABLE);
  32. m_hFastDisableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_DISABLE);
  33. m_hSlowDisableIcon= AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_DISABLE);
  34. m_hGotoTailEnableIcon = AfxGetApp()->LoadIcon(IDI_GOTOEND_ENABLE);
  35. m_hFastEnableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_ENABLE);
  36. m_hSlowEnableIcon = AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_ENABLE);
  37. m_hStepBackEnableIcon = AfxGetApp()->LoadIcon(IDI_STEPBACK_ENABLE);
  38. m_hStepBackDisableIcon = AfxGetApp()->LoadIcon(IDI_STEPBACK_DISABLE);
  39. m_hCaptureIcon = AfxGetApp()->LoadIcon(IDI_PIC);
  40. }
  41. void CRemoteTimePlay::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CRemoteTimePlay)
  45. DDX_Control(pDX, IDC_WND, m_PlayWnd);
  46. DDX_Control(pDX, IDC_VOLUME_SLIDER, m_ctlVolume);
  47. DDX_Control(pDX, IDC_COMBOSERVER, m_ServerName);
  48. DDX_Control(pDX, IDC_COMBOPORT, m_ChannelName);
  49. DDX_DateTimeCtrl(pDX, IDC_DATESTART, m_ctDateStart);
  50. DDX_DateTimeCtrl(pDX, IDC_DATESTOP, m_ctDateStop);
  51. DDX_DateTimeCtrl(pDX, IDC_TIMESTART, m_ctTimeStart);
  52. DDX_DateTimeCtrl(pDX, IDC_TIMESTOP, m_ctTimeStop);
  53. //}}AFX_DATA_MAP
  54. }
  55. BEGIN_MESSAGE_MAP(CRemoteTimePlay, CDialog)
  56. //{{AFX_MSG_MAP(CRemoteTimePlay)
  57. ON_BN_CLICKED(IDC_STOP, OnStop)
  58. ON_BN_CLICKED(IDC_SLOW, OnSlow)
  59. ON_BN_CLICKED(IDC_FAST, OnFast)
  60. ON_BN_CLICKED(IDC_CAPPIC, OnCappic)
  61. ON_BN_CLICKED(IDC_STEP, OnStep)
  62. ON_BN_CLICKED(IDC_SOUND, OnSound)
  63. ON_WM_HSCROLL()
  64. ON_WM_LBUTTONDBLCLK()
  65. ON_BN_CLICKED(IDC_PLAY_TIME, OnPlayTime)
  66. ON_CBN_SELCHANGE(IDC_COMBOSERVER, OnSelchangeComboserver)
  67. ON_WM_TIMER()
  68. ON_BN_CLICKED(IDC_BUTTONDOWNLOAD, OnButtondownload)
  69. ON_BN_CLICKED(IDC_BUTTONLOADSAVE, OnButtonloadsave)
  70. ON_BN_CLICKED(IDC_GOTOSTART, OnGotostart)
  71. //}}AFX_MSG_MAP
  72. END_MESSAGE_MAP()
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CRemoteTimePlay message handlers
  75. void CRemoteTimePlay::SetParentWnd(HWND *hhWnd, int iParentNum)
  76. {
  77. VERIFY(iParentNum==2);
  78. m_hPareDlgWnd=hhWnd[0];
  79. m_hPareTabWnd=hhWnd[1];
  80. }
  81. BOOL CRemoteTimePlay::OnInitDialog()
  82. {
  83. CDialog::OnInitDialog();
  84. // TODO: Add extra initialization here
  85. CRect rc(0, 0, 0, 0);
  86. GetParent()->GetClientRect(&rc);
  87. ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc);
  88. MoveWindow(&rc);
  89. F_InitUI();
  90. m_bPause=FALSE;
  91. m_bDown = FALSE;
  92. m_bTimeSave = FALSE;
  93. m_ServerName.AddString("请选择DVR");
  94. for(int i = 0; i < MAXIPNUMBER; i++)
  95. {
  96. if(g_pNewclientDlg->m_Serverinfo[i].m_csServerName != "")
  97. m_ServerName.AddString(g_pNewclientDlg->m_Serverinfo[i].m_csServerName);
  98. }
  99. m_ServerName.SetCurSel(0);
  100. m_ChannelName.SetCurSel(1);
  101. CTime time1 = CTime::GetCurrentTime();
  102. CTime time(time1.GetYear(),time1.GetMonth(),time1.GetDay(),0,0,0);
  103. CTime time0(time1.GetYear(),time1.GetMonth(),time1.GetDay(),23,59,59);
  104. m_ctDateStart = time;
  105. m_ctTimeStart = time;
  106. m_ctDateStop = time1;
  107. m_ctTimeStop = time0;
  108. m_ctlVolume.SetRange(1, 100, TRUE);
  109. m_ctlVolume.SetPos(50);
  110. lHandle = -1;
  111. m_lLoadHandle = -1;
  112. m_bSound = FALSE;
  113. m_bFullScreen = FALSE;
  114. m_hPareDlgWnd = NULL;
  115. m_hPareTabWnd = NULL;
  116. m_lStartChan = 0;
  117. GetDlgItem(IDC_WND)->GetWindowRect(m_rcWnd);
  118. ScreenToClient(m_rcWnd);
  119. m_rcScreen=CRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
  120. UpdateData(FALSE);
  121. return TRUE; // return TRUE unless you set the focus to a control
  122. // EXCEPTION: OCX Property Pages should return FALSE
  123. }
  124. void CRemoteTimePlay::OnPlayTime()
  125. {
  126. // TODO: Add your control notification handler code here
  127. NET_DVR_TIME StartTime,StopTime;
  128. UpdateData(TRUE);
  129. if(lHandle == -1)
  130. {
  131. if(m_ServerName.GetCurSel() == 0)
  132. {
  133. MessageBox("获取设备状态失败!", "温馨提示", MB_ICONINFORMATION);
  134. return;
  135. }
  136. //ServerID = g_pNewclientDlg->m_Serverinfo[i].m_lServerID;
  137. iChannel = m_ChannelName.GetCurSel()+m_lStartChan;
  138. StartTime.dwYear = m_ctDateStart.GetYear();
  139. StartTime.dwMonth = m_ctDateStart.GetMonth();
  140. StartTime.dwDay = m_ctDateStart.GetDay();
  141. StartTime.dwHour = m_ctTimeStart.GetHour();
  142. StartTime.dwMinute = m_ctTimeStart.GetMinute();
  143. StartTime.dwSecond = m_ctTimeStart.GetSecond();
  144. StopTime.dwYear = m_ctDateStop.GetYear();
  145. StopTime.dwMonth = m_ctDateStop.GetMonth();
  146. StopTime.dwDay = m_ctDateStop.GetDay();
  147. StopTime.dwHour = m_ctTimeStop.GetHour();
  148. StopTime.dwMinute = m_ctTimeStop.GetMinute();
  149. StopTime.dwSecond = m_ctTimeStop.GetSecond();
  150. lHandle = NET_DVR_PlayBackByTime(ServerID, iChannel, &StartTime, &StopTime, m_PlayWnd.GetSafeHwnd());
  151. if(lHandle == -1)
  152. {
  153. MessageBox("获取设备状态失败!", "温馨提示", MB_ICONINFORMATION);
  154. return;
  155. }
  156. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTART, 0, NULL);
  157. if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTARTAUDIO, 0, NULL))
  158. {
  159. m_bSound=TRUE;
  160. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYAUDIOVOLUME, (0xffff)/2, NULL);
  161. m_ctlVolume.SetPos(50);
  162. ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStartIcon);
  163. }
  164. else
  165. {
  166. m_bSound=FALSE;
  167. ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStopIcon);
  168. }
  169. F_SetPlayState();
  170. SetTimer(PLAYBYTIME_TIMER,2000,NULL);
  171. UpdateData(FALSE);
  172. }
  173. else
  174. {
  175. if(m_bPause)
  176. {
  177. if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYRESTART, 0, NULL))
  178. {
  179. m_bPause=FALSE;
  180. F_SetPlayState();
  181. }
  182. }
  183. else
  184. {
  185. if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYPAUSE, 0, NULL))
  186. {
  187. TRACE("handle:%d \n",lHandle);
  188. m_bPause=TRUE;
  189. CButton *pButton;
  190. pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
  191. pButton->SetIcon(m_hPlayEnableIcon);
  192. pButton->EnableWindow(TRUE);
  193. }
  194. }
  195. }
  196. }
  197. void CRemoteTimePlay::OnStop()
  198. {
  199. // TODO: Add your control notification handler code here
  200. F_StopPlay();
  201. }
  202. void CRemoteTimePlay::F_StopPlay()
  203. {
  204. CButton *pButton;
  205. if(lHandle >= 0)
  206. {
  207. if(m_bFullScreen)
  208. {
  209. m_bFullScreen = FALSE;
  210. F_ShowNormal();
  211. }
  212. if(m_bTimeSave)
  213. {
  214. NET_DVR_StopPlayBackSave(lHandle);
  215. m_bTimeSave = FALSE;
  216. GetDlgItem(IDC_BUTTONLOADSAVE)->SetWindowText("保存");
  217. }
  218. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTOPAUDIO, 0, NULL);
  219. NET_DVR_StopPlayBack(lHandle);
  220. lHandle = -1;
  221. Invalidate(TRUE);
  222. UpdateData(FALSE);
  223. KillTimer(PLAYBYTIME_TIMER);
  224. }
  225. m_bSound=FALSE;
  226. m_bPause = FALSE;
  227. m_ctlVolume.EnableWindow(FALSE);
  228. pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
  229. pButton->SetIcon(m_hPlayEnableIcon);
  230. pButton->EnableWindow(TRUE);
  231. pButton = (CButton *)GetDlgItem(IDC_STOP);
  232. pButton->SetIcon(m_hStopDisableIcon);
  233. pButton->EnableWindow(FALSE);
  234. pButton = (CButton *)GetDlgItem(IDC_FAST);
  235. pButton->SetIcon(m_hFastDisableIcon);
  236. pButton->EnableWindow(FALSE);
  237. pButton = (CButton *)GetDlgItem(IDC_SLOW);
  238. pButton->SetIcon(m_hSlowDisableIcon);
  239. pButton->EnableWindow(FALSE);
  240. pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
  241. pButton->SetIcon(m_hCaptureIcon);
  242. pButton->EnableWindow(FALSE);
  243. pButton = (CButton *)GetDlgItem(IDC_SOUND);
  244. pButton->SetIcon(m_hSoundStopIcon);
  245. pButton->EnableWindow(FALSE);
  246. }
  247. void CRemoteTimePlay::F_ShowNormal()
  248. {
  249. GetDlgItem(IDC_WND)->SetWindowPos(NULL,m_rcWnd.left,m_rcWnd.top,m_rcWnd.Width(),m_rcWnd.Height(),SWP_SHOWWINDOW);
  250. ::SetWindowPos(m_hWnd,NULL,m_rcParent.left,m_rcParent.top,m_rcParent.Width(),m_rcParent.Height(),SWP_SHOWWINDOW);
  251. ::SetWindowPos(m_hPareTabWnd,NULL,m_rcPareTab.left,m_rcPareTab.top,m_rcPareTab.Width(),m_rcPareTab.Height(),SWP_SHOWWINDOW);
  252. ::SetWindowPos(m_hPareDlgWnd,NULL,m_rcPareDlg.left,m_rcPareDlg.top,m_rcPareDlg.Width(),m_rcPareDlg.Height(),SWP_SHOWWINDOW);
  253. F_EnableFlashWnd(TRUE);
  254. Invalidate(FALSE);
  255. UpdateWindow();
  256. }
  257. void CRemoteTimePlay::OnSlow()
  258. {
  259. // TODO: Add your control notification handler code here
  260. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSLOW, 0, NULL);
  261. }
  262. void CRemoteTimePlay::OnFast()
  263. {
  264. // TODO: Add your control notification handler code here
  265. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYFAST, 0, NULL);
  266. }
  267. void CRemoteTimePlay::OnCappic()
  268. {
  269. // TODO: Add your control notification handler code here
  270. char cFilename[256];
  271. sprintf(cFilename, "%s\\%d_%d.bmp",g_pNewclientDlg->m_ClientParam.m_csPictureSavePath,iChannel, GetTickCount());
  272. if(NET_DVR_PlayBackCaptureFile(lHandle,cFilename))
  273. {
  274. CString sTemp;
  275. sTemp.Format("抓图成功 %s!",cFilename);
  276. MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION);
  277. return;
  278. }
  279. else
  280. {
  281. MessageBox("抓图失败!", "温馨提示", MB_ICONINFORMATION);
  282. }
  283. }
  284. void CRemoteTimePlay::OnStep()
  285. {
  286. // TODO: Add your control notification handler code here
  287. }
  288. void CRemoteTimePlay::OnSound()
  289. {
  290. // TODO: Add your control notification handler code here
  291. CButton *pButton;
  292. if(lHandle >= 0)
  293. {
  294. if(m_bSound)
  295. {
  296. if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTOPAUDIO, 0, NULL))
  297. {
  298. m_bSound=FALSE;
  299. pButton = (CButton *)GetDlgItem(IDC_SOUND);
  300. pButton->SetIcon(m_hSoundStopIcon);
  301. }
  302. }
  303. else
  304. {
  305. if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTARTAUDIO, 0, NULL))
  306. {
  307. pButton = (CButton *)GetDlgItem(IDC_SOUND);
  308. pButton->SetIcon(m_hSoundStartIcon);
  309. m_bSound=TRUE;
  310. }
  311. }
  312. }
  313. }
  314. void CRemoteTimePlay::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  315. {
  316. // TODO: Add your message handler code here and/or call default
  317. if (GetDlgItem(IDC_VOLUME_SLIDER) == pScrollBar)
  318. {
  319. char volume;
  320. WORD temp, volumevalue;
  321. temp = (0xffff)/100;
  322. volume = m_ctlVolume.GetPos();
  323. volumevalue = volume*temp;
  324. if(lHandle >= 0)
  325. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYAUDIOVOLUME, volumevalue, NULL);
  326. }
  327. CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
  328. }
  329. void CRemoteTimePlay::OnLButtonDblClk(UINT nFlags, CPoint point)
  330. {
  331. // TODO: Add your message handler code here and/or call default
  332. if( (IsInWnd(point)) && (lHandle >= 0) )
  333. {
  334. m_bFullScreen=!m_bFullScreen;
  335. if(m_bFullScreen)
  336. F_ShowFullScreen();
  337. else
  338. F_ShowNormal();
  339. }
  340. CDialog::OnLButtonDblClk(nFlags, point);
  341. }
  342. BOOL CRemoteTimePlay::IsInWnd(CPoint point)
  343. {
  344. CRect rc;
  345. GetDlgItem(IDC_WND)->GetWindowRect(&rc);
  346. ScreenToClient(&rc);
  347. if(PtInRect(&rc,point))
  348. return TRUE;
  349. else
  350. return FALSE;
  351. }
  352. void CRemoteTimePlay::F_ShowFullScreen()
  353. {
  354. F_EnableFlashWnd(FALSE);
  355. CRect rc,rcClient;
  356. ::GetWindowRect(m_hPareDlgWnd,m_rcPareDlg);
  357. ::GetWindowRect(m_hPareTabWnd,m_rcPareTab);
  358. ::ScreenToClient(m_hPareDlgWnd,(POINT*)(&m_rcPareTab));
  359. ::ScreenToClient(m_hPareDlgWnd,(POINT*)(&m_rcPareTab)+1);
  360. ::GetWindowRect(m_hWnd,m_rcParent);
  361. ::ScreenToClient(m_hPareTabWnd,(POINT*)(&m_rcParent));
  362. ::ScreenToClient(m_hPareTabWnd,(POINT*)(&m_rcParent)+1);
  363. ::SetWindowPos(m_hPareDlgWnd,NULL,m_rcScreen.left-SCREEN_EDGE,m_rcScreen.top-SCREEN_EDGE,m_rcScreen.Width()+2*SCREEN_EDGE,m_rcScreen.Height()+2*SCREEN_EDGE,SWP_SHOWWINDOW);
  364. ::GetClientRect(m_hPareDlgWnd,rc);
  365. ::SetWindowPos(m_hPareTabWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW);
  366. ::GetClientRect(m_hPareTabWnd,rc);
  367. ::SetWindowPos(m_hWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW);
  368. GetDlgItem(IDC_WND)->GetClientRect(rcClient);
  369. GetDlgItem(IDC_WND)->GetWindowRect(rc);
  370. int iEdge=(rc.Width()-rcClient.Width())/2;
  371. rc=m_rcScreen;
  372. rc.left-=iEdge;
  373. rc.right+=iEdge;
  374. rc.top-=iEdge;
  375. rc.bottom+=iEdge;
  376. this->ScreenToClient(rc);
  377. ::SetWindowPos(GetDlgItem(IDC_WND)->m_hWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW);
  378. Invalidate(FALSE);
  379. UpdateWindow();
  380. }
  381. void CRemoteTimePlay::F_EnableFlashWnd(BOOL bEnable)
  382. {
  383. if(bEnable)
  384. {
  385. //THE same to multiplay
  386. GetDlgItem(IDC_COMBOSERVER)->ModifyStyle(0,WS_VISIBLE,0);
  387. GetDlgItem(IDC_COMBOPORT)->ModifyStyle(0,WS_VISIBLE,0);
  388. GetDlgItem(IDC_DATESTART)->ModifyStyle(0,WS_VISIBLE,0);
  389. GetDlgItem(IDC_DATESTOP)->ModifyStyle(0,WS_VISIBLE,0);
  390. GetDlgItem(IDC_TIMESTOP)->ModifyStyle(0,WS_VISIBLE,0);
  391. GetDlgItem(IDC_TIMESTART)->ModifyStyle(0,WS_VISIBLE,0);
  392. GetDlgItem(IDC_PLAY_TIME)->ModifyStyle(0,WS_VISIBLE,0);
  393. GetDlgItem(IDC_STOP)->ModifyStyle(0,WS_VISIBLE,0);
  394. GetDlgItem(IDC_SLOW)->ModifyStyle(0,WS_VISIBLE,0);
  395. GetDlgItem(IDC_FAST)->ModifyStyle(0,WS_VISIBLE,0);
  396. GetDlgItem(IDC_CAPPIC)->ModifyStyle(0,WS_VISIBLE,0);
  397. GetDlgItem(IDC_SOUND)->ModifyStyle(0,WS_VISIBLE,0);
  398. GetDlgItem(IDC_VOLUME_SLIDER)->ModifyStyle(0,WS_VISIBLE,0);
  399. }
  400. else
  401. {
  402. //THE same to multiplay
  403. GetDlgItem(IDC_COMBOSERVER)->ModifyStyle(WS_VISIBLE,0,0);
  404. GetDlgItem(IDC_COMBOPORT)->ModifyStyle(WS_VISIBLE,0,0);
  405. GetDlgItem(IDC_DATESTART)->ModifyStyle(WS_VISIBLE,0,0);
  406. GetDlgItem(IDC_DATESTOP)->ModifyStyle(WS_VISIBLE,0,0);
  407. GetDlgItem(IDC_TIMESTOP)->ModifyStyle(WS_VISIBLE,0,0);
  408. GetDlgItem(IDC_TIMESTART)->ModifyStyle(WS_VISIBLE,0,0);
  409. GetDlgItem(IDC_PLAY_TIME)->ModifyStyle(WS_VISIBLE,0,0);
  410. GetDlgItem(IDC_STOP)->ModifyStyle(WS_VISIBLE,0,0);
  411. GetDlgItem(IDC_SLOW)->ModifyStyle(WS_VISIBLE,0,0);
  412. GetDlgItem(IDC_FAST)->ModifyStyle(WS_VISIBLE,0,0);
  413. GetDlgItem(IDC_CAPPIC)->ModifyStyle(WS_VISIBLE,0,0);
  414. GetDlgItem(IDC_SOUND)->ModifyStyle(WS_VISIBLE,0,0);
  415. GetDlgItem(IDC_VOLUME_SLIDER)->ModifyStyle(WS_VISIBLE,0,0);
  416. }
  417. }
  418. void CRemoteTimePlay::F_InitUI()
  419. {
  420. CButton *pButton;
  421. pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
  422. pButton->SetIcon(m_hPlayEnableIcon);
  423. pButton->EnableWindow(TRUE);
  424. pButton = (CButton *)GetDlgItem(IDC_STOP);
  425. pButton->SetIcon(m_hStopDisableIcon);
  426. pButton->EnableWindow(FALSE);
  427. pButton = (CButton *)GetDlgItem(IDC_FAST);
  428. pButton->SetIcon(m_hFastDisableIcon);
  429. pButton->EnableWindow(FALSE);
  430. pButton = (CButton *)GetDlgItem(IDC_SLOW);
  431. pButton->SetIcon(m_hSlowDisableIcon);
  432. pButton->EnableWindow(FALSE);
  433. pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
  434. pButton->SetIcon(m_hCaptureIcon);
  435. pButton->EnableWindow(FALSE);
  436. pButton = (CButton *)GetDlgItem(IDC_SOUND);
  437. pButton->SetIcon(m_hSoundStopIcon);
  438. pButton->EnableWindow(FALSE);
  439. }
  440. void CRemoteTimePlay::F_SetPlayState()
  441. {
  442. m_ctlVolume.EnableWindow(TRUE);
  443. CButton *pButton;
  444. pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
  445. pButton->SetIcon(m_hPauseEnableIcon);
  446. pButton->EnableWindow(TRUE);
  447. pButton = (CButton *)GetDlgItem(IDC_STOP);
  448. pButton->SetIcon(m_hStopEnableIcon);
  449. pButton->EnableWindow(TRUE);
  450. pButton = (CButton *)GetDlgItem(IDC_FAST);
  451. pButton->SetIcon(m_hFastEnableIcon);
  452. pButton->EnableWindow(TRUE);
  453. pButton = (CButton *)GetDlgItem(IDC_SLOW);
  454. pButton->SetIcon(m_hSlowEnableIcon);
  455. pButton->EnableWindow(TRUE);
  456. pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
  457. pButton->SetIcon(m_hCaptureIcon);
  458. pButton->EnableWindow(TRUE);
  459. pButton = (CButton *)GetDlgItem(IDC_SOUND);
  460. if(m_bSound)
  461. pButton->SetIcon(m_hSoundStartIcon);
  462. else
  463. pButton->SetIcon(m_hSoundStopIcon);
  464. pButton->EnableWindow(TRUE);
  465. }
  466. void CRemoteTimePlay::OnCancel()
  467. {
  468. // TODO: Add extra cleanup here
  469. // CDialog::OnCancel();
  470. }
  471. void CRemoteTimePlay::OnSelchangeComboserver()
  472. {
  473. // TODO: Add your control notification handler code here
  474. int iSelServer = m_ServerName.GetCurSel() - 1;
  475. if(iSelServer < 0)
  476. return;
  477. ServerID = g_pNewclientDlg->m_Serverinfo[iSelServer].m_lServerID;
  478. m_lStartChan = g_pNewclientDlg->m_Serverinfo[iSelServer].m_lStartChannel;
  479. int m_iChanNum = g_pNewclientDlg->m_Serverinfo[iSelServer].m_iServerChannelNumber;
  480. m_ChannelName.ResetContent();
  481. CString sTemp;
  482. for(int i=0; i<m_iChanNum; i++)
  483. {
  484. sTemp.Format("%d", i+m_lStartChan);
  485. m_ChannelName.AddString(sTemp);
  486. }
  487. iChannel = 0;
  488. m_ChannelName.SetCurSel(iChannel);
  489. }
  490. void CRemoteTimePlay::OnTimer(UINT nIDEvent)
  491. {
  492. // TODO: Add your message handler code here and/or call default
  493. DWORD nPos;
  494. if(nIDEvent == PLAYBYTIME_TIMER)
  495. {
  496. if(lHandle >= 0)
  497. {
  498. NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYGETPOS, 0, &nPos);
  499. if(nPos > 100) //由于网络原因或DVR忙,回放或下载异常终止
  500. {
  501. F_StopPlay();
  502. MessageBox("由于网络原因或DVR忙,回放异常终止!", "温馨提示", MB_ICONINFORMATION);
  503. }
  504. if(nPos == 100)
  505. {
  506. F_StopPlay();
  507. MessageBox("按时间回放结束!", "温馨提示", MB_ICONINFORMATION);
  508. }
  509. }
  510. }
  511. else if(nIDEvent == DOWNBYTIME_TIMER)
  512. {
  513. if(m_bDown)
  514. {
  515. NET_DVR_PlayBackControl(m_lLoadHandle, NET_DVR_PLAYGETPOS, 0, &nPos);
  516. if(nPos > 100) //由于网络原因或DVR忙,回放或下载异常终止
  517. {
  518. m_bDown=FALSE;
  519. NET_DVR_StopGetFile(m_lLoadHandle);
  520. GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("下载");
  521. MessageBox("由于网络原因或DVR忙,下载异常终止!", "温馨提示", MB_ICONINFORMATION);
  522. }
  523. if(nPos == 100)
  524. {
  525. m_bDown=FALSE;
  526. NET_DVR_StopGetFile(m_lLoadHandle);
  527. GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("下载");
  528. MessageBox("按时间下载结束!", "温馨提示", MB_ICONINFORMATION);
  529. }
  530. }
  531. }
  532. CDialog::OnTimer(nIDEvent);
  533. }
  534. void CRemoteTimePlay::OnButtondownload()
  535. {
  536. // TODO: Add your control notification handler code here
  537. CString csFileName;
  538. CString csStartTime, csStopTime;
  539. CString csTemp,csDir;
  540. char nFileName[256];
  541. UpdateData(TRUE);
  542. if(!m_bDown)
  543. {
  544. if(m_ServerName.GetCurSel() == 0)
  545. {
  546. MessageBox("请选择DVR!", "温馨提示", MB_ICONINFORMATION);
  547. return;
  548. }
  549. int iSelServer = m_ServerName.GetCurSel() - 1;
  550. iChannel = m_ChannelName.GetCurSel()+m_lStartChan;
  551. csStartTime.Format("%04d%02d%02d%02d%02d%02d",m_ctDateStart.GetYear(),m_ctDateStart.GetMonth(), m_ctDateStart.GetDay(), m_ctTimeStart.GetHour(), m_ctTimeStart.GetMinute(), m_ctTimeStart.GetSecond());
  552. csStopTime.Format("%04d%02d%02d%02d%02d%02d",m_ctDateStop.GetYear(),m_ctDateStop.GetMonth(), m_ctDateStop.GetDay(), m_ctTimeStop.GetHour(), m_ctTimeStop.GetMinute(), m_ctTimeStop.GetSecond());
  553. csDir.Format("%s\\",g_pNewclientDlg->m_ClientParam.m_csDownLoadPath);
  554. sprintf(nFileName,"%s%s_%02d_D%s_%sTime.mp4",csDir,g_pNewclientDlg->m_Serverinfo[iSelServer].m_csServerIP, iChannel,csStartTime,csStopTime);
  555. TRACE("Download file name: %s \n", nFileName);
  556. NET_DVR_TIME StartTime,StopTime;
  557. UpdateData(TRUE);
  558. StartTime.dwYear = m_ctDateStart.GetYear();
  559. StartTime.dwMonth = m_ctDateStart.GetMonth();
  560. StartTime.dwDay = m_ctDateStart.GetDay();
  561. StartTime.dwHour = m_ctTimeStart.GetHour();
  562. StartTime.dwMinute = m_ctTimeStart.GetMinute();
  563. StartTime.dwSecond = m_ctTimeStart.GetSecond();
  564. StopTime.dwYear = m_ctDateStop.GetYear();
  565. StopTime.dwMonth = m_ctDateStop.GetMonth();
  566. StopTime.dwDay = m_ctDateStop.GetDay();
  567. StopTime.dwHour = m_ctTimeStop.GetHour();
  568. StopTime.dwMinute = m_ctTimeStop.GetMinute();
  569. StopTime.dwSecond = m_ctTimeStop.GetSecond();
  570. m_lLoadHandle = NET_DVR_GetFileByTime(ServerID,iChannel, &StartTime, &StopTime, nFileName);
  571. if(m_lLoadHandle >= 0)
  572. {
  573. NET_DVR_PlayBackControl(m_lLoadHandle, NET_DVR_PLAYSTART, 0, NULL);
  574. GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("停止下载");
  575. m_bDown=TRUE;
  576. SetTimer(DOWNBYTIME_TIMER,1000,NULL);
  577. }
  578. else
  579. {
  580. MessageBox("按时间下载失败!", "温馨提示", MB_ICONINFORMATION);
  581. CString sTemp;
  582. sTemp.Format("ERROR: NET_DVR_GetFileByTime = %d",NET_DVR_GetLastError());
  583. TRACE(sTemp);
  584. return;
  585. }
  586. }
  587. else
  588. {
  589. NET_DVR_StopGetFile(m_lLoadHandle);
  590. m_bDown=FALSE;
  591. GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("下载");
  592. KillTimer(DOWNBYTIME_TIMER);
  593. Invalidate(TRUE);
  594. }
  595. UpdateData(FALSE);
  596. }
  597. void CRemoteTimePlay::OnButtonloadsave()
  598. {
  599. // TODO: Add your control notification handler code here
  600. if(!m_bTimeSave)
  601. {
  602. //zxy 2005-01-04
  603. static char szFilter[]="All File(*.*)|*.*||";
  604. char m_sFile[256] = "c:\\SavefileByTime.mp4";
  605. CString csFile;
  606. CFileDialog dlg(FALSE,"*.mp4","SavefileByTime.mp4",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
  607. szFilter);
  608. if(dlg.DoModal()==IDOK)
  609. {
  610. csFile = dlg.GetPathName();
  611. UpdateData(FALSE);
  612. sprintf(m_sFile, "%s", csFile);
  613. if(NET_DVR_PlayBackSaveData(lHandle, m_sFile))
  614. {
  615. m_bTimeSave = TRUE;
  616. GetDlgItem(IDC_BUTTONLOADSAVE)->SetWindowText("停止保存");
  617. }
  618. }
  619. }
  620. else
  621. {
  622. NET_DVR_StopPlayBackSave(lHandle);
  623. m_bTimeSave = FALSE;
  624. GetDlgItem(IDC_BUTTONLOADSAVE)->SetWindowText("保存");
  625. }
  626. }
  627. //zxy 2005-01-04
  628. /*
  629. void CRemoteTimePlay::OnButplay()
  630. {
  631. // TODO: Add your control notification handler code here
  632. NET_DVR_TIME StartTime,StopTime;
  633. UpdateData(TRUE);
  634. iChannel = m_ChannelName.GetCurSel()+m_lStartChan;
  635. StartTime.dwYear = m_ctDateStart.GetYear();
  636. StartTime.dwMonth = m_ctDateStart.GetMonth();
  637. StartTime.dwDay = m_ctDateStart.GetDay();
  638. StartTime.dwHour = m_ctTimeStart.GetHour();
  639. StartTime.dwMinute = m_ctTimeStart.GetMinute();
  640. StartTime.dwSecond = m_ctTimeStart.GetSecond();
  641. StopTime.dwYear = m_ctDateStop.GetYear();
  642. StopTime.dwMonth = m_ctDateStop.GetMonth();
  643. StopTime.dwDay = m_ctDateStop.GetDay();
  644. StopTime.dwHour = m_ctTimeStop.GetHour();
  645. StopTime.dwMinute = m_ctTimeStop.GetMinute();
  646. StopTime.dwSecond = m_ctTimeStop.GetSecond();
  647. // if(NET_DVR_PlayBackByTimeLocDisplay(ServerID, iChannel, &StartTime, &StopTime))
  648. {
  649. TRACE("远程控制本地回放成功!");
  650. }
  651. }
  652. void CRemoteTimePlay::OnButstop()
  653. {
  654. // TODO: Add your control notification handler code here
  655. // if(NET_DVR_StopLocDisplayPlay(ServerID))
  656. {
  657. TRACE("停止远程控制本地回放成功!");
  658. }
  659. }
  660. */
  661. void CRemoteTimePlay::OnGotostart()
  662. {
  663. // TODO: Add your control notification handler code here
  664. }