ATVO by Appgineering
Download
Read-only

Override Ticker background colour based on Spreadsheet data

3 posts 3,186 views Started 13 Sept 2021, 15:06
Showing 1–3 of 3 posts
Jeremy K.
Original poster

Hi all,

I have another question related to my Schedule.csv that I'm using in my theme. The schedule.csv links to a Ticker Widget and the Sub Widget template is for a row of each race week.

Schedule.csv is simple:

WEEK# TRACK SERIES CAR
1 <Track 1> <Series 1>
2 <Track 2> <Series 2>
3 <Track 3> <Series 3>
...

What I would like to automate is having the row for the current week when displayed in the Ticker have a different background colour, driven by a value in the spreadsheet. So, I'd like to modify schedule.csv so it looks like:

WEEK# TRACK SERIES CAR CURRENT WEEK
1 <Track 1> <Series 1>
2 <Track 2> <Series 2> YES
3 <Track 3> <Series 3>

And for the override background colour for the Sub Widget of the Ticker template to use the logic "if value of Current Week = 'Yes', then use Override background colour of #434343FF.

.. but I'm not a developer, so while I know the logic of what I want to build, I'm not fluent in scripting language to define it.

Any assistance greatly appreciated :)

Thanks!

-Jeremy

Nick Thissen Appgineering
Reply #1

This is pretty simple to achieve with OverrideBackground property. There are basically two options. I assume you use your schedule spreadsheet as the Data Set for the Widget.

Bind the OverrideBackground of the SubWidget that you use as a ticker template to the "Current" column of the spreadsheet. Then use the following script as converter to convert the "YES" case to a color, and any other case to a transparent color (or whatever color you want):

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

namespace Scripts
{
	public class ScheduleBackground : IScript
	{
		private Color CurrentColor = (Color) ColorConverter.ConvertFromString("#434343FF");
		private Color NotCurrentColor = Colors.Transparent;

		public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
		{	
			if (value != null)
			{
				if (value.ToString() == "YES")
					return CurrentColor;
			}				
			return NotCurrentColor;
		}
	}
}
Archive · Read-only

New replies have moved to Discord.