// PrhHistFindLabel.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include "DynamicDraw.h"
#include "HistViewDoc.h"		// For FFHistViewDoc().
#include "HistViewFrame.h"		// For FFHistViewFrame().
#include "DlgHistFindResults.h"	// For CFCDlgHistFindResults.
#include "HiProject.h"			// For FCHiProject.
#include "PrhHistFindLabel.h"	// This header.

// Superclass_xZkqqHx_iCmMjCoIiLgAiBeC_xHqqkZx_

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

//----- _xZkqqHx_iDiMiDfHiDfIiDgHiDiKjFnLjBlGjGlM_xHqqkZx_ -----
static const wchar_t* REG_PRH_HIST_FIND_LABEL = L"CFCPrhHistFindLabel";

/////////////////////////////////////////////////////////////////////////////
// CFCPrhHistFindLabel _xZkqqHx_iDfPiDeDiDeBiDiNiDeP_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCPrhHistFindLabel::CFCPrhHistFindLabel
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pWndResult	:_xZkqqHx_iMjPiNpFiMiLiJmKjFfMiOkGiDhAiDgMiDiLiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.12.25 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CFCPrhHistFindLabel::CFCPrhHistFindLabel ()
					: BASE_CLASS()
{
	//{{AFX_DATA_INIT(CFCPrhHistFindLabel)
	m_bFindCreateLabel = FALSE;
	m_bFindDeleteLabel = FALSE;
	m_bFindTimeLabel = FALSE;
	//}}AFX_DATA_INIT
} // CFCPrhHistFindLabel::CFCPrhHistFindLabel.

void CFCPrhHistFindLabel::DoDataExchange(CDataExchange* pDX)
{
	BASE_CLASS::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFCPrhHistFindLabel)
	DDX_Check(pDX, IDC_HFD_LBL_CHK_FIND_CREATE_LABEL, m_bFindCreateLabel);
	DDX_Check(pDX, IDC_HFD_LBL_CHK_FIND_DELETE_LABEL, m_bFindDeleteLabel);
	DDX_Check(pDX, IDC_HFD_LBL_CHK_FIND_TIME_LABEL, m_bFindTimeLabel);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFCPrhHistFindLabel, BASE_CLASS)
	//{{AFX_MSG_MAP(CFCPrhHistFindLabel)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFCPrhHistFindLabel _xZkqqHx_iDiGiBfLiDfFiKnGjAjEiBeC_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCPrhHistFindLabel::OnSetActive
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDhJiBfLiDfHiCkKiDeBiDeOiDgFiDeCiDhFiCmJiCmIiCoJiCmGiCkLiCmJiMmEiCnBiPgPiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.12.25 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCPrhHistFindLabel::OnSetActive ()
{
	// Superclass_xZkqqHx_iOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnSetActive();
	//----- _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiCkJiCoHiPpDiLlFiCpAiOoGjDlOiClHiCoJ_xHqqkZx_ -----
	g_pReg->LoadRegBinary(	GetRegName(),
							L"m_bFindCreateLabel",
							(BYTE*)&m_bFindCreateLabel,
							sizeof(m_bFindCreateLabel));
	g_pReg->LoadRegBinary(	GetRegName(),
							L"m_bFindDeleteLabel",
							(BYTE*)&m_bFindDeleteLabel,
							sizeof(m_bFindDeleteLabel));
	g_pReg->LoadRegBinary(	GetRegName(),
							L"m_bFindTimeLabel",
							(BYTE*)&m_bFindTimeLabel,
							sizeof(m_bFindTimeLabel));
} // CFCPrhHistFindLabel::OnSetActive.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCPrhHistFindLabel::OnKillActive
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDhJiBfLiDfHiCkKiDeBiDeOiDgFiDeCiDhFiCmFiCmIiCkNiCmIiCoJiCmGiCkLiCmJiMmEiCnBiPgPiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.12.25 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCPrhHistFindLabel::OnKillActive ()
{
	//----- _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiCmJiPpDiLlFiCpAjFnLjBlGiClHiCoJ_xHqqkZx_ -----
	g_pReg->SaveRegBinary(	GetRegName(),
							L"m_bFindCreateLabel",
							(BYTE*)&m_bFindCreateLabel,
							sizeof(m_bFindCreateLabel));
	g_pReg->SaveRegBinary(	GetRegName(),
							L"m_bFindDeleteLabel",
							(BYTE*)&m_bFindDeleteLabel,
							sizeof(m_bFindDeleteLabel));
	g_pReg->SaveRegBinary(	GetRegName(),
							L"m_bFindTimeLabel",
							(BYTE*)&m_bFindTimeLabel,
							sizeof(m_bFindTimeLabel));
	// Superclass_xZkqqHx_iOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnKillActive();
} // CFCPrhHistFindLabel::OnKillActive.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCPrhHistFindLabel::GetRegName
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDiMiDfHiDfIiDgHiDiKjDgPjIfOiClHiCoJiClNiCnPiCmMjDgPjIfOjGlMiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDiMiDfHiDfIiDgHiDiKjDgPjIfOiClHiCoJiClNiCnPiCmMjDgPjIfOjGlMiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	06.02.21 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
const wchar_t* CFCPrhHistFindLabel::GetRegName () const
{
	return REG_PRH_HIST_FIND_LABEL;
} // CFCPrhHistFindLabel::GetRegName.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCPrhHistFindLabel::IsConsistent
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLjAnNjCoIjCgMiCmMjGlFiPiCjAkLiCmMiDgAiDeGiDgCiDeOiCpAiNhDiCkEiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jGlDjGlFiPiCiCmMiPoKiNiHiCmN_xHqqkZx_ TRUE_xZkqqHx_iBeBjGlFiPiCiCmMiPoKiNiHiCmN_xHqqkZx_ FALSE _xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.12.25 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL CFCPrhHistFindLabel::IsConsistent ()
{
	// Superclass_xZkqqHx_iOmAiNhDiBeC_xHqqkZx_
	if (!BASE_CLASS::IsConsistent()) return FALSE;

	if ((!m_bFindCreateLabel && !m_bFindDeleteLabel && !m_bFindTimeLabel) ||
		m_wstrTxbFindString.IsEmpty())
	//----- _xZkqqHx_iMjPiNpFjBmOiPnLiCkKjAnNjCoIiClDiCoKiCmEiCkCiCmIiCkCiPoKiNiH_xHqqkZx_ -----
	{
		// IDS_ERR_MSG_SEARCH_TARGET_NOT_SPECIFIED = "_xZkqqHx_iMjPiNpFjBmOiPnLiCkKiOhHjCoIiClDiCoKiCmEiCkCiCnMiClJiCpB_xHqqkZx_"
		FFErrorBox(IDS_ERR_MSG_SEARCH_TARGET_NOT_SPECIFIED);
		return FALSE;
	}
	return TRUE;
} // CFCPrhHistFindLabel::IsConsistent.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCPrhHistFindLabel::DoFind
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iMjPiNpFiCpAiOmAiNhDiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.12.25 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCPrhHistFindLabel::DoFind ()
{
	// CFCDlgHistFindResults_xZkqqHx_iCkJiCoH_xHqqkZx_HistoryFind_xZkqqHx_iCpAiOoGjDlOiBeC_xHqqkZx_
	FCHistoryFind& hf = FFHistViewFrame()->GetHtreeFindResults()->GetHistoryFind();
//----- 06.02.22 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	// _xZkqqHx_iDhGiDiNiDfHiDeGiDeOiDgHiCkKjFmCiClGiCmEiCkCiCoJiPoKiNiHiCmNiDeHiDiJiBfLiBeCiOmAiNnLiCmNiMmEiCmOiCoKiCmIiCkCiCmNiClIiBeC_xHqqkZx_
	if (!g_pProject->IsProjectOpened())
		FFThrowMiscUnknown();
	long lDocumentId = FFHistViewDoc()->GetIsDocumentOpened() ? FFHistViewDoc()->GetDocumentId() : -1;
	flint fliNextSessionIndex = FFHistViewDoc()->GetIsDocumentOpened() ? FFHistViewDoc()->GetNextSessionIndex() : -1;
//----- 06.02.22 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

	// _xZkqqHx_iMjPiNpFiPiIjHjNiBeC_xHqqkZx_
	hf.FindLabel(	g_pProject->GetFilePathH(),
					GetNarrowTimeFrom(),
					GetNarrowTimeUntil(),
					GetNarrowUserId(),
					m_bTbcSrhSearchAllDocument,
					m_bTbcSrhSearchBefore,
					m_bTbcSrhSearchHigher,
					m_bTbcSrhSearchBeforeBranch,
					m_bTbcSrhSearchAfter,
					m_bTbcSrhSearchAfterBranch,
					lDocumentId,
					fliNextSessionIndex,
					m_bFindCreateLabel,
					m_bFindDeleteLabel,
					m_bFindTimeLabel,
					m_wstrTxbFindString,
					m_bTxbMultiWord,
					m_bTxbRegexp,
					m_bTxbAsUppercase);
} // CFCPrhHistFindLabel::DoFind.

/////////////////////////////////////////////////////////////////////////////
// CFCPrhHistFindLabel _xZkqqHx_iDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDgOiDjDiDgIiDiJ_xHqqkZx_
