示例#1
0
        /// <summary>
        /// Reacts to selection of the OK button in the dialog.
        /// </summary>
        /// <param name="wnd">The dialog window. If this matches the dialog that
        /// this command knows about, the command will be executed (and, on success,
        /// the dialog will be destroyed). If it's some other window, it must
        /// be a sub-dialog created by our guy, so let it handle the request.</param>
        /// <returns></returns>
        internal override bool DialFinish(Control wnd)
        {
            if (m_Dialog == null)
            {
                MessageBox.Show("LineExtensionUI.DialFinish - No dialog!");
                return(false);
            }

            // If we are doing an update, alter the original operation.
            UpdateUI up = this.Update;

            if (up != null)
            {
                // Get the original operation.
                LineExtensionOperation pop = (up.GetOp() as LineExtensionOperation);
                if (pop == null)
                {
                    MessageBox.Show("LineExtensionUI.DialFinish - Unexpected edit type.");
                    return(false);
                }

                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)
                UpdateItemCollection changes = pop.GetUpdateItems(m_Dialog.IsExtendFromEnd, m_Dialog.Length);
                if (!up.AddUpdate(pop, changes))
                {
                    return(false);
                }
            }
            else
            {
                // Get info from the dialog
                m_IsExtendFromEnd = m_Dialog.IsExtendFromEnd;
                m_Length          = m_Dialog.Length;
                IdHandle          idh = m_Dialog.PointId;
                CadastralMapModel map = CadastralMapModel.Current;
                m_LineType = (m_Dialog.WantLine ? map.DefaultLineType : null);

                // Execute the edit
                LineExtensionOperation op = null;

                try
                {
                    op = new LineExtensionOperation(m_ExtendLine, m_IsExtendFromEnd, m_Length);
                    op.Execute(idh, m_LineType);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.StackTrace, ex.Message);
                    return(false);
                }
            }

            // Destroy the dialog(s).
            KillDialogs();

            // Get the base class to finish up.
            return(FinishCommand());
        }
示例#2
0
        /// <summary>
        /// Handles the Finish button.
        /// </summary>
        /// <returns>The point created at the intersection (null if an error was reported).
        /// The caller is responsible for disposing of the dialog and telling the controller
        /// the command is done)</returns>
        internal override PointFeature Finish()
        {
            // The intersection SHOULD be defined (the Finish button should have
            // been disabled if it wasn't)
            IPosition x = intersectInfo.Intersection;

            if (x == null)
            {
                MessageBox.Show("No intersection. Nothing to save");
                return(null);
            }

            // If we're not doing an update, just save the edit
            UpdateUI up = (GetCommand() as UpdateUI);

            if (up == null)
            {
                return(SaveDirLine());
            }

            // Remember the changes as part of the UI object (the original edit remains
            // unchanged for now)
            IntersectDirectionAndLineOperation op = (IntersectDirectionAndLineOperation)up.GetOp();
            UpdateItemCollection changes          = op.GetUpdateItems(getDirection.Direction,
                                                                      getLine.Line,
                                                                      intersectInfo.ClosestPoint);

            if (!up.AddUpdate(op, changes))
            {
                return(null);
            }

            // Return the point previously created at the intersect
            return(op.IntersectionPoint);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RevisedEdit"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal RevisedEdit(EditDeserializer editDeserializer)
        {
            InternalIdValue id = editDeserializer.ReadInternalId(DataField.RevisedEdit);

            m_Edit    = editDeserializer.MapModel.FindOperation(id);
            m_Changes = (m_Edit as IRevisable).ReadUpdateItems(editDeserializer);
        }
示例#4
0
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            throw new NotImplementedException();
            return(result);
        }
示例#5
0
        /// <summary>
        /// Remembers details for an updated edit.
        /// </summary>
        /// <param name="revisedEdit">The edit that is being revised</param>
        /// <param name="changes">The changes to apply</param>
        /// <returns>True if an update was recorded, false if the supplied change collection is empty (in that
        /// case, the user receives a warning message).</returns>
        /// <remarks>This will be called when the user has finished making changes to an old
        /// edit. The call comes from the UI for the revised edit, which goes on to call
        /// CommandUI.FinishCommand, which routes back to UpdateUI.FinishCommand when an
        /// update UI is in progress.</remarks>
        internal bool AddUpdate(Operation revisedEdit, UpdateItemCollection changes)
        {
            if (changes.Count == 0)
            {
                MessageBox.Show("You do not appear to have made any changes.");
                return(false);
            }

            // Remember the revision that will be applied by ApplyRevision. In the vast majority of cases,
            // there should only be one revised edit per editing dialog. Currently, the only situation
            // where more than one revision is involved is an update where both sides of a subdivided line
            // get updated.

            var rev = new RevisedEdit(revisedEdit, changes);

            if (m_Revisions == null)
            {
                m_Revisions = new RevisedEdit[] { rev };
            }
            else
            {
                Array.Resize <RevisedEdit>(ref m_Revisions, m_Revisions.Length + 1);
                m_Revisions[m_Revisions.Length - 1] = rev;
            }

            return(true);
        }
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     data.WriteObservation <Direction>(editSerializer, DataField.Direction);
     data.WriteObservation <Observation>(editSerializer, DataField.Distance);
     data.WriteFeature <PointFeature>(editSerializer, DataField.From);
     data.WriteItem <bool>(editSerializer, DataField.Default);
 }
示例#7
0
        /// <summary>
        /// Exchanges any previously generated update items (this is currently done
        /// by <see cref="NewPointForm.GetUpdateItems"/>).
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            // Do nothing! This method is here because it is specified by the IRevisable
            // interface. But, while the NewPointOperation can be updated, it is unlike
            // other edits because we are explicitly changing a position (rather than
            // changing observations that are used to calculate a position).

            // Data exchange ordinarily happens before anything is moved, because
            // it may alter the calculation sequence. While explicitly changing a
            // position will not alter the sequence, it will move the point a little
            // too soon (the UpdateEditingContext.Recalculate method is responsible
            // for removing stuff from the spatial index, re-calculating geometry,
            // and re-adding to the spatial index). Ok, we could try fixing up the
            // index as part of this method. But if we do that, the old geometry
            // would not get remembered as part of the UpdateEditingContext (which
            // gets utilized in the event of a rollback).

            // To get around all this, the data exchange will be deferred until
            // CalculateGeometry is called (see implementation below).

            // ...the only problem with the above is that during deserialization, data
            // exchange occurs at the moment the update is encountered in the deserialization
            // stream. Subsequently, CalculateGeometry will be called with a null editing
            // context, so the update info will not be available. So do the exchange if
            // the model is just being loaded.

            if (MapModel.WorkingSession == null)
            {
                ApplyUpdateItems(null, data);
            }
        }
        /// <summary>
        /// Reacts to selection of the OK button in the dialog.
        /// </summary>
        /// <param name="wnd">The dialog window. If this matches the dialog that
        /// this command knows about, the command will be executed (and, on success,
        /// the dialog will be destroyed). If it's some other window, it must
        /// be a sub-dialog created by our guy, so let it handle the request.</param>
        /// <returns></returns>
        internal override bool DialFinish(Control wnd)
        {
            if (m_Dialog == null)
            {
                MessageBox.Show("SimpleLineSubdivisionUI.DialFinish - No dialog!");
                return(false);
            }

            // De-select the line that's being split
            Controller.ClearSelection();

            // Get info from the dialog.
            m_Length = m_Dialog.Length;

            // If we are doing an update, alter the original operation.
            UpdateUI up = this.Update;

            if (up != null)
            {
                // Get the original operation.
                SimpleLineSubdivisionOperation pop = (up.GetOp() as SimpleLineSubdivisionOperation);
                if (pop == null)
                {
                    MessageBox.Show("SimpleLineSubdivisionUI.DialFinish - Unexpected edit type.");
                    return(false);
                }

                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)
                UpdateItemCollection changes = pop.GetUpdateItems(m_Length, m_Dialog.IsFromEnd);
                if (!up.AddUpdate(pop, changes))
                {
                    return(false);
                }
            }
            else
            {
                // Execute the edit
                SimpleLineSubdivisionOperation op = null;

                try
                {
                    op = new SimpleLineSubdivisionOperation(m_Line, m_Length, m_Dialog.IsFromEnd);
                    op.Execute();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.StackTrace, ex.Message);
                    return(false);
                }
            }

            // Destroy the dialog(s).
            KillDialogs();

            // Get the base class to finish up.
            return(FinishCommand());
        }
示例#9
0
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.ReadObservation <Direction>(editDeserializer, DataField.Direction1);
            result.ReadObservation <Direction>(editDeserializer, DataField.Direction2);
            return(result);
        }
示例#10
0
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="isFromEnd">True if extending from the end of the line</param>
        /// <param name="length">The observed length of the extension</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(bool isFromEnd, Distance length)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddItem <bool>(DataField.ExtendFromEnd, m_IsExtendFromEnd, isFromEnd);
            result.AddObservation <Distance>(DataField.Distance, m_Length, length);
            return(result);
        }
示例#11
0
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.ReadItem <bool>(editDeserializer, DataField.ExtendFromEnd);
            result.ReadObservation <Distance>(editDeserializer, DataField.Distance);
            return(result);
        }
示例#12
0
 /// <summary>
 /// Exchanges any previously generated update items (this is currently done
 /// by <see cref="NewPointForm.GetUpdateItems"/>).
 /// </summary>
 /// <param name="data">The update data to apply to the edit (modified to
 /// hold the values that were previously defined for the edit)</param>
 public override void ExchangeData(UpdateItemCollection data)
 {
     // Only exchange if the model is being loaded - see comments in NewPointOperation.ExchangeData
     if (MapModel.WorkingSession == null)
     {
         ApplyUpdateItems(null, data);
     }
 }
示例#13
0
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="dir1">1st direction observation.</param>
        /// <param name="dir2">2nd direction observation.</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(Direction dir1, Direction dir2)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddObservation <Direction>(DataField.Direction1, m_Direction1, dir1);
            result.AddObservation <Direction>(DataField.Direction2, m_Direction2, dir2);
            return(result);
        }
示例#14
0
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     data.WriteFeature <LineFeature>(editSerializer, DataField.RefLine);
     data.WriteObservation <Observation>(editSerializer, DataField.Offset);
     data.WriteFeature <LineFeature>(editSerializer, DataField.Term1);
     data.WriteFeature <LineFeature>(editSerializer, DataField.Term2);
     data.WriteItem <bool>(editSerializer, DataField.ReverseArc);
 }
示例#15
0
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.ReadItem <double>(editDeserializer, DataField.X);
            result.ReadItem <double>(editDeserializer, DataField.Y);
            return(result);
        }
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="dist">The new observed distance.</param>
        /// <param name="isFromEnd">Is the distance observed from the end of the line?</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(Distance dist, bool isFromEnd)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddObservation <Distance>(DataField.Distance, m_Distance, dist);
            result.AddItem <bool>(DataField.EntryFromEnd, m_IsFromEnd, isFromEnd);
            return(result);
        }
示例#17
0
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="newPosition">The revised position</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(Position newPosition)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddItem <double>(DataField.X, m_NewPoint.Easting.Meters, newPosition.X);
            result.AddItem <double>(DataField.Y, m_NewPoint.Northing.Meters, newPosition.Y);
            return(result);
        }
示例#18
0
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="dir">The direction (could contain an offset).</param>
        /// <param name="length">The length of the sideshot arm (either a <see cref="Distance"/>
        /// or an <see cref="OffsetPoint"/>).</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(Direction dir, Observation length)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddObservation <Direction>(DataField.Direction, m_Direction, dir);
            result.AddObservation <Observation>(DataField.Length, m_Length, length);
            return(result);
        }
示例#19
0
        /// <summary>
        /// Applies changes to this editing operation.
        /// </summary>
        /// <param name="ctx">The editing context (null if the model is being deserialized)</param>
        /// <param name="data">The changes to apply</param>
        void ApplyUpdateItems(EditingContext ctx, UpdateItemCollection data)
        {
            double        x  = data.ExchangeValue <double>(DataField.X, m_NewPoint.Easting.Meters);
            double        y  = data.ExchangeValue <double>(DataField.Y, m_NewPoint.Northing.Meters);
            PointGeometry pg = new PointGeometry(x, y);

            m_NewPoint.ApplyPointGeometry(ctx, pg);
        }
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Direction = data.ExchangeObservation <Direction>(this, DataField.Direction, m_Direction);
            m_Distance  = data.ExchangeObservation <Observation>(this, DataField.Distance, m_Distance);
            m_From      = data.ExchangeFeature <PointFeature>(this, DataField.From, m_From);
            m_Default   = data.ExchangeValue <bool>(DataField.Default, m_Default);

            AssignObservedLengths();
        }
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="LineSubdivisionUpdateForm.GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            UpdateItem face = data.GetUpdateItem(DataField.Face);

            if (face != null)
            {
                m_Face.ExchangeData(face);
            }
        }
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.ReadObservation <Direction>(editDeserializer, DataField.Direction);
            result.ReadFeature <LineFeature>(editDeserializer, DataField.Line);
            result.ReadFeature <PointFeature>(editDeserializer, DataField.CloseTo);
            return(result);
        }
        ///// <summary>
        ///// Executes this operation.
        ///// </summary>
        ///// <param name="wantsplit">True if line should be split at the intersection.</param>
        ///// <param name="pointType">The entity type to assign to the intersection point.</param>
        ///// <param name="dirEnt">The entity type for any line that should be added along the direction
        ///// line. Specify null if you don't want a line.</param>
        //internal void Execute(bool wantsplit, IEntity pointType, IEntity dirEnt)
        //{
        //    // Calculate the position of the point of intersection.
        //    IPosition xsect;
        //    PointFeature closest;
        //    if (!m_Direction.Intersect(m_Line, m_CloseTo, out xsect, out closest))
        //        throw new Exception("Cannot calculate intersection point");

        //    // Add the intersection point
        //    m_Intersection = AddIntersection(xsect, pointType);

        //    // Are we splitting the input line? If so, do it.
        //    m_IsSplit = wantsplit;
        //    if (m_IsSplit)
        //        SplitLine(m_Intersection, m_Line, out m_LineA, out m_LineB);

        //    // If we have a defined entity type for the direction line, add a line too.
        //    CadastralMapModel map = MapModel;
        //    if (dirEnt != null)
        //        m_DirLine = map.AddLine(m_Direction.From, m_Intersection, dirEnt, this);

        //    // Peform standard completion steps
        //    Complete();
        //}

        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="dir">The direction to intersect.</param>
        /// <param name="line">The line to intersect.</param>
        /// <param name="closeTo">The point the intersection has to be close to. Used if
        /// there is more than one intersection to choose from. If null is specified, a
        /// default point will be selected.</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(Direction dir, LineFeature line,
                                                     PointFeature closeTo)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddObservation <Direction>(DataField.Direction, m_Direction, dir);
            result.AddFeature <LineFeature>(DataField.Line, m_Line, line);
            result.AddFeature <PointFeature>(DataField.CloseTo, m_CloseTo, closeTo);
            return(result);
        }
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.ReadObservation <Direction>(editDeserializer, DataField.Direction);
            result.ReadObservation <Observation>(editDeserializer, DataField.Distance);
            result.ReadFeature <PointFeature>(editDeserializer, DataField.From);
            result.ReadItem <bool>(editDeserializer, DataField.Default);
            return(result);
        }
示例#25
0
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Direction = data.ExchangeObservation <Direction>(this, DataField.Direction, m_Direction);
            m_Length    = data.ExchangeObservation <Observation>(this, DataField.Length, m_Length);

            if (m_Line != null)
            {
                m_Line.ObservedLength = (m_Length as Distance);
            }
        }
示例#26
0
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_IsExtendFromEnd = data.ExchangeValue <bool>(DataField.ExtendFromEnd, m_IsExtendFromEnd);
            m_Length          = data.ExchangeObservation <Distance>(this, DataField.Distance, m_Length);

            if (m_NewLine != null)
            {
                m_NewLine.ObservedLength = m_Length;
            }
        }
示例#27
0
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Distance1 = data.ExchangeObservation <Observation>(this, DataField.Distance1, m_Distance1);
            m_From1     = data.ExchangeFeature <PointFeature>(this, DataField.From1, m_From1);
            m_Distance2 = data.ExchangeObservation <Observation>(this, DataField.Distance2, m_Distance2);
            m_From2     = data.ExchangeFeature <PointFeature>(this, DataField.From2, m_From2);
            m_Default   = data.ExchangeValue <bool>(DataField.Default, m_Default);

            AssignObservedLengths();
        }
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/>).
        /// </summary>
        /// <param name="dist1">1st distance observation.</param>
        /// <param name="from1">The point the 1st distance was observed from.</param>
        /// <param name="dist2">2nd distance observation.</param>
        /// <param name="from2">The point the 2nd distance was observed from.</param>
        /// <param name="isdefault">True if the default intersection is required (the one that has the
        /// lowest bearing with respect to the 2 from points). False for the other one (if any).</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method).</returns>
        internal UpdateItemCollection GetUpdateItems(Direction dir, Observation distance,
                                                     PointFeature from, bool isdefault)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            result.AddObservation <Direction>(DataField.Direction, m_Direction, dir);
            result.AddObservation <Observation>(DataField.Distance, m_Distance, distance);
            result.AddFeature <PointFeature>(DataField.From, m_From, from);
            result.AddItem <bool>(DataField.Default, m_Default, isdefault);
            return(result);
        }
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/> and <see cref="WriteUpdateItems"/>).
        /// </summary>
        /// <param name="face">The revised observed lengths for each subdivision section</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method). Never null, but may be an empty collection
        /// if the supplied face does not involve any changes.</returns>
        internal UpdateItemCollection GetUpdateItems(LineSubdivisionFace face)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            if (!m_Face.HasIdenticalObservedLengths(face))
            {
                result.Add(m_Face.GetUpdateItem(DataField.Face, face.ObservedLengths));
            }

            return(result);
        }
        /// <summary>
        /// Writes updates for an editing operation to a persistent storage area.
        /// </summary>
        /// <param name="editSerializer">The mechanism for storing content.</param>
        /// <param name="data">The collection of changes to write</param>
        public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
        {
            // The logic that follows is based on the update items that get defined by GetUpdateItems

            UpdateItem face = data.GetUpdateItem(DataField.Face);

            if (face != null)
            {
                editSerializer.WritePersistentArray <Distance>(DataField.Face, (Distance[])face.Value);
            }
        }
示例#31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RevisedEdit"/> class.
        /// </summary>
        /// <param name="revisedEdit">The edit being updated (not null). Must implement
        /// <see cref="IRevisable"/>.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="edit"/> or
        /// <paramref name="changes"/> is null.</exception>
        /// <exception cref="ArgumentException">If <paramref name="revisedEdit"/> does not
        /// implement <see cref="IRevisable"/>.</exception>
        internal RevisedEdit(Operation revisedEdit, UpdateItemCollection changes)
            : base()
        {
            if (revisedEdit == null || changes == null)
                throw new ArgumentNullException();

            if (!(revisedEdit is IRevisable))
                throw new ArgumentException();

            m_Changes = changes;
            m_Edit = revisedEdit;
        }
        /// <summary>
        /// Exchanges any previously generated update items (this is currently done
        /// by <see cref="NewPointForm.GetUpdateItems"/>).
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            // Do nothing! This method is here because it is specified by the IRevisable
            // interface. But, while the NewPointOperation can be updated, it is unlike
            // other edits because we are explicitly changing a position (rather than
            // changing observations that are used to calculate a position).

            // Data exchange ordinarily happens before anything is moved, because
            // it may alter the calculation sequence. While explicitly changing a
            // position will not alter the sequence, it will move the point a little
            // too soon (the UpdateEditingContext.Recalculate method is responsible
            // for removing stuff from the spatial index, re-calculating geometry,
            // and re-adding to the spatial index). Ok, we could try fixing up the
            // index as part of this method. But if we do that, the old geometry
            // would not get remembered as part of the UpdateEditingContext (which
            // gets utilized in the event of a rollback).

            // To get around all this, the data exchange will be deferred until
            // CalculateGeometry is called (see implementation below).

            // ...the only problem with the above is that during deserialization, data
            // exchange occurs at the moment the update is encountered in the deserialization
            // stream. Subsequently, CalculateGeometry will be called with a null editing
            // context, so the update info will not be available. So do the exchange if
            // the model is just being loaded.

            if (MapModel.WorkingSession == null)
                ApplyUpdateItems(null, data);
        }
        /// <summary>
        /// Reads back updates made to an editing operation.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <returns>The changes made to the edit</returns>
        public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            if (editDeserializer.IsNextField(DataField.Face))
            {
                Distance[] face = editDeserializer.ReadPersistentArray<Distance>(DataField.Face);
                result.Add(new UpdateItem(DataField.Face, face));
            }

            return result;
        }
        /// <summary>
        /// Modifies this edit by applying the values in the supplied update items
        /// (as produced via a prior call to <see cref="GetUpdateItems"/>).
        /// </summary>
        /// <param name="data">The update items to apply to this edit.</param>
        /// <returns>The original values for the update items.</returns>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Distance = data.ExchangeObservation<Distance>(this, DataField.Distance, m_Distance);
            m_IsFromEnd = data.ExchangeValue<bool>(DataField.EntryFromEnd, m_IsFromEnd);

            if (m_IsFromEnd)
                m_NewLine2.ObservedLength = m_Distance;
            else
                m_NewLine1.ObservedLength = m_Distance;
        }
示例#35
0
 /// <summary>
 /// Reads back updates made to an editing operation.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <returns>The changes made to the edit</returns>
 public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     throw new NotImplementedException();
     return result;
 }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="newPosition">The revised position</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Position newPosition)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddItem<double>(DataField.X, m_NewPoint.Easting.Meters, newPosition.X);
     result.AddItem<double>(DataField.Y, m_NewPoint.Northing.Meters, newPosition.Y);
     return result;
 }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="isFromEnd">True if extending from the end of the line</param>
 /// <param name="length">The observed length of the extension</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(bool isFromEnd, Distance length)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddItem<bool>(DataField.ExtendFromEnd, m_IsExtendFromEnd, isFromEnd);
     result.AddObservation<Distance>(DataField.Distance, m_Length, length);
     return result;
 }
 /// <summary>
 /// Exchanges update items that were previously generated via
 /// a call to <see cref="GetUpdateItems"/>.
 /// </summary>
 /// <param name="data">The update data to apply to the edit (modified to
 /// hold the values that were previously defined for the edit)</param>
 public override void ExchangeData(UpdateItemCollection data)
 {
     m_Direction1 = data.ExchangeObservation<Direction>(this, DataField.Direction1, m_Direction1);
     m_Direction2 = data.ExchangeObservation<Direction>(this, DataField.Direction2, m_Direction2);
 }
示例#39
0
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dir">The direction (could contain an offset).</param>
 /// <param name="length">The length of the sideshot arm (either a <see cref="Distance"/>
 /// or an <see cref="OffsetPoint"/>).</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Direction dir, Observation length)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Direction>(DataField.Direction, m_Direction, dir);
     result.AddObservation<Observation>(DataField.Length, m_Length, length);
     return result;
 }
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     data.WriteObservation<Direction>(editSerializer, DataField.Direction1);
     data.WriteObservation<Direction>(editSerializer, DataField.Direction2);
 }
 /// <summary>
 /// Reads back updates made to an editing operation.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <returns>The changes made to the edit</returns>
 public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.ReadObservation<Direction>(editDeserializer, DataField.Direction1);
     result.ReadObservation<Direction>(editDeserializer, DataField.Direction2);
     return result;
 }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dir1">1st direction observation.</param>
 /// <param name="dir2">2nd direction observation.</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Direction dir1, Direction dir2)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Direction>(DataField.Direction1, m_Direction1, dir1);
     result.AddObservation<Direction>(DataField.Direction2, m_Direction2, dir2);
     return result;
 }
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_IsExtendFromEnd = data.ExchangeValue<bool>(DataField.ExtendFromEnd, m_IsExtendFromEnd);
            m_Length = data.ExchangeObservation<Distance>(this, DataField.Distance, m_Length);

            if (m_NewLine != null)
                m_NewLine.ObservedLength = m_Length;
        }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dist">The new observed distance.</param>
 /// <param name="isFromEnd">Is the distance observed from the end of the line?</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Distance dist, bool isFromEnd)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Distance>(DataField.Distance, m_Distance, dist);
     result.AddItem<bool>(DataField.EntryFromEnd, m_IsFromEnd, isFromEnd);
     return result;
 }
 /// <summary>
 /// Reads back updates made to an editing operation.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <returns>The changes made to the edit</returns>
 public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.ReadItem<double>(editDeserializer, DataField.X);
     result.ReadItem<double>(editDeserializer, DataField.Y);
     return result;
 }
 /// <summary>
 /// Exchanges update items that were previously generated via
 /// a call to <see cref="LineSubdivisionUpdateForm.GetUpdateItems"/>.
 /// </summary>
 /// <param name="data">The update data to apply to the edit (modified to
 /// hold the values that were previously defined for the edit)</param>
 public override void ExchangeData(UpdateItemCollection data)
 {
     UpdateItem face = data.GetUpdateItem(DataField.Face);
     if (face != null)
         m_Face.ExchangeData(face);
 }
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     data.WriteItem<double>(editSerializer, DataField.X);
     data.WriteItem<double>(editSerializer, DataField.Y);
 }
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     data.WriteObservation<Direction>(editSerializer, DataField.Direction);
     data.WriteObservation<Observation>(editSerializer, DataField.Distance);
     data.WriteFeature<PointFeature>(editSerializer, DataField.From);
     data.WriteItem<bool>(editSerializer, DataField.Default);
 }
 /// <summary>
 /// Applies changes to this editing operation.
 /// </summary>
 /// <param name="ctx">The editing context (null if the model is being deserialized)</param>
 /// <param name="data">The changes to apply</param>
 void ApplyUpdateItems(EditingContext ctx, UpdateItemCollection data)
 {
     double x = data.ExchangeValue<double>(DataField.X, m_NewPoint.Easting.Meters);
     double y = data.ExchangeValue<double>(DataField.Y, m_NewPoint.Northing.Meters);
     PointGeometry pg = new PointGeometry(x, y);
     m_NewPoint.ApplyPointGeometry(ctx, pg);
 }
示例#50
0
 /// <summary>
 /// Exchanges update items that were previously generated.
 /// </summary>
 /// <param name="data">The update data to apply to this edit (modified to
 /// hold the values that were previously defined for this edit)</param>
 /// <exception cref="NotImplementedException">Thrown always. Derived classes that are
 /// update capable must override (I'm not sure why this isn't part of the IRevisable
 /// interface)</exception>
 public virtual void ExchangeData(UpdateItemCollection data)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dist1">1st distance observation.</param>
 /// <param name="from1">The point the 1st distance was observed from.</param>
 /// <param name="dist2">2nd distance observation.</param>
 /// <param name="from2">The point the 2nd distance was observed from.</param>
 /// <param name="isdefault">True if the default intersection is required (the one that has the
 /// lowest bearing with respect to the 2 from points). False for the other one (if any).</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Direction dir, Observation distance,
     PointFeature from, bool isdefault)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Direction>(DataField.Direction, m_Direction, dir);
     result.AddObservation<Observation>(DataField.Distance, m_Distance, distance);
     result.AddFeature<PointFeature>(DataField.From, m_From, from);
     result.AddItem<bool>(DataField.Default, m_Default, isdefault);
     return result;
 }
示例#52
0
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Direction = data.ExchangeObservation<Direction>(this, DataField.Direction, m_Direction);
            m_Length = data.ExchangeObservation<Observation>(this, DataField.Length, m_Length);

            if (m_Line != null)
                m_Line.ObservedLength = (m_Length as Distance);
        }
 /// <summary>
 /// Reads back updates made to an editing operation.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <returns>The changes made to the edit</returns>
 public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.ReadObservation<Direction>(editDeserializer, DataField.Direction);
     result.ReadObservation<Observation>(editDeserializer, DataField.Distance);
     result.ReadFeature<PointFeature>(editDeserializer, DataField.From);
     result.ReadItem<bool>(editDeserializer, DataField.Default);
     return result;
 }
        /// <summary>
        /// Obtains update items for a revised version of this edit
        /// (for later use with <see cref="ExchangeData"/> and <see cref="WriteUpdateItems"/>).
        /// </summary>
        /// <param name="face">The revised observed lengths for each subdivision section</param>
        /// <returns>The items representing the change (may be subsequently supplied to
        /// the <see cref="ExchangeUpdateItems"/> method). Never null, but may be an empty collection
        /// if the supplied face does not involve any changes.</returns>
        internal UpdateItemCollection GetUpdateItems(LineSubdivisionFace face)
        {
            UpdateItemCollection result = new UpdateItemCollection();

            if (!m_Face.HasIdenticalObservedLengths(face))
                result.Add(m_Face.GetUpdateItem(DataField.Face, face.ObservedLengths));

            return result;
        }
示例#55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RevisedEdit"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 internal RevisedEdit(EditDeserializer editDeserializer)
 {
     InternalIdValue id = editDeserializer.ReadInternalId(DataField.RevisedEdit);
     m_Edit = editDeserializer.MapModel.FindOperation(id);
     m_Changes = (m_Edit as IRevisable).ReadUpdateItems(editDeserializer);
 }
        /// <summary>
        /// Writes updates for an editing operation to a persistent storage area.
        /// </summary>
        /// <param name="editSerializer">The mechanism for storing content.</param>
        /// <param name="data">The collection of changes to write</param>
        public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
        {
            // The logic that follows is based on the update items that get defined by GetUpdateItems

            UpdateItem face = data.GetUpdateItem(DataField.Face);
            if (face != null)
                editSerializer.WritePersistentArray<Distance>(DataField.Face, (Distance[])face.Value);
        }
示例#57
0
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     throw new NotImplementedException();
 }
示例#58
0
        /// <summary>
        /// Remembers details for an updated edit.
        /// </summary>
        /// <param name="revisedEdit">The edit that is being revised</param>
        /// <param name="changes">The changes to apply</param>
        /// <returns>True if an update was recorded, false if the supplied change collection is empty (in that
        /// case, the user receives a warning message).</returns>
        /// <remarks>This will be called when the user has finished making changes to an old
        /// edit. The call comes from the UI for the revised edit, which goes on to call
        /// CommandUI.FinishCommand, which routes back to UpdateUI.FinishCommand when an
        /// update UI is in progress.</remarks>
        internal bool AddUpdate(Operation revisedEdit, UpdateItemCollection changes)
        {
            if (changes.Count == 0)
            {
                MessageBox.Show("You do not appear to have made any changes.");
                return false;
            }

            // Remember the revision that will be applied by ApplyRevision. In the vast majority of cases,
            // there should only be one revised edit per editing dialog. Currently, the only situation
            // where more than one revision is involved is an update where both sides of a subdivided line
            // get updated.

            var rev = new RevisedEdit(revisedEdit, changes);
            if (m_Revisions == null)
            {
                m_Revisions = new RevisedEdit[] { rev };
            }
            else
            {
                Array.Resize<RevisedEdit>(ref m_Revisions, m_Revisions.Length + 1);
                m_Revisions[m_Revisions.Length - 1] = rev;
            }

            return true;
        }
 /// <summary>
 /// Reads back updates made to an editing operation.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <returns>The changes made to the edit</returns>
 public UpdateItemCollection ReadUpdateItems(EditDeserializer editDeserializer)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.ReadObservation<Distance>(editDeserializer, DataField.Distance);
     result.ReadItem<bool>(editDeserializer, DataField.EntryFromEnd);
     return result;
 }
 /// <summary>
 /// Writes updates for an editing operation to a persistent storage area.
 /// </summary>
 /// <param name="editSerializer">The mechanism for storing content.</param>
 /// <param name="data">The collection of changes to write</param>
 public void WriteUpdateItems(EditSerializer editSerializer, UpdateItemCollection data)
 {
     data.WriteObservation<Distance>(editSerializer, DataField.Distance);
     data.WriteItem<bool>(editSerializer, DataField.EntryFromEnd);
 }