Skip to content

Commit

Permalink
Machine_List applies to Linux and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
whitekaren committed Dec 7, 2023
1 parent c08509a commit d9c7898
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 40 deletions.
26 changes: 13 additions & 13 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,23 +904,23 @@ void MainFrame::create_preset_tabs()
wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_PRINTER);
});

m_printer_view->SetDeleteHandler([this](wxCommandEvent &event) {
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
//m_printer_view->SetDeleteHandler([this](wxCommandEvent &event) {
// PresetBundle &preset_bundle = *wxGetApp().preset_bundle;

const std::string &printer_name = preset_bundle.physical_printers.get_selected_full_printer_name();
if (printer_name.empty())
return false;
// const std::string &printer_name = preset_bundle.physical_printers.get_selected_full_printer_name();
// if (printer_name.empty())
// return false;

wxString msg;
//if (!note_string.IsEmpty())
// msg += note_string + "\n";
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), printer_name);
// wxString msg;
// //if (!note_string.IsEmpty())
// // msg += note_string + "\n";
// msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), printer_name);

if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
return false;
// if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
// return false;

preset_bundle.physical_printers.delete_selected_printer();
});
// preset_bundle.physical_printers.delete_selected_printer();
//});

// #if defined(__WIN32__)
// m_tabpanel->Bind(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, &MainFrame::OnTabPanelSelectionChanged, this);
Expand Down
52 changes: 25 additions & 27 deletions src/slic3r/GUI/PrinterWebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "PhysicalPrinterDialog.hpp"
//B45
#include <wx/regex.h>
#include <boost/regex.hpp>

namespace pt = boost::property_tree;

Expand Down Expand Up @@ -398,26 +399,24 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
formattedHost = wxString::Format("%s:10088", formattedHost);

std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
std::string preset_name = printer.get_preset_name(fullname);
Preset * preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
std::string model_id = "X-MAX 3";
if (preset != nullptr) {
model_id = preset->config.opt_string("printer_model");
}

std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
bool isValidIPAddress = std::regex_match(host.ToStdString(), ipRegex);
wxString machine_type = "X-MAX 3";
DynamicPrintConfig *cfg_t = &(printer.config);
std::regex regex1("\\*\\s(.*)(?=\\snozzle)");

std::smatch match;

if (std::regex_search(fullname, match, regex1)) {
std::string regexmatch = match.str(0);
std::regex regex2("(X-\\w+\\s\\d)");
if (std::regex_search(regexmatch, match, regex2))
machine_type = match.str(0);
}

boost::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
bool isValidIPAddress = boost::regex_match(host.ToStdString(), ipRegex);
DynamicPrintConfig *cfg_t = &(printer.config);

UnSelectedButton();
if (isValidIPAddress)
AddButton(
printer_name, host, machine_type, fullname,
printer_name, host, model_id, fullname,
[formattedHost, this](wxMouseEvent &event) {
wxString host = formattedHost;
load_url(host);
Expand All @@ -438,7 +437,12 @@ void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event) {
wxString msg;
//if (!note_string.IsEmpty())
// msg += note_string + "\n";
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), (button->getLabel()));

#if defined(__WIN32__) || defined(__WXMAC__)
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), (button->getLabel()));
#else
msg += _L("Are you sure you want to delete ") + (button->getLabel()) + _L("printer?");
#endif

if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
return ;
Expand Down Expand Up @@ -498,26 +502,20 @@ void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
std::string printer_name = printer.name;
wxString host = printer.config.opt_string("print_host");
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();

std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
bool isValidIPAddress = std::regex_match(host.ToStdString(), ipRegex);
wxString machine_type = "X-MAX 3";
std::string preset_name = printer.get_preset_name(fullname);
Preset * preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
std::string model_id = "X-MAX 3";
if (preset != nullptr) {
model_id = preset->config.opt_string("printer_model");
}
DynamicPrintConfig *cfg_t = &(printer.config);
std::regex regex1("\\*\\s(.*)(?=\\snozzle)");

std::smatch match;

if (std::regex_search(fullname, match, regex1)) {
std::string regexmatch = match.str(0);
std::regex regex2("(X-\\w+\\s\\d)");
if (std::regex_search(regexmatch, match, regex2))
machine_type = match.str(0);
}

button->SetNameText((wxString::FromUTF8(printer_name)));
button->SetIPText(host);
button->SetLabel(fullname);
wxString Machine_Name = Machine_Name.Format("%s%s", machine_type, "_thumbnail");
wxString Machine_Name = Machine_Name.Format("%s%s", model_id, "_thumbnail");

button->SetBitMap(get_bmp_bundle(std::string(Machine_Name.mb_str()), 80)->GetBitmapFor(this));
UpdateLayout();
Expand Down

0 comments on commit d9c7898

Please sign in to comment.