485 lines
14 KiB
C++
485 lines
14 KiB
C++
// appdatatdlistview.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "appdatatdlistview.h"
|
|
#include "Constant.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
int g_iUILang = (int)LANG_ENUS;
|
|
extern int g_iCurrListColIndex;
|
|
extern int g_iCurrListColOrder;
|
|
extern int CALLBACK ListStrCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lSortObject);
|
|
extern int g_UIOffset;
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAppDataTdListView
|
|
|
|
IMPLEMENT_DYNCREATE(CAppDataTdListView, CListView)
|
|
|
|
CAppDataTdListView::CAppDataTdListView()
|
|
{
|
|
|
|
}
|
|
|
|
CAppDataTdListView::~CAppDataTdListView()
|
|
{
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAppDataTdListView, CListView)
|
|
//{{AFX_MSG_MAP(CAppDataTdListView)
|
|
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
|
|
ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
|
|
//}}AFX_MSG_MAP
|
|
ON_NOTIFY_REFLECT(NM_RCLICK, OnNMRClickList)
|
|
ON_COMMAND(IDM_SELECT_ALL, OnSelectAll)
|
|
ON_COMMAND(IDM_CANCEL_SELECT, OnCancelSelect)
|
|
ON_COMMAND(IDM_Batch_export, OnBatchexport)
|
|
ON_COMMAND(IDM_BATCH_DEL_DATA, OnBatchDelData)
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAppDataTdListView drawing
|
|
|
|
void CAppDataTdListView::OnDraw(CDC* pDC)
|
|
{
|
|
CDocument* pDoc = GetDocument();
|
|
// TODO: add draw code here
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAppDataTdListView diagnostics
|
|
|
|
#ifdef _DEBUG
|
|
void CAppDataTdListView::AssertValid() const
|
|
{
|
|
CListView::AssertValid();
|
|
}
|
|
|
|
void CAppDataTdListView::Dump(CDumpContext& dc) const
|
|
{
|
|
CListView::Dump(dc);
|
|
}
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAppDataTdListView message handlers
|
|
|
|
BOOL CAppDataTdListView::PreCreateWindow(CREATESTRUCT& cs)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
cs.style &= ~LVS_TYPEMASK;
|
|
cs.style |= LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS;
|
|
return CListView::PreCreateWindow(cs);
|
|
}
|
|
|
|
void CAppDataTdListView::OnInitialUpdate()
|
|
{
|
|
CListView::OnInitialUpdate();
|
|
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
CString strColTitle;
|
|
int iColIndex = (int)VAL_ZERO;
|
|
|
|
|
|
m_pMngFrm = (CMDIChildWnd*)GetParentFrame();
|
|
/*
|
|
if (m_pMngFrm->IsKindOf(RUNTIME_CLASS(CDataMngFrame)))
|
|
{
|
|
GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
|
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES);
|
|
}
|
|
else
|
|
{
|
|
GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
|
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
|
}
|
|
*/
|
|
GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
|
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
|
|
|
g_iCurrListColIndex = (int)VAL_ZERO;
|
|
g_iCurrListColOrder = (int)VAL_ZERO;
|
|
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TDNAME+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 150);
|
|
|
|
// iColIndex++;
|
|
// strColTitle.Empty();
|
|
// strColTitle.LoadString(IDS_DB_TD_TLOCATION);
|
|
// GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_DESN+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_SCCN+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_SNAME+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_STYPE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TTYPE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TMODE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_EAMOUNT+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TPAMOUNT+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CHAMOUNT+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_N+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TRWAVE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TRFREQUENCY+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_IFREQUENCY+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_SAFREQUENCY+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CLAYOUT+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_ESPACE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_EDISTANCE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_WEATHER+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_WDIR+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TEMPERATURE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_HEIGHT+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_HUMIDITY+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CDATE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CTIME+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TDATE+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_TTIME+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_RDIRECTION+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_CRTIME+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_PM+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_OP+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_TD_QA+g_UIOffset);
|
|
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
|
}
|
|
|
|
void CAppDataTdListView::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
|
// TODO: Add your control notification handler code here
|
|
g_iCurrListColIndex = pNMListView->iSubItem;
|
|
g_iCurrListColOrder = !g_iCurrListColOrder;
|
|
GetListCtrl().SortItems(ListStrCompare, (LPARAM)&GetListCtrl());
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CAppDataTdListView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int iItemIndex = (int)VAL_ZERO;
|
|
POSITION posItem = NULL;
|
|
DWORD dwItemHandle = (DWORD)VAL_ZERO;
|
|
|
|
posItem = GetListCtrl().GetFirstSelectedItemPosition();
|
|
iItemIndex = GetListCtrl().GetNextSelectedItem(posItem);
|
|
|
|
if ((int)VAL_MINUS_ONE != iItemIndex)
|
|
{
|
|
dwItemHandle = GetListCtrl().GetItemData(iItemIndex);
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_SKIP, (WPARAM )dwItemHandle, (LPARAM)VAL_ZERO);
|
|
}
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
//add Batch export task by quyx 20180530
|
|
void CAppDataTdListView::OnNMRClickList(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
|
//if (pNMListView->iItem != -1)
|
|
{
|
|
DWORD dwPos = GetMessagePos();
|
|
CPoint point(LOWORD(dwPos), HIWORD(dwPos));
|
|
|
|
CMenu menu;
|
|
VERIFY(menu.LoadMenu(IDR_TASK_BATCH_EXPORT));
|
|
|
|
CMenu* popup = menu.GetSubMenu(0);
|
|
ASSERT(popup != NULL);
|
|
popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
void CAppDataTdListView::OnSelectAll()
|
|
{
|
|
// TODO: 在此添加命令处理程序代码
|
|
for (int i = 0; i < GetListCtrl().GetItemCount(); i++)
|
|
{
|
|
GetListCtrl().SetCheck(i);
|
|
}
|
|
}
|
|
|
|
|
|
void CAppDataTdListView::OnCancelSelect()
|
|
{
|
|
// TODO: 在此添加命令处理程序代码
|
|
for (int i = 0; i < GetListCtrl().GetItemCount(); i++)
|
|
{
|
|
GetListCtrl().SetCheck(i, FALSE);
|
|
}
|
|
}
|
|
|
|
void CAppDataTdListView::OnBatchDelData()
|
|
{
|
|
// TODO: 在此添加命令处理程序代码
|
|
CString szCaption;
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_OP_LD_TD_SEL + g_UIOffset);
|
|
int nRet = 0;
|
|
if (OFFSET_ENGLISH == g_UIOffset)
|
|
nRet = AfxMessageBox(szCaption, MB_YESNO | MB_ICONQUESTION);
|
|
else
|
|
nRet = MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_YESNO | MB_ICONQUESTION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
if (IDYES != nRet)
|
|
{
|
|
return;
|
|
}
|
|
int nItemCount = GetListCtrl().GetItemCount();
|
|
int index = 0;
|
|
CString strTaskName;
|
|
int iFirstFlag = 0;
|
|
int iExportNum = 0;
|
|
char str[30];
|
|
CProgressCtrl m_prog;
|
|
CStatic *m_pStatic = new CStatic;
|
|
|
|
for (index = 0; index < nItemCount; index++)
|
|
{
|
|
if (0 == index)
|
|
{
|
|
m_prog.Create(WS_VISIBLE, CRect(200, 0, 800, 20), this, 8000);// | WS_CHILD | PBS_SMOOTH
|
|
m_prog.SetRange32(0, nItemCount);
|
|
if (LANG_ZHCN == g_iUILang)
|
|
{
|
|
m_pStatic->Create(_T("删除任务中 ......"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 200, 20), this, 8001);
|
|
}
|
|
else
|
|
{
|
|
m_pStatic->Create(_T("Delete task ......"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 200, 20), this, 8001);
|
|
}
|
|
//m_pStatic->SetBkMode(TRANSPARENT); //设置字体背景为透明
|
|
}
|
|
|
|
if (GetListCtrl().GetCheck(index))//判断该行是否被选中
|
|
{
|
|
DWORD dwItemHandle = (DWORD)VAL_ZERO;
|
|
dwItemHandle = GetListCtrl().GetItemData(index);
|
|
if (0 == iFirstFlag)
|
|
{
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_MSG_BATCH_DEL_TD_FILE, (WPARAM)dwItemHandle, (LPARAM)VAL_ZERO);
|
|
}
|
|
else
|
|
{
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_MSG_BATCH_DEL_TD_FILE, (WPARAM)dwItemHandle, (LPARAM)VAL_ONE);
|
|
}
|
|
iFirstFlag++;
|
|
iExportNum++;
|
|
|
|
if (LANG_ZHCN == g_iUILang)
|
|
{
|
|
sprintf(str, "删除第 %d 个任务中 ......", iExportNum);
|
|
}
|
|
else
|
|
{
|
|
sprintf(str, "Delete the %d task ......", iExportNum);
|
|
}
|
|
m_pStatic->SetWindowTextA(str);
|
|
m_prog.SetPos(index);
|
|
m_prog.ShowWindow(SW_SHOW);
|
|
}
|
|
}
|
|
m_prog.SetPos(index);
|
|
m_prog.ShowWindow(SW_SHOW);
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_MSG_BATCH_DEL_TD_FILE, NULL, (LPARAM)VAL_MINUS_ONE);
|
|
delete m_pStatic;
|
|
|
|
{
|
|
::SendMessage(m_pMngFrm->m_hWnd, WM_REFRESH_CONLIST, (WPARAM)VAL_ZERO, (LPARAM)VAL_ZERO);
|
|
::SendMessage(m_pMngFrm->m_hWnd, WM_REFRESH, (WPARAM)OP_TD_REMOVE, (LPARAM)VAL_ZERO);
|
|
}
|
|
}
|
|
//add Batch export task by quyx 20180530
|
|
void CAppDataTdListView::OnBatchexport()
|
|
{
|
|
// TODO: 在此添加命令处理程序代码
|
|
int nItemCount = GetListCtrl().GetItemCount();
|
|
int index = 0;
|
|
CString strTaskName;
|
|
int iFirstFlag = 0;
|
|
int iExportNum = 0;
|
|
char str[30];
|
|
CProgressCtrl m_prog;
|
|
CStatic *m_pStatic = new CStatic;
|
|
|
|
for (index = 0; index < nItemCount; index++)
|
|
{
|
|
if (0 == index)
|
|
{
|
|
m_prog.Create(WS_VISIBLE, CRect(200, 0, 800, 20), this, 8000);// | WS_CHILD | PBS_SMOOTH
|
|
m_prog.SetRange32(0, nItemCount);
|
|
if (LANG_ZHCN == g_iUILang)
|
|
{
|
|
m_pStatic->Create(_T("导出任务中 ......"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 200, 20), this, 8001);
|
|
}
|
|
else
|
|
{
|
|
m_pStatic->Create(_T("Export task ......"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 200, 20), this, 8001);
|
|
}
|
|
//m_pStatic->SetBkMode(TRANSPARENT); //设置字体背景为透明
|
|
}
|
|
|
|
if (GetListCtrl().GetCheck(index))//判断该行是否被选中
|
|
{
|
|
DWORD dwItemHandle = (DWORD)VAL_ZERO;
|
|
dwItemHandle = GetListCtrl().GetItemData(index);
|
|
if (0 == iFirstFlag)
|
|
{
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_MSG_BATCH_EXPORT_FILE, (WPARAM)dwItemHandle, (LPARAM)VAL_ZERO);
|
|
}
|
|
else
|
|
{
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_MSG_BATCH_EXPORT_FILE, (WPARAM)dwItemHandle, (LPARAM)VAL_ONE);
|
|
}
|
|
iFirstFlag++;
|
|
iExportNum++;
|
|
|
|
if (LANG_ZHCN == g_iUILang)
|
|
{
|
|
sprintf(str, "导出第 %d 个任务中 ......", iExportNum);
|
|
}
|
|
else
|
|
{
|
|
sprintf(str, "Export the %d task ......", iExportNum);
|
|
}
|
|
m_pStatic->SetWindowTextA(str);
|
|
m_prog.SetPos(index);
|
|
m_prog.ShowWindow(SW_SHOW);
|
|
}
|
|
}
|
|
m_prog.SetPos(index);
|
|
m_prog.ShowWindow(SW_SHOW);
|
|
::SendMessage(GetParentFrame()->m_hWnd, WM_MSG_BATCH_EXPORT_FILE, NULL,(LPARAM)VAL_MINUS_ONE);
|
|
delete m_pStatic;
|
|
}
|
|
|