예제 #1
0
        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;
        }
예제 #2
0
        private void PreheatTypeComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            var type = PreheatTypeComboBox.GetSelectedItem <ArcticFoxConfiguration.PreheatType>();

            if (type == ArcticFoxConfiguration.PreheatType.Watts)
            {
                PreheatPowerUpDown.DecimalPlaces = 1;
                PreheatPowerUpDown.Increment     = 0.1m;
                PreheatPowerUpDown.Minimum       = MinimumWatts;
                PreheatPowerUpDown.Maximum       = m_configuration.Info.MaxPower / 10m;
                PreheatPowerUpDown.SetValue(m_profile.PreheatPower / 10m);
                PreheatPowerUnitLabel.Text = LocalizableStrings.WattsLabel;
            }
            else if (type == ArcticFoxConfiguration.PreheatType.Percents)
            {
                PreheatPowerUpDown.DecimalPlaces = 0;
                PreheatPowerUpDown.Increment     = 1;
                PreheatPowerUpDown.Minimum       = 100;
                PreheatPowerUpDown.Maximum       = 250;
                PreheatPowerUpDown.SetValue(m_profile.PreheatPower);
                PreheatPowerUnitLabel.Text = @"%";
            }

            if (type == ArcticFoxConfiguration.PreheatType.Curve)
            {
                PreheatPowerLabel.Text       = LocalizableStrings.PreheatCurveLabel;
                PowerCurveComboBox.Visible   = true;
                PowerCurveEditButton.Visible = true;

                PreheatTimeUpDown.Enabled  = false;
                PreheatDelayUpDown.Enabled = false;
                PreheatPowerUnitLabel.Text = string.Empty;
            }
            else
            {
                PreheatPowerLabel.Text       = LocalizableStrings.PreheatPowerLabel;
                PowerCurveComboBox.Visible   = false;
                PowerCurveEditButton.Visible = false;

                PreheatTimeUpDown.Enabled  = true;
                PreheatDelayUpDown.Enabled = true;
            }
        }
        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;
        }