230 lines
8.6 KiB
C++
230 lines
8.6 KiB
C++
// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingSymbolEditor.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "GeoMative.h"
|
|
#include "logging\CLoggingDataOper.h"
|
|
#include "logging\CDialogLoggingSymbolEditor.h"
|
|
#include "logging\CDialogLoggingEditSymbolBoard.h"
|
|
#include "afxdialogex.h"
|
|
|
|
extern CGeoMativeApp theApp;
|
|
// CDialogLoggingSymbolEditor 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(CDialogLoggingSymbolEditor, CDialog)
|
|
|
|
CDialogLoggingSymbolEditor::CDialogLoggingSymbolEditor(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CDialogLoggingSymbolEditor::IDD, pParent)
|
|
{
|
|
|
|
}
|
|
|
|
CDialogLoggingSymbolEditor::~CDialogLoggingSymbolEditor()
|
|
{
|
|
}
|
|
|
|
void CDialogLoggingSymbolEditor::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST_LITHOLOGY_NAME, m_listLithologyName);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDialogLoggingSymbolEditor, CDialog)
|
|
ON_BN_CLICKED(IDC_BTN_UPDATE, &CDialogLoggingSymbolEditor::OnBnClickedBtnUpdate)
|
|
ON_BN_CLICKED(IDC_BTN_ADD, &CDialogLoggingSymbolEditor::OnBnClickedBtnAdd)
|
|
ON_BN_CLICKED(IDC_BTN_DELETE, &CDialogLoggingSymbolEditor::OnBnClickedBtnDelete)
|
|
ON_BN_CLICKED(IDCANCEL, &CDialogLoggingSymbolEditor::OnBnClickedCancel)
|
|
ON_NOTIFY(NM_CLICK, IDC_LIST_LITHOLOGY_NAME, &CDialogLoggingSymbolEditor::OnNMClickListLithologyName)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CDialogLoggingSymbolEditor 消息处理程序
|
|
BOOL CDialogLoggingSymbolEditor::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
RECT rcList;
|
|
m_listLithologyName.GetClientRect(&rcList);
|
|
DWORD dwStyle = m_listLithologyName.GetExtendedStyle();
|
|
dwStyle |= LVS_EX_FULLROWSELECT;
|
|
m_listLithologyName.SetExtendedStyle(dwStyle);
|
|
m_listLithologyName.InsertColumn(0, _T(""), LVCFMT_LEFT, rcList.right - rcList.left);
|
|
m_listLithologyName.InsertColumn(1, _T(""), LVCFMT_LEFT, 0);//用于保存图片路径
|
|
m_listLithologyName.InsertColumn(2, _T(""), LVCFMT_LEFT, 0);//用于保存岩性类型
|
|
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
SetWindowText(_T("字符编辑器"));
|
|
SetDlgItemText(IDC_STATIC_EDITOR, _T("编辑"));
|
|
SetDlgItemText(IDC_STATIC_LITHOLOGY_NAME, _T("岩性名称"));
|
|
SetDlgItemText(IDC_BTN_UPDATE, _T("更新"));
|
|
SetDlgItemText(IDC_BTN_ADD, _T("添加"));
|
|
SetDlgItemText(IDC_BTN_DELETE, _T("删除"));
|
|
SetDlgItemText(IDCANCEL, _T("关闭"));
|
|
}
|
|
|
|
((CEdit*)GetDlgItem(IDC_EDIT_LITHOLOGY_NAME))->SetLimitText(20);
|
|
|
|
// TODO: 在此添加额外的初始化
|
|
QueryLithologyNameFromDB();
|
|
|
|
RECT rcPic,rcDrawBoard;
|
|
GetDlgItem(IDC_STATIC_PIC_SYMBOL_EDITROR)->GetClientRect(&rcPic);
|
|
rcDrawBoard = rcPic;
|
|
CDialogLoggingEditSymbolBoard::GetInstance()->Create(IDD_DIALOG_LOGGING_EDIT_SYMBOL_BOARD, GetDlgItem(IDC_STATIC_PIC_SYMBOL_EDITROR));
|
|
rcDrawBoard.left = rcDrawBoard.left + (rcPic.right - rcPic.left - GRID_SIZE*GRID_X_DIRECTION_SIZE) / 2;
|
|
rcDrawBoard.right = rcDrawBoard.left + GRID_SIZE*GRID_X_DIRECTION_SIZE+1;
|
|
rcDrawBoard.top = rcDrawBoard.top + (rcPic.bottom - rcPic.top - GRID_SIZE*GRID_Y_DIRECTION_SIZE) / 2;
|
|
rcDrawBoard.bottom = rcDrawBoard.top + GRID_SIZE*GRID_Y_DIRECTION_SIZE+1;
|
|
CDialogLoggingEditSymbolBoard::GetInstance()->MoveWindow(&rcDrawBoard);
|
|
CDialogLoggingEditSymbolBoard::GetInstance()->ShowWindow(SW_SHOW);
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
}
|
|
|
|
void CDialogLoggingSymbolEditor::OnBnClickedBtnUpdate()
|
|
{
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
int iSelItem = m_listLithologyName.GetSelectionMark();
|
|
if (iSelItem != -1)
|
|
{
|
|
CString strLithologyName,strLithologyPic,strLithologyType;
|
|
GetDlgItemText(IDC_EDIT_LITHOLOGY_NAME, strLithologyName);
|
|
if (strLithologyName.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("岩性名称为空"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Lithology name is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
//通知符号编辑窗口保存图片,是否需要删除图片
|
|
strLithologyPic = m_listLithologyName.GetItemText(iSelItem, 1);
|
|
strLithologyType = m_listLithologyName.GetItemText(iSelItem, 2);
|
|
if (CLoggingDataOper::GetInstance()->DeleteDBLithologyBitmap(strLithologyType))
|
|
{
|
|
strLithologyPic = CDialogLoggingEditSymbolBoard::GetInstance()->SaveLithologyBitmap(strLithologyType, strLithologyName);
|
|
m_listLithologyName.SetItemText(iSelItem, 0, strLithologyName);
|
|
m_listLithologyName.SetItemText(iSelItem, 1, strLithologyPic);
|
|
m_listLithologyName.SetItemText(iSelItem, 2, strLithologyType);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void CDialogLoggingSymbolEditor::OnBnClickedBtnAdd()
|
|
{
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
CString strLithologyName, strLithologyType;
|
|
GetDlgItemText(IDC_EDIT_LITHOLOGY_NAME, strLithologyName);
|
|
if (strLithologyName.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("岩性名称为空"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Lithology name is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
|
|
int iItemCount = m_listLithologyName.GetItemCount();
|
|
m_listLithologyName.InsertItem(iItemCount, _T(""));
|
|
m_listLithologyName.SetItemText(iItemCount, 0, strLithologyName);
|
|
|
|
//通知符号编辑窗口保存图片
|
|
CGUCodeCreator guCodeCreator;
|
|
strLithologyType = guCodeCreator.GenerateGUIDCode();
|
|
CString strLithologyPic = CDialogLoggingEditSymbolBoard::GetInstance()->SaveLithologyBitmap(strLithologyType, strLithologyName);
|
|
m_listLithologyName.SetItemText(iItemCount, 1, strLithologyPic);
|
|
m_listLithologyName.SetItemText(iItemCount, 2, strLithologyType);
|
|
}
|
|
|
|
|
|
void CDialogLoggingSymbolEditor::OnBnClickedBtnDelete()
|
|
{
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
int nItem = -1;
|
|
CString strLithologyType,strLithologyPicPath;
|
|
while (m_listLithologyName.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED) != -1)
|
|
{
|
|
nItem = m_listLithologyName.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
|
|
|
|
//通知符号编辑窗口删除岩性图片
|
|
strLithologyPicPath = m_listLithologyName.GetItemText(nItem, 1);
|
|
strLithologyType = m_listLithologyName.GetItemText(nItem, 2);
|
|
CDialogLoggingEditSymbolBoard::GetInstance()->DeleteLithologyBitmap(strLithologyType, strLithologyPicPath);
|
|
|
|
m_listLithologyName.DeleteItem(nItem);
|
|
}
|
|
}
|
|
|
|
|
|
void CDialogLoggingSymbolEditor::OnBnClickedCancel()
|
|
{
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
/*try
|
|
{
|
|
CString strSql = _T("");
|
|
//清除数据库
|
|
_CommandPtr pCmdIns = NULL;
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
// strSql.Format(_T("delete from TLithologyName where LanguageID=%d"), g_iUILanguage);
|
|
// pCmdIns->CommandText = strSql.AllocSysString();
|
|
// pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
//插入数据
|
|
//_RecordsetPtr pRecTd = NULL;
|
|
//pRecTd.CreateInstance(_uuidof(Recordset));
|
|
CString strLithologyName,strLithologyPic,strLithologyType;
|
|
int iItemCount = m_listLithologyName.GetItemCount();
|
|
for (int iIndex = 0; iIndex < iItemCount; iIndex++)
|
|
{
|
|
strLithologyName = m_listLithologyName.GetItemText(iIndex, 0);
|
|
strLithologyPic = m_listLithologyName.GetItemText(iIndex, 1);
|
|
strLithologyType = m_listLithologyName.GetItemText(iIndex, 2);
|
|
strSql.Format(_T("insert into TLithologyName(LithologyType,LithologyName,LithologyPic,LanguageID) values('%s','%s','%s',%d)"), strLithologyType, strLithologyName, strLithologyPic, g_iUILanguage);
|
|
pCmdIns->CommandText = strSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
}
|
|
catch (CException* e)
|
|
{
|
|
AfxMessageBox(e->ReportError());
|
|
}*/
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
void CDialogLoggingSymbolEditor::OnNMClickListLithologyName(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
CString strLithologyName = m_listLithologyName.GetItemText(pNMItemActivate->iItem, 0);
|
|
SetDlgItemText(IDC_EDIT_LITHOLOGY_NAME, strLithologyName);
|
|
|
|
CString strLithologyPic = m_listLithologyName.GetItemText(pNMItemActivate->iItem, 1);
|
|
CDialogLoggingEditSymbolBoard::GetInstance()->LoadLithologyBitmap(strLithologyPic);
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CDialogLoggingSymbolEditor::QueryLithologyNameFromDB()
|
|
{
|
|
m_listLithologyName.DeleteAllItems();
|
|
|
|
map<CString, STLoggingLithologyInfo> mapLithologyInfo = CLoggingDataOper::GetInstance()->QueryLithologyInfo();
|
|
int iItemCount = mapLithologyInfo.size();
|
|
if (iItemCount > 0)
|
|
{
|
|
map<CString, STLoggingLithologyInfo>::iterator iter = mapLithologyInfo.begin();
|
|
for (int i = 0; iter != mapLithologyInfo.end(), i < iItemCount; iter++,i++)
|
|
{
|
|
m_listLithologyName.InsertItem(i, _T(""));
|
|
m_listLithologyName.SetItemText(i, 0, iter->second.szLithologyName);
|
|
m_listLithologyName.SetItemText(i, 1, iter->second.szLithologyPic);
|
|
m_listLithologyName.SetItemText(i, 2, iter->second.szLithologyType);
|
|
}
|
|
}
|
|
}
|