354 lines
10 KiB
C++
354 lines
10 KiB
C++
// opsynsptdlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "opsynsptdlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
extern CGeoMativeApp theApp;
|
|
|
|
BEGIN_EASYSIZE_MAP(COpSynSptDlg)
|
|
|
|
EASYSIZE(IDC_STATIC_LOCAL, ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
|
|
EASYSIZE(IDC_LIST_SYN_LOCSPT, ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
|
|
|
|
EASYSIZE(IDC_SPT_DOWNLOAD, ES_BORDER,IDC_LIST_SYN_LOCSPT,ES_KEEPSIZE,ES_KEEPSIZE,0)
|
|
EASYSIZE(IDC_SPT_UPLOAD, IDC_SPT_DOWNLOAD,IDC_LIST_SYN_LOCSPT,ES_KEEPSIZE,ES_KEEPSIZE,0)
|
|
|
|
EASYSIZE(IDC_STATIC_DEVICE, ES_BORDER,IDC_SPT_UPLOAD,ES_BORDER,ES_BORDER,0)
|
|
EASYSIZE(IDC_LIST_SYN_HOSTSPT, ES_BORDER,IDC_STATIC_DEVICE,ES_BORDER,ES_BORDER,0)
|
|
|
|
EASYSIZE(IDC_SPT_DEL, IDC_LIST_SYN_HOSTSPT,IDC_STATIC_DEVICE,ES_KEEPSIZE,ES_KEEPSIZE,0)
|
|
|
|
END_EASYSIZE_MAP
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpSynSptDlg dialog
|
|
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
extern int g_UIOffset;
|
|
extern int g_iUILanguage;
|
|
COpSynSptDlg::COpSynSptDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(COpSynSptDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(COpSynSptDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
|
|
m_pDev = NULL;
|
|
}
|
|
|
|
|
|
void COpSynSptDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(COpSynSptDlg)
|
|
DDX_Control(pDX, IDC_LIST_SYN_LOCSPT, m_locSptList);
|
|
DDX_Control(pDX, IDC_LIST_SYN_HOSTSPT, m_hostSptList);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpSynSptDlg, CDialog)
|
|
//{{AFX_MSG_MAP(COpSynSptDlg)
|
|
ON_BN_CLICKED(IDC_SPT_DOWNLOAD, OnSptDownload)
|
|
ON_BN_CLICKED(IDC_SPT_UPLOAD, OnSptUpload)
|
|
ON_BN_CLICKED(IDC_SPT_DEL, OnSptDel)
|
|
ON_WM_SIZE()
|
|
ON_WM_PAINT()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpSynSptDlg message handlers
|
|
|
|
BOOL COpSynSptDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: Add extra initialization here
|
|
InitULByLanguage(g_iUILanguage);
|
|
CString strColTitle;
|
|
int iColIndex = (int)VAL_ZERO;
|
|
|
|
iColIndex = (int)VAL_ZERO;
|
|
m_locSptList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
|
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
|
|
|
// strColTitle.Empty();
|
|
// strColTitle.LoadString(IDS_DB_SCON_CN);
|
|
// m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 220);
|
|
// iColIndex++;
|
|
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_SNAME+g_UIOffset);
|
|
// strColTitle = _T("Script name");
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 133);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_STYPE+g_UIOffset);
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_EAMOUNT+g_UIOffset);
|
|
// strColTitle=_T("Electrode number");
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_TPAMOUNT+g_UIOffset);
|
|
// strColTitle = _T("Point number");
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_DEFINER+g_UIOffset);
|
|
// strColTitle = _T("Operator");
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_DEDATE+g_UIOffset);
|
|
// strColTitle = _T("Create date");
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_DESC+g_UIOffset);
|
|
// strColTitle = _T("Remark");
|
|
m_locSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex = (int)VAL_ZERO;
|
|
m_hostSptList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
|
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES /*| LVS_EX_CHECKBOXES*/);
|
|
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_SYN_ISSYNED+g_UIOffset);
|
|
m_hostSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 110);
|
|
iColIndex++;
|
|
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_SNAME+g_UIOffset);
|
|
// strColTitle = _T("Script name");
|
|
m_hostSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 133);
|
|
iColIndex++;
|
|
|
|
// strColTitle.Empty();
|
|
// strColTitle.LoadString(IDS_DB_SCON_CN);
|
|
// m_hostSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 220);
|
|
// iColIndex++;
|
|
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SCON_STYPE+g_UIOffset);
|
|
m_hostSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
|
|
|
iColIndex++;
|
|
strColTitle.Empty();
|
|
strColTitle.LoadString(IDS_DB_SFILE_SFNAME+g_UIOffset);
|
|
m_hostSptList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 250);
|
|
|
|
INIT_EASYSIZE;
|
|
GetDlgItem(IDC_SPT_UPLOAD)->ShowWindow(SW_HIDE);
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void COpSynSptDlg::OnSptDownload()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
CString strLog;
|
|
int iItemIndex = (int)VAL_ZERO;
|
|
POSITION pos = m_locSptList.GetFirstSelectedItemPosition();
|
|
if (pos == NULL)
|
|
OutputDebugString(_T("No items were selected!\n"));
|
|
else
|
|
{
|
|
while (pos)
|
|
{
|
|
iItemIndex = m_locSptList.GetNextSelectedItem(pos);
|
|
m_iSelSCID = m_locSptList.GetItemData(iItemIndex);
|
|
|
|
strLog.Format(_T("iItemIndex=%d,脚本名%s\n"), iItemIndex, m_locSptList.GetItemText(iItemIndex, 0));
|
|
OutputDebugString(strLog);
|
|
if (NULL != theApp.m_pSptManager)
|
|
{
|
|
theApp.m_pSptManager->PutScriptToDev(m_iSelSCID, m_pDev);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (IsWindow(m_hWnd) && m_pDev)
|
|
{
|
|
theApp.m_pSptManager->InitialSptList(m_locSptList);
|
|
theApp.m_pSptManager->InitialSptListForDev(m_hostSptList, m_pDev->m_szDevSN);
|
|
}
|
|
}
|
|
|
|
UINT COpSynSptDlg::DownloadScriptToGDDeviceThread(LPVOID lpParam)
|
|
{
|
|
COpSynSptDlg* pThis = (COpSynSptDlg*)lpParam;
|
|
if (NULL != theApp.m_pSptManager)
|
|
{
|
|
theApp.m_pSptManager->PutScriptToDev(pThis->m_iSelSCID, pThis->m_pDev);
|
|
if (IsWindow(pThis->m_hWnd) && pThis->m_pDev)
|
|
{
|
|
theApp.m_pSptManager->InitialSptList(pThis->m_locSptList);
|
|
theApp.m_pSptManager->InitialSptListForDev(pThis->m_hostSptList, pThis->m_pDev->m_szDevSN);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void COpSynSptDlg::OnSptUpload()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
|
|
int iItemIndex = (int)VAL_ZERO;
|
|
CString szSptFileName = _T("");
|
|
POSITION pos = NULL;
|
|
|
|
pos = m_hostSptList.GetFirstSelectedItemPosition();
|
|
while (pos)
|
|
{
|
|
iItemIndex = m_hostSptList.GetNextSelectedItem(pos);
|
|
|
|
szSptFileName = m_hostSptList.GetItemText(iItemIndex, 3);
|
|
|
|
if (APP_SUCCESS == theApp.m_pSptManager->LoadScriptFromDev(szSptFileName, this->m_pDev))
|
|
{
|
|
// if (TRUE == m_hostSptList.GetCheck(iItemIndex))
|
|
// {
|
|
// if (FALSE == theApp.m_pSptManager->DeleteSConInDev(szSptFileName.Left(35), m_pDev))
|
|
// {
|
|
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// MessageBox(_T("Delete script failed!"));
|
|
// }
|
|
// }
|
|
::SendMessage(AfxGetMainWnd()->m_hWnd, WM_REFRESH, (WPARAM)OP_SPT_SYN, (LPARAM)VAL_ZERO);
|
|
this->m_hostSptList.SetItemText(iItemIndex, 0, _T("Yes"));
|
|
}
|
|
}
|
|
|
|
if (this->m_pDev)
|
|
{
|
|
theApp.m_pSptManager->InitialSptList(m_locSptList);
|
|
theApp.m_pSptManager->InitialSptListForDev(m_hostSptList, this->m_pDev->m_szDevSN);
|
|
}
|
|
}
|
|
|
|
void COpSynSptDlg::OnSptDel()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
int iItemIndex = (int)VAL_ZERO;
|
|
CString szSptFileName = _T("");
|
|
POSITION pos = NULL;
|
|
|
|
pos = m_hostSptList.GetFirstSelectedItemPosition();
|
|
if (pos)
|
|
{
|
|
int nRet = 0;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
nRet = MessageBoxEx(NULL, _T("是否要删除脚本?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO | MB_ICONINFORMATION, MAKELANGID(LANG_CHINESE_SIMPLIFIED,SUBLANG_CHINESE_SINGAPORE));
|
|
}
|
|
else
|
|
{
|
|
nRet = MessageBoxEx(NULL, _T("Do you want to delete script?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO | MB_ICONINFORMATION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
|
|
}
|
|
if (IDYES != nRet)
|
|
{
|
|
CString strLog;
|
|
strLog.Format(_T("IDYES(%d) != nRet(%d), delete cancel"), IDYES, nRet);
|
|
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
|
return;
|
|
}
|
|
}
|
|
while (pos)
|
|
{
|
|
iItemIndex = m_hostSptList.GetNextSelectedItem(pos);
|
|
szSptFileName = m_hostSptList.GetItemText(iItemIndex, 3);
|
|
|
|
// if (TRUE == this->m_hostSptList.GetCheck(iItemIndex))
|
|
// {
|
|
if (FALSE == theApp.m_pSptManager->DeleteSConInDev(szSptFileName.Left(35), m_pDev))
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
MessageBox(_T("删除脚本失败!"));
|
|
else
|
|
MessageBox(_T("Delete script failed!"));
|
|
}
|
|
// }
|
|
}
|
|
|
|
if (this->m_pDev)
|
|
{
|
|
theApp.m_pSptManager->InitialSptList(m_locSptList);
|
|
theApp.m_pSptManager->InitialSptListForDev(m_hostSptList, this->m_pDev->m_szDevSN);
|
|
}
|
|
}
|
|
|
|
BOOL COpSynSptDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void COpSynSptDlg::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDialog::OnSize(nType, cx, cy);
|
|
UPDATE_EASYSIZE;
|
|
// TODO: Add your message handler code here
|
|
|
|
}
|
|
|
|
void COpSynSptDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
// TODO: Add your message handler code here
|
|
// CRect rect;
|
|
// GetDlgItem()GetClientRect(&rect);
|
|
// CDC dcMem;
|
|
// dcMem.CreateCompatibleDC(&dc);
|
|
// CBitmap bmpBackground;
|
|
// bmpBackground.LoadBitmap(IDB_BITMAP);
|
|
// //IDB_BITMAP是你自己的图对应的ID
|
|
// BITMAP bitmap;
|
|
// bmpBackground.GetBitmap(&bitmap);
|
|
// CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
|
|
// dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,
|
|
// bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);
|
|
// Do not call CDialog::OnPaint() for painting messages
|
|
}
|
|
|
|
void COpSynSptDlg::InitULByLanguage(int iLanguage)
|
|
{
|
|
if (LANG_ZHCN == iLanguage)
|
|
{
|
|
GetDlgItem(IDC_STATIC_LOCAL)->SetWindowText(_T("Geomative Studio中的脚本"));
|
|
GetDlgItem(IDC_STATIC_DEVICE)->SetWindowText(_T("主机设备中的脚本"));
|
|
GetDlgItem(IDC_SPT_DOWNLOAD)->SetWindowText(_T("下发"));
|
|
GetDlgItem(IDC_SPT_DEL)->SetWindowText(_T("删除\r\n脚本"));
|
|
}
|
|
}
|