コード例 #1
0
ファイル: FormMapBox.Designer.cs プロジェクト: cugkgq/Project
        private void lvwDecorations_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvwDecorations.SelectedItems.Count == 0)
            {
                pgMapDecoration.SelectedObject = null;
                return;
            }

            var lvwi = (ListViewItem)lvwDecorations.SelectedItems[0];

            if (!lvwi.Checked)
            {
                pgMapDecoration.SelectedObject = null;
                pgMapDecoration.Visible        = false;
                return;
            }

            Type mdType;

            if (MapDecorationTypes.TryGetValue(lvwi.Text, out mdType))
            {
                foreach (IMapDecoration mapDecoration in mapBox1.Map.Decorations)
                {
                    if (mapDecoration.GetType().Equals(mdType))
                    {
                        pgMapDecoration.SelectedObject = mapDecoration;
                        pgMapDecoration.Visible        = true;
                        return;
                    }
                }
            }
            pgMapDecoration.SelectedObject = null;
            pgMapDecoration.Visible        = false;
        }
コード例 #2
0
ファイル: FormMapBox.Designer.cs プロジェクト: cugkgq/Project
        private void lvwDecorations_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            Type mdType;

            if (!MapDecorationTypes.TryGetValue(e.Item.Text, out mdType))
            {
                return;
            }

            if (e.Item.Checked)
            {
                IMapDecoration ins = Activator.CreateInstance(mdType) as IMapDecoration;
                if (ins != null)
                {
                    mapBox1.Map.Decorations.Add(ins);
                }
            }
            else
            {
                foreach (var item in mapBox1.Map.Decorations)
                {
                    var mdTmpType = item.GetType();
                    if (mdType.Equals(mdTmpType))
                    {
                        mapBox1.Map.Decorations.Remove(item);
                        break;
                    }
                }
            }
            e.Item.Selected = true;
            mapBox1.Refresh();
        }
コード例 #3
0
        private void radioButton2_MouseUp(object sender, MouseEventArgs e)
        {
            var rb = sender as RadioButton;

            if (rb == null)
            {
                return;
            }

            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            SharpMap.Map map = null;
            switch (rb.Name)
            {
            case "radioButton2":     // ShapeFile
                map = Samples.ShapefileSample.InitializeMap(tbAngle.Value, GetOpenFileName("Shapefile|*.shp"));
                break;

            case "radioButton5":     // Ogr
                map = Samples.OgrSample.InitializeMap(tbAngle.Value, GetOpenFileName("Ogr Datasource|*.*"));
                break;

            case "radioButton6":     // Gdal
                map = Samples.GdalSample.InitializeMap(tbAngle.Value, GetOpenFileName("Gdal Datasource|*.*"));
                break;

            case "radioButton9":     // spatialite
                map = Samples.SpatiaLiteSample.InitializeMap(tbAngle.Value, GetOpenFileName("SpatiaLite 2|*.db;*.sqlite"));
                break;
            }

            if (map == null)
            {
                return;
            }


            //Add checked Map decorations
            foreach (ListViewItem checkedItem in lvwDecorations.CheckedItems)
            {
                Type mdType;
                if (MapDecorationTypes.TryGetValue(checkedItem.Text, out mdType))
                {
                    IMapDecoration md = Activator.CreateInstance(mdType) as IMapDecoration;
                    map.Decorations.Add(md);
                }
            }

            mapBox1.Map = map;
        }
コード例 #4
0
ファイル: FormMapBox.Designer.cs プロジェクト: cugkgq/Project
        private void radioButton_Click(object sender, EventArgs e)
        {
            Cursor mic = mapBox1.Cursor;

            mapBox1.Cursor = Cursors.WaitCursor;
            Cursor         = Cursors.WaitCursor;
            try
            {
                //mapImage.ActiveTool = MapImage.Tools.None;
                string text = ((RadioButton)sender).Text;

                switch (text)
                {
                case "Shapefile":
                    mapBox1.Map = ShapefileSample.InitializeMap(tbAngle.Value);
                    break;

                case "GradientTheme":
                    mapBox1.Map = GradiantThemeSample.InitializeMap(tbAngle.Value);
                    break;

                case "WFS Client":
                    mapBox1.Map = WfsSample.InitializeMap(tbAngle.Value);
                    break;

                case "WMS Client":
                    mapBox1.Map = TiledWmsSample.InitializeMap();
                    //mapBox1.Map = WmsSample.InitializeMap(tbAngle.Value);
                    break;

                case "OGR - MapInfo":
                case "OGR - S-57":
                    mapBox1.Map = OgrSample.InitializeMap(tbAngle.Value);
                    break;

                case "GDAL - GeoTiff":
                case "GDAL - '.DEM'":
                case "GDAL - '.ASC'":
                case "GDAL - '.VRT'":
                    mapBox1.Map        = GdalSample.InitializeMap(tbAngle.Value);
                    mapBox1.ActiveTool = MapBox.Tools.Pan;
                    break;

                case "TileLayer - OSM":
                case "TileLayer - OSM with XLS":
                case "TileLayer - Bing Roads":
                case "TileLayer - Bing Aerial":
                case "TileLayer - Bing Hybrid":
                case "TileLayer - GoogleMap":
                case "TileLayer - GoogleSatellite":
                case "TileLayer - GoogleTerrain":
                case "TileLayer - GoogleLabels":
                case "Eniro":
                    /*
                     * tbAngle.Visible = text.Equals("TileLayer - GoogleLabels");
                     * if (!tbAngle.Visible) tbAngle.Value = 0;
                     */
                    mapBox1.Map = TileLayerSample.InitializeMap(tbAngle.Value);
                    ((RadioButton)sender).Text = mapBox1.Map.Layers[0].LayerName;
                    break;

                case "PostGis":
                    mapBox1.Map = PostGisSample.InitializeMap(tbAngle.Value);
                    break;

                case "SpatiaLite":
                    mapBox1.Map = SpatiaLiteSample.InitializeMap(tbAngle.Value);
                    break;

                case "Oracle":
                    mapBox1.Map = OracleSample.InitializeMap(tbAngle.Value);
                    break;

                default:
                    break;
                }

                //Add checked Map decorations
                foreach (ListViewItem checkedItem in lvwDecorations.CheckedItems)
                {
                    Type mdType;
                    if (MapDecorationTypes.TryGetValue(checkedItem.Text, out mdType))
                    {
                        IMapDecoration md = Activator.CreateInstance(mdType) as IMapDecoration;
                        mapBox1.Map.Decorations.Add(md);
                    }
                }

                mapBox1.Map.Size = Size;
                mapBox1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error");
            }
            Cursor         = Cursors.Default;
            mapBox1.Cursor = mic;
        }
コード例 #5
0
        private void radioButton_Click(object sender, EventArgs e)
        {
            Cursor mic = mapBox1.Cursor;

            mapBox1.Cursor = Cursors.WaitCursor;
            Cursor         = Cursors.WaitCursor;

            if (formSqlServerOpts != null)
            {
                formSqlServerOpts.Close();
                formSqlServerOpts = null;
            }

            try
            {
                //mapImage.ActiveTool = MapImage.Tools.None;
                string text = ((RadioButton)sender).Text;

                switch (text)
                {
                case "Shapefile":
                    mapBox1.Map = ShapefileSample.InitializeMap(tbAngle.Value);
                    break;

                case "GradientTheme":
                    mapBox1.Map = GradiantThemeSample.InitializeMap(tbAngle.Value);
                    break;

                case "WFS Client":
                    mapBox1.Map = WfsSample.InitializeMap(tbAngle.Value);
                    break;

                case "WMS Client":
                    //mapBox1.Map = TiledWmsSample.InitializeMap();
                    mapBox1.Map = WmsSample.InitializeMap(tbAngle.Value);
                    break;

                case "OGR - MapInfo":
                case "OGR - S-57":
                    mapBox1.Map = OgrSample.InitializeMap(tbAngle.Value);
                    break;

                case "GDAL - GeoTiff":
                case "GDAL - '.DEM'":
                case "GDAL - '.ASC'":
                case "GDAL - '.VRT'":
                    mapBox1.Map        = GdalSample.InitializeMap(tbAngle.Value);
                    mapBox1.ActiveTool = MapBox.Tools.Pan;
                    break;

                case "TileLayer - OSM":
                case "TileLayer - OSM with XLS":
                case "TileLayer - Bing Roads":
                case "TileLayer - Bing Aerial":
                case "TileLayer - Bing Hybrid":
                case "TileLayer - GoogleMap":
                case "TileLayer - GoogleSatellite":
                case "TileLayer - GoogleTerrain":
                case "TileLayer - GoogleLabels":
                case "Eniro":
                    /*
                     * tbAngle.Visible = text.Equals("TileLayer - GoogleLabels");
                     * if (!tbAngle.Visible) tbAngle.Value = 0;
                     */
                    mapBox1.Map = TileLayerSample.InitializeMap(tbAngle.Value);
                    ((RadioButton)sender).Text           = (mapBox1.Map.BackgroundLayer.Count > 0)
                            ? ((RadioButton)sender).Text = mapBox1.Map.BackgroundLayer[0].LayerName
                            : ((RadioButton)sender).Text = mapBox1.Map.Layers[0].LayerName;
                    break;

                case "PostGis":
                    mapBox1.Map = PostGisSample.InitializeMap(tbAngle.Value);
                    break;

                case "SpatiaLite":
                    mapBox1.Map = SpatiaLiteSample.InitializeMap(tbAngle.Value);
                    break;

                case "SqlServer":
                    // create empty map with BruTile basemap
                    mapBox1.Map = SqlServerSample.InitializeMap(tbAngle.Value);
                    // check conn string
                    var connStrBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.SqlServerConnectionString);
                    if (string.IsNullOrEmpty(connStrBuilder.DataSource) || string.IsNullOrEmpty(connStrBuilder.InitialCatalog))
                    {
                        mapBox1.Refresh();

                        MessageBox.Show("Requires SqlServer connection string to be defined (Project / Settings)\n\n" +
                                        "Also, if project folder SqlServerTypes\\x64 and \\x86 are empty, then force reinstall of NuGet package:\n\n" +
                                        "PM> Update-Package Microsoft.SqlServer.Types -ProjectName Examples\\WinFormSamples -reinstall -ignoreDependencies", "Sql Server",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                        return;
                    }
                    // now show SqlServer dialog
                    formSqlServerOpts = new FormSqlServerOpts()
                    {
                        MapBox           = mapBox1,
                        ConnectionString = connStrBuilder.ToString()
                    };
                    formSqlServerOpts.Show(this);
                    break;

                case "Oracle":
                    mapBox1.Map = OracleSample.InitializeMap(tbAngle.Value);
                    break;

                case "shp_TextOnPath":
                    mapBox1.Map = TextOnPathSample.InitializeMapOrig(tbAngle.Value);
                    break;

                case "GdiImageLayer":
                    mapBox1.Map = GdiImageLayerSample.InitializeMap(tbAngle.Value);
                    break;

                default:
                    break;
                }

                //Add checked Map decorations
                foreach (ListViewItem checkedItem in lvwDecorations.CheckedItems)
                {
                    Type mdType;
                    if (MapDecorationTypes.TryGetValue(checkedItem.Text, out mdType))
                    {
                        IMapDecoration md = Activator.CreateInstance(mdType) as IMapDecoration;
                        mapBox1.Map.Decorations.Add(md);
                    }
                }

                mapBox1.Map.Size = Size;
                mapBox1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error");
            }
            Cursor         = Cursors.Default;
            mapBox1.Cursor = mic;
        }