protected override void OnClick() { if (AdvancedModeEnabled) { // Stop forcing advanced mode on, and sync the thresholds so we exit advanced mode. ForcedOn = false; foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { int pad = activePad.Item1; SMX.SMXConfig config = activePad.Item2; ConfigPresets.SyncUnifiedThresholds(ref config); SMX.SMX.SetConfig(pad, config); } CurrentSMXDevice.singleton.FireConfigurationChanged(this); } else { // Enable advanced mode. ForcedOn = true; } // Refresh the UI. LoadUIFromConfig(ActivePad.GetFirstActivePadConfig()); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); int[] PanelToIndex = new int[] { 7, 8, 9, 4, 5, 6, 1, 2, 3, }; EnabledPanelButtons = new PanelButton[9]; for (int i = 0; i < 9; ++i) { EnabledPanelButtons[i] = GetTemplateChild("EnablePanel" + PanelToIndex[i]) as PanelButton; } foreach (PanelButton button in EnabledPanelButtons) { button.Click += EnabledPanelButtonClicked; } onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args)); }); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); slider = GetTemplateChild("Slider") as DoubleSlider; LowerLabel = GetTemplateChild("LowerValue") as Label; UpperLabel = GetTemplateChild("UpperValue") as Label; ThresholdWarning = GetTemplateChild("ThresholdWarning") as Image; SensorDisplay = GetTemplateChild("PlatformSensorDisplay") as PlatformSensorDisplay; slider.ValueChanged += delegate(DoubleSlider slider) { SaveToConfig(); }; // Show the edit button for the custom-sensors slider. Button EditCustomSensorsButton = GetTemplateChild("EditCustomSensorsButton") as Button; EditCustomSensorsButton.Visibility = Type == "custom-sensors"? Visibility.Visible:Visibility.Hidden; EditCustomSensorsButton.Click += delegate(object sender, RoutedEventArgs e) { SetCustomSensors dialog = new SetCustomSensors(); dialog.Owner = Window.GetWindow(this); dialog.ShowDialog(); }; onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args)); }); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args)); }); }
protected override void OnClick() { Properties.Settings.Default.AdvancedMode = !Properties.Settings.Default.AdvancedMode; if (!Properties.Settings.Default.AdvancedMode) { // Sync thresholds when we exit advanced mode. XXX: not needed since MainWindow is recreating // sliders anyway ThresholdSettings.SyncSliderThresholds(); } // Refresh the UI. LoadUIFromConfig(ActivePad.GetFirstActivePadConfig()); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); slider = GetTemplateChild("Slider") as DoubleSlider; LowerLabel = GetTemplateChild("LowerValue") as Label; UpperLabel = GetTemplateChild("UpperValue") as Label; slider.ValueChanged += delegate(DoubleSlider slider) { SaveToConfig(); }; onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args)); }); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); OnConfigChange onConfigChange; onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { int SelectedPad = Panel < 9? 0:1; int PanelIndex = Panel % 9; Pressed = args.controller[SelectedPad].inputs[PanelIndex]; Warning = !args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex] || args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex) || args.controller[SelectedPad].test_data.AnyBadJumpersOnPanel(PanelIndex); // Only show this panel button if the panel's input is enabled. SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args); Visibility = ShouldBeDisplayed(config)? Visibility.Visible:Visibility.Collapsed; }); onConfigChange.RefreshOnInputChange = true; onConfigChange.RefreshOnTestDataChange = true; }
void RefreshVisibility() { SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(); this.Visibility = ShouldBeDisplayed(config)? Visibility.Visible:Visibility.Collapsed; }
bool IsThresholdSliderShown(string type) { bool AdvancedModeEnabled = Properties.Settings.Default.AdvancedMode; SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(); bool[] enabledPanels = config.GetEnabledPanels(); // Check the list of sensors this slider controls. If the list is empty, don't show it. // For example, if the user adds all four sensors on the up panel to custom-sensors, the // up button has nothing left to control, so we'll hide it. // // Don't do this for custom, inner-sensors or outer-sensors. Those are always shown in // advanced mode. List <ThresholdSettings.PanelAndSensor> panelAndSensors = ThresholdSettings.GetControlledSensorsForSliderType(type, AdvancedModeEnabled, false); if (type == "custom-sensors" || type == "inner-sensors" || type == "outer-sensors") { if (!AdvancedModeEnabled || !config.fsr()) { return(false); } } else { if (panelAndSensors.Count == 0) { return(false); } } // Hide thresholds that only affect panels that are disabled, so we don't show // corner panel sliders in advanced mode if the corner panels are disabled. We // don't handle this in GetControlledSensorsForSliderType, since we do want cardinal // and corner to write thresholds to disabled panels, so they're in sync if they're // turned back on. switch (type) { case "up-left": return(enabledPanels[0]); case "up": return(enabledPanels[1]); case "up-right": return(enabledPanels[2]); case "left": return(enabledPanels[3]); case "center": return(enabledPanels[4]); case "right": return(enabledPanels[5]); case "down-left": return(enabledPanels[6]); case "down": return(enabledPanels[7]); case "down-right": return(enabledPanels[8]); // Show cardinal and corner if at least one panel they affect is enabled. case "cardinal": return(enabledPanels[3] || enabledPanels[5] || enabledPanels[8]); case "corner": return(enabledPanels[0] || enabledPanels[2] || enabledPanels[6] || enabledPanels[8]); default: return(true); } }
private void LoadUIFromConfig(LoadFromConfigDelegateArgs args) { // Refresh whether LightsAnimation_SetAuto should be enabled. SMX.SMXConfig firstConfig = ActivePad.GetFirstActivePadConfig(); bool usePressedAnimationsEnabled = (firstConfig.configFlags & SMX.SMXConfigFlags.AutoLightingUsePressedAnimations) != 0; SMX.SMX.LightsAnimation_SetAuto(usePressedAnimationsEnabled); bool EitherControllerConnected = args.controller[0].info.connected || args.controller[1].info.connected; Main.Visibility = EitherControllerConnected ? Visibility.Visible : Visibility.Hidden; Searching.Visibility = EitherControllerConnected ? Visibility.Hidden : Visibility.Visible; ConnectedPads.Visibility = EitherControllerConnected ? Visibility.Visible : Visibility.Hidden; PanelColorP1.Visibility = args.controller[0].info.connected ? Visibility.Visible : Visibility.Collapsed; PanelColorP2.Visibility = args.controller[1].info.connected ? Visibility.Visible : Visibility.Collapsed; EnableCenterTopSensorCheckbox.Visibility = P1_Floor.Visibility = P2_Floor.Visibility = args.firmwareVersion() >= 5 ? Visibility.Visible : Visibility.Collapsed; // Show the color slider or GIF UI depending on which one is set in flags. // If both pads are turned on, just use the first one. foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { SMX.SMXConfig config = activePad.Item2; // If SMXConfigFlags_AutoLightingUsePressedAnimations is set, show the GIF UI. // If it's not set, show the color slider UI. SMX.SMXConfigFlags flags = config.configFlags; bool usePressedAnimations = (flags & SMX.SMXConfigFlags.AutoLightingUsePressedAnimations) != 0; ColorPickerGroup.Visibility = usePressedAnimations ? Visibility.Collapsed : Visibility.Visible; GIFGroup.Visibility = usePressedAnimations ? Visibility.Visible : Visibility.Collapsed; // Tell the color mode buttons which one is selected, to set the button highlight. PanelColorsButton.Selected = !usePressedAnimations; GIFAnimationsButton.Selected = usePressedAnimations; break; } RefreshConnectedPadList(args); RefreshUploadPadText(args); RefreshSelectedColorPicker(); // If a device has connected or disconnected, refresh the displayed threshold // sliders. Don't do this otherwise, or we'll do this when the sliders are // dragged. if (args.ConnectionsChanged) { CreateThresholdSliders(); } // Show the threshold warning explanation if any panels are showing the threshold warning icon. bool ShowThresholdWarningText = false; foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { SMX.SMXConfig config = activePad.Item2; for (int panelIdx = 0; panelIdx < 9; ++panelIdx) { for (int sensor = 0; sensor < 4; ++sensor) { if (config.ShowThresholdWarning(panelIdx, sensor)) { ShowThresholdWarningText = true; } } } } ThresholdWarningText.Visibility = ShowThresholdWarningText ? Visibility.Visible : Visibility.Hidden; // If a second controller has connected and we're on Both, see if we need to prompt // to sync configs. We only actually need to do this if a controller just connected. if (args.ConfigurationChanged) { CheckConfiguringBothPads(args); } }
private void Refresh(LoadFromConfigDelegateArgs args) { // First, make sure a valid panel is selected. SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args); SelectValidPanel(config); RefreshSelectedPanel(); // Make sure SetShowAllLights is disabled if the controller is disconnected, since // we can miss mouse up events. bool EitherControllerConnected = args.controller[0].info.connected || args.controller[1].info.connected; if (!EitherControllerConnected) { SetShowAllLights?.Invoke(false); } P1Diagnostics.Visibility = args.controller[0].info.connected? Visibility.Visible:Visibility.Collapsed; P2Diagnostics.Visibility = args.controller[1].info.connected? Visibility.Visible:Visibility.Collapsed; // Update the displayed DIP switch icons. int SelectedPad = SelectedPanel < 9? 0:1; int PanelIndex = SelectedPanel % 9; int dip = args.controller[SelectedPad].test_data.iDIPSwitchPerPanel[PanelIndex]; CurrentDIP.Frame = dip; ExpectedDIP.Frame = PanelIndex; // Show or hide the sensor error text. bool AnySensorsNotResponding = false, HaveIncorrectSensorDIP = false; if (args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex]) { AnySensorsNotResponding = args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex); // Don't show both warnings. HaveIncorrectSensorDIP = !AnySensorsNotResponding && args.controller[SelectedPad].test_data.AnyBadJumpersOnPanel(PanelIndex); } NoResponseFromSensors.Visibility = AnySensorsNotResponding? Visibility.Visible:Visibility.Collapsed; BadSensorDIPSwitches.Visibility = HaveIncorrectSensorDIP? Visibility.Visible:Visibility.Collapsed; // Adjust the DIP labels to match the PCB. bool DIPLabelsOnLeft = config.masterVersion < 4; DIPLabelRight.Visibility = DIPLabelsOnLeft? Visibility.Collapsed:Visibility.Visible; DIPLabelLeft.Visibility = DIPLabelsOnLeft? Visibility.Visible:Visibility.Collapsed; // Update the level bar from the test mode data for the selected panel. for (int sensor = 0; sensor < 4; ++sensor) { var controllerData = args.controller[SelectedPad]; Int16 value = controllerData.test_data.sensorLevel[PanelIndex * 4 + sensor]; if (GetTestMode() == SMX.SMX.SensorTestMode.Noise) { // In noise mode, we receive standard deviation values squared. Display the square // root, since the panels don't do this for us. This makes the numbers different // than the configured value (square it to convert back), but without this we display // a bunch of 4 and 5-digit numbers that are too hard to read. value = (Int16)Math.Sqrt(value); } LevelBarText[sensor].Visibility = Visibility.Visible; if (!args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex]) { LevelBars[sensor].Value = 0; LevelBarText[sensor].Visibility = Visibility.Hidden; LevelBarText[sensor].Content = "-"; LevelBars[sensor].Error = false; } else if (args.controller[SelectedPad].test_data.bBadSensorInput[PanelIndex * 4 + sensor]) { LevelBars[sensor].Value = 0; LevelBarText[sensor].Content = "!"; LevelBars[sensor].Error = true; } else { // Very slightly negative values happen due to noise. They don't indicate a // problem, but they're confusing in the UI, so clamp them away. if (value < 0 && value >= -10) { value = 0; } // Scale differently depending on if this is an FSR panel or a load cell panel. bool isFSR = controllerData.config.masterVersion >= 4 && (controllerData.config.configFlags & SMX.SMXConfigFlags.PlatformFlags_FSR) != 0; if (isFSR) { value >>= 2; } float maxValue = isFSR? 250:500; LevelBars[sensor].Value = value / maxValue; LevelBarText[sensor].Content = value; LevelBars[sensor].Error = false; } } NoResponseFromPanel.Visibility = Visibility.Collapsed; CurrentDIPGroup.Visibility = Visibility.Visible; if (!args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex]) { NoResponseFromPanel.Visibility = Visibility.Visible; NoResponseFromSensors.Visibility = Visibility.Collapsed; CurrentDIPGroup.Visibility = Visibility.Hidden; return; } }