Пример #1
0
        private void pChart_MouseUp(object sender, MouseEventArgs e)
        {
            System.Windows.Forms.DataVisualization.Charting.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 == System.Windows.Forms.DataVisualization.Charting.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 = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column,
                };
                pChart.Series.Add(Selseries1);
                Selseries1.Points.AddXY(dblXvalue, dblSelYValue);

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

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

                //Brushing to other graphs
                pSnippet.BrushingToOthers(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)pFLayer;
                pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                featureSelection.Clear();
                pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                //Brushing to other graphs
                pSnippet.BrushingToOthers(pFLayer, this.Handle);
            }
        }
Пример #2
0
		public ToolTipEventArgs (int x, int y, string text, HitTestResult result)
		{
			X = x;
			Y = y;
			Text = text;
			HitTestResult = result;
		}
Пример #3
0
 void colChart_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     hitTest = colChart.HitTest(e.X, e.Y);
     if (hitTest.ChartElementType == ChartElementType.DataPoint)
     {
         DataPoint point = hitTest.Object as DataPoint;
         point.IsValueShownAsLabel = true;
         point.BackHatchStyle      = ChartHatchStyle.Percent25;
     }
 }
Пример #4
0
        void chart_ForSystemStdDev_GetToolTipText(object sender, ToolTipEventArgs e)
        {
            System.Windows.Forms.DataVisualization.Charting.HitTestResult Result = new System.Windows.Forms.DataVisualization.Charting.HitTestResult();

            Result = chart_ForSystemStdDev.HitTest(e.X, e.Y);
            Series sr = Result.Series;

            if (Result.PointIndex < 0)
            {
                return;
            }
            if (sr != null)
            {
                e.Text = string.Format("第{0}道:{1}", sr.Name, sr.Points[Result.PointIndex].YValues[0]);
            }
            ////Result.Series;// 就是点击获得的Series
            ////Result.Series.Points[Result.PointIndex].XValue;// 为点击Series X坐标
            ////Result.Series.Points[Result.PointIndex].YValue;// 为点击Series
        }
Пример #5
0
        public static void tooltip_graph_display(System.Windows.Forms.ToolTip t, System.Windows.Forms.MouseEventArgs e, Chart c, System.Drawing.Point?p)
        {
            t.RemoveAll();
            System.Drawing.Point pos = e.Location;
            if (p.HasValue && pos == p.Value)
            {
                return;
            }

            System.Windows.Forms.DataVisualization.Charting.HitTestResult[] results = new System.Windows.Forms.DataVisualization.Charting.HitTestResult[4];

            try
            {
                results = c.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);

                foreach (System.Windows.Forms.DataVisualization.Charting.HitTestResult result in results)
                {
                    if (result.ChartElementType == ChartElementType.DataPoint)
                    {
                        DataPoint prop = result.Object as DataPoint;
                        if (prop != null)
                        {
                            double pointXPixel = result.ChartArea.AxisX.ValueToPixelPosition(prop.XValue);
                            double pointYPixel = result.ChartArea.AxisY.ValueToPixelPosition(prop.YValues[0]);

                            // check if the cursor is really close to the point (2 pixels around the point)
                            if (Math.Abs(pos.X - pointXPixel) < 2) //&& Math.Abs(pos.Y - pointYPixel) < 2)
                            {
                                t.Show("X=" + prop.XValue + ", Y=" + prop.YValues[0], c, pos.X, pos.Y - 15);
                            }
                        }
                    }
                }
            }
            catch
            { }
        }
        /// <summary>
        /// Mouse moved in the control.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        internal void OnMouseMove(MouseEventArgs e)
        {
            // Check if in annotation placement mode
            if (this.placingAnnotation != null)
            {
                System.Windows.Forms.Cursor newCursor = this.Chart.Cursor;
                if (this.placingAnnotation.IsValidPlacementPosition(e.X, e.Y))
                {
                    newCursor = Cursors.Cross;
                }
                else
                {
                    newCursor = this.Chart.defaultCursor;
                }

                // Set current chart cursor
                if (newCursor != this.Chart.Cursor)
                {
                    System.Windows.Forms.Cursor tmpCursor = this.Chart.defaultCursor;
                    this.Chart.Cursor        = newCursor;
                    this.Chart.defaultCursor = tmpCursor;
                }

                this.placingAnnotation.PlacementMouseMove(new PointF(e.X, e.Y));

                return;
            }

            // Check if currently resizing/moving annotation
            if (!this._movingResizingStartPoint.IsEmpty &&
                this._resizingMode != ResizingMode.None)
            {
                // Calculate how far the mouse was moved
                SizeF moveDistance = new SizeF(
                    this._movingResizingStartPoint.X - e.X,
                    this._movingResizingStartPoint.Y - e.Y);

                // Update location of all selected annotation objects
                foreach (Annotation annot in this)
                {
                    if (annot.IsSelected &&
                        ((this._resizingMode == ResizingMode.MovingPathPoints && annot.AllowPathEditing) ||
                         (this._resizingMode == ResizingMode.Moving && annot.AllowMoving) ||
                         (this._resizingMode == ResizingMode.AnchorHandle && annot.AllowAnchorMoving) ||
                         (this._resizingMode >= ResizingMode.TopLeftHandle && this._resizingMode <= ResizingMode.LeftHandle && annot.AllowResizing)))
                    {
                        annot.AdjustLocationSize(moveDistance, this._resizingMode, true, true);
                    }
                }

                // Move last clicked non-selected annotation
                if (lastClickedAnnotation != null &&
                    !lastClickedAnnotation.IsSelected)
                {
                    if (this._resizingMode == ResizingMode.Moving &&
                        lastClickedAnnotation.AllowMoving)
                    {
                        lastClickedAnnotation.AdjustLocationSize(moveDistance, this._resizingMode, true, true);
                    }
                }

                // Invalidate and update the chart
                this.Chart.Invalidate(true);
                this.Chart.UpdateAnnotations();
            }
            else if (this.Count > 0)
            {
                // Check if currently placing annotation from the UserInterface
                bool process = true;

                if (process)
                {
                    // Check if mouse pointer is over the annotation selection handle
                    ResizingMode currentResizingMode = ResizingMode.None;
                    Annotation   annotation          =
                        HitTestSelectionHandles(new PointF(e.X, e.Y), ref currentResizingMode);

                    // Check if mouse pointer over the annotation object movable area
                    if (annotation == null)
                    {
                        HitTestResult result = this.Chart.HitTest(e.X, e.Y, ChartElementType.Annotation);
                        if (result != null && result.ChartElementType == ChartElementType.Annotation)
                        {
                            annotation = (Annotation)result.Object;
                            if (annotation != null)
                            {
                                // Check if annotation is in the collection
                                if (this.Contains(annotation))
                                {
                                    currentResizingMode = ResizingMode.Moving;
                                    if (annotation.AllowMoving == false)
                                    {
                                        // Movement is not allowed
                                        annotation          = null;
                                        currentResizingMode = ResizingMode.None;
                                    }
                                }
                            }
                        }
                    }
                    // Set mouse cursor
                    SetResizingCursor(annotation, currentResizingMode);
                }
            }
        }
        /// <summary>
        /// Mouse button pressed in the control.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        /// <param name="isHandled">Returns true if event is handled and no further processing required.</param>
        internal void OnMouseDown(MouseEventArgs e, ref bool isHandled)
        {
            // Reset last clicked annotation object and stop text editing
            if (lastClickedAnnotation != null)
            {
                TextAnnotation textAnnotation = lastClickedAnnotation as TextAnnotation;
                if (textAnnotation != null)
                {
                    // Stop annotation text editing
                    textAnnotation.StopTextEditing();
                }
                lastClickedAnnotation = null;
            }

            // Check if in annotation placement mode
            if (this.placingAnnotation != null)
            {
                // Process mouse down
                this.placingAnnotation.PlacementMouseDown(new PointF(e.X, e.Y), e.Button);

                // Set handled flag
                isHandled = true;
                return;
            }

            // Process only left mouse buttons
            if (e.Button == MouseButtons.Left)
            {
                bool updateRequired = false;
                this._resizingMode = ResizingMode.None;

                // Check if mouse buton was pressed in any selection handles areas
                Annotation annotation =
                    HitTestSelectionHandles(new PointF(e.X, e.Y), ref this._resizingMode);

                // Check if mouse button was pressed over one of the annotation objects
                if (annotation == null && this.Count > 0)
                {
                    HitTestResult result = this.Chart.HitTest(e.X, e.Y, ChartElementType.Annotation);
                    if (result != null && result.ChartElementType == ChartElementType.Annotation)
                    {
                        annotation = (Annotation)result.Object;
                    }
                }

                // Unselect all annotations if mouse clicked outside any annotations
                if (annotation == null || !annotation.IsSelected)
                {
                    if ((Control.ModifierKeys & Keys.Control) != Keys.Control &&
                        (Control.ModifierKeys & Keys.Shift) != Keys.Shift)
                    {
                        foreach (Annotation annot in this.Chart.Annotations)
                        {
                            if (annot != annotation && annot.IsSelected)
                            {
                                annot.IsSelected = false;
                                updateRequired   = true;

                                // Call selection changed notification
                                if (this.Chart != null)
                                {
                                    this.Chart.OnAnnotationSelectionChanged(annot);
                                }
                            }
                        }
                    }
                }

                // Process mouse action in the annotation object
                if (annotation != null)
                {
                    // Mouse down event handled
                    isHandled = true;

                    // Select/Unselect annotation
                    Annotation selectableAnnotation = annotation;
                    if (annotation.AnnotationGroup != null)
                    {
                        // Select annotation group when click on any child annotations
                        selectableAnnotation = annotation.AnnotationGroup;
                    }
                    if (!selectableAnnotation.IsSelected && selectableAnnotation.AllowSelecting)
                    {
                        selectableAnnotation.IsSelected = true;
                        updateRequired = true;

                        // Call selection changed notification
                        if (this.Chart != null)
                        {
                            this.Chart.OnAnnotationSelectionChanged(selectableAnnotation);
                        }
                    }
                    else if ((Control.ModifierKeys & Keys.Control) == Keys.Control ||
                             (Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        selectableAnnotation.IsSelected = false;
                        updateRequired = true;

                        // Call selection changed notification
                        if (this.Chart != null)
                        {
                            this.Chart.OnAnnotationSelectionChanged(selectableAnnotation);
                        }
                    }

                    // Remember last clicked and selected annotation
                    lastClickedAnnotation = annotation;

                    // Rember mouse position
                    this._movingResizingStartPoint = new PointF(e.X, e.Y);

                    // Start moving, repositioning or resizing of annotation
                    if (annotation.IsSelected)
                    {
                        // Check if one of selection handles was clicked on
                        this._resizingMode = annotation.GetSelectionHandle(this._movingResizingStartPoint);
                        if (!annotation.AllowResizing &&
                            this._resizingMode >= ResizingMode.TopLeftHandle &&
                            this._resizingMode <= ResizingMode.LeftHandle)
                        {
                            this._resizingMode = ResizingMode.None;
                        }
                        if (!annotation.AllowAnchorMoving &&
                            this._resizingMode == ResizingMode.AnchorHandle)
                        {
                            this._resizingMode = ResizingMode.None;
                        }
                        if (this._resizingMode == ResizingMode.None && annotation.AllowMoving)
                        {
                            // Annotation moving mode
                            this._resizingMode = ResizingMode.Moving;
                        }
                    }
                    else
                    {
                        if (this._resizingMode == ResizingMode.None && annotation.AllowMoving)
                        {
                            // Do not allow moving child annotations inside the group.
                            // Only the whole group can be selected, resized or repositioned.
                            if (annotation.AnnotationGroup != null)
                            {
                                // Move the group instead
                                lastClickedAnnotation = annotation.AnnotationGroup;
                            }

                            // Annotation moving mode
                            this._resizingMode = ResizingMode.Moving;
                        }
                    }
                }

                // Update chart
                if (updateRequired)
                {
                    // Invalidate and update the chart
                    this.Chart.Invalidate(true);
                    this.Chart.UpdateAnnotations();
                }
            }
        }
Пример #8
0
        /// <summary>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            /*if (m_mouseDown != null)
			{
				Vector2 x, y;
				GetZoomRange(e, out x, out y);

				m_area.AxisX.ScaleView.Zoom(x.m_x, x.m_y);
				m_area.AxisY.ScaleView.Zoom(y.m_x, y.m_y);
			}*/

            // Call HitTest
            HitTestResult result = m_chart.HitTest(e.X, e.Y);

            // If the mouse if over a data point
            if (result.ChartElementType == ChartElementType.DataPoint)
            {
                // Find selected data point
                //DataPoint point = m_chart.Series[kSmaSSeriesName].Points[result.PointIndex];

                m_mouseOverResult = result;
                m_chart.Invalidate();
            }
            else
            {
                m_mouseOverResult = null;
            }
        }
Пример #9
0
        private void chart_ThamNien_MouseDown(object sender, MouseEventArgs e)
        {
            // Call Hit Test Method
            result = chart_ThamNien.HitTest(e.X, e.Y);

            if (result.ChartElementType == ChartElementType.DataPoint || result.ChartElementType == ChartElementType.DataPointLabel)
            {
                
                ClearThongTin();
                // Show dialog
                //MessageBox.Show(DateTime.FromOADate(chart_ThamNien.Series[result.Series.Name].Points[result.PointIndex].XValue).ToString());

                int? id = Convert.ToInt32(chart_ThamNien.Series[result.Series.Name].Points[result.PointIndex].Tag);
                DataRow r = dt_original.AsEnumerable().Where(a => a.Field<int?>("id") == id).CopyToDataTable().Rows[0];
                BindThongTin(r);
                
            }
            //else if (result.ChartElementType != ChartElementType.Nothing)
            //{
            //    string elementType = result.ChartElementType.ToString();
            //    MessageBox.Show(this, "Selected Element is: " + elementType);
            //}
        }
Пример #10
0
 private bool CompareCollections(HitTestResult[] result)
 {
     if ((_lastObjects == null ^ result == null) || result == null)
         return false;
     if (_lastObjects.Length != result.Length)
         return false;
     for (int i = 0; i < result.Length; i++)
     {
         if (_lastObjects[i].Object != result[i].Object)
             return false;
     }
     return true;
 }