Skip to content

Commit fb41d16

Browse files
authored
Feature: Redesign settings reset dialog (#3138)
* Feature: Reset settings dialog redesigned * Chore: Increase version after upgrade
1 parent b70f324 commit fb41d16

File tree

13 files changed

+112
-52
lines changed

13 files changed

+112
-52
lines changed

Source/GlobalAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
[assembly: AssemblyTrademark("")]
77
[assembly: AssemblyCulture("")]
88

9-
[assembly: AssemblyVersion("2025.6.13.0")]
10-
[assembly: AssemblyFileVersion("2025.6.13.0")]
9+
[assembly: AssemblyVersion("2025.8.11.0")]
10+
[assembly: AssemblyFileVersion("2025.8.11.0")]

Source/NETworkManager.Converters/ChildWindowIconToRectangleStyleConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1717
{
1818
case ChildWindowIcon.Info:
1919
return Application.Current.FindResource("InfoImageRectangle");
20+
case ChildWindowIcon.Question:
21+
return Application.Current.FindResource("QuestionImageRectangle");
2022
case ChildWindowIcon.Warn:
2123
return Application.Current.FindResource("WarnImageRectangle");
2224
case ChildWindowIcon.Error:

Source/NETworkManager.Settings/SettingsManager.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ public static void Upgrade(Version fromVersion, Version toVersion)
190190
if (fromVersion < new Version(2024, 11, 11, 0))
191191
UpgradeTo_2024_11_11_0();
192192

193+
// 2025.8.11.0
194+
if (fromVersion < new Version(2025, 8, 11, 0))
195+
UpgradeTo_2025_8_11_0();
196+
193197
// Latest
194198
if (fromVersion < toVersion)
195199
UpgradeToLatest(toVersion);
@@ -311,12 +315,11 @@ private static void UpgradeTo_2024_11_11_0()
311315
}
312316

313317
/// <summary>
314-
/// Method to apply changes for the latest version.
318+
/// Method to apply changes for version 2025.8.11.0.
315319
/// </summary>
316-
/// <param name="version">Latest version.</param>
317-
private static void UpgradeToLatest(Version version)
320+
private static void UpgradeTo_2025_8_11_0()
318321
{
319-
Log.Info($"Apply upgrade to {version}...");
322+
Log.Info("Apply upgrade to 2025.8.11.0...");
320323

321324
// Add Hosts editor application
322325
Log.Info("Add new app \"Hosts File Editor\"...");
@@ -326,5 +329,14 @@ private static void UpgradeToLatest(Version version)
326329
ApplicationManager.GetDefaultList().First(x => x.Name == ApplicationName.HostsFileEditor));
327330
}
328331

332+
/// <summary>
333+
/// Method to apply changes for the latest version.
334+
/// </summary>
335+
/// <param name="version">Latest version.</param>
336+
private static void UpgradeToLatest(Version version)
337+
{
338+
Log.Info($"Apply upgrade to {version}...");
339+
}
340+
329341
#endregion
330342
}

Source/NETworkManager.Utilities/ChildWindowIcon.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public enum ChildWindowIcon
1010
/// </summary>
1111
Info,
1212

13+
/// <summary>
14+
/// Question icon.
15+
/// </summary>
16+
Question,
17+
1318
/// <summary>
1419
/// Warning icon.
1520
/// </summary>

Source/NETworkManager/Resources/Styles/RectangleStyles.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636
<Setter Property="ToolTipService.ShowDuration" Value="600000" />
3737
</Style>
3838

39+
<Style x:Key="QuestionImageRectangle" TargetType="{x:Type Rectangle}">
40+
<Style.Resources>
41+
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource DefaultToolTip}" />
42+
</Style.Resources>
43+
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
44+
<Setter Property="OpacityMask">
45+
<Setter.Value>
46+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=HelpCircleOutline}" />
47+
</Setter.Value>
48+
</Setter>
49+
<Setter Property="ToolTipService.InitialShowDelay" Value="0" />
50+
<Setter Property="ToolTipService.ShowDuration" Value="600000" />
51+
</Style>
52+
3953
<Style x:Key="WarnImageRectangle" TargetType="{x:Type Rectangle}">
4054
<Style.Resources>
4155
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource DefaultToolTip}" />

Source/NETworkManager/ViewModels/OKCancelInfoMessageViewModel.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace NETworkManager.ViewModels;
77
public class OKCancelInfoMessageViewModel : ViewModelBase
88
{
99
public OKCancelInfoMessageViewModel(Action<OKCancelInfoMessageViewModel> okCommand,
10-
Action<OKCancelInfoMessageViewModel> cancelHandler, string message, string okButtonText = null, string cancelButtonText = null)
10+
Action<OKCancelInfoMessageViewModel> cancelHandler, string message, string okButtonText = null, string cancelButtonText = null, ChildWindowIcon icon = ChildWindowIcon.Info)
1111
{
1212
OKCommand = new RelayCommand(_ => okCommand(this));
1313
CancelCommand = new RelayCommand(_ => cancelHandler(this));
@@ -23,7 +23,6 @@ public OKCancelInfoMessageViewModel(Action<OKCancelInfoMessageViewModel> okComma
2323
public ICommand CancelCommand { get; }
2424

2525
private readonly string _message;
26-
2726
public string Message
2827
{
2928
get => _message;
@@ -38,7 +37,6 @@ private init
3837
}
3938

4039
private readonly string _okButtonText;
41-
4240
public string OKButtonText
4341
{
4442
get => _okButtonText;
@@ -53,7 +51,6 @@ private init
5351
}
5452

5553
private readonly string _cancelButtonText;
56-
5754
public string CancelButtonText
5855
{
5956
get => _cancelButtonText;
@@ -66,4 +63,18 @@ private init
6663
OnPropertyChanged();
6764
}
6865
}
66+
67+
private ChildWindowIcon _icon;
68+
public ChildWindowIcon Icon
69+
{
70+
get => _icon;
71+
private init
72+
{
73+
if (value == _icon)
74+
return;
75+
76+
_icon = value;
77+
OnPropertyChanged();
78+
}
79+
}
6980
}

Source/NETworkManager/ViewModels/OKMessageViewModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public OKMessageViewModel(Action<OKMessageViewModel> okCommand, string message,
1919
public ICommand OKCommand { get; }
2020

2121
private readonly string _message;
22-
2322
public string Message
2423
{
2524
get => _message;
@@ -34,7 +33,6 @@ private init
3433
}
3534

3635
private readonly string _okButtonText;
37-
3836
public string OKButtonText
3937
{
4038
get => _okButtonText;
@@ -49,7 +47,6 @@ private init
4947
}
5048

5149
private ChildWindowIcon _icon;
52-
5350
public ChildWindowIcon Icon
5451
{
5552
get => _icon;
Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
using System;
2-
using System.Diagnostics;
3-
using System.Windows;
4-
using System.Windows.Input;
5-
using MahApps.Metro.Controls.Dialogs;
1+
using MahApps.Metro.SimpleChildWindow;
62
using NETworkManager.Localization.Resources;
73
using NETworkManager.Settings;
84
using NETworkManager.Utilities;
5+
using NETworkManager.Views;
6+
using System;
7+
using System.Diagnostics;
8+
using System.Threading.Tasks;
9+
using System.Windows;
10+
using System.Windows.Input;
911

1012
namespace NETworkManager.ViewModels;
1113

1214
public class SettingsSettingsViewModel : ViewModelBase
1315
{
1416
#region Variables
15-
16-
private readonly IDialogCoordinator _dialogCoordinator;
17-
1817
public Action CloseAction { get; set; }
1918

2019
private string _location;
@@ -31,15 +30,12 @@ public string Location
3130
OnPropertyChanged();
3231
}
3332
}
34-
3533
#endregion
3634

3735
#region Constructor, LoadSettings
3836

39-
public SettingsSettingsViewModel(IDialogCoordinator instance)
37+
public SettingsSettingsViewModel()
4038
{
41-
_dialogCoordinator = instance;
42-
4339
LoadSettings();
4440
}
4541

@@ -61,26 +57,47 @@ private static void OpenLocationAction()
6157

6258
public ICommand ResetSettingsCommand => new RelayCommand(_ => ResetSettingsAction());
6359

64-
private async void ResetSettingsAction()
60+
private void ResetSettingsAction()
6561
{
66-
var settings = AppearanceManager.MetroDialog;
62+
ResetSettings().ConfigureAwait(false);
63+
}
6764

68-
settings.AffirmativeButtonText = Strings.Reset;
69-
settings.NegativeButtonText = Strings.Cancel;
65+
#endregion
7066

71-
settings.DefaultButtonFocus = MessageDialogResult.Affirmative;
67+
#region Methods
7268

73-
if (await _dialogCoordinator.ShowMessageAsync(this, Strings.ResetSettingsQuestion,
74-
Strings.SettingsAreResetAndApplicationWillBeRestartedMessage,
75-
MessageDialogStyle.AffirmativeAndNegative, settings) != MessageDialogResult.Affirmative)
76-
return;
69+
private Task ResetSettings()
70+
{
71+
var childWindow = new OKCancelInfoMessageChildWindow();
7772

78-
// Init default settings
79-
SettingsManager.Initialize();
73+
var childWindowViewModel = new OKCancelInfoMessageViewModel(_ =>
74+
{
75+
childWindow.IsOpen = false;
76+
ConfigurationManager.Current.IsChildWindowOpen = false;
8077

81-
// Restart the application
82-
(Application.Current.MainWindow as MainWindow)?.RestartApplication();
83-
}
78+
// Init default settings
79+
SettingsManager.Initialize();
80+
81+
// Restart the application
82+
(Application.Current.MainWindow as MainWindow)?.RestartApplication();
83+
}, _ =>
84+
{
85+
childWindow.IsOpen = false;
86+
ConfigurationManager.Current.IsChildWindowOpen = false;
87+
},
88+
Strings.SettingsAreResetAndApplicationWillBeRestartedMessage,
89+
Strings.Reset,
90+
Strings.Cancel,
91+
ChildWindowIcon.Question
92+
);
93+
94+
childWindow.Title = Strings.ResetSettingsQuestion;
95+
96+
childWindow.DataContext = childWindowViewModel;
8497

98+
ConfigurationManager.Current.IsChildWindowOpen = true;
99+
100+
return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow);
101+
}
85102
#endregion
86-
}
103+
}

Source/NETworkManager/ViewModels/WebConsoleSettingsViewModel.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
using System;
2-
using MahApps.Metro.SimpleChildWindow;
1+
using MahApps.Metro.SimpleChildWindow;
2+
using Microsoft.Web.WebView2.Core;
33
using NETworkManager.Localization.Resources;
44
using NETworkManager.Settings;
55
using NETworkManager.Utilities;
66
using NETworkManager.Views;
7+
using System;
78
using System.Threading.Tasks;
89
using System.Windows;
910
using System.Windows.Input;
10-
using Microsoft.Web.WebView2.Core;
11-
using Microsoft.Web.WebView2.Wpf;
1211

1312
namespace NETworkManager.ViewModels;
1413

Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
88
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
99
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
10+
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
1011
ChildWindowWidth="450"
1112
ChildWindowMaxHeight="500"
1213
ShowTitleBar="True"
@@ -20,6 +21,9 @@
2021
OverlayBrush="{DynamicResource ResourceKey=MahApps.Brushes.Gray.SemiTransparent}"
2122
Loaded="ChildWindow_Loaded"
2223
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:OKCancelInfoMessageViewModel}">
24+
<simpleChildWindow:ChildWindow.Resources>
25+
<converters:ChildWindowIconToRectangleStyleConverter x:Key="ChildWindowIconToRectangleStyleConverter" />
26+
</simpleChildWindow:ChildWindow.Resources>
2327
<Grid Margin="10">
2428
<Grid.RowDefinitions>
2529
<RowDefinition Height="*" />
@@ -36,8 +40,8 @@
3640
<ColumnDefinition Width="*" />
3741
</Grid.ColumnDefinitions>
3842
<Rectangle Grid.Column="0" Grid.Row="0"
39-
Width="32" Height="32"
40-
Style="{StaticResource InfoImageRectangle}" />
43+
Width="32" Height="32"
44+
Style="{Binding Icon, Converter={StaticResource ChildWindowIconToRectangleStyleConverter}}" />
4145
<TextBlock Grid.Column="2" Grid.Row="0"
4246
VerticalAlignment="Center"
4347
Text="{Binding Message}"

0 commit comments

Comments
 (0)