protected virtual void OnErrorSelection(ErrorSelectionEventArgs e) { if (ErrorSelection != null) { // Invokes the delegates. ErrorSelection(this, e); } }
private void _form_ErrorSelection(object sender, ErrorSelectionEventArgs e) { IMap theMap = this.Extension.FocusMap; try { this._selectedErrors = null; bool bNeedsRefesh = false; if (this._extraFeedback != null) { bNeedsRefesh = true; IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theMap); theGCont.DeleteElement(this._extraFeedback); this._extraFeedback = null; } if (e.SelectedIDs != null) { this._selectedErrors = new dao.QAError[e.SelectedIDs.Length]; for (int i = 0; i < this._selectedErrors.Length; i++) { this._selectedErrors[i] = this.Extension.QAManager.FindQAError(e.SelectedIDs[i]); } } // We're manipulating the map selection, stop listening to events for a moment try { this._bIgnoreSelectionEvents = true; IFeatureSelection theFSel = (IFeatureSelection)this.ErrorLayer; if (this._selectedErrors != null && this._selectedErrors.Length > 0) { bNeedsRefesh = true; IQueryFilter theQF = new QueryFilterClass(); theQF.WhereClause = "OBJECTID in (" + this._selectedErrors[0].ObjectID; for (int i = 1; i < this._selectedErrors.Length && i < 100; i++) { theQF.WhereClause += ", " + this._selectedErrors[i].ObjectID; } theQF.WhereClause += ")"; theFSel.SelectFeatures(theQF, esriSelectionResultEnum.esriSelectionResultNew, false); Application.DoEvents(); } else if (theFSel.SelectionSet.Count > 0) { bNeedsRefesh = true; IQueryFilter theQF = new QueryFilterClass(); theQF.WhereClause = "OBJECTID < 0"; theFSel.SelectFeatures(theQF, esriSelectionResultEnum.esriSelectionResultNew, false); Application.DoEvents(); } } finally { this._bIgnoreSelectionEvents = false; } if (this._selectedErrors != null && this._selectedErrors.Length == 1) { this._form.SetDetailError(this._selectedErrors[0]); // Put a graphic on the map ExtendedInfo theInfo = new ExtendedInfo(); theInfo.ReadXML(this._selectedErrors[0].Error.ExtendedData); double x1 = double.NaN; double y1 = double.NaN; double x2 = double.NaN; double y2 = double.NaN; Hashtable theProperties = theInfo.Properties; foreach (object key in theProperties.Keys) { string strkey = key.ToString().ToUpper(); if (strkey.Equals("FROM POINT X")) x1 = Convert.ToDouble(theProperties[key]); else if (strkey.Equals("FROM POINT Y")) y1 = Convert.ToDouble(theProperties[key]); else if (strkey.Equals("TO POINT X")) x2 = Convert.ToDouble(theProperties[key]); else if (strkey.Equals("TO POINT Y")) y2 = Convert.ToDouble(theProperties[key]); } if (!double.IsNaN(x1) && !double.IsNaN(y1) && !double.IsNaN(x2) && !double.IsNaN(y2)) { bNeedsRefesh = true; IPoint p1 = new PointClass(); p1.PutCoords(x1, y1); p1.Project(this.GeographicReference); IPoint p2 = new PointClass(); p2.PutCoords(x2, y2); p2.Project(this.GeographicReference); object theMissing = Type.Missing; IPolyline thePolyline = new PolylineClass(); thePolyline.Project(this.GeographicReference); ((IPointCollection)thePolyline).AddPoint(p1, ref theMissing, ref theMissing); ((IPointCollection)thePolyline).AddPoint(p2, ref theMissing, ref theMissing); thePolyline.Project(theMap.SpatialReference); IElement theElement = new LineElementClass(); theElement.Geometry = (IGeometry)thePolyline; ILineSymbol theSym = (ILineSymbol)util.GraphicsHelper.get_SimpleLineSymbol( util.GraphicsHelper.get_RgbColor(255, 0, 0), 2, esriSimpleLineStyle.esriSLSSolid); ((ILineElement)theElement).Symbol = theSym; IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theMap); theGCont.AddElement(theElement, 0); this._extraFeedback = theElement; } } else this._form.SetDetailError(null); if (bNeedsRefesh) { IActiveView theAV = (IActiveView)this.Extension.FocusMap; theAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, theAV.Extent); theAV.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, theAV.Extent); } } catch (Exception ex) { util.Logger.Write("Exception caught listening to selection change events: " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); } finally { Marshal.ReleaseComObject(theMap); } }