Exemplo n.º 1
0
 private void DrawContours(Graphics g, List <Contour> c, ScreenConverter sc)
 {
     foreach (Contour co in c)
     {
         co.Draw(g, allix, coord, sc);
     }
 }
Exemplo n.º 2
0
 public void Draw(Graphics g, bool allix, int pt, float x, float y, ScreenConverter sc)
 {
     foreach (ILine l in lines)
     {
         l.Draw(g, allix, pt, x, y, sc);
     }
 }
Exemplo n.º 3
0
 private void DrawCurContour(Graphics g, ScreenConverter sc)
 {
     if (curContour != null)
     {
         curContour.Draw(g, allix, coord, sc);
     }
 }
Exemplo n.º 4
0
 public void Draw(Graphics g, bool allix, bool coord, ScreenConverter sc)
 {
     foreach (Contour c in contours)
     {
         c.Draw(g, allix, coord, sc);
     }
 }
Exemplo n.º 5
0
 public void Draw(Graphics g, int pt, float x, float y, ScreenConverter sc)
 {
     foreach (Contour c in contours)
     {
         c.Draw(g, false, pt, x, y, sc);
     }
 }
Exemplo n.º 6
0
 public DrawingForm(MainForm f)
 {
     InitializeComponent();
     mainForm   = f;
     fontDrawer = new FontDrawer();
     draw       = false;
     sc         = new ScreenConverter(0, 0, 1, 1, Width, Height);
 }
Exemplo n.º 7
0
 private void DrawSymbol(Graphics g, ScreenConverter sc)
 {
     if (curSymbol != null && curSymbol.contours != null)
     {
         foreach (Contour c in curSymbol.contours)
         {
             c.Draw(g, allix, coord, sc);
         }
     }
 }
Exemplo n.º 8
0
 public void DrawSymbol(Graphics g, char c, bool allix, bool coord, ScreenConverter sc)
 {
     foreach (Symbol s in symbols)
     {
         if (s.symbol == c)
         {
             s.Draw(g, allix, coord, sc);
         }
     }
 }
Exemplo n.º 9
0
        private PointF B(float t, int pt, float x, float y, ScreenConverter sc)
        {
            float  c0 = (1 - t) * (1 - t) * (1 - t);
            float  c1 = (1 - t) * (1 - t) * 3 * t;
            float  c2 = (1 - t) * t * 3 * t;
            float  c3 = t * t * t;
            double X  = c0 * (sc.II(P1.X) * pt + x) + c1 * (sc.II(P2.X) * pt + x) + c2 * (sc.II(P3.X) * pt + x) + c3 * (sc.II(P4.X) * pt + x);
            double Y  = c0 * (sc.JJ(P1.Y) * pt + y) + c1 * (sc.JJ(P2.Y) * pt + y) + c2 * (sc.JJ(P3.Y) * pt + y) + c3 * (sc.JJ(P4.Y) * pt + y);

            return(new PointF((float)X, (float)Y));
        }
Exemplo n.º 10
0
        private PointF B(float t, ScreenConverter sc)
        {
            float  c0 = (1 - t) * (1 - t) * (1 - t);
            float  c1 = (1 - t) * (1 - t) * 3 * t;
            float  c2 = (1 - t) * t * 3 * t;
            float  c3 = t * t * t;
            double x  = c0 * sc.II(P1.X) + c1 * sc.II(P2.X) + c2 * sc.II(P3.X) + c3 * sc.II(P4.X);
            double y  = c0 * sc.JJ(P1.Y) + c1 * sc.JJ(P2.Y) + c2 * sc.JJ(P3.Y) + c3 * sc.JJ(P4.Y);

            return(new PointF((float)x, (float)y));
        }
Exemplo n.º 11
0
 public void Draw(Graphics g, bool allix, int pt, float x, float y, ScreenConverter sc)
 {
     if (Current)
     {
         g.DrawLine(Pens.Red, sc.II(P1.X) * pt + x, sc.JJ(P1.Y) * pt + y, sc.II(P2.X) * pt + x, sc.JJ(P2.Y) * pt + y);
     }
     else
     {
         g.DrawLine(Pens.Black, sc.II(P1.X) * pt + x, sc.JJ(P1.Y) * pt + y, sc.II(P2.X) * pt + x, sc.JJ(P2.Y) * pt + y);
     }
 }
Exemplo n.º 12
0
 public void Draw(Graphics g, bool allix, bool coord, ScreenConverter sc)
 {
     foreach (MyPoint p in myPoints)
     {
         p.Draw(g, Current, allix, coord, sc);
     }
     foreach (ILine l in lines)
     {
         l.Draw(g, Current, Color.Black, allix, coord, sc);
     }
 }
Exemplo n.º 13
0
 public void PointIn(PointF p, ILIneFactory factory, ILIneFactory fact, ScreenConverter sc)
 {
     if (curContour != null)
     {
         int n = SearchMyPoint(p, sc);
         if (n != -1)
         {
             curPoint = curContour.myPoints[n];
             if (curContour.myPoints[n].Current)
             {
                 curContour.myPoints[n].Current = false;
             }
             else
             {
                 curContour.myPoints[n].Current = true;
             }
             return;
         }
         if (SearchPoint(p, sc) != null)
         {
             curPoint = SearchPoint(p, sc);
             return;
         }
         else
         {
             if (lastPoint == null)
             {
                 curContour.myPoints.Add(new MyPoint(sc.XX((int)p.X), sc.YY((int)p.Y)));
                 if (curContour.myPoints.Count == 1)
                 {
                     curContour.myPoints[0].First = true;
                     firstPoint = curContour.myPoints[0];
                 }
                 lastPoint = curContour.myPoints.Last();
             }
             else
             {
                 if (curContour.myPoints.Count >= 2)
                 {
                     RemoveLastLine();
                 }
                 MyPoint curP = new MyPoint(sc.XX((int)p.X), sc.YY((int)p.Y));
                 curContour.lines.Add(factory.Create(lastPoint, curP));
                 curContour.myPoints.Add(curP);
                 lastPoint = curContour.myPoints.Last();
             }
             if (curContour.myPoints.Count >= 2)
             {
                 CloseContour(fact);
             }
         }
     }
 }
Exemplo n.º 14
0
        public void DrawBorder(Graphics g, ScreenConverter sc)
        {
            PointF p1 = new PointF(sc.II(0), sc.JJ(0));
            PointF p2 = new PointF(sc.II(0), sc.JJ(1));
            PointF p3 = new PointF(sc.II(1 * font.symbolWidth / 100f), sc.JJ(0));
            PointF p4 = new PointF(sc.II(1 * font.symbolWidth / 100f), sc.JJ(1));

            g.DrawLine(Pens.Black, p1, p2);
            g.DrawLine(Pens.Black, p1, p3);
            g.DrawLine(Pens.Black, p4, p3);
            g.DrawLine(Pens.Black, p2, p4);
            //g.DrawRectangle(Pens.Black, sc.II(sc.RX), sc.JJ(sc.RY), sc.LS(1), sc.LS(1));
        }
Exemplo n.º 15
0
 public MainForm()
 {
     InitializeComponent();
     MouseWheel += new MouseEventHandler(MainForm_MouseWheel);
     typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty
                                | BindingFlags.Instance | BindingFlags.NonPublic, null, WorkPanel, new object[] { true });
     workSpace = new WorkSpace(WorkPanel.Width, WorkPanel.Height);
     con       = new ScreenConverter(0, 0, 1, 1, WorkPanel.Width, WorkPanel.Height);
     System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
     LineRadioButton.Tag  = new LineFactory();
     BezieRadioButton.Tag = new BezieFactory();
     factory = new LineFactory();
     fact    = new LineFactory();
 }
Exemplo n.º 16
0
 private int SearchMyPoint(PointF p, ScreenConverter sc)
 {
     if (p != null)
     {
         for (int i = 0; i < curContour.myPoints.Count; i++)
         {
             MyPoint P = curContour.myPoints[i];
             if (p.X <= sc.II(P.X) + 4 && p.X >= sc.II(P.X) - 4 && p.Y >= sc.JJ(P.Y) - 4 && p.Y <= sc.JJ(P.Y) + 4)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
Exemplo n.º 17
0
 public void UpdatePoint(float dx, float dy, ScreenConverter sc)
 {
     if (curPoint != null)
     {
         MyPoint cur = curPoint;
         if (!(sc.II(cur.X) + dx > Width - 4) && sc.II(cur.X) + dx > 0)
         {
             cur.X += sc.LR((int)dx);
         }
         if (!(sc.JJ(cur.Y) + dy > Height - 4) && sc.JJ(cur.Y) + dy > 0)
         {
             cur.Y -= sc.LR((int)dy);
         }
         curPoint.Current = false;
     }
 }
Exemplo n.º 18
0
 public void DrawAll(Graphics g, ScreenConverter sc)
 {
     if (curSymbol != null)
     {
         DrawLines(g);
         DrawBorder(g, sc);
     }
     if (AllSymbol)
     {
         DrawSymbol(g, sc);
     }
     else
     {
         DrawCurContour(g, sc);
     }
 }
Exemplo n.º 19
0
 private MyPoint SearchPoint(PointF p, ScreenConverter sc)
 {
     /*foreach (MyPoint P in curContour.myPoints)
      *  if (p.X <= sc.II(P.X) + 4 && p.X >= sc.II(P.X) - 4 && p.Y >= sc.JJ(P.Y) - 4 && p.Y <= sc.JJ(P.Y) + 4)
      *      return P;*/
     foreach (ILine l in curContour.lines)
     {
         foreach (MyPoint P in l.GetSecondPoints())
         {
             if (p.X <= sc.II(P.X) + 4 && p.X >= sc.II(P.X) - 4 && p.Y >= sc.JJ(P.Y) - 4 && p.Y <= sc.JJ(P.Y) + 4)
             {
                 return(P);
             }
         }
     }
     return(null);
 }
Exemplo n.º 20
0
        public void Draw(Graphics g, bool allix, int pt, float x, float y, ScreenConverter sc)
        {
            float t  = 0f;
            float dt = 0.01f;

            PointF[] result = new PointF[101];
            for (int i = 0; i <= 100; i++)
            {
                result[i] = B(t, pt, x, y, sc);
                t        += dt;
            }
            if (allix)
            {
                g.DrawLine(Pens.Silver, sc.II(P1.X) * pt + x, sc.JJ(P1.Y) * pt + y, sc.II(P2.X) * pt + x, sc.JJ(P2.Y) * pt + y);
                g.DrawLine(Pens.Silver, sc.II(P3.X) * pt + x, sc.JJ(P3.Y) * pt + y, sc.II(P4.X) * pt + x, sc.JJ(P4.Y) * pt + y);
            }
            g.DrawLines(Pens.Black, result);
        }
Exemplo n.º 21
0
        public void Draw(Graphics g, bool curCont, bool allix, bool coord, ScreenConverter sc)
        {
            Pen p = new Pen(Brushes.Black);

            if (!allix)
            {
                return;
            }
            if (coord)
            {
                string s = "(" + sc.II(X) + ";" + sc.JJ(Y) + ")";
                Brush  b = new SolidBrush(Color.White);
                if (curCont)
                {
                    b = new SolidBrush(Color.FromArgb(60, Color.Black));
                }
                else
                {
                    b = new SolidBrush(Color.FromArgb(60, Color.Silver));
                }
                if (curCont)
                {
                    g.DrawString(s, new Font("Courier", 8), b, sc.II(X) + 4, sc.JJ(Y) - 1);
                }
            }
            if (curCont)
            {
                p.Color = Color.Black;
            }
            if (!curCont && !Current)
            {
                p.Color = Color.FromArgb(180, Color.DarkSlateGray);
            }
            if (First)
            {
                p.Color = Color.Blue;
            }
            if (Current)
            {
                p.Color = Color.Red;
            }
            g.DrawEllipse(p, sc.II(X) - 3, sc.JJ(Y) - 3, 6, 6);
        }
Exemplo n.º 22
0
        public void Draw(Graphics g, bool current, Color color, bool allix, bool coord, ScreenConverter sc)
        {
            Pen p = new Pen(color);

            if (current)
            {
                p.Color = Color.Black;
                g.DrawLine(p, sc.II(P1.X), sc.JJ(P1.Y), sc.II(P2.X), sc.JJ(P2.Y));
            }
            else
            {
                p.Color = Color.FromArgb(220, Color.DarkSlateGray);
                g.DrawLine(p, sc.II(P1.X), sc.JJ(P1.Y), sc.II(P2.X), sc.JJ(P2.Y));
            }
        }
Exemplo n.º 23
0
        public void Draw(Graphics g, bool current, Color color, bool allix, bool coord, ScreenConverter sc)
        {
            Pen   p  = new Pen(color);
            float t  = 0f;
            float dt = 0.01f;

            PointF[] result = new PointF[101];
            for (int i = 0; i <= 100; i++)
            {
                result[i] = B(t, sc);
                t        += dt;
            }
            if (allix && current)
            {
                g.DrawLine(Pens.Silver, sc.II(P1.X), sc.JJ(P1.Y), sc.II(P2.X), sc.JJ(P2.Y));
                g.DrawLine(Pens.Silver, sc.II(P3.X), sc.JJ(P3.Y), sc.II(P4.X), sc.JJ(P4.Y));
                P2.Draw(g, current, allix, coord, sc);
                P3.Draw(g, current, allix, coord, sc);
            }
            if (current)
            {
                p.Color = Color.Black;
                g.DrawLines(p, result);
            }
            else
            {
                p.Color = Color.FromArgb(220, Color.DarkSlateGray);
                g.DrawLines(p, result);
            }
        }
Exemplo n.º 24
0
 private void DrawContour(Graphics g, Contour c, ScreenConverter sc)
 {
     c.Draw(g, allix, coord, sc);
 }