Skip to content

Commit c18be2e

Browse files
authored
Fix: Change dialog to child window to allow drag & resize (#2914)
* Fix: Change dialog to child window to allow drag & drop * Docs: #2914
1 parent 2d51c48 commit c18be2e

File tree

7 files changed

+89
-64
lines changed

7 files changed

+89
-64
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("2024.8.1.0")]
10-
[assembly: AssemblyFileVersion("2024.8.1.0")]
9+
[assembly: AssemblyVersion("2024.11.18.0")]
10+
[assembly: AssemblyFileVersion("2024.11.18.0")]

Source/NETworkManager/MainWindow.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
</MenuItem>
7171
</ContextMenu>
7272
</mah:MetroWindow.Resources>
73-
7473
<mah:MetroWindow.InputBindings>
7574
<KeyBinding Command="{Binding OpenRunCommand}" Modifiers="Control+Shift" Key="P" />
7675
</mah:MetroWindow.InputBindings>
@@ -89,7 +88,7 @@
8988
</mah:WindowCommands>
9089
</mah:MetroWindow.LeftWindowCommands>
9190
<mah:MetroWindow.RightWindowCommands>
92-
<mah:WindowCommands ShowSeparators="False">
91+
<mah:WindowCommands ShowSeparators="False" Visibility="{Binding IsWelcomeWindowOpen, Converter={StaticResource BooleanReverseToVisibilityCollapsedConverter}}">
9392
<Button Command="{Binding OpenRunCommand}"
9493
Visibility="{Binding Path=FlyoutRunCommandIsOpen, Converter={StaticResource ResourceKey=BooleanReverseToVisibilityCollapsedConverter}}"
9594
ToolTip="{x:Static localization:Strings.ToolTip_RunCommandWithHotKey}"

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using log4net;
22
using MahApps.Metro.Controls.Dialogs;
3+
using MahApps.Metro.SimpleChildWindow;
34
using NETworkManager.Controls;
45
using NETworkManager.Documentation;
56
using NETworkManager.Localization;
@@ -127,6 +128,21 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
127128
private bool _isInTray;
128129
private bool _isClosing;
129130

131+
private bool _isWelcomeWindowOpen;
132+
133+
public bool IsWelcomeWindowOpen
134+
{
135+
get => _isWelcomeWindowOpen;
136+
set
137+
{
138+
if (value == _isWelcomeWindowOpen)
139+
return;
140+
141+
_isWelcomeWindowOpen = value;
142+
OnPropertyChanged();
143+
}
144+
}
145+
130146
private bool _applicationViewIsExpanded;
131147

132148
public bool ApplicationViewIsExpanded
@@ -487,14 +503,14 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset,
487503
// Show welcome dialog
488504
if (SettingsManager.Current.WelcomeDialog_Show)
489505
{
490-
var customDialog = new CustomDialog
491-
{
492-
Title = Strings.Welcome
493-
};
506+
507+
var x = new WelcomeChildWindow();
494508

495509
var welcomeViewModel = new WelcomeViewModel(async instance =>
496510
{
497-
await this.HideMetroDialogAsync(customDialog);
511+
IsWelcomeWindowOpen = false;
512+
513+
x.IsOpen = false;
498514

499515
// Set settings based on user choice
500516
SettingsManager.Current.Update_CheckForUpdatesAtStartup = instance.CheckForUpdatesAtStartup;
@@ -546,12 +562,11 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset,
546562
Load();
547563
});
548564

549-
customDialog.Content = new WelcomeDialog
550-
{
551-
DataContext = welcomeViewModel
552-
};
565+
x.DataContext = welcomeViewModel;
553566

554-
await this.ShowMetroDialogAsync(customDialog).ConfigureAwait(true);
567+
IsWelcomeWindowOpen = true;
568+
569+
await this.ShowChildWindowAsync(x);
555570
}
556571
else
557572
{
@@ -1315,7 +1330,7 @@ private void RunCommandFlyoutClose(bool clearSearch = false)
13151330
{
13161331
if (!FlyoutRunCommandIsOpen)
13171332
return;
1318-
1333+
13191334
FlyoutRunCommandIsOpen = false;
13201335

13211336
ConfigurationManager.OnDialogClose();
@@ -1522,9 +1537,9 @@ private void ProfileManager_OnLoadedProfileFileChangedEvent(object sender, Profi
15221537
private void CheckForUpdates()
15231538
{
15241539
var updater = new Updater();
1525-
1540+
15261541
updater.UpdateAvailable += Updater_UpdateAvailable;
1527-
1542+
15281543
updater.CheckOnGitHub(Properties.Resources.NETworkManager_GitHub_User,
15291544
Properties.Resources.NETworkManager_GitHub_Repo, AssemblyManager.Current.Version,
15301545
SettingsManager.Current.Update_CheckForPreReleases);
@@ -1945,7 +1960,7 @@ private async void OnNetworkHasChanged()
19451960
OpenStatusWindow(true);
19461961
}));
19471962
}
1948-
1963+
19491964
_isNetworkChanging = false;
19501965
}
19511966

Source/NETworkManager/NETworkManager.csproj

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
<BeautyLogLevel>Info</BeautyLogLevel>
4444
</PropertyGroup>
4545
<ItemGroup>
46-
<None Remove="log4net.config"/>
47-
<None Remove="NETworkManager.ico"/>
48-
<None Remove="SplashScreen.png"/>
49-
<None Include="..\.editorconfig" Link=".editorconfig"/>
46+
<None Remove="log4net.config" />
47+
<None Remove="NETworkManager.ico" />
48+
<None Remove="SplashScreen.png" />
49+
<None Include="..\.editorconfig" Link=".editorconfig" />
5050
<None Include="NETworkManager.ico">
5151
<Pack>True</Pack>
5252
</None>
@@ -57,53 +57,54 @@
5757
</Content>
5858
</ItemGroup>
5959
<ItemGroup>
60-
<PackageReference Include="AirspaceFixer" Version="1.0.6"/>
61-
<PackageReference Include="AWSSDK.EC2" Version="3.7.414.4"/>
62-
<PackageReference Include="DnsClient" Version="1.8.0"/>
63-
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1"/>
64-
<PackageReference Include="IPNetwork2" Version="3.0.667"/>
65-
<PackageReference Include="Lextm.SharpSnmpLib" Version="12.5.5"/>
66-
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7"/>
67-
<PackageReference Include="LoadingIndicators.WPF" Version="0.0.1"/>
68-
<PackageReference Include="log4net" Version="3.0.3"/>
69-
<PackageReference Include="MahApps.Metro" Version="2.4.10"/>
70-
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="5.1.0"/>
71-
<PackageReference Include="MahApps.Metro.IconPacks.Material" Version="5.1.0"/>
72-
<PackageReference Include="MahApps.Metro.IconPacks.MaterialLight" Version="5.1.0"/>
73-
<PackageReference Include="MahApps.Metro.IconPacks.Modern" Version="5.1.0"/>
74-
<PackageReference Include="MahApps.Metro.IconPacks.Octicons" Version="5.1.0"/>
75-
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2849.39"/>
76-
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6"/>
77-
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135"/>
78-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
79-
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.6"/>
80-
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3"/>
60+
<PackageReference Include="AirspaceFixer" Version="1.0.6" />
61+
<PackageReference Include="AWSSDK.EC2" Version="3.7.414.4" />
62+
<PackageReference Include="DnsClient" Version="1.8.0" />
63+
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
64+
<PackageReference Include="IPNetwork2" Version="3.0.667" />
65+
<PackageReference Include="Lextm.SharpSnmpLib" Version="12.5.5" />
66+
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
67+
<PackageReference Include="LoadingIndicators.WPF" Version="0.0.1" />
68+
<PackageReference Include="log4net" Version="3.0.3" />
69+
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
70+
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="5.1.0" />
71+
<PackageReference Include="MahApps.Metro.IconPacks.Material" Version="5.1.0" />
72+
<PackageReference Include="MahApps.Metro.IconPacks.MaterialLight" Version="5.1.0" />
73+
<PackageReference Include="MahApps.Metro.IconPacks.Modern" Version="5.1.0" />
74+
<PackageReference Include="MahApps.Metro.IconPacks.Octicons" Version="5.1.0" />
75+
<PackageReference Include="MahApps.Metro.SimpleChildWindow" Version="2.2.1" />
76+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2849.39" />
77+
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
78+
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />
79+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
80+
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.6" />
81+
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
8182
<Reference Include="AxMSTSCLib">
8283
<HintPath>$(TargetDir)\lib\AxMSTSCLib.dll</HintPath>
8384
</Reference>
8485
<Reference Include="MSTSCLib">
8586
<HintPath>$(TargetDir)\lib\MSTSCLib.dll</HintPath>
8687
</Reference>
87-
<Compile Include="..\GlobalAssemblyInfo.cs" Link="Properties\GlobalAssemblyInfo.cs"/>
88+
<Compile Include="..\GlobalAssemblyInfo.cs" Link="Properties\GlobalAssemblyInfo.cs" />
8889
</ItemGroup>
8990

9091
<ItemGroup>
91-
<ProjectReference Include="..\3rdparty\Dragablz\Dragablz\Dragablz.csproj"/>
92-
<ProjectReference Include="..\NETworkManager.Controls\NETworkManager.Controls.csproj"/>
93-
<ProjectReference Include="..\NETworkManager.Converters\NETworkManager.Converters.csproj"/>
94-
<ProjectReference Include="..\NETworkManager.Documentation\NETworkManager.Documentation.csproj"/>
95-
<ProjectReference Include="..\NETworkManager.Localization\NETworkManager.Localization.csproj"/>
96-
<ProjectReference Include="..\NETworkManager.Models\NETworkManager.Models.csproj"/>
97-
<ProjectReference Include="..\NETworkManager.Profiles\NETworkManager.Profiles.csproj"/>
98-
<ProjectReference Include="..\NETworkManager.Settings\NETworkManager.Settings.csproj"/>
99-
<ProjectReference Include="..\NETworkManager.Update\NETworkManager.Update.csproj"/>
100-
<ProjectReference Include="..\NETworkManager.Utilities.WPF\NETworkManager.Utilities.WPF.csproj"/>
101-
<ProjectReference Include="..\NETworkManager.Utilities\NETworkManager.Utilities.csproj"/>
102-
<ProjectReference Include="..\NETworkManager.Validators\NETworkManager.Validators.csproj"/>
92+
<ProjectReference Include="..\3rdparty\Dragablz\Dragablz\Dragablz.csproj" />
93+
<ProjectReference Include="..\NETworkManager.Controls\NETworkManager.Controls.csproj" />
94+
<ProjectReference Include="..\NETworkManager.Converters\NETworkManager.Converters.csproj" />
95+
<ProjectReference Include="..\NETworkManager.Documentation\NETworkManager.Documentation.csproj" />
96+
<ProjectReference Include="..\NETworkManager.Localization\NETworkManager.Localization.csproj" />
97+
<ProjectReference Include="..\NETworkManager.Models\NETworkManager.Models.csproj" />
98+
<ProjectReference Include="..\NETworkManager.Profiles\NETworkManager.Profiles.csproj" />
99+
<ProjectReference Include="..\NETworkManager.Settings\NETworkManager.Settings.csproj" />
100+
<ProjectReference Include="..\NETworkManager.Update\NETworkManager.Update.csproj" />
101+
<ProjectReference Include="..\NETworkManager.Utilities.WPF\NETworkManager.Utilities.WPF.csproj" />
102+
<ProjectReference Include="..\NETworkManager.Utilities\NETworkManager.Utilities.csproj" />
103+
<ProjectReference Include="..\NETworkManager.Validators\NETworkManager.Validators.csproj" />
103104
</ItemGroup>
104105
<ItemGroup>
105-
<Resource Include="NETworkManager.ico"/>
106-
<Resource Include="SplashScreen.png"/>
106+
<Resource Include="NETworkManager.ico" />
107+
<Resource Include="SplashScreen.png" />
107108
</ItemGroup>
108109
<ItemGroup>
109110
<Compile Update="Properties\Resources.Designer.cs">
@@ -136,6 +137,6 @@
136137
</Page>
137138
</ItemGroup>
138139
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
139-
<Exec Command="PowerShell.exe -ExecutionPolicy Bypass -NoProfile -File &quot;$(ProjectDir)..\..\Scripts\PreBuildEventCommandLine.ps1&quot; &quot;$(TargetDir)&quot;"/>
140+
<Exec Command="PowerShell.exe -ExecutionPolicy Bypass -NoProfile -File &quot;$(ProjectDir)..\..\Scripts\PreBuildEventCommandLine.ps1&quot; &quot;$(TargetDir)&quot;" />
140141
</Target>
141142
</Project>

Source/NETworkManager/Views/WelcomeDialog.xaml renamed to Source/NETworkManager/Views/WelcomeChildWindow.xaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
<UserControl x:Class="NETworkManager.Views.WelcomeDialog"
1+
<simpleChildWindow:ChildWindow x:Class="NETworkManager.Views.WelcomeChildWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
66
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"
9+
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
10+
ShowTitleBar="False"
11+
ChildWindowMaxWidth="650"
12+
ChildWindowMaxHeight="800"
13+
CloseByEscape="False"
14+
Padding="20"
15+
OverlayBrush="{DynamicResource MahApps.Brushes.Gray8}"
916
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:WelcomeViewModel}">
10-
<Grid Margin="0,20">
17+
<Grid Margin="10">
1118
<Grid.RowDefinitions>
1219
<RowDefinition Height="*" />
1320
<RowDefinition Height="10" />
1421
<RowDefinition Height="Auto" />
1522
</Grid.RowDefinitions>
1623
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Disabled">
1724
<StackPanel>
25+
<TextBlock Text="{x:Static Member=localization:Strings.Welcome}" Style="{StaticResource HeaderTextBlock}" />
1826
<TextBlock Text="{x:Static Member=localization:Strings.WelcomeMessage}"
1927
Style="{StaticResource ResourceKey=DefaultTextBlock}" Margin="0,0,0,20" TextWrapping="Wrap" />
2028
<TextBlock Text="{x:Static Member=localization:Strings.Privacy}"
@@ -96,4 +104,4 @@
96104
Command="{Binding ContinueCommand}" IsDefault="True"
97105
Style="{StaticResource ResourceKey=HighlightedButton}" />
98106
</Grid>
99-
</UserControl>
107+
</simpleChildWindow:ChildWindow>

Source/NETworkManager/Views/WelcomeDialog.xaml.cs renamed to Source/NETworkManager/Views/WelcomeChildWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace NETworkManager.Views;
22

3-
public partial class WelcomeDialog
3+
public partial class WelcomeChildWindow
44
{
5-
public WelcomeDialog()
5+
public WelcomeChildWindow()
66
{
77
InitializeComponent();
88
}

Website/docs/changelog/next-release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Release date: **xx.xx.2024**
2323

2424
## Bugfixes
2525

26+
- Changed the Welcome dialog from `MahApps.Metro.Controls.Dialogs` to `MahApps.Metro.SimpleChildWindow`, so the main window can be dragged and resized on the first start. [#2914](https://github.com/BornToBeRoot/NETworkManager/pull/2914)
27+
2628
## Dependencies, Refactoring & Documentation
2729

2830
- Code cleanup & refactoring

0 commit comments

Comments
 (0)