Esempio n. 1
0
        /// <summary>
        /// Displays all ranges.
        /// </summary>
        /// <param name="win"></param>
        void ShowRanges(IWindow win)
        {
            // Erase whatever's currently in the list
            controlTextBox.Text = String.Empty;

            // Return if there are no ranges.
            if (m_Ranges.Count == 0)
            {
                return;
            }

            // If the map doesn't have a defined extent, we'll need to initialize
            // the display with the window we've got
            if (m_NewMap)
            {
                ISpatialDisplay display = m_Cmd.ActiveDisplay;
                display.ReplaceMapModel(win);

                // Tell the user the draw scale that has been defined, and ensure points are drawn
                // at that scale.
                ProjectSettings ps    = EditingController.Current.Project.Settings;
                double          scale = GetSensibleScale(display.MapScale);
                display.MapScale = scale;
                if (!m_Cmd.ArePointsDrawn())
                {
                    ps.ShowPointScale = (scale + 1);
                    Debug.Assert(m_Cmd.ArePointsDrawn());
                }

                // Ensure the point size isn't TOO small (2mm at the display scale should be fine)
                ps.PointHeight = 0.002 * scale;

                string scalemsg = String.Format("Draw scale has been set to 1:{0}", (uint)scale);
                MessageBox.Show(scalemsg);
            }

            // Only show the first 100 ranges (any more, and the string
            // might get too long to display).
            StringBuilder sb = new StringBuilder(1000);

            for (int i = 0; i < Math.Min(100, m_Ranges.Count); i++)
            {
                ControlRange r = m_Ranges[i];

                // Get the range
                uint minkey = r.Min;
                uint maxkey = r.Max;

                // Form status string
                string status;
                int    nfound = r.NumDefined;
                int    ncontr = r.NumControl;

                if (nfound == ncontr)
                {
                    if (nfound == 1)
                    {
                        status = "found";
                    }
                    else
                    {
                        status = "all found";
                    }
                }
                else
                {
                    status = String.Format("found {0} out of {1}", nfound, ncontr);
                }

                string output;
                if (minkey == maxkey)
                {
                    output = String.Format("{0} ({1})", minkey, status);
                }
                else
                {
                    output = String.Format("{0}-{1} ({2})", minkey, maxkey, status);
                }

                sb.Append(output);
                sb.Append(System.Environment.NewLine);
            }

            controlTextBox.Text = sb.ToString();

            // Message if all the ranges could not be shown.
            if (m_Ranges.Count > 100)
            {
                string msg = String.Format("Only the first 100 ranges (of {0}) have been listed.",
                                           m_Ranges.Count);
                MessageBox.Show(msg);
            }
        }