コード例 #1
0
 public static void AddPoint(List <float> Input)
 {
     if (Input.Count == 0)
     {
         PointF   p1       = ShapeSystem.gridSystem.cursorPosition;
         cadPoint newPoint = new cadPoint(p1);
         Console.WriteLine("Point " + newPoint.IdShape.ToString() + " created as {0}", newPoint.MetaDesc);
         ShapeSystem.UpdateSnapPoints();
         return;
     }
     else if (Input.Count == 2)
     {
         float    x1       = (Input[0]);
         float    y1       = (Input[1]);
         PointF   p1       = new PointF(x1, y1);
         cadPoint newPoint = new cadPoint(p1);
         Console.WriteLine("Point " + newPoint.IdShape.ToString() + " created as {0}", newPoint.MetaDesc);
         ShapeSystem.UpdateSnapPoints();
         return;
     }
     else
     {
         Console.WriteLine("Invalid input.");
         return;
     }
 }
コード例 #2
0
        public static void AddLine(List <float> Input)
        {
            if (ShapeSystem.gridSystem.relativePositioning && Input.Count == 2)
            {
                PointF p1 = new PointF(ShapeSystem.gridSystem.cursorPosition.X, ShapeSystem.gridSystem.cursorPosition.Y);

                float  x2      = (Input[0] + p1.X);
                float  y2      = (Input[1] + p1.Y);
                PointF p2      = new PointF(x2, y2);
                Line   RetLine = new Line(p1, p2);
                ShapeSystem.gridSystem.cursorPosition = p2;
                Console.WriteLine("Line " + RetLine.IdShape.ToString() + " created as {0}", RetLine.MetaDesc);
                ShapeSystem.UpdateSnapPoints();
                return;
            }
            if (Input.Count != 4)
            {
                Console.WriteLine("Invalid input.");
                return;
            }
            else
            {
                float  x1      = (Input[0]);
                float  y1      = (Input[1]);
                float  x2      = (Input[2]);
                float  y2      = (Input[3]);
                PointF p1      = new PointF(x1, y1);
                PointF p2      = new PointF(x2, y2);
                Line   RetLine = new Line(p1, p2);
                Console.WriteLine("Line " + RetLine.IdShape.ToString() + " created as {0}", RetLine.MetaDesc);
                ShapeSystem.gridSystem.cursorPosition = p2;
                ShapeSystem.UpdateSnapPoints();
                return;
            }
        }
コード例 #3
0
ファイル: Ellipse.cs プロジェクト: dankelley2/WinFormCAD
 public static void AddEllipse(List <float> Input)
 {
     if (Input.Count() == 1)
     {
         PointF  P1        = ShapeSystem.gridSystem.cursorPosition;
         float   R         = Input[0];
         Ellipse retCircle = new Ellipse(P1, R);
         Console.WriteLine("Ellipse " + retCircle.IdShape.ToString() + " created as {0}", retCircle.MetaDesc);
         ShapeSystem.UpdateSnapPoints();
         return;
     }
     else if (Input.Count() == 3)
     {
         PointF  P1        = new PointF(Input[0], Input[1]);
         float   R         = Input[2];
         Ellipse retCircle = new Ellipse(P1, R);
         Console.WriteLine("Ellipse " + retCircle.IdShape.ToString() + " created as {0}", retCircle.MetaDesc);
         ShapeSystem.UpdateSnapPoints();
         return;
     }
     else
     {
         Console.WriteLine("Invalid input for Ellipse.");
     }
 }
コード例 #4
0
ファイル: ShapeSystem.cs プロジェクト: dankelley2/WinFormCAD
        public static bool RemoveActiveShape()
        {
            Shape S = ShapeSystem.ShapeList.Where(s => s.isActiveShape == true).FirstOrDefault();

            if (S != null)
            {
                ShapeSystem.ShapeList.Remove(S);
                DT_ShapeList.Rows.Remove(DT_ShapeList.Rows.Find(S.IdShape));
                ShapeSystem.UpdateSnapPoints();
                return(true);
            }
            return(false);
        }
コード例 #5
0
ファイル: ShapeSystem.cs プロジェクト: dankelley2/WinFormCAD
        public static void ClearData()
        {
            List <int> ShapeIds = new List <int>();

            foreach (Shape S in ShapeSystem.ShapeList)
            {
                ShapeIds.Add(S.IdShape);
            }
            foreach (int I in ShapeIds)
            {
                RemoveShapeById(I);
            }
            ShapeSystem.UpdateSnapPoints();
        }
コード例 #6
0
ファイル: CadSystem.cs プロジェクト: dankelley2/CADLib
 public bool DeSerializeAndLoadShapes(string fileName)
 {
     try
     {
         Snapshot snapshot = DeserializeFromFile <Snapshot>(fileName);
         ShapeSystem.ClearData();
         snapshot.Load();
         ShapeSystem.UpdateSnapPoints();
         Console.WriteLine("Shape system \"{0}\" loaded.", fileName);
     }
     catch (Exception e)
     {
         Console.WriteLine("An error occoured: {0}", e.Message);
     }
     return(false);
 }
コード例 #7
0
ファイル: Rectangle.cs プロジェクト: dankelley2/WinFormCAD
        public static void AddRect(List <float> Input)
        {
            //Width and height from cursor
            if (ShapeSystem.gridSystem.relativePositioning && Input.Count == 2)
            {
                PointF cursor  = new PointF(ShapeSystem.gridSystem.cursorPosition.X, ShapeSystem.gridSystem.cursorPosition.Y);
                PointF p1      = new PointF(Math.Min(cursor.X, cursor.X + Input[0]), Math.Min(cursor.Y, cursor.Y + Input[1]));
                PointF p2      = new PointF(Math.Max(cursor.X, cursor.X + Input[0]), Math.Min(cursor.Y, cursor.Y + Input[1]));
                PointF p3      = new PointF(Math.Max(cursor.X, cursor.X + Input[0]), Math.Max(cursor.Y, cursor.Y + Input[1]));
                PointF p4      = new PointF(Math.Min(cursor.X, cursor.X + Input[0]), Math.Max(cursor.Y, cursor.Y + Input[1]));
                Rect   RetRect = new Rect(p1, p2, p3, p4);
                ShapeSystem.gridSystem.cursorPosition = cursor;
                Console.WriteLine("Rectangle " + RetRect.IdShape.ToString() + " created as {0}", RetRect.MetaDesc);
                ShapeSystem.UpdateSnapPoints();
                return;
            }
            if (Input.Count != 4)
            {
                Console.WriteLine("Invalid input.");
                return;
            }
            else
            {
                PointF pRef = new PointF(Input[0], Input[1]);
                PointF p1   = new PointF(Math.Min(pRef.X, pRef.X + Input[2]), Math.Min(pRef.Y, pRef.Y + Input[3]));
                PointF p2   = new PointF(Math.Max(pRef.X, pRef.X + Input[2]), Math.Min(pRef.Y, pRef.Y + Input[3]));
                PointF p3   = new PointF(Math.Max(pRef.X, pRef.X + Input[2]), Math.Max(pRef.Y, pRef.Y + Input[3]));
                PointF p4   = new PointF(Math.Min(pRef.X, pRef.X + Input[2]), Math.Max(pRef.Y, pRef.Y + Input[3]));

                Rect RetRect = new Rect(p1, p2, p3, p4);
                ShapeSystem.gridSystem.cursorPosition = pRef;
                Console.WriteLine("Rectangle " + RetRect.IdShape.ToString() + " created as {0}", RetRect.MetaDesc);
                ShapeSystem.UpdateSnapPoints();
                return;
            }
        }