⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setclient.cpp

📁 SDK DVR/DVS HIKVISION
💻 CPP
字号:
// SetClient.cpp : implementation file
//

#include "stdafx.h"
#include "newclient.h"
#include "SetClient.h"
#include "SetClientRecordPlan.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSetClient dialog
extern	CLIENTPARAM	ClientParam;
extern	void	WriteClientConfig();
BOOL DeleteDirectory(LPCTSTR DirName);
int nUseCard;

CSetClient::CSetClient(CWnd* pParent /*=NULL*/)
	: CDialog(CSetClient::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetClient)
	m_bAutoRecord = FALSE;
	m_bCyclePlay = FALSE;
	m_bCycleRecord = FALSE;
	m_bUseCard = FALSE;
	m_iCycleTime = 0;
	m_iFileInterVal = 0;
	m_csLoadPath = _T("");
	m_csLogPath = _T("");
	m_csPICPath = _T("");
	m_ctCheckServerTime = 0;
	m_bCheckServerTime = FALSE;
	//}}AFX_DATA_INIT
}


void CSetClient::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetClient)
	DDX_Control(pDX, IDC_COMBOCARD, m_CardCtrl);
	DDX_Control(pDX, IDC_COMBO2, m_StopRecordDriverCtrl);
	DDX_Control(pDX, IDC_COMBO1, m_StartRecordDriverCtrl);
	DDX_Control(pDX, IDC_CHKUSECARD, m_UseCardCtrl);
	DDX_Control(pDX, IDC_CHKCYCLERECORD, m_CycleRecordCtrl);
	DDX_Control(pDX, IDC_CHKCYCLEPLAY, m_CyclePlayCtrl);
	DDX_Control(pDX, IDC_CHKAUTORECORD, m_AutoRecordCtrl);
	DDX_Check(pDX, IDC_CHKAUTORECORD, m_bAutoRecord);
	DDX_Check(pDX, IDC_CHKCYCLEPLAY, m_bCyclePlay);
	DDX_Check(pDX, IDC_CHKCYCLERECORD, m_bCycleRecord);
	DDX_Check(pDX, IDC_CHKUSECARD, m_bUseCard);
	DDX_Text(pDX, IDC_EDITCYCLETIME, m_iCycleTime);
	DDX_Text(pDX, IDC_EDITFILEINTERVAL, m_iFileInterVal);
	DDX_Text(pDX, IDC_EDITLOADPATH, m_csLoadPath);
	DDX_Text(pDX, IDC_EDITLOGPATH, m_csLogPath);
	DDX_Text(pDX, IDC_EDITPICPATH, m_csPICPath);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER, m_ctCheckServerTime);
	DDX_Check(pDX, IDC_CHECKSYSTIME, m_bCheckServerTime);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetClient, CDialog)
	//{{AFX_MSG_MAP(CSetClient)
	ON_BN_CLICKED(IDC_BUTSELFILEPATH, OnButselfilepath)
	ON_BN_CLICKED(IDC_BUTSELLOGPATH, OnButsellogpath)
	ON_BN_CLICKED(IDC_BUTSELPICPATH, OnButselpicpath)
	ON_BN_CLICKED(IDC_BUTTONSETTIME, OnButtonsettime)
	ON_BN_CLICKED(IDC_CHKAUTORECORD, OnChkautorecord)
	ON_BN_CLICKED(IDC_CHKCYCLEPLAY, OnChkcycleplay)
	ON_BN_CLICKED(IDC_CHECKSYSTIME, OnChecksystime)
	ON_BN_CLICKED(IDCLOCALOK, OnClocalok)
	ON_BN_CLICKED(IDC_CHKUSECARD, OnChkusecard)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetClient message handlers

BOOL CSetClient::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	int i, j;
	
	CRect rc(0, 0, 0, 0);
	GetParent()->GetClientRect(&rc);
	((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc);
	MoveWindow(&rc);
	
	CString csHardDriver;
	CNewclientApp* pApp =  (CNewclientApp*)AfxGetApp();
	for(i = 0; i < (int)(pApp->m_iDriverNum); i++)
	{
		csHardDriver.Format("%c%s", pApp->m_cHardDriver[i], ":\\");
		m_StartRecordDriverCtrl.AddString(csHardDriver);
		m_StopRecordDriverCtrl.AddString(csHardDriver);
	}
	m_bCyclePlay = ClientParam.m_bCyclePlay;
	if(m_bCyclePlay)
	{
		GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
	}
	else
	{
		GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
	}
	m_iCycleTime = ClientParam.m_iCycleTime;
	m_bUseCard = ClientParam.m_bUseCard;
	m_CardCtrl.SetCurSel(ClientParam.m_bNTSC);
	UpdateData(FALSE);
	OnChkusecard();
	
	m_bAutoRecord = ClientParam.m_bAutoRecord;
	if(m_bAutoRecord)
		GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
	m_bCycleRecord = ClientParam.m_bCycleRecord;
	
	m_iFileInterVal = ClientParam.m_iRecordFileInterval;
	i = ClientParam.m_iStartRecordDriver;
	m_StartRecordDriverCtrl.SetCurSel(i);
	j = ClientParam.m_iEndRecordDriver;
	m_StopRecordDriverCtrl.SetCurSel(j);
	
	m_csLoadPath = ClientParam.m_csDownLoadPath;
	m_csPICPath = ClientParam.m_csPictureSavePath;
	m_csLogPath = ClientParam.m_csLogSavePath;
	m_bCheckServerTime = ClientParam.m_bCheckServerTime;
	CTime ctTime(2000, 1, 1, ClientParam.m_iCheckServerTime/10000, (ClientParam.m_iCheckServerTime%10000)/100, ClientParam.m_iCheckServerTime%100);
	m_ctCheckServerTime = ctTime;
	if(m_bCheckServerTime)
	{
		GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
	}
	else
	{
		GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
	}

	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetClient::OnButselfilepath() 
{
	// TODO: Add your control notification handler code here
	CString Str = F_GetDirectoryPath();
	if(Str != "")
	{
		m_csLoadPath = Str;
		UpdateData(FALSE);
	}	
}

void CSetClient::OnButsellogpath() 
{
	// TODO: Add your control notification handler code here
	CString Str = F_GetDirectoryPath();
	if(Str != "")
	{
		m_csLogPath = Str;
		UpdateData(FALSE);
	}	
}

void CSetClient::OnButselpicpath() 
{
	// TODO: Add your control notification handler code here
	CString Str = F_GetDirectoryPath();
	if(Str != "")
	{
		m_csPICPath = Str;
		UpdateData(FALSE);
	}	
}

void CSetClient::OnButtonsettime() 
{
	// TODO: Add your control notification handler code here
	CSetClientRecordPlan	SetClientRecordPlanDlg;
	SetClientRecordPlanDlg.DoModal();
}

void CSetClient::OnChkautorecord() 
{
	// TODO: Add your control notification handler code here

	if(m_AutoRecordCtrl.GetCheck() == 1)
		GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
	else
		GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(FALSE);
}

CString CSetClient::F_GetDirectoryPath()
{
	LPITEMIDLIST pidlRoot=NULL;
	SHGetSpecialFolderLocation(m_hWnd,CSIDL_DRIVES,&pidlRoot);
	BROWSEINFO bi;   //
	CString strDisplayName;   //
	bi.hwndOwner=GetSafeHwnd();   //Parent Handle
	bi.pidlRoot=pidlRoot;   //
	bi.pszDisplayName=strDisplayName.GetBuffer(MAX_PATH+1);   //
	bi.lpszTitle="Folder";   //Title
	bi.ulFlags=BIF_RETURNONLYFSDIRS;   //Flag
	bi.lpfn=NULL;
	bi.lParam=0;
	bi.iImage=0;   //
	LPITEMIDLIST lpIDList= SHBrowseForFolder(&bi);	//open dialog
	strDisplayName.ReleaseBuffer();   //
	char pPath[MAX_PATH];
	CString Str;
	if(lpIDList)
	{
		SHGetPathFromIDList (lpIDList, pPath);
		Str=pPath;
	}
	return Str;
}

void CSetClient::OnChkcycleplay() 
{
	// TODO: Add your control notification handler code here
	if(m_CyclePlayCtrl.GetCheck() == 1)
	{
		GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
	}
	else
	{
		GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
	}
}

void CSetClient::OnChecksystime() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_bCheckServerTime)
	{
		GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
	}
	else
	{
		GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
	}
}

void CSetClient::OnClocalok() 
{
	// TODO: Add your control notification handler code here
	int i, j;
	
	UpdateData(TRUE);
	if( (m_iFileInterVal < 1) || (m_iFileInterVal > 60) )
	{
		AfxMessageBox("Illegal file interval!");
		return;
	}
	if( (m_csLoadPath == "") || (m_csPICPath == "") || (m_csLogPath == "") )
	{
		AfxMessageBox("Please select file save path!");
		return;
	}
	i = m_StartRecordDriverCtrl.GetCurSel();
	j = m_StopRecordDriverCtrl.GetCurSel();
	if(i > j)
	{
		AfxMessageBox("Start HDD and end HDD are not matched!");
		return;
	}
	
	if(m_iCycleTime < 20)
		m_iCycleTime = 20;
	ClientParam.m_bCyclePlay = m_bCyclePlay;
	ClientParam.m_iCycleTime = m_iCycleTime;
	if(ClientParam.m_bUseCard != m_bUseCard)
	{
		if(!ClientParam.m_bUseCard)
		{
			nUseCard = 1;
		}
		else
		{
			nUseCard = 2;
		}
	}
	ClientParam.m_bUseCard = m_bUseCard;
	ClientParam.m_bNTSC = m_CardCtrl.GetCurSel();
	ClientParam.m_bAutoRecord = m_bAutoRecord;
	ClientParam.m_bCycleRecord = m_bCycleRecord;
	ClientParam.m_iRecordFileInterval = m_iFileInterVal;
	ClientParam.m_iStartRecordDriver = i;
	ClientParam.m_iEndRecordDriver = j;
	
	ClientParam.m_csDownLoadPath = m_csLoadPath;
	ClientParam.m_csPictureSavePath = m_csPICPath;
	ClientParam.m_csLogSavePath = m_csLogPath;
	ClientParam.m_bCheckServerTime = m_bCheckServerTime;
	ClientParam.m_iCheckServerTime = m_ctCheckServerTime.GetHour()*10000 + m_ctCheckServerTime.GetMinute()*100 + m_ctCheckServerTime.GetSecond();
	CreateDirectory(m_csLoadPath, NULL);
	CreateDirectory(m_csPICPath, NULL);
	CreateDirectory(m_csLogPath, NULL);
	WriteClientConfig();
}

void CSetClient::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	//CDialog::OnCancel();
}

void CSetClient::OnOK() 
{
	// TODO: Add extra cleanup here
	
	//	CDialog::OnOK();
}

void CSetClient::OnChkusecard() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_bUseCard)
	{
		GetDlgItem(IDC_COMBOCARD)->EnableWindow(TRUE);
	}
	else
	{
		GetDlgItem(IDC_COMBOCARD)->EnableWindow(FALSE);
	}
	UpdateData(FALSE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -