コード例 #1
0
        /// <summary>
        /// Returns the number of inches represented by a given unit
        /// </summary>
        /// <param name="unit">The unit to use</param>
        /// <returns>The number of inches</returns>
        public static double InchesPerUnit(MS_UNITS unit)
        {
            switch (unit)
            {
            case MS_UNITS.MS_DD:
                return(4374754);

            case MS_UNITS.MS_FEET:
                return(12);

            case MS_UNITS.MS_INCHES:
                return(1);

            case MS_UNITS.MS_KILOMETERS:
                return(39370.1);

            case MS_UNITS.MS_METERS:
                return(39.3701);

            case MS_UNITS.MS_MILES:
                return(63360.0);

            default:
                return(1);
            }
        }
コード例 #2
0
        /// <summary>
        /// Retrieve the current unit precision of the map based on the given unit.
        /// </summary>
        /// <param name="map">The given unit.</param>
        /// <returns>The unit precision of the given unit.</returns>
        public static int GetUnitPrecision(MS_UNITS unit)
        {
            switch (unit)
            {
            case MS_UNITS.MS_DD:
                return(5);

            case MS_UNITS.MS_FEET:
                return(0);

            case MS_UNITS.MS_INCHES:
                return(0);

            case MS_UNITS.MS_KILOMETERS:
                return(3);

            case MS_UNITS.MS_METERS:
                return(0);

            case MS_UNITS.MS_MILES:
                return(3);

            case MS_UNITS.MS_PERCENTAGES:
                return(2);

            case MS_UNITS.MS_PIXELS:
                return(0);
            }

            return(0);
        }
コード例 #3
0
        /// <summary>
        /// Update the extent parameters according to the map.extent parameters.
        /// </summary>
        private void UpdateExtentValues()
        {
            if (comboBoxUnits.SelectedItem != null)
            {
                mapunits = (MS_UNITS)comboBoxUnits.SelectedItem;
            }
            else
            {
                mapunits = map.units;
            }

            unitPrecision     = MapUtils.GetUnitPrecision(mapunits);
            textBoxX.Text     = Convert.ToString(Math.Round((map.extent.maxx + map.extent.minx) / 2, unitPrecision));
            textBoxY.Text     = Convert.ToString(Math.Round((map.extent.maxy + map.extent.miny) / 2, unitPrecision));
            labelUnit2.Text   = MapUtils.GetUnitName(mapunits);
            textBoxScale.Text = Convert.ToString(Convert.ToInt64(map.scaledenom));

            unitPrecision   = MapUtils.GetUnitPrecision(mapunits);
            labelUnit1.Text = MapUtils.GetUnitName(mapunits);

            double zoom = (map.extent.maxx - map.extent.minx);

            if (mapunits != map.units)
            {
                zoom = zoom * MapUtils.InchesPerUnit(map.units) / MapUtils.InchesPerUnit(mapunits);
            }

            textBoxZoomWidth.Text = Convert.ToString(Math.Round(zoom, unitPrecision));
        }
コード例 #4
0
        /// <summary>
        /// Retrieve the current unit name of the given unit.
        /// </summary>
        /// <param name="map">The given unit.</param>
        /// <returns>The current unit name of the given unit.</returns>
        public static string GetUnitName(MS_UNITS unit)
        {
            switch (unit)
            {
            case MS_UNITS.MS_DD:
                return("°");

            case MS_UNITS.MS_FEET:
                return("ft");

            case MS_UNITS.MS_INCHES:
                return("in");

            case MS_UNITS.MS_KILOMETERS:
                return("km");

            case MS_UNITS.MS_METERS:
                return("m");

            case MS_UNITS.MS_MILES:
                return("mi");

            case MS_UNITS.MS_PERCENTAGES:
                return("%");

            case MS_UNITS.MS_PIXELS:
                return("px");
            }

            return("");
        }
コード例 #5
0
        /// <summary>
        /// Triggers a Zoom Chnaged event
        /// </summary>
        private void RaiseZoomChanged()
        {
            MS_UNITS mapunits = map.units;

            int unitPrecision = MapUtils.GetUnitPrecision(mapunits);

            double zoom = (map.extent.maxx - map.extent.minx);

            if (mapunits != map.units)
            {
                zoom = zoom * MapUtils.InchesPerUnit(map.units) / MapUtils.InchesPerUnit(mapunits);
            }
            target.RaiseZoomChanged(this, Math.Round(zoom, unitPrecision), map.scaledenom);
        }
コード例 #6
0
ファイル: ChangeViewForm.cs プロジェクト: 4g0st1n0/MapManager
        /// <summary>
        /// Refresh the controls according to the underlying object.
        /// </summary>
        public void RefreshView()
        {
            mapunits = map.units;

            unitPrecision = MapUtils.GetUnitPrecision(mapunits);
            textBoxX.Text = Convert.ToString(Math.Round((map.extent.maxx + map.extent.minx) / 2, unitPrecision));
            textBoxY.Text = Convert.ToString(Math.Round((map.extent.maxy + map.extent.miny) / 2, unitPrecision));
            labelUnit2.Text = MapUtils.GetUnitName(mapunits);
            textBoxScale.Text = Convert.ToString(Convert.ToInt32(map.scaledenom));

            labelUnit1.Text = MapUtils.GetUnitName(mapunits);

            double zoom = (map.extent.maxx - map.extent.minx);
            if (mapunits != map.units)
                zoom = zoom * MapUtils.InchesPerUnit(map.units) / MapUtils.InchesPerUnit(mapunits);

            textBoxZoomWidth.Text = Convert.ToString(Math.Round(zoom, unitPrecision));
        }
コード例 #7
0
        /// <summary>
        /// Refresh the controls according to the underlying object.
        /// </summary>
        public void RefreshView()
        {
            mapunits = map.units;

            unitPrecision     = MapUtils.GetUnitPrecision(mapunits);
            textBoxX.Text     = Convert.ToString(Math.Round((map.extent.maxx + map.extent.minx) / 2, unitPrecision));
            textBoxY.Text     = Convert.ToString(Math.Round((map.extent.maxy + map.extent.miny) / 2, unitPrecision));
            labelUnit2.Text   = MapUtils.GetUnitName(mapunits);
            textBoxScale.Text = Convert.ToString(Convert.ToInt32(map.scaledenom));

            labelUnit1.Text = MapUtils.GetUnitName(mapunits);

            double zoom = (map.extent.maxx - map.extent.minx);

            if (mapunits != map.units)
            {
                zoom = zoom * MapUtils.InchesPerUnit(map.units) / MapUtils.InchesPerUnit(mapunits);
            }

            textBoxZoomWidth.Text = Convert.ToString(Math.Round(zoom, unitPrecision));
        }
コード例 #8
0
ファイル: MapControl.cs プロジェクト: 4g0st1n0/MapManager
        /// <summary>
        /// Constructs a new MapControl object.
        /// </summary>
        public MapControl()
        {
            InitializeComponent();
            InputMode = InputModes.Pan;
            dragRect = new Rectangle(0,0,0,0);
            dragging = false;
            selectionBrush = new SolidBrush(Color.FromArgb(75, Color.Gray));
            selectionPen = new Pen(Color.Black,1);
            borderPen = new Pen(Color.Black, 1);
            border = false;

            drawMessage = "The map hasn't been initialised yet.";

            gap = 10;

            unitPrecision = 4;
            unitName = "";
            mapunits = MS_UNITS.MS_METERS;

            a11 = a13 = a21 = a23 = 0;

            this.SetStyle(ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
        }
コード例 #9
0
ファイル: MapControl.cs プロジェクト: 4g0st1n0/MapManager
        /// <summary>
        /// Update the unit values according to the mapObj settings.
        /// </summary>
        public void UpdateUnitValues()
        {
            mapunits = map.units;

            unitPrecision = MapUtils.GetUnitPrecision(map.units);

            string newUnit = MapUtils.GetUnitName(mapunits);
            if (unitName != newUnit)
            {
                unitName = newUnit;
                RaiseZoomChanged();
            }
        }
コード例 #10
0
ファイル: MapUtils.cs プロジェクト: 4g0st1n0/MapManager
 /// <summary>
 /// Returns the number of inches represented by a given unit
 /// </summary>
 /// <param name="unit">The unit to use</param>
 /// <returns>The number of inches</returns>
 public static double InchesPerUnit(MS_UNITS unit)
 {
     switch (unit)
     {
         case MS_UNITS.MS_DD:
             return 4374754;
         case MS_UNITS.MS_FEET:
             return 12;
         case MS_UNITS.MS_INCHES:
             return 1;
         case MS_UNITS.MS_KILOMETERS:
             return 39370.1;
         case MS_UNITS.MS_METERS:
             return 39.3701;
         case MS_UNITS.MS_MILES:
             return 63360.0;
         default:
             return 1;
     }
 }
コード例 #11
0
ファイル: MapUtils.cs プロジェクト: 4g0st1n0/MapManager
        /// <summary>
        /// Retrieve the current unit precision of the map based on the given unit.
        /// </summary>
        /// <param name="map">The given unit.</param>
        /// <returns>The unit precision of the given unit.</returns>
        public static int GetUnitPrecision(MS_UNITS unit)
        {
            switch (unit)
            {
                case MS_UNITS.MS_DD:
                    return 5;
                case MS_UNITS.MS_FEET:
                    return 0;
                case MS_UNITS.MS_INCHES:
                    return 0;
                case MS_UNITS.MS_KILOMETERS:
                    return 3;
                case MS_UNITS.MS_METERS:
                    return 0;
                case MS_UNITS.MS_MILES:
                    return 3;
                case MS_UNITS.MS_PERCENTAGES:
                    return 2;
                case MS_UNITS.MS_PIXELS:
                    return 0;
            }

            return 0;
        }
コード例 #12
0
ファイル: MapUtils.cs プロジェクト: 4g0st1n0/MapManager
        /// <summary>
        /// Retrieve the current unit name of the given unit.
        /// </summary>
        /// <param name="map">The given unit.</param>
        /// <returns>The current unit name of the given unit.</returns>
        public static string GetUnitName(MS_UNITS unit)
        {
            switch (unit)
            {
                case MS_UNITS.MS_DD:
                    return "°";
                case MS_UNITS.MS_FEET:
                    return "ft";
                case MS_UNITS.MS_INCHES:
                    return "in";
                case MS_UNITS.MS_KILOMETERS:
                    return "km";
                case MS_UNITS.MS_METERS:
                    return "m";
                case MS_UNITS.MS_MILES:
                    return "mi";
                case MS_UNITS.MS_PERCENTAGES:
                    return "%";
                case MS_UNITS.MS_PIXELS:
                    return "px";
            }

            return "";
        }
コード例 #13
0
        /// <summary>
        /// Update the extent parameters according to the map.extent parameters.
        /// </summary>
        private void UpdateExtentValues()
        {
            if (comboBoxUnits.SelectedItem != null)
                mapunits = (MS_UNITS)comboBoxUnits.SelectedItem;
            else
                mapunits = map.units;

            unitPrecision = MapUtils.GetUnitPrecision(mapunits);
            textBoxX.Text = Convert.ToString(Math.Round((map.extent.maxx + map.extent.minx) / 2, unitPrecision));
            textBoxY.Text = Convert.ToString(Math.Round((map.extent.maxy + map.extent.miny) / 2, unitPrecision));
            labelUnit2.Text = MapUtils.GetUnitName(mapunits);
            textBoxScale.Text = Convert.ToString(Convert.ToInt64(map.scaledenom));

            unitPrecision = MapUtils.GetUnitPrecision(mapunits);
            labelUnit1.Text = MapUtils.GetUnitName(mapunits);

            double zoom = (map.extent.maxx - map.extent.minx);
            if (mapunits != map.units)
                zoom = zoom * MapUtils.InchesPerUnit(map.units) / MapUtils.InchesPerUnit(mapunits);

            textBoxZoomWidth.Text = Convert.ToString(Math.Round(zoom, unitPrecision));
        }