private void PictureBox_Click(object sender, MouseEventArgs e)
        {
            //Used to check how close the click is to the first point
            DetectIfPointIsInside ifPointIsInside = new DetectIfPointIsInside(((PictureBox)sender).Width);
            bool doesIntersect = false;

            //Gets the position of the mouse cursor inside the picturebox
            PictureBox pic              = (PictureBox)sender;
            var        screenPosition   = pic.PointToScreen(new Point(0, 0));
            double     percentageOfZoom = 0;

            //Grbs the percentage of zoom from the tab page
            foreach (NewTabPage t in tabLst)
            {
                if (t.tabName == pic.Name)
                {
                    percentageOfZoom = t.percentageOfZoom;
                    break;
                }
            }

            //Maybe I should put this in its own fuction seen as it's repeated so many times
            double xCoordinate = Cursor.Position.X;
            double yCoordinate = Cursor.Position.Y;
            Point  cP          = new Point((int)((xCoordinate - screenPosition.X) / (percentageOfZoom / 100)), (int)((yCoordinate - screenPosition.Y) / (percentageOfZoom / 100)));

            foreach (DisplayPage d in pageLst)
            {
                if (d.displayPageName == ((PictureBox)sender).Name)
                {
                    foreach (CustomButton b in d.GetButtonList())
                    {
                        if (ifPointIsInside.DoesIntersect(b.GetPoly(), b.GetPoly().Length, cP))
                        {
                            doesIntersect = true;
                        }
                    }
                    foreach (CircleButton c in d.GetCircleBtnLst())
                    {
                        if (ifPointIsInside.DoesIntersectCircle(c.GetRadius(), cP, c.GetCentre()))
                        {
                            doesIntersect = true;
                        }
                    }
                    //Detects if the new line intersects with any of the others
                    if (d.GetCurrentButton().Count > 2)
                    {
                        for (int i = 0; i < d.GetCurrentButton().Count - 2; i++)
                        {
                            int next = (i + 1) % d.GetCurrentButton().Count;

                            if (ifPointIsInside.doIntersect(d.GetCurrentButton()[i], d.GetCurrentButton()[next], cP, d.GetCurrentButton()[d.GetCurrentButton().Count - 1]))
                            {
                                if (ifPointIsInside.orientation(d.GetCurrentButton()[i], cP, d.GetCurrentButton()[next]) == 0)
                                {
                                    doesIntersect = ifPointIsInside.OnSegment(d.GetCurrentButton()[i], cP, d.GetCurrentButton()[next]);
                                }
                                else
                                {
                                    doesIntersect = true;
                                }
                            }
                        }
                    }

                    if (!doesIntersect)
                    {
                        //Finds if the click is within 5px of the first point
                        //If true, the button is complete
                        if (isCreatingButton == true)
                        {
                            if (d.GetCurrentButton().Count != 0)
                            {
                                if (!ifPointIsInside.DoesIntersectCircle(5, cP, d.GetCurrentButton()[0]))
                                {
                                    d.AddPointToCurrentButton(cP);
                                }
                                else
                                {
                                    isCreatingButton  = false;
                                    btnFinish.Visible = false;
                                    btnCancel.Visible = false;
                                    break;
                                }
                            }

                            else
                            {
                                d.AddPointToCurrentButton(cP);
                                break;
                            }
                        }

                        if (isCreatingButton == false)
                        {
                            if (d.displayPageName == ((PictureBox)sender).Name)
                            {
                                d.FinishButton(currentButtonType, GetSelectedPage());
                            }

                            isCreatingButton = null;
                            break;
                        }

                        if (d.displayPageName == ((PictureBox)sender).Name && d.isCreatingCircle == true)
                        {
                            Point c = new Point((int)(cP.X - (r / 2)), (int)(cP.Y - (r / 2)));
                            d.isCreatingCircle = false;
                            d.AddCircleButton(c, r, GetSelectedPage());
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Buttons cannot intersect",
                                        "Button create error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error,
                                        MessageBoxDefaultButton.Button1);
                        break;
                    }
                }
            }
        }
        private void AlterButton_Click(object sender, EventArgs e)
        {
            //The code in this function is discgusting and almost getting to the point of spaghetti code
            //Shits getting hard to keep track of and needs to be optimised
            //Grabs the point on the picturebox the right click was made
            RightClickContextMenu rcm = new RightClickContextMenu();
            PictureBox            pic = new PictureBox();
            double percentageOfZoom   = 0;
            double xCoordinate        = 0;
            double yCoordinate        = 0;

            foreach (NewTabPage t in tabLst)
            {
                if (t.tabName == tabControlDesignerView.SelectedTab.Text)
                {
                    pic = t.picBox;
                    percentageOfZoom = t.percentageOfZoom;
                    break;
                }
            }

            foreach (RightClickContextMenu r in cmLst)
            {
                if (r.Name == tabControlDesignerView.SelectedTab.Text)
                {
                    xCoordinate = r.p.X;
                    yCoordinate = r.p.Y;
                    break;
                }
            }

            //Maybe I should put this in its own fuction seen as it's repeated so many times
            var   screenPosition = pic.PointToScreen(new Point(0, 0));
            Point p = new Point((int)((xCoordinate - screenPosition.X) / (percentageOfZoom / 100)), (int)((yCoordinate - screenPosition.Y) / (percentageOfZoom / 100)));

            DetectIfPointIsInside detectIfPoint = new DetectIfPointIsInside(projectDisplaySize.Width);

            if (p != null && p != new Point(0, 0))
            {
                foreach (DisplayPage d in pageLst)
                {
                    if (d.displayPageName == tabControlDesignerView.SelectedTab.Text)
                    {
                        foreach (CustomButton c in d.GetButtonList())
                        {
                            if (detectIfPoint.DoesIntersect(c.GetPoly(), c.GetPoly().Length, p))
                            {
                                c.SetPageLink(GetSelectedPage());
                                break;
                            }
                        }

                        foreach (CircleButton c in d.GetCircleBtnLst())
                        {
                            if (detectIfPoint.DoesIntersectCircle(c.GetRadius(), p, c.GetCentre()))
                            {
                                c.SetPageLink(GetSelectedPage());;
                                break;
                            }
                        }
                        break;
                    }
                }
            }

            else
            {
                MessageBox.Show("Error could not find the point the right click was made",
                                "INTERNAL ERROR",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }