/// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args">
        /// Unused.
        /// </param>
        static void Main(string[] args)
        {
            Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString());
            try
            {
                // Create ballTracking object
                ballTracking = new BallTracking(0.03f, 1.0f / 256.0f);

                // Connect to x-IMU
                Console.WriteLine("Searching for x-IMU...");
                x_IMU_API.PortAssignment[] portAssignment = (new x_IMU_API.PortScanner(true, true)).Scan();
                x_IMU_API.xIMUserial xIMUserial = new x_IMU_API.xIMUserial(portAssignment[0].PortName);
                xIMUserial.CalInertialAndMagneticDataReceived += new x_IMU_API.xIMUserial.onCalInertialAndMagneticDataReceived(xIMUserial_CalInertialMagneticDataReceived);
                xIMUserial.QuaternionDataReceived += new x_IMU_API.xIMUserial.onQuaternionDataReceived(xIMUserial_QuaternionDataReceived);
                xIMUserial.Open();
                Console.WriteLine("Connected to x-IMU " + portAssignment[0].DeviceID + " on " + portAssignment[0].PortName + ".");

                // Send 'algorithm initialise' command
                Console.WriteLine("Sending 'algorithm initialise' command...");
                xIMUserial.SendCommandPacket(x_IMU_API.CommandCodes.AlgorithmInitialise);

                // Running graphics
                Console.WriteLine("Running 3D Cuboid form...");
                form_3Dcuboid = new Form_3Dcuboid(new float[] { 0.06f, 0.04f, 0.02f }, Form_3Dcuboid.CameraViews.Top, 3.0f);
                form_3Dcuboid.WindowState = FormWindowState.Maximized;
                form_3Dcuboid.ShowDialog();
                form_3Dcuboid = null;

                // Closing form enables mouse control mode.
                Console.WriteLine("Mouse control active.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args">
        /// Unused.
        /// </param>
        static void Main(string[] args)
        {
            Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString());
            try
            {
                // Create ballTracking object
                ballTracking = new BallTracking(0.03f, 1.0f / 256.0f);

                // Connect to x-IMU
                Console.WriteLine("Searching for x-IMU...");
                x_IMU_API.PortAssignment[] portAssignment = (new x_IMU_API.PortScanner(true, true)).Scan();
                x_IMU_API.xIMUserial       xIMUserial     = new x_IMU_API.xIMUserial(portAssignment[0].PortName);
                xIMUserial.CalInertialAndMagneticDataReceived += new x_IMU_API.xIMUserial.onCalInertialAndMagneticDataReceived(xIMUserial_CalInertialMagneticDataReceived);
                xIMUserial.QuaternionDataReceived             += new x_IMU_API.xIMUserial.onQuaternionDataReceived(xIMUserial_QuaternionDataReceived);
                xIMUserial.Open();
                Console.WriteLine("Connected to x-IMU " + portAssignment[0].DeviceID + " on " + portAssignment[0].PortName + ".");

                // Send 'algorithm initialise' command
                Console.WriteLine("Sending 'algorithm initialise' command...");
                xIMUserial.SendCommandPacket(x_IMU_API.CommandCodes.AlgorithmInitialise);

                // Running graphics
                Console.WriteLine("Running 3D Cuboid form...");
                form_3Dcuboid             = new Form_3Dcuboid(new float[] { 0.06f, 0.04f, 0.02f }, Form_3Dcuboid.CameraViews.Top, 3.0f);
                form_3Dcuboid.WindowState = FormWindowState.Maximized;
                form_3Dcuboid.ShowDialog();
                form_3Dcuboid = null;

                // Closing form enables mouse control mode.
                Console.WriteLine("Mouse control active.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }