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()); }
protected override void OnClick() { if (AdvancedModeEnabled) { // Stop forcing advanced mode on, and sync the thresholds so we exit advanced mode. ForcedOn = false; for (int pad = 0; pad < 2; ++pad) { SMX.SMXConfig config; if (!SMX.SMX.GetConfig(pad, out config)) { continue; } ConfigPresets.SyncUnifiedThresholds(ref config); SMX.SMX.SetConfig(pad, config); } CurrentSMXDevice.singleton.FireConfigurationChanged(this); } else { // Enable advanced mode. ForcedOn = true; } // Refresh the UI. LoadFromConfigDelegateArgs args = CurrentSMXDevice.singleton.GetState(); LoadUIFromConfig(args.controller[args.FirstController].config); }
private void Select() { foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { int pad = activePad.Item1; SMX.SMXConfig config = activePad.Item2; ConfigPresets.SetPreset(Type, ref config); SMX.SMX.SetConfig(pad, config); } CurrentSMXDevice.singleton.FireConfigurationChanged(this); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); Button button = GetTemplateChild("PART_Button") as Button; button.Click += delegate(object sender, RoutedEventArgs e) { Select(); }; onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { string CurrentPreset = ConfigPresets.GetPreset(args.controller[args.FirstController].config); Selected = CurrentPreset == Type; }); }
private void Select() { foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { int pad = activePad.Item1; SMX.SMXConfig config = activePad.Item2; ConfigPresets.SetPreset(Type, ref config); Console.WriteLine("PresetButton::Select (" + Type + "): " + config.panelThreshold1Low + ", " + config.panelThreshold4Low + ", " + config.panelThreshold7Low + ", " + config.panelThreshold2Low); SMX.SMX.SetConfig(pad, config); } CurrentSMXDevice.singleton.FireConfigurationChanged(this); }
private void Select() { for (int pad = 0; pad < 2; ++pad) { SMX.SMXConfig config; if (!SMX.SMX.GetConfig(pad, out config)) { continue; } ConfigPresets.SetPreset(Type, ref config); Console.WriteLine("PresetButton::Select (" + Type + "): " + config.panelThreshold1Low + ", " + config.panelThreshold4Low + ", " + config.panelThreshold7Low + ", " + config.panelThreshold2Low); SMX.SMX.SetConfig(pad, config); } CurrentSMXDevice.singleton.FireConfigurationChanged(this); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); Button button = GetTemplateChild("PART_Button") as Button; button.Click += delegate(object sender, RoutedEventArgs e) { Select(); }; onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) { foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { SMX.SMXConfig config = activePad.Item2; string CurrentPreset = ConfigPresets.GetPreset(config); Selected = CurrentPreset == Type; break; } }); }
private void LoadUIFromConfig(SMX.SMXConfig config) { // The master version doesn't actually matter, but we use this as a signal that the panels // have a new enough firmware to support this. bool SupportsAdvancedMode = config.masterVersion != 0xFF && config.masterVersion >= 2; Visibility = SupportsAdvancedMode? Visibility.Visible:Visibility.Collapsed; // If the thresholds are different, force the checkbox on. This way, if you load the application // with a platform with per-panel thresholds, and change the thresholds to no longer be different, // advanced mode stays forced on. It'll only turn off if you uncheck the box, or if you exit // the application with synced thresholds and then restart it. if (SupportsAdvancedMode && !ConfigPresets.AreUnifiedThresholdsSynced(config)) { ForcedOn = true; } // Enable advanced mode if the master says it's supported, and either the user has checked the // box to turn it on or the thresholds are different in the current configuration. AdvancedModeEnabled = SupportsAdvancedMode && ForcedOn; }
private void SetValueToConfig(ref SMX.SMXConfig config) { byte lower = (byte)slider.LowerValue; byte upper = (byte)slider.UpperValue; switch (Type) { case "up-left": config.panelThreshold0Low = lower; config.panelThreshold0High = upper; break; case "up": config.panelThreshold1Low = lower; config.panelThreshold1High = upper; break; case "up-right": config.panelThreshold2Low = lower; config.panelThreshold2High = upper; break; case "left": config.panelThreshold3Low = lower; config.panelThreshold3High = upper; break; case "center": config.panelThreshold4Low = lower; config.panelThreshold4High = upper; break; case "right": config.panelThreshold5Low = lower; config.panelThreshold5High = upper; break; case "down-left": config.panelThreshold6Low = lower; config.panelThreshold6High = upper; break; case "down": config.panelThreshold7Low = lower; config.panelThreshold7High = upper; break; case "down-right": config.panelThreshold8Low = lower; config.panelThreshold8High = upper; break; case "cardinal": config.panelThreshold7Low = lower; config.panelThreshold7High = upper; break; case "corner": config.panelThreshold2Low = lower; config.panelThreshold2High = upper; break; } // If we're not in advanced mode, sync the cardinal value to each of the panel values. if (!AdvancedModeEnabled) { ConfigPresets.SyncUnifiedThresholds(ref config); } }
static private List <PanelAndSensor> GetControlledSensorsForSliderTypeInternal(string Type, bool advancedMode, bool includeOverridden) { // inner-sensors and outer-sensors do nothing if their checkbox is disabled. We do this here because we // need to skip this for the RemoveFromSensorList logic above. if (!includeOverridden) { if (Type == "inner-sensors" && !Properties.Settings.Default.UseInnerSensorThresholds) { return(new List <PanelAndSensor>()); } if (Type == "outer-sensors" && !Properties.Settings.Default.UseOuterSensorThresholds) { return(new List <PanelAndSensor>()); } } // Special sliders: if (Type == "custom-sensors") { return(GetCustomSensors()); } if (Type == "inner-sensors") { return(GetInnerSensors()); } if (Type == "outer-sensors") { return(GetOuterSensors()); } List <PanelAndSensor> result = new List <PanelAndSensor>(); // Check if this slider is shown in this mode. if (advancedMode) { // Hide the combo sliders in advanced mode. if (Type == "cardinal" || Type == "corner") { return(result); } } if (!advancedMode) { // Only these sliders are shown in normal mode. if (Type != "up" && Type != "center" && Type != "cardinal" && Type != "corner") { return(result); } } // If advanced mode is disabled, save to all panels this slider affects. The down arrow controls // all four cardinal panels. (If advanced mode is enabled we'll never be a different cardinal // direction, since those widgets won't exist.) If it's disabled, just write to our own panel. List <int> saveToPanels = new List <int>(); int ourPanelIdx = panelNameToIndex[Type]; saveToPanels.Add(ourPanelIdx); if (!advancedMode) { saveToPanels.AddRange(ConfigPresets.GetPanelsToSyncUnifiedThresholds(ourPanelIdx)); } foreach (int panelIdx in saveToPanels) { for (int sensor = 0; sensor < 4; ++sensor) { result.Add(new PanelAndSensor(panelIdx, sensor)); } } return(result); }