protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _font        = Content.Load <SpriteFont>("MgGenFont");
            _dot         = CreateDotTexture(GraphicsDevice, Color.White);
            DrawHelpers.Initialize(GraphicsDevice, _spriteBatch, null);

            curve = new Curve_BezierRecalculatingCps(_wayPoints, numOfPoints, isCurveClosed, isUniformedUsed);
            curve._showTangents = showGeneratedTangentsPositions;
        }
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            ms = Mouse.GetState();
            bool redoCurve = false;

            CurveIterationTimer(gameTime, 10f);


            // show extra position and tangent lines.
            if (IsPressedWithDelay(Keys.F1, gameTime))
            {
                showGeneratedTangentsPositions = !showGeneratedTangentsPositions;
                curve._showTangents            = showGeneratedTangentsPositions;
            }

            // switch to a uniformed or non uniformed curve.
            if (IsPressedWithDelay(Keys.Space, gameTime))
            {
                isUniformedUsed = !isUniformedUsed;
                redoCurve       = true;
            }

            // switch curve open or closed.
            if (IsPressedWithDelay(Keys.Tab, gameTime))
            {
                isCurveClosed = !isCurveClosed;
                redoCurve     = true;
            }

            // adjust weight
            if (IsPressedWithDelay(Keys.Up, gameTime) || ms.ScrollWheelValue > currentScrollWheelvalue)
            {
                selectedWeight += .05f;
                if (selectedWeight > maxSelectableWeight)
                {
                    selectedWeight = -1f;
                }
                _wayPoints[selectedCp].W = selectedWeight;
                currentScrollWheelvalue  = ms.ScrollWheelValue;
                redoCurve = true;
            }

            // adjust weight
            if (IsPressedWithDelay(Keys.Down, gameTime) || ms.ScrollWheelValue < currentScrollWheelvalue)
            {
                selectedWeight -= .05f;
                if (selectedWeight < -1f)
                {
                    selectedWeight = maxSelectableWeight;
                }
                _wayPoints[selectedCp].W = selectedWeight;
                currentScrollWheelvalue  = ms.ScrollWheelValue;
                redoCurve = true;
            }

            // adjust control point position.
            if (ms.LeftButton == ButtonState.Pressed)
            {
                _wayPoints[selectedCp] = new Vector4(ms.Position.X, ms.Position.Y, 0, _wayPoints[selectedCp].W);
                redoCurve = true;
            }

            // next control point
            if (IsPressedWithDelay(Keys.Right, gameTime))
            {
                selectedCp += 1;
                if (selectedCp > _wayPoints.Length - 1)
                {
                    selectedCp = 0;
                }
            }

            // check or select a control point.
            CheckPointSelected();

            if (redoCurve)
            {
                curve = new Curve_BezierRecalculatingCps(_wayPoints, numOfPoints, isCurveClosed, isUniformedUsed);
            }

            string msg2 = "Open";

            if (isCurveClosed)
            {
                msg2 = "Closed";
            }
            string msg3 = "NonUniform";

            if (isUniformedUsed)
            {
                msg3 = "Uniform";
            }
            msg =
                $"GameTime In Seconds {gameTimeInSeconds.ToString("#########0.00")}  Cycle time over curve: {cycledTime.ToString("###0.00")}" +
                $"\n" + $"Bezier " +
                $"\n" + $"Total Distance: {curve.TotalCurveDistance.ToString("#########0.000")}" +
                $"\n" + $"Press Tab ....... Curve is {msg2}" +
                $"\n" + $"Press Space .. Curve is {msg3}" +
                $"\n" + $"Left Click ........ Move selectedCp " +
                $"\n" + $"Right Click ...... Selected Cp " + selectedCp +
                $"\n" + $"Mouse Scroll ... Alter Weight " + selectedWeight
            ;

            base.Update(gameTime);
        }