Is there a drawing completed/activation completed event for layouts?

85
2
07-26-2018 12:55 PM
Highlighted
New Contributor

Is there an event that can be subscribed to that will fire when a layout has been activated and drawing is complete? I'm trying to fire off a process that begins once the layout is available but it kicks off early and doesn't do anything.

Thanks,

Scott Dickison

LOJIC

Reply
0 Kudos
2 Replies
Highlighted
by Esri Regular Contributor
Esri Regular Contributor

Hi Scott,

 You can try to subscribe to this event: "ArcGIS.Desktop.Layouts.Events.LayoutViewEvent" and in the event handler you can look at the Type and IsReady attributes as shown in the code snippet below.  If args.Type is "Initialized" and args.LayoutView.IsReady is true your layout is ready to be 'processed'.   However, as I tested this event I did notice that the events are not kicked off if an 'active' layout is open in your Project file, instead the events only work if you change the active layout after the project is loaded.  I relayed your requirements and the issues I found to the development team and they are looking to fix these issues for the 2.3 release.

Below is the code I added to my Module class, ActiveLayoutEventsPaneViewModel is a property that defines my status display Dockpane.  I also set the 'autoload' attribute for the insertModule tag in the config.daml to true.  

private static void OnLayoutViewEvent (ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs args)
{
  // For display in my dockpane:
  if (ActiveLayoutEventsPaneViewModel != null)
  {
    var status = $@"LayoutViewEvent: {args.LayoutView.Layout.Name}{Environment.NewLine}   arg Type: {args.Type.ToString()}";
    if (args.LayoutView.IsReady) status += $@"{Environment.NewLine}   layoutView is Ready";
    ActiveLayoutEventsPaneViewModel.UpdateStatusText(status);       
  }
}

/// <summary>
/// gives this add-ins a chance to initialize itself and return its status to the calling Framework.
/// </summary>
/// <returns></returns>
protected override bool Initialize()
{
  // initialize layout events
  _subscriptionToken = ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe(OnLayoutViewEvent);
  return base.Initialize();
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

And this is the result after I opened a layout view:

I hope this helps,

- Wolf

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Hello Scott,

We are looking at this issue for a possible 2.3 fix.  Could you please clarify "layout activated / drawing complete".  There are two scenarios

1) A layout it initialized - this is when a layout is opened for the first time and drawing is completed.

2) An already opened layout view (TAB) is activated.

I assume you want to address #2 above.

But what about 3) a scenario where you programatically add a layer to a map or you rearrange layer order or you rearrange elements in the TOC?  These will also force a redraw.  Do you want to know when the layout has stopped drawing here too? 

Thanks,

Jeff

Reply
0 Kudos