Exemplo n.º 1
0
        private void DravPolyline(double x, double y, double maxValueX = 0, double maxValueY = 0)
        {
            if (double.IsNaN(x) || double.IsNaN(y) || double.IsNaN(maxValueX) || double.IsNaN(maxValueY))
            {
                return;
            }
            if (double.IsInfinity(x) || double.IsInfinity(y) || double.IsInfinity(maxValueX) || double.IsInfinity(maxValueY))
            {
                return;
            }

            if (maxValueX == 0 || maxValueY == 0)
            {
                maxValueY = _current_MaxValue_Y;
                maxValueX = _current_MaxValue_X;
            }

            double copyX = x;
            double copyY = y;

            using (MathXY mathPoint = new MathXY())
            {
                AxisPosition = mathPoint.GetAxisPosition(copyX, copyY, valueOsX, valueOsY, heightChar, ChangeScaleAxisX, ChangeScaleAxisY);

                if (AxisPosition != null)
                {
                    lineChar.Points.Add(new Point(AxisPosition.PositionX, AxisPosition.PositionY));
                }

                AxisPosition.Dispose();
            }
        }
Exemplo n.º 2
0
        private void LineChar_MouseMove(object sender, MouseEventArgs e)
        {
            if (!Copy_ShowToolTipChar)
            {
                return;
            }

            double pointX = e.GetPosition(this.CharDrawe).X;
            double pointY = e.GetPosition(this.CharDrawe).Y;

            const int digitsx = 2, digitsy = 2;

            using (MathXY mathPoint = new MathXY())
            {
                var c = mathPoint.GetPointAB(pointX, pointY, 0, 0, heightChar, valueOsX, valueOsY, scalaX, scalaY, ChangeScaleAxisX, ChangeScaleAxisY);

                toolTipLabel.Visibility = Visibility.Visible;
                toolTipLabel.Content    = string.Format("{0} ; {1}", Math.Round(c.Axis_AX, digitsx).ToString(), Math.Round(c.Axis_AY, digitsy).ToString());
                toolTipLabel.Margin     = new Thickness(pointX + 5, pointY - 30, 0, 0);
            }
        }
Exemplo n.º 3
0
        private void CharLegend_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            //if the toolbar is moved - do not scale the graph
            if (changePositionToolbar)
            {
                return;
            }

            mouseIsDown = false;
            mouseIsUP   = true;

            //reading the current cursor position ie the current "under the cursor" item
            double pointX = e.GetPosition(this.CharDrawe).X;
            double pointY = e.GetPosition(this.CharDrawe).Y;

            double Axis_A_X = 0;
            double Axis_A_Y = 0;
            double Axis_B_X = 0;
            double Axis_B_Y = 0;

            if (pointX == x1 || pointY == y1)
            {
                //description if selecting the data on the chart is different than from the left corner to the right corner
                Axis_A_X = x1; Axis_A_Y = y1;
                Axis_B_X = x1 + x2; Axis_B_Y = y1 + y2;
            }
            else
            {
                Axis_A_X = x1; Axis_A_Y = y1;
                Axis_B_X = pointX; Axis_B_Y = pointY;
            }

            using (MathXY mathPoint = new MathXY()){
                zoomAxisXY = mathPoint.GetPointAB(Axis_A_X, Axis_A_Y, Axis_B_X, Axis_B_Y, heightChar, valueOsX, valueOsY, scalaX, scalaY, ChangeScaleAxisX, ChangeScaleAxisY);

                if (zoomAxisXY == null)
                {
                    return;
                }

                Axis_A_X = zoomAxisXY.Axis_AX;
                Axis_A_Y = zoomAxisXY.Axis_AY;
                Axis_B_X = zoomAxisXY.Axis_BX;
                Axis_B_Y = zoomAxisXY.Axis_BY;

                //change of scope
                //the function is repeated 2x ==> DrawLineAndValue
                if (Axis_B_X < Axis_A_X)
                {
                    double Tmp_odX = Axis_A_X;

                    Axis_A_X = Axis_B_X;
                    Axis_B_X = Tmp_odX;
                }

                if (Axis_A_Y < Axis_B_Y)
                {
                    double Tmp_odY = Axis_B_Y;

                    Axis_B_Y = Axis_A_Y;
                    Axis_A_Y = Tmp_odY;
                }

                //deleting the graph, i.e. the values of X and Y and the co-equivalents corresponding to them
                Delete();
                //drawing a new chart
                DrawLineAndValue(Axis_B_X, Axis_A_Y, Axis_A_X, Axis_B_Y);
            }

            //if a graph is plotted on the graph
            if (_Point.Count != 0)
            {
                AddNewPolyline();

                //scaling the chart after all points
                foreach (var v in _Point)
                {
                    DravPolyline(v.Axis_X, v.Axis_Y);
                }

                CharDrawe.Children.Add(lineChar);
            }

            //removing a square from the chart
            rectangleGeometry.Rect = new Rect(0, 0, 0, 0);
        }