public new void Show(IWin32Window form)
        {
            base.Show(form);
            Form1 form1 = this.Owner as Form1;

            lists        = getNameAndLayer(form1.axMapControl1);
            FeatureLists = lists.Where(i => i.layer is IFeatureLayer).ToList();
            RasterLists  = lists.Where(i => i.layer is IRasterLayer).ToList();
            foreach (var control in this.Controls)
            {
                if (control is ButtonEdit)
                {
                    Console.WriteLine((control as ButtonEdit).Name);
                    var buttonEdit = control as ButtonEdit;
                    if (buttonEdit is FeatureButtonEdit)
                    {
                        (buttonEdit as FeatureButtonEdit).ButtonClick += (hander1, e1) =>
                        {
                            String        path          = OSFileAndDir.OpenFile("打开矢量图层", "Shapefile(*.shp)|*.shp");
                            IFeatureLayer pFeatureLayer = null;
                            try
                            {
                                GISdataManager.readSHP(path, ref pFeatureLayer);
                            }
                            catch { }
                            (buttonEdit as FeatureButtonEdit).Text         = path;
                            (buttonEdit as FeatureButtonEdit).featureLayer = pFeatureLayer;
                        };
                    }
                    if (buttonEdit is RasterButtonEdit)
                    {
                        (buttonEdit as RasterButtonEdit).ButtonClick += (hander1, e1) =>
                        {
                            String       path         = OSFileAndDir.OpenFile("打开栅格图层", "TIFF(*.tif)|*.tif|IMAGE(*.img)|img");
                            IRasterLayer pRasterLayer = null;
                            try
                            {
                                GISdataManager.readRaster(path, ref pRasterLayer);
                            }
                            catch { }
                            (buttonEdit as RasterButtonEdit).Text        = path;
                            (buttonEdit as RasterButtonEdit).rasterLayer = pRasterLayer;
                        };
                    }
                    if (buttonEdit is SaveButtonEdit)
                    {
                        (buttonEdit as SaveButtonEdit).ButtonClick += (hander1, e1) =>
                        {
                            String path = OSFileAndDir.SaveFile("保存图层", "ShapeFile(*.shp)|*.shp|TIFF(*.tif)|*.tif|IMAGE(*.img)|img");
                            (buttonEdit as SaveButtonEdit).Text = path;
                        };
                    }
                    buttonEdit.Click += showPopup;
                    buttonEdit.Click += showPopup;
                }
            }
            this.Click += hidePopup;
        }
Exemple #2
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)//打开栅格或矢量数据
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "shapefile文件|*.shp|TIFF格式文件|*.tif|IMAGING Image|*.img";
            openFileDialog.Multiselect = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (var name in openFileDialog.FileNames)
                {
                    if (name.Split('.')[1] == "shp")
                    {
                        IFeatureLayer pFeaturelayer = null;
                        try
                        {
                            GISdataManager.readSHP(name, ref pFeaturelayer);
                            axMapControl1.AddLayer(pFeaturelayer as ILayer, 0);
                        }
                        catch
                        {
                            XtraMessageBox.Show(string.Format("读取{0}图层失败", name));
                        }
                    }
                    else
                    {
                        IRasterLayer pRasterLayer = null;
                        try
                        {
                            GISdataManager.readRaster(name, ref pRasterLayer);
                            axMapControl1.AddLayer(pRasterLayer as ILayer, 0);
                        }
                        catch {
                            XtraMessageBox.Show(string.Format("读取{0}图层失败", name));
                        }
                    }
                }
            }
        }