#include "stdafx.h"
|
#include "PlcView.h"
|
#include "BoounionPLC.h"
|
#include "Common.h"
|
|
|
// CPlcView ¶Ô»°¿ò
|
|
IMPLEMENT_DYNAMIC(CPlcView, CBaseView)
|
|
CPlcView::CPlcView(CWnd* pParent /*=nullptr*/)
|
: CBaseView(IDD_VIEW_PLC, pParent)
|
{
|
m_pObserver = nullptr;
|
m_crBkgnd = PLC_VIEW_BACKGROUND;
|
m_hbrBkgnd = nullptr;
|
m_pPlc = nullptr;
|
}
|
|
|
CPlcView::~CPlcView()
|
{
|
}
|
|
void CPlcView::DoDataExchange(CDataExchange* pDX)
|
{
|
CBaseView::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CPlcView, CBaseView)
|
ON_WM_CTLCOLOR()
|
ON_WM_DESTROY()
|
ON_WM_SIZE()
|
END_MESSAGE_MAP()
|
|
// CComponentData1Dlg ÏûÏ¢´¦Àí³ÌÐò
|
|
void CPlcView::SetContext(void* pContext)
|
{
|
CBaseView::SetContext(pContext);
|
|
if (::IsWindow(m_hWnd) && m_pContext != nullptr) {
|
SetDlgItemText(IDC_LABEL_PLC_NAME, ((CPLC*)m_pContext)->getName().c_str());
|
}
|
}
|
|
void CPlcView::InitRxWindows()
|
{
|
/* code */
|
// ¶©ÔÄÊý¾Ý
|
IRxWindows* pRxWindows = RX_GetRxWindows();
|
if (m_pObserver == NULL) {
|
m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
|
// onNext
|
pAny->addRef();
|
int code = pAny->getCode();
|
|
pAny->release();
|
}, [&]() -> void {
|
// onComplete
|
}, [&](IThrowable* pThrowable) -> void {
|
// onErrorm
|
pThrowable->printf();
|
});
|
|
theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
|
->subscribe(m_pObserver);
|
}
|
}
|
|
BOOL CPlcView::OnInitDialog()
|
{
|
CBaseView::OnInitDialog();
|
|
if (m_pContext != nullptr) {
|
SetDlgItemText(IDC_LABEL_PLC_NAME, ((CPLC*)m_pContext)->getName().c_str());
|
}
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// Òì³£: OCX ÊôÐÔÒ³Ó¦·µ»Ø FALSE
|
}
|
|
|
HBRUSH CPlcView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
{
|
HBRUSH hbr = CBaseView::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_STATIC) {
|
pDC->SetBkColor(m_crBkgnd);
|
}
|
|
if (m_hbrBkgnd == nullptr) {
|
m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
|
}
|
|
return m_hbrBkgnd;
|
}
|
|
void CPlcView::OnDestroy()
|
{
|
CBaseView::OnDestroy();
|
|
if (m_hbrBkgnd != nullptr) {
|
::DeleteObject(m_hbrBkgnd);
|
}
|
|
if (m_pObserver != NULL) {
|
m_pObserver->unsubscribe();
|
m_pObserver = NULL;
|
}
|
}
|
|
void CPlcView::OnSize(UINT nType, int cx, int cy)
|
{
|
CBaseView::OnSize(nType, cx, cy);
|
}
|
|
void CPlcView::Resize()
|
{
|
int y = 12;
|
int x = 0;
|
CRect rcClient, rcItem;
|
CWnd* pItem;
|
GetClientRect(&rcClient);
|
}
|