public void Initialize([NotNull] ArcticFoxConfiguration configuration, int profileIndex)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            m_configuration = configuration;
            m_profile       = configuration.General.Profiles[profileIndex];

            ProfileEnabledCheckBox.Checked = m_profile.Flags.IsEnabled;
            ProfileNameTextBox.Text        = m_profile.Name;
            PowerUpDown.Maximum            = configuration.Info.MaxDevicePower / 10m;
            PowerUpDown.SetValue(m_profile.Power / 10m);

            var selectedPreheatType = PreheatTypeComboBox.SelectedItem as NamedItemContainer <ArcticFoxConfiguration.PreheatType>;

            if (selectedPreheatType != null && selectedPreheatType.Data == m_profile.PreheatType)
            {
                PreheatTypeComboBox_SelectedValueChanged(null, EventArgs.Empty);
            }
            else
            {
                PreheatTypeComboBox.SelectItem(m_profile.PreheatType);
            }

            PowerCurveComboBox.SelectItem(m_profile.SelectedCurve);
            PreheatTimeUpDown.SetValue(m_profile.PreheatTime / 100m);
            PreheatDelayUpDown.SetValue(m_profile.PreheatDelay);

            ResistanceLockedCheckBox_CheckedChanged(null, EventArgs.Empty);

            TemperatureTypeComboBox.SelectItem(m_profile.Flags.IsCelcius);
            TemperatureUpDown.SetValue(m_profile.Temperature);
            TemperatureDominantCheckBox.Checked = m_profile.Flags.IsTemperatureDominant;

            if (m_profile.Flags.Material == ArcticFoxConfiguration.Material.VariWatt)
            {
                MaterialComboBox.SelectedIndex = 0;
                ModeComboBox.SelectItem(Mode.Power);
            }
            else
            {
                MaterialComboBox.SelectItem(m_profile.Flags.Material);
                ModeComboBox.SelectItem(Mode.TemperatureControl);
            }

            TCRUpDown.SetValue(m_profile.TCR);
            ResistanceUpDown.SetValue(m_profile.Resistance / 1000m);
            ResistanceLockedCheckBox.Checked = m_profile.Flags.IsResistanceLocked;
        }
        private void InitializeWorkspaceFromDataflash([NotNull] Dataflash dataflash)
        {
            if (dataflash == null)
            {
                throw new ArgumentNullException("dataflash");
            }

            DeviceNameLabel.Text        = USBConnector.GetDeviceInfo(dataflash.InfoBlock.ProductID).Name;
            FirmwareVersionTextBox.Text = (dataflash.InfoBlock.FWVersion / 100f).ToString("0.00", CultureInfo.InvariantCulture);
            BuildTextBox.Text           = m_simple.Build.ToString();
            HardwareVersionTextBox.Text = (dataflash.ParamsBlock.HardwareVersion / 100f).ToString("0.00", CultureInfo.InvariantCulture);
            BootModeTextBox.Text        = dataflash.ParamsBlock.BootMode.ToString();

            // General -> Power & Temp Tab
            PowerUpDown.Value      = Math.Max(1, Math.Min(dataflash.ParamsBlock.Power / 10m, 75));
            TCPowerUpDown.Value    = Math.Max(1, Math.Min(dataflash.ParamsBlock.TCPower / 10m, 75));
            Step1WCheckBox.Checked = dataflash.ParamsBlock.Status.Step1W;

            TemperatureTypeComboBox.SelectItem(dataflash.ParamsBlock.IsCelsius);
            TemperatureUpDown.Value             = dataflash.ParamsBlock.Temperature;
            TemperatureDominantCheckBox.Checked = dataflash.ParamsBlock.Status.TemperatureDominant;

            PreheatTypeComboBox.SelectItem(dataflash.ParamsBlock.Status.PreheatPercent);
            PreheatPowerUpDown.Value = dataflash.ParamsBlock.Status.PreheatPercent ? dataflash.ParamsBlock.PreheatPwr : Math.Max(1, Math.Min(dataflash.ParamsBlock.PreheatPwr / 10m, 75));
            PreheatTimeUpDown.Value  = dataflash.ParamsBlock.PreheatTime / 100m;

            // General -> Coils Manager Tab
            ResistanceNiUpDown.Value     = dataflash.ParamsBlock.ResistanceNi / 100m;
            ResistanceNiCheckBox.Checked = dataflash.ParamsBlock.ResistanceNiLocked;

            ResistanceTiUpDown.Value     = dataflash.ParamsBlock.ResistanceTi / 100m;
            ResistanceTiCheckBox.Checked = dataflash.ParamsBlock.ResistanceTiLocked;

            ResistanceSSUpDown.Value     = dataflash.ParamsBlock.ResistanceSS / 100m;
            ResistanceSSCheckBox.Checked = dataflash.ParamsBlock.ResistanceSSLocked;

            ResistanceTCRUpDown.Value     = dataflash.ParamsBlock.ResistanceTCR / 100m;
            ResistanceTCRCheckBox.Checked = dataflash.ParamsBlock.ResistanceTCRLocked;

            TCRM1UpDown.Value = dataflash.ParamsBlock.TCR[0];
            TCRM2UpDown.Value = dataflash.ParamsBlock.TCR[1];
            TCRM3UpDown.Value = dataflash.ParamsBlock.TCR[2];

            // General -> Modes Tab
            SelectedModeComboBox.SelectItem(dataflash.ParamsBlock.SelectedMode);
            TempNiModeCheckBox.Checked = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.TempNi);
            TempTiModeCheckBox.Checked = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.TempTi);
            TempSSModeCheckBox.Checked = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.TempSS);
            TCRModeCheckBox.Checked    = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.TCR);
            PowerModeCheckBox.Checked  = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.Power);
            BypassModeCheckBox.Checked = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.Bypass);
            SmartModeCheckBox.Checked  = !dataflash.ParamsBlock.DisabledModes.HasFlag(VapeModes.Start);

            // General -> Controls Tab
            Clicks2ComboBox.SelectItem(dataflash.ParamsBlock.MClicks[0]);
            Clicks3ComboBox.SelectItem(dataflash.ParamsBlock.MClicks[1]);
            Clicks4ComboBox.SelectItem(dataflash.ParamsBlock.MClicks[2]);
            WakeUpByPlusMinusCheckBox.Checked = dataflash.ParamsBlock.Status.WakeUpByPlusMinus;

            // General -> Stats Tab
            PuffsUpDown.Value     = Math.Max(0, Math.Min(dataflash.InfoBlock.PuffCount, 99999));
            PuffsTimeUpDown.Value = Math.Max(0, Math.Min(dataflash.InfoBlock.TimeCount / 10m, 99999));

            // Screen -> Display Tab
            BrightnessTrackBar.Value    = dataflash.ParamsBlock.Contrast;
            IdleTimeUpDow.Value         = dataflash.ParamsBlock.ScreenDimTimeout;
            StealthModeCheckBox.Checked = dataflash.ParamsBlock.StealthOn;
            FlippedModeCheckBox.Checked = dataflash.ParamsBlock.Status.Flipped;

            // Screen -> Layout Tab
            ThirdLineContentComboBox.SelectItem(dataflash.ParamsBlock.ThirdLineContent);
            BatteryPercentsCheckBox.Checked = dataflash.ParamsBlock.Status.BatteryPercent;
            ShowLogoCheckBox.Checked        = !dataflash.ParamsBlock.Status.NoLogo;

            if (!dataflash.ParamsBlock.Status.AnalogClock)
            {
                ClockTypeComboBox.SelectItem(ClockType.Disabled);
            }
            else if (dataflash.ParamsBlock.Status.AnalogClock && dataflash.ParamsBlock.Status.DigitalClock)
            {
                ClockTypeComboBox.SelectItem(ClockType.Digital);
            }
            else if (dataflash.ParamsBlock.Status.AnalogClock)
            {
                ClockTypeComboBox.SelectItem(ClockType.Analog);
            }
            UseClassicMenuCheckBox.Checked = dataflash.ParamsBlock.Status.UseClassicMenu;

            // Screen -> Screensaver Tab
            ScreensaverTypeComboBox.SelectItem(dataflash.ParamsBlock.ScreensaverType);
            ScreenProtectionTimeComboBox.SelectItem(dataflash.ParamsBlock.ScreenProtectionTime);

            // Developer -> Expert
            ShuntCorrectionUpDown.Value = Math.Max((byte)85, Math.Min(dataflash.ParamsBlock.ShuntCorrection, (byte)115));
            BatteryModelComboBox.SelectItem(dataflash.ParamsBlock.SelectedBatteryModel);
        }