コード例 #1
0
        protected override void OnClick()
        {
            IMxDocument pMxDoc           = ArcMap.Document;
            IMap        pMap             = pMxDoc.FocusMap;
            string      sampeMapFileName = "BasicHurricanes.mxd";

            if (pMap.LayerCount < 1)
            {
                MessageBox.Show("Before running this sample, load the associated file \'" + sampeMapFileName + "\'");
                return;
            }
            if (pMap.get_Layer(0).Name != "atlantic_hurricanes_2000")
            {
                MessageBox.Show("Before running this sample, load the associated file \'" + sampeMapFileName + "\'");
                return;
            }

            ITimeZoneFactory pTZFac = new TimeZoneFactoryClass();
            //making the first layer of the focused map time-aware
            IFeatureLayer pFLyr     = pMap.get_Layer(0) as IFeatureLayer;
            ITimeData     pTimeData = pFLyr as ITimeData;

            String         localTimeZoneId = pTZFac.QueryLocalTimeZoneWindowsID();
            ITimeReference timeRef         = pTZFac.CreateTimeReferenceFromWindowsID(localTimeZoneId);

            if (pTimeData.SupportsTime)
            {
                pTimeData.UseTime = true;
                ITimeTableDefinition pTimeDataDef = pFLyr as ITimeTableDefinition;
                pTimeDataDef.StartTimeFieldName = "Date_Time";

                pTimeDataDef.TimeReference = timeRef;
                ITimeDataDisplay pTimeAnimProp = pFLyr as ITimeDataDisplay;
                pTimeAnimProp.TimeIntervalUnits = esriTimeUnits.esriTimeUnitsHours;
                pTimeAnimProp.TimeInterval      = 12.0;
            }

            //
            IActiveView    pActiveView    = pMap as IActiveView;
            IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay;
            ITimeDisplay   pTimeDisplay   = pScreenDisplay as ITimeDisplay;

            pTimeDisplay.TimeReference = timeRef;

            ITime pStartTime = new TimeClass();

            pStartTime.Year = 2000; pStartTime.Month = 9; pStartTime.Day = 25;
            ITime pEndTime = new TimeClass();

            pEndTime.Year = 2000; pEndTime.Month = 9; pEndTime.Day = 30;

            ITimeExtent pTimeExt = new TimeExtentClass();

            pTimeExt.StartTime     = pStartTime;
            pTimeExt.EndTime       = pEndTime;
            pTimeDisplay.TimeValue = pTimeExt as ITimeValue;

            pActiveView.ContentsChanged();
        }
コード例 #2
0
    protected override void OnClick()
    {
      IMxDocument pMxDoc = ArcMap.Document;
      IMap pMap = pMxDoc.FocusMap;
      string sampeMapFileName = "BasicHurricanes.mxd";

      if (pMap.LayerCount < 1)
      {
        MessageBox.Show("Before running this sample, load the associated file \'" + sampeMapFileName + "\'");
        return;
      }
      if (pMap.get_Layer(0).Name != "atlantic_hurricanes_2000")
      {
        MessageBox.Show("Before running this sample, load the associated file \'" + sampeMapFileName + "\'");
        return;
      }

      ITimeZoneFactory pTZFac = new TimeZoneFactoryClass();
      //making the first layer of the focused map time-aware
      IFeatureLayer pFLyr = pMap.get_Layer(0) as IFeatureLayer;
      ITimeData pTimeData = pFLyr as ITimeData;

      String localTimeZoneId = pTZFac.QueryLocalTimeZoneWindowsID();
      ITimeReference timeRef = pTZFac.CreateTimeReferenceFromWindowsID(localTimeZoneId);
      if (pTimeData.SupportsTime)
      {
        pTimeData.UseTime = true;
        ITimeTableDefinition pTimeDataDef = pFLyr as ITimeTableDefinition;
        pTimeDataDef.StartTimeFieldName = "Date_Time";

        pTimeDataDef.TimeReference = timeRef;
        ITimeDataDisplay pTimeAnimProp = pFLyr as ITimeDataDisplay;
        pTimeAnimProp.TimeIntervalUnits = esriTimeUnits.esriTimeUnitsHours;
        pTimeAnimProp.TimeInterval = 12.0;
      }

      //
      IActiveView pActiveView = pMap as IActiveView;
      IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay;
      ITimeDisplay pTimeDisplay = pScreenDisplay as ITimeDisplay;
      pTimeDisplay.TimeReference = timeRef;

      ITime pStartTime = new TimeClass();
      pStartTime.Year = 2000; pStartTime.Month = 9; pStartTime.Day = 25;
      ITime pEndTime = new TimeClass();
      pEndTime.Year = 2000; pEndTime.Month = 9; pEndTime.Day = 30;

      ITimeExtent pTimeExt = new TimeExtentClass();
      pTimeExt.StartTime = pStartTime;
      pTimeExt.EndTime = pEndTime;
      pTimeDisplay.TimeValue = pTimeExt as ITimeValue;

      pActiveView.ContentsChanged();
    }
        protected override void OnClick()
        {
            IMxDocument pMxDoc   = ArcMap.Document;
            IMap        pMap     = pMxDoc.FocusMap;
            string      filename = "TimeAwareHurricanes.mxd";

            if (pMap.LayerCount < 1)
            {
                MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'");
                return;
            }
            if (pMap.get_Layer(0).Name != "atlantic_hurricanes_2000")
            {
                MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'");
                return;
            }
            ILayer selectedLayer = ArcMap.Document.SelectedLayer;

            if (selectedLayer == null)
            {
                MessageBox.Show("There is no selected layer.  Select a time-aware layer");
                return;
            }
            ITimeZoneFactory pTZFac    = new TimeZoneFactoryClass();
            IFeatureLayer    pFLyr     = selectedLayer as IFeatureLayer;
            ITimeData        pTimeData = pFLyr as ITimeData;

            //making the first layer of the focused map time-aware
            if (pTimeData.SupportsTime)
            {
                pTimeData.UseTime = true;
                ITimeDataDisplay pTimeAnimProp = pFLyr as ITimeDataDisplay;
                pTimeAnimProp.TimeOffsetUnits = esriTimeUnits.esriTimeUnitsYears;
                pTimeAnimProp.TimeOffset      = System.DateTime.Now.Year - 2000;
            }
            else
            {
                MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'");
                return;
            }

            IActiveView pActiveView = pMap as IActiveView;

            pActiveView.Refresh();
        }
コード例 #4
0
    protected override void OnClick()
    {
      IMxDocument pMxDoc = ArcMap.Document;
      IMap pMap = pMxDoc.FocusMap;
      string filename = "TimeAwareHurricanes.mxd";

      if (pMap.LayerCount < 1)
      {
        MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'");
        return;
      }
      if (pMap.get_Layer(0).Name != "atlantic_hurricanes_2000")
      {
        MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'");
        return;
      }
      ILayer selectedLayer = ArcMap.Document.SelectedLayer;
      if (selectedLayer == null)
      {
          MessageBox.Show("There is no selected layer.  Select a time-aware layer");
          return;
      }
      ITimeZoneFactory pTZFac = new TimeZoneFactoryClass();
      IFeatureLayer pFLyr = selectedLayer as IFeatureLayer;
      ITimeData pTimeData = pFLyr as ITimeData;

      //making the first layer of the focused map time-aware
      if (pTimeData.SupportsTime)
      {
        pTimeData.UseTime = true;
        ITimeDataDisplay pTimeAnimProp = pFLyr as ITimeDataDisplay;
        pTimeAnimProp.TimeOffsetUnits = esriTimeUnits.esriTimeUnitsYears;
        pTimeAnimProp.TimeOffset = System.DateTime.Now.Year - 2000;
      }
      else
      {
        MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'");
        return;
      }

      IActiveView pActiveView = pMap as IActiveView;
      pActiveView.Refresh();
    }