コード例 #1
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_Dialog != null)
            {
                throw new InvalidOperationException("RadialUI.Run - Command is already running.");
            }

            UpdateUI pup = this.Update;

            if (pup != null)
            {
                m_Dialog = new RadialControl(pup);
            }
            else
            {
                if (m_From == null)
                {
                    RadialOperation recall = (RadialOperation)this.Recall;
                    m_From = recall.From;
                }

                m_Dialog = new RadialControl(this, m_From);
            }

            this.Container.Display(m_Dialog);
            return(true);
        }
コード例 #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("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());
        }