Esempio n. 1
0
        public DialogResult OpenFileDialog()
        {
            string         filename = "";
            OpenFileDialog ofd      = new OpenFileDialog
            {
                Title            = "Open a GIS layer",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };
            var initialDirectory = RegistryTools.GetSetting("FAD3", "LastOpenedLayerDirectory", "");

            if (initialDirectory.ToString().Length > 0)
            {
                ofd.InitialDirectory = initialDirectory.ToString();
            }

            ofd.Filter = "ESRI Shapefile (shp)|*.shp|" +
                         "KML files (kml)|*.kml|" +
                         "Georeferenced raster files (jpg, tiff,bmp)|*.jpg;*.tif;*.tiff;*.bmp|" +
                         "Other files |*.*)";
            ofd.FilterIndex = 1;

            DialogResult dr = ofd.ShowDialog();

            if (dr == DialogResult.OK && ofd.FileName.Length > 0)
            {
                filename = ofd.FileName;

                var(success, errMsg) = _mapLayersHandler.FileOpenHandler(filename);
                if (!success)
                {
                    MessageBox.Show(errMsg, "Error in opening file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dr = DialogResult.Cancel;
                }
            }
            return(dr);
        }