Avatar
TsgcHTMLComponent_Avatar — 从图片或首字母渲染用户头像,带有尺寸、形状和在线状态圆点,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_Avatar — 从图片或首字母渲染用户头像,带有尺寸、形状和在线状态圆点,适用于 Delphi、C++ Builder 和 .NET。
一个显示图片或首字母的用户头像。设置尺寸、形状和在线状态,然后读取 HTML 属性。
赋值 Initials(或 ImageURL),选择 Size、Shape 和 Status,然后读取 HTML — 或使用静态的一行 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);
您最常使用的成员。
ImageURL 显示一张照片;为空时,Initials 渲染一个着色磁贴,AltText 设置图片替代文本。
Size(TsgcHTMLAvatarSize:asSmall、asMedium、asLarge、asXLarge)缩放头像。
Shape(TsgcHTMLAvatarShape:apCircle、apRounded、apSquare)设置边角样式。
Status(TsgcHTMLAvatarStatus:atOnline、atOffline、atBusy、atAway)绘制一个在线状态圆点;StatusBorderWidth 和 StatusBorderColor 为其加上圆环。
ColorStyle(TsgcHTMLColor)为首字母磁贴设置主题;Color 用原始十六进制值覆盖它。
Build(aInitials, aSize, aColor, aStatus) 和 BuildImage(aImageURL, aSize, aStatus) 通过单个静态调用返回头像 HTML。