private void LineConSelectCallback(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (logPntArr.Count > 1) { AnyLine line = new AnyLine(); Arc arc = new Arc(); arc.Dots = new Dot_2D[logPntArr.Count]; for (int i = 0; i < logPntArr.Count; i++) { arc.Dots[i] = new Dot_2D() { x = logPntArr[i].X, y = logPntArr[i].Y }; } line.Arcs = new Arc[1] { arc }; if (m_catalog.ActiveMapDoc != null && m_catalog.ActiveMapDoc.Display) { m_mapDocConditionInput.SelectionType = SelectionType.Both; m_mapDocConditionInput.QueryGeoObj = line; m_mapDocConditionInput.Show(); } if (m_catalog.ActiveLayerObj != null && m_catalog.ActiveLayerObj.Display) { m_layerConditionInput.SelectionType = SelectionType.Both; m_layerConditionInput.QueryGeoObj = line; m_layerConditionInput.Show(); } } }
/// <summary> /// 添加线 /// </summary> /// <param name="gLayer">GraphicsLayer图层对象</param> /// <param name="graphics">绘图对象</param> /// <param name="logPntArr">绘图保存的逻辑坐标数组</param> public void AddLine(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (ActiveMapDoc != null && logPntArr.Count > 0) { if (ActiveMapDoc.ActiveLayerIndex < 0) { MessageBox.Show("请激活文档的一个线图层", "提示", MessageBoxButton.OK); return; } SFclsGeomType type = ActiveMapDoc.ActiveLayerGeoType; if (!type.Equals(SFclsGeomType.Lin)) { MessageBox.Show("当前图层不能添加该几何类型的要素", "提示", MessageBoxButton.OK); return; } AnyLine line = new AnyLine(); line.Arcs = new Arc[1]; Arc arc = new Arc(); arc.Dots = new Dot_2D[logPntArr.Count]; for (int i = 0; i < logPntArr.Count; i++) { arc.Dots[i] = new Dot_2D() { x = logPntArr[i].X, y = logPntArr[i].Y }; } line.Arcs[0] = arc; m_targetGeo = line; GetActiveLayerAttStruct(); } }
public bool AppendFromFile(string FileName, int CharSet) { if (FileName == null) { return(false); } if (FileName.Length == 0) { return(false); } try { HFile = new System.IO.StreamReader(FileName, System.Text.Encoding.GetEncoding(CharSet)); string AnyLine; do { AnyLine = ((System.IO.StreamReader)HFile).ReadLine(); if (AnyLine != null) { if (AnyLine.Trim().Length > 2) { if (AnyLine.Trim().Substring(0, 1) != ";") { Add(AnyLine); } } } } while (!(AnyLine == null)); ((System.IO.StreamReader)HFile).Close(); HFile = null; } catch (System.Exception Excpt) { Err.Add(Excpt); return(false); } return(true); }
/// <summary> /// 添加线 /// </summary> /// <param name="gLayer">GraphicsLayer图层对象</param> /// <param name="graphics">绘图对象</param> /// <param name="logPntArr">绘图保存的逻辑坐标数组</param> public void AddLine(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (ActiveLayerObj != null && logPntArr.Count > 0) { if (ActiveLayerObj.ActiveGdbIndex < 0 || ActiveLayerObj.ActiveLayerIndex < 0) { MessageBox.Show("请激活矢量图层的一个线图层", "提示", MessageBoxButton.OK); return; } AnyLine line = new AnyLine(); line.Arcs = new Arc[1]; Arc arc = new Arc(); arc.Dots = new Dot_2D[logPntArr.Count]; for (int i = 0; i < logPntArr.Count; i++) { arc.Dots[i] = new Dot_2D() { x = logPntArr[i].X, y = logPntArr[i].Y }; } line.Arcs[0] = arc; m_targetGeo = line; CSetLayerIndex setIdx = new CSetLayerIndex(); setIdx.GdbIndex = ActiveLayerObj.ActiveGdbIndex; setIdx.LayerIndex = ActiveLayerObj.ActiveLayerIndex; ActiveLayerObj.GetGeomType(setIdx, new UploadStringCompletedEventHandler(CheckLineType)); } }
private static List <Point> GetLogPnts(AnyLine lines) { AnyLine _tmp = lines; List <Point> logPnts = new List <Point>(); Point _p; Dot_2D _dot; for (int i = 0; i < _tmp.Arcs.Length; i++) { for (int j = 0; j < _tmp.Arcs[i].Dots.Length; j++) { _dot = new Dot_2D(); _dot = _tmp.Arcs[i].Dots[j]; _p = new Point(_dot.x, _dot.y); logPnts.Add(_p); } } return(logPnts); }
/// <summary> /// 线查询 /// </summary> /// <param name="gLayer"></param> /// <param name="graphics"></param> /// <param name="logPntArr"></param> public void LineSelect(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (logPntArr.Count > 1) { AnyLine line = new AnyLine(); Arc arc = new Arc(); arc.Dots = new Dot_2D[logPntArr.Count]; for (int i = 0; i < logPntArr.Count; i++) { arc.Dots[i] = new Dot_2D() { x = logPntArr[i].X, y = logPntArr[i].Y }; } line.Arcs = new Arc[1] { arc }; Select(line, SelectionType.SpatialRange); } }
public IMSPolygon drawGetFeature(SFeatureGeometry sfeatureTemp) { GRegion reg = sfeatureTemp.RegGeom[0]; AnyLine arcLine = reg.Rings[0]; Arc arc = arcLine.Arcs[0]; //获取要素边界的点 Dot_2D[] Arcpnts = arc.Dots; int arcpntNum = Arcpnts.Length; //绘制多边形 IMSPolygon poly = new IMSPolygon(CoordinateType.Logic); m_gpLayer.AddGraphics(poly); for (int i = 0; i < arcpntNum; i++) { poly.Points.Add(new Point(arc.Dots[i].x, arc.Dots[i].y)); } poly.Draw(); return(poly); }
/// <summary> /// 线查询回调 /// </summary> private void LineSelect(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { //获取线坐标 if (logPntArr.Count > 1) { AnyLine line = new AnyLine(); Arc arc = new Arc(); arc.Dots = new Dot_2D[logPntArr.Count]; for (int i = 0; i < logPntArr.Count; i++) { arc.Dots[i] = new Dot_2D() { x = logPntArr[i].X, y = logPntArr[i].Y }; } line.Arcs = new Arc[1] { arc }; this.select(line, SelectionType.Both); } }
private void LineConSelectCallback(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (logPntArr.Count > 1) { AnyLine line = new AnyLine(); Arc arc = new Arc(); arc.Dots = new Dot_2D[logPntArr.Count]; for (int i = 0; i < logPntArr.Count; i++) { arc.Dots[i] = new Dot_2D() { x = logPntArr[i].X, y = logPntArr[i].Y }; } line.Arcs = new Arc[1] { arc }; m_conditionInput.SelectionType = SelectionType.Both; m_conditionInput.QueryGeoObj = line; m_conditionInput.Show(); } }
/// <summary> /// 获取要素信息 /// </summary> /// <returns></returns> private CMapFeatureInfo GetMapFeatureInfo() { CMapFeatureInfo fInfo = new CMapFeatureInfo(); SFeature sf = new SFeature(); sf.AttValue = new string[m_attStruct.FldNumber]; for (int i = 0; i < m_attStruct.FldNumber; i++) { sf.AttValue[i] = m_textBoxArr[i].Text; switch (this.m_attStruct.FldType[i]) { case "double": case "integer": case "long": case "short": if (!CommFun.IsNumber(sf.AttValue[i])) { MessageBox.Show("字段【Fld_" + this.m_attStruct.FldName[i] + "】输入的数据格式不正确。请重新输入!", "提示", MessageBoxButton.OK); return(null); } break; } } SFeatureGeometry sfGeo = null; SFclsGeomType curFGeoType; if (m_targetGeo != null) { sfGeo = m_targetGeo as SFeatureGeometry; if (sfGeo == null) //add feature { sfGeo = new SFeatureGeometry(); switch ((m_targetGeo as IWebGeometry).GetGeomType()) { case WebGeomType.Point: sf.ftype = SFclsGeomType.Pnt; GPoint pnt = new GPoint(); pnt.Dot = m_targetGeo as Dot_2D; sfGeo.PntGeom = new GPoint[] { pnt }; break; case WebGeomType.Line: sf.ftype = SFclsGeomType.Lin; GLine line = new GLine(); line.Line = m_targetGeo as AnyLine; sfGeo.LinGeom = new GLine[] { line }; break; case WebGeomType.Polygon: sf.ftype = SFclsGeomType.Reg; GRegion polygon = new GRegion(); AnyLine circle = new AnyLine(); circle.Arcs = new Arc[1]; circle.Arcs[0] = new Arc(); circle.Arcs[0].Dots = (m_targetGeo as ZDIMS.BaseLib.Polygon).Dots; polygon.Rings = new AnyLine[] { circle }; sfGeo.RegGeom = new GRegion[] { polygon }; break; default: sfGeo = null; break; } } } curFGeoType = ActiveMapDoc.ActiveLayerGeoType; if (this.m_featureStyle == null) { this.m_featureStyle = new WebGraphicsInfo(); } this.m_style.Update(); switch (curFGeoType) { case SFclsGeomType.Pnt: this.m_featureStyle.InfoType = GInfoType.PntInfo; PointStyle newPntStyle = this.m_style as PointStyle; this.m_featureStyle.PntInfo = new CPointInfo(); if (newPntStyle.patternAngle.Text == "") { this.m_featureStyle.PntInfo.Angle = 0.0; } else { this.m_featureStyle.PntInfo.Angle = Convert.ToDouble(newPntStyle.patternAngle.Text); } if (newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.PntInfo.Color = 0; } else { this.m_featureStyle.PntInfo.Color = Convert.ToInt32(newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0]); } if (newPntStyle.patternHeight.Text == "") { this.m_featureStyle.PntInfo.SymHeight = 0.0; } else { this.m_featureStyle.PntInfo.SymHeight = Convert.ToDouble(newPntStyle.patternHeight.Text); } if (newPntStyle.patternID._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.PntInfo.SymID = 0; } else { this.m_featureStyle.PntInfo.SymID = Convert.ToInt32(newPntStyle.patternID._TextBoxInput.Text.Split(':')[0]); } if (newPntStyle.patternWidth.Text == "") { this.m_featureStyle.PntInfo.SymWidth = 0.0; } else { this.m_featureStyle.PntInfo.SymWidth = Convert.ToDouble(newPntStyle.patternWidth.Text); } break; case SFclsGeomType.Lin: this.m_featureStyle.InfoType = GInfoType.LinInfo; LineStyle newLineStyle = this.m_style as LineStyle; this.m_featureStyle.LinInfo = new CLineInfo(); if (newLineStyle.color._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.LinInfo.Color = 0; } else { this.m_featureStyle.LinInfo.Color = Convert.ToInt32(newLineStyle.color._TextBoxInput.Text.Split(':')[0]); } if (newLineStyle.patternID._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.LinInfo.LinStyleID = 0; } else { this.m_featureStyle.LinInfo.LinStyleID = Convert.ToInt32(newLineStyle.patternID._TextBoxInput.Text.Split(':')[0]); } if (newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.LinInfo.LinStyleID2 = 0; } else { this.m_featureStyle.LinInfo.LinStyleID2 = Convert.ToInt32(newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0]); } if (newLineStyle.penWidth.Text == "") { this.m_featureStyle.LinInfo.LinWidth = 0.0; } else { this.m_featureStyle.LinInfo.LinWidth = Convert.ToDouble(newLineStyle.penWidth.Text); } if (newLineStyle.lineScaleX.Text == "") { this.m_featureStyle.LinInfo.Xscale = 0.0; } else { this.m_featureStyle.LinInfo.Xscale = Convert.ToDouble(newLineStyle.lineScaleX.Text); } if (newLineStyle.lineScaleY.Text == "") { this.m_featureStyle.LinInfo.Yscale = 0.0; } else { this.m_featureStyle.LinInfo.Yscale = Convert.ToDouble(newLineStyle.lineScaleY.Text); } break; case SFclsGeomType.Reg: this.m_featureStyle.InfoType = GInfoType.RegInfo; PolygonStyle newRegStyle = this.m_style as PolygonStyle; this.m_featureStyle.RegInfo = new CRegionInfo(); if (newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.RegInfo.FillColor = 0; } else { this.m_featureStyle.RegInfo.FillColor = Convert.ToInt32(newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0]); } if (newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.RegInfo.PatColor = 0; } else { this.m_featureStyle.RegInfo.PatColor = Convert.ToInt32(newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0]); } if (newRegStyle.patternHeight.Text == "") { this.m_featureStyle.RegInfo.PatHeight = 0.0; } else { this.m_featureStyle.RegInfo.PatHeight = Convert.ToDouble(newRegStyle.patternHeight.Text); } if (newRegStyle.patternID._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.RegInfo.PatID = 0; } else { this.m_featureStyle.RegInfo.PatID = Convert.ToInt32(newRegStyle.patternID._TextBoxInput.Text.Split(':')[0]); } if (newRegStyle.patternPenWidth.Text == "") { this.m_featureStyle.RegInfo.OutPenWidth = 0.0; } else { this.m_featureStyle.RegInfo.OutPenWidth = Convert.ToDouble(newRegStyle.patternPenWidth.Text); } if (newRegStyle.patternWidth.Text == "") { this.m_featureStyle.RegInfo.PatWidth = 0.0; } else { this.m_featureStyle.RegInfo.PatWidth = Convert.ToDouble(newRegStyle.patternWidth.Text); } break; } sf.fGeom = sfGeo; sf.FID = m_featureID; fInfo.GInfo = this.m_featureStyle; fInfo.FSet = sf; fInfo.LayerIndex = ActiveMapDoc.ActiveLayerIndex; fInfo.MapName = new COpenMap(); fInfo.MapName.MapName = new string[] { ActiveMapDoc.MapDocName }; return(fInfo); }