private BoundingBox updatedExtent(BoundingBox currentExtent, BoundingBox footprintExtent)
        {
            double xmax = currentExtent.Maxx;
            double xmin = currentExtent.Minx;
            double ymin = currentExtent.Miny;
            double ymax = currentExtent.Maxy;

            double bxmax = footprintExtent.Maxx;
            double bxmin = footprintExtent.Minx;
            double bymin = footprintExtent.Miny;
            double bymax = footprintExtent.Maxy;
            double rxmax = 0.0, rxmin = 0.0, rymax = 0.0, rymin = 0.0;
            if (xmax > bxmax) {
                rxmax = xmax;
            }
            else {
                rxmax = bxmax;
            }
            if (xmin < bxmin) {
                rxmin = xmin;
            }
            else {
                rxmin = bxmin;
            }
            if (ymax > bymax) {
                rymax = ymax;
            }
            else {
                rymax = bymax;
            }
            if (ymin < bymin) {
                rymin = ymin;
            }
            else {
                rymin = bymin;
            }
            BoundingBox newExtent = new BoundingBox();
            newExtent.Maxx = rxmax;
            newExtent.Maxy = rymax;
            newExtent.Minx = rxmin;
            newExtent.Miny = rymin;

            return newExtent;
        }
        /// <summary>
        /// Event handler for "Show All Footprint" button click event
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void showAllFootprint_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                IMxDocument mxDoc;
                mxDoc = (IMxDocument)m_application.Document;

                IGraphicsContainer graphicsContainer;
                graphicsContainer = (IGraphicsContainer)mxDoc.FocusMap;
                BoundingBox currentExtent = new BoundingBox();
                currentExtent.Maxx = mxDoc.ActiveView.Extent.XMax;
                currentExtent.Minx = mxDoc.ActiveView.Extent.XMin;
                currentExtent.Maxy = mxDoc.ActiveView.Extent.YMax;
                currentExtent.Miny = mxDoc.ActiveView.Extent.YMin;
                BoundingBox newExtent = currentExtent;
                if (showAll)
                {
                    showAll = false;
                    System.Windows.Forms.ToolTip toolTipForshowAll = new System.Windows.Forms.ToolTip();
                    toolTipForshowAll.SetToolTip(showAllFootprintToolStripButton, StringResources.hideAllFootprintTooltip);
                    //showAllFootprintToolStripButton = StringResources.hideAllFootprintTooltip;
                    showAllFootprintToolStripButton.Image = StringResources.hideAll;
                    foreach (Object obj in resultsListBox.Items)
                    {
                        currentExtent = newExtent;
                        CswRecord record = (CswRecord)obj;
                        if (record.BoundingBox.Maxx != NONEXSISTANTNUMBER)
                        {
                            drawfootprint(record, true, false);
                            newExtent = updatedExtent(currentExtent, record.BoundingBox);
                        }
                    }
                    IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
                    point.PutCoords(newExtent.Minx, newExtent.Maxy);

                    IPoint point1 = new ESRI.ArcGIS.Geometry.PointClass();
                    point1.PutCoords(newExtent.Maxx, newExtent.Maxy);

                    IPoint point2 = new ESRI.ArcGIS.Geometry.PointClass();
                    point2.PutCoords(newExtent.Maxx, newExtent.Miny);

                    IPoint point3 = new ESRI.ArcGIS.Geometry.PointClass();
                    point3.PutCoords(newExtent.Minx, newExtent.Miny);

                    IPointCollection pointCollection;
                    pointCollection = new ESRI.ArcGIS.Geometry.PolygonClass();

                    object x = Type.Missing;
                    object y = Type.Missing;

                    pointCollection.AddPoint(point, ref x, ref y);
                    pointCollection.AddPoint(point1, ref x, ref y);
                    pointCollection.AddPoint(point2, ref x, ref y);
                    pointCollection.AddPoint(point3, ref x, ref y);

                    PolygonElementClass element = new PolygonElementClass();
                    element.Geometry = (IGeometry)pointCollection;

                    graphicsContainer = (IGraphicsContainer)mxDoc.FocusMap;
                    mxDoc.ActiveView.Extent = element.Geometry.Envelope;
                    mxDoc.ActiveView.Refresh();
                }
                else
                {
                    showAll = true;
                    System.Windows.Forms.ToolTip toolTipForshowAll = new System.Windows.Forms.ToolTip();
                    toolTipForshowAll.SetToolTip(showAllFootprintToolStripButton, StringResources.showAllFootPrintToolTip);
                    showAllFootprintToolStripButton.Image = StringResources.showAll;
                    deleteelements();

                }
                mxDoc.ActiveView.Refresh();
            }
            catch (Exception ex)
            {

                ShowErrorMessageBox(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
        /// <summary>
        /// Event handler for "Display Footprint" button click event
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>  
        private void displayFootprinttoolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                CswRecord record = (CswRecord)(resultsListBox.SelectedItem);
                drawfootprint(record, false, false);
                //add the graphics element to the map
                IMxDocument mxDoc;
                mxDoc = (IMxDocument)m_application.Document;

                IGraphicsContainer graphicsContainer;
                graphicsContainer = (IGraphicsContainer)mxDoc.FocusMap;
                BoundingBox currentExtent = new BoundingBox();
                currentExtent.Maxx = mxDoc.ActiveView.Extent.XMax;
                currentExtent.Minx = mxDoc.ActiveView.Extent.XMin;
                currentExtent.Maxy = mxDoc.ActiveView.Extent.YMax;
                currentExtent.Miny = mxDoc.ActiveView.Extent.YMin;
                BoundingBox newExtent = updatedExtent(currentExtent, record.BoundingBox);

                IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
                point.PutCoords(newExtent.Minx, newExtent.Maxy);

                IPoint point1 = new ESRI.ArcGIS.Geometry.PointClass();
                point1.PutCoords(newExtent.Maxx, newExtent.Maxy);

                IPoint point2 = new ESRI.ArcGIS.Geometry.PointClass();
                point2.PutCoords(newExtent.Maxx, newExtent.Miny);

                IPoint point3 = new ESRI.ArcGIS.Geometry.PointClass();

                point3.PutCoords(newExtent.Minx, newExtent.Miny);

                IPointCollection pointCollection;
                pointCollection = new ESRI.ArcGIS.Geometry.PolygonClass();

                object x = Type.Missing;
                object y = Type.Missing;
                pointCollection.AddPoint(point, ref x, ref y);
                pointCollection.AddPoint(point1, ref x, ref y);
                pointCollection.AddPoint(point2, ref x, ref y);
                pointCollection.AddPoint(point3, ref x, ref y);
                PolygonElementClass element = new PolygonElementClass();
                element.Geometry = (IGeometry)pointCollection;
                graphicsContainer = (IGraphicsContainer)mxDoc.FocusMap;
                mxDoc.ActiveView.Extent = element.Geometry.Envelope;
                mxDoc.ActiveView.Refresh();
            }
            catch (Exception ex)
            {

                ShowErrorMessageBox(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #4
0
 /// <summary>
 /// Constructor        
 /// </summary>
 /// <param name="sid">record identifier</param>
 /// <param name="stitle">record title</param>
 /// <param name="sabstract">record abstract</param>
 public CswRecord(string sid, string stitle, string sabstract)
 {
     ID = sid;
     Abstract = sabstract;
     Title = stitle;
     boundingBox = new BoundingBox();
 }
Example #5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public CswRecord()
 {
     boundingBox = new BoundingBox();
 }
Example #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="sid">record identifier</param>
 public CswRecord(string sid)
 {
     ID = sid;
     boundingBox = new BoundingBox();
 }