You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.3 KiB
C++

#include "stdafx.h"
#include "LaiPuLaser.h"
#include "afxdialogex.h"
#include "DlgChildEventLog.h"
#include "WorkRecord.h"
#include "GlobalFunction.h"
#include "LogMgr.h"
#include "FileMgr.h"
IMPLEMENT_DYNAMIC(CDlgChildEventLog, CMyDlgView)
BEGIN_MESSAGE_MAP(CDlgChildEventLog, CMyDlgView)
ON_BN_CLICKED(IDC_CLEAR_LIST_BTN, &CDlgChildEventLog::OnBnClickedClearListBtn)
ON_BN_CLICKED(IDC_OPEN_LOG_DIR_BTN, &CDlgChildEventLog::OnBnClickedOpenLogDirBtn)
ON_CBN_SELCHANGE(IDC_LOG_TYPE_COMBO, &CDlgChildEventLog::OnCbnSelchangeLogTypeCombo)
ON_BN_CLICKED(IDC_STOP_REV_LOG_BTN, &CDlgChildEventLog::OnBnClickedStopRevLogBtn)
END_MESSAGE_MAP()
#define MAX_LOG_LIST_ROWS 1000//<2F><><EFBFBD><EFBFBD>log <20><><EFBFBD><EFBFBD>
CDlgChildEventLog::CDlgChildEventLog(CWnd* pParent /*=NULL*/)
: CMyDlgView(CDlgChildEventLog::IDD, pParent)
{
m_bStopRevLog = false;//<2F><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>log (<28><>Ӱ<EFBFBD><D3B0>log <20><><EFBFBD><EFBFBD>ļ<EFBFBD>)
}
CDlgChildEventLog::~CDlgChildEventLog()
{
}
void CDlgChildEventLog::DoDataExchange(CDataExchange* pDX)
{
CMyDlgView::DoDataExchange(pDX);
DDX_Control(pDX, NEW_REV_LOG_LIST, m_LaipuLaserLogList);
DDX_Control(pDX, NEW_LAIPU_DRAWING_LOG_LIST, m_LaipuDrawingLogList);
DDX_Control(pDX, IDC_LOG_TYPE_COMBO, m_SelLogTypeComb);
}
BOOL CDlgChildEventLog::OnInitDialog()
{
CMyDlgView::OnInitDialog();
InitLogList(m_LaipuLaserLogList);
InitLogList(m_LaipuDrawingLogList);
//<2F><>ʼ<EFBFBD><CABC>SelLogTypeComb
m_SelLogTypeComb.InsertString(0,"LaipuLaser");
m_SelLogTypeComb.InsertString(1,"LaipuDrawing");
m_SelLogTypeComb.SetCurSel(0);
m_CurLogListType = _LogListType_LaipuLaser;
UpdateData(FALSE);
return TRUE;
}
//<2F><>Ӧview <20>򿪵<EFBFBD>ʱ<EFBFBD><CAB1>
void CDlgChildEventLog::OnViewOpen()
{
}
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>־<EFBFBD>б<EFBFBD>
void CDlgChildEventLog::InitLogList(CListCtrl &List)
{
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int idx = 0;
List.InsertColumn(idx,"LOG",LVCFMT_LEFT,2000,-1);
idx++;
}
CListCtrl &CDlgChildEventLog::GetLogList(eLogListType LogListType)
{
if(LogListType==_LogListType_LaipuLaser)
return m_LaipuLaserLogList;
return m_LaipuDrawingLogList;
}
void CDlgChildEventLog::InsertLogToList(CString &LogStr,eLogListType LogListType)
{
if(!m_bStopRevLog)
{
InsertLogToListExt(LogStr,GetLogList(LogListType));
}
}
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>log
void CDlgChildEventLog::InsertLogToListExt(CString &LogStr,CListCtrl &List)
{
int CurItemCount = List.GetItemCount();//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(CurItemCount>=MAX_LOG_LIST_ROWS)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
{
List.DeleteItem(0);
CurItemCount--;
}
//<2F>²<EFBFBD><C2B2><EFBFBD>һ<EFBFBD><D2BB>
int idx = CurItemCount;
List.InsertItem(idx," ");//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
List.SetItemText(idx,0,LogStr);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
List.EnsureVisible(idx,FALSE);
}
void CDlgChildEventLog::OnBnClickedClearListBtn()
{
CListCtrl &List = GetLogList(m_CurLogListType);
List.DeleteAllItems();
gLogMgr->WriteDebugLog("Func---->OnBnClickedClearListBtn");
}
void CDlgChildEventLog::OnBnClickedOpenLogDirBtn()
{
gLogMgr->WriteDebugLog("Func---->OnBnClickedOpenLogDirBtn");
CString DirPath;
if(m_CurLogListType==_LogListType_LaipuLaser)
DirPath = gProgramLaserTuiHuo->GetLaipuLaserDataDir("\\LogFile\\");
else
DirPath = gProgramLaserTuiHuo->GetLaipuLaserDataDir("\\LogFile_DataMgr\\");
CFileMgr FileMgr;
FileMgr.OpenDir(DirPath);
}
void CDlgChildEventLog::OnCbnSelchangeLogTypeCombo()
{
gLogMgr->WriteDebugLog("Func---->OnCbnSelchangeLogTypeCombo");
int idx = m_SelLogTypeComb.GetCurSel();
if(idx==1)
{
GetDlgItem(NEW_REV_LOG_LIST)->ShowWindow(SW_HIDE);
GetDlgItem(NEW_LAIPU_DRAWING_LOG_LIST)->ShowWindow(SW_SHOW);
m_CurLogListType = _LogListType_LaipuDrawing;
}
else
{
GetDlgItem(NEW_REV_LOG_LIST)->ShowWindow(SW_SHOW);
GetDlgItem(NEW_LAIPU_DRAWING_LOG_LIST)->ShowWindow(SW_HIDE);
m_CurLogListType = _LogListType_LaipuLaser;
}
}
void CDlgChildEventLog::OnBnClickedStopRevLogBtn()
{
gLogMgr->WriteDebugLog("Func---->OnBnClickedStopRevLogBtn");
m_bStopRevLog = !m_bStopRevLog;
if(m_bStopRevLog)
GetDlgItem(IDC_STOP_REV_LOG_BTN)->SetWindowText("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
else
GetDlgItem(IDC_STOP_REV_LOG_BTN)->SetWindowText("<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}