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 Nick Thissen
on
Harold Darner wrote:
I was able to fix the Dynamic Image file by replacing return null with return value.

However, I cannot hide the CARNUM label.
I think it works when running in ATVO, but not in the editor. For the editor you also need to set "IsVisibleInEditor" separately.

Also, I noticed that the index of the label is not necessary the same as the index in which it's displayed in the list (Z-index). It is probably just the index in whatever order you added the labels to the subwidget, which is difficult to find back. I modified the script to look for the matching Z-index instead. Under Layout category for the label you can see the ZIndex of each label. Make sure to select the Zindex of the label with the normal carnum binding (not the dynamic image binding).

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using System.Linq;

namespace Scripts
{
public class CarNumberScript : 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;
if (label == null)
return null;

// Get the 'default carnumber' label to show instead
var index = 0; // The index (0-based) of your label in the template subwidget's list of labels
var subwidget = label.Parent;
var defaultLabel = subwidget.Labels.FirstOrDefault(l => l.ZIndex == index);

// Check if the dynamic image was found
var path = label.DynamicBackground.GetAbsolutePath(item.Theme);
if (System.IO.File.Exists(path))
{
// Show dynamic image label
defaultLabel.IsVisible = false;
defaultLabel.IsVisibleInEditor = false;
}
else
{
// Show regular label
defaultLabel.IsVisible = true;
defaultLabel.IsVisibleInEditor = true;
}

return value;
}
}
}


This seems to work fine for me.