Day 14/100 100 Days of Code
Info Hunter

AKA Chris, is a software developer from Athens, Greece. He started programming with basic when he was very young. He lost interest in programming during school years but after an unsuccessful career in audio, he decided focus on what he really loves which is technology.
He loves working with older languages like C and wants to start programming electronics and microcontrollers because he wants to get into embedded systems programming.
Today's session was about informing the user on what is happening with the application.
Analysis
I made a dialogue box that appears when the user presses the start button to inform him that an operation has started or that an operation is already running. If an operation is already being executed, the program doesn't start a new one. This is achieved by creating a new state manager for this exact purpose.
if (scrapingState == SST_Waiting)
{
wxMessageBox("The operation has started.", "", wxOK);
scrapingState = SST_Running;
}
else
{
wxMessageBox("An operation is already running","" ,wxOK);
return;
}
Next, I added a static text that displays which URL the program is operating on.
void MainFrame::StartScraping(int amount, int counter, std::vector<std::string> keywords,
std::vector<std::string> getUrls)
{
if (!Scraper::CheckForConnection())
{
wxMessageBox("You have been disconnected from the internet",
"", wxOK);
return;
}
std::vector<std::string> scraperKeywords;
scraperKeywords.reserve(amount);
for (int j = 0; j < amount; j++)
{
scraperKeywords.push_back(keywords[j]);
}
content->SetFont(wxFontInfo(32).FaceName("Helvetica Neue").Bold());
Scraper::SetupScraper(scraperKeywords, getUrls[counter]);
scrapingInfoText = new wxStaticText(MainFrame::content, wxID_ANY,
std::string("Currently checking: ") +
std::string(getUrls[counter]),
wxDefaultPosition, wxDefaultSize);
scrapingInfoSizer = new wxBoxSizer(wxVERTICAL);
scrapingInfoSizer->Add(scrapingInfoText, 1, wxCENTER);
runContentHolder->Add(scrapingInfoSizer, 1, wxEXPAND);
content->SetSizer(runContentHolder);
content->Layout();

When the user presses the stop button, it lets the user know that they should wait while the operation is stopping.
void MainFrame::StopOperation(wxMouseEvent &event)
{
if (scrapingState == SST_Waiting)
{
wxMessageBox("There are no operations running", "", wxOK);
return;
}
content->SetFont(wxFontInfo(32).FaceName("Helvetica Neue").Bold());
scrapingInfoText->Destroy();
scrapingInfoText = new wxStaticText(content, wxID_ANY, "Please wait while the operation is stopping",
wxDefaultPosition, wxDefaultSize);
scrapingInfoSizer = new wxBoxSizer(wxVERTICAL);
scrapingInfoSizer->Add(scrapingInfoText, 1, wxCENTER);
runContentHolder->Add(scrapingInfoSizer, 1, wxEXPAND);
content->SetSizer(runContentHolder);
content->Layout();
Scraper::isCanceled = true;
scrapingState = SST_Waiting;
}

Finally, when the operation comes to a stop, a message box appears to inform the user.

As soon as the user presses the ok button, the "Please wait while the operation is stopping" disappears.
I also fixed some crashes, and I added a line of code to destroy the URL title in the search settings. Next, I need to write the results in a file.




