Komponent ProgressBar — sgcHTML | eSeGeCe

ProgressBar

TsgcHTMLComponent_ProgressBar — pasek postępu Bootstrap, w paski i animowany, z opcjonalną etykietą, lub skumulowany pasek wieloczęściowy, w Delphi, C++ Builder i .NET.

TsgcHTMLComponent_ProgressBar

Ustaw Value i Max dla pojedynczego paska, lub dodaj wpisy do Bars dla skumulowanego paska wieloczęściowego, a następnie odczytaj właściwość HTML.

Klasa komponentu

TsgcHTMLComponent_ProgressBar

Renderuje

Pasek .progress Bootstrap 5 (pojedynczy lub skumulowany)

Języki

Delphi, C++ Builder, .NET

Ustaw wartość, dodaj styl, wyrenderuj

Ustaw Value, Max i ColorStyle, włącz Striped / Animated / ShowLabel w razie potrzeby, a następnie odczytaj 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";

Kluczowe właściwości i metody

Składniki, po które sięgasz najczęściej.

Pojedynczy pasek

Value i Max (domyślnie 100) ustawiają szerokość wypełnienia w procentach; ColorStyle wybiera kolor Bootstrap, lub ustaw surowy kolor CSS za pomocą Color.

Etykieta

ShowLabel renderuje tekst procentowy wewnątrz paska; LabelFormat (domyślnie %d%%) określa sposób jego formatowania.

Paski i animacja

Striped dodaje ukośne paski; Animated zakłada włączone paski i animuje je wzdłuż paska.

Segmenty skumulowane

Bars.Add dodaje TsgcHTMLProgressBarItem (Value, ColorStyle / Color, Label_); gdy Bars zawiera wpisy, zastępują one pojedynczy pasek Value.

Rozmiar i identyfikator

Height ustawia niestandardową wysokość paska w CSS; ProgressBarID (lub ElementID) nadaje nazwę zewnętrznemu <div class="progress"> na potrzeby wysyłania fragmentów.

Wynik

HTML zwraca kontener paska wraz z jego segmentami, gotowy do osadzenia lub przesyłania przez WebSockets przy zmianie wartości.

Poznawaj dalej

Pomoc onlinePełna dokumentacja API i przewodnik użytkowania tego komponentu.
Wszystkie komponenty sgcHTMLPrzejrzyj pełną matrycę funkcji 80+ komponentów.
Pobierz bezpłatną wersję próbną30-dniowa wersja próbna zawiera projekty demonstracyjne 60.HTML.
CennikLicencje Single, Team i Site z pełnym kodem źródłowym.

Gotowy, aby zacząć?

Pobierz bezpłatną wersję próbną i dodaj paski postępu do swojej aplikacji webowej w Delphi, C++ Builder lub .NET.