#pragma once


#include "MemoryClient.h"
// CUB530View 窗体视图


class CUB530View : public CFormView
{
	DECLARE_DYNCREATE(CUB530View)

protected:
	CUB530View();           // 动态创建所使用的受保护的构造函数
	virtual ~CUB530View();

public:
#ifdef AFX_DESIGN_TIME
	enum { IDD = DLG_UB530VIEW };
#endif
#ifdef _DEBUG
	virtual void AssertValid() const;
#ifndef _WIN32_WCE
	virtual void Dump(CDumpContext& dc) const;
#endif
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	virtual void OnInitialUpdate();
	virtual void OnDraw(CDC* /*pDC*/);


	//////////////////////////////////////////////////////////////////////////////////////////
public:
	// 设备句柄;
	PVOID 				m_hVideoDevice;
	// 是否有信号;
	BOOL				m_bNoSignal;
	// 是否在录频;
	BOOL				m_bIsRecord;
	// 录频格式;
	BOOL				m_bIsMp4; // FALSE= AVI
	//////////////////////////////////////////////////////////////////////////
	// VIDEO PROPERTIES
	// 是否支持GPU;
	BOOL				m_bSupportGPU;
	// 视频流宽度;
	ULONG				m_nVideoWidth;
	// 视频流高度;
	ULONG				m_nVideoHeight;

	BOOL				m_bVideoIsInterleaved;

	double				m_dVideoFrameRate;

	BOOL				m_bVideoDeinterlaceEnable;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// AUDIO PROPERTIES

	ULONG				m_nAudioChannels;

	ULONG				m_nAudioBitsPerSample;

	ULONG				m_nAudioSampleFrequency;

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QUALITY PROPERTIES

	ULONG				m_nSharpness;

	ULONG				m_nSaturation;

	ULONG				m_nHue;

	ULONG				m_nConstrast;

	ULONG				m_nBrightness;

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RECORD & FILE PROPERTIES

	// 截图路径;
	CString				m_strSnapshotPath;
	//
	CString				m_strFormatChangedOutput;
	// 垂直镜像;
	BOOL				m_bVertically;
	// 水平镜像;
	BOOL				m_bHoriontal;

	// 程序退出;
	BOOL				m_bAppQuit;

public:
	// 初始化设备;
	BOOL HwInitialize();
	// 释放设备;
	BOOL HwUninitialize();

	// 单次截图;
	void CaptureSingleImage(LPTSTR lpszFileName, BOOL bIsJPG = TRUE);
	// 单次截图并自动命名;
	std::string CaptureSingleImageAutoName(LPCTSTR lpszDir, BOOL bIsJPG = TRUE);
	// 连续截图;//默认持续1000ms;
	void CaptureMultiImage(LPCTSTR lpszDir, LPCTSTR lpszPrefix, BOOL bIsJPG, int nDurationTime = 1000);

	//////////////////////////////////////////////////////////////////////////
	// ->预览截图;
	CaptureInfo m_CaptureInfo;
	BOOL m_bCaptureImage;
	BOOL m_bSaveImage;
	std::mutex m_mut_cpature;
	std::mutex m_mut_saveImg;
	std::condition_variable m_saveImg_cond;
	// 单次截图;
	void CaptureSingleImageEx(LPTSTR lpszFileName, BOOL bIsJPG = TRUE);
	// 单次截图并自动命名;
	std::string CaptureSingleImageAutoNameEx(LPCTSTR lpszDir, BOOL bIsJPG = TRUE);
	// 连续截图;//默认持续1000ms;
	void CaptureMultiImageEx(LPCTSTR lpszDir, LPCTSTR lpszPrefix, BOOL bIsJPG, int nDurationTime = 1000);
	// 截图;
	BOOL SaveImageByCaptureInfo(const CaptureInfo& capInfo);

	// 截图线程;
	BYTE* m_pBuffer;
	DWORD m_dwBufferLen;

	std::mutex m_mut_thread;
	std::condition_variable m_thread_cond; //使用std::condition_variable等待数据
	static void CaptureImageThread(CUB530View* pView);

	// 录屏;
	void StartRecord(DWORD dwDuration, LPCTSTR lpSavePath);
	void StopRecord();

	public:

public:
	// 截图路径;
	enum SHOTDir{
		ShotLocal = 0,
		ShotSystem = 1,
		ShotSpec = 2
	};
	SHOTDir m_shotDir;
	TCHAR m_szSpecDir[MAX_PATH];

	void SetRibbonStatusBarText(CString strText, int uId);
	friend class CMemoryClient;
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnCutBmp();
	afx_msg void OnCutJpg();
	afx_msg void OnStartRecord();
	afx_msg void OnStopRecord();
	afx_msg void OnCheckVertically();
	afx_msg void OnCheckHoriontal();
	afx_msg void OnUpdateCheckVertically(CCmdUI* pCmdUI);
	afx_msg void OnUpdateCheckHoriontal(CCmdUI* pCmdUI);
	afx_msg void OnTraymenuReconnect();
	afx_msg void OnCheckSuportGpu();
	afx_msg void OnCheckFormatMp4();
	afx_msg void OnCheckFormatAvi();
	afx_msg void OnUpdateCheckSuportGpu(CCmdUI* pCmdUI);
	afx_msg void OnUpdateCheckFormatMp4(CCmdUI* pCmdUI);
	afx_msg void OnUpdateCheckFormatAvi(CCmdUI* pCmdUI);
	afx_msg void OnUpdateStartRecord(CCmdUI* pCmdUI);
	afx_msg void OnUpdateStopRecord(CCmdUI* pCmdUI);
	afx_msg void OnCheckShotLocal();
	afx_msg void OnUpdateCheckShotLocal(CCmdUI* pCmdUI);
	afx_msg void OnCheckShotSystem();
	afx_msg void OnUpdateCheckShotSystem(CCmdUI* pCmdUI);
	afx_msg void OnCheckShotSpec();
	afx_msg void OnUpdateCheckShotSpec(CCmdUI* pCmdUI);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	
	afx_msg void OnCheckIrShot();
	afx_msg void OnUpdateCheckIrShot(CCmdUI* pCmdUI);
};


