Exemple #1
0
        private void dgvAttTable_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                int           intSelCounts = dgvAttTable.SelectedRows.Count;
                IFeatureLayer pFLayer      = m_pLayer as IFeatureLayer;
                if (intSelCounts == 0)
                {
                    m_pSnippet.ClearSelectedMapFeatures(m_pActiveView, pFLayer);
                }
                else//Brushing on Map
                {
                    for (int i = 0; i < intSelCounts; i++)
                    {
                        string value1 = dgvAttTable.SelectedRows[i].Cells[0].Value.ToString();


                        string whereClause = "FID =" + value1;

                        if (m_pActiveView == null || pFLayer == null || whereClause == null || value1 == "")
                        {
                            return;
                        }
                        ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                        // Set up the query
                        ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                        queryFilter.WhereClause = whereClause;

                        // Invalidate only the selection cache. Flag the original selection
                        m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                        // Perform the selection
                        if (i == 0)
                        {
                            featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);
                        }
                        else
                        {
                            featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultAdd, false);
                        }
                    }
                    // Flag the new selection
                    m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(pFLayer, this.Handle);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Exemple #2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_pForm = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;
            FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms;
            IActiveView    pActiveView     = m_pForm.axMapControl1.ActiveView;

            clsSnippet pSnippet = new clsSnippet();

            //Using IRubberband
            IEnvelope pEnvelop = pSnippet.DrawRectangle(pActiveView);

            if (pEnvelop.IsEmpty)
            {
                int    x      = X;
                int    y      = Y;
                IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);


                double Tol_x = x / int.MaxValue;
                double Tol_y = y / int.MaxValue;
                pEnvelop = pPoint.Envelope;
                pEnvelop.Expand(Tol_x, Tol_y, false);
            }

            ISpatialFilter pSpatialFilter = new SpatialFilterClass();

            pSpatialFilter.Geometry   = pEnvelop;
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
            {
                ILayer pLayer = m_pForm.axMapControl1.get_Layer(i);

                IFeatureLayer pFLayer = (IFeatureLayer)pLayer;

                if (pFLayer.Visible)
                {
                    //Brushing to Mapcontrol
                    string ShapeFieldName = pFLayer.FeatureClass.ShapeFieldName;
                    pSpatialFilter.GeometryField = pFLayer.FeatureClass.ShapeFieldName;
                    BrushingOnMapControl(pSpatialFilter, pActiveView, pFLayer);
                    m_pBL.BrushingToOthers(pFLayer, m_pForm.Handle);
                }
            }
            pActiveView.GraphicsContainer.DeleteAllElements();
            pActiveView.Refresh();
        }
Exemple #3
0
        void MapCntrls_OnSelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (blnBrushingFromMapControl)
                {
                    return;
                }

                AxMapControl FocusedMapCntrl = (AxMapControl)sender;
                //MessageBox.Show(FocusedMapCntrl.Name);
                IMapControl3      pFocusedMapContrl = (IMapControl3)FocusedMapCntrl.Object;
                IFeatureLayer     pSelFlayer        = (IFeatureLayer)pFocusedMapContrl.ActiveView.FocusMap.get_Layer(0);
                IFeatureSelection pSelSet           = (IFeatureSelection)pSelFlayer;

                if (pSelSet.SelectionSet.Count > 0)
                {
                    int intMapCntrlCnt = this.m_axMapControls.Length;
                    for (int i = 0; i < intMapCntrlCnt; i++)
                    {
                        //AxMapControl MapCntrl = this.m_axMapControls[i].Object;
                        IMapControl3 pMapCntrl = (IMapControl3)this.m_axMapControls[i].Object;

                        if (pMapCntrl != pFocusedMapContrl)
                        {
                            pMapCntrl.ActiveView.FocusMap.ClearSelection();
                            pMapCntrl.ActiveView.Refresh();
                        }
                    }
                }

                FeatureSelectionOnActiveView(m_pActiveView, pFLayer, pSelSet.SelectionSet);
                m_pBL.BrushingToOthers(pFLayer, this.Handle);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Exemple #4
0
        private void pChart_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                m_pActiveView.GraphicsContainer.DeleteAllElements();
                //Export the chart to an image file
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    conMenu.Show(pChart, e.X, e.Y);
                    return;
                }

                //Clear previous selection
                int intLastSeriesIdx = pChart.Series.Count - 1;

                //Remove Previous Selection
                if (pChart.Series[intLastSeriesIdx].Name == "SelPoints")
                {
                    pChart.Series.RemoveAt(intLastSeriesIdx);
                }


                HitTestResult result = pChart.HitTest(e.X, e.Y);

                int dblOriPtsSize = pChart.Series[0].MarkerSize;
                _canDraw = false;

                System.Drawing.Color pMarkerColor = System.Drawing.Color.Cyan;
                var seriesPts = new System.Windows.Forms.DataVisualization.Charting.Series
                {
                    Name              = "SelPoints",
                    Color             = pMarkerColor,
                    BorderColor       = pMarkerColor,
                    IsVisibleInLegend = false,
                    IsXValueIndexed   = false,
                    ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point,
                    MarkerStyle       = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle,
                    MarkerSize        = dblOriPtsSize * 2
                };

                pChart.Series.Add(seriesPts);

                StringBuilder plotCommmand = new StringBuilder();

                for (int i = 0; i < pChart.Series[0].Points.Count; i++)
                {
                    int intX = (int)pChart.ChartAreas[0].AxisX.ValueToPixelPosition(pChart.Series[0].Points[i].XValue);
                    int intY = (int)pChart.ChartAreas[0].AxisY.ValueToPixelPosition(pChart.Series[0].Points[i].YValues[0]);

                    System.Drawing.Point SelPts = new System.Drawing.Point(intX, intY);

                    if (_rect.Contains(SelPts))
                    {
                        int intValueIdx = arrFID[i];
                        int index       = result.PointIndex;
                        seriesPts.Points.AddXY(pChart.Series[0].Points[i].XValue, pChart.Series[0].Points[i].YValues[0]);
                        //plotCommmand.Append("(" + strVarNM + " = " + arrVar[i].ToString() + ") Or ");
                        plotCommmand.Append("(" + strFIDNM + " = " + intValueIdx.ToString() + ") Or ");

                        DrawLineOnActiveView(intValueIdx, m_NBIDs[intValueIdx], m_arrXYCoord, m_pActiveView);
                    }
                }

                //Brushing on ArcView
                if (plotCommmand.Length > 3)
                {
                    plotCommmand.Remove(plotCommmand.Length - 3, 3);
                    string whereClause = plotCommmand.ToString();
                    m_pBL.FeatureSelectionOnActiveView(whereClause, m_pActiveView, m_pFLayer);
                }
                else
                {
                    IFeatureSelection featureSelection = (IFeatureSelection)m_pFLayer;
                    m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                    featureSelection.Clear();
                    //m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                    m_pActiveView.Refresh();
                }
                //Brushing to other graphs //The Function should be locatated after MapView Brushing
                m_pBL.BrushingToOthers(m_pFLayer, this.Handle);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
        private void pChart_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                HitTestResult result = pChart.HitTest(e.X, e.Y);

                int intLastSeriesIdx = pChart.Series.Count - 1;

                //Remove Previous Selection
                if (pChart.Series[intLastSeriesIdx].Name == "SelSeries")
                {
                    pChart.Series.RemoveAt(intLastSeriesIdx);
                }

                if (result.ChartElementType == ChartElementType.DataPoint)
                {
                    //Brushing on Graph
                    int index = result.PointIndex;

                    double dblYValue    = pChart.Series[0].Points[index].YValues[0] + pChart.Series[1].Points[index].YValues[0];
                    double dblSelYValue = pChart.Series[0].Points[index].YValues[0] + pChart.Series[1].Points[index].YValues[0] + pChart.Series[2].Points[index].YValues[0];

                    double dblXvalue = pChart.Series[1].Points[index].XValue;

                    var Selseries1 = new System.Windows.Forms.DataVisualization.Charting.Series
                    {
                        Name              = "SelSeries",
                        Color             = System.Drawing.Color.Cyan,
                        BorderColor       = System.Drawing.Color.Black,
                        IsVisibleInLegend = false,
                        //BackHatchStyle = ChartHatchStyle.DiagonalCross,
                        ChartType = SeriesChartType.Column,
                    };
                    pChart.Series.Add(Selseries1);
                    Selseries1.Points.AddXY(dblXvalue, dblSelYValue);

                    string whereClause = strValueFldName + " = " + dblYValue.ToString();

                    //Brushing to ActiveView
                    m_pBL.FeatureSelectionOnActiveView(whereClause, m_pActiveView, m_pFLayer);

                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(m_pFLayer, this.Handle);
                }
                else
                {
                    //Clear Selection Both Histogram and ActiveView
                    //Remove Previous Selection
                    intLastSeriesIdx = pChart.Series.Count - 1;
                    if (pChart.Series[intLastSeriesIdx].Name == "SelSeries")
                    {
                        pChart.Series.RemoveAt(intLastSeriesIdx);
                    }
                    IFeatureSelection featureSelection = (IFeatureSelection)m_pFLayer;
                    m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                    featureSelection.Clear();
                    m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(m_pFLayer, this.Handle);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.Handle.ToString() + " Error:" + ex.Message);
                return;
            }
        }
Exemple #6
0
        private void pChart_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                pActiveView.GraphicsContainer.DeleteAllElements();

                //Export the chart to an image file
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    conMenu.Show(pChart, e.X, e.Y);
                    return;
                }

                HitTestResult result = pChart.HitTest(e.X, e.Y);

                //Remove Previous Selection
                if (pChart.Series.Count == 2)
                {
                    pChart.Series.RemoveAt(1);
                    pChart.Series.RemoveAt(0);

                    var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
                    {
                        Name              = "Series1",
                        Color             = System.Drawing.Color.White,
                        BorderColor       = System.Drawing.Color.Black,
                        IsVisibleInLegend = false,
                        IsXValueIndexed   = true,
                        ChartType         = SeriesChartType.Column,
                    };

                    pChart.Series.Add(series1);

                    int intNBins = vecMids.Length;

                    for (int j = 0; j < intNBins; j++)
                    {
                        series1.Points.AddXY(vecMids[j], vecCounts[j]);
                    }
                    pChart.Series[0]["PointWidth"] = "1";
                }

                if (result.ChartElementType == ChartElementType.DataPoint)
                {
                    //Brushing on histogram
                    int index = result.PointIndex;

                    for (int i = 0; i < pChart.Series[0].Points.Count; i++)
                    {
                        if (i == index)
                        {
                            pChart.Series[0].Points[i].Color = System.Drawing.Color.Cyan;
                        }
                        else
                        {
                            pChart.Series[0].Points[i].Color = System.Drawing.Color.White;
                        }
                    }

                    string whereClause = strFieldName + " > " + dblBreaks[index].ToString() + " And " + strFieldName + " <= " + dblBreaks[index + 1].ToString();

                    //Brushing to ActiveView
                    FeatureSelectionOnActiveView(whereClause, pActiveView, pFLayer);

                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(pFLayer, this.Handle);
                }
                else
                {
                    //Clear Selection Both Histogram and ActiveView
                    for (int i = 0; i < pChart.Series[0].Points.Count; i++)
                    {
                        pChart.Series[0].Points[i].Color = System.Drawing.Color.White;
                    }
                    IFeatureSelection featureSelection = (IFeatureSelection)pFLayer;
                    pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                    featureSelection.Clear();
                    //pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                    pActiveView.Refresh();
                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(pFLayer, this.Handle);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }