Search code examples
c#eventstimearcmaparcobjects

How do I listen for TimeSlider Event in ArcMap using C#


I am updating rows of featureclasses via a plugin using C# and ArcObjects. For some reason the featureclasses then are not refreshing properly when the slider is moved, they do display properly if I manually refresh the map, however. I want to test if forcing a full refresh of the display on timeslider updates will work around the issue. In order to do that I want to listen for timeslider update events in my code.

I have seen another bug related to ArcSDE Direct Connection tables not displaying properly, but this is not my issue as I am not using an ArcSDE Direct Connection.

I have also recomputed attribute indexes (on time field) and spatial indexes but no dice.

So, hoping that refreshing on timeslider updates might help.

My C# plugin is running in ArcMap 10.1 SP1. Background enterprise geoDB is on SQLServer.

Thanks!


Solution

  • After a day of searching I posted my question, then found my solution within an hour.

    ITimeDisplayEvents_DisplayTimeChangedEventHandler DTC_EH;
    
    
    
        private void enableTimeDisplayEventHandler(bool enable = true)
            {
    
                IMxDocument pMxDoc = ArcMap.Document;
                IMap pMap = pMxDoc.FocusMap;
                IActiveView pActiveView = pMap as IActiveView;
                IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay;
                ITimeDisplay pTimeDisplay = pScreenDisplay as ITimeDisplay;
    
        DTC_EH = new ITimeDisplayEvents_DisplayTimeChangedEventHandler(this.OnDisplayTimeChangedEventHandler);
                            ((ITimeDisplayEvents_Event)pTimeDisplay).DisplayTimeChanged += DTC_EH;
    }
    
    
    private void OnDisplayTimeChangedEventHandler(IDisplay d, object oldvalue, object newvalue)
    {
                IMxDocument pMxDoc = ArcMap.Document;
                IMap pMap = pMxDoc.FocusMap;
                IActiveView pActiveView = pMap as IActiveView;
                pActiveView.Refresh();
    }
    

    Hopefully somebody else finds that useful.