private void SaveBLNMapFile() { SaveFileDialog SFDlg = new SaveFileDialog(); SFDlg.Filter = "BLN File (*.bln)|*.bln"; if (SFDlg.ShowDialog() == DialogResult.OK) { //ProgressBar toolStripProgressBar1.Visible = true; toolStripProgressBar1.Style = ProgressBarStyle.Marquee; this.Cursor = Cursors.WaitCursor; string aFile = SFDlg.FileName; List <Shape> shapes = new List <Shape>(); bool hasSelShape = _currentLayer.HasSelectedShapes(); for (int i = 0; i < _currentLayer.ShapeNum; i++) { Shape aShape = _currentLayer.ShapeList[i]; if (hasSelShape) { if (!aShape.Selected) { continue; } } shapes.Add(aShape); } MapDataManage.WriteMapFile_BLN(aFile, shapes); //Progressbar this.toolStripProgressBar1.Style = ProgressBarStyle.Blocks; this.toolStripProgressBar1.Value = 0; this.toolStripProgressBar1.Visible = false; this.Cursor = Cursors.Default; } }
private void SaveGrADSMapFile() { SaveFileDialog SFDlg = new SaveFileDialog(); //SFDlg.Filter = "wmp File (*.wmp)|*.wmp"; if (SFDlg.ShowDialog() == DialogResult.OK) { //ProgressBar toolStripProgressBar1.Visible = true; this.Cursor = Cursors.WaitCursor; string aFile = SFDlg.FileName; bool hasSelShape = _currentLayer.HasSelectedShapes(); int shpNum = _currentLayer.ShapeNum; if (hasSelShape) { shpNum = _currentLayer.GetSelectedShapeIndexes().Count; } int i; switch (_currentLayer.ShapeType) { case ShapeTypes.Polyline: List <PolylineShape> polylines = new List <PolylineShape>(); PolylineShape aPLS = new PolylineShape(); for (i = 0; i < _currentLayer.ShapeNum; i++) { aPLS = (PolylineShape)_currentLayer.ShapeList[i]; if (hasSelShape) { if (!aPLS.Selected) { continue; } } if (frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.Projection.IsLonLatMap) { if (aPLS.Extent.minX < 0 && aPLS.Extent.maxX > 0) { polylines.AddRange(frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.Projection.CutPolyLineShapeLon(0, aPLS)); } else { polylines.Add(aPLS); } } else { polylines.Add(aPLS); } Application.DoEvents(); this.toolStripProgressBar1.Value = (i + 1) * 100 / _currentLayer.ShapeNum; } MapDataManage.WriteMapFile_GrADS(aFile, polylines); break; case ShapeTypes.Polygon: List <PolygonShape> polygons = new List <PolygonShape>(); PolygonShape aPGS = new PolygonShape(); for (i = 0; i < _currentLayer.ShapeNum; i++) { aPGS = (PolygonShape)_currentLayer.ShapeList[i]; if (hasSelShape) { if (!aPGS.Selected) { continue; } } if (frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.Projection.IsLonLatMap) { if (aPGS.Extent.minX < 0 && aPGS.Extent.maxX > 0) { polygons.AddRange(frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.Projection.CutPolygonShapeLon(0, aPGS)); } else { polygons.Add(aPGS); } } else { polygons.Add(aPGS); } Application.DoEvents(); this.toolStripProgressBar1.Value = (i + 1) * 100 / _currentLayer.ShapeNum; } MapDataManage.WriteMapFile_GrADS(aFile, polygons); break; } //Progressbar this.toolStripProgressBar1.Value = 0; this.toolStripProgressBar1.Visible = false; this.Cursor = Cursors.Default; } }
private void B_OpenMapFile_Click(object sender, EventArgs e) { string aFile; if (RB_DefaultFolder.Checked) { if (LB_MapFiles.SelectedIndex < 0) { MessageBox.Show("Please select one map file!", "Error"); return; } else { aFile = Application.StartupPath + "\\Map\\" + LB_MapFiles.SelectedItem.ToString(); if (!File.Exists(aFile)) { aFile = Application.StartupPath + "/Map/" + LB_MapFiles.SelectedItem.ToString(); } } } else { OpenFileDialog aDlg = new OpenFileDialog(); aDlg.Filter = "Supported Formats|*.shp;*.wmp;*.bln;*.bmp;*.gif;*.jpg;*.tif;*.png|Shape File (*.shp)|*.shp|WMP File (*.wmp)|*.wmp|BLN File (*.bln)|*.bln|" + "Bitmap Image (*.bmp)|*.bmp|Gif Image (*.gif)|*.gif|Jpeg Image (*.jpg)|*.jpg|Tif Image (*.tif)|*.tif|Png Iamge (*.png)|*.png|All Files (*.*)|*.*"; if (aDlg.ShowDialog() == DialogResult.OK) { aFile = aDlg.FileName; } else { return; } } MapLayer aLayer = MapDataManage.OpenLayer(aFile); if (aLayer != null) { ////Set projection //if (Path.GetExtension(aLayer.LayerName).ToLower() != ".shp") // aLayer.ProjInfo = frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.Projection.ProjInfo; //Remove map layers if (CB_RemoveMaps.Checked) { frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.RemoveMapLayers(); } //Add layer if (aLayer.LayerType == LayerTypes.VectorLayer) { if (aLayer.ShapeType == ShapeTypes.Polygon) { frmMain.CurrentWin.MapDocument.ActiveMapFrame.InsertPolygonLayer((VectorLayer)aLayer); } else if (aLayer.ShapeType == ShapeTypes.Polyline) { frmMain.CurrentWin.MapDocument.ActiveMapFrame.InsertPolylineLayer((VectorLayer)aLayer); } else { frmMain.CurrentWin.MapDocument.ActiveMapFrame.AddLayer(aLayer); } } else { frmMain.CurrentWin.MapDocument.ActiveMapFrame.InsertImageLayer((ImageLayer)aLayer); } } }