예제 #1
0
        private void ApplyExtent()
        {
            double deltaX  = (map.extent.maxx - map.extent.minx) * zoomFactor / 2;
            double deltaY  = (map.extent.maxy - map.extent.miny) * zoomFactor / 2;
            double centerX = double.Parse(textBoxX.Text);
            double centerY = double.Parse(textBoxY.Text);

            map.setExtent(centerX - deltaX, centerY - deltaY, centerX + deltaX, centerY + deltaY);
            if (textBoxRotation.Text != "")
            {
                map.setRotation(double.Parse(textBoxRotation.Text));
            }

            if (target != null)
            {
                target.RaisePropertyChanged(this);
            }

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

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

            if (target != null)
            {
                target.RaiseZoomChanged(this, Math.Round(zoom, unitPrecision), map.scaledenom);
            }

            zoomFactor = 1.0;
        }
예제 #2
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));
        }
예제 #3
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);
        }
예제 #4
0
        /// <summary>
        /// Validating event handler of the textBoxZoomWidth control.
        /// </summary>
        /// <param name="sender">The source object of this event.</param>
        /// <param name="e">The event parameters.</param>
        private void textBoxZoomWidth_Validating(object sender, CancelEventArgs e)
        {
            double result;

            if (!double.TryParse(((TextBoxBase)sender).Text, out result) || result <= 0)
            {
                MessageBox.Show("Invalid zoom width or wrong number", "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.Cancel = true;
                return;
            }

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

            zoomFactor        = result / (map.extent.maxx - map.extent.minx);
            textBoxScale.Text = Convert.ToString(Convert.ToInt32(map.scaledenom * zoomFactor));
        }
예제 #5
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));
        }
예제 #6
0
        /// <summary>
        /// Validating event handler of the textBoxScale control.
        /// </summary>
        /// <param name="sender">The source object of this event.</param>
        /// <param name="e">The event parameters.</param>
        private void textBoxScale_Validating(object sender, CancelEventArgs e)
        {
            double result;

            if (!double.TryParse(((TextBoxBase)sender).Text, out result) || result <= 0)
            {
                MessageBox.Show("Invalid scale or wrong number", "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.Cancel = true;
                return;
            }
            zoomFactor = result / map.scaledenom;

            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) * zoomFactor, unitPrecision));
        }
예제 #7
0
        /// <summary>
        /// Click event handler of the buttonApply control.
        /// </summary>
        /// <param name="sender">The source object of this event.</param>
        /// <param name="e">The event parameters.</param>
        private void buttonApply_Click(object sender, EventArgs e)
        {
            double deltaX  = (map.extent.maxx - map.extent.minx) * zoomFactor / 2;
            double deltaY  = (map.extent.maxy - map.extent.miny) * zoomFactor / 2;
            double centerX = double.Parse(textBoxX.Text);
            double centerY = double.Parse(textBoxY.Text);

            map.setExtent(centerX - deltaX, centerY - deltaY, centerX + deltaX, centerY + deltaY);

            target.RaisePropertyChanged(this);

            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);

            zoomFactor = 1.0;
        }