/// <summary>
        /// RETURNS and SETS the Outcode of the Vector.
        /// </summary>
        /// <param name="ClippingWindow">The Renderwindow.</param>
        /// <returns></returns>
        public static int SetOutCode(this Vector vector, myRectangle ClippingWindow)
        {
            int b = 0;

            if (ClippingWindow == null)
            {
                return 0;
            }

            if (vector.X < ClippingWindow.v1.X) //left
            {
                b += 1;
            }
            if (vector.X >= ClippingWindow.v1.X && vector.X <= ClippingWindow.v2.X) //mitte
            {
                b += 0;
            }
            if (vector.X > ClippingWindow.v2.X) //right
            {
                b += 10;
            }

            if (vector.Y < ClippingWindow.v3.Y) //bottom
            {
                b += 100;
            }
            if (vector.Y > ClippingWindow.v1.Y) //top
            {
                b += 1000;
            }
            if (vector.Y >= ClippingWindow.v3.Y && vector.Y <= ClippingWindow.v1.Y) //center
            {
                b += 0;
            }
            vector.Outcode = b;
            return b;
        }
 void box_SizeChanged(object sender, EventArgs e)
 {
     ClippingWindow = new myRectangle(new Vector(gc.Parent.Width / 4, 3 * gc.Parent.Height / 4, false), new Vector(3 * (gc.Parent.Width / 4), (gc.Parent.Height / 4), false));
     UpdateLogger();
 }
        /// <summary>
        /// Creates a new Logic for the program.
        /// </summary>
        /// <param name="box">The drawing area.</param>
        /// <param name="fmMain">The main window.</param>
        /// <param name="logger">The ListView to display the vector coordinates.</param>
        public Logic(PictureBox box, FormMain fmMain, ListView logger)
        {
            gc = new GraphicCore(box);

            this.ShowCoordinates = true;

            this.UseCohenSutherlandAlgorithm = false;

            this.fmMain = fmMain;

            _trianglePointCount = 0;
            _linePointCount = 0;

            drawingMode = DrawingMode.Points;

            this.lvLogger = logger;

            box.MouseUp += new MouseEventHandler(box_MouseUp);
            box.MouseMove += new MouseEventHandler(box_MouseMove);
            box.SizeChanged += new EventHandler(box_SizeChanged);

            lvLogger.SelectedIndexChanged += new EventHandler(lvLogger_SelectedIndexChanged);

            lvLogger.Click += new EventHandler(lvLogger_Click);
            lvLogger.KeyUp += new KeyEventHandler(lvLogger_KeyUp);
            lvLogger.KeyDown += new KeyEventHandler(lvLogger_KeyDown);

            //1. corner: left top
            //2. corner right bottom
            ClippingWindow = new myRectangle(new Vector(box.Width / 4, 3 * box.Height / 4, false), new Vector(3 * (box.Width / 4), (box.Height / 4), false));

            this.InitLists();
        }
        /// <summary>
        /// Draw Cohen sutherland stuff (caption).
        /// </summary>
        /// <param name="ClippingWindow">The clipping window.</param>
        public void DrawCaption(myRectangle ClippingWindow)
        {
            //draw lines

            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v2.X, Parent.Height - ClippingWindow.v2.Y, ClippingWindow.v2.X, 0);
            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v2.X, Parent.Height - ClippingWindow.v2.Y, Parent.Width, Parent.Height - ClippingWindow.v2.Y);

            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v3.X, Parent.Height - ClippingWindow.v3.Y, Parent.Width, Parent.Height - ClippingWindow.v3.Y);
            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v3.X, Parent.Height - ClippingWindow.v3.Y, ClippingWindow.v3.X, Parent.Height);

            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v4.X, Parent.Height - ClippingWindow.v4.Y, 0, Parent.Height - ClippingWindow.v4.Y);
            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v4.X, Parent.Height - ClippingWindow.v4.Y, ClippingWindow.v4.X, Parent.Height);

            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v1.X, Parent.Height - ClippingWindow.v1.Y, ClippingWindow.v1.X, 0);
            g.DrawLine(GraphicCore.Cohen_Sutherland_LinesColor, ClippingWindow.v1.X, Parent.Height - ClippingWindow.v1.Y, 0, Parent.Height - ClippingWindow.v1.Y);

            //top
            PointF p1001 = new PointF((ClippingWindow.v1.X / 2) - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                                   (Parent.Height - ClippingWindow.v1.Y) / 2 - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2);

            g.DrawString("1001", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, p1001);

            PointF f2 = new PointF(((ClippingWindow.v2.X - ClippingWindow.v1.X) / 2 + ClippingWindow.v1.X) - (g.MeasureString("1000", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                                 (Parent.Height - ClippingWindow.v2.Y) / 2 - (g.MeasureString("1000", GraphicCore.Cohen_Sutherland_Font).Height) / 2);

            g.DrawString("1000", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f2);

            PointF f3 = new PointF(((Parent.Width - ClippingWindow.v2.X) / 2 + ClippingWindow.v2.X) - (g.MeasureString("1010", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                         (Parent.Height - ClippingWindow.v2.Y) / 2 - (g.MeasureString("1010", GraphicCore.Cohen_Sutherland_Font).Height) / 2);

            g.DrawString("1010", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f3);

            //unten
            PointF f4 = new PointF((ClippingWindow.v4.X / 2) - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                         Parent.Height - (Parent.Height - (Parent.Height - ClippingWindow.v4.Y)) / 2 - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2);

            g.DrawString("0101", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f4);

            PointF f5 = new PointF(((ClippingWindow.v3.X - ClippingWindow.v4.X) / 2 + ClippingWindow.v4.X) - (g.MeasureString("1000", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                          Parent.Height - (Parent.Height - (Parent.Height - ClippingWindow.v4.Y)) / 2 - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2);

            g.DrawString("0100", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f5);

            PointF f6 = new PointF(((Parent.Width - ClippingWindow.v3.X) / 2 + ClippingWindow.v3.X) - (g.MeasureString("1010", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                         Parent.Height - (Parent.Height - (Parent.Height - ClippingWindow.v3.Y)) / 2 - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2);

            g.DrawString("0110", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f6);

            //mitte

            PointF f7 = new PointF((ClippingWindow.v4.X / 2) - (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                        Parent.Height - (((ClippingWindow.v1.Y - ClippingWindow.v4.Y) / 2) + ClippingWindow.v4.Y + (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2));

            g.DrawString("0001", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f7);

            PointF f8 = new PointF(((ClippingWindow.v3.X - ClippingWindow.v4.X) / 2 + ClippingWindow.v4.X) - (g.MeasureString("1000", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                        Parent.Height - (((ClippingWindow.v1.Y - ClippingWindow.v4.Y) / 2) + ClippingWindow.v4.Y + (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2));

            g.DrawString("0000", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f8);

            PointF f9 = new PointF(((Parent.Width - ClippingWindow.v3.X) / 2 + ClippingWindow.v3.X) - (g.MeasureString("1010", GraphicCore.Cohen_Sutherland_Font).Width / 2),
                         Parent.Height - (((ClippingWindow.v2.Y - ClippingWindow.v3.Y) / 2) + ClippingWindow.v3.Y + (g.MeasureString("1001", GraphicCore.Cohen_Sutherland_Font).Height) / 2));

            g.DrawString("0010", GraphicCore.Cohen_Sutherland_Font, Brushes.Black, f9);
        }