Example #1
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            PointF loc;
            SizeF  afm;
            float  hoek;

            CalcEllipsWaarden(f1.Coordinaat, f2.Coordinaat, p.Coordinaat, out loc, out afm, out hoek);

            #region Assenstelsel draaien
            System.Drawing.Drawing2D.Matrix oudematrix = gr.Transform;
            System.Drawing.Drawing2D.Matrix transform  = new System.Drawing.Drawing2D.Matrix();
            transform.RotateAt((float)(hoek * 180 / Math.PI), tek.Offset);
            gr.Transform = transform;
            #endregion

            PointF loc2 = tek.co_pt(loc, gr.DpiX, gr.DpiY);

            if (fill)
            {
                gr.DrawFillEllipse(GetPen(false), GetBrush(gr, tek.Schaal, tek.Offset, false), loc2.X, loc2.Y, afm.Width * tek.Schaal / 2.54f * gr.DpiX, afm.Height * tek.Schaal / 2.54f * gr.DpiY);
            }
            else
            {
                gr.DrawEllipse(GetPen(false), loc2.X, loc2.Y, afm.Width * tek.Schaal / 2.54f * gr.DpiX, afm.Height * tek.Schaal / 2.54f * gr.DpiY);
            }

            #region Assenstelsel herstellen
            gr.Transform = oudematrix;
            #endregion
        }
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            PointF M; float straal;

            Cirkel.CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, Punten[2].Coordinaat, out M, out straal);
            PointF Mtek = tek.co_pt(new PointF(M.X, M.Y), gr.DpiX, gr.DpiY);

            double a0 = Math.Atan2(punten[0].Coordinaat.Y - M.Y, punten[0].Coordinaat.X - M.X) / Math.PI * 180;
            double a1 = Math.Atan2(punten[1].Coordinaat.Y - M.Y, punten[1].Coordinaat.X - M.X) / Math.PI * 180;
            double a2 = Math.Atan2(punten[2].Coordinaat.Y - M.Y, punten[2].Coordinaat.X - M.X) / Math.PI * 180;

            float start = (float)a0;
            float angle = (float)(a2 - a0);

            if (!((a0 < a1) & (a1 < a2)) & !((a2 < a1) & (a1 < a0)))
            {
                if (angle < 0)
                {
                    angle += 360;
                }
                else
                {
                    angle -= 360;
                }
            }

            if (fill)
            {
                gr.FillPie(GetBrush(gr, tek.Schaal, tek.Offset, false), Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY, start, angle);
            }
            gr.DrawPie(GetPen(false), Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY, start, angle);
        }
Example #3
0
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            if ((f1 == null) | (f2 == null))
            {
                return;
            }
            PointF loc;
            SizeF  afm;
            float  hoek;

            CalcEllipsWaarden(f1.Coordinaat, f2.Coordinaat, loc_co, out loc, out afm, out hoek);

            #region Assenstelsel draaien
            System.Drawing.Drawing2D.Matrix oudematrix = gr.Transform;
            System.Drawing.Drawing2D.Matrix transform  = new System.Drawing.Drawing2D.Matrix();
            transform.RotateAt((float)(hoek * 180 / Math.PI), tek.Offset);
            gr.Transform = transform;
            #endregion

            PointF loc2 = tek.co_pt(loc, gr.DpiX, gr.DpiY);

            gr.DrawFillEllipse(GetPen(false), GetBrush(gr, tek.Schaal, new PointF(), false), loc2.X, loc2.Y, afm.Width * tek.Schaal / 2.54f * gr.DpiX, afm.Height * tek.Schaal / 2.54f * gr.DpiY);

            #region Assenstelsel herstellen
            gr.Transform = oudematrix;
            #endregion
        }
Example #4
0
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            if (tek.Actie == enActie.Nieuwe_cirkel2)
            {
                if (punten.Count == 1)
                {
                    PointF pt1 = tek.co_pt(Punten[0].Coordinaat, gr.DpiX, gr.DpiY);
                    PointF pt2 = tek.co_pt(loc_co, gr.DpiX, gr.DpiY);

                    float r = (float)Math.Sqrt(Math.Pow(pt1.X - pt2.X, 2) + Math.Pow(pt1.Y - pt2.Y, 2));

                    gr.DrawFillEllipse(GetPen(false), GetBrush(gr, tek.Schaal, new PointF(), false), pt1.X - r, pt1.Y - r, 2 * r, 2 * r);
                }
            }
            else if (tek.Actie == enActie.Nieuwe_cirkel3)
            {
                if (punten.Count == 2)
                {
                    PointF M; float straal;
                    CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, loc_co, out M, out straal);
                    PointF Mtek = tek.co_pt(new PointF(M.X, M.Y), gr.DpiX, gr.DpiY);
                    Brush  br   = GetBrush(gr, tek.Schaal, new PointF(), false);
                    gr.DrawFillEllipse(GetPen(false), br, Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY);
                }
            }
        }
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            if (punten.Count != 2)
            {
                return;
            }
            PointF M; float straal;

            Cirkel.CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, loc_co, out M, out straal);
            PointF Mtek = tek.co_pt(new PointF(M.X, M.Y), gr.DpiX, gr.DpiY);

            double a0 = Math.Atan2(punten[0].Coordinaat.Y - M.Y, punten[0].Coordinaat.X - M.X) / Math.PI * 180;
            double a1 = Math.Atan2(punten[1].Coordinaat.Y - M.Y, punten[1].Coordinaat.X - M.X) / Math.PI * 180;
            double a2 = Math.Atan2(loc_co.Y - M.Y, loc_co.X - M.X) / Math.PI * 180;

            float start = (float)a0;
            float angle = (float)(a2 - a0);

            if (!((a0 < a1) & (a1 < a2)) & !((a2 < a1) & (a1 < a0)))
            {
                if (angle < 0)
                {
                    angle += 360;
                }
                else
                {
                    angle -= 360;
                }
            }

            gr.FillPie(GetBrush(gr, tek.Schaal, new PointF(), false), Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY, start, angle);
            gr.DrawPie(GetPen(false), Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY, start, angle);
        }
Example #6
0
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            if (punten.Count != 2)
            {
                return;
            }
            PointF M; float R;

            Cirkel.CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, loc_co, out M, out R);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            float Rtek = R * tek.Schaal * gr.DpiX / 2.54f;

            double hoek1 = (Math.Atan2(punten[0].Coordinaat.Y - M.Y, punten[0].Coordinaat.X - M.X) / Math.PI * 180);
            double hoek2 = (Math.Atan2(punten[1].Coordinaat.Y - M.Y, punten[1].Coordinaat.X - M.X) / Math.PI * 180);
            double hoek3 = (Math.Atan2(loc_co.Y - M.Y, loc_co.X - M.X) / Math.PI * 180);

            float start = (float)hoek1;
            float angle = (float)(hoek3 - hoek1);

            if (!((hoek1 < hoek2) & (hoek2 < hoek3)) & !((hoek3 < hoek2) & (hoek2 < hoek1)))
            {
                if (angle < 0)
                {
                    angle += 360;
                }
                else
                {
                    angle -= 360;
                }
            }

            gr.DrawArc(GetPen(false), Mtek.X - Rtek, Mtek.Y - Rtek, 2 * Rtek, 2 * Rtek, start, angle);
        }
Example #7
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            IEnumerable <Point> ptn = punten.Select(T => tek.co_pt(T.Coordinaat, gr.DpiX, gr.DpiY));

            Pen pen = (Pen)GetPen(false).Clone();

            if (Geselecteerd)
            {
                Pen selectie = new Pen(Color.Black, pen.Width + 2);
                pen.Width += 1;
                gr.DrawCurve(selectie, ptn.ToArray(), tension);
                gr.DrawCurve(pen, ptn.ToArray(), tension);
            }
            else
            {
                if (widepen)
                {
                    pen.Width    += 2;
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                }
                if (ptn.Count() >= 2)
                {
                    gr.DrawCurve(pen, ptn.ToArray(), tension);
                }
            }
        }
Example #8
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if (Punten.Count == 2)
            {
                PointF pt1 = tek.co_pt(Punten[0].Coordinaat, gr.DpiX, gr.DpiY);
                PointF pt2 = tek.co_pt(Punten[1].Coordinaat, gr.DpiX, gr.DpiY);

                float r = (float)Math.Sqrt(Math.Pow(pt1.X - pt2.X, 2) + Math.Pow(pt1.Y - pt2.Y, 2));

                if (fill)
                {
                    gr.DrawFillEllipse(GetPen(false), GetBrush(gr, tek.Schaal, tek.Offset, false), pt1.X - r, pt1.Y - r, 2 * r, 2 * r);
                }
                else
                {
                    gr.DrawEllipse(GetPen(false), pt1.X - r, pt1.Y - r, 2 * r, 2 * r);
                }
            }
            else if (punten.Count > 2)
            {
                PointF M; float straal;
                CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, Punten[2].Coordinaat, out M, out straal);
                PointF Mtek = tek.co_pt(new PointF(M.X, M.Y), gr.DpiX, gr.DpiY);
                Brush  br   = GetBrush(gr, tek.Schaal, tek.Offset, false);
                if (fill)
                {
                    gr.DrawFillEllipse(GetPen(false), br, Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY);
                }
                else
                {
                    gr.DrawEllipse(GetPen(false), Mtek.X - straal * tek.Schaal / 2.54f * gr.DpiX, Mtek.Y - straal * tek.Schaal / 2.54f * gr.DpiY, 2 * straal * tek.Schaal / 2.54f * gr.DpiX, 2 * straal * tek.Schaal / 2.54f * gr.DpiY);
                }
            }
        }
Example #9
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((punt1 == null) | (punt2 == null))
            {
                return;
            }
            Point p1  = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
            Point p2  = tek.co_pt(punt2.Coordinaat, gr.DpiX, gr.DpiY);
            Pen   pen = (Pen)GetPen(false).Clone();

            if (Geselecteerd)
            {
                Pen selectie = new Pen(Color.Black, pen.Width + 2);
                pen.Width += 1;
                gr.DrawLine(selectie, p1, p2);
                gr.DrawLine(pen, p1, p2);
            }
            else
            {
                if (widepen)
                {
                    pen.Width    += 2;
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                }
                else if (accent)
                {
                    pen.Width += 2;
                }
                gr.DrawLine(pen, p1, p2);
            }
        }
Example #10
0
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            IEnumerable <Point> ptn = punten.Select(T => T.Coordinaat).Combine(loc_co).Select(T => tek.co_pt(T, gr.DpiX, gr.DpiY));

            if (ptn.Count() >= 2)
            {
                gr.DrawCurve(GetPen(false), ptn.ToArray(), tension);
            }
        }
Example #11
0
 public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
 {
     Point[] pt = punten.Select(T => T.Coordinaat).Combine(loc_co).Select(T => tek.co_pt(T, gr.DpiX, gr.DpiY)).ToArray();
     if (pt.Length < 2)
     {
         return;
     }
     gr.FillPolygon(GetBrush(gr, tek.Schaal, tek.Offset, false), pt);
     gr.DrawPolygon(GetPen(false), pt);
 }
Example #12
0
        public override Region GetRegion(Tekening tek)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return(new Region());
            }
            Graphics gr = tek.CreateGraphics();

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)(richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First())).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * tek.Schaal * gr.DpiX / 2.54f;

            GraphicsPath path = new GraphicsPath();

            path.AddArc((float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            return(new Region(path));
        }
Example #13
0
        public override Region GetRegion(Tekening tek)
        {
            Graphics gr = tek.CreateGraphics();
            Point    p1 = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
            Point    p2 = tek.co_pt(punt2.Coordinaat, gr.DpiX, gr.DpiY);

            GraphicsPath path = new GraphicsPath();

            path.AddLine(p1, p2);
            return(new Region(path));
        }
Example #14
0
        public override Region GetRegion(Tekening tek)
        {
            Graphics            gr   = tek.CreateGraphics();
            IEnumerable <Point> ptn  = punten.Select(T => T.Coordinaat).Select(T => tek.co_pt(T, gr.DpiX, gr.DpiY));
            GraphicsPath        path = new GraphicsPath();

            if (ptn.Count() >= 2)
            {
                path.AddCurve(ptn.ToArray(), tension);
            }
            return(new Region(path));
        }
Example #15
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if (ref_punt != null)
            {
                return;
            }
            Point p   = tek.co_pt(Coordinaat, gr.DpiX, gr.DpiY);
            Pen   pen = Geselecteerd ? new Pen(Color.FromArgb(int.MaxValue - kleur.ToArgb()), 2) : new Pen(Kleur);
            Brush br  = Geselecteerd ? new SolidBrush(Color.FromArgb(int.MaxValue - kleur.ToArgb())) : new SolidBrush(Kleur);

            DrawPunt(gr, p, pen, br, false);
        }
Example #16
0
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            Point p = tek.co_pt(loc_co, gr.DpiX, gr.DpiY);
            float w = gr.MeasureString(text, font).Width, h = gr.MeasureString(text, font).Height;

            if (meeschalen)
            {
                w *= tek.Schaal;
                h *= tek.Schaal;
            }

            switch (uitlijning)
            {
            case ContentAlignment.MiddleLeft:
            case ContentAlignment.MiddleCenter:
            case ContentAlignment.MiddleRight:
                p.Offset(0, (int)(-h / 2));
                break;

            case ContentAlignment.BottomLeft:
            case ContentAlignment.BottomCenter:
            case ContentAlignment.BottomRight:
                p.Offset(0, (int)(-h));
                break;
            }
            switch (uitlijning)
            {
            case ContentAlignment.TopCenter:
            case ContentAlignment.MiddleCenter:
            case ContentAlignment.BottomCenter:
                p.Offset((int)(-w / 2), 0);
                break;

            case ContentAlignment.TopRight:
            case ContentAlignment.MiddleRight:
            case ContentAlignment.BottomRight:
                p.Offset((int)(-w), 0);
                break;
            }

            Brush br = new SolidBrush(Color.FromArgb((int)(2.55f * Zichtbaarheid), kleur));

            if (meeschalen)
            {
                // muteer font en wijzig enkel size
                Font f2 = new Font(font.Name, font.Size * tek.Schaal, font.Style, font.Unit);
                gr.DrawString(text, f2, br, p);
            }
            else
            {
                gr.DrawString(text, font, br, p);
            }
        }
Example #17
0
 public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
 {
     Point[] pt = punten.Select(T => tek.co_pt(T.Coordinaat, gr.DpiX, gr.DpiY)).ToArray();
     if (pt.Length < 2)
     {
         return;
     }
     if (fill)
     {
         gr.FillPolygon(GetBrush(gr, tek.Schaal, tek.Offset, false), pt);
     }
     gr.DrawPolygon(GetPen(false), pt);
 }
Example #18
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if (punten.Count != 3)
            {
                return;
            }
            PointF M; float R;

            Cirkel.CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, Punten[2].Coordinaat, out M, out R);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            float Rtek = R * tek.Schaal * gr.DpiX / 2.54f;

            double hoek1 = (Math.Atan2(punten[0].Coordinaat.Y - M.Y, punten[0].Coordinaat.X - M.X) / Math.PI * 180);
            double hoek2 = (Math.Atan2(punten[1].Coordinaat.Y - M.Y, punten[1].Coordinaat.X - M.X) / Math.PI * 180);
            double hoek3 = (Math.Atan2(punten[2].Coordinaat.Y - M.Y, punten[2].Coordinaat.X - M.X) / Math.PI * 180);

            float start = (float)hoek1;
            float angle = (float)(hoek3 - hoek1);

            if (!((hoek1 < hoek2) & (hoek2 < hoek3)) & !((hoek3 < hoek2) & (hoek2 < hoek1)))
            {
                if (angle < 0)
                {
                    angle += 360;
                }
                else
                {
                    angle -= 360;
                }
            }

            Pen pen = (Pen)GetPen(false).Clone();

            if (Geselecteerd)
            {
                Pen selectie = new Pen(Color.Black, pen.Width + 2);
                pen.Width += 1;
                gr.DrawArc(selectie, Mtek.X - Rtek, Mtek.Y - Rtek, 2 * Rtek, 2 * Rtek, start, angle);
                gr.DrawArc(pen, Mtek.X - Rtek, Mtek.Y - Rtek, 2 * Rtek, 2 * Rtek, start, angle);
            }
            else
            {
                if (widepen)
                {
                    pen.Width    += 2;
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                }
                gr.DrawArc(pen, Mtek.X - Rtek, Mtek.Y - Rtek, 2 * Rtek, 2 * Rtek, start, angle);
            }
        }
Example #19
0
        public bool Intersect(Tekening tekening, RectangleF sel)
        {
            if (sel.Width == 0 | sel.Height == 0)
            {
                return(false);
            }
            Bitmap   bmp = new Bitmap((int)sel.Width, (int)sel.Height);
            Graphics gr  = Graphics.FromImage(bmp);

            gr.TranslateTransform(-sel.Left, -sel.Top);
            Draw(tekening, gr, false, false);

            Color trans = Color.FromArgb(0, 0, 0, 0);

            return(!bmp.IsSolidColor(trans));
        }
Example #20
0
        public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
        {
            switch (tek.Actie)
            {
            case enActie.Nieuwe_rechte:
                if (punt1 == null)
                {
                    return;
                }
                PointF p1 = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
                PointF p2 = tek.co_pt(loc_co, gr.DpiX, gr.DpiY);
                gr.DrawLine(GetPen(false), p1, p2);
                break;

            case enActie.Nieuwe_parallelle:
                Rechte r   = (Rechte)ref_vormen.First();
                PointF pt1 = tek.co_pt(r.punt1.Coordinaat, gr.DpiX, gr.DpiY);
                PointF pt2 = tek.co_pt(r.punt2.Coordinaat, gr.DpiX, gr.DpiY);

                // Rechte berekenen
                float a, b, c;
                RaakBoog.Calc_Rechte(pt1, pt2, out a, out b, out c);

                // Loodlijn 1 berekenen
                float a_l1, b_l1, c_l1;
                RaakBoog.Calc_Loodlijn(pt1, pt2, pt1, out a_l1, out b_l1, out c_l1);

                // Loodlijn 2 berekenen
                float a_l2, b_l2, c_l2;
                RaakBoog.Calc_Loodlijn(pt1, pt2, pt2, out a_l2, out b_l2, out c_l2);

                // Evenwijdige berekenen
                float  a_p, b_p, c_p;
                PointF temp = tek.PointToClient(Control.MousePosition);
                if (ref_vormen.Where(T => T.Vorm_Type == Vorm_type.Punt).Count() != 0)
                {
                    temp = tek.co_pt(ref_vormen.Where(T => T.Vorm_Type == Vorm_type.Punt).Select(T => (Punt)T).First().Coordinaat, gr.DpiX, gr.DpiY);
                }
                RaakBoog.Calc_Loodlijn(a_l1, b_l1, c_l1, temp, out a_p, out b_p, out c_p);

                PointF s1 = RaakBoog.Calc_Snijpunt(a_l1, b_l1, c_l1, a_p, b_p, c_p);
                PointF s2 = RaakBoog.Calc_Snijpunt(a_l2, b_l2, c_l2, a_p, b_p, c_p);

                gr.DrawLine(GetPen(false), s1, s2);
                break;
            }
        }
Example #21
0
        public override Region GetRegion(Tekening tek)
        {
            if ((punt1 == null) | (punt2 == null))
            {
                return(new Region());
            }

            Graphics gr = tek.CreateGraphics();
            PointF   p1 = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
            PointF   p2 = tek.co_pt(punt2.Coordinaat, gr.DpiX, gr.DpiY);

            double alfa = Math.Atan2(punt1.Coordinaat.Y - punt2.Coordinaat.Y, punt1.Coordinaat.X - punt2.Coordinaat.X);
            double beta = alfa + Math.PI / 2;

            double dx = offset * Math.Cos(beta);
            double dy = offset * Math.Sin(beta);

            GraphicsPath path = new GraphicsPath();

            path.AddLine((float)(p1.X + dx), (float)(p1.Y + dy), (float)(p2.X + dx), (float)(p2.Y + dy));
            return(new Region(path));
        }
Example #22
0
        public override Region GetRegion(Tekening tek)
        {
            if (punten.Count != 2)
            {
                return(new Region(new Rectangle(0, 0, 0, 0)));
            }
            Graphics gr = tek.CreateGraphics();
            PointF   M; float R;

            Cirkel.CalcCirkelWaarden(Punten[0].Coordinaat, Punten[1].Coordinaat, Punten[2].Coordinaat, out M, out R);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            float Rtek = R * tek.Schaal * gr.DpiX / 2.54f;

            double hoek1 = (Math.Atan2(punten[0].Coordinaat.Y - M.Y, punten[0].Coordinaat.X - M.X) / Math.PI * 180);
            double hoek2 = (Math.Atan2(punten[1].Coordinaat.Y - M.Y, punten[1].Coordinaat.X - M.X) / Math.PI * 180);
            double hoek3 = (Math.Atan2(Punten[2].Coordinaat.Y - M.Y, Punten[2].Coordinaat.X - M.X) / Math.PI * 180);

            float start = (float)hoek1;
            float angle = (float)(hoek3 - hoek1);

            if (!((hoek1 < hoek2) & (hoek2 < hoek3)) & !((hoek3 < hoek2) & (hoek2 < hoek1)))
            {
                if (angle < 0)
                {
                    angle += 360;
                }
                else
                {
                    angle -= 360;
                }
            }

            GraphicsPath path = new GraphicsPath();

            path.AddArc(Mtek.X - Rtek, Mtek.Y - Rtek, 2 * Rtek, 2 * Rtek, start, angle);
            return(new Region(path));
        }
Example #23
0
 public override Region GetRegion(Tekening tek)
 {
     return(new Region());
 }
Example #24
0
 public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
 {
     DrawPunt(gr, tek.co_pt(loc_co, gr.DpiX, gr.DpiY), new Pen(kleur), new SolidBrush(kleur), false);
 }
Example #25
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((punt1 == null) | (punt2 == null))
            {
                return;
            }
            PointF p1 = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
            PointF p2 = tek.co_pt(punt2.Coordinaat, gr.DpiX, gr.DpiY);

            double alfa = Math.Atan2(punt1.Coordinaat.Y - punt2.Coordinaat.Y, punt1.Coordinaat.X - punt2.Coordinaat.X);
            double beta = alfa + Math.PI / 2;

            double dx = offset * tek.Schaal * Math.Cos(beta);
            double dy = offset * tek.Schaal * Math.Sin(beta);
            double sx = 5 * Math.Cos(beta);
            double sy = 5 * Math.Sin(beta);

            double t = 3 + 2 * LijnDikte;

            Pen pen  = (Pen)GetPen(false).Clone();                              // hoofdlijn
            Pen pen1 = new Pen(Geselecteerd ? Color.White : Color.Black, 1);    // hulplijnen

            double dbl_l = Ellips.Pyt(punt1.Coordinaat, punt2.Coordinaat);
            string l     = dbl_l.ToString("0.000");
            int    i     = ((dbl_l * tek.Schaal / 2.54f * gr.DpiX) < 50) ? -1 : 1;

            if (Geselecteerd)
            {
                Pen selectie  = new Pen(Color.Black, pen.Width + 2);
                Pen selectie1 = new Pen(Color.Black, 3);
                pen.Width += 1; pen1.Width += 1;

                gr.DrawLine(selectie1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                gr.DrawLine(selectie, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                gr.DrawLine(selectie1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));

                gr.DrawLine(pen1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                gr.DrawLine(pen, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                gr.DrawLine(pen1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));

                gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                    new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                    new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                selectie1.Width = 1;
                gr.DrawPolygon(selectie1, new PointF[] {
                    new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                gr.DrawPolygon(selectie1, new PointF[] {
                    new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                });

                Font f = new Font(FontFamily.GenericMonospace, 12);
                gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                SizeF size = gr.MeasureString(l, f);
                gr.TranslateTransform(-size.Width / 2, -size.Height - offset * tek.Schaal);

                GraphicsPath path = new GraphicsPath();
                path.AddString(l, f.FontFamily, (int)f.Style, f.SizeInPoints * 1.3f, new PointF(), new StringFormat());
                gr.DrawPath(Pens.Black, path);
                gr.FillPath(new SolidBrush(Color.FromArgb(255, pen.Color)), path);
                gr.ResetTransform();
            }
            else
            {
                Font f = new Font(FontFamily.GenericMonospace, 12);
                if (widepen)
                {
                    gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                    SizeF size = gr.MeasureString(l, f);
                    gr.TranslateTransform(-size.Width / 2, -size.Height - offset);
                    gr.FillRectangle(Brushes.Black, 0, 0, size.Width, size.Height);
                    gr.ResetTransform();
                }
                else
                {
                    gr.DrawLine(pen1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                    gr.DrawLine(pen, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                    gr.DrawLine(pen1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));
                    gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                        new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                        new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                        new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                    });
                    gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                        new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                        new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                        new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                    });


                    gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                    SizeF size = gr.MeasureString(l, f);
                    gr.TranslateTransform(-size.Width / 2, -size.Height - offset * tek.Schaal);
                    gr.DrawString(l, f, new SolidBrush(LijnKleur), new PointF());
                    gr.ResetTransform();
                }
            }
        }
Example #26
0
 public VormenToegevoegdActie(Vorm[] Vormen, Tekening tek)
     : base(Vormen)
 {
     this.tek = tek;
 }
Example #27
0
 public override void Draw(Tekening tek, Graphics gr, PointF loc_co, Vorm[] ref_vormen)
 {
 }
Example #28
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return;
            }

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)(richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First())).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * tek.Schaal * gr.DpiX / 2.54f;


            Pen pen = (Pen)GetPen(false).Clone();

            if (Geselecteerd)
            {
                Pen selectie = new Pen(Color.Black, pen.Width + 2);
                pen.Width += 1;


                gr.DrawArc(selectie, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
                gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            }
            else
            {
                if (widepen)
                {
                    pen.Width    += 2;
                    pen.DashStyle = DashStyle.Solid;
                }
                gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            }
        }
Example #29
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            Point p = tek.co_pt(punt.Coordinaat, gr.DpiX, gr.DpiY);
            float w = gr.MeasureString(text, font).Width, h = gr.MeasureString(text, font).Height;

            if (meeschalen)
            {
                w *= tek.Schaal;
                h *= tek.Schaal;
            }

            switch (uitlijning)
            {
            case ContentAlignment.MiddleLeft:
            case ContentAlignment.MiddleCenter:
            case ContentAlignment.MiddleRight:
                p.Offset(0, (int)(-h / 2));
                break;

            case ContentAlignment.BottomLeft:
            case ContentAlignment.BottomCenter:
            case ContentAlignment.BottomRight:
                p.Offset(0, (int)(-h));
                break;
            }
            switch (uitlijning)
            {
            case ContentAlignment.TopCenter:
            case ContentAlignment.MiddleCenter:
            case ContentAlignment.BottomCenter:
                p.Offset((int)(-w / 2), 0);
                break;

            case ContentAlignment.TopRight:
            case ContentAlignment.MiddleRight:
            case ContentAlignment.BottomRight:
                p.Offset((int)(-w), 0);
                break;
            }
            if (widepen)
            {
                gr.FillRectangle(Brushes.Black, p.X, p.Y, w, h);
            }
            else
            {
                Brush br = new SolidBrush(Color.FromArgb((int)(2.55f * Zichtbaarheid), kleur));
                if (meeschalen)
                {
                    // muteer font en wijzig enkel size
                    Font f2 = new Font(font.Name, font.Size * tek.Schaal, font.Style, font.Unit);
                    gr.DrawString(text, f2, br, p);
                }
                else
                {
                    gr.DrawString(text, font, br, p);
                }
            }

            if (Geselecteerd)
            {
                gr.DrawRectangle(new Pen(Color.Black)
                {
                    DashStyle = System.Drawing.Drawing2D.DashStyle.Custom, DashPattern = new float[] { 6, 3 }
                }, p.X, p.Y, w, h);
            }
        }
Example #30
0
        public override void Compleet(Schets s, Point p1, Point p2)
        {
            int breedte = maxX - minX + 6;
            int hoogte = maxY - minY + 6;

            Point min = new Point(minX - 3, minY - 3);
            Point max = new Point(maxX + 3, maxY + 3);

            Bitmap minibitmap = new Bitmap(breedte, hoogte);
            Graphics g = Graphics.FromImage(minibitmap);

            g.DrawImage(bitmap, 0, 0, Tools.Punten2Rechthoek(min, max), GraphicsUnit.Pixel);

            Tekening tekening = new Tekening(kleur, minibitmap, min);
            s.Toevoegen(tekening);

            bitmap.Dispose();
            BitmapGraphics.Dispose();
        }
 public VormenVerwijderdActie(Vorm[] Vormen, Tekening tek)
     : base(Vormen)
 {
     this.tek = tek;
 }