Skip to content

Commit 19bfbbc

Browse files
committed
Reload animation added
1 parent 79c8c9d commit 19bfbbc

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

Source/NETworkManager/Models/Network/ARPTable.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ protected virtual void OnUserHasCanceled()
7070
#endregion
7171

7272
#region Methods
73+
public static Task<List<ARPTableInfo>> GetTableAsync()
74+
{
75+
return Task.Run(() => GetTable());
76+
}
77+
7378
public static List<ARPTableInfo> GetTable()
7479
{
7580
List<ARPTableInfo> list = new List<ARPTableInfo>();

Source/NETworkManager/ViewModels/Applications/ARPTableViewModel.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using MahApps.Metro.Controls.Dialogs;
1010
using NETworkManager.ViewModels.Dialogs;
1111
using NETworkManager.Views.Dialogs;
12+
using System.Threading.Tasks;
1213

1314
namespace NETworkManager.ViewModels.Applications
1415
{
@@ -68,6 +69,20 @@ public ARPTableInfo SelectedARPTableInfo
6869
}
6970
}
7071

72+
private bool _isRefreshing;
73+
public bool IsRefreshing
74+
{
75+
get { return _isRefreshing; }
76+
set
77+
{
78+
if (value == _isRefreshing)
79+
return;
80+
81+
_isRefreshing = value;
82+
OnPropertyChanged();
83+
}
84+
}
85+
7186
private bool _displayStatusMessage;
7287
public bool DisplayStatusMessage
7388
{
@@ -264,11 +279,17 @@ private void CopySelectedMulticastAction()
264279
#endregion
265280

266281
#region Methods
267-
private void Refresh()
282+
private async void Refresh()
268283
{
284+
IsRefreshing = true;
285+
269286
ARPTable.Clear();
270287

271-
Models.Network.ARPTable.GetTable().ForEach(x => ARPTable.Add(x));
288+
(await Models.Network.ARPTable.GetTableAsync()).ForEach(x => ARPTable.Add(x));
289+
290+
await Task.Delay(2000);
291+
292+
IsRefreshing = false;
272293
}
273294
#endregion
274295

Source/NETworkManager/Views/Applications/ARPTableView.xaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
88
xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
99
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
10+
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
1011
Dialog:DialogParticipation.Register="{Binding}"
1112
mc:Ignorable="d">
1213
<UserControl.Resources>
1314
<Converter:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
1415
<Converter:BooleanToStringConverter x:Key="BooleanToStringConverter" />
16+
<Converter:BooleanReverseConverter x:Key="BooleanReverseConverter" />
1517
<Converter:PhysicalAddressToStringConverter x:Key="PhysicalAddressToStringConverter" />
1618
</UserControl.Resources>
1719
<Grid Margin="10">
@@ -20,6 +22,7 @@
2022
<RowDefinition Height="10" />
2123
<RowDefinition Height="*"/>
2224
<RowDefinition Height="Auto"/>
25+
<RowDefinition Height="Auto" />
2326
<RowDefinition Height="10" />
2427
<RowDefinition Height="Auto"/>
2528
</Grid.RowDefinitions>
@@ -91,7 +94,18 @@
9194
</DataGrid.Columns>
9295
</DataGrid>
9396
<TextBlock Grid.Row="3" Foreground="{DynamicResource AccentColorBrush}" Text="{Binding StatusMessage}" Visibility="{Binding DisplayStatusMessage, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{DynamicResource DefaultTextBlock}" Margin="0,10,0,0" />
94-
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right">
97+
<Controls:MetroProgressBar Grid.Row="4" Margin="0,10,0,0" Foreground="{DynamicResource AccentColorBrush}" IsIndeterminate="True">
98+
<Controls:MetroProgressBar.Style>
99+
<Style TargetType="{x:Type Controls:MetroProgressBar}">
100+
<Style.Triggers>
101+
<DataTrigger Binding="{Binding IsRefreshing}" Value="False">
102+
<Setter Property="Visibility" Value="Collapsed" />
103+
</DataTrigger>
104+
</Style.Triggers>
105+
</Style>
106+
</Controls:MetroProgressBar.Style>
107+
</Controls:MetroProgressBar>
108+
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Right">
95109
<Button Command="{Binding AddEntryCommand}" Style="{StaticResource ImageWithTextButton}">
96110
<Button.Content>
97111
<Grid>
@@ -150,7 +164,7 @@
150164
</Grid>
151165
</Button.Content>
152166
</Button>
153-
<Button Command="{Binding RefreshCommand}" Style="{StaticResource ImageWithTextButton}" Margin="10,0,0,0">
167+
<Button Command="{Binding RefreshCommand}" Style="{StaticResource ImageWithTextButton}" IsEnabled="{Binding IsRefreshing, Converter={StaticResource BooleanReverseConverter}}" Margin="10,0,0,0">
154168
<Button.Content>
155169
<Grid>
156170
<Grid.ColumnDefinitions>

0 commit comments

Comments
 (0)