private void ChamferStatus(object sender, EventArgs e)
 {
     if (frm.chbA.Checked) IsAChaked = true;
     else
     {
         IsAChaked = false;
         ChamferSizeA = Convert.ToDouble(frm.txtA.Text);
     }

     if (frm.chbB.Checked) IsBChaked = true;
     else
     {
         IsBChaked = false;
         ChamferSizeB = Convert.ToDouble(frm.txtB.Text);
     }

     if (frm.chbC.Checked) IsCChaked = true;
     else
     {
         IsCChaked = false;
         ChamferSizeC = Convert.ToDouble(frm.txtC.Text);
     }

     if (frm.chbD.Checked) IsDChaked = true;
     else
     {
         IsDChaked = false;
         ChamferSizeD = Convert.ToDouble(frm.txtD.Text);
     }

     ExpireSolution(true);
 }
protected override void AuthenticatedSolveInstance(IGH_DataAccess DA)
 {
     if (!closeForm)
     {
         frm.Show();
     }
     PreviewCurves.Clear();
     geometries.Clear();
     FinalCurves.Clear();
     HatcheGeometry.Clear();
     HatcheCurves.Clear();
     var doc = RhinoDoc.ActiveDoc;
     var currentDocPlane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();
     ShowPreview = true;



     // Section 1
     List<string> TurkeyMat = new List<string> { "Poliüretan", "Ahşap" };
     List<string> EnglishMat = new List<string> { "Polyurethane", "Wood" };
     List<string> RussianMat = new List<string> { "Полиуретан", "Дерево" };
     var mat = "";
     string Xdim = "";
     string Ydim = "";

     Point3d bsseLine0Start = new Point3d();
     Point3d bsseLine0End = new Point3d();
     Point3d bsseLine1Start = new Point3d();
     Point3d bsseLine1End = new Point3d();
     Point3d bsseLine2Start = new Point3d();
     Point3d bsseLine2End = new Point3d();
     Point3d bsseLine3Start = new Point3d();
     Point3d bsseLine3End = new Point3d();

     List<Point3d> allPoints = new List<Point3d>();


     if (SelectionType == 0)
     {
         if (points.Count > 2)
         {

             //Section 2
             var vec = points[1] - points[0];
             var pt = points[2] + vec;
             var parallelLine = new Line(points[2], pt);
             var scale = Transform.Scale(parallelLine.PointAt(0.5), 10);
             parallelLine.Transform(scale);
             //Section 3
             var closePt = parallelLine.ClosestPoint(points[0], true);
             //Section 4
             var plane = new Plane(points[0], points[1], closePt);
             Rectangle3d rectangle = new Rectangle3d(plane, points[0].DistanceTo(points[1]),
                 points[0].DistanceTo(closePt));

             Xdim = Convert.ToString(Math.Round(rectangle.Width, 2));
             Ydim = Convert.ToString(Math.Round(rectangle.Height, 2));


             var dup1 = rectangle.ToNurbsCurve().DuplicateSegments();
             var dup2 = rectangle.ToNurbsCurve().DuplicateSegments();
             var dup3 = rectangle.ToNurbsCurve().DuplicateSegments();
             var dup4 = rectangle.ToNurbsCurve().DuplicateSegments();

             ChamferCurveA = EIGeometeryToolsTI.ChamferCurves(dup1[0], dup1[1], ChamferSizeA, false);
             ChamferCurveB = EIGeometeryToolsTI.ChamferCurves(dup2[1], dup2[2], ChamferSizeB, false);
             ChamferCurveC = EIGeometeryToolsTI.ChamferCurves(dup3[2], dup3[3], ChamferSizeC, false);
             ChamferCurveD = EIGeometeryToolsTI.ChamferCurves(dup4[3], dup4[0], ChamferSizeD, false);



             if (!IsAChaked && !IsBChaked && !IsCChaked && !IsDChaked)
             {

                 CurveForHatch = rectangle.ToNurbsCurve();
                 geometries.Add(CurveForHatch);
                 FinalCurves.Add(CurveForHatch);
             }
             else
             {
                 Xdim = "-";
                 Ydim = "-";

                 if (IsAChaked)
                 {
                     if (ChamferCurveA != null)
                     {
                         bsseLine0End = ChamferCurveA.PointAtStart;
                         bsseLine1Start = ChamferCurveA.PointAtEnd;
                     }
                     else
                     {
                         bsseLine0End = rectangle.Corner(1);
                         bsseLine1Start = rectangle.Corner(1);
                     }
                 }
                 else
                 {
                     bsseLine0End = rectangle.Corner(1);
                     bsseLine1Start = rectangle.Corner(1);
                 }

                 if (IsBChaked)
                 {
                     if (ChamferCurveB != null)
                     {
                         bsseLine1End = ChamferCurveB.PointAtStart;
                         bsseLine2Start = ChamferCurveB.PointAtEnd;
                     }
                     else
                     {
                         bsseLine1End = rectangle.Corner(2);
                         bsseLine2Start = rectangle.Corner(2);
                     }
                 }
                 else
                 {
                     bsseLine1End = rectangle.Corner(2);
                     bsseLine2Start = rectangle.Corner(2);
                 }

                 if (IsCChaked)
                 {
                     if (ChamferCurveC != null)
                     {
                         bsseLine2End = ChamferCurveC.PointAtStart;
                         bsseLine3Start = ChamferCurveC.PointAtEnd;
                     }
                     else
                     {
                         bsseLine2End = rectangle.Corner(3);
                         bsseLine3Start = rectangle.Corner(3);
                     }
                 }
                 else
                 {
                     bsseLine2End = rectangle.Corner(3);
                     bsseLine3Start = rectangle.Corner(3);
                 }

                 if (IsDChaked)
                 {
                     if (ChamferCurveD != null)
                     {
                         bsseLine3End = ChamferCurveD.PointAtStart;
                         bsseLine0Start = ChamferCurveD.PointAtEnd;
                     }
                     else
                     {
                         bsseLine3End = rectangle.Corner(0);
                         bsseLine0Start = rectangle.Corner(0);
                     }
                 }
                 else
                 {
                     bsseLine3End = rectangle.Corner(0);
                     bsseLine0Start = rectangle.Corner(0);
                 }

                 allPoints.Add(bsseLine0Start);
                 allPoints.Add(bsseLine0End);
                 allPoints.Add(bsseLine1Start);
                 allPoints.Add(bsseLine1End);
                 allPoints.Add(bsseLine2Start);
                 allPoints.Add(bsseLine2End);
                 allPoints.Add(bsseLine3Start);
                 allPoints.Add(bsseLine3End);
                 allPoints.Add(bsseLine0Start);

                 Polyline finalCurve = new Polyline(allPoints);
                 CurveForHatch = finalCurve.ToNurbsCurve();
                 //FinalCurves.Clear();
                 FinalCurves.Add(CurveForHatch);
                 Curve.JoinCurves(FinalCurves);
                 geometries.AddRange(FinalCurves);
             }

         }


     }