//scaling the chart
        public ZoomAxisXY GetPointAB(double Axis_AX, double Axis_AY, double Axis_BX, double Axis_BY, double height, double distancePointAxisX, double distancePointAxisY, double scaleX, double scaleY, double ChangeScaleAxisX, double ChangeScaleAxisY)
        {
            if (double.IsNaN(Axis_AX) || double.IsNaN(Axis_AY) || double.IsNaN(Axis_BX) || double.IsNaN(Axis_BY) || double.IsNaN(height) || double.IsNaN(distancePointAxisX))
            {
                return(null);
            }
            if (double.IsNaN(distancePointAxisY) || double.IsNaN(scaleX) || double.IsNaN(scaleY) || double.IsNaN(ChangeScaleAxisX) || double.IsNaN(ChangeScaleAxisY))
            {
                return(null);
            }

            if (double.IsInfinity(Axis_AX) || double.IsInfinity(Axis_AY) || double.IsInfinity(Axis_BX) || double.IsInfinity(Axis_BY) || double.IsInfinity(height) || double.IsInfinity(distancePointAxisX))
            {
                return(null);
            }
            if (double.IsInfinity(distancePointAxisY) || double.IsInfinity(scaleX) || double.IsInfinity(scaleY) || double.IsInfinity(ChangeScaleAxisX) || double.IsInfinity(ChangeScaleAxisY))
            {
                return(null);
            }

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

            Axis_A_X = Axis_AX / distancePointAxisY;
            Axis_A_Y = (height - Axis_AY) / distancePointAxisX;

            Axis_B_X = Axis_BX / distancePointAxisY;
            Axis_B_Y = (height - Axis_BY) / distancePointAxisX;

            //rounding of variables
            if (scaleX >= 1)
            {
                Axis_A_X = Math.Round(Axis_A_X, 1);
                Axis_B_X = Math.Round(Axis_B_X, 1);
            }

            if (scaleY >= 1)
            {
                Axis_A_Y = Math.Round(Axis_A_Y, 1);
                Axis_B_Y = Math.Round(Axis_B_Y, 1);
            }

            axis = new ZoomAxisXY()
            {
                //if the scale has changed, add the difference => the situation occurs after the second magnification of the chart, i.e. ChangeScaleAxis
                Axis_AX = ChangeScaleAxisX + Axis_A_X,
                Axis_BX = ChangeScaleAxisX + Axis_B_X,
                Axis_AY = ChangeScaleAxisY + Axis_A_Y,
                Axis_BY = ChangeScaleAxisY + Axis_B_Y
            };

            return(axis);
        }
示例#2
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);
        }