private void ConMapControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { try { m_pActiveView.GraphicsContainer.DeleteAllElements(); IFeatureSelection featureSelection = (IFeatureSelection)m_pFLayer; m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null); featureSelection.Clear(); m_pActiveView.Refresh(); int x = e.x; int y = e.y; IPoint pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); int intFID = FindFeatureFID(pPoint, m_pFLayer, m_dblTolerance); if (intFID == -1) { return; } string whereClause = m_strFieldName + " = " + intFID.ToString(); m_pBL.FeatureSelectionOnActiveView(whereClause, m_pActiveView, m_pFLayer); int intNCount = Def_SWM.NBIDs[intFID].Count; StringBuilder sbStatusLabel = new StringBuilder(); sbStatusLabel.Append("The feature (ID:" + intFID.ToString() + ") has " + intNCount.ToString() + " neighbors: "); if (intNCount == 1 && Def_SWM.NBIDs[intFID][0] == 0) { return; } DrawLineOnActiveView(intFID, Def_SWM.NBIDs[intFID], Def_SWM.XYCoord, m_pActiveView); for (int i = 0; i < intNCount; i++) { sbStatusLabel.Append(Def_SWM.NBIDs[intFID][i].ToString() + ", "); } if (sbStatusLabel.Length > 3) { sbStatusLabel.Remove(sbStatusLabel.Length - 2, 2); } toolStripStatusLabel1.Text = sbStatusLabel.ToString(); statusStrip1.Refresh(); } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }
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; } }
private void pChart_MouseUp(object sender, MouseEventArgs e) { try { //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; } } int intSelectedValue = Convert.ToInt32(dblBreaks[index]); //var SelectedFIDs = DefSWM.NeighborCounts.Select(x => x == intSelectedValue); int[] SelectedFIDs = DefSWM.NeighborCounts.Select((b, i) => b == intSelectedValue ? i : -1).Where(i => i != -1).ToArray(); StringBuilder whereClause = new StringBuilder(); for (int i = 0; i < SelectedFIDs.Length; i++) { whereClause.Append("(" + m_strFieldName + " = " + DefSWM.FIDs[SelectedFIDs[i]].ToString() + ") Or "); } //Brushing on ArcView if (whereClause.Length > 3) { whereClause.Remove(whereClause.Length - 3, 3); m_pBL.FeatureSelectionOnActiveView(whereClause.ToString(), pActiveView, pFLayer); } } 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); } //Brushing to ActiveView //FeatureSelectionOnActiveView(whereClause, pActiveView, pFLayer); //Brushing to other graphs // m_pBL.BrushingToOthers(pFLayer, this.Handle); } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }