123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 |
- // RemoteTimePlay.cpp : implementation file
- //
- #include "stdafx.h"
- #include "newclient.h"
- #include "RemoteTimePlay.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CRemoteTimePlay dialog
- extern SERVER_INFO serverinfo[MAXIPNUMBER];
- extern CLIENTPARAM ClientParam;
- CRemoteTimePlay::CRemoteTimePlay(CWnd* pParent /*=NULL*/)
- : CDialog(CRemoteTimePlay::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CRemoteTimePlay)
- m_ctDateStart = 0;
- m_ctDateStop = 0;
- m_ctTimeStart = 0;
- m_ctTimeStop = 0;
- //}}AFX_DATA_INIT
- m_hPlayEnableIcon = AfxGetApp()->LoadIcon(IDI_PLAY_ENABLE);
- m_hPlayDisableIcon = AfxGetApp()->LoadIcon(IDI_PLAY_DISABLE);
- m_hPauseEnableIcon = AfxGetApp()->LoadIcon(IDI_PAUSE_ENABLE);
- m_hPauseDisableIcon = AfxGetApp()->LoadIcon(IDI_PAUSE_DISABLE);
- m_hStopEnableIcon = AfxGetApp()->LoadIcon(IDI_STOP_ENABLE);
- m_hStopDisableIcon = AfxGetApp()->LoadIcon(IDI_STOP_DISABLE);
- m_hSoundStartIcon= AfxGetApp()->LoadIcon(IDI_SOUND_ENABLE);
- m_hSoundStopIcon= AfxGetApp()->LoadIcon(IDI_SOUND_DISABLE);
- m_hGotoTailDisableIcon = AfxGetApp()->LoadIcon(IDI_GOTOEND_DISABLE);
- m_hFastDisableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_DISABLE);
- m_hSlowDisableIcon= AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_DISABLE);
- m_hGotoTailEnableIcon = AfxGetApp()->LoadIcon(IDI_GOTOEND_ENABLE);
- m_hFastEnableIcon = AfxGetApp()->LoadIcon(IDI_FASTFORWARD_ENABLE);
- m_hSlowEnableIcon = AfxGetApp()->LoadIcon(IDI_FASTBACKWARD_ENABLE);
- m_hStepBackEnableIcon = AfxGetApp()->LoadIcon(IDI_STEPBACK_ENABLE);
- m_hStepBackDisableIcon = AfxGetApp()->LoadIcon(IDI_STEPBACK_DISABLE);
- m_hCaptureIcon = AfxGetApp()->LoadIcon(IDI_PIC);
-
- }
- void CRemoteTimePlay::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CRemoteTimePlay)
- DDX_Control(pDX, IDC_WND, m_PlayWnd);
- DDX_Control(pDX, IDC_VOLUME_SLIDER, m_ctlVolume);
- DDX_Control(pDX, IDC_COMBOSERVER, m_ServerName);
- DDX_Control(pDX, IDC_COMBOPORT, m_ChannelName);
- DDX_DateTimeCtrl(pDX, IDC_DATESTART, m_ctDateStart);
- DDX_DateTimeCtrl(pDX, IDC_DATESTOP, m_ctDateStop);
- DDX_DateTimeCtrl(pDX, IDC_TIMESTART, m_ctTimeStart);
- DDX_DateTimeCtrl(pDX, IDC_TIMESTOP, m_ctTimeStop);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CRemoteTimePlay, CDialog)
- //{{AFX_MSG_MAP(CRemoteTimePlay)
- ON_BN_CLICKED(IDC_STOP, OnStop)
- ON_BN_CLICKED(IDC_SLOW, OnSlow)
- ON_BN_CLICKED(IDC_FAST, OnFast)
- ON_BN_CLICKED(IDC_CAPPIC, OnCappic)
- ON_BN_CLICKED(IDC_STEP, OnStep)
- ON_BN_CLICKED(IDC_SOUND, OnSound)
- ON_WM_HSCROLL()
- ON_WM_LBUTTONDBLCLK()
- ON_BN_CLICKED(IDC_PLAY_TIME, OnPlayTime)
- ON_CBN_SELCHANGE(IDC_COMBOSERVER, OnSelchangeComboserver)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_BUTTONDOWNLOAD, OnButtondownload)
- ON_BN_CLICKED(IDC_BUTTONLOADSAVE, OnButtonloadsave)
- ON_BN_CLICKED(IDC_GOTOSTART, OnGotostart)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CRemoteTimePlay message handlers
- void CRemoteTimePlay::SetParentWnd(HWND *hhWnd, int iParentNum)
- {
- VERIFY(iParentNum==2);
- m_hPareDlgWnd=hhWnd[0];
- m_hPareTabWnd=hhWnd[1];
- }
- BOOL CRemoteTimePlay::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CRect rc(0, 0, 0, 0);
- GetParent()->GetClientRect(&rc);
- ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc);
- MoveWindow(&rc);
- F_InitUI();
- m_bPause=FALSE;
- m_bDown = FALSE;
- m_bTimeSave = FALSE;
- m_ServerName.AddString("请选择DVR");
- for(int i = 0; i < MAXIPNUMBER; i++)
- {
- if(serverinfo[i].m_csServerName != "")
- m_ServerName.AddString(serverinfo[i].m_csServerName);
- }
- m_ServerName.SetCurSel(0);
- m_ChannelName.SetCurSel(1);
- CTime time1 = CTime::GetCurrentTime();
- CTime time(time1.GetYear(),time1.GetMonth(),time1.GetDay(),0,0,0);
- CTime time0(time1.GetYear(),time1.GetMonth(),time1.GetDay(),23,59,59);
- m_ctDateStart = time;
- m_ctTimeStart = time;
- m_ctDateStop = time1;
- m_ctTimeStop = time0;
- m_ctlVolume.SetRange(1, 100, TRUE);
- m_ctlVolume.SetPos(50);
- lHandle = -1;
- m_lLoadHandle = -1;
- m_bSound = FALSE;
- m_bFullScreen = FALSE;
- m_hPareDlgWnd = NULL;
- m_hPareTabWnd = NULL;
- m_lStartChan = 0;
- GetDlgItem(IDC_WND)->GetWindowRect(m_rcWnd);
- ScreenToClient(m_rcWnd);
- m_rcScreen=CRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CRemoteTimePlay::OnPlayTime()
- {
- // TODO: Add your control notification handler code here
- NET_DVR_TIME StartTime,StopTime;
- UpdateData(TRUE);
- if(lHandle == -1)
- {
- if(m_ServerName.GetCurSel() == 0)
- {
- AfxMessageBox("请选择DVR!");
- return;
- }
-
- //ServerID = serverinfo[i].m_lServerID;
- iChannel = m_ChannelName.GetCurSel()+m_lStartChan;
- StartTime.dwYear = m_ctDateStart.GetYear();
- StartTime.dwMonth = m_ctDateStart.GetMonth();
- StartTime.dwDay = m_ctDateStart.GetDay();
- StartTime.dwHour = m_ctTimeStart.GetHour();
- StartTime.dwMinute = m_ctTimeStart.GetMinute();
- StartTime.dwSecond = m_ctTimeStart.GetSecond();
- StopTime.dwYear = m_ctDateStop.GetYear();
- StopTime.dwMonth = m_ctDateStop.GetMonth();
- StopTime.dwDay = m_ctDateStop.GetDay();
- StopTime.dwHour = m_ctTimeStop.GetHour();
- StopTime.dwMinute = m_ctTimeStop.GetMinute();
- StopTime.dwSecond = m_ctTimeStop.GetSecond();
- lHandle = NET_DVR_PlayBackByTime(ServerID, iChannel, &StartTime, &StopTime, m_PlayWnd.GetSafeHwnd());
- if(lHandle == -1)
- {
- AfxMessageBox("远程回放失败!");
- return;
- }
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTART, 0, NULL);
- if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTARTAUDIO, 0, NULL))
- {
- m_bSound=TRUE;
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYAUDIOVOLUME, (0xffff)/2, NULL);
- m_ctlVolume.SetPos(50);
- ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStartIcon);
- }
- else
- {
- m_bSound=FALSE;
- ((CButton *)GetDlgItem(IDC_SOUND))->SetIcon(m_hSoundStopIcon);
- }
- F_SetPlayState();
- SetTimer(PLAYBYTIME_TIMER,2000,NULL);
- UpdateData(FALSE);
- }
- else
- {
- if(m_bPause)
- {
- if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYRESTART, 0, NULL))
- {
- m_bPause=FALSE;
- F_SetPlayState();
- }
- }
- else
- {
- if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYPAUSE, 0, NULL))
- {
- TRACE("handle:%d \n",lHandle);
- m_bPause=TRUE;
- CButton *pButton;
- pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
- pButton->SetIcon(m_hPlayEnableIcon);
- pButton->EnableWindow(TRUE);
- }
- }
- }
- }
- void CRemoteTimePlay::OnStop()
- {
- // TODO: Add your control notification handler code here
- F_StopPlay();
- }
- void CRemoteTimePlay::F_StopPlay()
- {
- CButton *pButton;
- if(lHandle >= 0)
- {
- if(m_bFullScreen)
- {
- m_bFullScreen = FALSE;
- F_ShowNormal();
- }
- if(m_bTimeSave)
- {
- NET_DVR_StopPlayBackSave(lHandle);
- m_bTimeSave = FALSE;
- GetDlgItem(IDC_BUTTONLOADSAVE)->SetWindowText("保存");
- }
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTOPAUDIO, 0, NULL);
- NET_DVR_StopPlayBack(lHandle);
- lHandle = -1;
- Invalidate(TRUE);
- UpdateData(FALSE);
- KillTimer(PLAYBYTIME_TIMER);
- }
- m_bSound=FALSE;
- m_bPause = FALSE;
- m_ctlVolume.EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
- pButton->SetIcon(m_hPlayEnableIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_STOP);
- pButton->SetIcon(m_hStopDisableIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_FAST);
- pButton->SetIcon(m_hFastDisableIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_SLOW);
- pButton->SetIcon(m_hSlowDisableIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
- pButton->SetIcon(m_hCaptureIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_SOUND);
- pButton->SetIcon(m_hSoundStopIcon);
- pButton->EnableWindow(FALSE);
- }
- void CRemoteTimePlay::F_ShowNormal()
- {
- GetDlgItem(IDC_WND)->SetWindowPos(NULL,m_rcWnd.left,m_rcWnd.top,m_rcWnd.Width(),m_rcWnd.Height(),SWP_SHOWWINDOW);
- ::SetWindowPos(m_hWnd,NULL,m_rcParent.left,m_rcParent.top,m_rcParent.Width(),m_rcParent.Height(),SWP_SHOWWINDOW);
- ::SetWindowPos(m_hPareTabWnd,NULL,m_rcPareTab.left,m_rcPareTab.top,m_rcPareTab.Width(),m_rcPareTab.Height(),SWP_SHOWWINDOW);
- ::SetWindowPos(m_hPareDlgWnd,NULL,m_rcPareDlg.left,m_rcPareDlg.top,m_rcPareDlg.Width(),m_rcPareDlg.Height(),SWP_SHOWWINDOW);
- F_EnableFlashWnd(TRUE);
- Invalidate(FALSE);
- UpdateWindow();
- }
- void CRemoteTimePlay::OnSlow()
- {
- // TODO: Add your control notification handler code here
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSLOW, 0, NULL);
- }
- void CRemoteTimePlay::OnFast()
- {
- // TODO: Add your control notification handler code here
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYFAST, 0, NULL);
- }
- void CRemoteTimePlay::OnCappic()
- {
- // TODO: Add your control notification handler code here
- char cFilename[256];
-
- sprintf(cFilename, "%s\\%d_%d.bmp",ClientParam.m_csPictureSavePath,iChannel, GetTickCount());
- if(NET_DVR_PlayBackCaptureFile(lHandle,cFilename))
- {
- CString sTemp;
- sTemp.Format("抓图成功 %s!",cFilename);
- AfxMessageBox(sTemp);
- return;
- }
- else
- {
- AfxMessageBox("抓图失败!");
- }
- }
- void CRemoteTimePlay::OnStep()
- {
- // TODO: Add your control notification handler code here
-
- }
- void CRemoteTimePlay::OnSound()
- {
- // TODO: Add your control notification handler code here
- CButton *pButton;
- if(lHandle >= 0)
- {
- if(m_bSound)
- {
- if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTOPAUDIO, 0, NULL))
- {
- m_bSound=FALSE;
- pButton = (CButton *)GetDlgItem(IDC_SOUND);
- pButton->SetIcon(m_hSoundStopIcon);
- }
- }
- else
- {
- if(NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYSTARTAUDIO, 0, NULL))
- {
- pButton = (CButton *)GetDlgItem(IDC_SOUND);
- pButton->SetIcon(m_hSoundStartIcon);
- m_bSound=TRUE;
- }
- }
- }
-
- }
- void CRemoteTimePlay::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- // TODO: Add your message handler code here and/or call default
- if (GetDlgItem(IDC_VOLUME_SLIDER) == pScrollBar)
- {
- char volume;
- WORD temp, volumevalue;
- temp = (0xffff)/100;
- volume = m_ctlVolume.GetPos();
- volumevalue = volume*temp;
- if(lHandle >= 0)
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYAUDIOVOLUME, volumevalue, NULL);
- }
- CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
- }
- void CRemoteTimePlay::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- if( (IsInWnd(point)) && (lHandle >= 0) )
- {
- m_bFullScreen=!m_bFullScreen;
- if(m_bFullScreen)
- F_ShowFullScreen();
- else
- F_ShowNormal();
- }
- CDialog::OnLButtonDblClk(nFlags, point);
- }
- BOOL CRemoteTimePlay::IsInWnd(CPoint point)
- {
- CRect rc;
- GetDlgItem(IDC_WND)->GetWindowRect(&rc);
- ScreenToClient(&rc);
- if(PtInRect(&rc,point))
- return TRUE;
- else
- return FALSE;
- }
- void CRemoteTimePlay::F_ShowFullScreen()
- {
- F_EnableFlashWnd(FALSE);
- CRect rc,rcClient;
- ::GetWindowRect(m_hPareDlgWnd,m_rcPareDlg);
- ::GetWindowRect(m_hPareTabWnd,m_rcPareTab);
- ::ScreenToClient(m_hPareDlgWnd,(POINT*)(&m_rcPareTab));
- ::ScreenToClient(m_hPareDlgWnd,(POINT*)(&m_rcPareTab)+1);
- ::GetWindowRect(m_hWnd,m_rcParent);
- ::ScreenToClient(m_hPareTabWnd,(POINT*)(&m_rcParent));
- ::ScreenToClient(m_hPareTabWnd,(POINT*)(&m_rcParent)+1);
-
- ::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);
- ::GetClientRect(m_hPareDlgWnd,rc);
- ::SetWindowPos(m_hPareTabWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW);
- ::GetClientRect(m_hPareTabWnd,rc);
- ::SetWindowPos(m_hWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW);
-
- GetDlgItem(IDC_WND)->GetClientRect(rcClient);
- GetDlgItem(IDC_WND)->GetWindowRect(rc);
- int iEdge=(rc.Width()-rcClient.Width())/2;
- rc=m_rcScreen;
- rc.left-=iEdge;
- rc.right+=iEdge;
- rc.top-=iEdge;
- rc.bottom+=iEdge;
- this->ScreenToClient(rc);
- ::SetWindowPos(GetDlgItem(IDC_WND)->m_hWnd,NULL,rc.left,rc.top,rc.Width(),rc.Height(),SWP_SHOWWINDOW);
- Invalidate(FALSE);
- UpdateWindow();
- }
- void CRemoteTimePlay::F_EnableFlashWnd(BOOL bEnable)
- {
- if(bEnable)
- {
- //THE same to multiplay
- GetDlgItem(IDC_COMBOSERVER)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_COMBOPORT)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_DATESTART)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_DATESTOP)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_TIMESTOP)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_TIMESTART)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_PLAY_TIME)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_STOP)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_SLOW)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_FAST)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_CAPPIC)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_SOUND)->ModifyStyle(0,WS_VISIBLE,0);
- GetDlgItem(IDC_VOLUME_SLIDER)->ModifyStyle(0,WS_VISIBLE,0);
- }
- else
- {
- //THE same to multiplay
- GetDlgItem(IDC_COMBOSERVER)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_COMBOPORT)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_DATESTART)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_DATESTOP)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_TIMESTOP)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_TIMESTART)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_PLAY_TIME)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_STOP)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_SLOW)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_FAST)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_CAPPIC)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_SOUND)->ModifyStyle(WS_VISIBLE,0,0);
- GetDlgItem(IDC_VOLUME_SLIDER)->ModifyStyle(WS_VISIBLE,0,0);
- }
- }
- void CRemoteTimePlay::F_InitUI()
- {
- CButton *pButton;
-
- pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
- pButton->SetIcon(m_hPlayEnableIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_STOP);
- pButton->SetIcon(m_hStopDisableIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_FAST);
- pButton->SetIcon(m_hFastDisableIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_SLOW);
- pButton->SetIcon(m_hSlowDisableIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
- pButton->SetIcon(m_hCaptureIcon);
- pButton->EnableWindow(FALSE);
-
- pButton = (CButton *)GetDlgItem(IDC_SOUND);
- pButton->SetIcon(m_hSoundStopIcon);
- pButton->EnableWindow(FALSE);
- }
- void CRemoteTimePlay::F_SetPlayState()
- {
- m_ctlVolume.EnableWindow(TRUE);
-
- CButton *pButton;
-
- pButton = (CButton *)GetDlgItem(IDC_PLAY_TIME);
- pButton->SetIcon(m_hPauseEnableIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_STOP);
- pButton->SetIcon(m_hStopEnableIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_FAST);
- pButton->SetIcon(m_hFastEnableIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_SLOW);
- pButton->SetIcon(m_hSlowEnableIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_CAPPIC);
- pButton->SetIcon(m_hCaptureIcon);
- pButton->EnableWindow(TRUE);
-
- pButton = (CButton *)GetDlgItem(IDC_SOUND);
- if(m_bSound)
- pButton->SetIcon(m_hSoundStartIcon);
- else
- pButton->SetIcon(m_hSoundStopIcon);
- pButton->EnableWindow(TRUE);
- }
- void CRemoteTimePlay::OnCancel()
- {
- // TODO: Add extra cleanup here
-
- // CDialog::OnCancel();
- }
- void CRemoteTimePlay::OnSelchangeComboserver()
- {
- // TODO: Add your control notification handler code here
- int iSelServer = m_ServerName.GetCurSel() - 1;
- if(iSelServer < 0)
- return;
- ServerID = serverinfo[iSelServer].m_lServerID;
- m_lStartChan = serverinfo[iSelServer].m_lStartChannel;
- int m_iChanNum = serverinfo[iSelServer].m_iServerChannelNumber;
- m_ChannelName.ResetContent();
- CString sTemp;
- for(int i=0; i<m_iChanNum; i++)
- {
- sTemp.Format("%d", i+m_lStartChan);
- m_ChannelName.AddString(sTemp);
- }
- iChannel = 0;
- m_ChannelName.SetCurSel(iChannel);
- }
- void CRemoteTimePlay::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- DWORD nPos;
- if(nIDEvent == PLAYBYTIME_TIMER)
- {
- if(lHandle >= 0)
- {
- NET_DVR_PlayBackControl(lHandle, NET_DVR_PLAYGETPOS, 0, &nPos);
- if(nPos > 100) //由于网络原因或DVR忙,回放或下载异常终止
- {
- F_StopPlay();
- AfxMessageBox("由于网络原因或DVR忙,回放异常终止!");
- }
- if(nPos == 100)
- {
- F_StopPlay();
- AfxMessageBox("按时间回放结束!");
- }
- }
-
- }
- else if(nIDEvent == DOWNBYTIME_TIMER)
- {
- if(m_bDown)
- {
- NET_DVR_PlayBackControl(m_lLoadHandle, NET_DVR_PLAYGETPOS, 0, &nPos);
- if(nPos > 100) //由于网络原因或DVR忙,回放或下载异常终止
- {
- m_bDown=FALSE;
- NET_DVR_StopGetFile(m_lLoadHandle);
- GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("下载");
- AfxMessageBox("由于网络原因或DVR忙,下载异常终止!");
- }
- if(nPos == 100)
- {
- m_bDown=FALSE;
- NET_DVR_StopGetFile(m_lLoadHandle);
- GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("下载");
- AfxMessageBox("按时间下载结束!");
- }
- }
- }
- CDialog::OnTimer(nIDEvent);
- }
- void CRemoteTimePlay::OnButtondownload()
- {
- // TODO: Add your control notification handler code here
- CString csFileName;
- CString csStartTime, csStopTime;
- CString csTemp,csDir;
- char nFileName[256];
-
- UpdateData(TRUE);
- if(!m_bDown)
- {
- if(m_ServerName.GetCurSel() == 0)
- {
- AfxMessageBox("请选择DVR!");
- return;
- }
- int iSelServer = m_ServerName.GetCurSel() - 1;
- iChannel = m_ChannelName.GetCurSel()+m_lStartChan;
-
- 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());
- 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());
-
- csDir.Format("%s\\",ClientParam.m_csDownLoadPath);
- sprintf(nFileName,"%s%s_%02d_D%s_%sTime.mp4",csDir,serverinfo[iSelServer].m_csServerIP, iChannel,csStartTime,csStopTime);
- TRACE("Download file name: %s \n", nFileName);
- NET_DVR_TIME StartTime,StopTime;
- UpdateData(TRUE);
-
- StartTime.dwYear = m_ctDateStart.GetYear();
- StartTime.dwMonth = m_ctDateStart.GetMonth();
- StartTime.dwDay = m_ctDateStart.GetDay();
- StartTime.dwHour = m_ctTimeStart.GetHour();
- StartTime.dwMinute = m_ctTimeStart.GetMinute();
- StartTime.dwSecond = m_ctTimeStart.GetSecond();
- StopTime.dwYear = m_ctDateStop.GetYear();
- StopTime.dwMonth = m_ctDateStop.GetMonth();
- StopTime.dwDay = m_ctDateStop.GetDay();
- StopTime.dwHour = m_ctTimeStop.GetHour();
- StopTime.dwMinute = m_ctTimeStop.GetMinute();
- StopTime.dwSecond = m_ctTimeStop.GetSecond();
- m_lLoadHandle = NET_DVR_GetFileByTime(ServerID,iChannel, &StartTime, &StopTime, nFileName);
- if(m_lLoadHandle >= 0)
- {
- NET_DVR_PlayBackControl(m_lLoadHandle, NET_DVR_PLAYSTART, 0, NULL);
- GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("停止下载");
- m_bDown=TRUE;
- SetTimer(DOWNBYTIME_TIMER,1000,NULL);
- }
- else
- {
- AfxMessageBox("按时间下载失败!");
- CString sTemp;
- sTemp.Format("ERROR: NET_DVR_GetFileByTime = %d",NET_DVR_GetLastError());
- TRACE(sTemp);
- return;
- }
- }
- else
- {
- NET_DVR_StopGetFile(m_lLoadHandle);
- m_bDown=FALSE;
- GetDlgItem(IDC_BUTTONDOWNLOAD)->SetWindowText("下载");
- KillTimer(DOWNBYTIME_TIMER);
- Invalidate(TRUE);
- }
- UpdateData(FALSE);
- }
- void CRemoteTimePlay::OnButtonloadsave()
- {
- // TODO: Add your control notification handler code here
- if(!m_bTimeSave)
- {
- //zxy 2005-01-04
- static char szFilter[]="All File(*.*)|*.*||";
- char m_sFile[256] = "c:\\SavefileByTime.mp4";
- CString csFile;
- CFileDialog dlg(FALSE,"*.mp4","SavefileByTime.mp4",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
- szFilter);
- if(dlg.DoModal()==IDOK)
- {
- csFile = dlg.GetPathName();
- UpdateData(FALSE);
- sprintf(m_sFile, "%s", csFile);
- if(NET_DVR_PlayBackSaveData(lHandle, m_sFile))
- {
- m_bTimeSave = TRUE;
- GetDlgItem(IDC_BUTTONLOADSAVE)->SetWindowText("停止保存");
- }
- }
- }
- else
- {
- NET_DVR_StopPlayBackSave(lHandle);
- m_bTimeSave = FALSE;
- GetDlgItem(IDC_BUTTONLOADSAVE)->SetWindowText("保存");
- }
- }
- //zxy 2005-01-04
- /*
- void CRemoteTimePlay::OnButplay()
- {
- // TODO: Add your control notification handler code here
- NET_DVR_TIME StartTime,StopTime;
- UpdateData(TRUE);
- if(m_ServerName.GetCurSel() == 0)
- {
- AfxMessageBox("请选择DVR!");
- return;
- }
-
- iChannel = m_ChannelName.GetCurSel()+m_lStartChan;
- StartTime.dwYear = m_ctDateStart.GetYear();
- StartTime.dwMonth = m_ctDateStart.GetMonth();
- StartTime.dwDay = m_ctDateStart.GetDay();
- StartTime.dwHour = m_ctTimeStart.GetHour();
- StartTime.dwMinute = m_ctTimeStart.GetMinute();
- StartTime.dwSecond = m_ctTimeStart.GetSecond();
- StopTime.dwYear = m_ctDateStop.GetYear();
- StopTime.dwMonth = m_ctDateStop.GetMonth();
- StopTime.dwDay = m_ctDateStop.GetDay();
- StopTime.dwHour = m_ctTimeStop.GetHour();
- StopTime.dwMinute = m_ctTimeStop.GetMinute();
- StopTime.dwSecond = m_ctTimeStop.GetSecond();
- // if(NET_DVR_PlayBackByTimeLocDisplay(ServerID, iChannel, &StartTime, &StopTime))
- {
- TRACE("远程控制本地回放成功!");
- }
- }
- void CRemoteTimePlay::OnButstop()
- {
- // TODO: Add your control notification handler code here
- // if(NET_DVR_StopLocDisplayPlay(ServerID))
- {
- TRACE("停止远程控制本地回放成功!");
- }
- }
- */
- void CRemoteTimePlay::OnGotostart()
- {
- // TODO: Add your control notification handler code here
-
- }
|