/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool BtnInitialize(int selectedIndex)
        {
            try
            {
                Spectrometer = Spectrometer.Factory.Create(selectedIndex);
            }
            catch (DllNotFoundException ex)
            {
                Front.My_msg(ex.Message);
                return(false);
            }

            Spectrometer.ExposureFinished += Spectrometer_ExposureFinished;

            // Use the choosen spectrometer class to search for devices.
            Spectrometer.SearchDevices();
            if (Spectrometer.NumberOfDevicesFound == 0)
            {
                Front.My_msg("No spectrometer found.");
                return(false);  // initState remains the same.
            }
            else
            {
                Front.My_msg("Spectrometers found:");
                for (int deviceIndex = 0; deviceIndex < Spectrometer.NumberOfDevicesFound; deviceIndex++)
                {
                    Spectrometer.SelectDevice(deviceIndex);
                    Front.My_msg(string.Format("  {0}... {1} : {2}", deviceIndex,
                                               Spectrometer.ModelName, Spectrometer.SerialNo));
                }
                Spectrometer.SelectDevice();
            }
            return(true);
        }
        /// <summary>
        /// Disconnect the device
        /// and write closing message.
        /// </summary>
        public bool BtnDisconnect()
        {
            if (Spectrometer is null)
            {
                return(false);
            }

            if (Spectrometer.DisconnectDevice())
            {
                Front.My_msg("Closing");
                Spectrometer = null;
            }
            return(true);
        }