Esempio n. 1
0
        public void drowLine(Equation equation)
        {
            DLLLandAndDoig.Point start = new DLLLandAndDoig.Point(0, 0);
            DLLLandAndDoig.Point end   = new DLLLandAndDoig.Point(0, 0);

            Equation axesX = new Equation(1, 0, ">=", 0);
            Equation axesY = new Equation(0, 1, ">=", 0);

            if (Utils.IsLineParallel(equation, axesX))
            {
                start.X = equation.solveY(0);
                start.Y = 0;
                end.X   = equation.solveY(0);
                end.Y   = _max;
            }
            else if (Utils.IsLineParallel(equation, axesY))
            {
                start.X = 0;
                start.Y = equation.solveX(0);
                end.X   = _max;
                end.Y   = equation.solveX(0);
            }
            else
            {
                start.Y = equation.solveY(0);
                if (start.Y > _max)
                {
                    reScale(_scale + 1);
                    drowLine(equation);
                    return;
                }
                end.X = equation.solveX(0);
                if (start.Y == end.X)
                {
                    end.X = equation.solveX(_max);
                    end.Y = _max;

                    double temp = equation.solveY(_max);

                    if (temp < end.X)
                    {
                        end.Y = temp;
                        end.X = _max;
                    }
                }
                if (end.X > _max)
                {
                    reScale(_scale + 0.5);
                    drowLine(equation);
                    return;
                }
            }

            drowLine(start, end, equation.toString());
        }
Esempio n. 2
0
        public void handleSelectEvent(SelectBlockObject obj)
        {
            _func.Clear();
            reScale(1);
            foreach (var t in obj.Limits)
            {
                drowLine(t);
            }
            if (obj.Limit != null)
            {
                drowLine(obj.Limit);
            }

            DLLLandAndDoig.Point start = new DLLLandAndDoig.Point(0, 0);
            DLLLandAndDoig.Point end   = new DLLLandAndDoig.Point(obj.Func.X, obj.Func.Y);
            drowLine(start, end, obj.Func.toString());
        }
Esempio n. 3
0
 public CoordinatePlane(Canvas canvas, DLLLandAndDoig.Point start, int axesLength)
 {
     _axesLines      = new List <Line>();
     _axesLabels     = new List <Label>();
     _grid           = new List <Line>();
     _divisionLabels = new List <Label>();
     _divisionLines  = new List <Line>();
     _func           = new List <Equation>();
     _funcLines      = new List <Line>();
     _funcLabels     = new List <Label>();
     _canvas         = canvas;
     _start          = start;
     _axesLength     = axesLength;
     drowGrid();
     drowAxes();
     reScale(1);
 }
Esempio n. 4
0
        public void drowLine(DLLLandAndDoig.Point start, DLLLandAndDoig.Point end, string text)
        {
            Line line = new Line();

            line.X1     = _start.X + ((start.X / _scale) * _step);
            line.Y1     = (_axesLength - ((start.Y / _scale) * _step)) - 5;
            line.X2     = _start.X + (end.X / _scale) * _step;
            line.Y2     = (_axesLength - ((end.Y / _scale) * _step)) - 5;
            line.Stroke = _colorFunc;
            _funcLines.Add(line);
            _canvas.Children.Add(line);

            Label labelX = new Label();

            labelX.Content = text;
            Canvas.SetLeft(labelX, (line.X1 + line.X2) / 2);
            Canvas.SetTop(labelX, (line.Y1 + line.Y2) / 2);
            labelX.Foreground = _colorFuncLabel;
            _divisionLabels.Add(labelX);
            _canvas.Children.Add(labelX);
        }