Пример #1
0
        private void centreOfCurveCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            // Toggle the status.
            m_WantCentre = !m_WantCentre;

            // If the user now wants to use the centre point as backsight
            if (m_WantCentre)
            {
                // How many circles were incident on the from-point?
                int ncircle = m_Circles.Count;

                // There SHOULD be at least one (otherwise the checkbox that
                // leads to this function should have been diabled).
                if (ncircle==0)
                {
                    MessageBox.Show("The from-point does not coincide with any circular curves.");
                    centreOfCurveCheckBox.Checked = false;
                    return;
                }

                // Get the circle involved. If there's more than one, we need
                // to ask the user which one.
                Circle circle;

                if (ncircle==1)
                    circle = m_Circles[0];
                else
                {
                    // Ask the user to select a circle.
                    GetCircleForm dial = new GetCircleForm(m_Circles);
                    if (dial.ShowDialog() != DialogResult.OK)
                    {
                        centreOfCurveCheckBox.Checked = false;
                        return;
                    }

                    circle = dial.Circle;
                    dial.Dispose();
                }

                // Get the point at the centre.
                ISpatialModel map = CadastralMapModel.Current;
                ISpatialObject so = map.QueryClosest(circle.Center, Backsight.Length.Zero, SpatialType.Point);
                m_Backsight = (so as PointFeature);

                // Confirm that we got something.
                if (m_Backsight==null)
                {
                    MessageBox.Show("Cannot find the center point.");
                    centreOfCurveCheckBox.Checked = false;
                    return;
                }

                // Display the key of the backsight.
                backsightTextBox.Text = String.Format("+{0}", m_Backsight.FormattedKey);

                // Disable the backsight field.
                backsightTextBox.Enabled = false;

                // Resume in the angle field.
                angleTextBox.Focus();
            }
            else
            {
                // Draw any backsight point normally.
                SetNormalColour(m_Backsight);

                // Reset backsight stuff.
                m_Backsight = null;
                backsightTextBox.Enabled = true;
                backsightTextBox.Text = String.Empty;

                // Resume in the backsight field.
                backsightTextBox.Focus();
            }

            OnChange();
        }
        private void useCenterCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            // Draw any existing backsight point normally.
            //SetNormalColour(m_pBacksight);

            // Toggle the status.
            m_WantCentre = !m_WantCentre;

            // If the user now wants to use the centre point as backsight
            if (m_WantCentre)
            {
                // How many circles were incident on the from-point?
                int ncircle = m_Circles.Count;

                // There SHOULD be at least one (otherwise the checkbox that
                // leads to this function should have been disabled).
                if (ncircle==0)
                {
                    MessageBox.Show("The from-point does not coincide with any circular arcs.");
                    useCenterCheckBox.Checked = false;
                    return;
                }

                // Get the circle involved. If there's more than one, we need
                // to ask the user which one.
                Circle circle = m_Circles[0];
                if (ncircle > 1)
                {
                    // Ask the user to select a circle.
                    GetCircleForm dial = new GetCircleForm(m_Circles);
                    if (dial.ShowDialog() != DialogResult.OK)
                    {
                        useCenterCheckBox.Checked = false;
                        dial.Dispose();
                        return;
                    }

                    circle = dial.Circle;
                    dial.Dispose();
                }

                // Get the point at the center.
                m_Backsight = circle.CenterPoint;

                // Confirm that we got something.
                if (m_Backsight==null)
                {
                    MessageBox.Show("Cannot find the center point.");
                    useCenterCheckBox.Checked = false;
                    return;
                }

                // Display the key of the backsight.
                ShowKey(backsightTextBox, m_Backsight);

                // Disable the backsight field.
                backsightTextBox.Enabled = false;

                // Resume in the direction field.
                directionTextBox.Focus();
            }
            else
            {
                // Reset and enable backsight stuff.
                m_Backsight = null;
                backsightTextBox.Enabled = true;
                backsightTextBox.Text = String.Empty;

                // Resume in the backsight field.
                backsightTextBox.Focus();
            }

            OnNewDirection();
        }