Skip to content

Commit c406271

Browse files
committed
Feature: Improve design / dialogs
1 parent e31ef74 commit c406271

30 files changed

+310
-4925
lines changed

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,8 @@ private async void LoadProfile(ProfileFileInfo info, bool showWrongPassword = fa
14421442
ProfileManager.Unload();
14431443
}, info.Name, showWrongPassword);
14441444

1445+
childWindow.Title = Strings.UnlockProfileFile;
1446+
14451447
childWindow.DataContext = viewModel;
14461448

14471449
ConfigurationManager.OnDialogOpen();

Source/NETworkManager/NETworkManager.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
<XamlRuntime>Wpf</XamlRuntime>
142142
<SubType>Designer</SubType>
143143
</Page>
144+
<Page Update="Views\ConfirmDeleteChildWindow.xaml">
145+
<Generator>MSBuild:Compile</Generator>
146+
<XamlRuntime>Wpf</XamlRuntime>
147+
<SubType>Designer</SubType>
148+
</Page>
144149
</ItemGroup>
145150
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
146151
<Exec Command="PowerShell.exe -ExecutionPolicy Bypass -NoProfile -File &quot;$(ProjectDir)..\..\Scripts\PreBuildEventCommandLine.ps1&quot; &quot;$(TargetDir)&quot;" />

Source/NETworkManager/ProfileDialogManager.cs

Lines changed: 68 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System;
1111
using System.Collections.Generic;
1212
using System.Configuration;
13+
using System.Diagnostics;
1314
using System.Security;
1415
using System.Threading.Tasks;
1516
using System.Windows;
@@ -308,7 +309,7 @@ private static GroupInfo ParseGroupInfo(GroupViewModel instance)
308309
{
309310
Name = name,
310311
Description = instance.Description?.Trim(),
311-
312+
312313
Profiles = profiles,
313314

314315
// Remote Desktop
@@ -468,133 +469,139 @@ private static GroupInfo ParseGroupInfo(GroupViewModel instance)
468469

469470
#region Dialog to add, edit, copy as and delete profile
470471

471-
public static Task ShowAddProfileDialog(Window parentWindow,IProfileManagerMinimal viewModel,
472+
public static Task ShowAddProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel,
472473
ProfileInfo profile = null, string group = null,
473474
ApplicationName applicationName = ApplicationName.None)
474475
{
475-
476476
var childWindow = new ProfileChildWindow(parentWindow);
477477

478478
ProfileViewModel profileViewModel = new(instance =>
479479
{
480480
childWindow.IsOpen = false;
481-
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
482-
481+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
482+
483483
viewModel.OnProfileManagerDialogClose();
484-
484+
485485
ProfileManager.AddProfile(ParseProfileInfo(instance));
486486
}, _ =>
487487
{
488+
Debug.WriteLine("Profile dialog closed without saving");
489+
488490
childWindow.IsOpen = false;
489491
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
490-
492+
491493
viewModel.OnProfileManagerDialogClose();
492494
}, ProfileManager.GetGroupNames(), group, ProfileEditMode.Add, profile, applicationName);
493495

494496
childWindow.Title = Strings.AddProfile;
495-
496-
childWindow.DataContext = profileViewModel;
497+
498+
childWindow.DataContext = profileViewModel;
499+
500+
viewModel.OnProfileManagerDialogOpen();
497501

498502
Settings.ConfigurationManager.Current.IsChildWindowOpen = true;
499503

500504
return parentWindow.ShowChildWindowAsync(childWindow);
501505
}
502506

503-
public static Task ShowEditProfileDialog(IProfileManagerMinimal viewModel,
504-
IDialogCoordinator dialogCoordinator, ProfileInfo profile)
507+
public static Task ShowEditProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel,
508+
ProfileInfo profile)
505509
{
506-
CustomDialog customDialog = new()
507-
{
508-
Title = Strings.EditProfile,
509-
Style = (Style)Application.Current.FindResource(DialogResourceKey)
510-
};
510+
var childWindow = new ProfileChildWindow(parentWindow);
511511

512-
ProfileViewModel profileViewModel = new(async instance =>
512+
ProfileViewModel profileViewModel = new(instance =>
513513
{
514-
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
514+
childWindow.IsOpen = false;
515+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
516+
515517
viewModel.OnProfileManagerDialogClose();
516518

517519
ProfileManager.ReplaceProfile(profile, ParseProfileInfo(instance));
518-
}, async _ =>
520+
}, _ =>
519521
{
520-
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
522+
childWindow.IsOpen = false;
523+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
524+
521525
viewModel.OnProfileManagerDialogClose();
522526
}, ProfileManager.GetGroupNames(), profile.Group, ProfileEditMode.Edit, profile);
523527

524-
customDialog.Content = new ProfileDialog
525-
{
526-
DataContext = profileViewModel
527-
};
528+
childWindow.Title = Strings.EditProfile;
528529

529-
viewModel.OnProfileManagerDialogOpen();
530+
childWindow.DataContext = profileViewModel;
530531

531-
return dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
532+
viewModel.OnProfileManagerDialogOpen();
533+
534+
Settings.ConfigurationManager.Current.IsChildWindowOpen = true;
535+
536+
return parentWindow.ShowChildWindowAsync(childWindow);
532537
}
533538

534-
public static Task ShowCopyAsProfileDialog(IProfileManagerMinimal viewModel,
535-
IDialogCoordinator dialogCoordinator, ProfileInfo profile)
539+
public static Task ShowCopyAsProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel,
540+
ProfileInfo profile)
536541
{
537-
CustomDialog customDialog = new()
538-
{
539-
Title = Strings.CopyProfile,
540-
Style = (Style)Application.Current.FindResource(DialogResourceKey)
541-
};
542+
var childWindow = new ProfileChildWindow(parentWindow);
542543

543-
ProfileViewModel profileViewModel = new(async instance =>
544+
ProfileViewModel profileViewModel = new(instance =>
544545
{
545-
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
546+
childWindow.IsOpen = false;
547+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
548+
546549
viewModel.OnProfileManagerDialogClose();
547550

548551
ProfileManager.AddProfile(ParseProfileInfo(instance));
549-
}, async _ =>
552+
}, _ =>
550553
{
551-
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
554+
childWindow.IsOpen = false;
555+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
556+
552557
viewModel.OnProfileManagerDialogClose();
553558
}, ProfileManager.GetGroupNames(), profile.Group, ProfileEditMode.Copy, profile);
554559

555-
customDialog.Content = new ProfileDialog
556-
{
557-
DataContext = profileViewModel
558-
};
559-
560+
childWindow.Title = Strings.CopyProfile;
561+
562+
childWindow.DataContext = profileViewModel;
563+
560564
viewModel.OnProfileManagerDialogOpen();
565+
566+
Settings.ConfigurationManager.Current.IsChildWindowOpen = true;
561567

562-
return dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
568+
return parentWindow.ShowChildWindowAsync(childWindow);
563569
}
564570

565-
public static Task ShowDeleteProfileDialog(IProfileManagerMinimal viewModel,
566-
IDialogCoordinator dialogCoordinator, IList<ProfileInfo> profiles)
571+
public static Task ShowDeleteProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel,
572+
IList<ProfileInfo> profiles)
567573
{
568-
CustomDialog customDialog = new()
569-
{
570-
Title = profiles.Count == 1
571-
? Strings.DeleteProfile
572-
: Strings.DeleteProfiles
573-
};
574-
575-
ConfirmDeleteViewModel confirmDeleteViewModel = new(async _ =>
574+
var childWindow = new ConfirmDeleteChildWindow();
575+
576+
ConfirmDeleteViewModel confirmDeleteViewModel = new(_ =>
576577
{
577-
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
578+
childWindow.IsOpen = false;
579+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
580+
578581
viewModel.OnProfileManagerDialogClose();
579582

580583
ProfileManager.RemoveProfiles(profiles);
581-
}, async _ =>
584+
}, _ =>
582585
{
583-
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
586+
childWindow.IsOpen = false;
587+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
588+
589+
584590
viewModel.OnProfileManagerDialogClose();
585591
},
586592
profiles.Count == 1
587593
? Strings.DeleteProfileMessage
588594
: Strings.DeleteProfilesMessage);
589595

590-
customDialog.Content = new ConfirmDeleteDialog
591-
{
592-
DataContext = confirmDeleteViewModel
593-
};
596+
childWindow.Title = Strings.DeleteProfile;
597+
598+
childWindow.DataContext = confirmDeleteViewModel;
594599

595600
viewModel.OnProfileManagerDialogOpen();
601+
602+
Settings.ConfigurationManager.Current.IsChildWindowOpen = true;
596603

597-
return dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
604+
return parentWindow.ShowChildWindowAsync(childWindow);
598605
}
599606

600607
#endregion

Source/NETworkManager/Resources/Styles/TextBlockStyles.xaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<Style x:Key="ErrorTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DefaultTextBlock}">
3030
<Setter Property="TextWrapping" Value="Wrap" />
31-
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Validation5}" />
31+
<Setter Property="Foreground" Value="#b95353" />
3232
</Style>
3333

3434
<Style x:Key="MessageTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DefaultTextBlock}">
@@ -52,6 +52,12 @@
5252

5353
<Style x:Key="StatusMessageTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource WrapTextBlock}" />
5454

55+
<Style x:Key="ConsoleTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DefaultTextBlock}">
56+
<Setter Property="FontFamily" Value="Consolas" />
57+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Gray3}" />
58+
<Setter Property="Margin" Value="0,5,0,5" />
59+
</Style>
60+
5561
<!-- TextBlock style for buttons with images and text -->
5662
<Style x:Key="ButtonWithImageTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DefaultTextBlock}">
5763
<Setter Property="Margin" Value="10,5" />

Source/NETworkManager/Resources/Templates/ValidationErrorTemplates.xaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111
-->
1212
<Grid>
1313
<Polygon x:Name="ToolTipCorner" Grid.ZIndex="1" Margin="0" Points="12,12 12,0 0,0"
14-
Fill="#b95353" HorizontalAlignment="Right"
15-
VerticalAlignment="Top" IsHitTestVisible="True" />
16-
14+
Fill="{DynamicResource MahApps.Brushes.Accent}" HorizontalAlignment="Right"
15+
VerticalAlignment="Top" IsHitTestVisible="True" />
1716
<AdornedElementPlaceholder x:Name="Adorner" />
1817
<Popup PlacementTarget="{Binding ElementName=Adorner}" PopupAnimation="Fade" HorizontalOffset="5">
1918
<Popup.Style>
2019
<Style TargetType="{x:Type Popup}">
2120
<Style.Triggers>
2221
<DataTrigger
23-
Binding="{Binding ElementName=Adorner, Path=AdornedElement.IsKeyboardFocusWithin}"
24-
Value="True">
22+
Binding="{Binding ElementName=Adorner, Path=AdornedElement.IsKeyboardFocusWithin}"
23+
Value="True">
2524
<Setter Property="PlacementTarget" Value="{Binding ElementName=Adorner}" />
2625
<Setter Property="Placement" Value="Right" />
2726
</DataTrigger>
2827
<DataTrigger Binding="{Binding ElementName=ToolTipCorner, Path=IsMouseOver}"
29-
Value="True">
28+
Value="True">
3029
<Setter Property="PlacementTarget" Value="{Binding ElementName=ToolTipCorner}" />
3130
<Setter Property="Placement" Value="Mouse" />
3231
</DataTrigger>
@@ -44,22 +43,22 @@
4443
</Popup.Style>
4544
<StackPanel>
4645
<Border MaxWidth="300" Background="{DynamicResource MahApps.Brushes.Window.Background}"
47-
BorderBrush="{DynamicResource MahApps.Brushes.Gray8}" BorderThickness="1" Padding="5">
46+
BorderBrush="{DynamicResource MahApps.Brushes.Gray8}" BorderThickness="1" Padding="5">
4847
<Grid>
4948
<Grid.ColumnDefinitions>
5049
<ColumnDefinition Width="Auto" />
5150
<ColumnDefinition Width="*" />
5251
</Grid.ColumnDefinitions>
5352
<Rectangle Grid.Column="0" Width="20" Height="20"
54-
Fill="{DynamicResource MahApps.Brushes.Gray3}">
53+
Fill="{DynamicResource MahApps.Brushes.Gray3}">
5554
<Rectangle.OpacityMask>
5655
<VisualBrush Stretch="Uniform"
57-
Visual="{iconPacks:Material Kind=InformationVariant}" />
56+
Visual="{iconPacks:Material Kind=InformationVariant}" />
5857
</Rectangle.OpacityMask>
5958
</Rectangle>
6059
<TextBlock Grid.Column="1" Text="{Binding Path=/ErrorContent}"
61-
Foreground="{DynamicResource MahApps.Brushes.Text}" FontSize="14"
62-
TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" />
60+
Foreground="{DynamicResource MahApps.Brushes.Text}" FontSize="14"
61+
TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" />
6362
</Grid>
6463
</Border>
6564
</StackPanel>

Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,22 +456,22 @@ private bool ModifyProfile_CanExecute(object obj)
456456

457457
private void EditProfileAction()
458458
{
459-
ProfileDialogManager.ShowEditProfileDialog(this, _dialogCoordinator, SelectedProfile).ConfigureAwait(false);
459+
ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile).ConfigureAwait(false);
460460
}
461461

462462
public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute);
463463

464464
private void CopyAsProfileAction()
465465
{
466-
ProfileDialogManager.ShowCopyAsProfileDialog(this, _dialogCoordinator, SelectedProfile).ConfigureAwait(false);
466+
ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow,this, SelectedProfile).ConfigureAwait(false);
467467
}
468468

469469
public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute);
470470

471471
private void DeleteProfileAction()
472472
{
473473
ProfileDialogManager
474-
.ShowDeleteProfileDialog(this, _dialogCoordinator, new List<ProfileInfo> { SelectedProfile })
474+
.ShowDeleteProfileDialog(Application.Current.MainWindow, this, new List<ProfileInfo> { SelectedProfile })
475475
.ConfigureAwait(false);
476476
}
477477

Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,22 +264,22 @@ private bool ModifyProfile_CanExecute(object obj)
264264

265265
private void EditProfileAction()
266266
{
267-
ProfileDialogManager.ShowEditProfileDialog(this, _dialogCoordinator, SelectedProfile).ConfigureAwait(false);
267+
ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile).ConfigureAwait(false);
268268
}
269269

270270
public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute);
271271

272272
private void CopyAsProfileAction()
273273
{
274-
ProfileDialogManager.ShowCopyAsProfileDialog(this, _dialogCoordinator, SelectedProfile).ConfigureAwait(false);
274+
ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow,this, SelectedProfile).ConfigureAwait(false);
275275
}
276276

277277
public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute);
278278

279279
private void DeleteProfileAction()
280280
{
281281
ProfileDialogManager
282-
.ShowDeleteProfileDialog(this, _dialogCoordinator, new List<ProfileInfo> { SelectedProfile })
282+
.ShowDeleteProfileDialog(Application.Current.MainWindow, this, new List<ProfileInfo> { SelectedProfile })
283283
.ConfigureAwait(false);
284284
}
285285

Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,22 @@ private bool ModifyProfile_CanExecute(object obj)
265265

266266
private void EditProfileAction()
267267
{
268-
ProfileDialogManager.ShowEditProfileDialog(this, _dialogCoordinator, SelectedProfile).ConfigureAwait(false);
268+
ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile).ConfigureAwait(false);
269269
}
270270

271271
public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute);
272272

273273
private void CopyAsProfileAction()
274274
{
275-
ProfileDialogManager.ShowCopyAsProfileDialog(this, _dialogCoordinator, SelectedProfile).ConfigureAwait(false);
275+
ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow,this, SelectedProfile).ConfigureAwait(false);
276276
}
277277

278278
public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute);
279279

280280
private void DeleteProfileAction()
281281
{
282282
ProfileDialogManager
283-
.ShowDeleteProfileDialog(this, _dialogCoordinator, new List<ProfileInfo> { SelectedProfile })
283+
.ShowDeleteProfileDialog(Application.Current.MainWindow, this, new List<ProfileInfo> { SelectedProfile })
284284
.ConfigureAwait(false);
285285
}
286286

0 commit comments

Comments
 (0)