Avatar

TsgcHTMLComponent_Avatar — renderuje awatar użytkownika z obrazu lub inicjałów z rozmiarem, kształtem i kropką statusu obecności, w Delphi, C++ Builder i .NET.

TsgcHTMLComponent_Avatar

Awatar użytkownika, który pokazuje obraz lub inicjały. Ustaw rozmiar, kształt i status obecności, a następnie odczytaj właściwość HTML.

Klasa komponentu

TsgcHTMLComponent_Avatar

Renderuje

Znaczniki Bootstrap 5

Języki

Delphi, C++ Builder, .NET

Utwórz go, ustaw tożsamość, wyrenderuj

Przypisz Initials (lub ImageURL), wybierz Size, Shape i Status, a następnie odczytaj HTML — albo użyj statycznej, jednolinijkowej metody pomocniczej Build.

uses
  sgcHTML_Enums, sgcHTML_Component_Avatar;

var
  oAv: TsgcHTMLComponent_Avatar;
begin
  oAv := TsgcHTMLComponent_Avatar.Create(nil);
  try
    oAv.Initials := 'JS';
    oAv.AltText := 'Jane Smith';
    oAv.Size := asLarge;
    oAv.Shape := apCircle;
    oAv.ColorStyle := hcPrimary;
    oAv.Status := atOnline;

    WebModule.Response := oAv.HTML;   // avatar markup
  finally
    oAv.Free;
  end;
end;

// Or in a single line with the static helpers:
Result := TsgcHTMLComponent_Avatar.Build('JS', asLarge, '#0d6efd', atOnline);
Result := TsgcHTMLComponent_Avatar.BuildImage('/img/jane.jpg', asLarge, atOnline);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Avatar.hpp

TsgcHTMLComponent_Avatar *oAv = new TsgcHTMLComponent_Avatar(NULL);
try
{
  oAv->Initials = "JS";
  oAv->AltText = "Jane Smith";
  oAv->Size = asLarge;
  oAv->Shape = apCircle;
  oAv->ColorStyle = hcPrimary;
  oAv->Status = atOnline;

  String html = oAv->HTML;   // avatar markup
}
__finally
{
  delete oAv;
}

// Or in a single line with the static helpers:
String html = TsgcHTMLComponent_Avatar::Build("JS", asLarge, "#0d6efd", atOnline);
String img = TsgcHTMLComponent_Avatar::BuildImage("/img/jane.jpg", asLarge, atOnline);
using esegece.sgcWebSockets;

var avatar = new TsgcHTMLComponent_Avatar();
avatar.Initials = "JS";
avatar.AltText = "Jane Smith";
avatar.Size = TsgcHTMLAvatarSize.asLarge;
avatar.Shape = TsgcHTMLAvatarShape.apCircle;
avatar.ColorStyle = TsgcHTMLColor.hcPrimary;
avatar.Status = TsgcHTMLAvatarStatus.atOnline;

string html = avatar.HTML;   // avatar markup

// Or in a single line with the static helpers:
string oneLine = TsgcHTMLComponent_Avatar.Build("JS", TsgcHTMLAvatarSize.asLarge,
    "#0d6efd", TsgcHTMLAvatarStatus.atOnline);
string fromImage = TsgcHTMLComponent_Avatar.BuildImage("/img/jane.jpg",
    TsgcHTMLAvatarSize.asLarge, TsgcHTMLAvatarStatus.atOnline);

Kluczowe właściwości i metody

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

Tożsamość

ImageURL pokazuje zdjęcie; gdy jest puste, Initials renderuje kolorowy kafelek, a AltText ustawia tekst alternatywny obrazu.

Rozmiar

Size (TsgcHTMLAvatarSize: asSmall, asMedium, asLarge, asXLarge) skaluje awatar.

Kształt

Shape (TsgcHTMLAvatarShape: apCircle, apRounded, apSquare) nadaje styl narożnikom.

Status

Status (TsgcHTMLAvatarStatus: atOnline, atOffline, atBusy, atAway) rysuje kropkę obecności; StatusBorderWidth i StatusBorderColor ją obramowują.

Kolor

ColorStyle (TsgcHTMLColor) nadaje motyw kafelkowi z inicjałami; Color nadpisuje go surową wartością szesnastkową.

Budowa w jednej linii

Build(aInitials, aSize, aColor, aStatus) i BuildImage(aImageURL, aSize, aStatus) zwracają HTML awatara w pojedynczym statycznym wywołaniu.

Poznawaj dalej

Wszystkie komponenty sgcHTMLPrzejrzyj pełną matrycę funkcji 60+ 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 zacznij budować interfejsy webowe w Delphi, C++ Builder i .NET.