示例#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>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();
        }
示例#2
0
        /// <summary>
        /// Destroys any dialogs that are currently displayed.
        /// </summary>
        void KillDialogs()
        {
            this.Container.Clear();

            if (m_ParDial!=null)
            {
                m_ParDial.Dispose();
                m_ParDial = null;
            }

            if (m_TermDial1!=null)
            {
                m_TermDial1.Dispose();
                m_TermDial1 = null;
            }

            if (m_TermDial2!=null)
            {
                m_TermDial2.Dispose();
                m_TermDial2 = null;
            }
        }
示例#3
0
 /// <summary>
 /// Initializes everything with null values. For used by constructors.
 /// </summary>
 void SetZeroValues()
 {
     m_Line = null;
     m_ParDial = null;
     m_Offset = null;
     m_OffsetPoint = null;
     m_IsReversed = false;
     m_TermDial1 = null;
     m_TermLine1 = null;
     m_TermDial2 = null;
     m_TermLine2 = null;
     m_Par1 = null;
     m_Par2 = null;
     m_Term1 = null;
     m_Term2 = null;
 }