Ejemplo n.º 1
0
        int ShowCheck(int index, bool advanceOnFix)
        {
            // Get the check object.
            CheckItem check = m_Cmd.GetResult(index);

            if (check == null)
            {
                return(-1);
            }

            // If auto-advance is allowed, and the check has been fixed, keep going until
            // we find something that hasn't been fixed.
            int nShow = index;

            if (advanceOnFix)
            {
                while (check.Types == CheckType.Null)
                {
                    nShow++;
                    if (nShow >= m_nTotal)
                    {
                        return(nShow);
                    }

                    check = m_Cmd.GetResult(nShow);
                    if (check == null)
                    {
                        return(-1);
                    }
                }
            }

            // If there is even more, ensure the OK button says "Next".
            // Otherwise display "Finish" or "ReCheck" depending on
            // whether any edits have been performed.
            if ((nShow + 1) == m_nTotal)
            {
                if (m_IsEdited)
                {
                    okButton.Text = "Re-Chec&k";
                }
                else
                {
                    okButton.Text = "&Finish";
                }
            }
            else
            {
                okButton.Text = "&Next";
            }

            // Enable the "Back" button if we're now beyond the 1st item.
            previousButton.Enabled = (nShow > 0);

            // Display current sequence
            statusGroupBox.Text = String.Format("{0} of {1}", nShow + 1, m_nTotal);

            // Get the check to provide an explanation.
            string msg = (check == null ? "sync lost" : check.Explanation);

            // Get a position for the check. If we can't get one, append a note to the explanation.
            IPosition pos = check.Position;

            if (pos == null)
            {
                msg += " (cannot re-locate the problem)";
            }

            explanationLabel.Text = msg;

            // Return if we did not get a position for the check, ensuring that this
            // focus is with THIS dialog.
            if (pos == null)
            {
                this.Focus();
                return(nShow);
            }

            // Get the current draw window, and shrink it by 10% all the way round.
            ISpatialDisplay display = EditingController.Current.ActiveDisplay;
            Window          win     = new Window(display.Extent);

            win.Expand(-0.1);

            // If necessary, re-center the draw on the position we've got.
            if (!win.IsOverlap(pos))
            {
                display.Center = pos;
            }

            // Select the object involved, so long as it hasn't been de-activated (selecting
            // the object will highlight it and shift the focus to the main map window).
            if (check.Types != CheckType.Null)
            {
                check.Select();
            }

            // Return the index of the check that was actually shown.
            return(nShow);
        }