コード例 #1
0
ファイル: LineExtensionUI.cs プロジェクト: 15831944/backsight
        /// <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>
        /// 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());
        }
コード例 #3
0
        /// <summary>
        /// Reacts to selection of the OK button in the dialog.
        /// </summary>
        /// <param name="wnd">The dialog window.</param>
        /// <returns></returns>
        internal override bool DialFinish(Control wnd)
        {
            if (m_Dialog == null)
            {
                throw new Exception("NewPointUI.DialFinish -- No dialog!");
            }

            // Hide the dialog so it doesn't become part of any saved display
            m_Dialog.Visible = false;

            // If we are doing an update, remember the changes
            UpdateUI up = this.Update;

            if (up != null)
            {
                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)

                Operation            revisedEdit = up.GetOp();
                UpdateItemCollection changes     = m_Dialog.GetUpdateItems();
                if (!up.AddUpdate(revisedEdit, changes))
                {
                    return(false);
                }
            }
            else
            {
                // Save the new point.
                PointFeature p = m_Dialog.Save();
                if (p == null)
                {
                    return(false);
                }

                // Ensure the point is on screen, and select it.
                Controller.EnsureVisible(p, true);
            }

            // Get the base class to finish up.
            return(FinishCommand());
        }
コード例 #4
0
        internal override bool DialFinish(Control wnd)
        {
            if (m_Dialog == null && m_UpDial == null)
            {
                throw new Exception("LineSubdivisionUI.DialFinish - No dialog!");
            }

            UpdateUI up      = this.Update;
            bool     doAbort = false;

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

                // Ensure we've got the edit for the primary face
                if (!pop.IsPrimaryFace)
                {
                    pop = pop.OtherSide;
                    Debug.Assert(pop != null);
                    Debug.Assert(pop.IsPrimaryFace);
                }

                // Package up any changes to the primary face
                UpdateItemCollection changes = pop.GetUpdateItems(m_UpDial.WorkingFace1);
                if (changes.Count > 0)
                {
                    up.AddUpdate(pop, changes);
                }

                // If a second face has just been defined, append a new edit.
                LineSubdivisionFace face2 = m_UpDial.WorkingFace2;
                if (face2 != null)
                {
                    if (pop.OtherSide == null)
                    {
                        AddOtherSide(pop, face2);
                    }
                    else
                    {
                        changes = pop.OtherSide.GetUpdateItems(face2);
                        if (changes.Count > 0)
                        {
                            up.AddUpdate(pop.OtherSide, changes);
                        }
                    }
                }

                // If all we've done is add a new face, UpdateUI.AddUpdate wouldn't have been
                // called, which will later lead to an exception from UpdateUI.FinishCommand (via
                // the FinishCommand done below). So remember to abort in that case.
                doAbort = (up.HasRevisions == false);
            }
            else
            {
                // Ensure that the parent line has been de-selected by the view.
                Controller.ClearSelection();

                // Get the dialog to save.
                m_Dialog.Save();
            }

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

            // Get the base class to finish up.
            if (doAbort)
            {
                return(AbortCommand());
            }
            else
            {
                return(FinishCommand());
            }
        }
コード例 #5
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());
        }
コード例 #6
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("RadialUI.DialFinish - No dialog!");
                return(false);
            }

            // Handle any sub-dialog request.
            if (m_Dialog != wnd)
            {
                return(m_Dialog.DialFinish(wnd));
            }

            // If we are doing an update, remember the changes
            UpdateUI up = this.Update;

            if (up != null)
            {
                RadialOperation pop = (up.GetOp() as RadialOperation);
                if (pop == null)
                {
                    MessageBox.Show("RadialUI.DialFinish - Unexpected edit type.");
                    return(false);
                }

                // Get info from the dialog.
                Direction   dir = m_Dialog.Direction;
                Observation len = m_Dialog.Length;

                // The direction and length must both be defined.
                if (dir == null || len == null)
                {
                    MessageBox.Show("Missing parameters for sideshot update.");
                    return(false);
                }

                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)
                UpdateItemCollection changes = pop.GetUpdateItems(dir, len);
                if (!up.AddUpdate(pop, changes))
                {
                    return(false);
                }
            }
            else
            {
                // Get info from the dialog.
                Direction   dir = m_Dialog.Direction;
                Observation len = m_Dialog.Length;
                IdHandle    idh = m_Dialog.PointId;

                IEntity lineEnt = null;
                if (m_Dialog.WantLine)
                {
                    lineEnt = CadastralMapModel.Current.DefaultLineType;
                    if (lineEnt == null)
                    {
                        throw new InvalidOperationException("No default entity type for lines");
                    }
                }

                // The direction, length, and point entity type must all be defined.
                if (dir == null || len == null || idh.Entity == null)
                {
                    MessageBox.Show("Missing parameters for sideshot creation.");
                    return(false);
                }

                RadialOperation pop = null;

                try
                {
                    pop = new RadialOperation(dir, len);
                    pop.Execute(idh, lineEnt);
                }

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

            // Get the base class to finish up.
            return(FinishCommand());
        }