Exemplo n.º 1
0
        /// <summary>
        /// Runs a deletion command by creating the editing operation (using the current feature
        /// selection) & executing it. The controller is then told to clear the selection before
        /// completing the command.
        /// </summary>
        /// <returns>True if the command ran to completion. False if any exception arose (in that
        /// case, the controller would be told to abort the command).</returns>
        internal override bool Run()
        {
            EditingController c   = Controller;
            DeletionOperation dop = null;

            try
            {
                SetCommandCursor();
                dop = new DeletionOperation();
                foreach (ISpatialObject so in c.SpatialSelection.Items)
                {
                    if (so is Feature)
                    {
                        dop.AddDeletion(so as Feature);
                    }
                }
                dop.Execute();
                c.ClearSelection();
                c.FinishCommand(this);
                return(true);
            }

            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace, e.Message);
                c.AbortCommand(this);
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Undoes the last edit.
        /// </summary>
        /// <returns>True if the command ran to completion. False if there was nothing to
        /// undo in the current editing session, or an exception arose.</returns>
        internal override bool Run()
        {
            EditingController c = Controller;

            try
            {
                // Turn off any highlighted features (confusing if the feature is undone by the rollback).
                c.ClearSelection();

                // Ask the map to rollback the last operation (restricting
                // to the current editing session).
                Session s = CadastralMapModel.Current.WorkingSession;
                if (CadastralMapModel.Current.Rollback(s))
                {
                    c.FinishCommand(this);
                    return(true);
                }

                MessageBox.Show("Nothing to undo from current session.");
            }

            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            c.AbortCommand(this);
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Runs a trim dangles command by creating the editing operation (using the current feature
        /// selection) & executing it. The controller is then told to clear the selection before
        /// completing the command.
        /// </summary>
        /// <returns>True if the command ran to completion. False if any exception arose (in that
        /// case, the controller would be told to abort the command).</returns>
        internal override bool Run()
        {
            // Grab the current selection & filter out stuff that can't be trimmed
            EditingController c  = Controller;
            ISpatialSelection ss = c.SpatialSelection;

            LineFeature[] lines = TrimLineOperation.PreCheck(ss.Items);
            if (lines.Length == 0)
            {
                StringBuilder sb = new StringBuilder(200);
                sb.Append("Nothing can be trimmed. Possible reasons:");
                sb.Append(System.Environment.NewLine);
                sb.Append(System.Environment.NewLine);
                sb.Append("1. Lines have to be dangling.");
                sb.Append(System.Environment.NewLine);
                sb.Append("2. Only lines that are polygon boundaries can be trimmed.");
                sb.Append(System.Environment.NewLine);
                sb.Append("3. There has to be something left after trimming a line.");

                MessageBox.Show(sb.ToString());
                c.AbortCommand(this);
                return(false);
            }

            TrimLineOperation op = null;

            try
            {
                op = new TrimLineOperation();
                op.Execute(lines);

                c.ClearSelection();
                c.FinishCommand(this);
                return(true);
            }

            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace, e.Message);
                c.AbortCommand(this);
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts the user interface (if any) for this command. This will change the
        /// topological status of the line that was passed to the constructor, then
        /// complete the command.
        /// </summary>
        /// <returns>True if command started (and completed) ok.</returns>
        internal override bool Run()
        {
            EditingController    c  = Controller;
            SetTopologyOperation op = null;

            try
            {
                op = new SetTopologyOperation(m_Line);
                op.Execute();
                c.ClearSelection();
                c.FinishCommand(this);
                return(true);
            }

            catch (Exception e)
            {
                c.AbortCommand(this);
                MessageBox.Show(e.StackTrace, e.Message);
            }

            return(false);
        }