RemoteTimePlay.cpp 21 KB

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