public override void Run(object sender, EventArgs e) { DF2DPipe.Query.Frm.FrmCompoundConditionQuery dialog = new DF2DPipe.Query.Frm.FrmCompoundConditionQuery(); dialog.SetData(LogicDataStructureManage2D.Instance.RootLogicGroups, LogicDataStructureManage2D.Instance.RootMajorClasses, null); if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; this._uc = new UCPropertyInfo2D(); this._uc.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._uc); this._uc.SetPropertyInfo(dialog.Dict); }
public override void Run(object sender, EventArgs e) { Map2DCommandManager.Push(this); FrmSimpleConditionQuery dialog = new FrmSimpleConditionQuery(); if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; this._uc = new UCPropertyInfo2D(); this._uc.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._uc); this._uc.SetPropertyInfo(dialog.Dict); }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; this._dict.Clear(); m_ActiveView = app.Current2DMapControl.ActiveView; if (this.m_ActiveView.FocusMap.FeatureSelection != null) { this.m_ActiveView.FocusMap.ClearSelection(); } bool ready = false; bool haveone = false; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } app.Workbench.SetMenuEnable(true); IGeometry pGeo = null; try { if (button == 1) { WaitForm.Start("正在查询...", "请稍后"); PointClass searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } ready = true; if (ready == true) { //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) //{ IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; ISpatialFilter pSpatialFilter = new SpatialFilter(); IFeatureClass fc; DF2DFeatureClass dffc; //foreach (MajorClass mc in lg.MajorClasses) foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } if (fc == null || pGeo == null) { continue; } pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; pSpatialFilter.WhereClause = whereClause; pFeatureCursor = fc.Search(pSpatialFilter, false); if (pFeatureCursor == null) { continue; } pFeature = pFeatureCursor.NextFeature(); if (pFeature == null) { continue; } DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } DataRow dtRow = dt.NewRow(); dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = pFeature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = GetFieldValueByIndex(pFeature, index1); string str = ""; if (obj1 != null) { IField field = pFeature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); if (dt.Rows.Count > 0) { this._dict[sc.Name] = dt; } haveone = true; break; } if (haveone) { break; } } if (haveone) { break; } } } #region 查询建筑物 if (!haveone) { FacilityClass facBuild = FacilityClassManager.Instance.GetFacilityClassByName("Building"); if (facBuild != null) { haveone = HaveOne(facBuild, pGeo); } if (!haveone) { FacilityClass facStruct = FacilityClassManager.Instance.GetFacilityClassByName("Structure"); if (facStruct != null) { haveone = HaveOne(facStruct, pGeo); } } } #endregion try { if (!haveone) { WaitForm.Stop(); XtraMessageBox.Show("未选中要素,请重新选择", "提示"); return; } this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; if (this._ucPropInfo2D == null) { this._ucPropInfo2D = new UCPropertyInfo2D(); } this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._ucPropInfo2D); this._ucPropInfo2D.Init(); this._ucPropInfo2D.SetPropertyInfo(this._dict); WaitForm.Stop(); } catch { WaitForm.Stop(); } } //} } catch { WaitForm.Stop(); } finally { } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; this._dict.Clear(); bool ready = true; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } app.Workbench.SetMenuEnable(true); m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; IGeometry pGeo = null; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; //pColor = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16); IRubberBand pRubberBand; pRubberBand = new RubberLineClass(); IGeometry pLine; pLine = pRubberBand.TrackNew(m_Display, null); //IPolyline pLine = app.Current2DMapControl.TrackLine() as IPolyline; object symbol = pLineSym as object; app.Current2DMapControl.DrawShape(pLine, ref symbol); WaitForm.Start("正在查询...", "请稍后"); //if (GlobalValue.System_Selection_Environment(m_ActiveView).CombinationMethod == 0)//new selection //{ // this.m_ActiveView.FocusMap.ClearSelection(); //} pGeo = PublicFunction.DoBuffer(pLine, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } //m_ActiveView.FocusMap.SelectByShape(pGeo, GlobalValue.System_Selection_Environment(m_ActiveView), false); //if (m_ActiveView.FocusMap.SelectionCount > 0) //{ // ready = true; // m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //} //else //{ // m_ActiveView.Refresh(); //} if (ready) { //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) //{ foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } if (fc == null || pGeo == null) { continue; } ISpatialFilter pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; pSpatialFilter.WhereClause = whereClause; pFeatureCursor = fc.Search(pSpatialFilter, false); if (pFeatureCursor == null) { continue; } DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } while ((pFeature = pFeatureCursor.NextFeature()) != null) { DataRow dtRow = dt.NewRow(); dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = pFeature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = pFeature.get_Value(index1); string str = ""; if (obj1 != null) { IField field = pFeature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); } if (dt.Rows.Count > 0) { this._dict.Add(sc.Name, dt); } } } } } } WaitForm.Stop(); try { this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; if (this._ucPropInfo2D == null) { this._ucPropInfo2D = new UCPropertyInfo2D(); } this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._ucPropInfo2D); this._ucPropInfo2D.Init(); this._ucPropInfo2D.SetPropertyInfo(this._dict); } catch { } //} } catch { } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; bool ready = true; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } app.Workbench.SetMenuEnable(true); m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; ISimpleFillSymbol pFillSym = new SimpleFillSymbol(); pFillSym.Color = pColor; pFillSym.Style = esriSimpleFillStyle.esriSFSDiagonalCross; pFillSym.Outline = pLineSym; object symbol = pFillSym as object; IRubberBand band = new RubberPolygonClass(); IGeometry geo = band.TrackNew(m_Display, null); app.Current2DMapControl.DrawShape(geo, ref symbol); WaitForm.Start("正在查询...", "请稍后"); if (geo.IsEmpty) { IPoint searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); geo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); //m_ActiveView.FocusMap.SelectByShape(geo, s, false); } _geo = geo; spatialQuery = true; if (spatialQuery) { FrmCompoundConditionQuery dialog = new FrmCompoundConditionQuery(); dialog.SetData(LogicDataStructureManage2D.Instance.RootLogicGroups, LogicDataStructureManage2D.Instance.RootMajorClasses, _geo); WaitForm.Stop(); IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; mapView.UnBind(this); if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; this._uc = new UCPropertyInfo2D(); this._uc.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._uc); this._uc.SetPropertyInfo(dialog.Dict); } } } catch { this.RestoreEnv(); } }