Are you sure you want to report the post shown below? This will send an email to the ATVO administrators. Please include a short reason for reporting.
Users reporting for no reason may be locked out.
public class ChangeResultsMode : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// The name of the desired template is passed to the script as the value
var templateName = value?.ToString();
if (!string.IsNullOrWhiteSpace(templateName))
{
// Find the ticker and the desired template subwidget
var resultsTicker = item.Theme.Widgets.Find("W_ResultsTicker");
var template = resultsTicker.SubWidgets.Find(templateName);
// Change the template
if (template != null)
{
resultsTicker.Ticker.TemplateSubWidget = template;
}
else
{
Console.WriteLine("Invalid results ticker template subwidget name: " + templateName);
}
}
return null;
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.Data;
using System.Collections.Generic;
using System.Linq;
namespace Scripts
{
public class ChangeDriverInfoBottomBinding : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value is string)
{
var bindingKey = value?.ToString();
Console.WriteLine("Changing driver info binding to " + bindingKey);
var widgets = new List<Widget>();
widgets.Add(item.Theme.Widgets.Find("W_DriverInfo"));
widgets.Add(item.Theme.Widgets.Find("W_DriverInfoRight"));
foreach (var widget in widgets)
{
var binding = widget.DataSet.GetBindingByKey(bindingKey);
var subwidget = widget.SubWidgets.FirstOrDefault(sw => sw.Name.StartsWith("SW_DriverInfo"));
var label = subwidget?.Labels.FirstOrDefault(l => l.Name.StartsWith("L_DriverInfoBottom"));
if (label != null)
{
label.DataBindings.Clear();
if (binding != null)
{
label.DataBindings.Add(binding);
label.Text = "{0}";
}
else
{
label.Text = "";
}
}
else {
Console.WriteLine("Did not find label");
}
}
}
return null;
}
}
}