简体   繁体   English

如何使用C#监听ArcMap中的TimeSlider事件

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

I am updating rows of featureclasses via a plugin using C# and ArcObjects. 我正在使用C#和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. 为此,我想在代码中侦听timeslider更新事件。

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. 我已经看到与ArcSDE Direct Connection表相关的另一个错误,该Bug无法正确显示,但这不是我的问题,因为我没有使用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. 我的C#插件在ArcMap 10.1 SP1中运行。 Background enterprise geoDB is on SQLServer. 后台企业geoDB在SQLServer上。

Thanks! 谢谢!

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. 希望其他人会觉得有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM