Add 'auto mode' button to the air alarm ui (#17874)
Signed-off-by: c4llv07e <kseandi@gmail.com>
This commit is contained in:
@@ -33,6 +33,7 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
|
||||
_window.AtmosDeviceDataChanged += OnDeviceDataChanged;
|
||||
_window.AtmosAlarmThresholdChanged += OnThresholdChanged;
|
||||
_window.AirAlarmModeChanged += OnAirAlarmModeChanged;
|
||||
_window.AutoModeChanged += OnAutoModeChanged;
|
||||
_window.ResyncAllRequested += ResyncAllDevices;
|
||||
_window.AirAlarmTabChange += OnTabChanged;
|
||||
}
|
||||
@@ -52,6 +53,11 @@ public sealed class AirAlarmBoundUserInterface : BoundUserInterface
|
||||
SendMessage(new AirAlarmUpdateAlarmModeMessage(mode));
|
||||
}
|
||||
|
||||
private void OnAutoModeChanged(bool enabled)
|
||||
{
|
||||
SendMessage(new AirAlarmUpdateAutoModeMessage(enabled));
|
||||
}
|
||||
|
||||
private void OnThresholdChanged(string address, AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null)
|
||||
{
|
||||
SendMessage(new AirAlarmUpdateAlarmThresholdMessage(address, type, threshold, gas));
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'air-alarm-ui-window-mode-label'}" Margin="0 0 2 0" />
|
||||
<OptionButton Name="CModeButton" HorizontalExpand="True" />
|
||||
<CheckBox Name="AutoModeCheckBox" Text="{Loc 'air-alarm-ui-window-auto-mode-label'}" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</ui:FancyWindow>
|
||||
|
||||
@@ -20,6 +20,7 @@ public sealed partial class AirAlarmWindow : FancyWindow
|
||||
public event Action<string, IAtmosDeviceData>? AtmosDeviceDataChanged;
|
||||
public event Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? AtmosAlarmThresholdChanged;
|
||||
public event Action<AirAlarmMode>? AirAlarmModeChanged;
|
||||
public event Action<bool>? AutoModeChanged;
|
||||
public event Action<string>? ResyncDeviceRequested;
|
||||
public event Action? ResyncAllRequested;
|
||||
public event Action<AirAlarmTab>? AirAlarmTabChange;
|
||||
@@ -44,6 +45,8 @@ public sealed partial class AirAlarmWindow : FancyWindow
|
||||
|
||||
private OptionButton _modes => CModeButton;
|
||||
|
||||
private CheckBox _autoMode => AutoModeCheckBox;
|
||||
|
||||
public AirAlarmWindow(BoundUserInterface owner)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
@@ -68,6 +71,11 @@ public sealed partial class AirAlarmWindow : FancyWindow
|
||||
AirAlarmModeChanged!.Invoke((AirAlarmMode) args.Id);
|
||||
};
|
||||
|
||||
_autoMode.OnToggled += args =>
|
||||
{
|
||||
AutoModeChanged!.Invoke(_autoMode.Pressed);
|
||||
};
|
||||
|
||||
_tabContainer.SetTabTitle(0, Loc.GetString("air-alarm-ui-window-tab-vents"));
|
||||
_tabContainer.SetTabTitle(1, Loc.GetString("air-alarm-ui-window-tab-scrubbers"));
|
||||
_tabContainer.SetTabTitle(2, Loc.GetString("air-alarm-ui-window-tab-sensors"));
|
||||
@@ -101,6 +109,7 @@ public sealed partial class AirAlarmWindow : FancyWindow
|
||||
("color", ColorForAlarm(state.AlarmType)),
|
||||
("state", $"{state.AlarmType}")));
|
||||
UpdateModeSelector(state.Mode);
|
||||
UpdateAutoMode(state.AutoMode);
|
||||
foreach (var (addr, dev) in state.DeviceData)
|
||||
{
|
||||
UpdateDeviceData(addr, dev);
|
||||
@@ -114,6 +123,11 @@ public sealed partial class AirAlarmWindow : FancyWindow
|
||||
_modes.SelectId((int) mode);
|
||||
}
|
||||
|
||||
public void UpdateAutoMode(bool enabled)
|
||||
{
|
||||
_autoMode.Pressed = enabled;
|
||||
}
|
||||
|
||||
public void UpdateDeviceData(string addr, IAtmosDeviceData device)
|
||||
{
|
||||
switch (device)
|
||||
|
||||
Reference in New Issue
Block a user