Skip to content

Commit bd93b02

Browse files
committed
Fix: Reload animation fixed
1 parent d878310 commit bd93b02

File tree

7 files changed

+135
-82
lines changed

7 files changed

+135
-82
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Windows;
3+
using System.Windows.Media;
4+
using System.Windows.Media.Animation;
5+
using System.Windows.Shapes;
6+
7+
namespace NETworkManager.Utilities.WPF;
8+
9+
public static class ReloadAnimationHelper
10+
{
11+
public static readonly DependencyProperty IsReloadingProperty =
12+
DependencyProperty.RegisterAttached(
13+
"IsReloading",
14+
typeof(bool),
15+
typeof(ReloadAnimationHelper),
16+
new PropertyMetadata(false, OnIsReloadingChanged));
17+
18+
public static void SetIsReloading(UIElement element, bool value) =>
19+
element.SetValue(IsReloadingProperty, value);
20+
21+
public static bool GetIsReloading(UIElement element) =>
22+
(bool)element.GetValue(IsReloadingProperty);
23+
24+
private static void OnIsReloadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
25+
{
26+
if (d is Rectangle rect && e.NewValue is bool isReloading)
27+
{
28+
if (isReloading)
29+
{
30+
var rotate = new RotateTransform { CenterX = 12, CenterY = 12 };
31+
rect.RenderTransform = rotate;
32+
33+
var animation = new DoubleAnimation(0, 720, new Duration(TimeSpan.FromSeconds(2)));
34+
rotate.BeginAnimation(RotateTransform.AngleProperty, animation);
35+
}
36+
else
37+
{
38+
rect.RenderTransform = null;
39+
}
40+
}
41+
}
42+
}

Source/NETworkManager/Resources/Styles/RectangleStyles.xaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,6 @@
6464
<Setter Property="ToolTipService.ShowDuration" Value="600000" />
6565
</Style>
6666

67-
<Style x:Key="ReloadAnimation" TargetType="{x:Type Rectangle}">
68-
<Setter Property="Height" Value="24" />
69-
<Setter Property="RenderTransform">
70-
<Setter.Value>
71-
<RotateTransform CenterX="12" CenterY="12" />
72-
</Setter.Value>
73-
</Setter>
74-
<Style.Triggers>
75-
<Trigger Property="IsEnabled" Value="False">
76-
<Trigger.EnterActions>
77-
<BeginStoryboard>
78-
<Storyboard>
79-
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle" From="0" To="720"
80-
Duration="0:0:2" />
81-
</Storyboard>
82-
</BeginStoryboard>
83-
</Trigger.EnterActions>
84-
</Trigger>
85-
</Style.Triggers>
86-
</Style>
87-
8867
<!-- @FutureMe Don't touch this! Converter "ConnectionStateToRectangleStyleConverter" returns to the x:Key -->
8968
<Style x:Key="CheckRectangle" TargetType="{x:Type Rectangle}">
9069
<Style.Resources>

Source/NETworkManager/ViewModels/WiFiViewModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ public WiFiViewModel(IDialogCoordinator instance)
473473
{
474474
if (string.IsNullOrEmpty(Search))
475475
return true;
476-
476+
477477
if (o is not WiFiNetworkInfo info)
478478
return false;
479479

@@ -528,7 +528,12 @@ private void LoadSettings()
528528

529529
#region ICommands & Actions
530530

531-
public ICommand ReloadAdaptersCommand => new RelayCommand(_ => ReloadAdapterAction());
531+
public ICommand ReloadAdaptersCommand => new RelayCommand(_ => ReloadAdapterAction(), ReloadAdapter_CanExecute);
532+
533+
private bool ReloadAdapter_CanExecute(object obj)
534+
{
535+
return !IsAdaptersLoading && !IsNetworksLoading && !IsBackgroundSearchRunning && !AutoRefreshEnabled && !IsConnecting;
536+
}
532537

533538
private void ReloadAdapterAction()
534539
{
@@ -540,7 +545,7 @@ private void ReloadAdapterAction()
540545

541546
private bool ScanNetworks_CanExecute(object obj)
542547
{
543-
return !IsAdaptersLoading && !IsNetworksLoading && !IsBackgroundSearchRunning && !IsConnecting;
548+
return !IsAdaptersLoading && !IsNetworksLoading && !IsBackgroundSearchRunning && !AutoRefreshEnabled && !IsConnecting;
544549
}
545550

546551
private async Task ScanNetworksAction()

Source/NETworkManager/Views/ARPTableView.xaml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,67 @@
3737
<RowDefinition Height="10" />
3838
<RowDefinition Height="Auto" />
3939
</Grid.RowDefinitions>
40-
<TextBox Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right"
41-
Width="250" Text="{Binding Path=Search, UpdateSourceTrigger=PropertyChanged}"
42-
Style="{StaticResource ResourceKey=SearchTextBox}" />
40+
<StackPanel Grid.Column="0" Grid.Row="0"
41+
Orientation="Horizontal"
42+
VerticalAlignment="Center"
43+
HorizontalAlignment="Right" >
44+
<CheckBox IsChecked="{Binding AutoRefreshEnabled}" Content="{x:Static localization:Strings.AutomaticallyUpdateEvery}" Margin="0,0,10,0" />
45+
<ComboBox ItemsSource="{Binding AutoRefreshTimes}" SelectedItem="{Binding SelectedAutoRefreshTime}" MinWidth="150" Margin="0,0,10,0">
46+
<ComboBox.ItemTemplate>
47+
<DataTemplate DataType="utilities:AutoRefreshTimeInfo">
48+
<TextBlock>
49+
<TextBlock.Text>
50+
<MultiBinding StringFormat="{}{0} {1}">
51+
<Binding Path="Value" />
52+
<Binding Path="TimeUnit"
53+
Converter="{StaticResource TimeUnitToStringConverter}" />
54+
</MultiBinding>
55+
</TextBlock.Text>
56+
</TextBlock>
57+
</DataTemplate>
58+
</ComboBox.ItemTemplate>
59+
</ComboBox>
60+
61+
<Button Command="{Binding RefreshCommand}" Margin="0,0,10,0">
62+
<Button.Style>
63+
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource ImageWithTextButton}">
64+
<Style.Triggers>
65+
<DataTrigger Binding="{Binding IsRefreshing}" Value="True">
66+
<Setter Property="IsEnabled" Value="False" />
67+
</DataTrigger>
68+
<DataTrigger Binding="{Binding AutoRefreshEnabled}" Value="True">
69+
<Setter Property="IsEnabled" Value="False" />
70+
</DataTrigger>
71+
</Style.Triggers>
72+
</Style>
73+
</Button.Style>
74+
<Grid>
75+
<Grid.ColumnDefinitions>
76+
<ColumnDefinition Width="Auto" />
77+
<ColumnDefinition Width="*" />
78+
</Grid.ColumnDefinitions>
79+
<Rectangle Style="{StaticResource ButtonWithImageRectangle}">
80+
<Rectangle.OpacityMask>
81+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Refresh}" />
82+
</Rectangle.OpacityMask>
83+
</Rectangle>
84+
<TextBlock Grid.Column="1" Text="{x:Static localization:Strings.Refresh}"
85+
Style="{StaticResource ButtonWithImageTextBlock}" />
86+
</Grid>
87+
</Button>
88+
89+
90+
91+
<TextBox Width="250" Text="{Binding Path=Search, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ResourceKey=SearchTextBox}" />
92+
</StackPanel>
93+
94+
95+
96+
97+
98+
99+
100+
43101
<controls:MultiSelectDataGrid x:Name="DataGridArpTable"
44102
Grid.Column="0" Grid.Row="2"
45103
ItemsSource="{Binding ResultsView}"

Source/NETworkManager/Views/NetworkInterfaceView.xaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
xmlns:controls="clr-namespace:NETworkManager.Controls"
1717
xmlns:liveChart="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
1818
xmlns:profiles="clr-namespace:NETworkManager.Profiles;assembly=NETworkManager.Profiles"
19+
xmlns:wpfHelper="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
1920
dialog:DialogParticipation.Register="{Binding}"
2021
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:NetworkInterfaceViewModel}">
2122
<UserControl.InputBindings>
@@ -160,13 +161,13 @@
160161
Style="{StaticResource CleanButton}"
161162
IsEnabled="{Binding IsNetworkInterfaceLoading, Converter={StaticResource BooleanReverseConverter}}"
162163
Margin="10,0,0,0">
163-
<Rectangle Width="24" Height="24">
164+
<Rectangle Width="24" Height="24"
165+
wpfHelper:ReloadAnimationHelper.IsReloading="{Binding IsNetworkInterfaceLoading}">
164166
<Rectangle.OpacityMask>
165167
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Refresh}" />
166168
</Rectangle.OpacityMask>
167169
<Rectangle.Style>
168-
<Style TargetType="{x:Type Rectangle}"
169-
BasedOn="{StaticResource ReloadAnimation}">
170+
<Style TargetType="{x:Type Rectangle}">
170171
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
171172
<Style.Triggers>
172173
<DataTrigger
@@ -581,13 +582,13 @@
581582
Style="{StaticResource CleanButton}"
582583
IsEnabled="{Binding IsNetworkInterfaceLoading, Converter={StaticResource BooleanReverseConverter}}"
583584
Margin="10,0,0,0">
584-
<Rectangle Width="24" Height="24">
585+
<Rectangle Width="24" Height="24"
586+
wpfHelper:ReloadAnimationHelper.IsReloading="{Binding IsNetworkInterfaceLoading}">
585587
<Rectangle.OpacityMask>
586588
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Refresh}" />
587589
</Rectangle.OpacityMask>
588590
<Rectangle.Style>
589-
<Style TargetType="{x:Type Rectangle}"
590-
BasedOn="{StaticResource ReloadAnimation}">
591+
<Style TargetType="{x:Type Rectangle}">
591592
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
592593
<Style.Triggers>
593594
<DataTrigger
@@ -820,14 +821,14 @@
820821
Style="{StaticResource CleanButton}"
821822
IsEnabled="{Binding IsNetworkInterfaceLoading, Converter={StaticResource BooleanReverseConverter}}"
822823
Margin="10,0,0,0">
823-
<Rectangle Width="24" Height="24">
824+
<Rectangle Width="24" Height="24"
825+
wpfHelper:ReloadAnimationHelper.IsReloading="{Binding IsNetworkInterfaceLoading}">
824826
<Rectangle.OpacityMask>
825827
<VisualBrush Stretch="Uniform"
826828
Visual="{iconPacks:Material Kind=Refresh}" />
827829
</Rectangle.OpacityMask>
828830
<Rectangle.Style>
829-
<Style TargetType="{x:Type Rectangle}"
830-
BasedOn="{StaticResource ReloadAnimation}">
831+
<Style TargetType="{x:Type Rectangle}">
831832
<Setter Property="Fill"
832833
Value="{DynamicResource MahApps.Brushes.Gray3}" />
833834
<Style.Triggers>

Source/NETworkManager/Views/WiFiView.xaml

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
xmlns:controls2="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
1515
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
1616
xmlns:utilities="clr-namespace:NETworkManager.Utilities;assembly=NETworkManager.Utilities"
17+
xmlns:wpfHelper="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
1718
dialogs:DialogParticipation.Register="{Binding}"
1819
mc:Ignorable="d"
1920
d:DataContext="{d:DesignInstance viewModels:WiFiViewModel}">
@@ -168,37 +169,17 @@
168169
<Button Grid.Column="1" Grid.Row="0"
169170
Width="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualHeight}"
170171
Height="{Binding ElementName=ComboBoxAdapters, Path=ActualHeight}"
171-
Command="{Binding Path=ReloadAdaptersCommand}" Margin="10,0,0,0">
172-
<Button.Style>
173-
<Style TargetType="{x:Type TypeName=Button}"
174-
BasedOn="{StaticResource ResourceKey=CleanButton}">
175-
<Style.Triggers>
176-
<DataTrigger Binding="{Binding Path=IsNetworksLoading}"
177-
Value="True">
178-
<Setter Property="IsEnabled" Value="False" />
179-
</DataTrigger>
180-
<DataTrigger Binding="{Binding Path=IsBackgroundSearchRunning}"
181-
Value="True">
182-
<Setter Property="IsEnabled" Value="False" />
183-
</DataTrigger>
184-
<DataTrigger Binding="{Binding Path=AutoRefreshEnabled}"
185-
Value="True">
186-
<Setter Property="IsEnabled" Value="False" />
187-
</DataTrigger>
188-
<DataTrigger Binding="{Binding Path=IsConnecting}" Value="True">
189-
<Setter Property="IsEnabled" Value="False" />
190-
</DataTrigger>
191-
</Style.Triggers>
192-
</Style>
193-
</Button.Style>
194-
<Rectangle Width="24" Height="24">
172+
Command="{Binding Path=ReloadAdaptersCommand}"
173+
Style="{StaticResource CleanButton}"
174+
Margin="10,0,0,0">
175+
<Rectangle Width="24" Height="24"
176+
wpfHelper:ReloadAnimationHelper.IsReloading="{Binding IsAdaptersLoading}">
195177
<Rectangle.OpacityMask>
196178
<VisualBrush Stretch="Uniform"
197179
Visual="{iconPacks:Material Kind=Refresh}" />
198180
</Rectangle.OpacityMask>
199181
<Rectangle.Style>
200-
<Style TargetType="{x:Type TypeName=Rectangle}"
201-
BasedOn="{StaticResource ResourceKey=ReloadAnimation}">
182+
<Style TargetType="{x:Type TypeName=Rectangle}">
202183
<Setter Property="Fill"
203184
Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray3}" />
204185
<Style.Triggers>
@@ -843,26 +824,9 @@
843824
</ComboBox.ItemTemplate>
844825
</ComboBox>
845826
</WrapPanel>
846-
<Button Grid.Column="4" Grid.Row="0" Command="{Binding Path=ScanNetworksCommand}">
847-
<Button.Style>
848-
<Style TargetType="{x:Type TypeName=Button}"
849-
BasedOn="{StaticResource ResourceKey=ImageWithTextButton}">
850-
<Style.Triggers>
851-
<DataTrigger Binding="{Binding Path=IsNetworksLoading}" Value="True">
852-
<Setter Property="IsEnabled" Value="False" />
853-
</DataTrigger>
854-
<DataTrigger Binding="{Binding Path=IsBackgroundSearchRunning}" Value="True">
855-
<Setter Property="IsEnabled" Value="False" />
856-
</DataTrigger>
857-
<DataTrigger Binding="{Binding Path=AutoRefreshEnabled}" Value="True">
858-
<Setter Property="IsEnabled" Value="False" />
859-
</DataTrigger>
860-
<DataTrigger Binding="{Binding Path=IsConnecting}" Value="True">
861-
<Setter Property="IsEnabled" Value="False" />
862-
</DataTrigger>
863-
</Style.Triggers>
864-
</Style>
865-
</Button.Style>
827+
<Button Grid.Column="4" Grid.Row="0"
828+
Command="{Binding Path=ScanNetworksCommand}"
829+
Style="{StaticResource ImageWithTextButton}">
866830
<Button.Content>
867831
<Grid>
868832
<Grid.ColumnDefinitions>

Website/docs/changelog/next-release.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Release date: **xx.xx.2025**
5252

5353
- Re-select the network interface after a network change or configuration update. Thanks to [@Ghislain1](https://github.com/Ghislain1) [#3004](https://github.com/BornToBeRoot/NETworkManager/pull/3004) [#2962](https://github.com/BornToBeRoot/NETworkManager/pull/2962)
5454

55+
**WiFi**
56+
57+
- Reload animation fixed in some cases. [#3012](https://github.com/BornToBeRoot/NETworkManager/pull/3012)
58+
5559
**PowerShell**
5660

5761
- Set PowerShell console color for correct path... [#3023](https://github.com/BornToBeRoot/NETworkManager/pull/3023)

0 commit comments

Comments
 (0)