Avatar

TsgcHTMLComponent_Avatar — affichez un avatar utilisateur à partir d'une image ou d'initiales avec taille, forme et point d'état de présence, en Delphi, C++ Builder et .NET.

TsgcHTMLComponent_Avatar

Un avatar utilisateur qui affiche soit une image, soit des initiales. Définissez la taille, la forme et l'état de présence, puis lisez la propriété HTML.

Classe du composant

TsgcHTMLComponent_Avatar

Produit

Du balisage Bootstrap 5

Langages

Delphi, C++ Builder, .NET

Créez-le, définissez l'identité, affichez-le

Affectez Initials (ou une ImageURL), choisissez une Size, une Shape et un Status, puis lisez HTML — ou utilisez l'assistant statique Build en une ligne.

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

Propriétés & méthodes clés

Les membres que vous utilisez le plus souvent.

Identité

ImageURL affiche une photo ; lorsqu'elle est vide, Initials rend une tuile colorée et AltText définit le texte alternatif de l'image.

Taille

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

Forme

Shape (TsgcHTMLAvatarShape : apCircle, apRounded, apSquare) stylise les coins.

Statut

Status (TsgcHTMLAvatarStatus : atOnline, atOffline, atBusy, atAway) dessine un point de présence ; StatusBorderWidth et StatusBorderColor l'entourent.

Couleur

ColorStyle (TsgcHTMLColor) thématise la tuile d'initiales ; Color la remplace par une valeur hexadécimale brute.

Construction en une ligne

Build(aInitials, aSize, aColor, aStatus) et BuildImage(aImageURL, aSize, aStatus) renvoient le HTML de l'avatar en un seul appel statique.

Continuez l'exploration

Tous les composants sgcHTMLParcourez la matrice complète des fonctionnalités de plus de 60 composants.
Télécharger la version d'essai gratuiteLa version d'essai de 30 jours fournit les projets de démonstration 60.HTML.
TarifsLicences Single, Team et Site avec code source complet.

Prêt à démarrer ?

Téléchargez la version d'essai gratuite et commencez à créer des interfaces web en Delphi, C++ Builder et .NET.