diff --git a/CrossGen.workspace b/CrossGen.workspace index 1d039f5..0a4b414 100644 --- a/CrossGen.workspace +++ b/CrossGen.workspace @@ -2,10 +2,10 @@ - + - + diff --git a/wxCrossGen/main.cpp b/wxCrossGen/main.cpp index 448dc65..8213882 100644 --- a/wxCrossGen/main.cpp +++ b/wxCrossGen/main.cpp @@ -26,6 +26,8 @@ MainFrame::MainFrame(wxWindow* parent, int id, const wxString& title, const wxPo set_properties(); do_layout(); + + _isDictLoaded = false; } @@ -162,9 +164,13 @@ void MainFrame::SetGridImage(GridType &grid, size_t w) { void MainFrame::OnbtnGenerateClick(wxCommandEvent &event) { event.Skip(); - DictType dict; + + if ( !_isDictLoaded ) { + readDict(wxT("big_cross_ru.txt"), _dict); + _isDictLoaded = true; + } + std::vector words_out; - readDict(wxT("big_cross_ru.txt"), dict); GridType grid; if (tPath->GetValue() == wxEmptyString){ wxMessageBox( wxT("Не указана путь к сетке"), wxT("Инфо"), wxICON_INFORMATION); @@ -172,7 +178,7 @@ void MainFrame::OnbtnGenerateClick(wxCommandEvent &event) { } readGrid(tPath->GetValue(), grid); try{ - generateCross(grid,dict,words_out); + generateCross(grid,_dict,words_out); _words.clear(); _words = words_out; @@ -187,7 +193,7 @@ void MainFrame::OnbtnGenerateClick(wxCommandEvent &event) { for (size_t i = 0; i < words_out.size(); ++i){ if (winfos.at(i).direct == false) tOutput->AppendText(wxString::Format(wxT("%d. "), winfos.at(i).ind) - + dict[words_out.at(i)] +wxT("\n")); + + _dict[words_out.at(i)] +wxT("\n")); } tOutput->AppendText(wxT("По горизонтали:\n")); @@ -195,7 +201,7 @@ void MainFrame::OnbtnGenerateClick(wxCommandEvent &event) { for (size_t i = 0; i < words_out.size(); ++i){ if (winfos.at(i).direct == true) tOutput->AppendText(wxString::Format(wxT("%d. "), winfos.at(i).ind) - + dict[words_out.at(i)]+wxT("\n")); + + _dict[words_out.at(i)]+wxT("\n")); } if (winfos.size() == 0) throw 42; @@ -205,7 +211,7 @@ void MainFrame::OnbtnGenerateClick(wxCommandEvent &event) { catch (...){ tOutput->Clear(); this->Refresh(); - wxMessageBox( wxT("Не могу создать кроссворд"), wxT("Ошибка"), wxICON_ERROR); + wxMessageBox( wxT("Не могу создать кроссворд"), wxT("Ошибка"), wxICON_ERROR ); } } diff --git a/wxCrossGen/wxgui.hpp b/wxCrossGen/wxgui.hpp index bf507e6..f6fcb04 100644 --- a/wxCrossGen/wxgui.hpp +++ b/wxCrossGen/wxgui.hpp @@ -45,6 +45,9 @@ private: // end wxGlade protected: + std::vector _words; + DictType _dict; + bool _isDictLoaded; // begin wxGlade: MainFrame::attributes wxStaticText* label_1; wxTextCtrl* tPath; @@ -52,7 +55,6 @@ protected: wxTextCtrl* tOutput; wxButton* btnGenerate; wxStaticBitmap* bPreview; - std::vector _words; // end wxGlade DECLARE_EVENT_TABLE();