Skip to content

Commit f480e12

Browse files
authored
Merge pull request #23 from Atlas-OS/na-home-rework
Beta v0.1.7
2 parents 420c96d + 32fb15e commit f480e12

30 files changed

+868
-264
lines changed

AtlasToolbox/App.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using Newtonsoft.Json;
2222
using System.Linq;
2323
using Windows.ApplicationModel.Core;
24+
using System.Collections;
25+
using System.Reflection;
2426

2527
namespace AtlasToolbox
2628
{
@@ -34,9 +36,8 @@ public partial class App : Application
3436
public static Window f_window;
3537
public static XamlRoot XamlRoot { get; set; }
3638
public static string CurrentCategory { get; set; }
37-
3839
private static Dictionary<string, string> StringList = new Dictionary<string, string>();
39-
40+
public static List<IConfigurationItem> RootList = new List<IConfigurationItem>();
4041
private static Mutex _mutex = new(true, "{AtlasToolbox}");
4142

4243
public static string Version { get; set; }

AtlasToolbox/Enums/ConfigurationType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public enum ConfigurationType
2323
Security,
2424
[Description("Troubleshooting")]
2525
Troubleshooting,
26+
[Description("Software")]
27+
Software,
2628
ContextMenuSubMenu,
2729
AiSubMenu,
2830
ServicesSubMenu,

AtlasToolbox/HostBuilder/AddServicesHostBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ private static IHostBuilder AddConfigurationServices(this IHostBuilder host)
116116
services.AddKeyedTransient<IConfigurationService, GiveAccessToMenuConfigurationService>("GiveAccessToMenu");
117117
services.AddKeyedTransient<IConfigurationService, NetworkNavigationPaneConfigurationService>("NetworkNavigationPane");
118118
services.AddKeyedTransient<IConfigurationService, FileSharingConfigurationService>("FileSharing");
119+
services.AddKeyedTransient<IConfigurationService, WindowsHelloConfigurationServices>("WindowsHello");
119120
services.AddKeyedTransient<IMultiOptionConfigurationServices, ContextMenuTeminalsConfigurationService>("ContextMenuTerminals");
120121
services.AddKeyedTransient<IMultiOptionConfigurationServices, ShortcutIconConfigurationService>("ShortcutIcon");
121122
services.AddKeyedTransient<IMultiOptionConfigurationServices, MitigationsConfigurationService>("Mitigations");

AtlasToolbox/HostBuilder/AddStoresHostBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private static IHostBuilder AddConfigurationStores(this IHostBuilder host)
9898
services.AddKeyedSingleton<ConfigurationStore>("GiveAccessToMenu");
9999
services.AddKeyedSingleton<ConfigurationStore>("NetworkNavigationPane");
100100
services.AddKeyedSingleton<ConfigurationStore>("FileSharing");
101+
services.AddKeyedSingleton<ConfigurationStore>("WindowsHello");
101102
services.AddKeyedSingleton<MultiOptionConfigurationStore>("ContextMenuTerminals");
102103
services.AddKeyedSingleton<MultiOptionConfigurationStore>("ShortcutIcon");
103104
services.AddKeyedSingleton<MultiOptionConfigurationStore>("Mitigations");

AtlasToolbox/HostBuilder/AddViewModelsHostBuilderExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private static IHostBuilder AddConfigurationSubMenu(this IHostBuilder host)
289289
{
290290
ObservableCollection<ConfigurationItemViewModel> itemViewModels = new ObservableCollection<ConfigurationItemViewModel>(provider.GetServices<ConfigurationItemViewModel>().Where(item => item.Type.ToString() == subMenu.Key));
291291
ObservableCollection<MultiOptionConfigurationItemViewModel> multiOptionItemViewModels = new ObservableCollection<MultiOptionConfigurationItemViewModel>(provider.GetServices<MultiOptionConfigurationItemViewModel>().Where(item => item.Type.ToString() == subMenu.Key));
292-
ObservableCollection<LinksViewModel> linksViewModel = new ObservableCollection<LinksViewModel>(provider.GetServices<LinksViewModel>().Where(item => item.ConfigurationType.ToString() == subMenu.Key));
292+
ObservableCollection<LinksViewModel> linksViewModel = new ObservableCollection<LinksViewModel>(provider.GetServices<LinksViewModel>().Where(item => item.Type.ToString() == subMenu.Key));
293293
ObservableCollection<ConfigurationSubMenuViewModel> configurationSubMenuViewModels = new ObservableCollection<ConfigurationSubMenuViewModel>(viewModels.Where(item => item.Type.ToString() == subMenu.Key));
294294
ObservableCollection<ConfigurationButtonViewModel> configurationButtonViewModels = new ObservableCollection<ConfigurationButtonViewModel>(provider.GetServices<ConfigurationButtonViewModel>().Where(item => item.Type.ToString() == subMenu.Key));
295295

@@ -406,6 +406,7 @@ private static IHostBuilder AddConfigurationItemViewModels(this IHostBuilder hos
406406
["GiveAccessToMenu"] = new(App.GetValueFromItemList("GiveAccessToMenu"), "GiveAccessToMenu", ConfigurationType.FileSharingSubMenu, RiskRating.HighRisk),
407407
["NetworkNavigationPane"] = new(App.GetValueFromItemList("NetworkNavigationPane"), "NetworkNavigationPane", ConfigurationType.FileSharingSubMenu, RiskRating.HighRisk),
408408
["FileSharing"] = new(App.GetValueFromItemList("FileSharing"), "FileSharing", ConfigurationType.FileSharingSubMenu, RiskRating.HighRisk),
409+
["WindowsHello"] = new(App.GetValueFromItemList("WindowsHello"), "WindowsHello", ConfigurationType.General, RiskRating.HighRisk),
409410
};
410411

411412
host.ConfigureServices((_,services) =>

AtlasToolbox/MainWindow.xaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
</Grid.ColumnDefinitions>
1919
<Grid.RowDefinitions>
2020
<RowDefinition Height="Auto" />
21-
<!-- TitleBar -->
2221
<RowDefinition Height="*" />
23-
<!-- NavView -->
2422
</Grid.RowDefinitions>
2523
<Border
2624
x:Name="AppTitleBar"
@@ -70,7 +68,7 @@
7068
</NavigationView.Content>
7169

7270
<NavigationView.PaneFooter>
73-
<!-- Alpha version message, to be removed at release -->
71+
<!-- Beta version message, to be removed at release -->
7472
<StackPanel>
7573
<InfoBar
7674
x:Name="UnstableCard"
@@ -89,14 +87,22 @@
8987
</NavigationView.PaneFooter>
9088

9189
<NavigationView.Resources>
92-
<!-- This top margin is the height of the custom titleBar -->
9390
<Thickness x:Key="NavigationViewContentMargin">0,48,0,0</Thickness>
9491
<Thickness x:Key="NavigationViewMinimalContentMargin">0,48,0,0</Thickness>
9592
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,1,0,0</Thickness>
96-
<!-- This is the rounded corner on the Top left of the L Pattern -->
9793
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">8,0,0,0</CornerRadius>
9894
</NavigationView.Resources>
9995

96+
<!-- Since this is WIP and really buggy at this stage, prefer to comment it rathen than releasing it. -->
97+
<!--<NavigationView.AutoSuggestBox>
98+
<AutoSuggestBox
99+
Width="300"
100+
AutomationProperties.Name="Basic AutoSuggestBox"
101+
PlaceholderText="Search a tweak (WIP)"
102+
QueryIcon="Find"
103+
SuggestionChosen="AutoSuggestBox_SuggestionChosen"
104+
TextChanged="AutoSuggestBox_TextChanged" />
105+
</NavigationView.AutoSuggestBox>-->
100106

101107
<NavigationView.MenuItems>
102108
<NavigationViewItem

AtlasToolbox/MainWindow.xaml.cs

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515
using Windows.Security.Authentication.Web.Provider;
1616
using Microsoft.UI;
1717
using WinRT.Interop;
18+
using System.Collections.Generic;
19+
using Microsoft.Extensions.DependencyInjection;
20+
using ICSharpCode.Decompiler.CSharp.Syntax;
21+
using AtlasToolbox.ViewModels;
22+
using System.Runtime.CompilerServices;
1823

1924
namespace AtlasToolbox
2025
{
2126
public sealed partial class MainWindow : Window
2227
{
28+
public List<IConfigurationItem> RootList { get; set; }
2329
public MainWindow()
2430
{
2531
this.InitializeComponent();
@@ -31,14 +37,34 @@ public MainWindow()
3137
WindowManager.Get(this).Height = 850;
3238
WindowManager.Get(this).MinHeight = 850;
3339

34-
WindowManager.Get(this).IsResizable = false;
35-
WindowManager.Get(this).IsMaximizable = false;
36-
3740
CenterWindowOnScreen();
3841
ExtendsContentIntoTitleBar = true;
3942

4043
LoadText();
4144

45+
// Setup root list
46+
RootList = new List<IConfigurationItem>();
47+
foreach (IConfigurationItem item in App._host.Services.GetServices<LinksViewModel>())
48+
{
49+
/*if (!item.Type.ToString().Contains("SubMenu"))*/ RootList.Add(item);
50+
}
51+
foreach (IConfigurationItem item in App._host.Services.GetServices<ConfigurationItemViewModel>())
52+
{
53+
/*if (!item.Type.ToString().Contains("SubMenu"))*/ RootList.Add(item);
54+
}
55+
foreach (IConfigurationItem item in App._host.Services.GetServices<MultiOptionConfigurationItemViewModel>())
56+
{
57+
/*if (!item.Type.ToString().Contains("SubMenu"))*/ RootList.Add(item);
58+
}
59+
foreach (IConfigurationItem item in App._host.Services.GetServices<ConfigurationSubMenuViewModel>())
60+
{
61+
/*if (!item.Type.ToString().Contains("SubMenu"))*/ RootList.Add(item);
62+
}
63+
foreach (IConfigurationItem item in App._host.Services.GetServices<ConfigurationButtonViewModel>())
64+
{
65+
/*if (!item.Type.ToString().Contains("SubMenu"))*/ RootList.Add(item);
66+
}
67+
App.RootList = this.RootList;
4268
NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems.OfType<NavigationViewItem>().First();
4369
ContentFrame.Navigate(
4470
typeof(Views.HomePage),
@@ -48,7 +74,7 @@ public MainWindow()
4874
SetTitleBar(AppTitleBar);
4975

5076
if (RegistryHelper.IsMatch("HKLM\\SOFTWARE\\AtlasOS\\Toolbox", "OnStartup", 1)) this.Closed += AppBehaviorHelper.HideApp;
51-
else this.Closed += AppBehaviorHelper.CloseApp;
77+
else this.Closed += AppBehaviorHelper.CloseApp;
5278
}
5379

5480
public void LoadText()
@@ -89,7 +115,8 @@ private void NavigationViewControl_ItemInvoked(NavigationView sender,
89115
//var NavView = sender as NavigationView;
90116
//if (NavView.SelectedItem == args.InvokedItemContainer) { return; };
91117

92-
if (App.CurrentCategory == args.InvokedItemContainer.Tag.ToString() || (App.CurrentCategory == "SettingsItem" && args.IsSettingsInvoked == true)) { return; };
118+
if (App.CurrentCategory == args.InvokedItemContainer.Tag.ToString() || (App.CurrentCategory == "SettingsItem" && args.IsSettingsInvoked == true)) { return; }
119+
;
93120

94121
App.CurrentCategory = args.InvokedItemContainer.Tag.ToString();
95122
if (args.IsSettingsInvoked == true)
@@ -99,7 +126,13 @@ private void NavigationViewControl_ItemInvoked(NavigationView sender,
99126
return;
100127
}
101128

102-
switch (args.InvokedItemContainer.Tag.ToString())
129+
Navigate(args.InvokedItemContainer.Tag.ToString());
130+
App.XamlRoot = this.Content.XamlRoot;
131+
}
132+
133+
private void Navigate(string tag)
134+
{
135+
switch (tag)
103136
{
104137
case "SettingsPage":
105138
App.CurrentCategory = "SettingsItem";
@@ -113,7 +146,7 @@ private void NavigationViewControl_ItemInvoked(NavigationView sender,
113146
);
114147
break;
115148
case "AtlasToolbox.Views.HomePage":
116-
Type newPage = Type.GetType(args.InvokedItemContainer.Tag.ToString());
149+
Type newPage = Type.GetType(tag);
117150
ContentFrame.Navigate(
118151
newPage,
119152
null,
@@ -126,7 +159,6 @@ private void NavigationViewControl_ItemInvoked(NavigationView sender,
126159
new DrillInNavigationTransitionInfo());
127160
break;
128161
}
129-
App.XamlRoot = this.Content.XamlRoot;
130162
}
131163

132164
public void GoBack()
@@ -175,6 +207,7 @@ private void NavigateTo()
175207
}
176208
}
177209

210+
178211
/// <summary>
179212
/// Creates a ContentDialog with the required type
180213
/// </summary>
@@ -279,5 +312,47 @@ private void AtlasButton_Click(object sender, RoutedEventArgs e)
279312
timesClicked++;
280313
}
281314
}
315+
316+
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
317+
{
318+
var configItem = RootList.Where(item => item.Name == args.SelectedItem.ToString()).FirstOrDefault();
319+
string type = configItem.Type.ToString();
320+
321+
if (configItem is not null)
322+
{
323+
NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems
324+
.OfType<NavigationViewItem>()
325+
.First(n => n.Tag.Equals(configItem.Type.ToString()));
326+
App.CurrentCategory = configItem.Type.ToString();
327+
Navigate(configItem.Type.ToString());
328+
}
329+
}
330+
331+
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
332+
{
333+
// Since selecting an item will also change the text,
334+
// only listen to changes caused by user entering text.
335+
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
336+
{
337+
var suitableItems = new List<string>();
338+
var splitText = sender.Text.ToLower().Split(" ");
339+
foreach (var viewModel in RootList)
340+
{
341+
var found = splitText.All((key) =>
342+
{
343+
return viewModel.Name.ToLower().Contains(key);
344+
});
345+
if (found)
346+
{
347+
suitableItems.Add(viewModel.Name);
348+
}
349+
}
350+
if (suitableItems.Count == 0)
351+
{
352+
suitableItems.Add("No results found");
353+
}
354+
sender.ItemsSource = suitableItems;
355+
}
356+
}
282357
}
283358
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using AtlasToolbox.Stores;
7+
using AtlasToolbox.Utils;
8+
using Microsoft.Extensions.DependencyInjection;
9+
10+
namespace AtlasToolbox.Services.ConfigurationServices
11+
{
12+
public class WindowsHelloConfigurationServices : IConfigurationService
13+
{
14+
private const string ATLAS_STORE_KEY_NAME = @"HKLM\SOFTWARE\AtlasOS\WindowsHello";
15+
private const string STATE_VALUE_NAME = "state";
16+
17+
private const string PASSPORT_FOR_WORK_KEY_NAME = @"HKLM\SOFTWARE\Policies\Microsoft\PassportForWork";
18+
private const string SYSTEM_KEY_NAME = @"HKLM\SOFTWARE\Policies\Microsoft\Windows\System";
19+
private const string BIOMETRICS_KEY_NAME = @"HKLM\SOFTWARE\Policies\Microsoft\Biometrics";
20+
private const string FACIAL_FEATURES_KEY_NAME = @"HKLM\SOFTWARE\Policies\Microsoft\Biometrics\FacialFeatures";
21+
private const string FINGERPRINT_FEATURES_KEY_NAME = @"HKLM\SOFTWARE\Policies\Microsoft\Biometrics\FingerprintFeatures";
22+
private const string ALLOW_SIGN_IN_OPTIONS_KEY_NAME = @"HKLM\SOFTWARE\Microsoft\PolicyManager\default\Settings\AllowSignInOptions";
23+
24+
private const string ENABLED_VALUE_NAME = @"Enabled";
25+
private const string ALLOW_DOMAIN_PIN_LOGON_VALUE_NAME = @"AllowDomainPINLogon";
26+
private const string VALUE_VALUE_NAME = @"value";
27+
28+
private readonly ConfigurationStore configurationStore;
29+
30+
public WindowsHelloConfigurationServices(
31+
[FromKeyedServices("WindowsHello")] ConfigurationStore ConfigurationStore)
32+
{
33+
configurationStore = ConfigurationStore;
34+
}
35+
public void Disable()
36+
{
37+
RegistryHelper.SetValue(PASSPORT_FOR_WORK_KEY_NAME, ENABLED_VALUE_NAME, 0, Microsoft.Win32.RegistryValueKind.DWord);
38+
RegistryHelper.SetValue(SYSTEM_KEY_NAME, ALLOW_DOMAIN_PIN_LOGON_VALUE_NAME, 0, Microsoft.Win32.RegistryValueKind.DWord);
39+
RegistryHelper.SetValue(BIOMETRICS_KEY_NAME, ENABLED_VALUE_NAME, 0, Microsoft.Win32.RegistryValueKind.DWord);
40+
RegistryHelper.SetValue(FACIAL_FEATURES_KEY_NAME, ENABLED_VALUE_NAME, 0, Microsoft.Win32.RegistryValueKind.DWord);
41+
RegistryHelper.SetValue(FINGERPRINT_FEATURES_KEY_NAME, ENABLED_VALUE_NAME, 0, Microsoft.Win32.RegistryValueKind.DWord);
42+
RegistryHelper.SetValue(ALLOW_SIGN_IN_OPTIONS_KEY_NAME, VALUE_VALUE_NAME, 0, Microsoft.Win32.RegistryValueKind.DWord);
43+
44+
configurationStore.CurrentSetting = IsEnabled();
45+
}
46+
47+
public void Enable()
48+
{
49+
RegistryHelper.SetValue(PASSPORT_FOR_WORK_KEY_NAME, ENABLED_VALUE_NAME, 1, Microsoft.Win32.RegistryValueKind.DWord);
50+
RegistryHelper.SetValue(SYSTEM_KEY_NAME, ALLOW_DOMAIN_PIN_LOGON_VALUE_NAME, 1, Microsoft.Win32.RegistryValueKind.DWord);
51+
RegistryHelper.SetValue(BIOMETRICS_KEY_NAME, ENABLED_VALUE_NAME, 1, Microsoft.Win32.RegistryValueKind.DWord);
52+
RegistryHelper.SetValue(FACIAL_FEATURES_KEY_NAME, ENABLED_VALUE_NAME, 1, Microsoft.Win32.RegistryValueKind.DWord);
53+
RegistryHelper.SetValue(FINGERPRINT_FEATURES_KEY_NAME, ENABLED_VALUE_NAME, 1, Microsoft.Win32.RegistryValueKind.DWord);
54+
RegistryHelper.SetValue(ALLOW_SIGN_IN_OPTIONS_KEY_NAME, VALUE_VALUE_NAME, 1, Microsoft.Win32.RegistryValueKind.DWord);
55+
56+
configurationStore.CurrentSetting = IsEnabled();
57+
}
58+
59+
public bool IsEnabled()
60+
{
61+
return RegistryHelper.IsMatch(ATLAS_STORE_KEY_NAME, STATE_VALUE_NAME, 1);
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)