Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions Source/NETworkManager/StatusWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,7 @@
</mah:WindowCommands>
</mah:MetroWindow.LeftWindowCommands>
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands ShowSeparators="False">
<Button Command="{Binding Path=ReloadCommand}"
ToolTip="{x:Static Member=localization:Strings.Reload}"
Cursor="Hand"
Focusable="False"
Margin="0,0,5,0">
<StackPanel Orientation="Horizontal">
<Rectangle Width="16" Height="16"
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Refresh}" />
</Rectangle.OpacityMask>
</Rectangle>
</StackPanel>
</Button>
<mah:WindowCommands ShowSeparators="False">
<Button Command="{Binding Path=ShowMainWindowCommand}"
ToolTip="{x:Static Member=localization:Strings.Show}"
Cursor="Hand"
Expand Down
7 changes: 0 additions & 7 deletions Source/NETworkManager/StatusWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ public double Time

#region ICommands & Actions

public ICommand ReloadCommand => new RelayCommand(_ => ReloadAction());

private void ReloadAction()
{
Check();
}

public ICommand ShowMainWindowCommand => new RelayCommand(_ => ShowMainWindowAction());

private void ShowMainWindowAction()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using System.Windows.Input;
using NETworkManager.Models.IPApi;
using NETworkManager.Settings;
Expand Down Expand Up @@ -55,6 +55,7 @@ private set
public IPApiDNSResolverWidgetViewModel()
{
LoadSettings();
Check();
}

/// <summary>
Expand All @@ -70,17 +71,9 @@ private void LoadSettings()
#region ICommands & Actions

/// <summary>
/// Gets the command to check via hotkey.
/// Gets the command to check the DNS resolver.
/// </summary>
public ICommand CheckViaHotkeyCommand => new RelayCommand(_ => CheckViaHotkeyAction());

/// <summary>
/// Action to check via hotkey.
/// </summary>
private void CheckViaHotkeyAction()
{
Check();
}
public ICommand CheckCommand => new RelayCommand(_ => Check(), _ => !IsRunning);

#endregion

Expand All @@ -89,7 +82,7 @@ private void CheckViaHotkeyAction()
/// <summary>
/// Checks the DNS resolver.
/// </summary>
public void Check()
private void Check()
{
_ = CheckAsync();
}
Expand All @@ -103,14 +96,10 @@ private async Task CheckAsync()
if (!SettingsManager.Current.Dashboard_CheckIPApiDNSResolver)
return;

// Don't check multiple times if already running
if (IsRunning)
return;

IsRunning = true;
Result = null;

// Make the user happy, let him see a reload animation (and he cannot spam the reload command)
// Make the user happy, let him see a reload animation (and he cannot spam the reload command)
await Task.Delay(GlobalStaticConfiguration.ApplicationUIRefreshInterval);

Result = await DNSResolverService.GetInstance().GetDNSResolverAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private set
public IPApiIPGeolocationWidgetViewModel()
{
LoadSettings();
Check();
}

/// <summary>
Expand All @@ -72,17 +73,9 @@ private void LoadSettings()
#region ICommands & Actions

/// <summary>
/// Gets the command to check via hotkey.
/// Gets the command to check the IP geolocation.
/// </summary>
public ICommand CheckViaHotkeyCommand => new RelayCommand(_ => CheckViaHotkeyAction());

/// <summary>
/// Action to check via hotkey.
/// </summary>
private void CheckViaHotkeyAction()
{
Check();
}
public ICommand CheckCommand => new RelayCommand(_ => Check(), _ => !IsRunning);

#endregion

Expand All @@ -91,7 +84,7 @@ private void CheckViaHotkeyAction()
/// <summary>
/// Checks the IP geolocation.
/// </summary>
public void Check()
private void Check()
{
_ = CheckAsync();
}
Expand All @@ -105,10 +98,6 @@ private async Task CheckAsync()
if (!SettingsManager.Current.Dashboard_CheckIPApiIPGeolocation)
return;

// Don't check multiple times if already running
if (IsRunning)
return;

IsRunning = true;
Result = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,22 @@ private set
/// </summary>
public bool CheckPublicIPAddressEnabled => SettingsManager.Current.Dashboard_CheckPublicIPAddress;

/// <summary>
/// Gets or sets a value indicating whether a check is currently running.
/// </summary>
public bool IsChecking
{
get;
private set
{
if (value == field)
return;

field = value;
OnPropertyChanged();
}
}

#endregion

#region Constructor, load settings
Expand All @@ -486,6 +502,7 @@ private set
public NetworkConnectionWidgetViewModel()
{
LoadSettings();
Check();
}

/// <summary>
Expand All @@ -500,17 +517,9 @@ private void LoadSettings()
#region ICommands & Actions

/// <summary>
/// Gets the command to check connections via hotkey.
/// Gets the command to check connections.
/// </summary>
public ICommand CheckViaHotkeyCommand => new RelayCommand(_ => CheckViaHotkeyAction());

/// <summary>
/// Executes the check via hotkey action.
/// </summary>
private void CheckViaHotkeyAction()
{
Check();
}
public ICommand CheckCommand => new RelayCommand(_ => Check());

#endregion

Expand Down Expand Up @@ -564,6 +573,8 @@ private async Task CheckAsync()
_cancellationTokenSource = new CancellationTokenSource();
var wasCanceled = false;

IsChecking = true;

try
{
_checkTask = RunTask(_cancellationTokenSource.Token);
Expand All @@ -576,6 +587,9 @@ private async Task CheckAsync()
}
finally
{
IsChecking = false;
_cancellationTokenSource.Dispose();

if (!wasCanceled)
Log.Info("Network connection check completed.");
}
Expand Down
1 change: 1 addition & 0 deletions Source/NETworkManager/Views/ConnectionsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
</ComboBox>
<Button Command="{Binding Path=RefreshCommand}"
Style="{StaticResource CleanButton}"
ToolTip="{x:Static localization:Strings.Refresh}"
Margin="0,0,10,0">
<Rectangle Width="16" Height="16"
wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
Expand Down
19 changes: 3 additions & 16 deletions Source/NETworkManager/Views/DashboardView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,18 @@ public DashboardView()
ContentControlIPApiIPGeolocation.Content = _ipApiIPGeolocationWidgetView;
ContentControlIPApiDNSResolver.Content = _ipApiDNSResolverWidgetView;
ContentControlSpeedTest.Content = _speedTestWidgetView;

// Check all widgets
Check();
}

public void OnViewVisible()
{
_viewModel.OnViewVisible();

// Check all widgets
Check();
// Check network connection
_networkConnectionWidgetView.Check();
}

public void OnViewHide()
{
_viewModel.OnViewHide();
}

/// <summary>
/// Check all widgets
/// </summary>
private void Check()
{
_networkConnectionWidgetView.Check();
_ipApiIPGeolocationWidgetView.Check();
_ipApiDNSResolverWidgetView.Check();
}
}
}
1 change: 1 addition & 0 deletions Source/NETworkManager/Views/FirewallView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
HorizontalAlignment="Right">
<Button Command="{Binding Path=RefreshCommand}"
Style="{StaticResource CleanButton}"
ToolTip="{x:Static localization:Strings.Refresh}"
Margin="0,0,10,0">
<Rectangle Width="16" Height="16"
wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
Expand Down
1 change: 1 addition & 0 deletions Source/NETworkManager/Views/HostsFileEditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
HorizontalAlignment="Right">
<Button Command="{Binding Path=RefreshCommand}"
Style="{StaticResource CleanButton}"
ToolTip="{x:Static localization:Strings.Refresh}"
Margin="0,0,10,0">
<Rectangle Width="16" Height="16"
wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
Expand Down
49 changes: 39 additions & 10 deletions Source/NETworkManager/Views/IPApiDNSResolverWidgetView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
mc:Ignorable="d" MinHeight="200"
d:DataContext="{d:DesignInstance viewModels:IPApiDNSResolverWidgetViewModel}">
<UserControl.InputBindings>
<KeyBinding Key="F5" Command="{Binding CheckViaHotkeyCommand}" />
<KeyBinding Key="F5" Command="{Binding CheckCommand}" />
</UserControl.InputBindings>
<UserControl.Resources>
<converters:BooleanReverseToVisibilityCollapsedConverter x:Key="BooleanReverseToVisibilityCollapsedConverter" />
Expand All @@ -37,15 +38,43 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="10">
<Rectangle Width="32" Height="32" Fill="{DynamicResource MahApps.Brushes.Gray3}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=SearchWeb}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Text="{x:Static localization:Strings.DNSResolver}"
Style="{StaticResource MessageTextBlock}" Margin="10,0,0,0" />
</StackPanel>
<Grid Grid.Row="0" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
<Rectangle Width="32" Height="32" Fill="{DynamicResource MahApps.Brushes.Gray3}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=SearchWeb}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Text="{x:Static localization:Strings.DNSResolver}"
Style="{StaticResource MessageTextBlock}" Margin="10,0,0,0" />
</StackPanel>
<Button Grid.Column="2" Command="{Binding CheckCommand}"
Style="{StaticResource CleanButton}"
ToolTip="{x:Static localization:Strings.Refresh}"
VerticalAlignment="Center">
<Rectangle Width="20" Height="20"
Comment on lines +56 to +60
wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRunning}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Refresh}" />
</Rectangle.OpacityMask>
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}" Value="True">
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray5}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
</Button>
</Grid>
<Grid Grid.Column="0" Grid.Row="2" Margin="10"
Visibility="{Binding Source={x:Static Member=settings:SettingsManager.Current}, Path=Dashboard_CheckIPApiDNSResolver, Converter={StaticResource ResourceKey=BooleanToVisibilityCollapsedConverter}}">
<!-- Result-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

using NETworkManager.ViewModels;

Comment on lines +1 to 3
namespace NETworkManager.Views;
Expand All @@ -12,8 +13,4 @@ public IPApiDNSResolverWidgetView()
DataContext = _viewModel;
}

public void Check()
{
_viewModel.Check();
}
}
Loading
Loading