Пример #1
0
        /// <summary>
        /// Creates a new <c>SelectionTool</c> for performing line- and area-
        /// based selections.
        /// </summary>
        /// <param name="controller">The controller making use of this tool (not null)</param>
        /// <exception cref="ArgumentNullException">If <paramref name="controller"/> is null</exception>
        internal SelectionTool(EditingController controller)
        {
            if (controller == null)
                throw new ArgumentNullException();

            m_Controller = controller;
            m_Limit = null;
            m_Mouse = null;
            m_LimSel = new List<ISpatialObject>();
        }
Пример #2
0
        /// <summary>
        /// Creates a new <c>SelectionTool</c> for performing line- and area-
        /// based selections.
        /// </summary>
        /// <param name="controller">The controller making use of this tool (not null)</param>
        /// <exception cref="ArgumentNullException">If <paramref name="controller"/> is null</exception>
        internal SelectionTool(EditingController controller)
        {
            if (controller == null)
            {
                throw new ArgumentNullException();
            }

            m_Controller = controller;
            m_Limit      = null;
            m_Mouse      = null;
            m_LimSel     = new List <ISpatialObject>();
        }
Пример #3
0
        /// <summary>
        /// Reads a distance unit type.
        /// </summary>
        /// <param name="field">A tag associated with the item</param>
        /// <returns>The distance unit that was read.</returns>
        internal DistanceUnit ReadDistanceUnit(DataField field)
        {
            DistanceUnitType unitType = (DistanceUnitType)m_Reader.ReadInt32(field.ToString());

            return(EditingController.GetUnits(unitType));
        }
Пример #4
0
        /// <summary>
        /// Gets the distance string to annotate a line with.
        /// </summary>
        /// <param name="len">The adjusted length (in meters on the ground).</param>
        /// <param name="dist">The observed length (if any).</param>
        /// <param name="drawObserved">Draw the observed distance?</param>
        /// <returns>The distance string (null if the distance is supposed to be the
        /// observed distance, but there is no observed distance.</returns>
        protected string GetDistance(double len, Distance dist, bool drawObserved)
        {
            // Return if we are drawing the observed distance, and we don't have one.
            if (drawObserved && dist == null)
            {
                return(null);
            }

            // Get the current display units.
            EditingController ec    = EditingController.Current;
            DistanceUnit      dunit = ec.DisplayUnit;
            string            distr = String.Empty;

            // If we are drawing the observed distance
            if (drawObserved)
            {
                // Display the units only if the distance does not
                // correspond to the current data entry units.

                if (dunit.UnitType == DistanceUnitType.AsEntered)
                {
                    dunit = ec.EntryUnit;
                }

                if (!dist.EntryUnit.Equals(dunit))
                {
                    distr = dist.Format(true); // with units abbreviation
                }
                else
                {
                    distr = dist.Format(false); // no units abbreviation
                }
            }
            else
            {
                // Drawing adjusted distance.

                // If the current display units are "as entered"

                if (dunit.UnitType == DistanceUnitType.AsEntered)
                {
                    // What's the current data entry unit?
                    DistanceUnit eunit = ec.EntryUnit;

                    // Display the units only if the distance does not
                    // correspond to the current data entry units.
                    if (dist != null)
                    {
                        DistanceUnit entryUnit = dist.EntryUnit;
                        if (entryUnit != eunit)
                        {
                            distr = entryUnit.Format(len, true); // with abbrev
                        }
                        else
                        {
                            distr = entryUnit.Format(len, false); // no abbrev
                        }
                    }
                    else
                    {
                        // No observed length, so format the actual length using
                        // the current data entry units (no abbreviation).
                        distr = eunit.Format(len, false);
                    }
                }
                else
                {
                    // Displaying in a specific display unit. Format the
                    // result without any units abbreviation.
                    distr = dunit.Format(len, false);
                }
            }

            // Never show distances with a leading negative sign.
            if (distr.StartsWith("-"))
            {
                distr = distr.Substring(1);
            }

            return(distr);
        }
Пример #5
0
        /// <summary>
        /// Converts a string that represents a distance unit abbreviation into
        /// a DistanceUnit reference (to one of the objects known to the enclosing map).
        /// </summary>
        /// <param name="abbrev">The units abbreviation.</param>
        /// <returns>The corresponding units (null if the abbreviation was not found).</returns>
        DistanceUnit MatchUnits(string abbrev)
        {
            EditingController ec = EditingController.Current;

            return(ec.GetUnit(abbrev));
        }