public void Save(ArcticFoxConfiguration.Profile profile) { profile.Flags.IsEnabled = ProfileEnabledCheckBox.Checked; profile.Name = ProfileNameTextBox.Text; profile.Power = (ushort)(PowerUpDown.Value * 10); profile.PreheatType = PreheatTypeComboBox.GetSelectedItem <ArcticFoxConfiguration.PreheatType>(); if (profile.PreheatType == ArcticFoxConfiguration.PreheatType.Watts) { profile.PreheatPower = (ushort)(PreheatPowerUpDown.Value * 10); } else if (profile.PreheatType == ArcticFoxConfiguration.PreheatType.Percents) { profile.PreheatPower = (ushort)PreheatPowerUpDown.Value; } else if (profile.PreheatType == ArcticFoxConfiguration.PreheatType.Curve) { profile.SelectedCurve = (byte)PowerCurveComboBox.SelectedIndex; } profile.PreheatTime = (byte)(PreheatTimeUpDown.Value * 100); profile.PreheatDelay = (byte)PreheatDelayUpDown.Value; profile.Flags.IsCelcius = TemperatureTypeComboBox.GetSelectedItem <bool>(); profile.Temperature = (ushort)TemperatureUpDown.Value; profile.Flags.IsTemperatureDominant = TemperatureDominantCheckBox.Checked; var mode = ModeComboBox.GetSelectedItem <Mode>(); profile.Flags.Material = mode == Mode.TemperatureControl ? MaterialComboBox.GetSelectedItem <ArcticFoxConfiguration.Material>() : ArcticFoxConfiguration.Material.VariWatt; profile.TCR = (ushort)TCRUpDown.Value; profile.Resistance = (ushort)(ResistanceUpDown.Value * 1000); profile.Flags.IsResistanceLocked = ResistanceLockedCheckBox.Checked; }
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 SaveWorkspaceToDataflash([NotNull] Dataflash dataflash) { if (dataflash == null) { throw new ArgumentNullException("dataflash"); } // General -> Power & Temp Tab dataflash.ParamsBlock.Power = (ushort)(PowerUpDown.Value * 10); dataflash.ParamsBlock.TCPower = (ushort)(TCPowerUpDown.Value * 10); dataflash.ParamsBlock.Status.Step1W = Step1WCheckBox.Checked; dataflash.ParamsBlock.IsCelsius = TemperatureTypeComboBox.GetSelectedItem <bool>(); dataflash.ParamsBlock.Temperature = (ushort)TemperatureUpDown.Value; dataflash.ParamsBlock.Status.TemperatureDominant = TemperatureDominantCheckBox.Checked; dataflash.ParamsBlock.Status.PreheatPercent = PreheatTypeComboBox.GetSelectedItem <bool>(); dataflash.ParamsBlock.PreheatPwr = (ushort)(dataflash.ParamsBlock.Status.PreheatPercent ? PreheatPowerUpDown.Value : PreheatPowerUpDown.Value * 10); dataflash.ParamsBlock.PreheatTime = (byte)(PreheatTimeUpDown.Value * 100); // General -> Coils Manager Tab dataflash.ParamsBlock.ResistanceNi = (ushort)(ResistanceNiUpDown.Value * 100); dataflash.ParamsBlock.ResistanceNiLocked = ResistanceNiCheckBox.Checked; dataflash.ParamsBlock.ResistanceTi = (ushort)(ResistanceTiUpDown.Value * 100); dataflash.ParamsBlock.ResistanceTiLocked = ResistanceTiCheckBox.Checked; dataflash.ParamsBlock.ResistanceSS = (ushort)(ResistanceSSUpDown.Value * 100); dataflash.ParamsBlock.ResistanceSSLocked = ResistanceSSCheckBox.Checked; dataflash.ParamsBlock.ResistanceTCR = (ushort)(ResistanceTCRUpDown.Value * 100); dataflash.ParamsBlock.ResistanceTCRLocked = ResistanceTCRCheckBox.Checked; dataflash.ParamsBlock.TCR[0] = (ushort)TCRM1UpDown.Value; dataflash.ParamsBlock.TCR[1] = (ushort)TCRM2UpDown.Value; dataflash.ParamsBlock.TCR[2] = (ushort)TCRM3UpDown.Value; // General -> Modes Tab dataflash.ParamsBlock.SelectedMode = SelectedModeComboBox.GetSelectedItem <VapeMode>(); dataflash.ParamsBlock.SelectedTCRIndex = (byte)SelectedTCRComboBox.SelectedIndex; dataflash.ParamsBlock.DisabledModes = VapeModes.None; { if (!TempNiModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.TempNi; } if (!TempTiModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.TempTi; } if (!TempSSModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.TempSS; } if (!TCRModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.TCR; } if (!PowerModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.Power; } if (!BypassModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.Bypass; } if (!SmartModeCheckBox.Checked) { dataflash.ParamsBlock.DisabledModes |= VapeModes.Start; } } // General -> Controls Tab dataflash.ParamsBlock.MClicks[0] = Clicks2ComboBox.GetSelectedItem <ClickAction>(); dataflash.ParamsBlock.MClicks[1] = Clicks3ComboBox.GetSelectedItem <ClickAction>(); dataflash.ParamsBlock.MClicks[2] = Clicks4ComboBox.GetSelectedItem <ClickAction>(); dataflash.ParamsBlock.Status.WakeUpByPlusMinus = WakeUpByPlusMinusCheckBox.Checked; // General -> Stats Tab dataflash.InfoBlock.PuffCount = (uint)PuffsUpDown.Value; dataflash.InfoBlock.TimeCount = (uint)PuffsTimeUpDown.Value * 10; // Screen -> Display Tab dataflash.ParamsBlock.Contrast = (byte)BrightnessTrackBar.Value; dataflash.ParamsBlock.ScreenDimTimeout = (byte)IdleTimeUpDow.Value; dataflash.ParamsBlock.StealthOn = StealthModeCheckBox.Checked; dataflash.ParamsBlock.Status.Flipped = FlippedModeCheckBox.Checked; // Screen -> Layout Tab dataflash.ParamsBlock.ThirdLineContent = ThirdLineContentComboBox.GetSelectedItem <LineContentType>(); dataflash.ParamsBlock.Status.BatteryPercent = BatteryPercentsCheckBox.Checked; dataflash.ParamsBlock.Status.NoLogo = !ShowLogoCheckBox.Checked; var clockMode = ClockTypeComboBox.GetSelectedItem <ClockType>(); switch (clockMode) { case ClockType.Disabled: { dataflash.ParamsBlock.Status.AnalogClock = false; dataflash.ParamsBlock.Status.DigitalClock = false; break; } case ClockType.Analog: { dataflash.ParamsBlock.Status.AnalogClock = true; dataflash.ParamsBlock.Status.DigitalClock = false; break; } case ClockType.Digital: { dataflash.ParamsBlock.Status.AnalogClock = true; dataflash.ParamsBlock.Status.DigitalClock = true; break; } default: throw new ArgumentOutOfRangeException(); } dataflash.ParamsBlock.Status.UseClassicMenu = UseClassicMenuCheckBox.Checked; // Screen -> Screensaver Tab dataflash.ParamsBlock.ScreensaverType = ScreensaverTypeComboBox.GetSelectedItem <ScreensaverType>(); dataflash.ParamsBlock.ScreenProtectionTime = ScreenProtectionTimeComboBox.GetSelectedItem <ScreenProtectionTime>(); // Developer -> Expert dataflash.ParamsBlock.ShuntCorrection = (byte)ShuntCorrectionUpDown.Value; dataflash.ParamsBlock.SelectedBatteryModel = BatteryModelComboBox.GetSelectedItem <BatteryModel>(); // Setup DateTime dataflash.InfoBlock.Year = (ushort)DateTime.Now.Year; dataflash.InfoBlock.Month = (byte)DateTime.Now.Month; dataflash.InfoBlock.Day = (byte)DateTime.Now.Day; dataflash.InfoBlock.Hour = (byte)DateTime.Now.Hour; dataflash.InfoBlock.Minute = (byte)DateTime.Now.Minute; dataflash.InfoBlock.Second = (byte)DateTime.Now.Second; }
private void InitializeControls() { var errorIcon = BitmapProcessor.CreateIcon(Resources.exclamation); if (errorIcon != null) { MainErrorProvider.Icon = errorIcon; } MainContainer.SelectedPage = WelcomePage; FirmwareVersionTextBox.ReadOnly = true; FirmwareVersionTextBox.BackColor = Color.White; BuildTextBox.ReadOnly = true; BuildTextBox.BackColor = Color.White; HardwareVersionTextBox.ReadOnly = true; HardwareVersionTextBox.BackColor = Color.White; BootModeTextBox.ReadOnly = true; BootModeTextBox.BackColor = Color.White; TraceTextBox.ReadOnly = true; TraceTextBox.BackColor = Color.White; InititalizeComboBoxes(); TemperatureTypeComboBox.SelectedValueChanged += (s, e) => { var isCelcius = TemperatureTypeComboBox.GetSelectedItem <bool>(); if (isCelcius) { TemperatureUpDown.Minimum = 100; TemperatureUpDown.Maximum = 315; } else { TemperatureUpDown.Minimum = 200; TemperatureUpDown.Maximum = 600; } }; PreheatTypeComboBox.SelectedValueChanged += (s, e) => { var isPercents = PreheatTypeComboBox.GetSelectedItem <bool>(); if (isPercents) { PreheatPowerUpDown.DecimalPlaces = 0; PreheatPowerUpDown.Increment = 1; PreheatPowerUpDown.Minimum = 100; PreheatPowerUpDown.Maximum = 250; } else { PreheatPowerUpDown.DecimalPlaces = 1; PreheatPowerUpDown.Increment = 0.1m; PreheatPowerUpDown.Minimum = 1; PreheatPowerUpDown.Maximum = 75; } }; SelectedModeComboBox.SelectedValueChanged += (s, e) => { var mode = SelectedModeComboBox.GetSelectedItem <VapeMode>(); switch (mode) { case VapeMode.TempNi: SetupModesCheckBoxes(TempNiModeCheckBox); break; case VapeMode.TempTi: SetupModesCheckBoxes(TempTiModeCheckBox); break; case VapeMode.TempSS: SetupModesCheckBoxes(TempSSModeCheckBox); break; case VapeMode.TCR: SetupModesCheckBoxes(TCRModeCheckBox); break; case VapeMode.Power: SetupModesCheckBoxes(PowerModeCheckBox); break; case VapeMode.Bypass: SetupModesCheckBoxes(BypassModeCheckBox); break; case VapeMode.Start: SetupModesCheckBoxes(SmartModeCheckBox); break; default: throw new ArgumentOutOfRangeException(); } SelectedTCRComboBox.SelectedIndex = Math.Min(m_dataflash.ParamsBlock.SelectedTCRIndex, (byte)2); SelectedTCRComboBox.Visible = TCRIndexLabel.Visible = mode == VapeMode.TCR; }; BatteryModelComboBox.SelectedValueChanged += (s, e) => { var batteryModel = BatteryModelComboBox.GetSelectedItem <BatteryModel>(); BatteryEditButton.Visible = batteryModel == BatteryModel.Custom; }; PortComboBox.SelectedIndex = 0; BrightnessTrackBar.ValueChanged += (s, e) => BrightnessPercentLabel.Text = (int)(BrightnessTrackBar.Value * 100m / 255) + @"%"; DownloadButton.Click += DownloadButton_Click; UploadButton.Click += UploadButton_Click; ResetButton.Click += ResetButton_Click; BatteryEditButton.Click += BatteryEditButton_Click; TakeScreenshotButton.Click += TakeScreenshotButton_Click; SaveScreenshotButton.Click += SaveScreenshotButton_Click; BroadcastButton.Click += BroadcastButton_Click; RebootButton.Click += RebootButton_Click; ComConnectButton.Click += ComConnectButton_Click; ComDisconnectButton.Click += ComDisconnectButton_Click; CommandTextBox.KeyDown += CommandTextBox_KeyDown; }
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); }
private void InitializeControls() { ProfileNameTextBox.TextChanged += (s, e) => { var position = ProfileNameTextBox.SelectionStart; var input = ProfileNameTextBox.Text; var matches = s_blackList.Matches(input); foreach (Match match in matches) { if (!match.Success) { continue; } input = input.Replace(match.Value, string.Empty); } ProfileNameTextBox.Text = input; ProfileNameTextBox.SelectionStart = position; }; PowerUpDown.Minimum = MinimumWatts; PowerUpDown.Maximum = 60; PreheatTypeComboBox.Fill(PredefinedData.ArcticFox.Profile.PreheatTypes); PreheatTypeComboBox.SelectedValueChanged += PreheatTypeComboBox_SelectedValueChanged; PowerCurveComboBox.Fill(PredefinedData.ArcticFox.Profile.PowerCurves); TemperatureTypeComboBox.Fill(PredefinedData.ArcticFox.Profile.TemperatureTypes); TemperatureTypeComboBox.SelectedValueChanged += (s, e) => { var isCelcius = TemperatureTypeComboBox.GetSelectedItem <bool>(); if (isCelcius) { TemperatureUpDown.Minimum = 100; TemperatureUpDown.Maximum = 315; } else { TemperatureUpDown.Minimum = 200; TemperatureUpDown.Maximum = 600; } }; ModeComboBox.Items.Clear(); ModeComboBox.Items.AddRange(new object[] { new NamedItemContainer <Mode>(LocalizableStrings.VapeModePower, Mode.Power), new NamedItemContainer <Mode>(LocalizableStrings.VapeModeTempControl, Mode.TemperatureControl) }); ModeComboBox.SelectedValueChanged += (s, e) => { var isTemperatureSensing = ModeComboBox.GetSelectedItem <Mode>() == Mode.TemperatureControl; SetupTempControlButton.Visible = isTemperatureSensing; MaterialComboBox.Visible = isTemperatureSensing; MaterialLabel.Visible = isTemperatureSensing; ResistanceLabel.Visible = isTemperatureSensing; ResistanceUpDown.Visible = isTemperatureSensing; ResistanceLockedCheckBox.Visible = isTemperatureSensing; OhmLabel.Visible = isTemperatureSensing; TemperatureLabel.Visible = isTemperatureSensing; TemperatureUpDown.Visible = isTemperatureSensing; TemperatureTypeComboBox.Visible = isTemperatureSensing; TemperatureDominantCheckBox.Visible = isTemperatureSensing; var selectedMaterial = MaterialComboBox.GetSelectedItem <ArcticFoxConfiguration.Material>(); TCRUpDown.Visible = isTemperatureSensing && selectedMaterial == ArcticFoxConfiguration.Material.TCR; TFRCurveEditButton.Visible = isTemperatureSensing && (int)selectedMaterial >= (int)ArcticFoxConfiguration.Material.TFR1 && (int)selectedMaterial <= (int)ArcticFoxConfiguration.Material.TFR8; }; MaterialComboBox.Fill(PredefinedData.ArcticFox.Profile.Materials); MaterialComboBox.SelectedValueChanged += (s, e) => { if (MaterialComboBox.SelectedItem == null) { return; } var selectedMaterial = MaterialComboBox.GetSelectedItem <ArcticFoxConfiguration.Material>(); TCRUpDown.Visible = selectedMaterial == ArcticFoxConfiguration.Material.TCR; TFRCurveEditButton.Visible = (int)selectedMaterial >= (int)ArcticFoxConfiguration.Material.TFR1 && (int)selectedMaterial <= (int)ArcticFoxConfiguration.Material.TFR8; }; PowerCurveEditButton.Click += PowerCurveEditButton_Click; TFRCurveEditButton.Click += TFRCurveEditButton_Click; SetupTempControlButton.Click += SetupTempControlButton_Click; }