Skip to content

Commit d345310

Browse files
authored
AppControl Manager v2.0.70.0 (#1089)
Added the ability to choose a custom path for the Policies Library cache location. By default, the location of the Policies Library cache on disk is in the app's internal OS-designated directory which is automatically cleared during app uninstallation. You can choose a custom location to be used as the Policies Library cache by using the "Manage Cache Location" button under the "Actions" menu on the Sidebar. Once you press that button, you will be presented with multiple options. Being able to change the Policies Library cache location on disk can come in handy if you, for instance, intend to sync the policy files with OneDrive, GitHub and so on. It was a feature request from the GitHub community's discussion: #1084
1 parent 33d35eb commit d345310

65 files changed

Lines changed: 708 additions & 304 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AppControl Manager/AppControl Manager.csproj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<AssemblyName>AppControlManager</AssemblyName>
6262
<!-- https://learn.microsoft.com/dotnet/core/deploying/native-aot/optimizing -->
6363

64-
<FileVersion>2.0.69.0</FileVersion>
64+
<FileVersion>2.0.70.0</FileVersion>
6565
<AssemblyVersion>$(FileVersion)</AssemblyVersion>
6666

6767
<StartupObject>AppControlManager.Program</StartupObject>
@@ -109,13 +109,13 @@
109109
<NuGetAudit>false</NuGetAudit>
110110
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
111111

112-
<!--
112+
<!--
113113
https://learn.microsoft.com/visualstudio/code-quality/disable-code-analysis
114114
This project utilizes extensive and comprehensive analyzers that can take a lot of time to complete.
115115
So we disable them for debug/design time and only run them during release configuration.
116116
-->
117117

118-
<RunAnalyzers>false</RunAnalyzers>
118+
<RunAnalyzers>false</RunAnalyzers>
119119

120120
</PropertyGroup>
121121

@@ -196,13 +196,12 @@
196196
<!-- Main Packages - Without these packages, there will be compilation errors related to missing types -->
197197
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.2.251219" />
198198
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.2.251219" />
199-
<PackageReference Include="CommunityToolkit.WinUI.Lottie" Version="8.2.250604" />
200199
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.251219" />
201200
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.3.2" />
202201
<PackageReference Include="Microsoft.Identity.Client" Version="4.82.1" />
203202
<PackageReference Include="Microsoft.Identity.Client.Broker" Version="4.82.1" />
204203
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.82.1" />
205-
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.3.0-prerelease.251115.2" />
204+
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.3.0-prerelease.251115.2" />
206205
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.260209005" />
207206
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.3" />
208207
<PackageReference Include="System.Diagnostics.EventLog" Version="10.0.3" />
@@ -227,8 +226,8 @@
227226
<PackageReference Include="Microsoft.WindowsAppSDK.Runtime" Version="1.8.260209005" />
228227
<PackageReference Include="Microsoft.WindowsAppSDK.Widgets" Version="1.8.251231004" />
229228
<PackageReference Include="Microsoft.WindowsAppSDK.WinUI" Version="1.8.260204000" />
230-
<PackageReference Include="Microsoft.WindowsAppSDK.ML" Version="1.8.2124" />
231-
<PackageReference Include="System.Numerics.Tensors" Version="10.0.3" />
229+
<PackageReference Include="Microsoft.WindowsAppSDK.ML" Version="1.8.2124" />
230+
<PackageReference Include="System.Numerics.Tensors" Version="10.0.3" />
232231
<PackageReference Include="Microsoft.Windows.SDK.BuildTools.MSIX" Version="1.7.251221100">
233232
<PrivateAssets>all</PrivateAssets>
234233
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

AppControl Manager/CustomUIElements/ColumnSelector.xaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
x:Class="AppControlManager.CustomUIElements.ColumnSelector"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
xmlns:others="using:AppControlManager.Others"
9-
mc:Ignorable="d">
6+
xmlns:others="using:AppControlManager.Others">
107

118
<DropDownButton x:Uid="ColumnsDropDownButton"
129
IsEnabled="{x:Bind IsEnabled, Mode=OneWay}">
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<customUI:ContentDialogV2
3+
x:Class="AppControlManager.CustomUIElements.CustomPoliciesLibraryCacheLocationManagerDialog"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:customUI="using:AppControlManager.CustomUIElements"
7+
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
8+
DefaultButton="Close"
9+
IsEnabled="{x:Bind AreElementsEnabled, Mode=OneWay}"
10+
x:Uid="CustomPoliciesLibraryCacheLocationManagerDialog"
11+
Style="{ThemeResource DefaultContentDialogStyle}"
12+
FlowDirection="{x:Bind AppSettings.ApplicationGlobalFlowDirection, Mode=OneWay}">
13+
14+
<customUI:ContentDialogV2.Resources>
15+
<!-- https://github.com/microsoft/microsoft-ui-xaml/issues/424 -->
16+
<x:Double x:Key="ContentDialogMaxWidth">2000</x:Double>
17+
</customUI:ContentDialogV2.Resources>
18+
19+
<ScrollView>
20+
21+
<Border Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
22+
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
23+
BorderThickness="1"
24+
CornerRadius="8"
25+
Padding="15">
26+
27+
<StackPanel Orientation="Vertical" Spacing="10">
28+
29+
<ProgressRing Visibility="{x:Bind ProgressRingVisibility, Mode=OneWay}"
30+
HorizontalAlignment="Center"
31+
VerticalAlignment="Top"
32+
IsActive="{x:Bind ProgressRingIsActive, Mode=OneWay}" />
33+
34+
<TextBlock x:Uid="CustomPoliciesLibraryCacheDialogInnerTitle"
35+
Style="{StaticResource BodyStrongTextBlockStyle}"
36+
HorizontalAlignment="Center"/>
37+
38+
<TextBox x:Uid="CustomPoliciesLibraryCacheTextBox"
39+
TextWrapping="Wrap"
40+
MaxWidth="350"
41+
IsReadOnly="True"
42+
Text="{x:Bind AppSettings.CustomSidebarPoliciesLibraryCacheLocation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
43+
VerticalAlignment="Center" />
44+
45+
<controls:WrapPanel Orientation="Horizontal"
46+
HorizontalAlignment="Center"
47+
HorizontalSpacing="10"
48+
VerticalSpacing="10">
49+
50+
<Button x:Uid="BrowseAndSetCustomPoliciesLibraryCacheButton"
51+
IsEnabled="{x:Bind AreElementsEnabled, Mode=OneWay}"
52+
Click="{x:Bind BrowseAndSetCustomCacheDirectory}"
53+
HorizontalAlignment="Center"
54+
VerticalAlignment="Center">
55+
<Button.ContentTemplate>
56+
<DataTemplate x:DataType="x:String">
57+
<StackPanel Orientation="Horizontal" Spacing="8">
58+
<FontIcon Glyph="&#xEC50;" FontSize="16"/>
59+
<TextBlock Text="{x:Bind}"/>
60+
</StackPanel>
61+
</DataTemplate>
62+
</Button.ContentTemplate>
63+
</Button>
64+
65+
<Button x:Uid="OpenCustomPoliciesLibraryCacheButton"
66+
IsEnabled="{x:Bind AreElementsEnabled, Mode=OneWay}"
67+
HorizontalAlignment="Center"
68+
Click="{x:Bind Open}"
69+
VerticalAlignment="Center">
70+
<Button.ContentTemplate>
71+
<DataTemplate x:DataType="x:String">
72+
<StackPanel Orientation="Horizontal" Spacing="8">
73+
<FontIcon Glyph="&#xED25;" FontSize="16"/>
74+
<TextBlock Text="{x:Bind}"/>
75+
</StackPanel>
76+
</DataTemplate>
77+
</Button.ContentTemplate>
78+
</Button>
79+
80+
<Button x:Uid="ClearCustomPoliciesLibraryCacheButton"
81+
IsEnabled="{x:Bind AreElementsEnabled, Mode=OneWay}"
82+
HorizontalAlignment="Center"
83+
Click="{x:Bind Clear}"
84+
VerticalAlignment="Center">
85+
<Button.ContentTemplate>
86+
<DataTemplate x:DataType="x:String">
87+
<StackPanel Orientation="Horizontal" Spacing="8">
88+
<FontIcon Glyph="&#xE8E6;" FontSize="16"/>
89+
<TextBlock Text="{x:Bind}"/>
90+
</StackPanel>
91+
</DataTemplate>
92+
</Button.ContentTemplate>
93+
</Button>
94+
95+
</controls:WrapPanel>
96+
97+
</StackPanel>
98+
99+
</Border>
100+
101+
</ScrollView>
102+
</customUI:ContentDialogV2>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// MIT License
2+
//
3+
// Copyright (c) 2023-Present - Violet Hansen - (aka HotCakeX on GitHub) - Email Address: spynetgirl@outlook.com
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// See here for more information: https://github.com/HotCakeX/Harden-Windows-Security/blob/main/LICENSE
16+
//
17+
18+
using System.ComponentModel;
19+
using AppControlManager.ViewModels;
20+
using Microsoft.UI.Xaml;
21+
22+
namespace AppControlManager.CustomUIElements;
23+
24+
internal sealed partial class CustomPoliciesLibraryCacheLocationManagerDialog : ContentDialogV2, INPCImplant
25+
{
26+
private CommonCore.AppSettings.Main AppSettings => GlobalVars.Settings;
27+
28+
internal CustomPoliciesLibraryCacheLocationManagerDialog() => InitializeComponent();
29+
30+
private async void BrowseAndSetCustomCacheDirectory()
31+
{
32+
try
33+
{
34+
AreElementsEnabled = false;
35+
36+
string? directory = FileDialogHelper.ShowDirectoryPickerDialog();
37+
38+
if (!string.IsNullOrEmpty(directory))
39+
{
40+
AppSettings.CustomSidebarPoliciesLibraryCacheLocation = directory;
41+
42+
await ViewModelProvider.MainWindowVM.SetSidebarPoliciesLibraryCacheLocationToCustom();
43+
44+
await ViewModelProvider.MainWindowVM.InitialPoliciesLibrarySetup();
45+
}
46+
}
47+
finally
48+
{
49+
AreElementsEnabled = true;
50+
}
51+
}
52+
53+
private async void Clear()
54+
{
55+
try
56+
{
57+
AreElementsEnabled = false;
58+
59+
await ViewModelProvider.MainWindowVM.SetSidebarPoliciesLibraryCacheLocationToDefault();
60+
61+
// Clear the user-defined custom path after it was used to copy files to the default location
62+
AppSettings.CustomSidebarPoliciesLibraryCacheLocation = string.Empty;
63+
64+
await ViewModelProvider.MainWindowVM.InitialPoliciesLibrarySetup();
65+
}
66+
finally
67+
{
68+
AreElementsEnabled = true;
69+
}
70+
}
71+
72+
private async void Open() => await ViewModels.ViewModelBase.OpenFileInDefaultFileHandler(AppSettings.CustomSidebarPoliciesLibraryCacheLocation);
73+
74+
private bool AreElementsEnabled
75+
{
76+
get; set
77+
{
78+
if (this.SP(ref field, value))
79+
{
80+
ProgressRingVisibility = field ? Visibility.Collapsed : Visibility.Visible;
81+
ProgressRingIsActive = !field;
82+
}
83+
}
84+
} = true;
85+
86+
private Visibility ProgressRingVisibility { get; set => this.SP(ref field, value); } = Visibility.Collapsed;
87+
private bool ProgressRingIsActive { get; set => this.SP(ref field, value); }
88+
89+
#region IPropertyChangeHost Implementation
90+
public event PropertyChangedEventHandler? PropertyChanged;
91+
public void RaisePropertyChanged(string? propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
92+
#endregion
93+
94+
}

AppControl Manager/CustomUIElements/HomePageCarousel/AnimatedImage.xaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
x:Class="AppControlManager.CustomUIElements.HomePageCarousel.AnimatedImage"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
Unloaded="{x:Bind AnimatedImage_Unloaded}"
9-
mc:Ignorable="d">
6+
Unloaded="{x:Bind AnimatedImage_Unloaded}">
107

118
<Grid>
12-
<Image
13-
x:Name="BottomImage"
14-
Opacity="1"
15-
Stretch="UniformToFill" />
16-
<Image
17-
x:Name="TopImage"
18-
Opacity="0"
19-
Stretch="UniformToFill" />
9+
<Image x:Name="BottomImage" Opacity="1" Stretch="UniformToFill" />
10+
<Image x:Name="TopImage" Opacity="0" Stretch="UniformToFill" />
2011
</Grid>
2112
</UserControl>

AppControl Manager/CustomUIElements/HomePageCarousel/AnimatedImage.xaml.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Uri ImageUrl
6767
set => SetValue(ImageUrlProperty, value);
6868
}
6969

70-
public AnimatedImage() => InitializeComponent();
70+
internal AnimatedImage() => InitializeComponent();
7171

7272
private void AnimatedImage_Unloaded(object sender, RoutedEventArgs e)
7373
{
@@ -94,8 +94,6 @@ private void SelectAnimation_Completed(object? sender, EventArgs e)
9494
TopImage.Source = new BitmapImage(ImageUrl);
9595
TopImage.Opacity = 1;
9696
}
97-
catch
98-
{
99-
}
97+
catch { }
10098
}
10199
}

AppControl Manager/CustomUIElements/HomePageCarousel/HeaderCarousel.xaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
x:Class="AppControlManager.CustomUIElements.HomePageCarousel.HeaderCarousel"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
76
xmlns:local="using:AppControlManager.CustomUIElements.HomePageCarousel"
8-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
97
xmlns:media="using:CommunityToolkit.WinUI.Media"
108
Loaded="{x:Bind UserControl_Loaded}"
11-
Unloaded="{x:Bind UserControl_Unloaded}"
12-
mc:Ignorable="d">
9+
Unloaded="{x:Bind UserControl_Unloaded}">
1310
<UserControl.Resources>
1411
<ResourceDictionary>
1512
<ResourceDictionary.ThemeDictionaries>

AppControl Manager/CustomUIElements/HomePageCarousel/HeaderTile.xaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
76
xmlns:local="using:AppControlManager.CustomUIElements.HomePageCarousel"
87
xmlns:lights="using:AppControlManager.CustomUIElements.HomePageCarousel.Lights"
9-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
108
xmlns:media="using:CommunityToolkit.WinUI.Media"
119
xmlns:ui="using:CommunityToolkit.WinUI">
1210

@@ -17,8 +15,6 @@
1715
<Setter Property="UseLayoutRounding" Value="True" />
1816
<Setter Property="Height" Value="208" />
1917
<Setter Property="CornerRadius" Value="8" />
20-
<Setter Property="ui:VisualExtensions.Scale" Value="0.8" />
21-
<Setter Property="ui:VisualExtensions.NormalizedCenterPoint" Value="0.5, 0.5" />
2218
<Setter Property="ui:Effects.Shadow">
2319
<Setter.Value>
2420
<media:AttachedCardShadow

AppControl Manager/CustomUIElements/HomePageCarousel/HeaderTile.xaml.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@
4444
// SOFTWARE
4545
//
4646

47+
using System.Numerics;
4748
using CommunityToolkit.WinUI.Animations;
49+
using Microsoft.UI.Composition;
4850
using Microsoft.UI.Xaml;
4951
using Microsoft.UI.Xaml.Automation;
5052
using Microsoft.UI.Xaml.Controls;
53+
using Microsoft.UI.Xaml.Hosting;
5154
using Microsoft.UI.Xaml.Media;
5255

5356
namespace AppControlManager.CustomUIElements.HomePageCarousel;
@@ -66,7 +69,7 @@ public ImageSource ImageUrl
6669
set => SetValue(ImageUrlProperty, value);
6770
}
6871

69-
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(HeaderTile), new PropertyMetadata(defaultValue: null, (d, e) => ((HeaderTile)d).HeaderChanged((string)e.OldValue, (string)e.NewValue)));
72+
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(HeaderTile), new PropertyMetadata(defaultValue: null, (d, e) => ((HeaderTile)d).HeaderChanged()));
7073

7174
public string Header
7275
{
@@ -98,7 +101,23 @@ public bool IsSelected
98101
set => SetValue(IsSelectedProperty, value);
99102
}
100103

101-
internal HeaderTile() => DefaultStyleKey = typeof(HeaderTile);
104+
internal HeaderTile()
105+
{
106+
Visual visual = ElementCompositionPreview.GetElementVisual(this);
107+
visual.Scale = new Vector3(0.8f);
108+
109+
Vector2 center = new(0.5f, 0.5f);
110+
const string expression = "Vector2(this.Target.Size.X * X, this.Target.Size.Y * Y)";
111+
ExpressionAnimation animation = visual.Compositor.CreateExpressionAnimation(expression);
112+
113+
animation.SetScalarParameter("X", center.X);
114+
animation.SetScalarParameter("Y", center.Y);
115+
116+
visual.StopAnimation("CenterPoint.XY");
117+
visual.StartAnimation("CenterPoint.XY", animation);
118+
119+
DefaultStyleKey = typeof(HeaderTile);
120+
}
102121

103122
private void IsSelectedChanged(object oldValue, object newValue)
104123
{
@@ -121,11 +140,5 @@ private void IsSelectedChanged(object oldValue, object newValue)
121140
}
122141
}
123142

124-
private void HeaderChanged(string oldValue, string newValue)
125-
{
126-
if (!string.IsNullOrEmpty(Header))
127-
{
128-
AutomationProperties.SetName(this, Header);
129-
}
130-
}
143+
private void HeaderChanged() => AutomationProperties.SetName(this, Header);
131144
}

0 commit comments

Comments
 (0)