Exemple #1
0
        private void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            string[] draggedPaths = (string[])e.Data.GetData(DataFormats.FileDrop);
            if ((draggedPaths != null) && (draggedPaths.Length > 0))
            {
                filesWithoutIndex.Clear();
                addedFiles.Clear();

                foreach (string draggedPath in draggedPaths)
                {
                    if (draggedPath.EndsWith(".shp", StringComparison.OrdinalIgnoreCase) && File.Exists(draggedPath))
                    {
                        AddShapeFileFeatureLayers(new string[] { draggedPath });
                    }
                    else if (ExplorerHelper.IsRasterLayerFile(draggedPath) && File.Exists(draggedPath))
                    {
                        AddRasterLayers(new string[] { draggedPath });
                    }
                    else if (Directory.Exists(draggedPath))
                    {
                        AddLayersByFolder(draggedPath);
                    }
                }

                if (filesWithoutIndex.Count > 0)
                {
                    CancelAddingLayer();
                }

                SetCurrentExtent();

                themeView.SetupItems();
                DrawImage();
            }
        }
Exemple #2
0
        private void AddLayersByFolder(string folderName)
        {
            string[] fileNames = Directory.GetFiles(folderName, "*.*", SearchOption.AllDirectories);

            Collection <string> rasterFilenames  = new Collection <string>();
            Collection <string> featureFilenames = new Collection <string>();

            foreach (string filename in fileNames)
            {
                if (ExplorerHelper.IsRasterLayerFile(filename))
                {
                    rasterFilenames.Add(filename);
                }
                else if (filename.ToUpperInvariant().Contains(".SHP"))
                {
                    featureFilenames.Add(filename);
                }
            }

            AddShapeFileFeatureLayers(featureFilenames);
            AddRasterLayers(rasterFilenames);
        }
Exemple #3
0
        // use OpenFileDialog
        private void AddLayersByOpenFileDialog()
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                filesWithoutIndex.Clear();
                addedFiles.Clear();

                Collection <string> rasterFilenames  = new Collection <string>();
                Collection <string> featureFilenames = new Collection <string>();

                foreach (string filename in openFileDialog.FileNames)
                {
                    if (ExplorerHelper.IsRasterLayerFile(filename))
                    {
                        rasterFilenames.Add(filename);
                    }
                    else
                    {
                        featureFilenames.Add(filename);
                    }
                }

                AddShapeFileFeatureLayers(featureFilenames);
                AddRasterLayers(rasterFilenames);

                if (filesWithoutIndex.Count > 0)
                {
                    CancelAddingLayer();
                }

                SetCurrentExtent();

                themeView.SetupItems();

                DrawImage();
            }
        }