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);
        }
Example #4
0
        private void SaveWorkspace()
        {
            var general = m_deviceConfiguration.General;
            {
                // Profiles Tab
                for (var i = 0; i < general.Profiles.Length; i++)
                {
                    var tabContent = (ProfileTabContent)ProfilesTabControl.TabPages[i].Controls[0];
                    tabContent.Save(general.Profiles[i]);
                }

                general.SelectedProfile = SelectedProfleComboBox.GetSelectedItem <byte>();
                general.IsSmartEnabled  = SmartCheckBox.Checked;
            }

            var ui = m_deviceConfiguration.Interface;
            {
                // General -> Screen Tab
                ui.Brightness          = (byte)BrightnessTrackBar.Value;
                ui.DimTimeout          = (byte)IdleTimeUpDow.Value;
                ui.PuffScreenDelay     = (byte)(PuffScreenDelayUpDown.Value * 10);
                ui.IsStealthMode       = StealthModeCheckBox.Checked;
                ui.IsFlipped           = FlippedModeCheckBox.Checked;
                ui.MainScreenSkin      = MainScreenSkinComboBox.GetSelectedItem <ArcticFoxConfiguration.Skin>();
                ui.IsClassicMenu       = UseClassicMenuCheckBox.Checked;
                ui.IsLogoEnabled       = ShowLogoCheckBox.Checked;
                ui.IsClockOnMainScreen = ShowClockCheckBox.Checked;
                ui.ClockType           = ClockTypeComboBox.GetSelectedItem <ArcticFoxConfiguration.ClockType>();
                ui.ScreensaveDuration  = ScreensaverTimeComboBox.GetSelectedItem <ArcticFoxConfiguration.ScreenProtectionTime>();
                ui.ChargeScreenType    = ChargeScreenComboBox.GetSelectedItem <ArcticFoxConfiguration.ChargeScreenType>();

                // General -> Layout Tab -> Classic Screen
                ui.ClassicSkinVWLines.Line1 = SaveLineContent(ClassicVWLine1ComboBox, ClassicVWLine1FireCheckBox);
                ui.ClassicSkinVWLines.Line2 = SaveLineContent(ClassicVWLine2ComboBox, ClassicVWLine2FireCheckBox);
                ui.ClassicSkinVWLines.Line3 = SaveLineContent(ClassicVWLine3ComboBox, ClassicVWLine3FireCheckBox);
                ui.ClassicSkinVWLines.Line4 = SaveLineContent(ClassicVWLine4ComboBox, ClassicVWLine4FireCheckBox);

                ui.ClassicSkinTCLines.Line1 = SaveLineContent(ClassicTCLine1ComboBox, ClassicTCLine1FireCheckBox);
                ui.ClassicSkinTCLines.Line2 = SaveLineContent(ClassicTCLine2ComboBox, ClassicTCLine2FireCheckBox);
                ui.ClassicSkinTCLines.Line3 = SaveLineContent(ClassicTCLine3ComboBox, ClassicTCLine3FireCheckBox);
                ui.ClassicSkinTCLines.Line4 = SaveLineContent(ClassicTCLine4ComboBox, ClassicTCLine4FireCheckBox);

                // General -> Layout Tab -> Circle Screen
                ui.CircleSkinVWLines.Line1 = SaveLineContent(CircleVWLine1ComboBox);
                ui.CircleSkinVWLines.Line2 = SaveLineContent(CircleVWLine2ComboBox);
                ui.CircleSkinVWLines.Line3 = SaveLineContent(CircleVWLine3ComboBox, CircleVWLine3FireCheckBox);

                ui.CircleSkinTCLines.Line1 = SaveLineContent(CircleTCLine1ComboBox);
                ui.CircleSkinTCLines.Line2 = SaveLineContent(CircleTCLine2ComboBox);
                ui.CircleSkinTCLines.Line3 = SaveLineContent(CircleTCLine3ComboBox, CircleTCLine3FireCheckBox);

                // General -> Layout Tab -> Small Screen
                ui.SmallSkinVWLines.Line1 = SaveLineContent(SmallVWLine1ComboBox, SmallVWLine1FireCheckBox);
                ui.SmallSkinVWLines.Line2 = SaveLineContent(SmallVWLine2ComboBox, SmallVWLine2FireCheckBox);

                ui.SmallSkinTCLines.Line1 = SaveLineContent(SmallTCLine1ComboBox, SmallTCLine1FireCheckBox);
                ui.SmallSkinTCLines.Line2 = SaveLineContent(SmallTCLine2ComboBox, SmallTCLine2FireCheckBox);

                // General -> Controls Tab
                ui.ClicksVW[0] = ClicksVW2ComboBox.GetSelectedItem <ArcticFoxConfiguration.ClickAction>();
                ui.ClicksVW[1] = ClicksVW3ComboBox.GetSelectedItem <ArcticFoxConfiguration.ClickAction>();
                ui.ClicksVW[2] = ClicksVW4ComboBox.GetSelectedItem <ArcticFoxConfiguration.ClickAction>();

                ui.ClicksTC[0] = ClicksTC2ComboBox.GetSelectedItem <ArcticFoxConfiguration.ClickAction>();
                ui.ClicksTC[1] = ClicksTC3ComboBox.GetSelectedItem <ArcticFoxConfiguration.ClickAction>();
                ui.ClicksTC[2] = ClicksTC4ComboBox.GetSelectedItem <ArcticFoxConfiguration.ClickAction>();

                ui.IsUpDownSwapped   = UpDownButtonsComboBox.GetSelectedItem <bool>();
                ui.WakeUpByPlusMinus = WakeUpByPlusMinusCheckBox.Checked;
                ui.IsPowerStep1W     = Step1WCheckBox.Checked;
            }

            var stats = m_deviceConfiguration.Counters;
            {
                var now = DateTime.Now;

                // General -> Stats Tab
                stats.PuffsCount = (uint)PuffsUpDown.Value;
                stats.PuffsTime  = (uint)(PuffsTimeUpDown.Value * 10);

                // Time sync
                stats.DateTime.Year   = (ushort)now.Year;
                stats.DateTime.Month  = (byte)now.Month;
                stats.DateTime.Day    = (byte)now.Day;
                stats.DateTime.Hour   = (byte)now.Hour;
                stats.DateTime.Minute = (byte)now.Minute;
                stats.DateTime.Second = (byte)now.Second;

                ui.PuffsTimeFormat = PuffsTimeFormatComboBox.GetSelectedItem <ArcticFoxConfiguration.PuffsTimeFormat>();
            }

            var advanced = m_deviceConfiguration.Advanced;
            {
                advanced.PuffCutOff             = (byte)(PuffCutOffUpDown.Value * 10);
                advanced.ShuntCorrection        = (byte)ShuntCorrectionUpDown.Value;
                advanced.BatteryModel           = BatteryModelComboBox.GetSelectedItem <ArcticFoxConfiguration.BatteryModel>();
                advanced.IsX32                  = X32CheckBox.Checked;
                advanced.IsLightSleepMode       = LightSleepCheckBox.Checked;
                advanced.ResetCountersOnStartup = ResetCountersCheckBox.Checked;
                advanced.CheckTCR               = CheckTCRCheckBox.Checked;
                advanced.IsUsbCharge            = UsbChargeCheckBox.Checked;
                advanced.UsbNoSleep             = UsbNoSleepCheckBox.Checked;

                advanced.BatteryVoltageOffsets[0] = (sbyte)(Battery1OffsetUpDown.Value * 100);
                advanced.BatteryVoltageOffsets[1] = (sbyte)(Battery2OffsetUpDown.Value * 100);
                advanced.BatteryVoltageOffsets[2] = (sbyte)(Battery3OffsetUpDown.Value * 100);
                advanced.BatteryVoltageOffsets[3] = (sbyte)(Battery4OffsetUpDown.Value * 100);
            }
        }
Example #5
0
        private void InitializeWorkspace()
        {
            var deviceInfo = m_deviceConfiguration.Info;
            {
                DeviceNameLabel.Text        = HidDeviceInfo.Get(deviceInfo.ProductId).Name;
                FirmwareVersionTextBox.Text = (deviceInfo.FirmwareVersion / 100f).ToString("0.00", CultureInfo.InvariantCulture);
                BuildTextBox.Text           = deviceInfo.FirmwareBuild.ToString();
                HardwareVersionTextBox.Text = (deviceInfo.HardwareVersion / 100f).ToString("0.00", CultureInfo.InvariantCulture);

                if (deviceInfo.DisplaySize == ArcticFoxConfiguration.DisplaySize.W96H16)
                {
                    MainScreenSkinLabel.Visible = MainScreenSkinComboBox.Visible = false;
                    ClockTypeLabel.Visible      = ClockTypeComboBox.Visible = false;
                    UseClassicMenuLabel.Visible = UseClassicMenuCheckBox.Visible = false;
                }

                Battery2OffsetLabel.Visible = Battery2OffsetUpDown.Visible = Battery2OffsetVoltsLabel.Visible = deviceInfo.NumberOfBatteries > 1;
                Battery3OffsetLabel.Visible = Battery3OffsetUpDown.Visible = Battery3OffsetVoltsLabel.Visible = deviceInfo.NumberOfBatteries > 2;
                Battery4OffsetLabel.Visible = Battery4OffsetUpDown.Visible = Battery4OffsetVoltsLabel.Visible = deviceInfo.NumberOfBatteries > 3;
            }

            var general = m_deviceConfiguration.General;
            {
                for (var i = 0; i < general.Profiles.Length; i++)
                {
                    var tabName = "P" + (i + 1);
                    ProfileTabContent tabContent;

                    if (ProfilesTabControl.TabPages.Count <= i)
                    {
                        var tabPage = new TabPage(tabName);
                        tabContent = new ProfileTabContent(this)
                        {
                            Dock = DockStyle.Fill
                        };
                        tabPage.Controls.Add(tabContent);
                        ProfilesTabControl.TabPages.Add(tabPage);

                        SelectedProfleComboBox.Items.Add(new NamedItemContainer <byte>(tabName, (byte)i));
                    }
                    else
                    {
                        tabContent = (ProfileTabContent)ProfilesTabControl.TabPages[i].Controls[0];
                    }

                    tabContent.Initialize(m_deviceConfiguration, i);
                    tabContent.UpdatePowerCurveNames(m_deviceConfiguration.Advanced.PowerCurves);
                    tabContent.UpdateTFRNames(m_deviceConfiguration.Advanced.TFRTables);
                }

                ProfilesTabControl.SelectedIndex = Math.Max(0, Math.Min(general.SelectedProfile, ProfilesTabControl.TabCount));
                SelectedProfleComboBox.SelectItem(general.SelectedProfile);
                SmartCheckBox.Checked = general.IsSmartEnabled;
            }

            var ui = m_deviceConfiguration.Interface;
            {
                BrightnessTrackBar.Value = ui.Brightness;
                IdleTimeUpDow.SetValue(ui.DimTimeout);
                PuffScreenDelayUpDown.SetValue(ui.PuffScreenDelay / 10m);
                StealthModeCheckBox.Checked = ui.IsStealthMode;
                FlippedModeCheckBox.Checked = ui.IsFlipped;
                MainScreenSkinComboBox.SelectItem(ui.MainScreenSkin);
                UseClassicMenuCheckBox.Checked = ui.IsClassicMenu;
                ShowLogoCheckBox.Checked       = ui.IsLogoEnabled;
                ShowClockCheckBox.Checked      = ui.IsClockOnMainScreen;
                ClockTypeComboBox.SelectItem(ui.ClockType);
                ScreensaverTimeComboBox.SelectItem(ui.ScreensaveDuration);
                ChargeScreenComboBox.SelectItem(ui.ChargeScreenType);

                // Classic Screen
                InitializeLineContentEditor(ui.ClassicSkinVWLines.Line1, ClassicVWLine1ComboBox, ClassicVWLine1FireCheckBox);
                InitializeLineContentEditor(ui.ClassicSkinVWLines.Line2, ClassicVWLine2ComboBox, ClassicVWLine2FireCheckBox);
                InitializeLineContentEditor(ui.ClassicSkinVWLines.Line3, ClassicVWLine3ComboBox, ClassicVWLine3FireCheckBox);
                InitializeLineContentEditor(ui.ClassicSkinVWLines.Line4, ClassicVWLine4ComboBox, ClassicVWLine4FireCheckBox);

                InitializeLineContentEditor(ui.ClassicSkinTCLines.Line1, ClassicTCLine1ComboBox, ClassicTCLine1FireCheckBox);
                InitializeLineContentEditor(ui.ClassicSkinTCLines.Line2, ClassicTCLine2ComboBox, ClassicTCLine2FireCheckBox);
                InitializeLineContentEditor(ui.ClassicSkinTCLines.Line3, ClassicTCLine3ComboBox, ClassicTCLine3FireCheckBox);
                InitializeLineContentEditor(ui.ClassicSkinTCLines.Line4, ClassicTCLine4ComboBox, ClassicTCLine4FireCheckBox);

                // Circle Screen
                InitializeLineContentEditor(ui.CircleSkinVWLines.Line1, CircleVWLine1ComboBox);
                InitializeLineContentEditor(ui.CircleSkinVWLines.Line2, CircleVWLine2ComboBox);
                InitializeLineContentEditor(ui.CircleSkinVWLines.Line3, CircleVWLine3ComboBox, CircleVWLine3FireCheckBox);

                InitializeLineContentEditor(ui.CircleSkinTCLines.Line1, CircleTCLine1ComboBox);
                InitializeLineContentEditor(ui.CircleSkinTCLines.Line2, CircleTCLine2ComboBox);
                InitializeLineContentEditor(ui.CircleSkinTCLines.Line3, CircleTCLine3ComboBox, CircleTCLine3FireCheckBox);

                // Small Screen
                InitializeLineContentEditor(ui.SmallSkinVWLines.Line1, SmallVWLine1ComboBox, SmallVWLine1FireCheckBox);
                InitializeLineContentEditor(ui.SmallSkinVWLines.Line2, SmallVWLine2ComboBox, SmallVWLine2FireCheckBox);

                InitializeLineContentEditor(ui.SmallSkinTCLines.Line1, SmallTCLine1ComboBox, SmallTCLine1FireCheckBox);
                InitializeLineContentEditor(ui.SmallSkinTCLines.Line2, SmallTCLine2ComboBox, SmallTCLine2FireCheckBox);

                ClicksVW2ComboBox.SelectItem(ui.ClicksVW[0]);
                ClicksVW3ComboBox.SelectItem(ui.ClicksVW[1]);
                ClicksVW4ComboBox.SelectItem(ui.ClicksVW[2]);

                ClicksTC2ComboBox.SelectItem(ui.ClicksTC[0]);
                ClicksTC3ComboBox.SelectItem(ui.ClicksTC[1]);
                ClicksTC4ComboBox.SelectItem(ui.ClicksTC[2]);

                UpDownButtonsComboBox.SelectItem(ui.IsUpDownSwapped);
                WakeUpByPlusMinusCheckBox.Checked = ui.WakeUpByPlusMinus;
                Step1WCheckBox.Checked            = ui.IsPowerStep1W;

                LayoutTabControl.SelectedTab = deviceInfo.DisplaySize == ArcticFoxConfiguration.DisplaySize.W64H128
                                        ? ui.MainScreenSkin == ArcticFoxConfiguration.Skin.Classic
                                                ? ClassicScreenTabPage
                                                : CircleScreenTabPage
                                        : SmallScreenTabPage;
            }

            var stats = m_deviceConfiguration.Counters;
            {
                PuffsUpDown.SetValue(stats.PuffsCount);
                PuffsTimeUpDown.SetValue(stats.PuffsTime / 10m);
                PuffsTimeFormatComboBox.SelectItem(ui.PuffsTimeFormat);
            }

            var advanced = m_deviceConfiguration.Advanced;
            {
                PuffCutOffUpDown.SetValue(advanced.PuffCutOff / 10m);
                ShuntCorrectionUpDown.SetValue(advanced.ShuntCorrection);
                BatteryModelComboBox.SelectItem(advanced.BatteryModel);
                X32CheckBox.Checked           = advanced.IsX32;
                LightSleepCheckBox.Checked    = advanced.IsLightSleepMode;
                ResetCountersCheckBox.Checked = advanced.ResetCountersOnStartup;
                CheckTCRCheckBox.Checked      = advanced.CheckTCR;
                UsbChargeCheckBox.Checked     = advanced.IsUsbCharge;
                UsbNoSleepCheckBox.Checked    = advanced.UsbNoSleep;

                Battery1OffsetUpDown.SetValue(advanced.BatteryVoltageOffsets[0] / 100m);
                Battery2OffsetUpDown.SetValue(advanced.BatteryVoltageOffsets[1] / 100m);
                Battery3OffsetUpDown.SetValue(advanced.BatteryVoltageOffsets[2] / 100m);
                Battery4OffsetUpDown.SetValue(advanced.BatteryVoltageOffsets[3] / 100m);

                PowerCurvesListView.Items.Clear();
                PowerCurvesListView.LargeImageList.Images.Clear();
                for (var i = 0; i < m_deviceConfiguration.Advanced.PowerCurves.Length; i++)
                {
                    var powerCurve = m_deviceConfiguration.Advanced.PowerCurves[i];
                    var bitmap     = ChartPreviewService.CreatePowerCurvePreview(powerCurve, PowerCurvesListView.LargeImageList.ImageSize);
                    PowerCurvesListView.LargeImageList.Images.Add(bitmap);
                    PowerCurvesListView.Items.Add(new ListViewItem(powerCurve.Name, i)
                    {
                        Tag = i
                    });
                }

                MaterialsListView.Items.Clear();
                MaterialsListView.LargeImageList.Images.Clear();
                for (var i = 0; i < m_deviceConfiguration.Advanced.TFRTables.Length; i++)
                {
                    var tfrTable = m_deviceConfiguration.Advanced.TFRTables[i];
                    var bitmap   = ChartPreviewService.CreateTFRCurvePreview(tfrTable, PowerCurvesListView.LargeImageList.ImageSize);
                    MaterialsListView.LargeImageList.Images.Add(bitmap);
                    MaterialsListView.Items.Add(new ListViewItem("[TFR] " + tfrTable.Name, i)
                    {
                        Tag = i
                    });
                }
            }
        }
Example #6
0
        private void InitializeComboBoxes()
        {
            // Fill Classic Skin ComboBoxes
            foreach (var comboBox in new[]
            {
                ClassicVWLine1ComboBox, ClassicVWLine2ComboBox, ClassicVWLine3ComboBox, ClassicVWLine4ComboBox,
                ClassicTCLine1ComboBox, ClassicTCLine2ComboBox, ClassicTCLine3ComboBox, ClassicTCLine4ComboBox,
            })
            {
                comboBox.Fill(PredefinedData.ArcticFox.ClassicSkinLineContentItems);
            }

            // Fill Circle Skin ComboBoxes
            foreach (var comboBox in new[]
            {
                CircleVWLine1ComboBox, CircleVWLine2ComboBox,
                CircleTCLine1ComboBox, CircleTCLine2ComboBox
            })
            {
                comboBox.Fill(PredefinedData.ArcticFox.CircleSkinLineContentItems);
            }
            CircleVWLine3ComboBox.Fill(PredefinedData.ArcticFox.CircleSkin3RdLineContentItems);
            CircleTCLine3ComboBox.Fill(PredefinedData.ArcticFox.CircleSkin3RdLineContentItems);

            // Fill Small Skin ComboBoxes
            foreach (var comboBox in new[] { SmallVWLine1ComboBox, SmallVWLine2ComboBox, SmallTCLine1ComboBox, SmallTCLine2ComboBox, })
            {
                comboBox.Fill(PredefinedData.ArcticFox.SmallScreenLineContentItems);
            }

            MainScreenSkinComboBox.Fill(PredefinedData.ArcticFox.MainScreenSkins);
            ChargeScreenComboBox.Fill(PredefinedData.ArcticFox.ChargeScreenTypes);
            ClockTypeComboBox.Fill(PredefinedData.ArcticFox.ClockTypes);
            ScreensaverTimeComboBox.Fill(PredefinedData.ArcticFox.ScreenSaverTimes);

            foreach (var clickComboBox in new[]
            {
                ClicksVW2ComboBox, ClicksVW3ComboBox, ClicksVW4ComboBox,
                ClicksTC2ComboBox, ClicksTC3ComboBox, ClicksTC4ComboBox
            })
            {
                clickComboBox.Fill(PredefinedData.ArcticFox.ClickActions);
            }
            UpDownButtonsComboBox.Fill(PredefinedData.ArcticFox.UpDownButtons);

            PuffsTimeFormatComboBox.Fill(PredefinedData.ArcticFox.PuffTimeFormats);
            BatteryModelComboBox.Fill(PredefinedData.ArcticFox.BatteryModels);
            BatteryModelComboBox.SelectedValueChanged += (s, e) =>
            {
                var batteryModel = BatteryModelComboBox.GetSelectedItem <ArcticFoxConfiguration.BatteryModel>();
                BatteryEditButton.Visible = batteryModel == ArcticFoxConfiguration.BatteryModel.Custom;
            };

            SelectedProfleComboBox.SelectedValueChanged += (s, e) =>
            {
                var profileIndex = SelectedProfleComboBox.GetSelectedItem <byte>();
                if (profileIndex >= ProfilesTabControl.TabCount)
                {
                    return;
                }

                for (var i = 0; i < ProfilesTabControl.TabCount; i++)
                {
                    var tabPage    = ProfilesTabControl.TabPages[i];
                    var tabContent = tabPage.Controls[0] as ProfileTabContent;
                    if (tabContent == null)
                    {
                        return;
                    }

                    if (i == profileIndex)
                    {
                        tabContent.CanDeactive        = false;
                        tabContent.IsProfileActivated = true;
                    }
                    else
                    {
                        tabContent.CanDeactive = true;
                    }
                }
            };
        }