Ejemplo n.º 1
0
        //level 2 methods-process RU-values, and use level 1 method using RU-values
        private void DrawSimpleEquation(float a, float b, string description = "", float step = 0.05f)
        {
            bool GetP1 = false;
            bool GetP2 = false;
            float x, y, maxX, maxY, x1 = 0, y1 = 0, x2 = 0, y2 = 0;  //RU_VALUE
            maxX = (canvas.Width - Origin.X) / Unit.X;//RU_VALUE
            maxY = (canvas.Height - Origin.Y) / Unit.Y; // RU_VALUE
            for (x = (0 - Origin.X) / Unit.X; x <= maxX; x += step)
            {
                y = a * x + b;
                DrawPoint(x, y);//RU_VALUE

                //get 2 locations(about 2/3 of range) for label.
                if (x >= maxX * 2f / 3f && !GetP1)
                {
                    x1 = x;
                    y1 = y;
                    GetP1 = true;
                }
                if (y >= maxY * 2f / 3f && !GetP2)
                {
                    x2 = x;
                    y2 = y;
                    GetP2 = true;
                }
            }
            //choose 1 good location from 2
            if (y1 < maxY && y1 > 0 && !GetP1)
            {
                AddLabel lb = new AddLabel(x1, y1, Origin.X, Origin.Y, canvas, description);
            }
            else
            {
                AddLabel lb = new AddLabel(x2, y2, Origin.X, Origin.Y, canvas, description);
            }
        }
Ejemplo n.º 2
0
        private void DrawSegmentByTwoPoints(PointF p1, PointF p2, string description = "", Color? color = null, float width = 1f)
        {
            Pen pen = new Pen(color ?? Color.Red, width);
            PointF _p1 = new PointF(Origin.X + p1.X * Unit.X, Origin.Y - p1.Y * Unit.Y);
            PointF _p2 = new PointF(Origin.X + p2.X * Unit.X, Origin.Y - p2.Y * Unit.Y);
            g.DrawLine(pen, _p1, _p2);

            AddLabel lb1 = new AddLabel(p1, new PointF(Origin.X, Origin.Y), canvas, description);
        }
Ejemplo n.º 3
0
        private void DrawPoint(PointF p, string description = "", Color? color = null, float height = 0.05f, float width = 0.05f)
        {
            Pen pen = new Pen(color ?? Color.Red, height);
            PointF pA = new PointF(Origin.X + p.X * Unit.X, Origin.Y - p.Y * Unit.Y);
            PointF pa = new PointF(pA.X + width, pA.Y);
            g.DrawLine(pen, pA, pa);//this is a built-in method, needs absolute value

            if (description != "")
            {
                AddLabel lb = new AddLabel(p, new PointF(Origin.X, Origin.Y), canvas, description);
            }
        }
Ejemplo n.º 4
0
        private void DrawSegmentByTwoPoints(float x1, float y1, float x2, float y2, string description, Color? color = null, float width = 1f)
        {
            Pen pen = new Pen(color ?? Color.Red, width);
            PointF p1 = new PointF(Origin.X + x1 * Unit.X, Origin.Y - y1 * Unit.Y);
            PointF p2 = new PointF(Origin.X + x2 * Unit.X, Origin.Y - y2 * Unit.Y);
            g.DrawLine(pen, p1, p2);

            AddLabel lb1 = new AddLabel(new PointF(x1, y1), new PointF(Origin.X, Origin.Y), canvas, description);
        }
Ejemplo n.º 5
0
        //level 1 methods-process RU-values, and use built-in method using abs-value
        private void DrawPoint(float x, float y, string description = "", Color? color = null, float height = 0.05f, float width = 0.05f)
        {
            Pen pen = new Pen(color ?? Color.Red, height); //1f for vertical height, acts as height of point
            PointF p_Abs = new PointF(Origin.X + x * Unit.X, Origin.Y - y * Unit.Y);
            PointF _p_Abs = new PointF(p_Abs.X + width, p_Abs.Y);//1f acts as with of point
            g.DrawLine(pen, p_Abs, _p_Abs);

            if (description != "")
            {
                AddLabel lb = new AddLabel(new PointF(x, y), new PointF(Origin.X, Origin.Y), canvas, description);
            }
        }