Report post

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.


Post

Posted by Josh L
on
Working on a script that will automatically hide one label and show another when another widget has a dynamic background. Getting the "Object reference not set to an instance of an object" error in the event log and I have no idea why.

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;

namespace Scripts
{
public class ShowDriverScript : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Get the label running this converter script
// This label is showing the dynamic image
var label = item as Label;

var path = label.DynamicBackground.GetAbsolutePath(item.Theme);

var widget = item.Theme.Widgets.Find("W_DriverInfoLarge");
var subw = widget.SubWidgets.Find("SW_DriverInfoFollowL_Base");
var normlabel = subw.Labels.Find("L_DriverInfoFollowL_Number");
var newlabel = subw.Labels.Find("L_DriverInfoFollowL_Number_Driver");

if (System.IO.File.Exists(path))
{
normlabel.AnimateHide("0");
newlabel.AnimateShow("0");
return "";
}

else
{
normlabel.AnimateShow("0");
newlabel.AnimateHide("0");
return "";
}
}
}
}