Avatar

TsgcHTMLComponent_Avatar — renderize um avatar de usuário a partir de uma imagem ou iniciais com tamanho, forma e um ponto de status de presença, em Delphi, C++ Builder e .NET.

TsgcHTMLComponent_Avatar

Um avatar de usuário que mostra uma imagem ou iniciais. Defina o tamanho, a forma e o status de presença e então leia a propriedade HTML.

Classe do componente

TsgcHTMLComponent_Avatar

Renderiza

Markup do Bootstrap 5

Linguagens

Delphi, C++ Builder, .NET

Crie, defina a identidade, renderize

Atribua Initials (ou uma ImageURL), escolha um Size, Shape e Status e então leia HTML — ou use o helper estático de uma linha 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);

Principais propriedades & métodos

Os membros que você usa com mais frequência.

Identidade

ImageURL mostra uma foto; quando vazio, Initials renderiza um bloco colorido e AltText define o texto alternativo da imagem.

Tamanho

Size (TsgcHTMLAvatarSize: asSmall, asMedium, asLarge, asXLarge) dimensiona o avatar.

Forma

Shape (TsgcHTMLAvatarShape: apCircle, apRounded, apSquare) estiliza os cantos.

Status

Status (TsgcHTMLAvatarStatus: atOnline, atOffline, atBusy, atAway) desenha um ponto de presença; StatusBorderWidth e StatusBorderColor o contornam.

Cor

ColorStyle (TsgcHTMLColor) aplica tema ao bloco de iniciais; Color o substitui por um valor hex bruto.

Construção em uma linha

Build(aInitials, aSize, aColor, aStatus) e BuildImage(aImageURL, aSize, aStatus) retornam o HTML do avatar em uma única chamada estática.

Continue explorando

Todos os Componentes sgcHTMLExplore a matriz completa de recursos com mais de 60 componentes.
Baixar Versão de Avaliação GratuitaA avaliação de 30 dias inclui os projetos de demonstração 60.HTML.
PreçosLicenças Single, Team e Site com código-fonte completo.

Pronto para Começar?

Baixe a versão de avaliação gratuita e comece a construir UIs web em Delphi, C++ Builder e .NET.