Exemplo n.º 1
0
        public void SetDetailError(dao.QAError error)
        {
            if (error == null || error.Error == null)
            {
                this.grpDetail.Text = "Multiple or No Selection";
                this.lblLocation.Text = "";
                this.lblSeverity.Text = "";
                this.lblStatus.Text = "";
                this.txtDescription.Text = "";
                this.lvExtendedInfo.Items.Clear();
            }
            else
            {
                this.grpDetail.Text = error.Error.ErrorType + " #" + error.ObjectID;

                //ILatLonFormat theFormat = new LatLonFormatClass();
                //INumberFormat theNFormat = (INumberFormat)theFormat;
                //theFormat.ShowDirections = true;
                //theFormat.ShowZeroMinutes = true;
                //theFormat.ShowZeroSeconds = true;

                //theFormat.IsLatitude = true;
                //this.lblLocation.Text = theNFormat.ValueToString(error.Latitude);
                //theFormat.IsLatitude = false;
                //this.lblLocation.Text += " " + theNFormat.ValueToString(error.Longitude);

                this.lblLocation.Text = Math.Round(error.Latitude, 7) + ", " + Math.Round(error.Longitude, 7);

                switch (error.Error.Severity)
                {
                    case 1:
                        this.lblSeverity.Text = "High";
                        break;
                    case 2:
                        this.lblSeverity.Text = "Medium";
                        break;
                    case 3:
                        this.lblSeverity.Text = "Low";
                        break;
                    default:
                        this.lblSeverity.Text = "";
                        break;
                }
                this.lblStatus.Text = error.Error.Status;
                this.txtDescription.Text = error.Error.Description;

                this.lvExtendedInfo.Items.Clear();
                ExtendedInfo theInfo = new ExtendedInfo();
                theInfo.ReadXML(error.Error.ExtendedData);

                Hashtable theProperties = theInfo.Properties;
                foreach (object key in theProperties.Keys)
                {
                    string[] theTextByCol = new string[] {
                                                             key.ToString(),
                                                             theProperties[key].ToString()
                                                         };
                    ListViewItem theItem = new ListViewItem(theTextByCol);
                    this.lvExtendedInfo.Items.Add(theItem);
                }
            }
        }
Exemplo n.º 2
0
        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);
            }
        }