using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using static ATVO.ThemeEditor.ThemeModels.SubWidgetTicker;

namespace Scripts
{
	public class SetHTickerLeadersCount : IScript
	{
		public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
		{
			var numClasses = sim.Session.ClassManager.Classes.Count;
			Console.WriteLine("Num classes: " + numClasses);
			var widget = item.Theme.Widgets.Find("W_HTickerLeaders");
			widget.Ticker.ItemCount = numClasses;
			widget.Ticker.HeaderSubWidget = widget.SubWidgets.Find("SW_LeadersHeader");

			if (numClasses > 4)
				widget.Ticker.Type = TickerTypes.Paging;
			else 
				widget.Ticker.Type = TickerTypes.Static;
				
			widget.Ticker.Restart();

			return null;
		}
	}
}