Ejemplo n.º 1
0
        private void DrawingB_MouseMove(object sender, MouseEventArgs e)
        {
            HitTestResult result     = DrawingB.HitTest(e.X, e.Y);
            ChartArea     chartAreas = DrawingB.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)
            {
                bHystoLabel.Text = "Coordinates " + (int)X + "; " + (int)Y;
            }
        }
Ejemplo n.º 2
0
        private void DrawingB_Click(object sender, EventArgs e)
        {
            MouseEventArgs args = (MouseEventArgs)e;

            HitTestResult result     = DrawingB.HitTest(args.X, args.Y);
            ChartArea     chartAreas = DrawingB.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 = DrawingB.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;
                    }
                }

                DrawingB.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)
                {
                    DrawingB.Series[0].Points.AddXY(point.Key, point.Value);
                }
            }
        }