コード例 #1
0
        bool InitRecall()
        {
            ParallelLineOperation op = (m_Cmd.Recall as ParallelLineOperation);

            if (op == null)
            {
                return(false);
            }

            // Unlike updates, the reference line can be different
            // from what it was originally.

            // Initialize the observed stuff.
            InitOp(op);
            return(true);
        }
コード例 #2
0
        bool InitUpdate()
        {
            // Get the creating op.
            ParallelLineOperation op = UpdateOp;

            if (op == null)
            {
                return(false);
            }

            // Pick up the reference arc.
            m_Line = op.ReferenceLine;

            // Initialize the observed stuff.
            InitOp(op);
            return(true);
        }
コード例 #3
0
        void InitOp(ParallelLineOperation op)
        {
            // The direction is significant only if an offset distance
            // has been specified.
            m_IsLeft = false;

            // Pick up the offset.
            Observation offset = op.Offset;

            // If it's an observed distance, get the side.
            Distance dist = (offset as Distance);

            if (dist != null)
            {
                m_Offset = new Distance(dist);
                m_IsLeft = m_Offset.SetPositive();
            }
            else
            {
                // The only other thing it could be is an offset point.
                OffsetPoint offPoint = (offset as OffsetPoint);
                if (offPoint != null)
                {
                    m_Point = offPoint.Point;
                }
            }

            if (m_Point != null)
            {
                SelectPoint(m_Point);
            }
            else if (m_Offset != null)
            {
                offsetTextBox.Text = m_Offset.Format();
            }
        }
コード例 #4
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>True if command finished ok</returns>
        internal override bool DialFinish(Control wnd)
        {
            // If it's the offset dialog that's just finished, grab info
            // from it, delete it, and go to the dialog for the first
            // terminal line.

            ISpatialDisplay view = ActiveDisplay;
            UpdateUI        up   = this.Update;

            if (m_ParDial != null)
            {
                // Get info from dialog (it'll be ONE of the two). The dialog
                // should only call this function after validating that one
                // of them is defined.
                m_OffsetPoint = m_ParDial.OffsetPoint;
                if (m_OffsetPoint == null)
                {
                    m_Offset = m_ParDial.OffsetDistance;
                }

                // Destroy the dialog.
                KillDialogs();

                // Calculate the positions for the parallel points.
                Calculate();

                // Repaint what we know about.
                Draw();

                // And start the dialog for the first terminal line.
                if (up != null)
                {
                    m_TermDial1 = new TerminalControl(up, false);
                }
                else
                {
                    m_TermDial1 = new TerminalControl(this, false);
                }

                //m_TermDial1.Show();
                this.Container.Display(m_TermDial1);
                return(true);
            }

            if (m_TermDial1 != null)
            {
                // Get the first terminal line (if any). And the position.
                m_TermLine1 = m_TermDial1.TerminalLine;
                m_Term1     = m_TermDial1.TerminalPosition;

                // And move on to the 2nd terminal dialog.
                KillDialogs();

                // Repaint what we know about.

                Draw();
                // And start the dialog for the first terminal line.
                if (up != null)
                {
                    m_TermDial2 = new TerminalControl(up, true);
                }
                else
                {
                    m_TermDial2 = new TerminalControl(this, true);
                }

                this.Container.Display(m_TermDial2);
                //m_TermDial2.Show();
                return(true);
            }

            if (m_TermDial2 == null)
            {
                throw new Exception("ParallelLineUI.DialFinish - No dialog!");
            }

            // Get the nortthern terminal line (if any). And the position.
            m_TermLine2 = m_TermDial2.TerminalLine;
            m_Term2     = m_TermDial2.TerminalPosition;

            // Erase everything special that we've drawn.
            ErasePainting();

            // And ensure the view has nothing selected (sometimes the line
            // last selected had been unhighlighted, although it's end points
            // stay highlighted for some reason).
            EditingController.Current.ClearSelection();

            // If we are doing an update, remember the changes
            if (up != null)
            {
                // Get the original operation.
                ParallelLineOperation op = (ParallelLineOperation)up.GetOp();
                if (op == null)
                {
                    throw new Exception("ParallelLineUI.DialFinish - Unexpected edit type.");
                }

                // Note the offset (it SHOULD be defined)
                Observation offset = null;

                if (m_Offset != null)
                {
                    offset = m_Offset;
                }
                else if (m_OffsetPoint != null)
                {
                    offset = new OffsetPoint(m_OffsetPoint);
                }

                Debug.Assert(offset != null);

                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)

                UpdateItemCollection changes = op.GetUpdateItems(m_Line, offset, m_TermLine1, m_TermLine2, m_IsReversed);
                if (!up.AddUpdate(op, changes))
                {
                    return(false);
                }
            }
            else
            {
                Observation offset = m_Offset;
                if (offset == null && m_OffsetPoint != null)
                {
                    offset = new OffsetPoint(m_OffsetPoint);
                }
                Debug.Assert(offset != null);

                // Execute the edit
                ParallelLineOperation op = null;

                try
                {
                    op = new ParallelLineOperation(m_Line, offset, m_TermLine1, m_TermLine2, m_IsReversed);
                    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());
        }
コード例 #5
0
        /// <summary>
        /// Starts the user interface (if any) for this command.
        /// </summary>
        /// <returns>True if command started ok.</returns>
        internal override bool Run()
        {
            // Don't run more than once.
            if (m_ParDial != null || m_TermDial1 != null || m_TermDial2 != null)
            {
                throw new Exception("ParallelLineUI.Run - Command is already running.");
            }

            // If we're doing an update, get the reference line from the original op.
            ParallelLineOperation op = null;
            UpdateUI up = this.Update;

            if (up != null)
            {
                op = (up.GetOp() as ParallelLineOperation);
                if (op == null)
                {
                    throw new Exception("ParallelLineUI.Run - Unexpected edit type.");
                }

                // Pick up the line that acted as the reference line.
                m_Line = op.ReferenceLine;
            }

            // If it wasn't an update, we might be recalling an old op.
            if (op == null)
            {
                op = (this.Recall as ParallelLineOperation);
            }

            // Get old observations if necessary.
            if (op != null)
            {
                // Pick up the offset.
                Observation offset = op.Offset;

                // Is it an observed distance?
                Distance dist = (offset as Distance);
                if (dist != null)
                {
                    m_Offset = new Distance(dist);
                }
                else
                {
                    // The only other thing it could be is an offset point.
                    OffsetPoint offPoint = (offset as OffsetPoint);
                    if (offPoint != null)
                    {
                        m_OffsetPoint = offPoint.Point;
                    }
                }

                m_IsReversed = op.IsArcReversed;
                m_TermLine1  = op.Terminal1;
                m_TermLine2  = op.Terminal2;

                // Ensure the reference line has been selected/highlighted (this may end up
                // calling OnSelectLine)
                EditingController.Current.Select(m_Line);

                // Calculate stuff & paint what we've got.
                Calculate();
                Paint(null);
            }

            // Create modeless dialog.

            if (up != null)
            {
                m_ParDial = new ParallelControl(up);
            }
            else
            {
                m_ParDial = new ParallelControl(this);
            }

            this.Container.Display(m_ParDial);
            return(true);
        }
コード例 #6
0
ファイル: TerminalControl.cs プロジェクト: 15831944/backsight
        int InitUpdate()
        {
            // Get the creating op.
            ParallelLineOperation op = UpdateOp;

            if (op == null)
            {
                return(0);
            }

            ISpatialDisplay view = m_Cmd.ActiveDisplay;
            ParallelLineUI  cmd  = Command;

            // The originally produced parallel may have been
            // changed to have a different offset.

            // Get the line that the parallel originally terminated on (if any).
            if (m_IsLast)
            {
                m_Line = op.Terminal2;
            }
            else
            {
                m_Line = op.Terminal1;
            }

            // If we didn't terminate on any particular line, that's
            // the way it will remain, Otherwise confirm that the
            // parallel continues to intersect it. In the event that
            // the parallel no longer intersects, get another
            // terminal position (and maybe a different terminal line).
            if (m_Line != null)
            {
                m_Terminal = cmd.GetIntersect(m_Line, m_IsLast);
                if (m_Terminal != null)
                {
                    // The parallel still intersects the terminal line that was originally specified,
                    // so highlight the terminal line (having de-selected and unhighlighted
                    // anything that was previously highlighted).

                    m_Line.Render(view, new HighlightStyle());
                }
                else
                {
                    // Get a new terminal position (preferably coincident with some other line).

                    // DON'T try to find a new terminal if the op is being corrected due to a
                    // problem in rollforward preview. In that case, we want the user to see
                    // where the old terminal was ... well, leave that nicety for now.

                    if (!FindTerminal())
                    {
                        return(-1);
                    }
                }
            }
            else
            {
                // Parallel did not terminate on a line, so grab the start or end of the parallel line
                LineFeature parLine = op.ParallelLine;
                if (m_IsLast)
                {
                    m_Terminal = parLine.EndPoint;
                }
                else
                {
                    m_Terminal = parLine.StartPoint;
                }
            }

            return(1);
        }
コード例 #7
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>True if command finished ok</returns>
        internal override bool DialFinish(Control wnd)
        {
            // If it's the offset dialog that's just finished, grab info
            // from it, delete it, and go to the dialog for the first
            // terminal line.

            ISpatialDisplay view = ActiveDisplay;
            UpdateUI up = this.Update;

            if (m_ParDial!=null)
            {
                // Get info from dialog (it'll be ONE of the two). The dialog
                // should only call this function after validating that one
                // of them is defined.
                m_OffsetPoint = m_ParDial.OffsetPoint;
                if (m_OffsetPoint==null)
                    m_Offset = m_ParDial.OffsetDistance;

                // Destroy the dialog.
                KillDialogs();

                // Calculate the positions for the parallel points.
                Calculate();

                // Repaint what we know about.
                Draw();

                // And start the dialog for the first terminal line.
                if (up!=null)
                    m_TermDial1 = new TerminalControl(up, false);
                else
                    m_TermDial1 = new TerminalControl(this, false);

                //m_TermDial1.Show();
                this.Container.Display(m_TermDial1);
                return true;
            }

            if (m_TermDial1!=null)
            {
                // Get the first terminal line (if any). And the position.
                m_TermLine1 = m_TermDial1.TerminalLine;
                m_Term1 = m_TermDial1.TerminalPosition;

                // And move on to the 2nd terminal dialog.
                KillDialogs();

                // Repaint what we know about.

                Draw();
                // And start the dialog for the first terminal line.
                if (up!=null)
                    m_TermDial2 = new TerminalControl(up, true);
                else
                    m_TermDial2 = new TerminalControl(this, true);

                this.Container.Display(m_TermDial2);
                //m_TermDial2.Show();
                return true;
            }

            if (m_TermDial2==null)
                throw new Exception("ParallelLineUI.DialFinish - No dialog!");

            // Get the nortthern terminal line (if any). And the position.
            m_TermLine2 = m_TermDial2.TerminalLine;
            m_Term2 = m_TermDial2.TerminalPosition;

            // Erase everything special that we've drawn.
            ErasePainting();

            // And ensure the view has nothing selected (sometimes the line
            // last selected had been unhighlighted, although it's end points
            // stay highlighted for some reason).
            EditingController.Current.ClearSelection();

            // If we are doing an update, remember the changes
            if (up!=null)
            {
                // Get the original operation.
                ParallelLineOperation op = (ParallelLineOperation)up.GetOp();
                if (op==null)
                    throw new Exception("ParallelLineUI.DialFinish - Unexpected edit type.");

                // Note the offset (it SHOULD be defined)
                Observation offset = null;

                if (m_Offset != null)
                    offset = m_Offset;
                else if (m_OffsetPoint != null)
                    offset = new OffsetPoint(m_OffsetPoint);

                Debug.Assert(offset != null);

                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)

                UpdateItemCollection changes = op.GetUpdateItems(m_Line, offset, m_TermLine1, m_TermLine2, m_IsReversed);
                if (!up.AddUpdate(op, changes))
                    return false;
            }
            else
            {
                Observation offset = m_Offset;
                if (offset == null && m_OffsetPoint != null)
                    offset = new OffsetPoint(m_OffsetPoint);
                Debug.Assert(offset!= null);

                // Execute the edit
                ParallelLineOperation op = null;

                try
                {
                    op = new ParallelLineOperation(m_Line, offset, m_TermLine1, m_TermLine2, m_IsReversed);
                    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();
        }