项目文件夹

文件
wehub-resource-sync 79031da543
Spell checking / Check Spelling (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled
Publish Dev Docs Website / build (push) Failing after 1s
Publish Dev Docs Website / deploy (push) Has been skipped
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:16:02 +08:00

468 行
30 KiB
XML

<?xml version="1.0" encoding="utf-8" ?>
<local:NavigablePage
x:Class="Microsoft.PowerToys.Settings.UI.Views.LightSwitchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ptcontrols="using:Microsoft.PowerToys.Common.UI.Controls"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:viewModels="using:Microsoft.PowerToys.Settings.UI.ViewModels"
d:DataContext="{d:DesignInstance Type=viewModels:LightSwitchViewModel}"
AutomationProperties.LandmarkType="Main"
mc:Ignorable="d">
<local:NavigablePage.Resources>
<converters:TimeSpanToFriendlyTimeConverter x:Key="TimeSpanToFriendlyTimeConverter" />
<converters:StringToDoubleConverter x:Key="StringToDoubleConverter" />
</local:NavigablePage.Resources>
<Grid>
<controls:SettingsPageControl
x:Uid="LightSwitch"
IsTabStop="False"
ModuleImageSource="ms-appx:///Assets/Settings/Modules/LightSwitch.png">
<controls:SettingsPageControl.ModuleContent>
<StackPanel Orientation="Vertical">
<controls:GPOInfoControl ShowWarning="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}">
<tkcontrols:SettingsCard
x:Uid="LightSwitch_EnableSettingsCard"
HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/LightSwitch.png}"
IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch AutomationProperties.AutomationId="Toggle_LightSwitch" IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</controls:GPOInfoControl>
<controls:SettingsGroup x:Uid="LightSwitch_ShortcutsSettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard x:Uid="LightSwitch_ThemeToggle_Shortcut" HeaderIcon="{ui:FontIcon Glyph=&#xE708;}">
<controls:ShortcutControl
MinWidth="{StaticResource SettingActionControlMinWidth}"
AllowDisable="True"
AutomationProperties.AutomationId="Shortcut_LightSwitch"
HotkeySettings="{x:Bind Path=ViewModel.ToggleThemeActivationShortcut, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="LightSwitch_ScheduleSettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsExpander
x:Uid="LightSwitch_ModeSettingsExpander"
HeaderIcon="{ui:FontIcon Glyph=&#xE823;}"
IsExpanded="True">
<ComboBox
x:Name="ModeSelector"
AutomationProperties.AutomationId="ModeSelection_LightSwitch"
SelectedValue="{x:Bind ViewModel.ScheduleMode, Mode=TwoWay}"
SelectedValuePath="Tag"
SelectionChanged="ModeSelector_SelectionChanged">
<ComboBoxItem
x:Uid="LightSwitch_ModeOff"
AutomationProperties.AutomationId="OffCBItem_LightSwitch"
Tag="Off" />
<ComboBoxItem
x:Uid="LightSwitch_ModeManual"
AutomationProperties.AutomationId="ManualCBItem_LightSwitch"
Tag="FixedHours" />
<ComboBoxItem
x:Uid="LightSwitch_ModeSunsetToSunrise"
AutomationProperties.AutomationId="SunCBItem_LightSwitch"
Tag="SunsetToSunrise" />
<ComboBoxItem
x:Uid="LightSwitch_ModeFollowNightLight"
AutomationProperties.AutomationId="FollowNightLightCBItem_LightSwitch"
Tag="FollowNightLight" />
</ComboBox>
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard
x:Name="Fixed_TurnOnCard"
x:Uid="LightSwitch_TurnOnDarkMode"
Visibility="Collapsed">
<TimePicker AutomationProperties.AutomationId="DarkTimePicker" Time="{x:Bind ViewModel.DarkTimePickerValue, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="Fixed_TurnOffCard"
x:Uid="LightSwitch_TurnOffDarkMode"
Visibility="Collapsed">
<TimePicker AutomationProperties.AutomationId="LightTimePicker" Time="{x:Bind ViewModel.LightTimePickerValue, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="SunLocation_Card"
x:Uid="LightSwitch_LocationSettingsCard"
Visibility="Collapsed">
<StackPanel Orientation="Horizontal" Spacing="8">
<ptcontrols:IsEnabledTextBlock
VerticalAlignment="Center"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind ViewModel.SyncButtonInformation, Mode=OneWay}" />
<Button
x:Uid="LightSwitch_SetLocationButton"
AutomationProperties.AutomationId="SetLocationButton_LightSwitch"
Click="SyncLocationButton_Click" />
</StackPanel>
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="SunOffset_Card"
x:Uid="LightSwitch_OffsetSettingsCard"
Visibility="Collapsed">
<StackPanel Orientation="Horizontal" Spacing="20">
<StackPanel Orientation="Horizontal" Spacing="8">
<!--<FontIcon Glyph="&#xED39;" FontSize="16" />-->
<ptcontrols:IsEnabledTextBlock x:Uid="LightSwitch_SunriseText" VerticalAlignment="Center" />
<NumberBox
AutomationProperties.AutomationId="SunriseOffset_LightSwitch"
Maximum="{x:Bind ViewModel.SunriseOffsetMax, Mode=OneWay}"
Minimum="{x:Bind ViewModel.SunriseOffsetMin, Mode=OneWay}"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.SunriseOffset, Mode=TwoWay}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="8">
<ptcontrols:IsEnabledTextBlock x:Uid="LightSwitch_SunsetText" VerticalAlignment="Center" />
<NumberBox
AutomationProperties.AutomationId="SunsetOffset_LightSwitch"
Maximum="{x:Bind ViewModel.SunsetOffsetMax, Mode=OneWay}"
Minimum="{x:Bind ViewModel.SunsetOffsetMin, Mode=OneWay}"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.SunsetOffset, Mode=TwoWay}" />
</StackPanel>
</StackPanel>
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="TimelineCard"
HorizontalContentAlignment="Stretch"
ContentAlignment="Vertical"
Visibility="Collapsed">
<controls:Timeline
Margin="0,24,0,24"
AutomationProperties.AutomationId="Timeline_LightSwitch"
EndTime="{x:Bind ViewModel.DarkTimeTimeSpan, Mode=OneWay}"
StartTime="{x:Bind ViewModel.LightTimeTimeSpan, Mode=OneWay}"
Sunrise="{x:Bind ViewModel.SunriseTimeSpan, Mode=OneWay}"
Sunset="{x:Bind ViewModel.SunsetTimeSpan, Mode=OneWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="NoScheduleCard"
Padding="0"
HorizontalContentAlignment="Stretch"
Background="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}"
ContentAlignment="Vertical"
Visibility="Visible">
<InfoBar
x:Uid="LightSwitch_ScheduleOffMessage"
Background="Transparent"
BorderThickness="0"
IsClosable="False"
IsOpen="True"
Severity="Informational" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="FollowNightLightCard"
Padding="0"
HorizontalContentAlignment="Stretch"
Background="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}"
ContentAlignment="Vertical"
Visibility="Collapsed">
<InfoBar
Background="Transparent"
BorderThickness="0"
IsClosable="False"
IsOpen="True"
Severity="Informational">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center">
<Run x:Uid="LightSwitch_FollowNightLightCardMessage" />
</TextBlock>
<HyperlinkButton
x:Uid="LightSwitch_NightLightSettingsButton"
Margin="3,0,0,0"
Padding="0"
Click="OpenNightLightSettings_Click" />
</StackPanel>
</InfoBar>
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
<InfoBar
x:Name="LocationWarningBar"
x:Uid="LightSwitch_LocationWarningBar"
IsOpen="True"
Severity="Informational"
Visibility="Collapsed" />
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="LightSwitch_BehaviorSettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsExpander
x:Uid="LightSwitch_ApplyDarkModeExpander"
HeaderIcon="{ui:FontIcon Glyph=&#xE790;}"
IsExpanded="True">
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard HorizontalContentAlignment="Stretch" ContentAlignment="Left">
<ptcontrols:CheckBoxWithDescriptionControl
x:Uid="LightSwitch_SystemCheckbox"
AutomationProperties.AutomationId="ChangeSystemCheckbox_LightSwitch"
IsChecked="{x:Bind ViewModel.ChangeSystem, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard HorizontalContentAlignment="Stretch" ContentAlignment="Left">
<ptcontrols:CheckBoxWithDescriptionControl
x:Uid="LightSwitch_AppsCheckbox"
AutomationProperties.AutomationId="ChangeAppsCheckbox_LightSwitch"
IsChecked="{x:Bind ViewModel.ChangeApps, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
<InfoBar
x:Name="PowerDisplayDisabledWarningBar"
x:Uid="LightSwitch_PowerDisplayDisabledWarningBar"
Background="Transparent"
BorderBrush="Transparent"
IsClosable="False"
IsOpen="True"
IsTabStop="True"
Severity="Informational"
Visibility="{x:Bind ViewModel.ShowPowerDisplayDisabledWarning, Mode=OneWay}">
<InfoBar.ActionButton>
<HyperlinkButton
x:Uid="LightSwitch_NavigatePowerDisplaySettings"
HorizontalAlignment="Right"
Click="NavigatePowerDisplaySettings_Click" />
</InfoBar.ActionButton>
</InfoBar>
<tkcontrols:SettingsExpander
x:Uid="LightSwitch_ApplyMonitorSettingsExpander"
HeaderIcon="{ui:FontIcon Glyph=&#xE7F4;}"
IsExpanded="True">
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard>
<tkcontrols:SettingsCard.Header>
<CheckBox
x:Uid="LightSwitch_DarkModeProfileCheckbox"
IsChecked="{x:Bind ViewModel.EnableDarkModeProfile, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.IsPowerDisplayEnabled, Mode=OneWay}" />
</tkcontrols:SettingsCard.Header>
<ComboBox
MinWidth="200"
DisplayMemberPath="Name"
IsEnabled="{x:Bind ViewModel.IsPowerDisplayEnabled, Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.AvailableProfiles, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.SelectedDarkModeProfile, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard>
<tkcontrols:SettingsCard.Header>
<CheckBox
x:Uid="LightSwitch_LightModeProfileCheckbox"
IsChecked="{x:Bind ViewModel.EnableLightModeProfile, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.IsPowerDisplayEnabled, Mode=OneWay}" />
</tkcontrols:SettingsCard.Header>
<ComboBox
MinWidth="200"
DisplayMemberPath="Name"
IsEnabled="{x:Bind ViewModel.IsPowerDisplayEnabled, Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.AvailableProfiles, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.SelectedLightModeProfile, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</tkcontrols:SettingsExpander.Items>
</tkcontrols:SettingsExpander>
</controls:SettingsGroup>
<!-- Force mode buttons -->
<!--<tkcontrols:SettingsCard
Header="Force mode now"
HeaderIcon="{ui:FontIcon Glyph=&#xE706;}"
Description="Apply light or dark mode immediately">
<StackPanel Orientation="Horizontal" Spacing="12">
<Button
Content="Force Light"
Command="{x:Bind ViewModel.ForceLightCommand}" />
<Button
Content="Force Dark"
Command="{x:Bind ViewModel.ForceDarkCommand}" />
</StackPanel>
</tkcontrols:SettingsCard>-->
<ContentDialog
x:Name="LocationDialog"
x:Uid="LightSwitch_LocationDialog"
IsPrimaryButtonEnabled="False"
IsSecondaryButtonEnabled="True"
PrimaryButtonClick="LocationDialog_PrimaryButtonClick"
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
<Grid RowSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" MinHeight="64" />
</Grid.RowDefinitions>
<TextBlock
x:Uid="LightSwitch_LocationDialog_Description"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
TextWrapping="Wrap" />
<!--<AutoSuggestBox
x:Name="CityAutoSuggestBox"
Grid.Row="1"
Margin="0,16,0,8"
AutomationProperties.AutomationId="CitySearchBox_LightSwitch"
ItemsSource="{x:Bind ViewModel.SearchLocations, Mode=OneWay}"
PlaceholderText="Search for a city near you.."
QueryIcon="Find"
SuggestionChosen="CityAutoSuggestBox_SuggestionChosen"
TextChanged="CityAutoSuggestBox_TextChanged">
<AutoSuggestBox.ItemTemplate>
<DataTemplate x:DataType="helpers:SearchLocation">
<Grid Padding="12,8,0,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{x:Bind City}" />
<TextBlock
Grid.Row="1"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind Country}" />
</Grid>
</DataTemplate>
</AutoSuggestBox.ItemTemplate>
</AutoSuggestBox>-->
<Grid
Grid.Row="1"
Margin="0,12,0,0"
ColumnSpacing="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="124" />
<ColumnDefinition Width="124" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<NumberBox
x:Name="LatitudeBox"
x:Uid="LightSwitch_LatitudeBox"
AutomationProperties.AutomationId="LatitudeBox_LightSwitch"
Maximum="90"
Minimum="-90"
ValueChanged="LatLonBox_ValueChanged"
Value="{x:Bind ViewModel.LocationPanelLatitude, Mode=TwoWay}" />
<NumberBox
x:Name="LongitudeBox"
x:Uid="LightSwitch_LongitudeBox"
Grid.Column="1"
AutomationProperties.AutomationId="LongitudeBox_LightSwitch"
Maximum="180"
Minimum="-180"
ValueChanged="LatLonBox_ValueChanged"
Value="{x:Bind ViewModel.LocationPanelLongitude, Mode=TwoWay}" />
<Button
x:Name="SyncButton"
x:Uid="LightSwitch_FindLocationAutomation"
Grid.Column="2"
Margin="4,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
AutomationProperties.AutomationId="SyncLocationButton_LightSwitch"
Click="GetGeoLocation_Click">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon FontSize="16" Glyph="&#xECAF;" />
<TextBlock x:Uid="LightSwitch_FindLocation" />
</StackPanel>
</Button>
</Grid>
<ProgressRing
x:Name="SyncLoader"
Grid.Row="2"
Width="40"
Height="40"
VerticalAlignment="Center"
IsActive="False"
Visibility="Collapsed" />
<TextBlock
x:Name="LocationErrorText"
Grid.Row="2"
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
TextWrapping="Wrap"
Visibility="Collapsed" />
<Grid
x:Name="LocationResultPanel"
Grid.Row="2"
VerticalAlignment="Bottom"
ColumnSpacing="16"
RowSpacing="12"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<FontIcon FontSize="20" Glyph="&#xED39;">
<ToolTipService.ToolTip>
<TextBlock x:Uid="LightSwitch_SunriseTooltip" />
</ToolTipService.ToolTip>
</FontIcon>
<TextBlock
Grid.Column="1"
AutomationProperties.AutomationId="SunriseText_LightSwitch"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind ViewModel.LocationPanelLightTime, Converter={StaticResource TimeSpanToFriendlyTimeConverter}, Mode=OneWay}"
TextAlignment="Left" />
<FontIcon
Grid.Row="1"
FontSize="20"
Glyph="&#xED3A;">
<ToolTipService.ToolTip>
<TextBlock x:Uid="LightSwitch_SunsetTooltip" />
</ToolTipService.ToolTip>
</FontIcon>
<TextBlock
Grid.Row="1"
Grid.Column="1"
AutomationProperties.AutomationId="SunsetText_LightSwitch"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind ViewModel.LocationPanelDarkTime, Converter={StaticResource TimeSpanToFriendlyTimeConverter}, Mode=OneWay}"
TextAlignment="Left" />
</Grid>
</Grid>
</ContentDialog>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>
<controls:SettingsPageControl.PrimaryLinks>
<controls:PageLink x:Uid="LearnMore_LightSwitch" Link="https://aka.ms/PowerToysOverview_LightSwitch" />
</controls:SettingsPageControl.PrimaryLinks>
</controls:SettingsPageControl>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ScheduleModeStates">
<VisualState x:Name="OffState" />
<VisualState x:Name="SunsetToSunriseState">
<VisualState.Setters>
<Setter Target="SunLocation_Card.Visibility" Value="Visible" />
<Setter Target="SunOffset_Card.Visibility" Value="Visible" />
<Setter Target="NoScheduleCard.Visibility" Value="Collapsed" />
<Setter Target="FollowNightLightCard.Visibility" Value="Collapsed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="ManualState">
<VisualState.Setters>
<Setter Target="Fixed_TurnOnCard.Visibility" Value="Visible" />
<Setter Target="Fixed_TurnOffCard.Visibility" Value="Visible" />
<Setter Target="NoScheduleCard.Visibility" Value="Collapsed" />
<Setter Target="FollowNightLightCard.Visibility" Value="Collapsed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="FollowNightLightState">
<VisualState.Setters>
<Setter Target="Fixed_TurnOnCard.Visibility" Value="Collapsed" />
<Setter Target="Fixed_TurnOffCard.Visibility" Value="Collapsed" />
<Setter Target="NoScheduleCard.Visibility" Value="Collapsed" />
<Setter Target="FollowNightLightCard.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</local:NavigablePage>