Ejemplo n.º 1
0
        private void DrawingG_MouseMove(object sender, MouseEventArgs e)
        {
            HitTestResult result     = DrawingG.HitTest(e.X, e.Y);
            ChartArea     chartAreas = DrawingG.ChartAreas[0];

            double X = chartAreas.AxisX.PixelPositionToValue(e.X);
            double Y = chartAreas.AxisY.PixelPositionToValue(e.Y);

            chartAreas.CursorX.Position = X;
            chartAreas.CursorY.Position = Y;

            if (X >= -1 && Y >= -1 && X <= 256 && Y <= 256)
            {
                gHystoLabel.Text = "Coordinates " + (int)X + "; " + (int)Y;
            }
        }
Ejemplo n.º 2
0
        private void DrawingG_Click(object sender, EventArgs e)
        {
            MouseEventArgs args = (MouseEventArgs)e;

            HitTestResult result     = DrawingG.HitTest(args.X, args.Y);
            ChartArea     chartAreas = DrawingG.ChartAreas[0];
            int           X          = (int)chartAreas.AxisX.PixelPositionToValue(args.X);
            int           Y          = (int)chartAreas.AxisY.PixelPositionToValue(args.Y);

            if (X >= 0 && X <= 255 && Y >= 0 && Y <= 255)
            {
                //MessageBox.Show("Coordinates: X " + X + " Y " + Y);
                DataPoint[] dataPoints = DrawingG.Series[0].Points.ToArray();

                bool xFound = false;
                for (int i = 0; i < dataPoints.Length; i++)
                {
                    if (dataPoints[i].XValue == X)
                    {
                        dataPoints[i].YValues[0] = Y;
                        xFound = true;
                    }
                }

                DrawingG.Series[0].Points.Clear();
                SortedDictionary <int, int> realPoints = new SortedDictionary <int, int>();

                foreach (DataPoint point in dataPoints)
                {
                    realPoints.Add((int)point.XValue, (int)point.YValues[0]);
                }
                if (xFound == false)
                {
                    realPoints.Add(X, Y);
                }


                foreach (var point in realPoints)
                {
                    DrawingG.Series[0].Points.AddXY(point.Key, point.Value);
                }
            }
        }