using EmreIstikam001.component.TehranOffice.Components._3D_DEN_2D_YE.Olculendir;
using EmreIstikam001.component.TehranOffice.Components.Other.CustomLibrary;
using Grasshopper;
using Grasshopper.Kernel;
using Rhino.Display;
using Rhino.Geometry;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using Rhino;
using Rhino.FileIO;
using EmreIstikam001.component.TehranOffice.ToosForAll;
using Rhino.DocObjects;
using Rhino.Input.Custom;
using static EmreIstikam001.component.TehranOffice.ToosForAll.EIAttributesTl;
using EmreIstikam001.Properties;
using System.Windows.Forms;
using static EmreIstikam001.component.TehranOffice.Components.Other.CustomLibrary.CustomLibraryFrm;

namespace EmreIstikam001.component.TehranOffice.Components.Other.CustomLibrary
{
    public class CUSTOMLIBRARY : BaseGhComponent
    {
        protected override string CodeName => "KUTUPHANE";
        protected override GH_Exposure? ValidExposure => GH_Exposure.quinary;
        private readonly CustomLibraryFrm frm = new CustomLibraryFrm();
        private File3dm File;
        private readonly List<Curve> ShowCurves = new List<Curve>();
        private List<Point3d> points = new List<Point3d>();
        Point3d InsertPoint = Point3d.Origin;
        private string BlockName;
        private ObjectAttributes BlockAttribute = new ObjectAttributes();
        private List<ObjectAttributes> BlockAttributes = new List<ObjectAttributes>();
        private bool ShowGeometry = false;
        private bool Getpoint = false;
        private bool Bake = false;


        //private static CustomDisplayConduit _conduit;

        public CUSTOMLIBRARY()
          : base("KÜTÜPHANE", "CL",
            "CUSTOM LIBRARY",
            "PARDUS", "PROFİLLER")
        {
            frm.btn1.Click += RhinoImport;
            frm.btn2.Click += RhinoBake;
            frm.PictureBoxClicked += RhinoImport;
            frm.PictureBoxDoubleClicked += RhinoImport;
        }

        //private void PictureBoxDoubleClickedHandler(object sender, PictureBoxEventArgs e)
        //{
        //    // Handle the PictureBox double-click event
        //    PictureBox clickedPictureBox = e.ClickedPictureBox;
        //    // Perform your logic here, possibly calling RhinoImport2
        //}

        //private void PictureBoxClickedHandler(object sender, PictureBoxEventArgs e)
        //{
        //    // Handle the PictureBox click event
        //    PictureBox clickedPictureBox = e.ClickedPictureBox;
        //    // Perform your logic here, possibly calling RhinoImport2 or RhinoImport3
        //}

        private void RhinoImport(object sender, EventArgs e)
        {
            //points = EIGetRihnoTl.Get2PointWithShow("1 İNCİ NOKTA", "2 İNCİ NOKTA", ShowCurves, 90);
            InsertPoint = EIGetRihnoTl.Get1Point("1İNCİ NOKTA");
            Getpoint = true;
            ExpireSolution(true);
        }

        private void RhinoBake(object sender, EventArgs e)
        {
            ShowGeometry = false;
            EIShowGeomatryTl.ShowGeomatry(ShowCurves, false, 2);
            Bake = true;
            ExpireSolution(true);
        }
        protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
        {
        }
        protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
        }
        protected override void AuthenticatedSolveInstance(IGH_DataAccess DA)
        {
            frm.Show();
            var translation = Transform.Translation(InsertPoint - Point3d.Origin);
            var filePath = frm.SelectedFilePath;
            //BlockName = filePath;
            BlockName = frm.FileName;
            //var filePath = frm.fillfulPath;
            if (filePath != null)
            {
                BlockName = Path.GetFileNameWithoutExtension(BlockName);
                Getpoint = true;
                double fileSuffix;
                if (filePath.Contains(".3dm"))
                {
                    fileSuffix = 0;
                    File = Rhino.FileIO.File3dm.Read(filePath);
                }
                else
                {
                    fileSuffix = 1;
                    File = File3dmMood.Read(filePath);
                }

                var newBlockName = EIAttributesTl.EIBlocks.CreateBlockFromFile3dm(filePath, BlockName, BlockName,fileSuffix);
               
                var doc = RhinoDoc.ActiveDoc;
                var blockGeo = new List<GeometryBase>();
                var previewGeometry = new List<GeometryBase>();
                var geometries = new List<GeometryBase>();
                var attributes = new List<ObjectAttributes>();
                ShowCurves.Clear();
                blockGeo.Clear();
                var allGeometry = new List<Curve>();
                var blockAttribute = new ObjectAttributes();
                blockAttribute.SetUserString(BlockName, "0");

                foreach (var obj in File.Objects)
                {
                    attributes.Add(obj.Attributes.Duplicate());
                    var newGeo = obj.Geometry;
                    if (newGeo != null && newGeo is Curve) allGeometry.Add((Curve)newGeo);

                    geometries.Add(obj.Geometry);
                }
                var joinedCurves = Curve.JoinCurves(allGeometry);
                foreach (var crv in joinedCurves)
                {
                    if (!crv.IsClosed) crv.MakeClosed(1);
                    previewGeometry.Add(crv);
                }
                for (int i = 0; i < geometries.Count; i++)
                {
                    geometries[i].Transform(translation);
                }
                ShowCurves.AddRange(EIToolsTl.GeomatryBaseToCurveLIst(geometries));
                if (Bake)
                {
                    ShowGeometry = false;
                    Getpoint = false;
                    previewGeometry.Clear();
                    Bake = false;
                    ShowGeometry = false;
                    //EIBlocksTl.CreateAndBakeBlock(BlockName, geometries, attributes, BlockAttribute);
                    EIAttributesTl.EIBlocks.BakeBlock(BlockName, blockAttribute, translation);
                }
                if (Getpoint)
                {
                    ShowGeometry = true;
                    EIShowGeomatryTl.ShowGeomatry(ShowCurves, ShowGeometry, 2);
                }
                doc.Views.Redraw();
            }

            ShowGeometry = false;


        }
        protected override Bitmap Icon => EmreIstikam001.Properties.Resources.kutuphane;
        public override Guid ComponentGuid => new Guid("62ef59d1-4abb-45f4-b728-a80ae813b5e7");
    }


 public static string CreateBlockFromFile3dm(string FilePath, string BlockName, string BlockDescription,double fileSuffix)
 {
     var path = FilePath;
     File3dm File3d;
     if (fileSuffix == 0)
     {
        File3d = File3dm.Read(path);
     }
     else
     {
         File3d = File3dmMood.Read(path);
     }
     
     var attributes = new List<ObjectAttributes>();
     var geos = new List<GeometryBase>();
     var doc = RhinoDoc.ActiveDoc;
     foreach (var obj in File3d.Objects)
     {
         var attribute = new ObjectAttributes();
         var layerIndex = obj.Attributes.LayerIndex;
         var attribute2 = obj.Attributes;
         var layerName = File3d.Layers[layerIndex].ToString();
         var layerNew = doc.Layers.FindByFullPath(layerName, 0);
         //attribute.LayerIndex = layerNew;
         attribute2.LayerIndex = layerNew;
         //attribute.ColorSource = ObjectColorSource.ColorFromObject;
         //attribute.MaterialSource = ObjectMaterialSource.MaterialFromObject;
         // attribute.LinetypeSource = ObjectLinetypeSource.LinetypeFromLayer;
         if (obj.Geometry is Hatch)
         {
             var hObj = (Hatch)obj.Geometry;
             var hPattern = hObj.PatternIndex;
             var hpatternName = File3d.AllHatchPatterns.FindIndex(hPattern).Name;
             var hPatternNew = doc.HatchPatterns.FindName(hpatternName);
             hObj.PatternIndex = hPatternNew.Index;
             geos.Add(hObj);
         }
         else
         {
             geos.Add(obj.Geometry);
         }
         attributes.Add(attribute2);
     }

     var blockNameNew = CreateBlockName(BlockName);
     var block = CreateBlock(blockNameNew, "block description", geos, attributes);
     return block;
 }
public static Guid BakeBlock(string BlockName, ObjectAttributes Attribute, Transform blockTransform)
{
    var guid = Guid.NewGuid();
    var doc = RhinoDoc.ActiveDoc;
    var Block = doc.InstanceDefinitions.Find(BlockName, false);
    guid = doc.Objects.AddInstanceObject(Block.Index, blockTransform, Attribute);
    return guid; 
}

}

I have this code for importing from another file.
I want to refactor the importing logic to get two point from user and orient the imported file based on the points user input. something like this :
 public static List<Point3d> Get2PointWithShow(string command, string command2, List<Curve> showxCurve,
     double rotate)
 {
     var points = new List<Point3d>();
     Point3d pt0;
     using (var getPointAction = new GetPoint())
     {
         getPointAction.SetCommandPrompt(command);
         if (getPointAction.Get() != GetResult.Point)
         {
             RhinoApp.WriteLine("No select the point to draw Profile");
             getPointAction.CommandResult();
         }
         pt0 = getPointAction.Point();
     }
public static void Orient2Points(Point3d pt1, Point3d pt2, List<GeometryBase> geoCollection)
{
    var moVector3d = pt1 - pt2;
    var crossVector3d = Vector3d.CrossProduct(moVector3d, -Vector3d.ZAxis);
    var move = Transform.PlaneToPlane(Plane.WorldXY, new Plane(pt1, -moVector3d, -crossVector3d));
    foreach (var OBJ in geoCollection) OBJ.Transform(move);
}