예제 #1
0
        private void newFaceButton_Click(object sender, EventArgs e)
        {
            LegFace face = CurrentFace;

            if (face == null)
            {
                return;
            }

            // Get the observed length of the leg (in meters on the ground).
            double len = face.GetTotal();

            try
            {
                this.WindowState = FormWindowState.Minimized;

                // Present a data entry dialog for the new face.
                using (LegForm dial = new LegForm(len))
                {
                    if (dial.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    // Create the new face and insert it after the current leg.

                    // Must be at least two distances
                    Distance[] dists = dial.Distances;
                    if (dists == null || dists.Length < 2)
                    {
                        MessageBox.Show("The new face must have at least two spans");
                        return;
                    }

                    // Default annotations to the flip side
                    foreach (Distance d in dists)
                    {
                        d.IsAnnotationFlipped = true;
                    }

                    // Attach the new face to the leg
                    var newFace = new LegFace(face.Leg, dists);

                    // Insert the new face into our array of faces.
                    int faceIndex = m_Faces.IndexOf(face);
                    m_Faces.Insert(faceIndex + 1, newFace);

                    // Make the new face the current leg, and select the very first distance.
                    SetCurrentFace(m_CurFaceIndex + 1);
                    Refresh(0);
                }
            }

            finally
            {
                this.WindowState = FormWindowState.Normal;
            }
        }
        private void newFaceButton_Click(object sender, EventArgs e)
        {
            // If we previously highlighted something, draw it normally (since it cannot exist as part of any other face).
            m_SelectedLine = null;

            // If a second face doesn't already exist, get the user to specify the distances.

            if (m_Face2 == null)
            {
                try
                {
                    this.WindowState = FormWindowState.Minimized;

                    // Get the distance observations

                    using (LegForm dial = new LegForm(GetObservedLength()))
                    {
                        if (dial.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        // Must be at least two distances
                        Distance[] dists = dial.Distances;
                        if (dists == null || dists.Length < 2)
                        {
                            MessageBox.Show("The new face must have at least two spans");
                            return;
                        }

                        // Default annotations to the flip side
                        foreach (Distance d in dists)
                        {
                            d.IsAnnotationFlipped = true;
                        }

                        // Create the new face (for use in preview only)
                        m_Face2 = new LineSubdivisionFace(dists, m_Face1.IsEntryFromEnd);
                        InitializeWorkingFace(m_Face2, false);

                        newFaceButton.Text = "&Other Face";
                    }
                }

                finally
                {
                    this.WindowState = FormWindowState.Normal;
                }
            }

            // Switch to the other face (possibly the one just added)

            if (m_CurrentFace == m_Face1)
            {
                m_CurrentFace = m_Face2;
            }
            else
            {
                m_CurrentFace = m_Face1;
            }

            RefreshList();
        }
        private void newFaceButton_Click(object sender, EventArgs e)
        {
            // If we previously highlighted something, draw it normally (since it cannot exist as part of any other face).
            m_SelectedLine = null;

            // If a second face doesn't already exist, get the user to specify the distances.

            if (m_Face2 == null)
            {
                try
                {
                    this.WindowState = FormWindowState.Minimized;

                    // Get the distance observations

                    using (LegForm dial = new LegForm(GetObservedLength()))
                    {
                        if (dial.ShowDialog() != DialogResult.OK)
                            return;

                        // Must be at least two distances
                        Distance[] dists = dial.Distances;
                        if (dists == null || dists.Length < 2)
                        {
                            MessageBox.Show("The new face must have at least two spans");
                            return;
                        }

                        // Default annotations to the flip side
                        foreach (Distance d in dists)
                            d.IsAnnotationFlipped = true;

                        // Create the new face (for use in preview only)
                        m_Face2 = new LineSubdivisionFace(dists, m_Face1.IsEntryFromEnd);
                        InitializeWorkingFace(m_Face2, false);

                        newFaceButton.Text = "&Other Face";
                    }
                }

                finally
                {
                    this.WindowState = FormWindowState.Normal;
                }
            }

            // Switch to the other face (possibly the one just added)

            if (m_CurrentFace == m_Face1)
                m_CurrentFace = m_Face2;
            else
                m_CurrentFace = m_Face1;

            RefreshList();
        }
예제 #4
0
        private void newFaceButton_Click(object sender, EventArgs e)
        {
            LegFace face = CurrentFace;
            if (face == null)
                return;

            // Get the observed length of the leg (in meters on the ground).
            double len = face.GetTotal();

            try
            {
                this.WindowState = FormWindowState.Minimized;

                // Present a data entry dialog for the new face.
                using (LegForm dial = new LegForm(len))
                {
                    if (dial.ShowDialog() != DialogResult.OK)
                        return;

                    // Create the new face and insert it after the current leg.

                    // Must be at least two distances
                    Distance[] dists = dial.Distances;
                    if (dists == null || dists.Length < 2)
                    {
                        MessageBox.Show("The new face must have at least two spans");
                        return;
                    }

                    // Default annotations to the flip side
                    foreach (Distance d in dists)
                        d.IsAnnotationFlipped = true;

                    // Attach the new face to the leg
                    var newFace = new LegFace(face.Leg, dists);

                    // Insert the new face into our array of faces.
                    int faceIndex = m_Faces.IndexOf(face);
                    m_Faces.Insert(faceIndex + 1, newFace);

                    // Make the new face the current leg, and select the very first distance.
                    SetCurrentFace(m_CurFaceIndex + 1);
                    Refresh(0);
                }
            }

            finally
            {
                this.WindowState = FormWindowState.Normal;
            }
        }