public void UpdateCurrentTime(double progress)
        {
            if (progress <= 0)
            {
                progress = 0.05;
            }
            else if (progress >= 100)
            {
                progress = 0.95;
            }

            //Calculate how far into the layer to jump
            ITimeDuration offsetToNewCurrentTime = m_myLayerTimeExtent.QueryTimeDuration();

            offsetToNewCurrentTime.Scale(progress);

            IMxDocument    pMxDoc         = ArcMap.Document;
            IMap           pMap           = pMxDoc.FocusMap;
            IActiveView    pActiveView    = pMap as IActiveView;
            IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay;
            ITimeDisplay   pTimeDisplay   = pScreenDisplay as ITimeDisplay;

            ITime startTime = m_myLayerTimeExtent.StartTime;
            ITime endTime   = (ITime)((IClone)startTime).Clone();

            ((ITimeOffsetOperator)endTime).AddDuration(m_layerInterval);
            ITimeExtent pTimeExt = new TimeExtentClass();

            pTimeExt.SetExtent(startTime, endTime);
            pTimeExt.Empty = false;
            ((ITimeOffsetOperator)pTimeExt).AddDuration(offsetToNewCurrentTime);
            pTimeDisplay.TimeValue = pTimeExt as ITimeValue;
            pActiveView.Refresh();
        }
        /// <summary>
        /// Sets an event definition for the timer with a time duration.
        /// </summary>
        /// <param name="timerDuration"> the time duration of the timer </param>
        /// <returns> the builder object </returns>
        public virtual ICatchEventBuilder <TE> TimerWithDuration(string timerDuration)
        {
            ITimeDuration timeDuration = CreateInstance <ITimeDuration>(typeof(ITimeDuration));

            timeDuration.TextContent = timerDuration;

            ITimerEventDefinition timerEventDefinition = CreateInstance <ITimerEventDefinition>(typeof(ITimerEventDefinition));

            timerEventDefinition.TimeDuration = timeDuration;

            element.EventDefinitions.Add(timerEventDefinition);

            return(this);
        }
        protected override void OnClick()
        {
            IMxDocument pMxDoc = ArcMap.Document;

            if (pMxDoc.SelectedLayer == null)
            {
                MessageBox.Show("There is no layer selected.  First select a time-aware layer.");
                return;
            }

            IFeatureLayer pFLyr     = pMxDoc.SelectedLayer as IFeatureLayer;
            ITimeData     pTimeData = pFLyr as ITimeData;

            if (!pTimeData.SupportsTime)
            {
                MessageBox.Show("Select a time-aware layer first.");
                return;
            }
            m_myLayerTimeExtent = pTimeData.GetFullTimeExtent();

            ITimeDataDisplay pTimeDataDisplayProperties = pFLyr as ITimeDataDisplay;
            esriTimeUnits    LayerIntervalUnits         = pTimeDataDisplayProperties.TimeIntervalUnits;
            double           LayerInterval = pTimeDataDisplayProperties.TimeInterval;
            ITime            startTime     = m_myLayerTimeExtent.StartTime;
            ITime            endTime       = (ITime)((IClone)startTime).Clone();

            switch (LayerIntervalUnits)
            {
            case esriTimeUnits.esriTimeUnitsYears:
                ((ITimeOffsetOperator)endTime).AddYears(LayerInterval, false, true);
                break;

            case esriTimeUnits.esriTimeUnitsMonths:
                ((ITimeOffsetOperator)endTime).AddMonths(LayerInterval, false, true);
                break;

            case esriTimeUnits.esriTimeUnitsDays:
                ((ITimeOffsetOperator)endTime).AddDays(LayerInterval);
                break;

            case esriTimeUnits.esriTimeUnitsHours:
                ((ITimeOffsetOperator)endTime).AddHours(LayerInterval);
                break;

            case esriTimeUnits.esriTimeUnitsMinutes:
                ((ITimeOffsetOperator)endTime).AddMinutes(LayerInterval);
                break;

            case esriTimeUnits.esriTimeUnitsSeconds:
                ((ITimeOffsetOperator)endTime).AddSeconds(LayerInterval);
                break;
            }

            ITimeExtent pTimeExt = new TimeExtentClass();

            pTimeExt.SetExtent(startTime, endTime);
            m_layerInterval = pTimeExt.QueryTimeDuration();


            m_sliderDlg = new TimeSliderDialog(this);
            m_sliderDlg.Show();
        }
    protected override void OnClick()
    {
      IMxDocument pMxDoc = ArcMap.Document;
      if (pMxDoc.SelectedLayer == null)
      {
        MessageBox.Show("There is no layer selected.  First select a time-aware layer.");
        return;
      }

      IFeatureLayer pFLyr = pMxDoc.SelectedLayer as IFeatureLayer;
      ITimeData pTimeData = pFLyr as ITimeData;
      if (!pTimeData.SupportsTime)
      {
        MessageBox.Show("Select a time-aware layer first.");
        return;
      }
      m_myLayerTimeExtent = pTimeData.GetFullTimeExtent();

      ITimeDataDisplay pTimeDataDisplayProperties = pFLyr as ITimeDataDisplay;
      esriTimeUnits LayerIntervalUnits = pTimeDataDisplayProperties.TimeIntervalUnits;
      double LayerInterval = pTimeDataDisplayProperties.TimeInterval;
      ITime startTime = m_myLayerTimeExtent.StartTime;
      ITime endTime = (ITime)((IClone)startTime).Clone();

      switch (LayerIntervalUnits)
      {
        case esriTimeUnits.esriTimeUnitsYears:
          ((ITimeOffsetOperator)endTime).AddYears(LayerInterval, false, true);
          break;
        case esriTimeUnits.esriTimeUnitsMonths:
          ((ITimeOffsetOperator)endTime).AddMonths(LayerInterval, false, true);
          break;
        case esriTimeUnits.esriTimeUnitsDays:
          ((ITimeOffsetOperator)endTime).AddDays(LayerInterval);
          break;
        case esriTimeUnits.esriTimeUnitsHours:
          ((ITimeOffsetOperator)endTime).AddHours(LayerInterval);
          break;
        case esriTimeUnits.esriTimeUnitsMinutes:
          ((ITimeOffsetOperator)endTime).AddMinutes(LayerInterval);
          break;
        case esriTimeUnits.esriTimeUnitsSeconds:
          ((ITimeOffsetOperator)endTime).AddSeconds(LayerInterval);
          break;
      }

      ITimeExtent pTimeExt = new TimeExtentClass();
      pTimeExt.SetExtent(startTime, endTime);
      m_layerInterval = pTimeExt.QueryTimeDuration();


      m_sliderDlg = new TimeSliderDialog(this);
      m_sliderDlg.Show();
    }
Beispiel #5
0
        protected override void OnClick()
        {
            m_pApp = (IApplication)ArcMap.Application;
            if (m_pApp == null)
            {
                //if the app is null then could be running from ArcCatalog
                m_pApp = (IApplication)ArcCatalog.Application;
            }

            if (m_pApp == null)
            {
                MessageBox.Show("Could not access the application.", "No Application found");
                return;
            }
            IGxApplication pGXApp = (IGxApplication)m_pApp;

            stdole.IUnknown pUnk = null;
            try
            {
                pUnk = (stdole.IUnknown)pGXApp.SelectedObject.InternalObjectName.Open();
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == (int)fdoError.FDO_E_DATASET_TYPE_NOT_SUPPORTED_IN_RELEASE ||
                    ex.ErrorCode == -2147220944)
                {
                    MessageBox.Show("The dataset is not supported in this release.", "Could not open the dataset");
                }
                else
                {
                    MessageBox.Show(ex.ErrorCode.ToString(), "Could not open the dataset");
                }
                return;
            }

            if (pUnk is ICadastralFabric)
            {
                m_pCadaFab = (ICadastralFabric)pUnk;
            }
            else
            {
                MessageBox.Show("Please select a parcel fabric and try again.", "Not a parcel fabric");
                return;
            }

            IMouseCursor pMouseCursor = new MouseCursorClass();

            pMouseCursor.SetCursor(2);

            Utils FabricUTILS = new Utils();

            ITable     pTable          = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);
            IDataset   pDS             = (IDataset)pTable;
            IWorkspace pWS             = pDS.Workspace;
            bool       bIsFileBasedGDB = true;
            bool       bIsUnVersioned  = true;

            FabricUTILS.GetFabricPlatform(pWS, m_pCadaFab, out bIsFileBasedGDB,
                                          out bIsUnVersioned);

            //Do a Start and Stop editing to make sure we're not running in an edit session
            if (!FabricUTILS.StartEditing(pWS, true))
            {//if start editing fails then bail
                if (pUnk != null)
                {
                    Marshal.ReleaseComObject(pUnk);
                }
                Cleanup(pMouseCursor, null, pTable, null, pWS, null);
                FabricUTILS = null;
                return;
            }
            FabricUTILS.StopEditing(pWS);
            IFIDSet pPlansToDelete = null;

            try
            {
                string[] SummaryNames = new string[0]; //define as dynamic array
                string[] RepeatPlans  = new string[0]; //define as dynamic array
                ITable   pPlansTable  = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
                //load all the plan names into a string array
                m_pProgressorDialogFact = new ProgressDialogFactoryClass();
                m_pTrackCancel          = new CancelTrackerClass();
                m_pStepProgressor       = m_pProgressorDialogFact.Create(m_pTrackCancel, m_pApp.hWnd);
                IProgressDialog2 pProgressorDialog = (IProgressDialog2)m_pStepProgressor;
                int iRowCount = pPlansTable.RowCount(null);
                m_pStepProgressor.MinRange  = 1;
                m_pStepProgressor.MaxRange  = iRowCount * 2;
                m_pStepProgressor.StepValue = 1;
                pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
                pProgressorDialog.ShowDialog();
                m_pStepProgressor.Message = "Finding same-name plans to merge...";

                int iRepeatCnt = 0;

                if (!FindRepeatPlans(pPlansTable, out RepeatPlans, out SummaryNames, out iRepeatCnt))
                {
                    pProgressorDialog.HideDialog();
                    if (iRepeatCnt == 0)
                    {
                        MessageBox.Show("All plans in the fabric have unique names." +
                                        Environment.NewLine + "There are no plans to merge.", "Merge plans by name");
                    }
                    else
                    {
                        MessageBox.Show("There was a problem searching for repeat plans.", "Merge plans by name");
                    }
                    SummaryNames = null;
                    RepeatPlans  = null;
                    Cleanup(pMouseCursor, null, pTable, pPlansTable, pWS, pProgressorDialog);
                    return;
                }

                dlgMergeSameNamePlans TheSummaryDialog = new dlgMergeSameNamePlans();

                FillTheSummaryList(TheSummaryDialog, SummaryNames);

                DialogResult dResult = TheSummaryDialog.ShowDialog();

                if (dResult == DialogResult.Cancel)
                {
                    pProgressorDialog.HideDialog();
                    SummaryNames = null;
                    RepeatPlans  = null;
                    Cleanup(pMouseCursor, null, pTable, pPlansTable, pWS, pProgressorDialog);
                    pPlansTable = null;
                    return;
                }

                //get the time now
                m_pStartTime = new TimeClass();
                m_pStartTime.SetFromCurrentLocalTime();

                Dictionary <int, int> Lookup = new Dictionary <int, int>();
                string[] InClause            = new string[0]; //define as dynamic array

                m_pStepProgressor.Message = "Creating the merge query...";
                FabricUTILS.BuildSearchMapAndQuery(RepeatPlans, out Lookup, out InClause, out pPlansToDelete);

                ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)m_pCadaFab;
                ITable ParcelTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);
                pSchemaEd.ReleaseReadOnlyFields(ParcelTable, esriCadastralFabricTable.esriCFTParcels); //release safety-catch

                if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
                {
                    Cleanup(pMouseCursor, pPlansToDelete, pTable, pPlansTable, pWS, pProgressorDialog);
                    InClause = null;
                    Lookup.Clear();
                    Lookup = null;
                    return;
                }

                //setup progressor dialog for merge
                m_pStepProgressor.Message = "Moving parcels from source to target plans...";

                if (!FabricUTILS.MergePlans(ParcelTable, Lookup, InClause, bIsUnVersioned, m_pStepProgressor, m_pTrackCancel))
                {
                    FabricUTILS.AbortEditing(pWS);
                    pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTParcels);
                    Cleanup(pMouseCursor, pPlansToDelete, pTable, pPlansTable, pWS, pProgressorDialog);
                    InClause = null;
                    Lookup.Clear();
                    Lookup = null;
                    return;
                }

                if (TheSummaryDialog.checkBox1.Checked)
                {
                    //setup progressor dialog for Delete
                    m_pStepProgressor.MaxRange = pPlansToDelete.Count();
                    m_pStepProgressor.Message  = "Deleting source plans...";

                    if (bIsUnVersioned)
                    {
                        if (!FabricUTILS.DeleteRowsUnversioned(pWS, pPlansTable, pPlansToDelete, m_pStepProgressor, m_pTrackCancel))
                        {
                            Cleanup(pMouseCursor, pPlansToDelete, pTable, pPlansTable, pWS, pProgressorDialog);
                        }
                    }
                    else
                    {
                        if (!FabricUTILS.DeleteRowsByFIDSet(pPlansTable, pPlansToDelete, m_pStepProgressor, m_pTrackCancel))
                        {
                            Cleanup(pMouseCursor, pPlansToDelete, pTable, pPlansTable, pWS, pProgressorDialog);
                        }
                    }
                }

                pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTParcels);

                m_pEndTime = new TimeClass();
                m_pEndTime.SetFromCurrentLocalTime();
                ITimeDuration HowLong = m_pEndTime.SubtractTime(m_pStartTime);

                m_pStepProgressor.Message = "["
                                            + HowLong.Hours.ToString("00") + "h "
                                            + HowLong.Minutes.ToString("00") + "m "
                                            + HowLong.Seconds.ToString("00") + "s]" + "  Saving changes...please wait.";

                FabricUTILS.StopEditing(pWS);
                Cleanup(pMouseCursor, pPlansToDelete, pTable, pPlansTable, pWS, pProgressorDialog);
            }
            catch (COMException ex)
            {
                MessageBox.Show(Convert.ToString(ex.ErrorCode));
                Cleanup(pMouseCursor, pPlansToDelete, pTable, null, pWS, null);
            }
        }