Example #1
0
 public override void Draw(PlotterGraphics pg)
 {
     pg.DrawLineC(_p0, _p1, _color);
     if (Selected && _mode == SelectMode.P0)
     {
         pg.DrawCircleC(_p0, 5);
     }
     if (Selected && _mode == SelectMode.P1)
     {
         pg.DrawCircleC(_p1, 5);
     }
 }
Example #2
0
        public void Draw(PlotterGraphics g)
        {
            SolidBrush   b          = new SolidBrush(Color.Black);
            FontFamily   fontFamily = new FontFamily("Lucida Console");
            Font         f          = new Font(fontFamily, _fontSize, FontStyle.Regular, GraphicsUnit.Point);
            StringFormat sf         = new StringFormat(StringFormatFlags.DirectionVertical);
            SizeF        st         = g.Graphics.MeasureString("0", f);

            // draw x axis
            int oy = g.VR.YVToC(YAxis.Origin);

            g.DrawLineC(g.VR.CXMin, oy, g.VR.CXMax, oy);

            // draw x axis ticks and values
            for (int i = 0; i < XAxis.NoOfTicks; i++)
            {
                double tv = XAxis.Tick(i);
                int    tc = g.VR.XVToC(tv);

                if (tv != XAxis.Origin)
                {
                    // tick mark
                    g.DrawLineC(tc, oy - _tickSize, tc, oy + _tickSize);

                    // value
                    string stv = tv.ToString();
                    if (stv.Length < 4)
                    {
                        // horizontal text
                        g.Graphics.DrawString(stv, f, b, new PointF(tc - (st.Width), oy + _tickSize));
                    }
                    else
                    {
                        // vertical
                        g.Graphics.DrawString(stv, f, b, new PointF(tc - _fontSize, oy + _tickSize), sf);
                    }
                }
            }

            // draw y axis
            int ox = g.VR.XVToC(XAxis.Origin);

            g.DrawLineC(ox, g.VR.CYMin, ox, g.VR.CYMax);

            // draw y axis ticks
            for (int i = 0; i < YAxis.NoOfTicks; i++)
            {
                double tv = YAxis.Tick(i);
                int    tc = g.VR.YVToC(tv);

                if (tv != YAxis.Origin)
                {
                    // tick mark
                    g.DrawLineC(ox - _tickSize, tc, ox + _tickSize, tc);

                    // value
                    g.Graphics.DrawString(tv.ToString(), f, b, new PointF(ox + _tickSize, tc - (st.Height / 4)));
                }
            }

            // origin circle
            if (XAxis.Origin == 0.0 && YAxis.Origin == 0.0)
            {
                g.DrawEllipseC(ox - _tickSize, oy - _tickSize, _tickSize * 2, _tickSize * 2);
            }
        }