ProgressBar
TsgcHTMLComponent_ProgressBar — Delphi、C++ Builder、.NET で、任意のラベルを備えたストライプ・アニメーション付きの Bootstrap プログレスバー、またはスタック型のマルチセグメントバーです。
TsgcHTMLComponent_ProgressBar — Delphi、C++ Builder、.NET で、任意のラベルを備えたストライプ・アニメーション付きの Bootstrap プログレスバー、またはスタック型のマルチセグメントバーです。
単一バーには Value と Max を設定し、スタック型のマルチセグメントバーには Bars にエントリーを追加してから、HTML プロパティを読み取ります。
TsgcHTMLComponent_ProgressBar
Bootstrap 5 の .progress バー(単一またはスタック型)
Delphi, C++ Builder, .NET
Value、Max、ColorStyle を設定し、必要に応じて Striped / Animated / ShowLabel を有効にしてから、HTML を読み取ります。
uses
sgcHTML_Enums, sgcHTML_Component_ProgressBar;
var
oBar: TsgcHTMLComponent_ProgressBar;
begin
oBar := TsgcHTMLComponent_ProgressBar.Create(nil);
try
oBar.ProgressBarID := 'upload';
oBar.Value := 72;
oBar.Max := 100;
oBar.ColorStyle := hcSuccess;
oBar.Striped := True;
oBar.Animated := True;
oBar.ShowLabel := True;
oBar.LabelFormat := '%d%% complete';
WebModule.Response := oBar.HTML; // Bootstrap progress bar
finally
oBar.Free;
end;
end;
// Or a stacked, multi-segment bar:
with oBar.Bars.Add do
begin
Value := 40;
ColorStyle := hcPrimary;
Label_ := 'Done';
end;
with oBar.Bars.Add do
begin
Value := 20;
ColorStyle := hcWarning;
Label_ := 'In progress';
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ProgressBar.hpp
TsgcHTMLComponent_ProgressBar *oBar = new TsgcHTMLComponent_ProgressBar(NULL);
try
{
oBar->ProgressBarID = "upload";
oBar->Value = 72;
oBar->Max = 100;
oBar->ColorStyle = hcSuccess;
oBar->Striped = true;
oBar->Animated = true;
oBar->ShowLabel = true;
oBar->LabelFormat = "%d%% complete";
String html = oBar->HTML; // Bootstrap progress bar
// Or a stacked, multi-segment bar:
TsgcHTMLProgressBarItem *oSeg1 = oBar->Bars->Add();
oSeg1->Value = 40;
oSeg1->ColorStyle = hcPrimary;
oSeg1->Label_ = "Done";
TsgcHTMLProgressBarItem *oSeg2 = oBar->Bars->Add();
oSeg2->Value = 20;
oSeg2->ColorStyle = hcWarning;
oSeg2->Label_ = "In progress";
}
__finally
{
delete oBar;
}
using esegece.sgcWebSockets;
var bar = new TsgcHTMLComponent_ProgressBar();
bar.ProgressBarID = "upload";
bar.Value = 72;
bar.Max = 100;
bar.ColorStyle = TsgcHTMLColor.hcSuccess;
bar.Striped = true;
bar.Animated = true;
bar.ShowLabel = true;
bar.LabelFormat = "%d%% complete";
string html = bar.HTML; // Bootstrap progress bar
// Or a stacked, multi-segment bar:
var seg1 = bar.Bars.Add();
seg1.Value = 40;
seg1.ColorStyle = TsgcHTMLColor.hcPrimary;
seg1.Label_ = "Done";
var seg2 = bar.Bars.Add();
seg2.Value = 20;
seg2.ColorStyle = TsgcHTMLColor.hcWarning;
seg2.Label_ = "In progress";
最もよく使うメンバーです。
Value と Max(デフォルト 100)は塗りつぶし幅をパーセンテージで設定します。ColorStyle は Bootstrap の色を選択し、Color で任意の CSS カラーを直接指定することもできます。
ShowLabel はバー内にパーセンテージテキストをレンダリングします。LabelFormat(デフォルト %d%%)はその書式を制御します。
Striped は斜めのストライプを追加します。Animated はストライプを含意し、バー全体でアニメーションさせます。
Bars.Add は TsgcHTMLProgressBarItem(Value、ColorStyle / Color、Label_)を追加します。Bars にエントリーがあると、単一の Value バーの代わりに使用されます。
Height はカスタムの CSS バー高さを設定します。ProgressBarID(または ElementID)は、フラグメントのプッシュ用に外側の <div class="progress"> に名前を付けます。
HTML はプログレスラッパーとそのバーセグメントを返し、埋め込んだり、値の変化に応じて WebSocket 経由でプッシュしたりできます。