Skip to content
AppgineeringAppgineering
Shop
Read-only2 posts · 2,613 views · Started 05 May 2021, 18:44

Displaying Colors as a Background from a Hex Value on a spreadsheet.

Archived: discussion moved to DiscordDiscord
Gary S.Original poster
#1

I'd like to know how I could go about having a dynamic background fill on a label that is being read from a corresponding hex value that is on a linked spreadsheet?

Nick ThissenAppgineering
#2

For now you'll need a small script to convert the color string (e.g. hex) to an actual color. I have some plans to automate that in a next version but that isn't working yet. Add a new C# script and copy the code from below.

The rest is simple: add your spreadsheet to the theme, go to your label and find the Overrides category, then find the Override Background Color property. Choose your spreadsheet column that has the hex color as your data binding. Then choose the script as the converter script.

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using System.Windows.Media;

namespace Scripts
{
	public class StringToColorConverter : IScript
	{
		public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
		{	
			var colorString = value?.ToString();
			if (string.IsNullOrWhiteSpace(colorString))
				return Colors.Transparent;
							
			return (Color)ColorConverter.ConvertFromString(colorString);
		}
	}
}

This thread is archived.

New replies have moved to Discord.

Continue on Discord