How do I trigger a User-Defined event from the Smart Client programmatically?
The user enters a string and then I want to trigger the event with that exact name.
My best idea.
Search the configuration for the user defined event. (Perhaps GetItemsByKind or GetItemsBySearch)
Then use messaging and the TriggerCommand.
User-defined events seems like a gray-zone in general in the SDK doc. I currently use Corporate 2017 R2 as dev environment and when I do
var eventList = Configuration.Instance.GetItemsByKind(Kind.TriggerEvent, ItemHierarchy.UserDefined);
I get a single Item returned, and that’s the main server item. To reach the event items, I have to use this very horrific piece of code:
var eventList = Configuration.Instance.GetItemsByKind(Kind.TriggerEvent, ItemHierarchy.UserDefined);
foreach(Item item in eventList)
{
foreach (Item child in item.GetChildren())
{
foreach(Item item2 in child.GetChildren())
{
foreach(Item item3 in item2.GetChildren())
{
foreach (Item item4 in item3.GetChildren())
{
foreach (string usrEvent in eventStrings)
{
if(item4.Name == usrEvent)
{
PlaySoundUserControl btn = new PlaySoundUserControl(usrEvent, item4);
btn.Text = usrEvent;
flowLayoutPanel1.Controls.Add(btn);
}
}
}
}
}
}
}
I feel bad looking at it.. I don’t know if it works outside the Corporate hierarchy standard, as I need this to work on Express as well.
Please look at the FindCamera routine in the CameraStreamResolution sample, it shows how to effectively traverse the configuration.
This is how configuration works in MIP, the return object is as expected.
I recommend the ConfigAccessViaSDK sample or ConfigDump plugin sample to get a better understanding of the configuration in MIP.