Skip to content

Commit feeae82

Browse files
committed
Fix: Refresh view
1 parent f81b1d6 commit feeae82

File tree

6 files changed

+123
-184
lines changed

6 files changed

+123
-184
lines changed

Source/NETworkManager/ViewModels/ARPTableViewModel.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ private bool Refresh_CanExecute(object parameter)
256256
return Application.Current.MainWindow != null &&
257257
!((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen &&
258258
!ConfigurationManager.Current.IsChildWindowOpen &&
259-
!IsRefreshing;
259+
!IsRefreshing &&
260+
!AutoRefreshEnabled;
260261
}
261262

262263
private async Task RefreshAction()
@@ -304,7 +305,7 @@ private bool DeleteEntry_CanExecute(object parameter)
304305
{
305306
return Application.Current.MainWindow != null &&
306307
!((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen &&
307-
!ConfigurationManager.Current.IsChildWindowOpen; ;
308+
!ConfigurationManager.Current.IsChildWindowOpen;
308309
}
309310

310311
private async Task DeleteEntryAction()
@@ -430,8 +431,6 @@ private async Task Refresh()
430431
{
431432
IsRefreshing = true;
432433

433-
Debug.WriteLine("Refreshing...");
434-
435434
await Task.Delay(GlobalStaticConfiguration.ApplicationUIRefreshInterval);
436435

437436
Results.Clear();

Source/NETworkManager/ViewModels/ConnectionsViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ private bool Refresh_CanExecute(object parameter)
278278
{
279279
return Application.Current.MainWindow != null &&
280280
!((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen &&
281-
!ConfigurationManager.Current.IsChildWindowOpen;
281+
!ConfigurationManager.Current.IsChildWindowOpen &&
282+
!IsRefreshing &&
283+
!AutoRefreshEnabled;
282284
}
283285

284286
private async Task RefreshAction()
@@ -345,6 +347,8 @@ private async Task Refresh()
345347
{
346348
IsRefreshing = true;
347349

350+
await Task.Delay(GlobalStaticConfiguration.ApplicationUIRefreshInterval);
351+
348352
Results.Clear();
349353

350354
(await Connection.GetActiveTcpConnectionsAsync()).ForEach(Results.Add);

Source/NETworkManager/ViewModels/ListenersViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ private bool Refresh_CanExecute(object parameter)
269269
{
270270
return Application.Current.MainWindow != null &&
271271
!((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen &&
272-
!ConfigurationManager.Current.IsChildWindowOpen;
272+
!ConfigurationManager.Current.IsChildWindowOpen &&
273+
!IsRefreshing &&
274+
!AutoRefreshEnabled;
273275
}
274276

275277
private async Task RefreshAction()
@@ -334,6 +336,8 @@ private async Task Refresh()
334336
{
335337
IsRefreshing = true;
336338

339+
await Task.Delay(GlobalStaticConfiguration.ApplicationUIRefreshInterval);
340+
337341
Results.Clear();
338342

339343
(await Listener.GetAllActiveListenersAsync()).ForEach(Results.Add);

Source/NETworkManager/Views/ARPTableView.xaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,6 @@
180180
Text="{Binding StatusMessage}"
181181
Visibility="{Binding IsStatusMessageDisplayed, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
182182
Style="{DynamicResource StatusMessageTextBlock}" Margin="0,10,0,0" />
183-
<!--
184-
<mahAppsControls:MetroProgressBar Grid.Column="0" Grid.Row="4" Margin="0,10,0,0"
185-
Foreground="{DynamicResource MahApps.Brushes.Accent}"
186-
IsIndeterminate="True">
187-
<mahAppsControls:MetroProgressBar.Style>
188-
<Style TargetType="{x:Type mahAppsControls:MetroProgressBar}">
189-
<Style.Triggers>
190-
<DataTrigger Binding="{Binding IsRefreshing}" Value="False">
191-
<Setter Property="Visibility" Value="Collapsed" />
192-
</DataTrigger>
193-
</Style.Triggers>
194-
</Style>
195-
</mahAppsControls:MetroProgressBar.Style>
196-
</mahAppsControls:MetroProgressBar>
197-
-->
198183
<Grid Grid.Column="0" Grid.Row="5">
199184
<Grid.ColumnDefinitions>
200185
<ColumnDefinition Width="Auto" />

Source/NETworkManager/Views/ConnectionsView.xaml

Lines changed: 55 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
xmlns:utilities="clr-namespace:NETworkManager.Utilities;assembly=NETworkManager.Utilities"
1313
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
1414
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
15+
xmlns:wpfHelper="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
1516
dialogs:DialogParticipation.Register="{Binding}"
1617
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:ConnectionsViewModel}">
1718
<UserControl.InputBindings>
@@ -30,16 +31,61 @@
3031
<RowDefinition Height="10" />
3132
<RowDefinition Height="*" />
3233
<RowDefinition Height="Auto" />
33-
<RowDefinition Height="Auto" />
34-
<RowDefinition Height="10" />
35-
<RowDefinition Height="Auto" />
3634
</Grid.RowDefinitions>
37-
<TextBox Grid.Column="0" Grid.Row="0"
38-
VerticalAlignment="Center"
39-
HorizontalAlignment="Right"
40-
Width="250"
41-
Text="{Binding Search, UpdateSourceTrigger=PropertyChanged}"
42-
Style="{StaticResource SearchTextBox}" />
35+
<StackPanel Grid.Column="0" Grid.Row="0"
36+
Orientation="Horizontal"
37+
VerticalAlignment="Center"
38+
HorizontalAlignment="Right">
39+
<CheckBox IsChecked="{Binding AutoRefreshEnabled}"
40+
Content="{x:Static localization:Strings.AutomaticallyUpdateEvery}"
41+
Margin="0,0,10,0" />
42+
<ComboBox ItemsSource="{Binding AutoRefreshTimes}"
43+
SelectedItem="{Binding SelectedAutoRefreshTime}"
44+
MinWidth="150"
45+
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+
<Button Command="{Binding Path=RefreshCommand}"
61+
Style="{StaticResource CleanButton}"
62+
Margin="0,0,10,0">
63+
<Rectangle Width="24" Height="24"
64+
wpfHelper:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
65+
<Rectangle.OpacityMask>
66+
<VisualBrush Stretch="Uniform"
67+
Visual="{iconPacks:Material Kind=Refresh}" />
68+
</Rectangle.OpacityMask>
69+
<Rectangle.Style>
70+
<Style TargetType="{x:Type TypeName=Rectangle}">
71+
<Setter Property="Fill"
72+
Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray3}" />
73+
<Style.Triggers>
74+
<DataTrigger
75+
Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}"
76+
Value="True">
77+
<Setter Property="Fill"
78+
Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray5}" />
79+
</DataTrigger>
80+
</Style.Triggers>
81+
</Style>
82+
</Rectangle.Style>
83+
</Rectangle>
84+
</Button>
85+
<TextBox Width="250"
86+
Text="{Binding Path=Search, UpdateSourceTrigger=PropertyChanged}"
87+
Style="{StaticResource ResourceKey=SearchTextBox}" />
88+
</StackPanel>
4389
<controls:MultiSelectDataGrid Grid.Column="0" Grid.Row="2"
4490
ItemsSource="{Binding ResultsView}"
4591
SelectedItem="{Binding SelectedResult}"
@@ -163,78 +209,6 @@
163209
Text="{Binding StatusMessage}"
164210
Visibility="{Binding IsStatusMessageDisplayed, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
165211
Style="{DynamicResource StatusMessageTextBlock}" Margin="0,10,0,0" />
166-
<mahAppsControls:MetroProgressBar Grid.Row="4" Margin="0,10,0,0"
167-
Foreground="{DynamicResource MahApps.Brushes.Accent}"
168-
IsIndeterminate="True">
169-
<mahAppsControls:MetroProgressBar.Style>
170-
<Style TargetType="{x:Type mahAppsControls:MetroProgressBar}">
171-
<Style.Triggers>
172-
<DataTrigger Binding="{Binding IsRefreshing}" Value="False">
173-
<Setter Property="Visibility" Value="Collapsed" />
174-
</DataTrigger>
175-
</Style.Triggers>
176-
</Style>
177-
</mahAppsControls:MetroProgressBar.Style>
178-
</mahAppsControls:MetroProgressBar>
179-
<Grid Grid.Column="0" Grid.Row="6">
180-
<Grid.ColumnDefinitions>
181-
<ColumnDefinition Width="Auto" />
182-
<ColumnDefinition Width="10" />
183-
<ColumnDefinition Width="*" />
184-
<ColumnDefinition Width="10" />
185-
<ColumnDefinition Width="Auto" />
186-
</Grid.ColumnDefinitions>
187-
<WrapPanel Grid.Column="2" Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center"
188-
HorizontalAlignment="Right">
189-
<CheckBox IsChecked="{Binding AutoRefreshEnabled}"
190-
Content="{x:Static localization:Strings.AutomaticallyUpdateEvery}" Margin="0,0,10,0" />
191-
<ComboBox ItemsSource="{Binding AutoRefreshTimes}"
192-
SelectedItem="{Binding SelectedAutoRefreshTime}" MinWidth="150">
193-
<ComboBox.ItemTemplate>
194-
<DataTemplate DataType="utilities:AutoRefreshTimeInfo">
195-
<TextBlock>
196-
<TextBlock.Text>
197-
<MultiBinding StringFormat="{}{0} {1}">
198-
<Binding Path="Value" />
199-
<Binding Path="TimeUnit"
200-
Converter="{StaticResource TimeUnitToStringConverter}" />
201-
</MultiBinding>
202-
</TextBlock.Text>
203-
</TextBlock>
204-
</DataTemplate>
205-
</ComboBox.ItemTemplate>
206-
</ComboBox>
207-
</WrapPanel>
208-
<Button Grid.Column="4" Grid.Row="0" Command="{Binding RefreshCommand}">
209-
<Button.Style>
210-
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource ImageWithTextButton}">
211-
<Style.Triggers>
212-
<DataTrigger Binding="{Binding IsRefreshing}" Value="True">
213-
<Setter Property="IsEnabled" Value="False" />
214-
</DataTrigger>
215-
<DataTrigger Binding="{Binding AutoRefreshEnabled}" Value="True">
216-
<Setter Property="IsEnabled" Value="False" />
217-
</DataTrigger>
218-
</Style.Triggers>
219-
</Style>
220-
</Button.Style>
221-
<Button.Content>
222-
<Grid>
223-
<Grid.ColumnDefinitions>
224-
<ColumnDefinition Width="Auto" />
225-
<ColumnDefinition Width="*" />
226-
</Grid.ColumnDefinitions>
227-
<Rectangle Style="{StaticResource ButtonWithImageRectangle}">
228-
<Rectangle.OpacityMask>
229-
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Refresh}" />
230-
</Rectangle.OpacityMask>
231-
</Rectangle>
232-
<TextBlock Grid.Column="1" Text="{x:Static localization:Strings.Refresh}"
233-
Style="{StaticResource ButtonWithImageTextBlock}" />
234-
</Grid>
235-
</Button.Content>
236-
</Button>
237-
</Grid>
238212
</Grid>
239213
</TabItem>
240214
</TabControl>

0 commit comments

Comments
 (0)