Is it possible to create custom dynamic text fields through the SDK? Let's say (as a bad example) that I want to display the user's computer name on every printed layout. I would write some custom C# to extract the computer name, and ideally expose it through something like:
PC name: <dyn type="custom" property="computerName">
Which would then render as:
PC name: Donald's MacBook Pro
In case it wasn't clear, I'm just using this as a simple example - this isn't actually what I'm trying to do.
I can't figure out from the documentation whether this is possible, and where the rendering actually happens? Anyone have any ideas?
Solved! Go to Solution.
It doesn't look like Esri supports ways for devs to implement custom <dyn>s.
I'd try using the CustomProperties, maybe with a similar dyn-like language, to populate TextProperties.Text when a suitable event fires.
Careful with LayoutViewEvent - if TextProperties.Text is changed when it fires, an infinite loop can ensue.
As I recall, ActivePaneChangingEvent doesn't have this issue.
This sample shows how to update a text element:
Thanks for responding, but that example just illustrates changing text in a non-dynamic element. It's not clear how the value renders in a dynamic text element.
One theoretical approach would be to hook into an event called something like RenderDynamicTextElementEvent, but I can't see anything like that in the docs. Another might be to somehow tell the SDK to render the value in place of the dynamic text, but I can't see how to do that either.
It doesn't look like Esri supports ways for devs to implement custom <dyn>s.
I'd try using the CustomProperties, maybe with a similar dyn-like language, to populate TextProperties.Text when a suitable event fires.
Careful with LayoutViewEvent - if TextProperties.Text is changed when it fires, an infinite loop can ensue.
As I recall, ActivePaneChangingEvent doesn't have this issue.
Thanks! ActiveWindowChangingEvent (not Pane) seemed a good solution, although I haven't managed to get what I really want working at the moment. The events just seem too unpredictable - ElementsUpdatedEvent seemed promising, but it's really difficult to tell what's actually changed and very easy to fall into infinite loops.
I'm putting this on the back burner for now, but will accept your suggested solution above and will update if there are future developments.
For getting computername:
https://docs.microsoft.com/en-us/dotnet/api/system.environment.machinename?view=netframework-4.8