public void AddFeatureToListView(CodeCell.AgileMap.Core.Feature fet) { ListViewItem it = fet.ToListViewItem(); if (it != null) { it.Tag = fet; listView1.Items.Add(it); } }
private CodeCell.AgileMap.Core.Feature ToFeature(int[] aoi, CodeCell.AgileMap.Core.Shape shape, string[] fieldNames) { string[] fieldValues = new string[fieldNames.Length]; fieldValues[0] = OID.ToString(); fieldValues[1] = aoi.Length.ToString(); fieldValues[2] = StatArea(aoi).ToString("0.##"); CodeCell.AgileMap.Core.Feature fet = new CodeCell.AgileMap.Core.Feature(OID, shape, fieldNames, fieldValues, null); OID++; return(fet); }
private CodeCell.AgileMap.Core.Feature ToFeature(Shape shape, double[] statAreas) { string[] fieldValues = new string[_fieldNames.Length]; fieldValues[0] = OID.ToString(); for (int i = 0; i < statAreas.Length; i++) { fieldValues[i + 1] = statAreas[i].ToString("0.###"); } CodeCell.AgileMap.Core.Feature fet = new CodeCell.AgileMap.Core.Feature(OID, shape, _fieldNames, fieldValues, null); OID++; return(fet); }
public static ListViewItem ToListViewItem(this CodeCell.AgileMap.Core.Feature fet) { string[] values = fet.FieldValues; if (values == null || values.Length == 0) { return(null); } ListViewItem it = new ListViewItem(values[0]); for (int i = 1; i < values.Length; i++) { it.SubItems.Add(values[i]); } return(it); }
private void StatFilterAreas() { ICurrentRasterInteractiver inter = _session.SmartWindowManager.ActiveCanvasViewer as ICurrentRasterInteractiver; if (inter != null) { inter.StartAOIDrawing(GetPencilType(), (aoi, shape) => { string layerName = "System:StatArea"; ILabelLayer lyr = GetLabelLayer((_activeViewer as ICurrentRasterInteractiver), layerName, _fieldNames); if (lyr != null) { Dictionary <string, double> areas = StatArea(aoi, _filters); _layerName = layerName; //ApplyColor(lyr); //lyr.LabelDef.Fieldname = "面积(平方公里)"; ApplyColor(lyr); lyr.LabelDef.Fieldname = _fieldNames[1]; lyr.LabelDef.EnableLabeling = true; CodeCell.AgileMap.Core.Feature fet = null; try { fet = ToFeature(shape, areas.Values.ToArray()); } catch (Exception ex) { _session.PrintMessage(ex); } if (fet != null) { lyr.AddFeature(fet); AddFeatureToListView(fet); } } }); } }
private void SataSimpleArea() { string[] lstViewfieldNames = new string[] { "名称", "像元个数", "面积(平方公里)" }; string[] fieldNames = new string[] { "name", "pixelcount", "area" }; UpdateHeadersOfListView(lstViewfieldNames); ICurrentRasterInteractiver inter = _activeViewer as ICurrentRasterInteractiver; if (inter != null) { //inter inter.StartAOIDrawing(GetPencilType(), (aoi, shape) => { string layerName = "System:StatArea"; ILabelLayer lyr = GetLabelLayer((_activeViewer as ICurrentRasterInteractiver), layerName, fieldNames); if (lyr != null) { _layerName = layerName; ApplyColor(lyr); lyr.LabelDef.Fieldname = "area"; CodeCell.AgileMap.Core.Feature fet = null; try { fet = ToFeature(aoi, shape, fieldNames); } catch (Exception ex) { _session.PrintMessage(ex); } if (fet != null) { lyr.AddFeature(fet); AddFeatureToListView(fet); } } }); } }
public void Render(bool enableDisplayLevel, QuickTransformArgs quickTransformArgs, IGrid gd, Graphics g, Envelope rect, RepeatFeatureRecorder recorder) { if (g == null) { return; } _currentFeatureRects.Clear(); List <Feature> features = gd.VectorFeatures; if (features == null || features.Count == 0) { return; } _quickTransformArgs = quickTransformArgs; int fetCount = features.Count; Feature feature = null; IOutsideIndicator outsideIndicator = null; bool isfullInside = (gd as Grid)._isfullInternal; for (int i = 0; i < fetCount; i++) { feature = features[i]; if (feature == null || feature.Geometry == null) { continue; } outsideIndicator = feature.OutsideIndicator;// (feature as ISupportOutsideIndicator).OutsideIndicator; //判断是否在该级别显示 if (enableDisplayLevel && feature.DisplayLevel != -1) { if (feature.DisplayLevel > _environment.CurrentLevel) { outsideIndicator.SetOutside(true); continue; } } //可见性计算 if (!isfullInside) { if (feature.Geometry is ShapePoint) { outsideIndicator.SetOutside(!IsPointInCurrentExtent(feature, rect)); } else //Polyline,Polygon { outsideIndicator.SetOutside(!IsPolygonInCurrentExtent(feature, rect)); } if (outsideIndicator.IsOutside) { continue; } } else//整个网格都在可视区域内部 { outsideIndicator.SetOutside(false); } //是否已经在其他网格绘制过了 if (feature.IsRepeatedOverGrids) { if (recorder.IsRendered(feature.OID)) { continue; } else { recorder.AddRenderedOID(feature.OID); } } //为要素设置绘制符号 SetCurrentSymbolFromFeature(feature); if (_currentSymbol == null) { continue; } //为符号设置角度 SetAngleOfSymbol(feature); //画几何形状 try { if (feature.Geometry is ShapePoint) { PointF pt = ShapePoint2PixelPoint(feature.Geometry as ShapePoint); //位置冲突检测 if (_environment != null) { IConflictor conflictorForSymbol = _environment.ConflictorForSymbol; if (conflictorForSymbol != null && conflictorForSymbol.Enabled) { //符号冲突 if (conflictorForSymbol.IsConflicted(pt.X - _currentSymbol.SymbolHalfWidth, pt.Y - _currentSymbol.SymbolHalfHeight, _currentSymbol.SymbolSize)) { outsideIndicator.SetOutside(true); continue; } } } //画符号 DrawPointUseCurrentSymbol(g, pt); //记下要素符号矩形区域 _currentFeatureRects.Add(feature, new RectangleF((_currentSymbol as IMarkerSymbol).PixelLocation, _currentSymbol.SymbolSize)); //符号不冲突,在标注冲突检测网格中占位 #region debug //符号矩形 //PointF tpt = new PointF((pt.X - _currentSymbol.SymbolSize.Width / 2f), // (pt.Y - _currentSymbol.SymbolSize.Height / 2f)); //(_environment.ConflictorForLabel as PixelConflictor).DrawTestRectangleF(tpt, _currentSymbol.SymbolSize, Color.Yellow); #endregion if (_environment != null) { if (_environment.ConflictorForLabel != null && _environment.ConflictorForLabel.Enabled) { _environment.ConflictorForLabel.HoldPosition((pt.X - _currentSymbol.SymbolSize.Width / 2f), (pt.Y - _currentSymbol.SymbolSize.Height / 2f), _currentSymbol.SymbolSize); } } } else //Polyline,Polygon { SetGraphicsPathFromGeometry(feature.Geometry); if (_path.PointCount > 0) { DrawPathUseCurrentSymbol(g); _currentFeatureRects.Add(feature, RectangleF.Empty); } } } catch (Exception ex) { Log.WriterException("BaseFeatureRenderer", "Render(Layer:" + (_name != null ?_name : string.Empty) + ",OID:" + feature.OID.ToString() + ")", ex); } finally { _currentSymbol.Angle = 0; } } }
protected abstract void SetCurrentSymbolFromFeature(Feature feature);