Skip to content

Commit 9269dfb

Browse files
authored
Feature: Add PowerShell theme to first run dialog (#1761)
* Feature: Add PowerShell theme to first run dialog * Docs: Add #1761
1 parent 2464af7 commit 9269dfb

File tree

6 files changed

+79
-34
lines changed

6 files changed

+79
-34
lines changed

Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager.Localization/Resources/Strings.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,9 +1986,9 @@ Changing this value requires a restart of the application to take effect.</value
19861986
<value>Check public IP address</value>
19871987
</data>
19881988
<data name="FirstRunMessage" xml:space="preserve">
1989-
<value>Thanks for using NETworkManager!
1989+
<value>Thank you for using NETworkManager!
19901990

1991-
To provide additional features the application uses services on the Internet that are not operated by me. No data will be sent to me at any time.</value>
1991+
In order to provide additional features, services on the Internet are used that are not operated by me. You can deselect them below in the privacy section. No data is transmitted to me at any time.</value>
19921992
</data>
19931993
<data name="HelpMessage_CheckForUpdatesAtStartup" xml:space="preserve">
19941994
<value>When starting the program, it checks in the background whether a new program version is available on GitHub.

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,10 @@ protected override async void OnContentRendered(EventArgs e)
416416
{
417417
await this.HideMetroDialogAsync(customDialog);
418418

419-
SettingsManager.Current.FirstRun = false;
420-
421419
// Set settings based on user choice
422420
SettingsManager.Current.Update_CheckForUpdatesAtStartup = instance.CheckForUpdatesAtStartup;
423421
SettingsManager.Current.Dashboard_CheckPublicIPAddress = instance.CheckPublicIPAddress;
422+
SettingsManager.Current.Appearance_PowerShellModifyGlobalProfile = instance.PowerShellModifyGlobalProfile;
424423

425424
// Generate lists at runtime
426425
SettingsManager.Current.General_ApplicationList = new ObservableSetCollection<ApplicationInfo>(ApplicationManager.GetList());
@@ -436,6 +435,7 @@ protected override async void OnContentRendered(EventArgs e)
436435
{
437436
SettingsManager.Current.PowerShell_ApplicationFilePath = file;
438437
SettingsManager.Current.AWSSessionManager_ApplicationFilePath = file;
438+
439439
break;
440440
}
441441
}
@@ -450,6 +450,8 @@ protected override async void OnContentRendered(EventArgs e)
450450
}
451451
}
452452

453+
SettingsManager.Current.FirstRun = false;
454+
453455
// Save it to create a settings file
454456
SettingsManager.Save();
455457

@@ -1542,6 +1544,8 @@ private void WriteDefaultPowerShellProfileToRegistry()
15421544
if (!SettingsManager.Current.Appearance_PowerShellModifyGlobalProfile)
15431545
return;
15441546

1547+
Debug.WriteLine("Test");
1548+
15451549
HashSet<string> paths = new();
15461550

15471551
// PowerShell
@@ -1565,7 +1569,7 @@ private void OpenStatusWindow(bool activate)
15651569

15661570
private async void OnNetworkHasChanged()
15671571
{
1568-
if(_isNetworkChanging)
1572+
if (_isNetworkChanging)
15691573
return;
15701574

15711575
_isNetworkChanging = true;
@@ -1595,27 +1599,43 @@ private async void OnNetworkHasChanged()
15951599
#region Events
15961600
private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
15971601
{
1598-
// Show restart required note for some settings
1599-
if (e.PropertyName == nameof(SettingsInfo.Localization_CultureCode))
1600-
IsRestartRequired = true;
1601-
1602-
// Update TrayIcon if changed in the settings
1603-
if (e.PropertyName == nameof(SettingsInfo.TrayIcon_AlwaysShowIcon))
1602+
switch (e.PropertyName)
16041603
{
1605-
if (SettingsManager.Current.TrayIcon_AlwaysShowIcon && _notifyIcon == null)
1606-
InitNotifyIcon();
1604+
// Show restart required note for some settings
1605+
case nameof(SettingsInfo.Localization_CultureCode):
1606+
IsRestartRequired = true;
16071607

1608-
if (_notifyIcon != null)
1609-
_notifyIcon.Visible = SettingsManager.Current.TrayIcon_AlwaysShowIcon;
1610-
}
1608+
break;
1609+
1610+
// Update TrayIcon if changed in the settings
1611+
case nameof(SettingsInfo.TrayIcon_AlwaysShowIcon):
1612+
if (SettingsManager.Current.TrayIcon_AlwaysShowIcon && _notifyIcon == null)
1613+
InitNotifyIcon();
16111614

1612-
// Update DNS server if changed in the settings
1613-
if (e.PropertyName == nameof(SettingsInfo.Network_UseCustomDNSServer) || e.PropertyName == nameof(SettingsInfo.Network_CustomDNSServer))
1614-
ConfigureDNS();
1615+
if (_notifyIcon != null)
1616+
_notifyIcon.Visible = SettingsManager.Current.TrayIcon_AlwaysShowIcon;
16151617

1616-
// Update PowerShell profile if changed in the settings
1617-
if (e.PropertyName == nameof(SettingsInfo.Appearance_PowerShellModifyGlobalProfile) || e.PropertyName == nameof(SettingsInfo.Appearance_Theme) || e.PropertyName == nameof(SettingsInfo.PowerShell_ApplicationFilePath) || e.PropertyName == nameof(SettingsInfo.AWSSessionManager_ApplicationFilePath))
1618-
WriteDefaultPowerShellProfileToRegistry();
1618+
break;
1619+
1620+
// Update DNS server if changed in the settings
1621+
case nameof(SettingsInfo.Network_UseCustomDNSServer):
1622+
case nameof(SettingsInfo.Network_CustomDNSServer):
1623+
ConfigureDNS();
1624+
1625+
break;
1626+
1627+
// Update PowerShell profile if changed in the settings
1628+
case nameof(SettingsInfo.Appearance_PowerShellModifyGlobalProfile):
1629+
case nameof(SettingsInfo.Appearance_Theme):
1630+
case nameof(SettingsInfo.PowerShell_ApplicationFilePath):
1631+
case nameof(SettingsInfo.AWSSessionManager_ApplicationFilePath):
1632+
if (SettingsManager.Current.FirstRun)
1633+
return;
1634+
1635+
WriteDefaultPowerShellProfileToRegistry();
1636+
1637+
break;
1638+
}
16191639
}
16201640
#endregion
16211641

Source/NETworkManager/ViewModels/FirstRunViewModel.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ namespace NETworkManager.ViewModels
77
public class FirstRunViewModel : ViewModelBase
88
{
99
public ICommand ContinueCommand { get; }
10-
10+
1111
private bool _checkForUpdatesAtStartup = true;
1212
public bool CheckForUpdatesAtStartup
1313
{
1414
get => _checkForUpdatesAtStartup;
1515
set
1616
{
17-
if(value == _checkForUpdatesAtStartup)
17+
if (value == _checkForUpdatesAtStartup)
1818
return;
1919

2020
_checkForUpdatesAtStartup = value;
@@ -28,17 +28,31 @@ public bool CheckPublicIPAddress
2828
get => _checkPublicIPAddress;
2929
set
3030
{
31-
if(value == _checkPublicIPAddress)
31+
if (value == _checkPublicIPAddress)
3232
return;
3333

3434
_checkPublicIPAddress = value;
3535
OnPropertyChanged();
3636
}
3737
}
3838

39+
private bool _powerShellModifyGlobalProfile;
40+
public bool PowerShellModifyGlobalProfile
41+
{
42+
get => _powerShellModifyGlobalProfile;
43+
set
44+
{
45+
if (value == _powerShellModifyGlobalProfile)
46+
return;
47+
48+
_powerShellModifyGlobalProfile = value;
49+
OnPropertyChanged();
50+
}
51+
}
52+
3953
public FirstRunViewModel(Action<FirstRunViewModel> continueCommand)
4054
{
4155
ContinueCommand = new RelayCommand(p => continueCommand(this));
42-
}
56+
}
4357
}
4458
}

Source/NETworkManager/Views/FirstRunDialog.xaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:mahAppsControls="http://metro.mahapps.com/winfx/xaml/controls"
6+
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
77
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
88
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
99
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:FirstRunViewModel}">
@@ -16,25 +16,34 @@
1616
<StackPanel Grid.Row="0">
1717
<TextBlock Text="{x:Static localization:Strings.FirstRunMessage}" Style="{StaticResource DefaultTextBlock}" Margin="0,0,0,20" TextWrapping="Wrap" />
1818
<TextBlock Text="{x:Static localization:Strings.Privacy}" Style="{StaticResource HeaderTextBlock}" />
19-
<StackPanel>
20-
<StackPanel Orientation="Horizontal" Margin="0,0,0,10" >
21-
<mahAppsControls:ToggleSwitch IsOn="{Binding CheckForUpdatesAtStartup}" Header="{x:Static localization:Strings.CheckForUpdatesAtStartup}" />
19+
<StackPanel Margin="0,0,0,10">
20+
<StackPanel Orientation="Horizontal">
21+
<mah:ToggleSwitch IsOn="{Binding CheckForUpdatesAtStartup}" Header="{x:Static localization:Strings.CheckForUpdatesAtStartup}" />
2222
<Rectangle Width="24" Height="24" VerticalAlignment="Top" ToolTip="{x:Static localization:Strings.HelpMessage_CheckForUpdatesAtStartup}" Style="{StaticResource HelpImageRectangle}" Margin="10,0,0,0">
2323
<Rectangle.Resources>
2424
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" />
2525
</Rectangle.Resources>
2626
</Rectangle>
2727
</StackPanel>
28-
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
29-
<mahAppsControls:ToggleSwitch IsOn="{Binding CheckPublicIPAddress}" Header="{x:Static localization:Strings.CheckPublicIPAddress}" />
28+
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
29+
<mah:ToggleSwitch IsOn="{Binding CheckPublicIPAddress}" Header="{x:Static localization:Strings.CheckPublicIPAddress}" />
3030
<Rectangle Width="24" Height="24" VerticalAlignment="Top" ToolTip="{x:Static localization:Strings.HelpMessage_CheckPublicIPAddress}" Style="{StaticResource HelpImageRectangle}" Margin="10,0,0,0">
3131
<Rectangle.Resources>
3232
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" />
3333
</Rectangle.Resources>
3434
</Rectangle>
3535
</StackPanel>
3636
</StackPanel>
37+
<TextBlock Text="{x:Static localization:Strings.Appearance}" Style="{StaticResource HeaderTextBlock}" />
3738
<StackPanel Orientation="Horizontal">
39+
<mah:ToggleSwitch Header="{x:Static localization:Strings.ApplyThemeToPowerShellConsole}" IsOn="{Binding PowerShellModifyGlobalProfile}"/>
40+
<Rectangle Width="24" Height="24" ToolTip="{x:Static localization:Strings.HelpMessage_ApplyThemeToPowerShellConsole}" Style="{StaticResource HelpImageRectangle}" VerticalAlignment="Top" Margin="10,0,0,0">
41+
<Rectangle.Resources>
42+
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" />
43+
</Rectangle.Resources>
44+
</Rectangle>
45+
</StackPanel>
46+
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
3847
<Rectangle Width="24" Height="24" Style="{StaticResource InfoImageRectangle}" Margin="0,0,10,0" />
3948
<TextBlock Text="{x:Static localization:Strings.AllSettingsCanBeChangedLaterInTheSettings}" Style="{StaticResource InfoTextBlock}" />
4049
</StackPanel>

docs/Changelog/next-release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ New Feature
2828
- Detect new DNS servers if they have been changed e.g. by a new network connection (LAN, WLAN) or VPN connection [#1733](https://github.com/BornToBeRoot/NETworkManager/pull/1733){:target="\_blank"}
2929
- Error messages for failed DNS resolution improved [#1733](https://github.com/BornToBeRoot/NETworkManager/pull/1733){:target="\_blank"}
3030
- Check if folder exists in export dialog [#1760](https://github.com/BornToBeRoot/NETworkManager/pull/1760){:target="\_blank"}
31+
- First run dialog
32+
- PowerShell theme added [#1761](https://github.com/BornToBeRoot/NETworkManager/pull/1761){:target="\_blank"}
3133

3234
## Bugfixes
3335

0 commit comments

Comments
 (0)