add tcp client
This commit is contained in:
parent
d6045de076
commit
d163878aef
@ -71,18 +71,21 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
TcpClientInfo* info = (TcpClientInfo*)wParam;
|
TcpClientInfo* info = (TcpClientInfo*)wParam;
|
||||||
TcpClientLibevent* cli = (TcpClientLibevent*)lParam;
|
TcpClientLibevent* cli = (TcpClientLibevent*)lParam;
|
||||||
ui::TreeNode* node = new ui::TreeNode;
|
ui::TreeNode* node = new ui::TreeNode;
|
||||||
node->SetText(info->ip);
|
node->SetText(info->ip + L":" + std::to_wstring(info->socket_fd));
|
||||||
|
node->SetTextId(L"sdfsdfasd");
|
||||||
node->SetClass(L"listitem");
|
node->SetClass(L"listitem");
|
||||||
node->SetFixedHeight(20);
|
node->SetFixedHeight(20);
|
||||||
node->SetMargin({ 20, 0, 0, 0 });
|
node->SetMargin({ 20, 0, 0, 0 });
|
||||||
mMonitor->GetRootNode()->GetChildNode(1)->AddChildNode(node);
|
mMonitor->GetRootNode()->GetChildNode(1)->AddChildNode(node);
|
||||||
|
|
||||||
if (mTcpClientForm.find(info->socket_fd) == mTcpClientForm.end()) {
|
if (mTcpClientForm.find(info->ip + L":"
|
||||||
auto form = new TcpClientForm(wstring2string(info->ip),info->port, cli);
|
+ std::to_wstring(info->socket_fd)) == mTcpClientForm.end())
|
||||||
form->SetChildLayoutXML(L"basic/tcp_form.xml");
|
{
|
||||||
form->SetName(info->ip);
|
auto form = new TcpClientForm(this,wstring2string(info->ip),info->port, cli);
|
||||||
|
form->SetChildLayoutXML(L"basic/uart_form.xml");
|
||||||
|
form->SetName(info->ip + L":" + std::to_wstring(info->socket_fd));
|
||||||
form->SetVisible(false);
|
form->SetVisible(false);
|
||||||
mTcpClientForm[info->socket_fd] = form;
|
mTcpClientForm[info->ip + L":" + std::to_wstring(info->socket_fd)] = form;
|
||||||
if (!mRightSide->Add(form))
|
if (!mRightSide->Add(form))
|
||||||
printf("erroer 1");
|
printf("erroer 1");
|
||||||
}
|
}
|
||||||
@ -90,9 +93,11 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
if (ui::EventType::kEventSelect == ev->Type) {
|
if (ui::EventType::kEventSelect == ev->Type) {
|
||||||
wprintf(L"%s\r\n", dynamic_cast<ui::TreeNode*> (ev->pSender)->GetText().c_str());
|
wprintf(L"%s\r\n", dynamic_cast<ui::TreeNode*> (ev->pSender)->GetText().c_str());
|
||||||
printf("GetCurSel %d\r\n", mRightSide->GetCurSel());
|
printf("GetCurSel %d\r\n", mRightSide->GetCurSel());
|
||||||
//TcpClientForm* p = mTcpClientForm[dynamic_cast<ui::TreeNode*> (ev->pSender)->GetText()];
|
TcpClientForm* p = mTcpClientForm[dynamic_cast<ui::TreeNode*> (ev->pSender)->GetText()];
|
||||||
/*
|
|
||||||
if (p != nullptr) {
|
if (p != nullptr) {
|
||||||
|
printf("GetCurSel %d\r\n", mRightSide->GetCurSel());
|
||||||
|
|
||||||
p->SetAutoDestroy(true);
|
p->SetAutoDestroy(true);
|
||||||
if (mRightShow != nullptr) {
|
if (mRightShow != nullptr) {
|
||||||
mRightShow->SetVisible(false);
|
mRightShow->SetVisible(false);
|
||||||
@ -107,7 +112,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
mRightSide->SelectItem(p->GetName());
|
mRightSide->SelectItem(p->GetName());
|
||||||
mRightShow = p;
|
mRightShow = p;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -57,7 +57,7 @@ private:
|
|||||||
ui::TabBox *mRightSide;
|
ui::TabBox *mRightSide;
|
||||||
ui::TreeView *mMonitor;
|
ui::TreeView *mMonitor;
|
||||||
std::map<std::wstring,UartForm*> mUartForm;
|
std::map<std::wstring,UartForm*> mUartForm;
|
||||||
std::map<uint32_t, TcpClientForm*> mTcpClientForm;
|
std::map<std::wstring, TcpClientForm*> mTcpClientForm;
|
||||||
|
|
||||||
ui::Control* mRightShow;
|
ui::Control* mRightShow;
|
||||||
};
|
};
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
#include "tcp_client_form.h"
|
#include "tcp_client_form.h"
|
||||||
|
|
||||||
TcpClientForm::TcpClientForm(std::string url, uint32_t port, TcpClientLibevent* p)
|
TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, TcpClientLibevent* p)
|
||||||
{
|
{
|
||||||
mClient = p;
|
mClient = p;
|
||||||
|
if (nullptr != hwnd) {
|
||||||
|
this->SetWindow(hwnd, nullptr, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TcpClientForm::Init()
|
void TcpClientForm::Init()
|
||||||
{
|
{
|
||||||
ui::Label* m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
ui::ChildBox::Init();
|
||||||
ui::RichEdit* m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
|
||||||
ui::RichEdit* m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
||||||
ui::RichEdit* m_rich_edit_3 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_send_edit"));
|
m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
||||||
ui::Button* m_button_1 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_send_data"));
|
m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
||||||
ui::CheckBox* m_check_box_1 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_new_line"));
|
m_rich_edit_3 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_send_edit"));
|
||||||
ui::CheckBox* m_check_box_2 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_time_send"));
|
m_button_1 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_send_data"));
|
||||||
ui::CheckBox* m_check_box_3 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_hex_send"));
|
m_check_box_1 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_new_line"));
|
||||||
ui::CheckBox* m_check_box_4 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_hex_recv"));
|
m_check_box_2 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_time_send"));
|
||||||
|
m_check_box_3 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_hex_send"));
|
||||||
|
m_check_box_4 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_hex_recv"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class TcpClientForm : public ui::ChildBox {
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TcpClientForm(string url, uint32_t port, TcpClientLibevent* p);
|
TcpClientForm(ui::Window* hwnd,string url, uint32_t port, TcpClientLibevent* p);
|
||||||
virtual void Init() override;
|
virtual void Init() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user