2023-07-28 14:50:46 +02:00
|
|
|
#include "pch.h"
|
|
|
|
#include "download_surface.h"
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
CProgressPanel::CProgressPanel()
|
2023-07-28 14:50:46 +02:00
|
|
|
: Forms::Form(), m_bCanClose(false), m_bCanceled(false), m_bAutoClose(false)
|
|
|
|
{
|
|
|
|
this->InitializeComponent();
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::UpdateProgress(uint32_t Progress, bool Finished)
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
this->m_ProgressBar->SetValue(Progress);
|
|
|
|
|
|
|
|
if (Finished)
|
|
|
|
{
|
|
|
|
this->m_CancelButton->SetEnabled(false);
|
|
|
|
this->m_bCanClose = true;
|
2023-08-01 00:02:35 +02:00
|
|
|
this->SetText("Operation finished");
|
2023-07-28 14:50:46 +02:00
|
|
|
|
|
|
|
if (this->m_bCanceled || this->m_bAutoClose)
|
|
|
|
this->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
bool CProgressPanel::IsCanceled()
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
return this->m_bCanceled;
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::SetCanCancel(bool bEnable)
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
m_CancelButton->SetEnabled(bEnable);
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::SetAutoClose(bool Value)
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
this->m_bAutoClose = Value;
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::SetExportLabel(const char* pNewLabel)
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
m_DownloadLabel->SetText(pNewLabel);
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::InitializeComponent()
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
this->SuspendLayout();
|
|
|
|
this->SetAutoScaleDimensions({ 6, 13 });
|
|
|
|
this->SetAutoScaleMode(Forms::AutoScaleMode::Font);
|
2023-08-01 00:02:35 +02:00
|
|
|
this->SetText("Initiating operation...");
|
2023-07-28 14:50:46 +02:00
|
|
|
this->SetClientSize({ 409, 119 });
|
|
|
|
this->SetFormBorderStyle(Forms::FormBorderStyle::FixedSingle);
|
|
|
|
this->SetStartPosition(Forms::FormStartPosition::CenterParent);
|
|
|
|
this->SetMinimizeBox(false);
|
|
|
|
this->SetMaximizeBox(false);
|
2023-07-29 16:55:49 +02:00
|
|
|
this->SetControlBox(false);
|
2023-07-28 14:50:46 +02:00
|
|
|
this->SetShowInTaskbar(false);
|
|
|
|
this->SetBackColor(Drawing::Color(47, 54, 61));
|
|
|
|
|
|
|
|
this->m_DownloadLabel = new UIX::UIXLabel();
|
|
|
|
this->m_DownloadLabel->SetSize({ 385, 17 });
|
|
|
|
this->m_DownloadLabel->SetLocation({ 12, 18 });
|
|
|
|
this->m_DownloadLabel->SetTabIndex(3);
|
|
|
|
this->m_DownloadLabel->SetText("Progress:");
|
|
|
|
this->m_DownloadLabel->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left | Forms::AnchorStyles::Right);
|
|
|
|
this->m_DownloadLabel->SetTextAlign(Drawing::ContentAlignment::TopLeft);
|
|
|
|
this->AddControl(this->m_DownloadLabel);
|
|
|
|
|
|
|
|
this->m_CancelButton = new UIX::UIXButton();
|
|
|
|
this->m_CancelButton->SetSize({ 87, 31 });
|
|
|
|
this->m_CancelButton->SetLocation({ 310, 76 });
|
|
|
|
this->m_CancelButton->SetTabIndex(2);
|
|
|
|
this->m_CancelButton->SetText("Cancel");
|
|
|
|
this->m_CancelButton->SetAnchor(Forms::AnchorStyles::Bottom | Forms::AnchorStyles::Right);
|
|
|
|
this->m_CancelButton->Click += &OnCancelClick;
|
|
|
|
this->AddControl(this->m_CancelButton);
|
|
|
|
|
|
|
|
this->m_ProgressBar = new UIX::UIXProgressBar();
|
|
|
|
this->m_ProgressBar->SetSize({ 385, 29 });
|
|
|
|
this->m_ProgressBar->SetLocation({ 12, 38 });
|
|
|
|
this->m_ProgressBar->SetTabIndex(0);
|
|
|
|
this->m_ProgressBar->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left | Forms::AnchorStyles::Right);
|
|
|
|
this->AddControl(this->m_ProgressBar);
|
|
|
|
|
|
|
|
this->ResumeLayout(false);
|
|
|
|
this->PerformLayout();
|
|
|
|
// END DESIGNER CODE
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::OnFinishClick(Forms::Control* Sender)
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
((Forms::Form*)Sender->FindForm())->Close();
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::OnCancelClick(Forms::Control* Sender)
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
2023-07-30 16:51:44 +02:00
|
|
|
((CProgressPanel*)Sender->FindForm())->CancelProgress();
|
2023-07-28 14:50:46 +02:00
|
|
|
}
|
|
|
|
|
2023-07-30 16:51:44 +02:00
|
|
|
void CProgressPanel::CancelProgress()
|
2023-07-28 14:50:46 +02:00
|
|
|
{
|
|
|
|
this->m_CancelButton->SetEnabled(false);
|
|
|
|
this->m_CancelButton->SetText("Canceling...");
|
|
|
|
this->m_bCanceled = true;
|
|
|
|
}
|