ENH:Update IP address input process

Change-Id: Iaf1c187dac117ba10ac16045049a346f7c2b9478
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
tao wang 2023-01-16 18:53:35 +08:00 committed by Lane.Wei
parent 1015b7bca9
commit 9a8f832498
21 changed files with 527 additions and 318 deletions

View File

@ -0,0 +1 @@
just a test file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -306,11 +306,36 @@ void MachineObject::set_access_code(std::string code)
{
this->access_code = code;
AppConfig *config = GUI::wxGetApp().app_config;
if (config) {
if (config && !code.empty()) {
GUI::wxGetApp().app_config->set_str("access_code", dev_id, code);
}
}
std::string MachineObject::get_access_code()
{
if (get_user_access_code().empty())
return access_code;
return get_user_access_code();
}
void MachineObject::set_user_access_code(std::string code)
{
this->user_access_code = code;
AppConfig* config = GUI::wxGetApp().app_config;
if (config) {
GUI::wxGetApp().app_config->set_str("user_access_code", dev_id, code);
}
}
std::string MachineObject::get_user_access_code()
{
AppConfig* config = GUI::wxGetApp().app_config;
if (config) {
return GUI::wxGetApp().app_config->get("user_access_code", dev_id);
}
return "";
}
bool MachineObject::is_lan_mode_printer()
{
bool result = false;
@ -3618,7 +3643,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
//load access code
AppConfig* config = Slic3r::GUI::wxGetApp().app_config;
if (config) {
obj->access_code = Slic3r::GUI::wxGetApp().app_config->get("access_code", dev_id);
obj->set_access_code(Slic3r::GUI::wxGetApp().app_config->get("access_code", dev_id));
}
localMachineList.insert(std::make_pair(dev_id, obj));

View File

@ -321,6 +321,9 @@ private:
bool check_valid_ip();
void _parse_print_option_ack(int option);
std::string access_code;
std::string user_access_code;
public:
enum LIGHT_EFFECT {
@ -398,12 +401,14 @@ public:
std::string dev_ip;
std::string dev_id;
bool local_use_ssl { false };
std::string access_code;
std::string dev_connection_type; /* lan | cloud */
std::string connection_type() { return dev_connection_type; }
void set_dev_ip(std::string ip) {dev_ip = ip;};
bool has_access_right() { return !access_code.empty(); }
void set_access_code(std::string code);
std::string get_access_code();
void set_user_access_code(std::string code);
std::string get_user_access_code();
bool is_lan_mode_printer();
//PRINTER_TYPE printer_type = PRINTER_3DPrinter_UKNOWN;
std::string printer_type; /* model_id */

View File

@ -2327,6 +2327,8 @@ bool GUI_App::on_init_inner()
Bind(EVT_USER_LOGIN, &GUI_App::on_user_login, this);
Bind(EVT_SHOW_IP_DIALOG, &GUI_App::show_ip_address_enter_dialog_handler, this);
copy_network_if_available();
on_init_network();
@ -4559,17 +4561,27 @@ void GUI_App::update_mode()
plater()->canvas3D()->update_gizmos_on_off_state();
}
bool GUI_App::show_ip_address_enter_dialog()
void GUI_App::show_ip_address_enter_dialog(wxString title)
{
auto evt = new wxCommandEvent(EVT_SHOW_IP_DIALOG);
evt->SetString(title);
wxQueueEvent(this, evt);
}
bool GUI_App::show_modal_ip_address_enter_dialog(wxString title)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return false;
if (!dev->get_selected_machine()) return false;
auto obj = dev->get_selected_machine();
InputIpAddressDialog dlg(nullptr, from_u8(dev->get_selected_machine()->dev_name), dev->get_selected_machine()->dev_ip, dev->get_selected_machine()->access_code);
InputIpAddressDialog dlg(nullptr);
dlg.set_machine_obj(obj);
if (!title.empty()) dlg.update_title(title);
dlg.Bind(EVT_ENTER_IP_ADDRESS, [this, obj](wxCommandEvent& e) {
auto selection_data_arr = wxSplit(e.GetString().ToStdString(), '|');
if (selection_data_arr.size() != 2) return false;
if (selection_data_arr.size() != 2) return;
auto ip_address = selection_data_arr[0];
auto access_code = selection_data_arr[1];
@ -4579,20 +4591,23 @@ bool GUI_App::show_ip_address_enter_dialog()
wxGetApp().app_config->set_str("ip_address", obj->dev_id, ip_address.ToStdString());
wxGetApp().app_config->save();
obj->set_access_code(access_code.ToStdString());
obj->dev_ip = ip_address.ToStdString();
obj->access_code = access_code.ToStdString();
}
return true;
obj->set_user_access_code(access_code.ToStdString());
}
});
if (dlg.ShowModal() == wxID_YES) {
return true;
}
return false;
}
void GUI_App::show_ip_address_enter_dialog_handler(wxCommandEvent& evt)
{
wxString title = evt.GetString();
show_modal_ip_address_enter_dialog(title);
}
//void GUI_App::add_config_menu(wxMenuBar *menu)
//void GUI_App::add_config_menu(wxMenu *menu)
//{

View File

@ -437,7 +437,9 @@ public:
ConfigOptionMode get_mode();
void save_mode(const /*ConfigOptionMode*/int mode) ;
void update_mode();
bool show_ip_address_enter_dialog();
void show_ip_address_enter_dialog(wxString title = wxEmptyString);
void show_ip_address_enter_dialog_handler(wxCommandEvent &evt);
bool show_modal_ip_address_enter_dialog(wxString title);
// BBS
//void add_config_menu(wxMenuBar *menu);

View File

@ -16,6 +16,7 @@ public:
int plate_idx;
fs::path _3mf_path;
fs::path _3mf_config_path;
fs::path _temp_path;
PrintPrepareData() {
plate_idx = 0;
}

View File

@ -104,11 +104,46 @@ inline std::string get_transform_string(int bytes)
void SendJob::process()
{
/* display info */
BBL::PrintParams params;
wxString msg;
int curr_percent = 10;
NetworkAgent* m_agent = wxGetApp().getAgent();
AppConfig* config = wxGetApp().app_config;
int result = -1;
unsigned int http_code;
std::string http_body;
// check access code and ip address
params.dev_id = m_dev_id;
params.project_name = "verify_job";
params.filename = job_data._temp_path.string();
params.connection_type = this->connection_type;
// local print access
params.dev_ip = m_dev_ip;
params.username = "bblp";
params.password = m_access_code;
params.use_ssl = m_local_use_ssl;
result = m_agent->start_send_gcode_to_sdcard(params, nullptr, nullptr);
if (result != 0) {
BOOST_LOG_TRIVIAL(error) << "access code is invalid";
m_enter_ip_address_fun_fail();
if (m_is_check_mode) {
m_job_finished = true;
return;
}
}
else {
if (m_is_check_mode) {
m_enter_ip_address_fun_success();
m_job_finished = true;
return;
}
}
/* display info */
if (this->connection_type == "lan") {
msg = _L("Sending gcode file over LAN");
@ -117,10 +152,6 @@ void SendJob::process()
msg = _L("Sending gcode file through cloud service");
}
int result = -1;
unsigned int http_code;
std::string http_body;
int total_plate_num = m_plater->get_partplate_list().get_plate_count();
PartPlate* plate = m_plater->get_partplate_list().get_plate(job_data.plate_idx);
@ -148,7 +179,6 @@ void SendJob::process()
else if (job_data.plate_idx == PLATE_CURRENT_IDX)
curr_plate_idx = m_plater->get_partplate_list().get_curr_plate_index() + 1;
BBL::PrintParams params;
params.dev_id = m_dev_id;
params.project_name = m_project_name + ".gcode.3mf";
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
@ -305,7 +335,6 @@ void SendJob::process()
if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
msg_text += ". ";
msg_text += _L("Please log out and login to the printer again.");
m_enter_ip_address_fun();
}
else {
msg_text += wxString::Format("[%s]", error_text);
@ -314,7 +343,6 @@ void SendJob::process()
if (result == BAMBU_NETWORK_ERR_WRONG_IP_ADDRESS) {
msg_text = _L("Failed uploading print file. Please enter ip address again.");
m_enter_ip_address_fun();
}
update_status(curr_percent, msg_text);
@ -333,11 +361,15 @@ void SendJob::on_success(std::function<void()> success)
m_success_fun = success;
}
void SendJob::on_enter_ip_address(std::function<void()> success)
void SendJob::on_check_ip_address_fail(std::function<void()> func)
{
m_enter_ip_address_fun = success;
m_enter_ip_address_fun_fail = func;
}
void SendJob::on_check_ip_address_success(std::function<void()> func)
{
m_enter_ip_address_fun_success = func;
}
void SendJob::finalize() {

View File

@ -20,8 +20,10 @@ class SendJob : public PlaterJob
std::string m_dev_id;
bool m_job_finished{ false };
int m_print_job_completed_id = 0;
bool m_is_check_mode{false};
std::function<void()> m_success_fun{nullptr};
std::function<void()> m_enter_ip_address_fun{nullptr};
std::function<void()> m_enter_ip_address_fun_fail{nullptr};
std::function<void()> m_enter_ip_address_fun_success{nullptr};
protected:
@ -51,10 +53,12 @@ public:
}
wxString get_http_error_msg(unsigned int status, std::string body);
void set_check_mode() {m_is_check_mode = true;};
bool is_finished() { return m_job_finished; }
void process() override;
void on_success(std::function<void()> success);
void on_enter_ip_address(std::function<void()> success);
void on_check_ip_address_fail(std::function<void()> func);
void on_check_ip_address_success(std::function<void()> func);
void finalize() override;
void set_project_name(std::string name);
};

View File

@ -71,6 +71,7 @@ namespace GUI {
wxDEFINE_EVENT(EVT_SELECT_TAB, wxCommandEvent);
wxDEFINE_EVENT(EVT_HTTP_ERROR, wxCommandEvent);
wxDEFINE_EVENT(EVT_USER_LOGIN, wxCommandEvent);
wxDEFINE_EVENT(EVT_SHOW_IP_DIALOG, wxCommandEvent);
wxDEFINE_EVENT(EVT_UPDATE_PRESET_CB, SimpleEvent);
// BBS: backup

View File

@ -373,6 +373,7 @@ public:
wxDECLARE_EVENT(EVT_HTTP_ERROR, wxCommandEvent);
wxDECLARE_EVENT(EVT_USER_LOGIN, wxCommandEvent);
wxDECLARE_EVENT(EVT_SHOW_IP_DIALOG, wxCommandEvent);
wxDECLARE_EVENT(EVT_UPDATE_PRESET_CB, SimpleEvent);
} // GUI

View File

@ -181,7 +181,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_supported = true;
m_lan_mode = obj->is_lan_mode_printer();
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : "";
m_lan_passwd = obj->access_code;
m_lan_passwd = obj->get_access_code();
m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
} else {
m_supported = false;

View File

@ -85,7 +85,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_camera_exists = obj->has_ipcam;
m_lan_mode = obj->is_lan_mode_printer();
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : "";
m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->access_code : "";
m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->get_access_code() : "";
m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
} else {
m_camera_exists = false;
@ -233,7 +233,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
++m_failed_retry;
if (m_failed_code != 0 && !m_tutk_support) {
m_next_retry = wxDateTime(); // stop retry
if (wxGetApp().show_ip_address_enter_dialog()) {
if (wxGetApp().show_modal_ip_address_enter_dialog(_L("Failed to start liveview"))) {
m_failed_retry = 0;
m_next_retry = wxDateTime::Now();
}

View File

@ -26,9 +26,6 @@
namespace Slic3r {
namespace GUI {
wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDEFINE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style, wxBitmap bitmap)
: DPIDialog(parent ? parent : dynamic_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxSize(360, -1),wxDEFAULT_DIALOG_STYLE)
, boldfont(wxGetApp().normal_font())
@ -422,252 +419,4 @@ void DownloadDialog::SetExtendedMessage(const wxString &extendedMessage)
Fit();
}
InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent, wxString name, wxString ip, wxString access_code)
:DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, _L("Unable to connect printer"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
SetBackgroundColour(*wxWHITE);
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
//comfirm_before_enter_text = wxString::Format(_L("Cannot detect the LAN IP address of %s. Are %s and Bambu Studio in the same LAN?"), name, name);
//comfirm_after_enter_text = _L("Please input the LAN IP address of your printer manually. You can find the IP address on device's screen, Settings > Network > IP.");
comfirm_after_enter_text = _L("Failed to connect to the printer through LAN. Please enter the correct printer IP address and access code.");
tip = new Label(this, comfirm_before_enter_text);
tip->SetMinSize(wxSize(FromDIP(420), -1));
tip->SetMaxSize(wxSize(FromDIP(420), -1));
tip->Wrap(FromDIP(420));
m_tips_ip = new Label(this, _L("IP"));
m_input_ip = new TextInput(this, ip, wxEmptyString);
m_input_ip->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_ip->SetMinSize(wxSize(FromDIP(420), FromDIP(28)));
m_input_ip->SetMaxSize(wxSize(FromDIP(420), FromDIP(28)));
m_tips_access_code = new Label(this, _L("Access Code"));
m_input_access_code = new TextInput(this, access_code, wxEmptyString);
m_input_access_code->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_access_code->SetMinSize(wxSize(FromDIP(420), FromDIP(28)));
m_input_access_code->SetMaxSize(wxSize(FromDIP(420), FromDIP(28)));
m_tips_note1 = new Label(this, _L("Note : The location of IP and access code on the machine is as follows :"));
m_tips_note2 = new Label(this, _L("X1 General Settings - Network Settings in the side bar of X1 main screen"));
m_tips_note3 = new Label(this, _L("P1P General Settings - WLAN in the sidebar of the main screen"));
m_tips_note1->SetFont(::Label::Body_12);
m_tips_note2->SetFont(::Label::Body_12);
m_tips_note3->SetFont(::Label::Body_12);
m_tips_note1->SetForegroundColour(wxColour(0x898989));
m_tips_note2->SetForegroundColour(wxColour(0x898989));
m_tips_note3->SetForegroundColour(wxColour(0x898989));
m_tips_note1->SetMinSize(wxSize(FromDIP(400),-1));
m_tips_note1->Wrap(FromDIP(400));
m_tips_note2->SetMinSize(wxSize(FromDIP(400), -1));
m_tips_note2->Wrap(FromDIP(400));
m_tips_note3->SetMinSize(wxSize(FromDIP(400), -1));
m_tips_note3->Wrap(FromDIP(400));
/* m_tips_ip->Hide();
m_input_ip->Hide();
m_tips_access_code->Hide();
m_input_access_code->Hide();
m_tips_note1->Hide();
m_tips_note2->Hide();
m_tips_note3->Hide();*/
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_ok = new Button(this, _L("OK"));
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
m_button_ok->SetFont(Label::Body_12);
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
m_button_ok->Bind(wxEVT_LEFT_DOWN, &InputIpAddressDialog::on_ok, this);
auto m_button_cancel = new Button(this, _L("Cancel"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetCornerRadius(FromDIP(12));
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
EndModal(wxID_CANCEL);
});
sizer_button->AddStretchSpacer();
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(15));
m_sizer_main->Add(tip, 1, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
m_sizer_main->Add(m_tips_ip, 0, wxLEFT, FromDIP(18));
m_sizer_main->Add(m_input_ip, 1, wxALIGN_CENTER, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_tips_access_code, 0, wxLEFT, FromDIP(18));
m_sizer_main->Add(m_input_access_code, 1, wxALIGN_CENTER, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_tips_note1, 0, wxALIGN_CENTER, FromDIP(5));
m_sizer_main->Add(m_tips_note2, 0, wxALIGN_CENTER, FromDIP(2));
m_sizer_main->Add(m_tips_note3, 0, wxALIGN_CENTER, FromDIP(2));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(sizer_button, 1, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
tip->SetLabel(comfirm_after_enter_text);
tip->SetMinSize(wxSize(FromDIP(420), -1));
tip->SetMaxSize(wxSize(FromDIP(420), -1));
tip->Wrap(FromDIP(420));
m_tips_ip->Show();
m_input_ip->Show();
m_tips_access_code->Show();
m_input_access_code->Show();
m_tips_note1->Show();
m_tips_note2->Show();
m_tips_note3->Show();
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
Layout();
Fit();
SetSizer(m_sizer_main);
Layout();
m_sizer_main->Fit(this);
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
bool InputIpAddressDialog::isIp(std::string ipstr)
{
istringstream ipstream(ipstr);
int num[4];
char point[3];
string end;
ipstream >> num[0] >> point[0] >> num[1] >> point[1] >> num[2] >> point[2] >> num[3] >> end;
for (int i = 0; i < 3; ++i) {
if (num[i] < 0 || num[i]>255) return false;
if (point[i] != '.') return false;
}
if (num[3] < 0 || num[3]>255) return false;
if (!end.empty()) return false;
return true;
}
void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
{
/*if (!m_input_ip->IsShown()) {
tip->SetLabel(comfirm_after_enter_text);
tip->SetMinSize(wxSize(FromDIP(420), -1));
tip->SetMaxSize(wxSize(FromDIP(420), -1));
tip->Wrap(FromDIP(420));
m_tips_ip->Show();
m_input_ip->Show();
m_tips_access_code->Show();
m_input_access_code->Show();
m_tips_note1->Show();
m_tips_note2->Show();
m_tips_note3->Show();
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetBackgroundColor(btn_bg_green);
}
else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
Layout();
Fit();
}
else {
wxString ip = m_input_ip->GetTextCtrl()->GetValue();
wxString str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
wxString input_str = wxString::Format("%s|%s", ip, str_access_code);
auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS);
event.SetString(input_str);
event.SetEventObject(this);
wxPostEvent(this, event);
EndModal(wxID_YES);
}*/
wxString ip = m_input_ip->GetTextCtrl()->GetValue();
wxString str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
wxString input_str = wxString::Format("%s|%s", ip, str_access_code);
auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS);
event.SetString(input_str);
event.SetEventObject(this);
wxPostEvent(this, event);
EndModal(wxID_YES);
}
void InputIpAddressDialog::on_text(wxCommandEvent& evt)
{
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetBackgroundColor(btn_bg_green);
}
else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
}
InputIpAddressDialog::~InputIpAddressDialog()
{
}
void InputIpAddressDialog::on_dpi_changed(const wxRect& suggested_rect)
{
}
}} // namespace Slic3r::GUI

View File

@ -371,33 +371,6 @@ private:
wxString msg;
};
class InputIpAddressDialog: public DPIDialog
{
public:
wxString comfirm_before_enter_text;
wxString comfirm_after_enter_text;
std::string m_ip;
Label* tip{nullptr};
InputIpAddressDialog(wxWindow* parent = nullptr, wxString name = wxEmptyString, wxString id = wxEmptyString, wxString access_code = wxEmptyString);
~InputIpAddressDialog();
Button* m_button_ok{nullptr};
Label* m_tips_ip{nullptr};
Label* m_tips_access_code{nullptr};
TextInput* m_input_ip{nullptr};
TextInput* m_input_access_code{nullptr};
Label* m_tips_note1{nullptr};
Label* m_tips_note2{nullptr};
Label* m_tips_note3{nullptr};
bool isIp(std::string ipstr);
void on_ok(wxMouseEvent& evt);
void on_text(wxCommandEvent& evt);
void on_dpi_changed(const wxRect& suggested_rect) override;
};
wxDECLARE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDECLARE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
}
}

View File

@ -6558,6 +6558,8 @@ void Plater::get_print_job_data(PrintPrepareData* data)
data->plate_idx = p->m_print_job_data.plate_idx;
data->_3mf_path = p->m_print_job_data._3mf_path;
data->_3mf_config_path = p->m_print_job_data._3mf_config_path;
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
data->_temp_path = encode_path(temp_file.c_str());
}
}

View File

@ -26,6 +26,10 @@ namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent);
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CANCEL, wxCommandEvent);
wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDEFINE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
wxDEFINE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent);
wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent);
ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
@ -871,4 +875,349 @@ void ConfirmBeforeSendDialog::rescale()
m_button_cancel->Rescale();
}
InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
:DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, _L("Unable to connect printer"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
SetBackgroundColour(*wxWHITE);
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
comfirm_before_enter_text = _L("First,please confirm Bambu Studio and your printer are in same LAN.");
comfirm_after_enter_text = _L("Then,if the IP and Access Code below are different from the actual values on your printer,please correct them.");
m_tip1 = new Label(this, comfirm_before_enter_text);
m_tip1->SetFont(::Label::Body_12);
m_tip1->SetMinSize(wxSize(FromDIP(390), -1));
m_tip1->SetMaxSize(wxSize(FromDIP(390), -1));
m_tip1->Wrap(FromDIP(390));
auto m_line_tips = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_tips->SetBackgroundColour(wxColour(0xEEEEEE));
m_tip2 = new Label(this, comfirm_after_enter_text);
m_tip2->SetFont(::Label::Body_12);
m_tip2->SetMinSize(wxSize(FromDIP(390), -1));
m_tip2->SetMaxSize(wxSize(FromDIP(390), -1));
m_tip2->Wrap(FromDIP(390));
auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_area = new wxBoxSizer(wxHORIZONTAL);
m_tips_ip = new Label(this, _L("IP"));
m_tips_ip->SetMinSize(wxSize(FromDIP(180), FromDIP(28)));
m_tips_ip->SetMaxSize(wxSize(FromDIP(180), FromDIP(28)));
m_input_ip = new TextInput(this, wxEmptyString, wxEmptyString);
m_input_ip->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_ip->SetMinSize(wxSize(FromDIP(180), FromDIP(28)));
m_input_ip->SetMaxSize(wxSize(FromDIP(180), FromDIP(28)));
m_tips_access_code = new Label(this, _L("Access Code"));
m_tips_access_code->SetMinSize(wxSize(FromDIP(180), FromDIP(28)));
m_tips_access_code->SetMaxSize(wxSize(FromDIP(180), FromDIP(28)));
m_input_access_code = new TextInput(this, wxEmptyString, wxEmptyString);
m_input_access_code->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_access_code->SetMinSize(wxSize(FromDIP(180), FromDIP(28)));
m_input_access_code->SetMaxSize(wxSize(FromDIP(180), FromDIP(28)));
m_input_tip_area->Add(m_tips_ip, 0, wxALIGN_CENTER, 0);
m_input_tip_area->Add(0, 0, 0, wxLEFT, FromDIP(16));
m_input_tip_area->Add(m_tips_access_code, 0, wxALIGN_CENTER, 0);
m_input_area->Add(m_input_ip, 0, wxALIGN_CENTER, 0);
m_input_area->Add(0, 0, 0, wxLEFT, FromDIP(16));
m_input_area->Add(m_input_access_code, 0, wxALIGN_CENTER, 0);
m_error_msg = new Label(this, wxEmptyString);
m_error_msg->SetFont(::Label::Body_13);
m_error_msg->SetForegroundColour(wxColour(208,27,27));
m_error_msg->Hide();
m_tip3 = new Label(this, _L("Where to find your printer's IP and Access Code?"));
m_tip3->SetFont(::Label::Body_12);
m_tip3->SetMinSize(wxSize(FromDIP(390), -1));
m_tip3->SetMaxSize(wxSize(FromDIP(390), -1));
m_tip3->Wrap(FromDIP(390));
m_img_help1 = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_accesscode_help1", this, 198), wxDefaultPosition, wxSize(FromDIP(352), FromDIP(198)), 0);
m_img_help2 = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_accesscode_help2", this, 118), wxDefaultPosition, wxSize(FromDIP(352), FromDIP(118)), 0);
m_img_help1->Hide();
m_img_help2->Hide();
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_ok = new Button(this, _L("OK"));
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
m_button_ok->SetFont(Label::Body_12);
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
m_button_ok->Bind(wxEVT_LEFT_DOWN, &InputIpAddressDialog::on_ok, this);
auto m_button_cancel = new Button(this, _L("Cancel"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_cancel->SetCornerRadius(FromDIP(12));
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
on_cancel();
});
sizer_button->AddStretchSpacer();
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
m_status_bar = std::make_shared<BBLStatusBarSend>(this);
m_status_bar->get_panel()->Hide();
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(18));
m_sizer_main->Add(m_tip1, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_line_tips, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_tip2, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(18));
m_sizer_main->Add(m_input_tip_area, 1, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(m_input_area, 1, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(m_error_msg, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_tip3, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_main->Add(m_img_help1, 0, wxALIGN_CENTER, FromDIP(18));
m_sizer_main->Add(m_img_help2, 0, wxALIGN_CENTER, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(12));
m_sizer_main->Add(sizer_button, 1, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(12));
m_sizer_main->Add(m_status_bar->get_panel(), 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(18));
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ok->SetBackgroundColor(btn_bg_green);
}
else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
SetSizer(m_sizer_main);
Layout();
Fit();
CentreOnParent(wxBOTH);
Move(wxPoint(GetScreenPosition().x, GetScreenPosition().y - FromDIP(50)));
wxGetApp().UpdateDlgDarkUI(this);
Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this);
Bind(EVT_CLOSE_IPADDRESS_DLG, [this](auto& e) {
m_status_bar->reset();
this->EndModal(wxID_OK);
});
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {on_cancel();});
}
void InputIpAddressDialog::on_cancel()
{
if (m_send_job) {
if (m_send_job->is_running()) {
m_send_job->cancel();
m_send_job->join();
}
}
this->EndModal(wxID_CANCEL);
}
void InputIpAddressDialog::update_title(wxString title)
{
SetTitle(title);
}
void InputIpAddressDialog::set_machine_obj(MachineObject* obj)
{
m_obj = obj;
m_input_ip->GetTextCtrl()->SetLabelText(m_obj->dev_ip);
m_input_access_code->GetTextCtrl()->SetLabelText(m_obj->get_access_code());
if (m_obj->printer_type == "C11") {
m_img_help1->Hide();
m_img_help2->Show();
}
else if (m_obj->printer_type == "BL-P001" || m_obj->printer_type == "BL-P002") {
m_img_help1->Show();
m_img_help2->Hide();
}
Layout();
Fit();
}
void InputIpAddressDialog::update_error_msg(wxString msg)
{
if (msg.empty()) {
m_error_msg->Hide();
}
else {
m_error_msg->Show();
m_error_msg->SetLabelText(msg);
m_error_msg->SetMinSize(wxSize(FromDIP(390), -1));
m_error_msg->SetMaxSize(wxSize(FromDIP(390), -1));
m_error_msg->Wrap(FromDIP(390));
}
Layout();
Fit();
}
bool InputIpAddressDialog::isIp(std::string ipstr)
{
istringstream ipstream(ipstr);
int num[4];
char point[3];
string end;
ipstream >> num[0] >> point[0] >> num[1] >> point[1] >> num[2] >> point[2] >> num[3] >> end;
for (int i = 0; i < 3; ++i) {
if (num[i] < 0 || num[i]>255) return false;
if (point[i] != '.') return false;
}
if (num[3] < 0 || num[3]>255) return false;
if (!end.empty()) return false;
return true;
}
void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
{
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
if (m_send_job) {
m_send_job->join();
}
m_status_bar->reset();
m_status_bar->set_prog_block();
m_status_bar->set_cancel_callback_fina([this]() {
BOOST_LOG_TRIVIAL(info) << "print_job: enter canceled";
if (m_send_job) {
if (m_send_job->is_running()) {
BOOST_LOG_TRIVIAL(info) << "send_job: canceled";
m_send_job->cancel();
}
m_send_job->join();
}
});
m_send_job = std::make_shared<SendJob>(m_status_bar, wxGetApp().plater(), m_obj->dev_id);
wxString ip = m_input_ip->GetTextCtrl()->GetValue();
wxString str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
m_send_job->m_dev_ip = ip.ToStdString();
m_send_job->m_access_code = str_access_code.ToStdString();
m_send_job->m_local_use_ssl = m_obj->local_use_ssl;
m_send_job->connection_type = m_obj->connection_type();
m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = m_obj->has_sdcard();
m_send_job->set_check_mode();
m_send_job->set_project_name("verify_job");
m_send_job->on_check_ip_address_fail([this]() {
this->check_ip_address_failed();
});
m_send_job->on_check_ip_address_success([this, ip, str_access_code]() {
wxString input_str = wxString::Format("%s|%s", ip, str_access_code);
auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS);
event.SetString(input_str);
event.SetEventObject(this);
wxPostEvent(this, event);
auto event_close = wxCommandEvent(EVT_CLOSE_IPADDRESS_DLG);
event_close.SetEventObject(this);
wxPostEvent(this, event_close);
});
m_send_job->start();
}
void InputIpAddressDialog::check_ip_address_failed()
{
auto evt = new wxCommandEvent(EVT_CHECK_IP_ADDRESS_FAILED);
wxQueueEvent(this, evt);
}
void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt)
{
update_error_msg("Error: IP or Access Code are not correct");
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ok->SetBackgroundColor(btn_bg_green);
}
void InputIpAddressDialog::on_text(wxCommandEvent& evt)
{
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ok->SetBackgroundColor(btn_bg_green);
}
else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
}
InputIpAddressDialog::~InputIpAddressDialog()
{
}
void InputIpAddressDialog::on_dpi_changed(const wxRect& suggested_rect)
{
}
}} // namespace Slic3r::GUI

View File

@ -169,6 +169,52 @@ public:
std::string show_again_config_text = "";
};
class InputIpAddressDialog : public DPIDialog
{
public:
wxString comfirm_before_enter_text;
wxString comfirm_after_enter_text;
std::string m_ip;
Label* m_tip1{ nullptr };
Label* m_tip2{ nullptr };
Label* m_tip3{ nullptr };
InputIpAddressDialog(wxWindow* parent = nullptr);
~InputIpAddressDialog();
MachineObject* m_obj{nullptr};
Button* m_button_ok{ nullptr };
Label* m_tips_ip{ nullptr };
Label* m_tips_access_code{ nullptr };
Label* m_error_msg{ nullptr };
TextInput* m_input_ip{ nullptr };
TextInput* m_input_access_code{ nullptr };
wxStaticBitmap* m_img_help1{ nullptr };
wxStaticBitmap* m_img_help2{ nullptr };
bool m_show_access_code{ false };
std::shared_ptr<SendJob> m_send_job{nullptr};
std::shared_ptr<BBLStatusBarSend> m_status_bar;
void on_cancel();
void update_title(wxString title);
void set_machine_obj(MachineObject* obj);
void update_error_msg(wxString msg);
bool isIp(std::string ipstr);
void check_ip_address_failed();
void on_check_ip_address_failed(wxCommandEvent& evt);
void on_ok(wxMouseEvent& evt);
void on_text(wxCommandEvent& evt);
void on_dpi_changed(const wxRect& suggested_rect) override;
};
wxDECLARE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent);
wxDECLARE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDECLARE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
wxDECLARE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent);
}} // namespace Slic3r::GUI
#endif

View File

@ -2141,7 +2141,7 @@ void SelectMachineDialog::on_ok()
m_print_job = std::make_shared<PrintJob>(m_status_bar, m_plater, m_printer_last_select);
m_print_job->m_dev_ip = obj_->dev_ip;
m_print_job->m_access_code = obj_->access_code;
m_print_job->m_access_code = obj_->get_access_code();
m_print_job->m_local_use_ssl = obj_->local_use_ssl;
m_print_job->connection_type = obj_->connection_type();
m_print_job->set_project_name(m_current_project_name.utf8_string());

View File

@ -649,16 +649,23 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
m_send_job = std::make_shared<SendJob>(m_status_bar, m_plater, m_printer_last_select);
m_send_job->m_dev_ip = obj_->dev_ip;
m_send_job->m_access_code = obj_->access_code;
m_send_job->m_access_code = obj_->get_access_code();
m_send_job->m_local_use_ssl = obj_->local_use_ssl;
m_send_job->connection_type = obj_->connection_type();
m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = obj_->has_sdcard();
m_send_job->set_project_name(m_current_project_name.utf8_string());
m_send_job->on_enter_ip_address([this, obj_]() {
/*m_send_job->on_check_ip_address_success([this, obj_]() {
wxCommandEvent* evt = new wxCommandEvent(EVT_CLEAR_IPADDRESS);
wxQueueEvent(this, evt);
});*/
m_send_job->on_check_ip_address_fail([this]() {
wxCommandEvent* evt = new wxCommandEvent(EVT_CLEAR_IPADDRESS);
wxQueueEvent(this, evt);
wxGetApp().show_ip_address_enter_dialog();
});
enable_prepare_mode = false;
@ -668,13 +675,15 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
void SendToPrinterDialog::clear_ip_address_config(wxCommandEvent& e)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
enable_prepare_mode = true;
prepare_mode();
/*DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
if (!dev->get_selected_machine()) return;
auto obj = dev->get_selected_machine();
Slic3r::GUI::wxGetApp().app_config->set_str("ip_address", obj->dev_id, "");
Slic3r::GUI::wxGetApp().app_config->save();
wxGetApp().show_ip_address_enter_dialog();
wxGetApp().show_ip_address_enter_dialog();*/
}
void SendToPrinterDialog::update_user_machine_list()
@ -859,18 +868,12 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event)
}
//check ip address
if (obj->dev_ip.empty()) {
if (obj->dev_ip.empty() || obj->get_access_code().empty()) {
BOOST_LOG_TRIVIAL(info) << "MachineObject IP is empty ";
std::string app_config_dev_ip = Slic3r::GUI::wxGetApp().app_config->get("ip_address", obj->dev_id);
std::string app_config_access_code = Slic3r::GUI::wxGetApp().app_config->get("access_code", obj->dev_id);
if (app_config_dev_ip.empty()) {
if (app_config_dev_ip.empty() || obj->get_access_code().empty()) {
wxGetApp().show_ip_address_enter_dialog();
}
else {
obj->dev_ip = app_config_dev_ip;
obj->access_code = app_config_access_code;
}
}
update_show_status();