Пример #1
0
        /// <summary>
        /// Creates a new instance of the test grid form
        /// </summary>
        public TestGridForm1()
        {
            InitializeComponent();

            axMap1.Measuring.MeasuringType = tkMeasuringType.MeasureArea;

            GeoProjection pr = new GeoProjection();

            pr.SetGoogleMercator();
            Debug.Print(pr.ExportToWKT());
            axMap1.ShowVersionNumber = true;

            GridHelper.Initialize(axMap1, this);
            MapHelper.Initialize(axMap1, this);

            axMap1.TileProvider    = tkTileProvider.OpenStreetMap;
            axMap1.ShowRedrawTime  = true;
            axMap1.ScalebarVisible = true;

            cboScalebarUnits.SetEnum(typeof(tkScalebarUnits));
            cboColoring.SetEnum(typeof(ColoringType));
            cboColoringScheme.SetEnum(typeof(PredefinedColorScheme));
            cboProxyFormat.SetEnum(typeof(tkGridProxyFormat));
            cboProxyMode.SetEnum(typeof(tkGridProxyMode));
            cboCountry.SetEnum(typeof(tkKnownExtents));
            cboCoordinates.SetEnum(typeof(tkCoordinatesDisplay));
            cboZoomBehavior.SetEnum(typeof(tkZoomBehavior));

            cboActiveProxyMode.Items.Add("Proxy");
            cboActiveProxyMode.Items.Add("Direct rendering");

            InitGlobalSettings();

            cboProxyFormat.SelectedIndexChanged += (s, e) => UpdateGlobalSettings();
            cboProxyMode.SelectedIndexChanged   += (s, e) => UpdateGlobalSettings();
            udMaxSizeWoProxy.ValueChanged       += (s, e) => UpdateGlobalSettings();

            InitListbox();

            this.axMap1.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs e)
            {
                switch (e.KeyCode)
                {
                case Keys.Left:
                case Keys.Right:
                case Keys.Up:
                case Keys.Down:
                    e.IsInputKey = true;
                    return;
                }
            };

            axMap1.LayerRemoved += (s, e) => AxMap1LayersChanged(s, new EventArgs());
            axMap1.LayerAdded   += (s, e) => AxMap1LayersChanged(s, new EventArgs());

            axMap1.ScalebarVisible   = false;
            axMap1.ShowVersionNumber = false;
            axMap1.ShowRedrawTime    = false;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (App.Map.NumLayers > 0)
            {
                MessageHelper.Info("Can't change projection when there are layers on the map.");
                return;
            }

            var gp = new GeoProjection();

            if (optDefinition.Checked)
            {
                if (string.IsNullOrWhiteSpace(txtDefinition.Text))
                {
                    MessageHelper.Info("Projection string is empty");
                    return;
                }

                if (!gp.ImportFromAutoDetect(txtDefinition.Text))
                {
                    MessageHelper.Info("Failed to identify projection");
                    return;
                }
            }

            if (optEmpty.Checked)
            {
                // do nothing it's empty all right
            }

            if (optWellKnown.Checked)
            {
                if (cboWellKnown.SelectedIndex == 0)
                {
                    gp.SetWgs84();
                }

                if (cboWellKnown.SelectedIndex == 1)
                {
                    gp.SetGoogleMercator();
                }
            }

            App.Map.GeoProjection = gp;
            App.Map.Redraw();
            DialogResult = DialogResult.OK;
        }
Пример #3
0
        public static void CheckProjection()
        {
            var proj = new GeoProjection {
                GlobalCallback = callback
            };

            if (proj.SetWgs84())
            {
                if (!proj.SetGoogleMercator())
                {
                    MessageBox.Show("ERROR: failed to set projection");
                }
                else
                {
                    axMap1.GeoProjection = proj;
                    if (!proj.SetWgs84())
                    {
                        Debug.WriteLine("Failed to change projection of the map; Frozen: " + proj.IsFrozen);
                        axMap1.GeoProjection = proj.Clone();
                        if (!proj.SetWgs84())
                        {
                            MessageBox.Show("ERROR: projection is still frozen when no longer applied to map");
                        }
                        else
                        {
                            Debug.WriteLine("Projection changed; Frozen: " + proj.IsFrozen);
                            MessageBox.Show("Success");
                        }
                    }
                    else
                    {
                        MessageBox.Show("ERROR: projection of the map was changed; Frozen: " + proj.IsFrozen);
                    }
                }
            }
            else
            {
                MessageBox.Show("Failed to set WGS84 projection");
            }
        }
Пример #4
0
 public bool SetGoogleMercator()
 {
     _epsgCode = 3857;
     return(_projection.SetGoogleMercator());
 }
Пример #5
0
 public bool SetGoogleMercator()
 {
     return(_projection.SetGoogleMercator());
 }