Resource

Resource Basics

Resource Name Category Color Bar
Resource Version 1.0
Category Custom Thumbnail Info
Downloads 804
Release Date 9/25/2021 12:45:42 PM
 

Resource Details

Description This script shows a custom thumb line with blocks for every applicable category.
Installation Instructions Select the script from the drop down in a custom thumb info line -> From Repository

or

1. Store the script on the local hard drive
2. Open the script in a text editor
3. Copy/Paste the content of the script to a custom thumb info line
Usage Instructions see installation instructions
Changes in this version n.a.
Special Requirements
 

Author Information

Author Name IDimager Support
 

Available Attachments

Attachment #1 Category Color Bar.png
 

Script

%code

  procedure PreparePropsForCats(AProps: TCatalogItemProps; ACats: TCatalogPropCategories);
  var
    i: Integer;
    ACat: TCatalogPropCategory;
  begin
    for i := 0 to AProps.Count - 1 do
    begin
      AProps.Items[i].Name := '';
      ACat := TCatalogPropCategory.Create(nil);
      try        
        if PublicCatalog.EnumCategoryForProp(AProps.Items[i], ACat) then
          AProps.Items[i].Name := ACat.GUID;
      finally
        ACat.Free;
      end;
    end;
  end;

  function AddCatMarker(ACat: TCatalogPropCategory; AProps: TCatalogItemProps);
  var
    i, ACount: Integer;
  begin
    // add a color marker, when one of the props is from the category
    result := '';

    ACount := 0;
    for i := 0 to AProps.Count - 1 do
    begin
      if AProps.Items[i].Name = ACat.GUID then
        ACount := ACount + 1;
    end;

    if (ACount > 0) {and (ACat.UseColor)} then
      result := '<span alt="' + ACat.CategoryName + ' (' + IntToStr(ACount) + ')' + '" ><font style="background-color: ' + ACat.Color + '; color: ' + ACat.FontColor + '; width:30%;" width="50%">&nbsp;&nbsp;' + IntToStr(ACount) + '&nbsp;&nbsp;</font></span>';
  end;

var
  ACats: TCatalogPropCategories;
  AProps: TCatalogItemProps;
  i: Integer;
begin
  result := '';

  ACats := TCatalogPropCategories.Create(TCatalogPropCategory, '');
  AProps := TCatalogItemProps.Create(TCatalogItemProp, '');
  try
    PublicCatalog.EnumCategories(ACats, False);
    PublicCatalog.EnumPropsForImage(ImageItem, AProps, False, False);

    PreparePropsForCats(AProps, ACats);

    for i := 0 to ACats.Count - 1 do
      result := result + AddCatMarker(ACats.Items[i], AProps)
  finally
    AProps.Free;
    ACats.Free;
  end;
end;
%/code