2023-03-06 15:40:07 -05:00
|
|
|
#include "progress_ui.hpp"
|
|
|
|
|
2023-11-10 16:52:20 -05:00
|
|
|
#include "string.hpp"
|
2023-03-06 15:40:07 -05:00
|
|
|
|
2023-11-10 16:52:20 -05:00
|
|
|
namespace utilities
|
2023-03-06 15:40:07 -05:00
|
|
|
{
|
|
|
|
progress_ui::progress_ui()
|
|
|
|
{
|
2023-11-10 16:52:20 -05:00
|
|
|
this->dialog_ = utilities::com::create_progress_dialog();
|
2023-03-06 15:40:07 -05:00
|
|
|
if (!this->dialog_)
|
|
|
|
{
|
|
|
|
throw std::runtime_error{"Failed to create dialog"};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
progress_ui::~progress_ui()
|
|
|
|
{
|
|
|
|
this->dialog_->StopProgressDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void progress_ui::show(const bool marquee, HWND parent) const
|
|
|
|
{
|
|
|
|
this->dialog_->StartProgressDialog(parent, nullptr, PROGDLG_AUTOTIME | (marquee ? PROGDLG_MARQUEEPROGRESS : 0), nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void progress_ui::set_progress(const size_t current, const size_t max) const
|
|
|
|
{
|
|
|
|
this->dialog_->SetProgress64(current, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
void progress_ui::set_line(const int line, const std::string& text) const
|
|
|
|
{
|
2023-11-10 16:52:20 -05:00
|
|
|
this->dialog_->SetLine(line, utilities::string::convert(text).data(), false, nullptr);
|
2023-03-06 15:40:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void progress_ui::set_title(const std::string& title) const
|
|
|
|
{
|
2023-11-10 16:52:20 -05:00
|
|
|
this->dialog_->SetTitle(utilities::string::convert(title).data());
|
2023-03-06 15:40:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool progress_ui::is_cancelled() const
|
|
|
|
{
|
|
|
|
return this->dialog_->HasUserCancelled();
|
|
|
|
}
|
|
|
|
}
|