/// <summary>
        /// Performs the data processing associated with this editing operation.
        /// </summary>
        /// <param name="ctx">The context in which the geometry is being calculated.</param>
        internal override void CalculateGeometry(EditingContext ctx)
        {
            // We only have to do stuff when processing an update (see comments in ExchangeData).

            if (ctx is UpdateEditingContext)
            {
                UpdateEditingContext uec = (ctx as UpdateEditingContext);
                ApplyUpdateItems(ctx, uec.UpdateSource.GetChanges(this));
            }
        }
Exemple #2
0
        /// <summary>
        /// Rollback this operation (occurs when a user undoes the last edit).
        /// </summary>
        internal override void Undo()
        {
            // Undoing involves re-exchanging the data for each revised edit, then re-calculating.

            // The update edit should have been removed already from the map model (see Session.Rollback),
            // so the re-calculate call done below will not attempt to re-run this update again.

            // Hitting a RollforwardException at this stage would be quite unexpected, indicating a basic
            // application logic error, so do not attempt to cover that eventuality.

            RevertChanges();
            UpdateEditingContext uec = new UpdateEditingContext(this);

            uec.Recalculate();
        }
Exemple #3
0
        /// <summary>
        /// Cancels all updates.
        /// </summary>
        internal void Cancel()
        {
            // No can do if an update is currently in progress!
            if (m_Cmd != null)
            {
                string msg = "You are in the middle of making an update." + System.Environment.NewLine;
                msg += "You must cancel that first.";
                MessageBox.Show(msg);
                return;
            }

            // If we've currently got a problem, treat the cancellation
            // request as a request to undo just the last revision
            if (m_CurrentUpdate != null)
            {
                m_CurrentUpdate.RevertChanges();
                m_CurrentUpdate = null;
                m_Problem       = null;

                CadastralMapModel model = CadastralMapModel.Current;
                model.EnsureFeaturesAreIndexed();
                model.CleanEdit();

                if (m_SelectedFeature != null)
                {
                    Run(m_SelectedFeature);
                }

                m_Info.OnFinishUpdate(null);
                ActiveDisplay.Redraw();
            }
            else
            {
                // If we saved any updates, undo them all.
                UndoAll();

                FinishCommand();
            }
        }
        /// <summary>
        /// Rollback this operation (occurs when a user undoes the last edit).
        /// </summary>
        internal override void Undo()
        {
            // Undoing involves re-exchanging the data for each revised edit, then re-calculating.

            // The update edit should have been removed already from the map model (see Session.Rollback),
            // so the re-calculate call done below will not attempt to re-run this update again.

            // Hitting a RollforwardException at this stage would be quite unexpected, indicating a basic
            // application logic error, so do not attempt to cover that eventuality.

            RevertChanges();
            UpdateEditingContext uec = new UpdateEditingContext(this);
            uec.Recalculate();
        }
Exemple #5
0
        /// <summary>
        /// Applies a revised edit (as noted on a prior call to <see cref="AddUpdate"/>).
        /// </summary>
        void ApplyRevision()
        {
            UpdateOperation uop;

            // If we already have an update context, it means we're applying a revision in an attempt
            // to fix a rollforward problem.

            if (m_CurrentUpdate == null)
            {
                uop             = new UpdateOperation(m_Revisions);
                m_CurrentUpdate = new UpdateEditingContext(uop);
            }
            else
            {
                // Undo the previous recalculation
                m_CurrentUpdate.RevertChanges();

                // Include the latest revision
                uop = m_CurrentUpdate.UpdateSource;
                foreach (RevisedEdit rev in m_Revisions)
                {
                    uop.AddRevisedEdit(rev);
                }
            }

            m_Revisions = null;

            try
            {
                // Serialize the edit to a string BEFORE we apply the changes (otherwise we'll end
                // up serializing the modified values)
                string editString = uop.GetEditString();

                // Apply changes, then rework the map model to account for the update
                uop.ApplyChanges();
                m_CurrentUpdate.Recalculate();

                // Update topology
                uop.MapModel.CleanEdit();

                // Save the update as part of the working session
                uop.Session.SaveEditString(uop, editString);
                m_CurrentUpdate = null;
                m_NumUpdate++;
            }

            catch (RollforwardException rex)
            {
                // Remember the problem edit
                m_Problem = rex.Problem;

                // The spatial index may be missing stuff (since the recalc exited early)
                CadastralMapModel model = uop.MapModel;
                model.EnsureFeaturesAreIndexed();

                // Update topology and cleanup any junk
                model.CleanEdit();

                // Re-center on the problem edit if it's off-screen
                ISpatialDisplay display   = base.ActiveDisplay;
                IPosition       newCenter = m_Problem.GetRecenter(display.Extent);
                if (newCenter != null)
                {
                    display.Center = newCenter;
                }

                MessageBox.Show("Cannot re-work geometry due to edit " + m_Problem.EditSequence, "Problem",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
                m_CurrentUpdate.RevertChanges();
                m_CurrentUpdate = null;
            }
        }
Exemple #6
0
        /// <summary>
        /// Applies a revised edit (as noted on a prior call to <see cref="AddUpdate"/>).
        /// </summary>
        void ApplyRevision()
        {
            UpdateOperation uop;

            // If we already have an update context, it means we're applying a revision in an attempt
            // to fix a rollforward problem.

            if (m_CurrentUpdate == null)
            {
                uop = new UpdateOperation(m_Revisions);
                m_CurrentUpdate = new UpdateEditingContext(uop);
            }
            else
            {
                // Undo the previous recalculation
                m_CurrentUpdate.RevertChanges();

                // Include the latest revision
                uop = m_CurrentUpdate.UpdateSource;
                foreach (RevisedEdit rev in m_Revisions)
                    uop.AddRevisedEdit(rev);
            }

            m_Revisions = null;

            try
            {
                // Serialize the edit to a string BEFORE we apply the changes (otherwise we'll end
                // up serializing the modified values)
                string editString = uop.GetEditString();

                // Apply changes, then rework the map model to account for the update
                uop.ApplyChanges();
                m_CurrentUpdate.Recalculate();

                // Update topology
                uop.MapModel.CleanEdit();

                // Save the update as part of the working session
                uop.Session.SaveEditString(uop, editString);
                m_CurrentUpdate = null;
                m_NumUpdate++;
            }

            catch (RollforwardException rex)
            {
                // Remember the problem edit
                m_Problem = rex.Problem;

                // The spatial index may be missing stuff (since the recalc exited early)
                CadastralMapModel model = uop.MapModel;
                model.EnsureFeaturesAreIndexed();

                // Update topology and cleanup any junk
                model.CleanEdit();

                // Re-center on the problem edit if it's off-screen
                ISpatialDisplay display = base.ActiveDisplay;
                IPosition newCenter = m_Problem.GetRecenter(display.Extent);
                if (newCenter != null)
                    display.Center = newCenter;

                MessageBox.Show("Cannot re-work geometry due to edit " + m_Problem.EditSequence, "Problem",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
                m_CurrentUpdate.RevertChanges();
                m_CurrentUpdate = null;
            }
        }
Exemple #7
0
        /// <summary>
        /// Cancels all updates.
        /// </summary>
        internal void Cancel()
        {
            // No can do if an update is currently in progress!
            if (m_Cmd != null)
            {
                string msg = "You are in the middle of making an update." + System.Environment.NewLine;
                msg += "You must cancel that first.";
                MessageBox.Show(msg);
                return;
            }

            // If we've currently got a problem, treat the cancellation
            // request as a request to undo just the last revision
            if (m_CurrentUpdate != null)
            {
                m_CurrentUpdate.RevertChanges();
                m_CurrentUpdate = null;
                m_Problem = null;

                CadastralMapModel model = CadastralMapModel.Current;
                model.EnsureFeaturesAreIndexed();
                model.CleanEdit();

                if (m_SelectedFeature != null)
                    Run(m_SelectedFeature);

                m_Info.OnFinishUpdate(null);
                ActiveDisplay.Redraw();
            }
            else
            {
                // If we saved any updates, undo them all.
                UndoAll();

                FinishCommand();
            }
        }