private void SaveShapeFile() { SaveFileDialog SFDlg = new SaveFileDialog(); SFDlg.Filter = "Shape File (*.shp)|*.shp"; if (SFDlg.ShowDialog() == DialogResult.OK) { //ProgressBar toolStripProgressBar1.Visible = true; this.Cursor = Cursors.WaitCursor; string aFile = SFDlg.FileName; //Create a VectorLayer with selected shapes int i, j; VectorLayer aLayer = new VectorLayer(_currentLayer.ShapeType); for (i = 0; i < _currentLayer.NumFields; i++) { aLayer.EditAddField(_currentLayer.Fields[i].ColumnName, _currentLayer.Fields[i].DataType); } bool hasSelShape = _currentLayer.HasSelectedShapes(); for (i = 0; i < _currentLayer.ShapeNum; i++) { Shape aPS = _currentLayer.ShapeList[i]; if (hasSelShape) { if (!aPS.Selected) { continue; } } int sNum = aLayer.ShapeNum; if (aLayer.EditInsertShape(aPS, sNum)) { for (j = 0; j < aLayer.NumFields; j++) { aLayer.EditCellValue(j, sNum, _currentLayer.GetCellValue(j, i)); } } Application.DoEvents(); this.toolStripProgressBar1.Value = (i + 1) * 100 / _currentLayer.ShapeNum; } aLayer.ProjInfo = _currentLayer.ProjInfo; aLayer.SaveFile(aFile); //Progressbar this.toolStripProgressBar1.Value = 0; this.toolStripProgressBar1.Visible = false; this.Cursor = Cursors.Default; } }
private void AddCharts() { if (CLB_Fields.CheckedItems.Count < 1) { return; } VectorLayer aLayer = (VectorLayer)_mapLayer; aLayer.ChartSet.ChartType = (ChartTypes)Enum.Parse(typeof(ChartTypes), CB_ChartType.Text); List <string> fieldNames = new List <string>(); int i, j; for (i = 0; i < CLB_Fields.CheckedItems.Count; i++) { fieldNames.Add(CLB_Fields.CheckedItems[i].ToString()); } aLayer.ChartSet.FieldNames = fieldNames; aLayer.ChartSet.LegendScheme = legendView_Chart.LegendScheme; aLayer.ChartSet.MinSize = int.Parse(TB_MinSize.Text); aLayer.ChartSet.MaxSize = int.Parse(TB_MaxSize.Text); aLayer.ChartSet.BarWidth = int.Parse(TB_BarWidth.Text); aLayer.ChartSet.XShift = int.Parse(TB_XShift.Text); aLayer.ChartSet.YShift = int.Parse(TB_YShift.Text); aLayer.ChartSet.AvoidCollision = CHB_Collision.Checked; aLayer.ChartSet.AlignType = (AlignType)Enum.Parse(typeof(AlignType), CB_Align.Text); aLayer.ChartSet.View3D = CHB_View3D.Checked; aLayer.ChartSet.Thickness = int.Parse(TB_Thickness.Text); List <List <float> > values = new List <List <float> >(); List <float> minList = new List <float>(); List <float> maxList = new List <float>(); List <float> sumList = new List <float>(); for (i = 0; i < aLayer.ShapeNum; i++) { List <float> vList = new List <float>(); float sum = 0; float v; for (j = 0; j < fieldNames.Count; j++) { v = float.Parse(aLayer.GetCellValue(fieldNames[j], i).ToString()); vList.Add(v); sum += v; } values.Add(vList); minList.Add(vList.Min()); maxList.Add(vList.Max()); sumList.Add(sum); } switch (aLayer.ChartSet.ChartType) { case ChartTypes.BarChart: aLayer.ChartSet.MinValue = minList.Min(); aLayer.ChartSet.MaxValue = maxList.Max(); break; case ChartTypes.PieChart: aLayer.ChartSet.MinValue = sumList.Min(); aLayer.ChartSet.MaxValue = sumList.Max(); break; } aLayer.AddCharts(); }