Avatar

TsgcHTMLComponent_Avatar — renderizza un avatar utente da un'immagine o dalle iniziali con dimensione, forma e indicatore di stato di presenza, in Delphi, C++ Builder e .NET.

TsgcHTMLComponent_Avatar

Un avatar utente che mostra un'immagine oppure le iniziali. Imposta dimensione, forma e stato di presenza, quindi leggi la proprietà HTML.

Classe del componente

TsgcHTMLComponent_Avatar

Renderizza

Markup Bootstrap 5

Linguaggi

Delphi, C++ Builder, .NET

Crealo, imposta l'identità, renderizzalo

Assegna Initials (oppure un ImageURL), scegli una Size, una Shape e uno Status, quindi leggi HTML — oppure usa l'helper statico Build a riga singola.

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);

Proprietà e metodi principali

I membri che utilizzerai più spesso.

Identità

ImageURL mostra una foto; quando è vuoto, Initials renderizza un riquadro colorato e AltText imposta il testo alternativo dell'immagine.

Dimensione

Size (TsgcHTMLAvatarSize: asSmall, asMedium, asLarge, asXLarge) ridimensiona l'avatar.

Forma

Shape (TsgcHTMLAvatarShape: apCircle, apRounded, apSquare) definisce lo stile degli angoli.

Stato

Status (TsgcHTMLAvatarStatus: atOnline, atOffline, atBusy, atAway) disegna un indicatore di presenza; StatusBorderWidth e StatusBorderColor lo bordano.

Colore

ColorStyle (TsgcHTMLColor) applica il tema al riquadro delle iniziali; Color lo sovrascrive con un valore esadecimale grezzo.

Build a riga singola

Build(aInitials, aSize, aColor, aStatus) e BuildImage(aImageURL, aSize, aStatus) restituiscono l'HTML dell'avatar con una singola chiamata statica.

Continua a esplorare

Tutti i componenti sgcHTMLEsplora la matrice completa delle funzionalità di oltre 60 componenti.
Scarica la Prova GratuitaLa prova di 30 giorni include i progetti demo 60.HTML.
PrezziLicenze Single, Team e Site con codice sorgente completo.

Pronto a Iniziare?

Scarica la versione di prova gratuita e inizia a creare interfacce web in Delphi, C++ Builder e .NET.