28 : wxDialog(parent, wxID_ANY,
_L(
"Detect Creality K-series printer"),
29 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
30{
31 const int em = wxGetApp().em_unit();
32
33 m_status =
new wxStaticText(
this, wxID_ANY,
_L(
"Click Scan to look for K-series printers on your network."));
34
35 m_list =
new wxListView(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
36 wxLC_REPORT | wxSIMPLE_BORDER | wxLC_SINGLE_SEL);
37 m_list->SetMinSize(wxSize(50 * em, 18 * em));
38 m_list->AppendColumn(
_L_CONTEXT(
"Model",
"Printer model"), wxLIST_FORMAT_LEFT, 8 * em);
39 m_list->AppendColumn(
_L(
"Hostname"), wxLIST_FORMAT_LEFT, 14 * em);
40 m_list->AppendColumn(
_L(
"IP"), wxLIST_FORMAT_LEFT, 14 * em);
41
42 auto* dlg_btns =
new DialogButtons(
this, {
L(
"Scan"),
"OK",
"Cancel"},
"", 1 );
43 auto* ok_btn = dlg_btns->GetOK();
44 ok_btn->SetLabel(
_L(
"Use Selected"));
45 ok_btn->Disable();
46
47 auto* vsizer = new wxBoxSizer(wxVERTICAL);
48 vsizer->Add(
m_status, 0, wxEXPAND | wxALL, em);
49 vsizer->Add(
m_list, 1, wxEXPAND | wxALL, em);
50 vsizer->Add(dlg_btns, 0, wxEXPAND);
51 SetSizerAndFit(vsizer);
52
53 dlg_btns->GetFIRST()->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&) {
run_discovery(); });
54
55 m_list->Bind(wxEVT_LIST_ITEM_SELECTED, [ok_btn](wxListEvent&) { ok_btn->Enable(); });
56 m_list->Bind(wxEVT_LIST_ITEM_DESELECTED, [ok_btn](wxListEvent&) { ok_btn->Disable(); });
57 m_list->Bind(wxEVT_LIST_ITEM_ACTIVATED, [
this](wxListEvent&) {
on_ok(); EndModal(wxID_OK); });
58
59 ok_btn->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&) {
on_ok(); EndModal(wxID_OK); });
60 dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { EndModal(wxID_CANCEL); });
61
62 wxGetApp().UpdateDlgDarkUI(this);
63
64
65
66
67
68
70}
#define L(s)
Definition ExtrusionEntity.cpp:25
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
void run_discovery()
Definition CrealityDiscoveryDialog.cpp:72
void on_ok()
Definition CrealityDiscoveryDialog.cpp:119
wxListView * m_list
Definition CrealityDiscoveryDialog.hpp:42
wxStaticText * m_status
Definition CrealityDiscoveryDialog.hpp:43
#define _L_CONTEXT(s, ctx)
Definition I18N.hpp:15