Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MovePolygonPositionOperation"/> class
 /// </summary>
 /// <param name="label">The polygon label to modify</param>
 internal MovePolygonPositionOperation(TextFeature label)
     : base()
 {
     m_Label       = label;
     m_OldPosition = null;
     m_NewPosition = null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MovePolygonPositionOperation"/> class
 /// </summary>
 /// <param name="label">The polygon label to modify</param>
 internal MovePolygonPositionOperation(TextFeature label)
     : base()
 {
     m_Label = label;
     m_OldPosition = null;
     m_NewPosition = null;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MoveTextOperation"/> class
 /// </summary>
 /// <param name="text">The text to be moved</param>
 internal MoveTextOperation(TextFeature text)
     : base()
 {
     m_Text           = text;
     m_OldPosition    = null;
     m_OldPolPosition = null;
     m_NewPosition    = null;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MoveTextOperation"/> class
 /// </summary>
 /// <param name="text">The text to be moved</param>
 internal MoveTextOperation(TextFeature text)
     : base()
 {
     m_Text = text;
     m_OldPosition = null;
     m_OldPolPosition = null;
     m_NewPosition = null;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new <c>MoveTextUI</c>
        /// </summary>
        /// <param name="cc">The container for any dialogs</param>
        /// <param name="action">The action that initiated this command</param>
        /// <param name="text">The text to move (not null)</param>
        internal MoveTextUI(IControlContainer cc, IUserAction action, TextFeature text)
            : base(cc, action)
        {
            if (text == null)
                throw new ArgumentNullException();

            m_Text = text;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates a previously added polygon label.
        /// </summary>
        /// <param name="label">The previously added label.</param>
        /// <returns>True if an update was made.</returns>
        internal override bool UpdateLabel(TextFeature label)
        {
            // For the time being, "update" means updating the attributes
            // associated with the label. There's no way to update the
            // entity type, schema, or annotation template (apart from
            // deleting an existing label, and re-adding a new one).

            return(false);
        }
        /// <summary>
        /// Creates a new <c>MovePolygonPositionUI</c>
        /// </summary>
        /// <param name="cc">The container for any dialogs</param>
        /// <param name="action">The action that initiated this command</param>
        /// <param name="text">The text to move (not null)</param>
        internal MovePolygonPositionUI(IControlContainer cc, IUserAction action, TextFeature text)
            : base(cc, action)
        {
            if (text == null)
                throw new ArgumentNullException();

            m_Text = text;
            m_LastPolygon = m_Text.Container;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new <c>MoveTextUI</c>
        /// </summary>
        /// <param name="cc">The container for any dialogs</param>
        /// <param name="action">The action that initiated this command</param>
        /// <param name="text">The text to move (not null)</param>
        internal MoveTextUI(IControlContainer cc, IUserAction action, TextFeature text)
            : base(cc, action)
        {
            if (text == null)
            {
                throw new ArgumentNullException();
            }

            m_Text = text;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new <c>MovePolygonPositionUI</c>
        /// </summary>
        /// <param name="cc">The container for any dialogs</param>
        /// <param name="action">The action that initiated this command</param>
        /// <param name="text">The text to move (not null)</param>
        internal MovePolygonPositionUI(IControlContainer cc, IUserAction action, TextFeature text)
            : base(cc, action)
        {
            if (text == null)
            {
                throw new ArgumentNullException();
            }

            m_Text        = text;
            m_LastPolygon = m_Text.Container;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PolygonSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PolygonSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.DeactivatedLabel))
            {
                m_Label            = editDeserializer.ReadFeatureRef <TextFeature>(DataField.DeactivatedLabel);
                m_Label.IsInactive = true; // later ?
            }

            m_Lines = editDeserializer.ReadPersistentArray <LineFeature>(DataField.Lines);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PolygonSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PolygonSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            if (editDeserializer.IsNextField(DataField.DeactivatedLabel))
            {
                m_Label = editDeserializer.ReadFeatureRef<TextFeature>(DataField.DeactivatedLabel);
                m_Label.IsInactive = true; // later ?
            }

            m_Lines = editDeserializer.ReadPersistentArray<LineFeature>(DataField.Lines);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Executes this operation. This version is suitable for adding miscellaneous
        /// non-topological trim.
        /// </summary>
        /// <param name="trim">The text of the label.</param>
        /// <param name="ent">The entity type to assign to the new label (default was null)</param>
        /// <param name="position">The reference position for the label.</param>
        /// <param name="ght">The height of the new label, in meters on the ground.</param>
        /// <param name="gwd">The width of the new label, in meters on the ground.</param>
        /// <param name="rot">The clockwise rotation of the text, in radians from the horizontal.</param>
        internal void Execute(string trim, IEntity ent, IPosition position, double ght, double gwd, double rot)
        {
            // Add the label.
            TextFeature text = MapModel.AddMiscText(this, trim, ent, position, ght, gwd, rot);

            SetText(text);

            // The trim is always non-topological.
            text.SetTopology(false);

            Complete();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MoveTextOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal MoveTextOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Text = editDeserializer.ReadFeatureRef<TextFeature>(DataField.Text);
            m_OldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            m_NewPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldPolygonX))
                m_OldPolPosition = editDeserializer.ReadPointGeometry(DataField.OldPolygonX, DataField.OldPolygonY);
            else
                m_OldPolPosition = null;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Executes the new label operation.
        /// </summary>
        /// <param name="vtx">The position of the new label.</param>
        /// <param name="polygonId">The ID and entity type to assign to the new label.</param>
        /// <param name="pol">The polygon that the label falls inside. It should not already refer to a label.</param>
        /// <param name="height">The height of the text, in meters on the ground.</param>
        /// <param name="width">The width of the text, in meters on the ground.</param>
        /// <param name="rotation">The clockwise rotation of the text, in radians from the horizontal.</param>
        internal void Execute(IPosition vtx, IdHandle polygonId, Polygon pol,
                              double height, double width, double rotation)
        {
            // Add the label.
            CadastralMapModel map  = MapModel;
            TextFeature       text = map.AddKeyLabel(this, polygonId, vtx, height, width, rotation);

            SetText(text);

            // Associate the polygon with the label, and vice versa.
            text.SetTopology(true);
            pol.ClaimLabel(text);

            Complete();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="label">The polygon label that was modified</param>
        /// <param name="newPosition">The revised position of the reference point.</param>
        /// <param name="oldPosition">The original position of the reference point.</param>
        static void ReadData(EditDeserializer editDeserializer, out TextFeature label, out PointGeometry newPosition,
                             out PointGeometry oldPosition)
        {
            label       = editDeserializer.ReadFeatureRef <TextFeature>(DataField.Label);
            newPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldX))
            {
                oldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            }
            else
            {
                oldPosition = null;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new <c>NewTextForm</c>
        /// </summary>
        /// <param name="label">Optional label that's being updated (null if
        /// specifying a new item of text) [default was null]</param>
        internal NewTextForm(TextFeature label)
        {
            InitializeComponent();

            m_Text   = String.Empty;
            m_Entity = null;
            m_Label  = label;

            // If we're doing an update, grab initial values.
            if (m_Label != null)
            {
                m_Text   = m_Label.TextGeometry.Text;
                m_Entity = m_Label.EntityType;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MoveTextOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal MoveTextOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Text        = editDeserializer.ReadFeatureRef <TextFeature>(DataField.Text);
            m_OldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            m_NewPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldPolygonX))
            {
                m_OldPolPosition = editDeserializer.ReadPointGeometry(DataField.OldPolygonX, DataField.OldPolygonY);
            }
            else
            {
                m_OldPolPosition = null;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="sub">The polygon subdivision information.</param>
        internal void Execute(PolygonSub sub)
        {
            int numLine = sub.NumLink;

            if (numLine == 0)
            {
                throw new Exception("PolygonSubdivisionOperation.Execute - Nothing to add");
            }

            // If the polygon contains just one label, de-activate it. This covers a "well-behaved" situation,
            // where the label inside the polygon is likely to be redundant after the subdivision (it also
            // conforms to logic used in the past). In a situation where the polygon contains multiple labels,
            // it's less clear whether the labels become redundant or not, so we keep them all.
            Polygon pol = sub.Polygon;

            if (pol.LabelCount == 1)
            {
                m_Label = pol.Label;
                if (m_Label != null)
                {
                    m_Label.IsInactive = true;
                }
            }

            // Mark the polygon for deletion
            pol.IsDeleted = true;

            // Get the default entity type for lines.
            CadastralMapModel map = MapModel;
            IEntity           ent = map.DefaultLineType;

            // Allocate array to point to the lines we will be creating.
            m_Lines = new LineFeature[numLine];

            // Add lines for each link
            PointFeature start, end;

            for (int i = 0; sub.GetLink(i, out start, out end); i++)
            {
                m_Lines[i] = map.AddLine(start, end, ent, this);
            }

            // Peform standard completion steps
            Complete();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Update a previously added item of text.
        /// </summary>
        /// <param name="label">The previously added text.</param>
        /// <returns>TRUE if an update was made.</returns>
        internal override bool UpdateLabel(TextFeature label)
        {
            throw new NotImplementedException("NewTextUI.UpdateLabel");

            //// The label MUST be miscellaneous text.
            //MiscTextGeometry text = (label.TextGeometry as MiscTextGeometry);
            //if (text==null)
            //    throw new Exception("Can only update miscellaneous text.");

            //// Display dialog to get info.
            //NewTextForm dial = new NewTextForm(label);
            //if (dial.ShowDialog() != DialogResult.OK)
            //{
            //    dial.Dispose();
            //    return false;
            //}

            //// Confirm that the entity type has been specified.
            //IEntity ent = dial.EntityType;
            //if (ent==null)
            //{
            //    MessageBox.Show("Text type must be specified.");
            //    return false;
            //}

            //// Confirm that the new text is defined.
            //m_NewText = dial.EnteredText.Trim();
            //if (m_NewText.Length==0)
            //{
            //    MessageBox.Show("You cannot delete text this way.");
            //    return false;
            //}

            //// Set the new text (this removes the old text from the
            //// spatial index, changes the text, and re-indexes).
            //text.SetText(label, m_NewText);

            //// Change the text's entity type.
            //if (ent.Id != label.EntityType.Id)
            //    label.EntityType = ent;

            //// Redraw the text.
            //label.Draw(ActiveDisplay, Color.Black);
            //return true;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Executes the new label operation.
        /// </summary>
        /// <param name="vtx">The position of the new label.</param>
        /// <param name="polygonId">The ID and entity type to assign to the new label.</param>
        /// <param name="row">The data to use for creating a row for the new label.</param>
        /// <param name="atemplate">The template to use in creating the RowTextGeometry
        /// for the new label.</param>
        /// <param name="pol">The polygon that the label falls inside. It should not already
        /// refer to a label. Not null.</param>
        /// <param name="height">The height of the text, in meters on the ground.</param>
        /// <param name="width">The width of the new label, in meters on the ground.</param>
        /// <param name="rotation">The clockwise rotation of the text, in radians from the horizontal.</param>
        internal void Execute(IPosition vtx, IdHandle polygonId, DataRow row, ITemplate atemplate, Polygon pol,
                              double height, double width, double rotation)
        {
            if (pol == null)
            {
                throw new ArgumentNullException();
            }

            // Add the label.
            TextFeature text = MapModel.AddRowLabel(this, polygonId, vtx, row, atemplate, height, width, rotation);

            SetText(text);

            // Associate the polygon with the label, and vice versa.
            text.SetTopology(true);
            pol.ClaimLabel(text);

            Complete();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Handles a mouse down event
        /// </summary>
        /// <param name="p">The position where the click occurred</param>
        /// <returns>True (always), indicating that something was done.</returns>
        internal override bool LButtonDown(IPosition p)
        {
            // Erase any text outline.
            EraseRect();

            // Add a new label.
            TextFeature label = AddNewLabel(p);

            // Draw it.
            if (label != null)
            {
                label.Draw(ActiveDisplay, Color.Black);
            }

            // Tell the base class.
            OnLabelAdd();

            // Get the info for the next piece of text.
            GetLabelInfo();

            return(true);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Do any command-specific drawing.
        /// </summary>
        /// <param name="point">The specific point (if any) that the parent window has drawn.</param>
        internal override void Paint(PointFeature point)
        {
            HighlightStyle style = new HighlightStyle();

            if (m_Orient != null)
            {
                style.ShowLineEndPoints = false;
                m_Orient.Render(ActiveDisplay, style);
            }

            if (m_IsAutoPos && m_Polygon != null)
            {
                if (m_AutoPosition == null)
                {
                    m_AutoPosition = m_Polygon.GetLabelPosition(Width, Height);
                }

                DrawText(m_AutoPosition);
            }
            else
            {
                base.Paint(point);
            }

            if (IsValidPolygon())
            {
                m_Polygon.Render(ActiveDisplay, style);

                // If the polygon actually contains a label that is drawn on the current editing
                // layer, take this opportunity to draw it in gray.
                TextFeature label = m_Polygon.Label;
                if (label != null)
                {
                    label.Draw(ActiveDisplay, Color.Gray);
                }
            }
        }
Ejemplo n.º 23
0
 abstract internal bool UpdateLabel(TextFeature label);
Ejemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewTextOperation"/> class.
 /// </summary>
 protected NewTextOperation()
     : base()
 {
     m_NewText = null;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewTextOperation"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 protected NewTextOperation(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     m_NewText = editDeserializer.ReadPersistent<TextFeature>(DataField.Text);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Defines the text created by this edit
 /// </summary>
 /// <param name="label">The created text (not null)</param>
 internal void SetText(TextFeature label)
 {
     m_NewText = label;
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewTextOperation"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 protected NewTextOperation(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     m_NewText = editDeserializer.ReadPersistent <TextFeature>(DataField.Text);
 }
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="sub">The polygon subdivision information.</param>
        internal void Execute(PolygonSub sub)
        {
            int numLine = sub.NumLink;
            if (numLine==0)
                throw new Exception("PolygonSubdivisionOperation.Execute - Nothing to add");

            // If the polygon contains just one label, de-activate it. This covers a "well-behaved" situation,
            // where the label inside the polygon is likely to be redundant after the subdivision (it also
            // conforms to logic used in the past). In a situation where the polygon contains multiple labels,
            // it's less clear whether the labels become redundant or not, so we keep them all.
            Polygon pol = sub.Polygon;
            if (pol.LabelCount == 1)
            {
                m_Label = pol.Label;
                if (m_Label!=null)
                    m_Label.IsInactive = true;
            }

            // Mark the polygon for deletion
            pol.IsDeleted = true;

            // Get the default entity type for lines.
            CadastralMapModel map = MapModel;
            IEntity ent = map.DefaultLineType;

            // Allocate array to point to the lines we will be creating.
            m_Lines = new LineFeature[numLine];

            // Add lines for each link
            PointFeature start, end;
            for (int i=0; sub.GetLink(i, out start, out end); i++)
            {
                m_Lines[i] = map.AddLine(start, end, ent, this);
            }

            // Peform standard completion steps
            Complete();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Updates a previously added polygon label.
        /// </summary>
        /// <param name="label">The previously added label.</param>
        /// <returns>True if an update was made.</returns>
        internal override bool UpdateLabel(TextFeature label)
        {
            // For the time being, "update" means updating the attributes
            // associated with the label. There's no way to update the
            // entity type, schema, or annotation template (apart from
            // deleting an existing label, and re-adding a new one).

            return false;
        }
Ejemplo n.º 30
0
 internal abstract bool UpdateLabel(TextFeature label);
Ejemplo n.º 31
0
        /// <summary>
        /// Handles a mouse down event
        /// </summary>
        /// <param name="p">The position where the click occurred</param>
        /// <returns>True (always), indicating that something was done.</returns>
        internal override bool LButtonDown(IPosition p)
        {
            // Make sure the enclosing polygon refers to the point we
            // have been supplied.
            MouseMove(p);

            // Exit the command if the user left-clicked in an area that
            // does not have a polygon (perhaps the user doesn't know that
            // you exit via the right-click menu).
            if (m_Polygon == null)
            {
                DialFinish(null);
                return(true);
            }

            // Issue error if the enclosing polygon already has a label (this
            // was supposed to be pretty obvious, given that the cursor is
            // grey, and the polygon is not filled in that case).
            if (!IsValidPolygon())
            {
                MessageBox.Show("Polygon already has a label");
                SetCommandCursor();
                return(true);
            }

            // Erase any text outline.
            EraseRect();

            // Erase any highlighting.
            DrawPolygon(false);

            if (m_Orient != null)
            {
                ErasePainting();
                m_Orient = null;
            }

            // Does the polygon actually contain a label that's shared with a base layer?
            TextFeature oldLabel = m_Polygon.Label;

            // Add a new label.
            TextFeature label = null;

            if (m_IsAutoPos)
            {
                label = AddNewLabel();
            }
            else
            {
                label = AddNewLabel(p);
            }

            // Tell the base class (resets the last known position, used
            // to erase labels during dragging).
            OnLabelAdd();

            // Undefine the enclosing polygon pointer so that the cursor
            // will become gray as the user moves the mouse out of the polygon.
            m_Polygon = null;

            // Draw it. Note that if the new label replaces an old label,
            // the AddNewLabel call explicitly erases it, but something
            // from within a subsequent CleanEdit call re-draws it in
            // red. To get around that, ensure it's erased again here.
            // ...changes made elsewhere may now make this redundant
            //if (pLabel)
            //{
            //    if (pOldLabel)
            //        pOldLabel->Erase();
            //    GetpWnd()->Draw(pLabel, COL_BLACK);
            //}

            // Get the info for the next label.
            return(GetLabelInfo());
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Update a previously added item of text.
        /// </summary>
        /// <param name="label">The previously added text.</param>
        /// <returns>TRUE if an update was made.</returns>
        internal override bool UpdateLabel(TextFeature label)
        {
            throw new NotImplementedException("NewTextUI.UpdateLabel");

            //// The label MUST be miscellaneous text.
            //MiscTextGeometry text = (label.TextGeometry as MiscTextGeometry);
            //if (text==null)
            //    throw new Exception("Can only update miscellaneous text.");

            //// Display dialog to get info.
            //NewTextForm dial = new NewTextForm(label);
            //if (dial.ShowDialog() != DialogResult.OK)
            //{
            //    dial.Dispose();
            //    return false;
            //}

            //// Confirm that the entity type has been specified.
            //IEntity ent = dial.EntityType;
            //if (ent==null)
            //{
            //    MessageBox.Show("Text type must be specified.");
            //    return false;
            //}

            //// Confirm that the new text is defined.
            //m_NewText = dial.EnteredText.Trim();
            //if (m_NewText.Length==0)
            //{
            //    MessageBox.Show("You cannot delete text this way.");
            //    return false;
            //}

            //// Set the new text (this removes the old text from the
            //// spatial index, changes the text, and re-indexes).
            //text.SetText(label, m_NewText);

            //// Change the text's entity type.
            //if (ent.Id != label.EntityType.Id)
            //    label.EntityType = ent;

            //// Redraw the text.
            //label.Draw(ActiveDisplay, Color.Black);
            //return true;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Creates a new polygon label in the map.
        /// </summary>
        /// <param name="posn">Reference position for the label.</param>
        /// <returns>The text feature that was added.</returns>
        internal override TextFeature AddNewLabel(IPosition posn)
        {
            Debug.Assert(m_Polygon != null);
            CadastralMapModel map      = CadastralMapModel.Current;
            TextFeature       newLabel = null;

            // Confirm that the polygon ID has been reserved.
            if (!m_PolygonId.IsReserved)
            {
                MessageBox.Show("NewLabelUI.AddNewLabel - No polygon ID");
                return(null);
            }

            /*
             * // Check whether another label exists in the specified
             * // polygon, but on a layer that is derived from the current
             * // editing layer. If so, note the entity type and free the
             * // supplied ID.
             *
             * // SS20080421 - This bit of code was used to check whether the polygon
             * // was already labelled on a derived layer, in which case the ID would
             * // be promoted to the current layer. However, it's difficult to continue
             * // with that logic, since the polygon object is no longer shared with
             * // any other layer (and won't even exist unless you switch to another
             * // editing layer). Even if the structure was unchanged, I'm not convinced
             * // that it's good to define the ID on the basis of something that the user
             * // can't actually see (if this were to be done, the user should have been
             * // told already, since an explicitly specified ID would be disregarded here).
             *
             *  CeLabel* pOldLabel = m_pPolygon->GetBaseLabel();
             *  const CeEntity* pEnt=0;
             *
             *  if ( pOldLabel ) {
             *          pEnt = m_PolygonId.GetpEntity();
             *          m_PolygonId.FreeId();
             *  }
             */

            // Execute the edit
            NewTextOperation txop = null;

            try
            {
                if (m_Template != null && m_LastRow != null)
                {
                    // Save the attributes in the database
                    IDataServer ds = EditingController.Current.DataServer;
                    if (ds == null)
                    {
                        throw new InvalidOperationException("No database available");
                    }

                    ds.SaveRow(m_LastRow);

                    NewRowTextOperation op = new NewRowTextOperation();
                    txop = op;
                    op.Execute(posn, m_PolygonId, m_LastRow, m_Template, m_Polygon, Height, Width, Rotation);

                    // Confirm that the row got cross-referenced to an ID (not
                    // sure what the above ends up doing).
                    //if (m_LastRow.GetpId()==null)
                    //{
                    //    MessageBox.Show("Attributes were not attached to an ID");
                    //    return null;
                    //}
                }
                else
                {
                    NewKeyTextOperation op = new NewKeyTextOperation();
                    txop = op;
                    op.Execute(posn, m_PolygonId, m_Polygon, Height, Width, Rotation);
                }

                newLabel = txop.Text;
            }

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

            return(newLabel);
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewTextOperation"/> class.
 /// </summary>
 protected NewTextOperation()
     : base()
 {
     m_NewText = null;
 }
        /// <summary>
        /// Reads data that was previously written using <see cref="WriteData"/>
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        /// <param name="label">The polygon label that was modified</param>
        /// <param name="newPosition">The revised position of the reference point.</param>
        /// <param name="oldPosition">The original position of the reference point.</param>
        static void ReadData(EditDeserializer editDeserializer, out TextFeature label, out PointGeometry newPosition,
            out PointGeometry oldPosition)
        {
            label = editDeserializer.ReadFeatureRef<TextFeature>(DataField.Label);
            newPosition = editDeserializer.ReadPointGeometry(DataField.NewX, DataField.NewY);

            if (editDeserializer.IsNextField(DataField.OldX))
                oldPosition = editDeserializer.ReadPointGeometry(DataField.OldX, DataField.OldY);
            else
                oldPosition = null;
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Defines the text created by this edit
 /// </summary>
 /// <param name="label">The created text (not null)</param>
 internal void SetText(TextFeature label)
 {
     m_NewText = label;
 }