use combo box instead of radio button group for break mode background

This commit is contained in:
vanzue
2025-12-03 19:42:28 +08:00
parent 1d022dc444
commit a4da3f1da0
2 changed files with 50 additions and 22 deletions

View File

@@ -264,8 +264,7 @@
<tkcontrols:SettingsCard Name="ZoomItBreakShowBackgroundBitmap" x:Uid="ZoomIt_Break_ShowBackgroundBitmap">
<ComboBox>
<!-- TO DO: Set the SelectedIndex -->
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Path=ViewModel.BreakBackgroundSelectionIndex, Mode=TwoWay}">
<ComboBoxItem x:Uid="ZoomIt_Break_BackgroundImage_None" />
<ComboBoxItem x:Uid="ZoomIt_Break_ShowFadedDesktop" />
<ComboBoxItem x:Uid="ZoomIt_Break_ShowImageFile" />
@@ -292,20 +291,6 @@
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
<!-- - DELETE -->
<tkcontrols:SettingsExpander IsExpanded="True">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.BreakShowBackgroundFile, Mode=TwoWay}" />
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard Name="ZoomItBreakShowDesktopOrImageFile" x:Uid="ZoomIt_Break_ShowDesktopOrImageFile">
<RadioButtons SelectedIndex="{x:Bind ViewModel.BreakShowDesktopOrImageFileIndex, Mode=TwoWay}">
<RadioButton x:Uid="ZoomIt_Break_ShowFadedDesktop" />
<RadioButton x:Uid="ZoomIt_Break_ShowImageFile" />
</RadioButtons>
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
<!-- - DELETE END -->
</controls:SettingsGroup>

View File

@@ -693,26 +693,69 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
_zoomItSettings.Properties.BreakShowBackgroundFile.Value = value;
OnPropertyChanged(nameof(BreakShowBackgroundFile));
OnPropertyChanged(nameof(BreakBackgroundSelectionIndex));
NotifySettingsChanged();
}
}
}
public int BreakShowDesktopOrImageFileIndex
public bool BreakShowDesktop
{
get => _zoomItSettings.Properties.BreakShowDesktop.Value ? 0 : 1;
get => _zoomItSettings.Properties.BreakShowDesktop.Value;
set
{
bool newValue = value == 0;
if (_zoomItSettings.Properties.BreakShowDesktop.Value != newValue)
if (_zoomItSettings.Properties.BreakShowDesktop.Value != value)
{
_zoomItSettings.Properties.BreakShowDesktop.Value = newValue;
OnPropertyChanged(nameof(BreakShowDesktopOrImageFileIndex));
_zoomItSettings.Properties.BreakShowDesktop.Value = value;
OnPropertyChanged(nameof(BreakShowDesktop));
OnPropertyChanged(nameof(BreakBackgroundSelectionIndex));
NotifySettingsChanged();
}
}
}
public int BreakBackgroundSelectionIndex
{
get
{
if (!BreakShowBackgroundFile)
{
return 0;
}
return BreakShowDesktop ? 1 : 2;
}
set
{
int clampedValue = Math.Clamp(value, 0, 2);
switch (clampedValue)
{
case 0:
BreakShowBackgroundFile = false;
break;
case 1:
if (!BreakShowBackgroundFile)
{
BreakShowBackgroundFile = true;
}
BreakShowDesktop = true;
break;
case 2:
if (!BreakShowBackgroundFile)
{
BreakShowBackgroundFile = true;
}
BreakShowDesktop = false;
break;
default:
break;
}
}
}
public string BreakBackgroundFile
{
get => _zoomItSettings.Properties.BreakBackgroundFile.Value;