using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using System.Windows.Media;
using ATVO.ThemesSDK.Data.Entity;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class SC_ClassColor : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value == null)
{
// do something appropriate, in this case probably just return nothing
return null;
}
var Classcolor = value.ToString();
var numClasses = sim.Session.ClassManager.Classes.Count;
var hex = "#17a5ff";
if (numClasses == 1)
return (Color) ColorConverter.ConvertFromString(hex);
else
return (Color) ColorConverter.ConvertFromString(Classcolor);
}
}
}
IEntitySessionResult result = (IEntitySessionResult) value;
ITrack result1 = (ITrack) value;
var classname = result.Entity.Car.Class.Name;
var track0 = result1.DisplayName;
return track0 + " " + classname;
Emmanuel Suter wrote:No, it doesn't work that way. I think you misunderstand the way script converters work.
I try to get different information from different places but in the same widget (so with same data set)
I want to add the track name in combinaison with classname for result title.
I try to catch information with something like that:IEntitySessionResult result = (IEntitySessionResult) value;
ITrack result1 = (ITrack) value;
var classname = result.Entity.Car.Class.Name;
var track0 = result1.DisplayName;
return track0 + " " + classname;
But track0 return no good value.
var result = (IEntitySessionResult) value;
ITrack track = sim.Session.Track;
Emmanuel Suter wrote:You can change the DataClassIndex property of the widget just by specifying a new value. The type must be one of the available values in the DataClassIndex enum. The possible values are:
Other things.
Is it possible to change Data Class filter of a widget ?
For some ticker or resluts, it will be intersting to just change that for show standing class1 or class2 or all.
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.Data;
namespace Scripts
{
public class ChangeClassIndex : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var widget = item.Theme.Widgets.Find("Widget1");
// Change to FollowedClass
widget.DataClassIndex = DataClassIndex.FollowedClass;
// Change to class 2
widget.DataClassIndex = DataClassIndex.Class2;
// Change to class "n" where n is an integer 1-10
var n = 5;
widget.DataClassIndex = (DataClassIndex)n;
return null;
}
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.Data;
using System.Collections.Generic;
namespace Scripts
{
public class ChangeTickerClassFilter : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Which ticker(s) are we changing?
List<Widget> tickers = new List<Widget>();
var tickerValue = (string)value;
if (tickerValue == "H")
{
// Horizontal ticker
tickers.Add(item.Theme.Widgets.Find("W_HTicker"));
}
else if (tickerValue == "V")
{
// Vertical ticker
tickers.Add(item.Theme.Widgets.Find("W_VTickerTop"));
tickers.Add(item.Theme.Widgets.Find("W_VTickerBottom"));
}
else if (tickerValue == "Grid")
{
// Grid tickers
tickers.Add(item.Theme.Widgets.Find("W_GridLeft"));
tickers.Add(item.Theme.Widgets.Find("W_GridRight"));
}
else if (tickerValue == "Results")
{
// Results ticker
tickers.Add(item.Theme.Widgets.Find("W_Results"));
}
// Default: all classes
DataClassIndex index = DataClassIndex.AllClasses;
// Find the dropdown and the index of the selected item
var dropdown = (Dropdown)item;
var selectedIndex = dropdown.Items.IndexOf(dropdown.SelectedItem);
if (selectedIndex >= 0)
{
// The index of the dropdown items happens to coincide with the class filter indices,
// so this is an easy way to set the index without a long list of "if" or switch statements
index = (DataClassIndex) selectedIndex;
}
// Finally change the class filter
// Also restart the ticker to have it recalculate which items to show
foreach (var ticker in tickers)
{
ticker.DataClassIndex = index;
ticker.Ticker.Restart();
}
return null;
}
}
}
Emmanuel Suter wrote:No, we don't get that info.
Hi.
Does it something for showing witch iRacing Split is watching ?
Emmanuel Suter wrote:Where does it say that? It seems to work fine for me.
Is it possible to search Storyboards in a scripts ?
var sybd = item.Theme.Storyboards.Find("SB1"); returns that it is not a function
Emmanuel Suter wrote:This is for Ticker with DropDown selection:
And if I want when I change Class, to use Class Position than Position (when i am not in AllClasses), we need to change DataOrder, but the name not match in my script.
Emmanuel Suter wrote:There is no Restart indeed. Just do Stop, then Play to start a new instance:
For stroryboard, error is when I want to make:
sybd.Restart();
Restart is not a definition of Storyboard
sybd.Stop(); // stops all instances of this storyboard
sybd.Play(); // starts a new instance
Emmanuel Suter wrote:You can use this:Emmanuel Suter wrote:This is for Ticker with DropDown selection:
And if I want when I change Class, to use Class Position than Position (when i am not in AllClasses), we need to change DataOrder, but the name not match in my script.
Is it possible to add in script to change to Dataorder --> liveposition if index=0 and Dataorder --> liveclassposition if index >= 1 ?
widget.DataOrder = DataSetManager.GetDataOrder("liveclassposition");
var dropdown = (Dropdown)item;
var selectedIndex = dropdown.Items.IndexOf(dropdown.SelectedItem);
var dataO = "";
if (selectedIndex == 0)
{
// The index of the dropdown items happens to coincide with the class filter indices,
// so this is an easy way to set the index without a long list of "if" or switch statements
index = (DataClassIndex) selectedIndex;
dataO ="liveposition";
}
if (selectedIndex >= 1)
{
// The index of the dropdown items happens to coincide with the class filter indices,
// so this is an easy way to set the index without a long list of "if" or switch statements
index = (DataClassIndex) selectedIndex;
dataO ="liveclassposition";
}
// Finally change the class filter
// Also restart the ticker to have it recalculate which items to show
foreach (var ticker in tickers)
{
ticker.DataOrder = DataSetManager.GetDataOrder(dataO);
ticker.DataClassIndex = index;
ticker.Ticker.Restart();
}
Nick Thissen wrote:Emmanuel Suter wrote:There is no Restart indeed. Just do Stop, then Play to start a new instance:
For stroryboard, error is when I want to make:
sybd.Restart();
Restart is not a definition of Storyboardsybd.Stop(); // stops all instances of this storyboard
sybd.Play(); // starts a new instance
var classId = 1;
var count = sim.Session.Entities.Where(e => e.Car.Class.Id == classId).Count();
// Group entities by class ID
var groups = sim.Session.Entities.GroupBy(e => e.Car.Class.Id);
// For each group (= class) get the ID and number of drivers
foreach (var group in groups)
{
var classId = group.Key;
var driverCount = group.Count();
}
var startTime = sim.Session.Options.StartDateTime;
var startHour = startTime.Hour;
var currentTime = sim.Telemetry.LiveDateTime;
var currentHour = currentTime.Hour;