Skip to content

Commit

Permalink
累积策略更新并新增深色模式支持 (#18)
Browse files Browse the repository at this point in the history
新增 深色模式支持
优化 格式化代码
调整 版本信息中当前版本号的显示逻辑
调整 图标文件结构
调整 README.md
更新 策略配置文件至123.0.2420.10版本
更新 依赖项
  • Loading branch information
NXY666 authored Mar 3, 2024
1 parent aca98b1 commit 65b2c03
Show file tree
Hide file tree
Showing 44 changed files with 207 additions and 1,688 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ msbuild.wrn

# Visual Studio 2015
.vs/

# DIY
/Local/
13 changes: 6 additions & 7 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:uiConverters="using:CommunityToolkit.WinUI.UI.Converters"
RequestedTheme="Light">
xmlns:uiConverters="using:CommunityToolkit.WinUI.UI.Converters">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand All @@ -16,7 +15,7 @@
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
<Style x:Key="BackButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="#4C4C4C" />
<Setter Property="Foreground" Value="{ThemeResource TextFillColorPrimaryBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
Expand Down Expand Up @@ -49,11 +48,11 @@
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="#EAEAEA" />
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleFillColorSecondaryBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="#494949" />
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorPrimaryBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<VisualState.Setters>
Expand All @@ -66,11 +65,11 @@
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="#EDEDED" />
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleFillColorSecondaryBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="#7D7D7D" />
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorTertiaryBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<VisualState.Setters>
Expand Down
12 changes: 6 additions & 6 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
namespace PolicyManager;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
InitializeComponent();
}

public static Window MWindow { get; private set; }

/// <summary>
/// Invoked when the application is launched.
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
Expand All @@ -29,6 +31,4 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
MWindow.ExtendsContentIntoTitleBar = true;
MWindow.Activate();
}

public static Window MWindow { get; private set; }
}
1 change: 0 additions & 1 deletion Assets/github.svg

This file was deleted.

Binary file modified Assets/icon.ico
Binary file not shown.
8 changes: 4 additions & 4 deletions MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class GoPageParameter

public class MainPageModel(MainPage mainPage) : INotifyPropertyChanged
{
private string _activePageName;

public bool CanGoBack => mainPage.MainFrame.CanGoBack;

public bool CantGoBack => !CanGoBack;

private string _activePageName;

public string ActivePageName
{
get => _activePageName;
Expand All @@ -32,6 +32,8 @@ public string ActivePageName
}
}

public event PropertyChangedEventHandler PropertyChanged;

public void GoBack()
{
if (!CanGoBack) return;
Expand Down Expand Up @@ -64,8 +66,6 @@ private void OnRouteUpdated()
OnPropertyChanged(nameof(CantGoBack));
}

public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
Expand Down
2 changes: 1 addition & 1 deletion Pages/Policy/Contents/IntegerContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
GotFocus="NumberBox_OnGotFocus" LostFocus="NumberBox_OnLostFocus" />
<HyperlinkButton x:Name="AcceptButton" Width="32" Height="32" Margin="5,0,-37,0" Visibility="Collapsed" Padding="0">
<HyperlinkButton.Content>
<FontIcon Glyph="&#xE8FB;" FontSize="14" Foreground="#18864B" FontWeight="bold"/>
<FontIcon Glyph="&#xE8FB;" FontSize="14" Foreground="{ThemeResource SystemFillColorSuccessBrush}" FontWeight="bold" />
</HyperlinkButton.Content>
</HyperlinkButton>
<TextBlock x:Uid="PolicyContent/UnconfiguredTextBlock" Foreground="{ThemeResource TextFillColorDisabledBrush}"
Expand Down
10 changes: 5 additions & 5 deletions Pages/Policy/Contents/PolicyContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace PolicyManager.Pages.Policy.Contents;

public abstract class PolicyContent : Page
{
public NotifyPolicyManager PolicyManager { get; }

public PolicyContent This => this;

protected PolicyContent(NotifyPolicyManager policyManager)
{
NavigationCacheMode = NavigationCacheMode.Disabled;

PolicyManager = policyManager;

DataContext = This;
}

public NotifyPolicyManager PolicyManager { get; }

public PolicyContent This => this;
}
2 changes: 1 addition & 1 deletion Pages/Policy/Contents/StringContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
GotFocus="TextBox_OnGotFocus" LostFocus="TextBox_OnLostFocus" />
<HyperlinkButton x:Name="AcceptButton" Width="32" Height="32" Margin="5,0,-37,0" Visibility="Collapsed" Padding="0">
<HyperlinkButton.Content>
<FontIcon Glyph="&#xE8FB;" FontSize="14" Foreground="#18864B" FontWeight="bold"/>
<FontIcon Glyph="&#xE8FB;" FontSize="14" Foreground="{ThemeResource SystemFillColorSuccessBrush}" FontWeight="bold" />
</HyperlinkButton.Content>
</HyperlinkButton>
<TextBlock x:Uid="PolicyContent/UnconfiguredTextBlock" Foreground="{ThemeResource TextFillColorDisabledBrush}"
Expand Down
3 changes: 2 additions & 1 deletion Pages/Policy/DetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
</ListView>
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"
Visibility="{Binding Path=IsExpanderListItemsEmpty, Converter={StaticResource BoolToVisibilityConverter}}">
<TextBlock Text="¯\_(ツ)_/¯" FontSize="42" HorizontalAlignment="Center" Foreground="Gray" Margin="0,0,0,100" />
<TextBlock Text="¯\_(ツ)_/¯" FontSize="42" HorizontalAlignment="Center"
Foreground="{ThemeResource TextFillColorSecondaryBrush}" Margin="0,0,0,100" />
</StackPanel>
</Grid>
</Page>
28 changes: 14 additions & 14 deletions Pages/Policy/DetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ public sealed class DetailPageModel : INotifyPropertyChanged, IDisposable
{
public delegate void SearchPolicyEventHandler(string keyword);

public event SearchPolicyEventHandler SearchPolicyEvent;
private readonly PolicyMenuItem _activePolicyMenu;

public string PolicyType { get; init; }

public PolicyDetailMap PolicyDetailMap { get; set; }

private readonly PolicyMenuItem _activePolicyMenu;

public PolicyMenuItem ActivePolicyMenu
{
init
Expand All @@ -47,8 +45,16 @@ public PolicyMenuItem ActivePolicyMenu

public SearchPolicyEventHandler SearchPolicyHandler { get; init; }

public void Dispose()
{
// PolicyPage停止监听SearchPolicyEvent事件
SearchPolicyEvent -= SearchPolicyHandler;
}

public event PropertyChangedEventHandler PropertyChanged;

public event SearchPolicyEventHandler SearchPolicyEvent;

private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
Expand All @@ -58,12 +64,6 @@ internal void OnSearchPolicyEvent(string keyword)
{
SearchPolicyEvent?.Invoke(keyword);
}

public void Dispose()
{
// PolicyPage停止监听SearchPolicyEvent事件
SearchPolicyEvent -= SearchPolicyHandler;
}
}

public class ExpanderListItem
Expand Down Expand Up @@ -190,20 +190,20 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)
private void CopyItemTitle_Click(object sender, RoutedEventArgs e)
{
var menuFlyoutItem = sender as MenuFlyoutItem;

var itemData = menuFlyoutItem?.DataContext as ExpanderListItem;

var dataPackage = new DataPackage();
dataPackage.SetText(itemData?.PolicyDetail.Name);
Clipboard.SetContent(dataPackage);
}

private void CopyItemShortDescription_Click(object sender, RoutedEventArgs e)
{
var menuFlyoutItem = sender as MenuFlyoutItem;

var itemData = menuFlyoutItem?.DataContext as ExpanderListItem;

var dataPackage = new DataPackage();
dataPackage.SetText(itemData?.PolicyDetail.ShortDescription);
Clipboard.SetContent(dataPackage);
Expand Down
2 changes: 1 addition & 1 deletion Pages/Policy/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</controls:SettingsCard>
<controls:SettingsCard Margin="5" x:Uid="SettingsPage/RestartEdgeSettingsCard"
HeaderIcon="{winUi:FontIcon Glyph=&#xE72C;}">
<Button Click="RestartButton_OnClick" Margin="5" x:Uid="SettingsPage/RestartEdgeSettings/RestartButton" x:Name="RestartButton"/>
<Button Click="RestartButton_OnClick" Margin="5" x:Uid="SettingsPage/RestartEdgeSettings/RestartButton" x:Name="RestartButton" />
</controls:SettingsCard>
<controls:SettingsCard Margin="5" IsClickEnabled="True" Description="由 Edge 提供的策略管理页面"
Visibility="Collapsed"
Expand Down
11 changes: 4 additions & 7 deletions Pages/Policy/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ private static bool CloseProcess(string processName, bool entireProcessTree = tr
foreach (var process in Process.GetProcessesByName(processName))
{
process.CloseMainWindow();
if (!process.HasExited)
{
process.Kill(entireProcessTree);
}
if (!process.HasExited) process.Kill(entireProcessTree);

hasClosed = true;
}
Expand All @@ -136,7 +133,7 @@ private static void StartProcess(string fileName, string arguments = "")
private async void RestartButton_OnClick(object sender, RoutedEventArgs e)
{
RestartButton.IsEnabled = false;

// 关闭edge
if (!CloseProcess("msedge"))
{
Expand All @@ -151,7 +148,7 @@ private async void RestartButton_OnClick(object sender, RoutedEventArgs e)
CloseButtonText = ResourceUtil.GetString("SettingsPage/RestartButton_OnClick/ConfirmDialog/CloseButtonText"),
DefaultButton = ContentDialogButton.Primary
}.ShowAsync();

if (result == ContentDialogResult.None)
{
RestartButton.IsEnabled = true;
Expand All @@ -161,7 +158,7 @@ private async void RestartButton_OnClick(object sender, RoutedEventArgs e)

// 启动edge
StartProcess("msedge");

RestartButton.IsEnabled = true;
}

Expand Down
Loading

0 comments on commit 65b2c03

Please sign in to comment.