inline void PlaneListWidget::NewClicked() { Plane plane = CommonInterface::GetComputerSettings().plane; while (dlgPlaneDetailsShowModal(plane)) { if (plane.registration.empty()) { ShowMessageBox(_("Please enter the registration of the plane!"), _("Error"), MB_OK); continue; } StaticString<42> filename(plane.registration); filename += _T(".xcp"); StaticString<MAX_PATH> path; LocalPath(path.buffer(), filename); if (File::Exists(path)) { StaticString<256> tmp; tmp.Format(_("Plane \"%s\" already exists. " "Overwrite it?"), plane.registration.c_str()); if (ShowMessageBox(tmp, _("Overwrite"), MB_YESNO) != IDYES) continue; } PlaneGlue::WriteFile(plane, path); UpdateList(); break; } }
static void NewClicked(gcc_unused WndButton &button) { Plane plane = CommonInterface::GetComputerSettings().plane; while (dlgPlaneDetailsShowModal(*(SingleWindow*)dialog->get_root_owner(), plane)) { if (plane.registration.empty()) { MessageBoxX(_("Please enter the registration of the plane!"), _("Error"), MB_OK); continue; } StaticString<42> filename(plane.registration); filename += _T(".xcp"); StaticString<MAX_PATH> path; LocalPath(path.buffer(), filename); if (File::Exists(path)) { StaticString<256> tmp; tmp.Format(_("A plane profile \"%s\" already exists. " "Do you want to overwrite it?"), filename.c_str()); if (MessageBoxX(tmp, _("Overwrite"), MB_YESNO) != IDYES) continue; } PlaneGlue::WriteFile(plane, path); UpdateList(); break; } }
inline void PlaneListWidget::EditClicked() { assert(GetList().GetCursorIndex() < list.size()); const unsigned index = GetList().GetCursorIndex(); const TCHAR *old_path = list[index].path; const TCHAR *old_filename = list[index].name; Plane plane; PlaneGlue::ReadFile(plane, old_path); while (dlgPlaneDetailsShowModal(plane)) { if (plane.registration.empty()) { ShowMessageBox(_("Please enter the registration of the plane!"), _("Error"), MB_OK); continue; } StaticString<42> filename(plane.registration); filename += _T(".xcp"); if (filename != old_filename) { StaticString<MAX_PATH> path; DirName(old_path, path.buffer()); path += _T(DIR_SEPARATOR_S); path += filename; if (File::Exists(path)) { StaticString<256> tmp; tmp.Format(_("Plane \"%s\" already exists. " "Overwrite it?"), plane.registration.c_str()); if (ShowMessageBox(tmp, _("Overwrite"), MB_YESNO) != IDYES) continue; } File::Delete(old_path); PlaneGlue::WriteFile(plane, path); if (Profile::GetPathIsEqual("PlanePath", old_path)) { list[index].path = path; list[index].name = filename; Load(index); } } else { PlaneGlue::WriteFile(plane, old_path); if (Profile::GetPathIsEqual("PlanePath", old_path)) Load(index); } UpdateList(); break; } }
static void EditClicked(gcc_unused WndButton &button) { assert(plane_list->GetCursorIndex() < list.size()); const unsigned index = plane_list->GetCursorIndex(); const TCHAR *old_path = list[index].path; const TCHAR *old_filename = list[index].name; Plane plane; PlaneGlue::ReadFile(plane, old_path); while (dlgPlaneDetailsShowModal(*(SingleWindow*)dialog->get_root_owner(), plane)) { if (plane.registration.empty()) { MessageBoxX(_("Please enter the registration of the plane!"), _("Error"), MB_OK); continue; } StaticString<42> filename(plane.registration); filename += _T(".xcp"); if (filename != old_filename) { StaticString<MAX_PATH> path; DirName(old_path, path.buffer()); path += _T(DIR_SEPARATOR_S); path += filename; if (File::Exists(path)) { StaticString<256> tmp; tmp.Format(_("A plane profile \"%s\" already exists. " "Do you want to overwrite it?"), filename.c_str()); if (MessageBoxX(tmp, _("Overwrite"), MB_YESNO) != IDYES) continue; } File::Delete(old_path); PlaneGlue::WriteFile(plane, path); if (Profile::GetPathIsEqual(_T("PlanePath"), old_path)) { list[index].path = path; list[index].name = filename; Load(index); } } else { PlaneGlue::WriteFile(plane, old_path); if (Profile::GetPathIsEqual(_T("PlanePath"), old_path)) Load(index); } UpdateList(); break; } }