Beispiel #1
0
        /// <summary>
        /// Prompts the user for information needed to create a new shapefile, then creates it.
        /// </summary>
        public void AddNewShapefile()
        {
            AddShapefileForm dlg = new AddShapefileForm();

            if (dlg.ShowDialog(m_globals.MapWindowForm) == System.Windows.Forms.DialogResult.OK)
            {
                MapWinGIS.Shapefile sf = new MapWinGIS.ShapefileClass();
                switch (dlg.cmbType.Text)
                {
                case "Point":
                    sf.CreateNewWithShapeID(dlg.txtFilename.Text, MapWinGIS.ShpfileType.SHP_POINT);
                    break;

                case "Line":
                    sf.CreateNewWithShapeID(dlg.txtFilename.Text, MapWinGIS.ShpfileType.SHP_POLYLINE);
                    break;

                case "Polygon":
                    sf.CreateNewWithShapeID(dlg.txtFilename.Text, MapWinGIS.ShpfileType.SHP_POLYGON);
                    break;

                default:
                    return;
                }

                sf.SaveAs(dlg.txtFilename.Text, null);
                sf.Close();
                m_globals.MapWin.Layers.Add(dlg.txtFilename.Text);
                MapWinUtility.Logger.Message("An empty shapefile has been created. Before adding shapes, make sure that your extents are set properly. To make sure extents are correct load an image, grid or shapefile that is located in the same area.", "Important Information!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.DialogResult.OK);
            }
        }