Exemple #1
0
        /// <summary>
        /// When we click chart
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Clicked dot</param>
        private void MainChart_MouseDown(object sender, MouseEventArgs e)
        {
            //Information abour click result
            var DotWeGot = MainChart.HitTest(e.X, e.Y);

            //If we click one of x dots
            if ((DotWeGot.Series != null) && (DotWeGot.Series.Name == SOURSE_DOTS_SERIES_NAME))
            {
                //capture it
                captured = MainChart.Series[SOURSE_DOTS_SERIES_NAME].Points[DotWeGot.PointIndex].XValue;
            }

            //Els if we click on chart area
            else if (DotWeGot.ChartArea != null)
            {
                //Finde x coordinate of click on chart
                double clickedColumn = MainChart.ChartAreas[0].AxisX.PixelPositionToValue(e.X);

                //If we clicked almost on one of the start dot's column
                if ((Math.Abs(Math.Round(clickedColumn) - clickedColumn) < this.Width * 0.00005) && (Math.Round(clickedColumn) >= FIRST_DOT_X) && (Math.Round(clickedColumn) < (FIRST_DOT_X + NUMBBER_OF_SOURSE_DOTS)))
                {
                    //Move start dot
                    SourseDots[Math.Round(clickedColumn)] = MainChart.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);

                    //Rewrite all functions according to
                    Rewrite();
                }
            }
        }
Exemple #2
0
        private void LineMarker_PositionChanged(object sender, PositionChangedArgs e)
        {
            var chartPoint   = new Point(LineMarker.X, LineMarker.Y);
            var _hitTestInfo = MainChart.HitTest(chartPoint);

            var hitTestInfo = MainChart.HitTest(chartPoint);
        }
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (m_isPlacingAnnotation)
            {
                return;
            }

            while (m_isChartUpdating)
            {
            }

            try
            {
                m_isPlacingAnnotation = true;
                var xValueUnderCursor = MainChart.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
                var results           = MainChart.HitTest(e.X, e.Y, false, ChartElementType.DataPoint);
                var point             = results.Where(x => x.ChartElementType == ChartElementType.DataPoint)
                                        .Select(x => x.Object as DataPoint)
                                        .Where(x => x != null && x.Tag != null)
                                        .OrderBy(x => Math.Abs(xValueUnderCursor - x.XValue))
                                        .FirstOrDefault();

                if (point == null)
                {
                    return;
                }
                if (m_pointUnderCursor != null && !m_pointerUnderCursorSelected)
                {
                    m_pointUnderCursor.MarkerSize = ChartMarkerSize;
                }

                m_pointUnderCursor            = point;
                m_pointerUnderCursorSelected  = m_pointUnderCursor.MarkerSize == ChartSelectedMarkerSize;
                m_pointUnderCursor.MarkerSize = ChartSelectedMarkerSize;

                m_valueAnnotation.BeginPlacement();
                {
                    m_valueAnnotation.AnchorX = m_pointUnderCursor.XValue;
                    m_valueAnnotation.AnchorY = m_pointUnderCursor.YValues[0];
                    m_valueAnnotation.Text    = m_pointUnderCursor.Tag.ToString();
                }
                m_valueAnnotation.EndPlacement();
            }
            catch (Exception)
            {
                // Ignore
            }
            finally
            {
                m_isPlacingAnnotation = false;
            }
        }
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button.HasFlag(MouseButtons.Left))
            {
                ChartArea     ca = MainChart.ChartAreas[0];
                Axis          ax = ca.AxisX;
                Axis          ay = ca.AxisY;
                int           X = e.X, Y = e.Y;
                HitTestResult hit = MainChart.HitTest(e.X, e.Y);
                if (hit.PointIndex > 0)
                {
                    curPoint = hit.Series.Points[hit.PointIndex];
                }

                //if (curPoint != null)
                //{
                //    if (curPoint.XValue == 255 && curPoint.YValues[0] == 255) curPoint = null;
                //    if (curPoint.XValue == 0 && curPoint.YValues[0] == 0) curPoint = null;
                //    if (MainChart.Series[0].Points[MainChart.Series[0].Points.Count() - 1] == curPoint) curPoint = null;
                //    if (MainChart.Series[0].Points[0] == curPoint) curPoint = null;

                //}
                if (curPoint != null)
                {
                    Series s  = hit.Series;
                    double dx = ax.PixelPositionToValue(e.X);
                    double dy = ay.PixelPositionToValue(e.Y);

                    curPoint.XValue     = dx;
                    curPoint.YValues[0] = dy;
                }


                ObjectAPI pic2 = pic.Clone() as ObjectAPI;
                //pic2.ChangeGist(MainChart,str);
                Gist.Series[str2].Points.Clear();

                if (flag == false)
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.ShowRGB());
                }
                //MainPic.Image = pic2.ShowRGB();
                else
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.Show());
                }
                //MainPic.Image = pic2.Show();
                MainPic.Refresh();
                Gist = Curve.loadGist(Gist, pic2, str2);
            }
        }
Exemple #5
0
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            //If mous left button is clamped and some dot is captured
            if ((MouseButtons == MouseButtons.Left) && (captured != 0))
            {
                //If we still on our chart area
                if (MainChart.HitTest(e.X, e.Y).ChartArea != null)
                {
                    //Move captured dot
                    SourseDots[captured] = MainChart.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);

                    //Rebuid series
                    Rewrite();
                }
            }
        }
Exemple #6
0
        private void InitializeChart()
        {
            MainChart.Palette = ChartColorPalette.Pastel;
            var area = new ChartArea();
            {
                area.AxisX.IsMarginVisible             = false;
                area.AxisX.MajorGrid.Enabled           = true;
                area.AxisX.MajorGrid.LineColor         = Color.FromArgb(230, 230, 230);
                area.AxisX.MajorTickMark.TickMarkStyle = TickMarkStyle.None;
                area.AxisX.LabelStyle.Enabled          = false;
                area.AxisX.LineColor          = Color.DarkGray;
                area.AxisX.IntervalOffsetType = DateTimeIntervalType.Milliseconds;
                area.AxisX.ScaleView.Zoomable = true;
                area.AxisX.ScrollBar.Enabled  = false;

                area.AxisY.IsMarginVisible             = false;
                area.AxisY.MajorGrid.Enabled           = true;
                area.AxisY.MajorGrid.LineColor         = Color.FromArgb(230, 230, 230);
                area.AxisY.MajorTickMark.TickMarkStyle = TickMarkStyle.None;
                area.AxisY.LabelStyle.Enabled          = false;
                area.AxisY.LineColor = Color.DarkGray;
            }
            var valueAnnotation = new CalloutAnnotation
            {
                AxisX = area.AxisX,
                AxisY = area.AxisY
            };

            MainChart.ChartAreas.Add(area);
            MainChart.Annotations.Add(valueAnnotation);

            DataPoint pointUnderCursor = null;

            MainChart.MouseMove += (s, e) =>
            {
                var result = MainChart.HitTest(e.X, e.Y);

                if (result.ChartElementType != ChartElementType.DataPoint ||
                    result.PointIndex < 0 ||
                    result.Series.Points.Count <= result.PointIndex)
                {
                    return;
                }

                if (result.Series.Points.Count <= result.PointIndex)
                {
                    return;
                }
                if (pointUnderCursor != null)
                {
                    pointUnderCursor.MarkerSize = 0;
                }

                pointUnderCursor            = result.Series.Points[result.PointIndex];
                pointUnderCursor.MarkerSize = 7;

                valueAnnotation.BeginPlacement();

                // You must set AxisX before binding to xValue!
                valueAnnotation.AnchorX = pointUnderCursor.XValue;
                valueAnnotation.AnchorY = pointUnderCursor.YValues[0];
                valueAnnotation.Text    = pointUnderCursor.Tag.ToString();

                valueAnnotation.EndPlacement();
            };

            MainChartScrollBar.Scroll       += (s, e) => IsTracking = MainChartScrollBar.Value == MainChartScrollBar.Maximum;
            MainChartScrollBar.ValueChanged += (s, e) => ScrollChart(false);
        }