示例#1
0
        public override bool Raaktpunt(Point p, Graphics g)
        {
            Rectangle rect = TweepuntTool.Punten2Rechthoek(startpunt, eindpunt);
            double    h    = rect.Location.X + rect.Width / 2;
            double    k    = rect.Location.Y + rect.Height / 2;
            double    rx   = rect.Width / 2;
            double    ry   = rect.Height / 2;

            double d = Math.Pow((p.X - h), 2) / Math.Pow(rx, 2) +
                       Math.Pow((p.Y - k), 2) / Math.Pow(ry, 2);

            if (d <= 1.1)
            {
                if (gevuld)
                {
                    return(true);
                }

                else
                {
                    return(d >= 0.9);
                }
            }

            return(false);
        }
示例#2
0
        public override void Bezig(SchetsControl s, Point p1, Point p2)
        {
            Pen dashedPen = new Pen(Color.Black, 1);

            dashedPen.DashPattern = dashValues;
            s.CreateGraphics().DrawEllipse(dashedPen, TweepuntTool.Punten2Rechthoek(p1, p2));
        }
        public void DrawFigure(Graphics g)
        {
            if (this.soort == "RechthoekTool")                                                                                    //this line might activate VolRechthoekTools as well
            {
                g.DrawRectangle(TweepuntTool.MaakPen(new SolidBrush(this.kleur), 3), TweepuntTool.Punten2Rechthoek(this.startpunt, this.endpunt));
            }
            else if (this.soort == "VolRechthoekTool")                                                                            //instead of giving a type we might just use a string like if this.soort == "RechthoekTool"
            {
                g.FillRectangle(new SolidBrush(this.kleur), TweepuntTool.Punten2Rechthoek(this.startpunt, this.endpunt));
            }
            else if (this.soort == "CircleTool")
            {
                g.DrawEllipse(TweepuntTool.MaakPen(new SolidBrush(this.kleur), 3), TweepuntTool.Punten2Rechthoek(startpunt, endpunt));
            }
            else if (this.soort == "VolCircleTool")
            {
                g.FillEllipse(new SolidBrush(this.kleur), TweepuntTool.Punten2Rechthoek(this.startpunt, this.endpunt));
            }
            else if (this.soort == "LijnTool")
            {
                g.DrawLine(TweepuntTool.MaakPen(new SolidBrush(this.kleur), 3), this.startpunt, this.endpunt);
            }
            else if (this.soort == "PenTool")
            {
                g.DrawLine(TweepuntTool.MaakPen(new SolidBrush(this.kleur), 3), this.startpunt, this.endpunt);
            }
            else if (this.soort == "TekstTool")
            {
                Font font = new Font("Tahoma", 40);

                SizeF sz = g.MeasureString(this.text, font, this.startpunt, StringFormat.GenericTypographic);

                g.DrawString(this.text, font, (new SolidBrush(this.kleur)), this.startpunt, StringFormat.GenericTypographic);
            }
        }
示例#4
0
        public override void teken(Graphics g)
        {
            Pen       p    = TweepuntTool.MaakPen(kleur, 3);
            Rectangle rect = TweepuntTool.Punten2Rechthoek(beginpunt, eindpunt);

            g.DrawEllipse(p, rect);
        }
        private double berekenEllipse(Point p)
        {   //Met behulp van https://math.stackexchange.com/questions/76457/check-if-a-point-is-within-an-ellipse
            Rectangle myEllipse = TweepuntTool.Punten2Rechthoek(beginPunt, eindPunt);
            double    h         = (Math.Abs(eindPunt.X + beginPunt.X) / 2);
            double    k         = (Math.Abs(eindPunt.Y + beginPunt.Y) / 2);
            double    rx        = myEllipse.Width / 2;
            double    ry        = myEllipse.Height / 2;

            return((((p.X - h) * (p.X - h)) / (rx * rx)) + (((p.Y - k) * (p.Y - k)) / (ry * ry)));
        }
示例#6
0
 public override void Teken(Graphics g)
 {
     if (pen != null)
     {
         g.DrawEllipse(pen, TweepuntTool.Punten2Rechthoek(startpunt, eindpunt));
     }
     else if (kwast != null)
     {
         g.FillEllipse(kwast, TweepuntTool.Punten2Rechthoek(startpunt, eindpunt));
     }
 }
示例#7
0
 public override void Tekenitem(Graphics g)
 {
     if (gevuld)
     {
         g.FillEllipse(kwast, TweepuntTool.Punten2Rechthoek(startpunt, eindpunt));
     }
     else
     {
         g.DrawEllipse(new Pen(kwast, 3), TweepuntTool.Punten2Rechthoek(startpunt, eindpunt));
     }
 }
示例#8
0
        // Maakt gebruik van distance between point and lijn functie
        // Sinds in wiskunde lijnen oneindig lang zijn controleren we ook of de lijn binnen een rechthoek is van de 2 coordinaten
        public override bool IsWithin(Point p1)
        {
            double t;

            if (TweepuntTool.Punten2Rechthoek(Startpoint, EindPoint).Contains(p1.X, p1.Y) &&
                (Math.Abs((EindPoint.Y - Startpoint.Y) * p1.X - (EindPoint.X - Startpoint.X) * p1.Y +
                          EindPoint.X * Startpoint.Y - EindPoint.Y * Startpoint.X) /
                 Math.Sqrt(Math.Pow(EindPoint.Y - Startpoint.Y, 2) + Math.Pow(EindPoint.X - Startpoint.X, 2))) < Dikte)
            {
                return(true);
            }

            return(false);
        }
示例#9
0
 public override void Bezig(Graphics g, Point p1, Point p2)
 {
     if ((Control.ModifierKeys & Keys.Shift) != 0)
     {
         Rectangle rect = TweepuntTool.Punten2Vierkant(p1, p2);
         g.DrawRectangle(MaakPen(kwast, brushWidth), rect);
         lastDrawnShape = new DrawnRectangle(new Point(rect.X, rect.Y), new Point(rect.Right, rect.Bottom), brushWidth, ((SolidBrush)kwast).Color);
     }
     else
     {
         g.DrawRectangle(MaakPen(kwast, brushWidth), TweepuntTool.Punten2Rechthoek(p1, p2));
         lastDrawnShape = new DrawnRectangle(p1, p2, brushWidth, ((SolidBrush)kwast).Color);
     }
 }
示例#10
0
 public override void Bezig(Graphics g, Point p1, Point p2)
 {
     if ((Control.ModifierKeys & Keys.Shift) != 0)
     {
         Rectangle rect = TweepuntTool.Punten2Vierkant(p1, p2);
         g.FillEllipse(kwast, rect);
         lastDrawnShape = new DrawnFilledEllipse(new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Bottom), schetscontrol.PenKleur);
     }
     else
     {
         g.FillEllipse(kwast, TweepuntTool.Punten2Rechthoek(p1, p2));
         lastDrawnShape = new DrawnFilledEllipse(p1, p2, schetscontrol.PenKleur);
     }
 }
示例#11
0
        public override void Bezig(Graphics g, Point p1, Point p2)
        {
            g.DrawEllipse(MaakPen(kwast, 3), TweepuntTool.Punten2Rechthoek(p1, p2));


            double Xgrootte;

            Xgrootte = Math.Abs(p1.X - p2.X);

            double Ygrootte;

            Ygrootte = Math.Abs(p1.Y - p2.Y);

            DoubleSize grootte = new DoubleSize(Xgrootte, Ygrootte);


            o.Eigenschap(this.GetType().Name, startpunt, kwast, grootte);
        }
示例#12
0
        public override bool Raaktpunt(Point p, Graphics g)
        {
            Rectangle rect = TweepuntTool.Punten2Rechthoek(startpunt, eindpunt);

            if (p.X > rect.Location.X - 4 && p.X < rect.Location.X + rect.Width + 4 &&
                p.Y > rect.Location.Y - 4 && p.Y < rect.Location.Y + rect.Height + 4)
            {
                if (gevuld)
                {
                    return(true);
                }

                else
                {
                    return(!(p.X > rect.Location.X + 4 && p.X < rect.Location.X + rect.Width - 4 &&
                             p.Y > rect.Location.Y + 4 && p.Y < rect.Location.Y + rect.Height - 4));
                }
            }
            return(false);
        }
示例#13
0
 public override bool Geklikt(Point p)
 {
     if (pen != null)
     {
         int       marge           = 5;
         Rectangle buitenrechthoek = TweepuntTool.Punten2Rechthoek(new Point(startpunt.X - marge, startpunt.Y - marge), new Point(eindpunt.X + marge, eindpunt.Y + marge));
         Rectangle binnenrechthoek = TweepuntTool.Punten2Rechthoek(new Point(startpunt.X + marge, startpunt.Y + marge), new Point(eindpunt.X - marge, eindpunt.Y - marge));
         if (buitenrechthoek.Contains(p) && !binnenrechthoek.Contains(p))
         {
             return(true);
         }
     }
     else if (kwast != null)
     {
         if (TweepuntTool.Punten2Rechthoek(startpunt, eindpunt).Contains(p))
         {
             return(true);
         }
     }
     return(false);
 }
示例#14
0
        public override bool Geklikt(Point p)
        {
            // credits to: https://stackoverflow.com/questions/13285007/how-to-determine-if-a-point-is-within-an-ellipse
            Rectangle rechthoek          = TweepuntTool.Punten2Rechthoek(startpunt, eindpunt);
            Point     center             = new Point(rechthoek.X + rechthoek.Width / 2, rechthoek.Y + rechthoek.Height / 2);
            double    xRadius            = rechthoek.Width / 2;
            double    yRadius            = rechthoek.Height / 2;
            Point     normalized         = new Point(p.X - center.X, p.Y - center.Y);
            double    normalizedDistance = ((double)(normalized.X * normalized.X) / (xRadius * xRadius)) + ((double)(normalized.Y * normalized.Y) / (yRadius * yRadius));
            float     marge = 0.05F;

            if (pen != null)
            {
                return(normalizedDistance > 1.0 - marge && normalizedDistance < 1.0 + marge);
            }
            else if (kwast != null)
            {
                return(normalizedDistance <= 1.0);
            }

            return(false);
        }
示例#15
0
 public void Draw(Graphics g, Point startPoint, Point endPoint, Brush col)
 {
     g.FillEllipse(col, TweepuntTool.Punten2Rechthoek(startPoint, endPoint));
 }
示例#16
0
 public void Draw(Graphics g, Point startPoint, Point endPoint, int width, Brush col)
 {
     g.DrawEllipse(MaakPen(col, width), TweepuntTool.Punten2Rechthoek(startPoint, endPoint));
 }
示例#17
0
 public override void Teken(Graphics g, Point p1, Point p2, Color kleur, char c)
 {
     g.FillEllipse(new SolidBrush(kleur), TweepuntTool.Punten2Rechthoek(p1, p2));
 }
示例#18
0
 public override void Teken(Graphics g, Point p1, Point p2, Color kleur, Char c)
 {
     g.DrawRectangle(MaakPen(new SolidBrush(kleur), 3), TweepuntTool.Punten2Rechthoek(p1, p2));
 }
示例#19
0
 public override void Bezig(Graphics g, Point p1, Point p2)
 {
     g.FillEllipse(kwast, TweepuntTool.Punten2Rechthoek(p1, p2));
     lijst.Add(this.GetType().Name + " " + p1 + " " + p2); //
     Console.WriteLine(lijst[0]);
 }
示例#20
0
 public override void Compleet(Graphics g, Point p1, Point p2, Brush kwast)
 {
     g.DrawRectangle(MaakPen(kwast, 3), TweepuntTool.Punten2Rechthoek(p1, p2));
 }
 public override void Bezig(Graphics g, Point p1, Point p2)
 {
     g.DrawRectangle(MaakPen(kwast, 3), TweepuntTool.Punten2Rechthoek(p1, p2));
 }
示例#22
0
 public override void teken(Graphics g)
 {
     g.FillRectangle(kleur, TweepuntTool.Punten2Rechthoek(beginpunt, eindpunt));
 }
示例#23
0
 public override void teken(Graphics g)
 {
     g.DrawRectangle(TweepuntTool.MaakPen(kleur, 3), TweepuntTool.Punten2Rechthoek(beginpunt, eindpunt));
 }
示例#24
0
 // teken tekent de lijn. Er wordt hier gebruik gemaakt van de methode MaakPen uit de klasse TweepuntTool,
 // dit kan omdat die methode statisch is.
 public override void teken(Graphics g)
 {
     g.DrawLine(TweepuntTool.MaakPen(this.kleur, 3), beginpunt.X, beginpunt.Y, eindpunt.X, eindpunt.Y);
 }
        public bool Contains(Point p)
        {
            switch (tool.ToString())
            {
            case "tekst":
                return(TweepuntTool.Punten2Rechthoek(beginPunt, eindPunt).Contains(p));

            case "vlak":
                return(TweepuntTool.Punten2Rechthoek(beginPunt, eindPunt).Contains(p));

            case "rondje":
                if (berekenEllipse(p) <= 1.1)
                {
                    return(true);
                }
                return(false);

            case "lijn":
                if (berekenLijn(p) < 25 && berekenLijn(p) > -25)
                {
                    return(true);
                }
                return(false);

            case "cirkel":
                if (berekenEllipse(p) < 1.5 && berekenEllipse(p) > 0.5)
                {
                    return(true);
                }
                return(false);

            case "kader":
                if ((beginPunt.Y - 5 <= p.Y && beginPunt.Y + 5 >= p.Y) && ((beginPunt.X <= p.X && eindPunt.X >= p.X) || (beginPunt.X >= p.X + 5 || eindPunt.X <= p.X - 5)))
                {
                    return(true);
                }
                if ((eindPunt.Y - 5 <= p.Y && eindPunt.Y + 5 >= p.Y) && ((beginPunt.X <= p.X && eindPunt.X >= p.X) || (beginPunt.X >= p.X + 5 || eindPunt.X <= p.X - 5)))
                {
                    return(true);
                }
                if ((beginPunt.Y <= p.Y + 5 && eindPunt.Y >= p.Y + 5) && (beginPunt.X <= p.X + 5 && beginPunt.X >= p.X - 5))
                {
                    return(true);
                }
                if ((beginPunt.Y <= p.Y + 5 && eindPunt.Y >= p.Y + 5) && (eindPunt.X <= p.X + 5 && eindPunt.X >= p.X - 5))
                {
                    return(true);
                }
                return(false);

            case "pen":
                if (berekenLijn(p) < 25 && berekenLijn(p) > -25)
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
示例#26
0
 public override void Compleet(Graphics g, Point p1, Point p2, Brush kwast)
 {
     g.FillEllipse(kwast, TweepuntTool.Punten2Rechthoek(p1, p2));
 }
示例#27
0
 public override void Compleet(Graphics g, Point p1, Point p2)
 {
     g.FillRectangle(kwast, TweepuntTool.Punten2Rechthoek(p1, p2));
 }
示例#28
0
        public override void teken(Graphics g)
        {
            Rectangle rect = TweepuntTool.Punten2Rechthoek(beginpunt, eindpunt);

            g.FillEllipse(kleur, rect);
        }
示例#29
0
 public override void Bezig(Graphics g, Point p1, Point p2)
 {
     g.FillEllipse(kwast, TweepuntTool.Punten2Rechthoek(p1, p2));
 }
示例#30
0
 public override void Compleet(Graphics g, Point p1, Point p2)
 {
     g.DrawEllipse(MaakPen(kwast, 3), TweepuntTool.Punten2Rechthoek(p1, p2));
 }