Skip to content

Commit cad6d59

Browse files
committed
Update to the latest Nuget packages
1 parent a08af23 commit cad6d59

18 files changed

+377
-409
lines changed

src/Core/Models/FileTransferParameters.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ public int TransferredBytes
5252
}
5353
}
5454

55-
partial void OnTotalBytesChanged(int value)
56-
{
57-
UpdateProgressPercentage();
58-
}
59-
6055
private void UpdateProgressPercentage()
6156
{
6257
if (TotalBytes <= 0)
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using CommunityToolkit.Mvvm.ComponentModel;
22

3-
namespace OSDPBench.Core.ViewModels.Windows
4-
{
5-
/// <summary>
6-
/// Represents the view model for the main window of the application.
7-
/// </summary>
8-
public class MainWindowViewModel : ObservableObject;
9-
}
3+
namespace OSDPBench.Core.ViewModels.Windows;
4+
5+
/// <summary>
6+
/// Represents the view model for the main window of the application.
7+
/// </summary>
8+
public class MainWindowViewModel : ObservableObject;

src/UI/Windows/App.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using OSDPBench.Windows.Views.Pages;
1010
using OSDPBench.Windows.Views.Windows;
1111
using Wpf.Ui;
12+
using Wpf.Ui.Abstractions;
1213

1314
namespace OSDPBench.Windows;
1415

@@ -28,9 +29,6 @@ public partial class App
2829
{
2930
services.AddHostedService<ApplicationHostService>();
3031

31-
// Page resolver service
32-
services.AddSingleton<IPageService, PageService>();
33-
3432
// Theme manipulation
3533
services.AddSingleton<IThemeService, ThemeService>();
3634

@@ -39,6 +37,7 @@ public partial class App
3937

4038
// Service containing navigation, same as INavigationWindow... but without window
4139
services.AddSingleton<INavigationService, NavigationService>();
40+
services.AddSingleton<INavigationViewPageProvider, PageService>();
4241

4342
// Main window with navigation
4443
services.AddSingleton<INavigationWindow, MainWindow>();
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
using System;
21
using System.Globalization;
32
using System.Windows;
43
using System.Windows.Data;
54

6-
namespace OSDPBench.Windows.Converters
5+
namespace OSDPBench.Windows.Converters;
6+
7+
public class BooleanToVisibilityConverter : IValueConverter
78
{
8-
public class BooleanToVisibilityConverter : IValueConverter
9+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
910
{
10-
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
11+
if (value is bool booleanValue)
1112
{
12-
if (value is bool booleanValue)
13-
{
14-
// Handle the "Invert" parameter
15-
var isInverted = parameter != null && parameter.ToString()!.Equals("Invert", StringComparison.OrdinalIgnoreCase);
16-
17-
// Return the inverted or non-inverted result
18-
return isInverted ? booleanValue ? Visibility.Collapsed : Visibility.Visible :
19-
booleanValue ? Visibility.Visible : Visibility.Collapsed;
20-
}
13+
// Handle the "Invert" parameter
14+
var isInverted = parameter != null && parameter.ToString()!.Equals("Invert", StringComparison.OrdinalIgnoreCase);
2115

22-
return Visibility.Collapsed; // Default
16+
// Return the inverted or non-inverted result
17+
return isInverted ? booleanValue ? Visibility.Collapsed : Visibility.Visible :
18+
booleanValue ? Visibility.Visible : Visibility.Collapsed;
2319
}
2420

25-
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
26-
{
27-
if (value is Visibility visibilityValue)
28-
{
29-
var isInverted = parameter != null && parameter.ToString()!.Equals("Invert", StringComparison.OrdinalIgnoreCase);
21+
return Visibility.Collapsed; // Default
22+
}
3023

31-
// Convert visibility back to boolean
32-
return isInverted ? visibilityValue == Visibility.Collapsed : visibilityValue == Visibility.Visible;
33-
}
24+
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
25+
{
26+
if (value is Visibility visibilityValue)
27+
{
28+
var isInverted = parameter != null && parameter.ToString()!.Equals("Invert", StringComparison.OrdinalIgnoreCase);
3429

35-
return false; // Default
30+
// Convert visibility back to boolean
31+
return isInverted ? visibilityValue == Visibility.Collapsed : visibilityValue == Visibility.Visible;
3632
}
33+
34+
return false; // Default
3735
}
3836
}

src/UI/Windows/Converters/NullToVisibilityConverter.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
using System.Windows;
33
using System.Windows.Data;
44

5-
namespace OSDPBench.Windows.Converters
5+
namespace OSDPBench.Windows.Converters;
6+
7+
public class NullToVisibilityConverter : IValueConverter
68
{
7-
public class NullToVisibilityConverter : IValueConverter
9+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
810
{
9-
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
10-
{
11-
bool isVisible = value != null;
12-
if (parameter != null && bool.Parse(parameter.ToString() ?? "False")) isVisible = !isVisible;
13-
return isVisible ? Visibility.Visible : Visibility.Collapsed;
14-
}
11+
bool isVisible = value != null;
12+
if (parameter != null && bool.Parse(parameter.ToString() ?? "False")) isVisible = !isVisible;
13+
return isVisible ? Visibility.Visible : Visibility.Collapsed;
14+
}
1515

16-
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
17-
{
18-
throw new NotImplementedException();
19-
}
16+
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
17+
{
18+
throw new NotImplementedException();
2019
}
21-
}
20+
}

src/UI/Windows/Converters/StringToVisibilityConverter.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
using System.Windows;
33
using System.Windows.Data;
44

5-
namespace OSDPBench.Windows.Converters
5+
namespace OSDPBench.Windows.Converters;
6+
7+
public class StringToVisibilityConverter : IValueConverter
68
{
7-
public class StringToVisibilityConverter : IValueConverter
9+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
810
{
9-
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
10-
{
11-
return value?.ToString() == parameter?.ToString() ? Visibility.Visible : Visibility.Collapsed;
12-
}
11+
return value?.ToString() == parameter?.ToString() ? Visibility.Visible : Visibility.Collapsed;
12+
}
1313

14-
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
15-
{
16-
throw new NotImplementedException();
17-
}
14+
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
15+
{
16+
throw new NotImplementedException();
1817
}
19-
}
18+
}

src/UI/Windows/Services/ApplicationHostService.cs

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,48 @@
33
using OSDPBench.Windows.Views.Windows;
44
using Wpf.Ui;
55

6-
namespace OSDPBench.Windows.Services
6+
namespace OSDPBench.Windows.Services;
7+
8+
/// <summary>
9+
/// Managed host of the application.
10+
/// </summary>
11+
public class ApplicationHostService(IServiceProvider serviceProvider) : IHostedService
712
{
13+
private INavigationWindow? _navigationWindow;
14+
815
/// <summary>
9-
/// Managed host of the application.
16+
/// Triggered when the application host is ready to start the service.
1017
/// </summary>
11-
public class ApplicationHostService(IServiceProvider serviceProvider) : IHostedService
18+
/// <param name="cancellationToken">Indicates that the start process has been aborted.</param>
19+
public async Task StartAsync(CancellationToken cancellationToken)
1220
{
13-
private INavigationWindow? _navigationWindow;
14-
15-
/// <summary>
16-
/// Triggered when the application host is ready to start the service.
17-
/// </summary>
18-
/// <param name="cancellationToken">Indicates that the start process has been aborted.</param>
19-
public async Task StartAsync(CancellationToken cancellationToken)
20-
{
21-
await HandleActivationAsync();
22-
}
21+
await HandleActivationAsync();
22+
}
2323

24-
/// <summary>
25-
/// Triggered when the application host is performing a graceful shutdown.
26-
/// </summary>
27-
/// <param name="cancellationToken">Indicates that the shutdown process should no longer be graceful.</param>
28-
public async Task StopAsync(CancellationToken cancellationToken)
29-
{
30-
await Task.CompletedTask;
31-
}
24+
/// <summary>
25+
/// Triggered when the application host is performing a graceful shutdown.
26+
/// </summary>
27+
/// <param name="cancellationToken">Indicates that the shutdown process should no longer be graceful.</param>
28+
public async Task StopAsync(CancellationToken cancellationToken)
29+
{
30+
await Task.CompletedTask;
31+
}
3232

33-
/// <summary>
34-
/// Creates main window during activation.
35-
/// </summary>
36-
private async Task HandleActivationAsync()
33+
/// <summary>
34+
/// Creates main window during activation.
35+
/// </summary>
36+
private async Task HandleActivationAsync()
37+
{
38+
if (!Application.Current.Windows.OfType<MainWindow>().Any())
3739
{
38-
if (!Application.Current.Windows.OfType<MainWindow>().Any())
39-
{
40-
_navigationWindow = (
41-
serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow
42-
)!;
43-
_navigationWindow.ShowWindow();
40+
_navigationWindow = (
41+
serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow
42+
)!;
43+
_navigationWindow.ShowWindow();
4444

45-
_navigationWindow.Navigate(typeof(Views.Pages.ConnectPage));
46-
}
47-
48-
await Task.CompletedTask;
45+
_navigationWindow.Navigate(typeof(Views.Pages.ConnectPage));
4946
}
47+
48+
await Task.CompletedTask;
5049
}
51-
}
50+
}
Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,32 @@
11
using System.Windows;
2-
using Wpf.Ui;
2+
using Wpf.Ui.Abstractions;
33

4-
namespace OSDPBench.Windows.Services
4+
namespace OSDPBench.Windows.Services;
5+
6+
/// <summary>
7+
/// Service that provides pages for navigation.
8+
/// </summary>
9+
public class PageService : INavigationViewPageProvider
510
{
611
/// <summary>
7-
/// Service that provides pages for navigation.
12+
/// Service which provides the instances of pages.
813
/// </summary>
9-
public class PageService : IPageService
10-
{
11-
/// <summary>
12-
/// Service which provides the instances of pages.
13-
/// </summary>
14-
private readonly IServiceProvider _serviceProvider;
15-
16-
/// <summary>
17-
/// Creates new instance and attaches the <see cref="IServiceProvider"/>.
18-
/// </summary>
19-
public PageService(IServiceProvider serviceProvider)
20-
{
21-
_serviceProvider = serviceProvider;
22-
}
14+
private readonly IServiceProvider _serviceProvider;
2315

24-
/// <inheritdoc />
25-
public T? GetPage<T>()
26-
where T : class
27-
{
28-
if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T)))
29-
throw new InvalidOperationException("The page should be a WPF control.");
30-
31-
return (T?)_serviceProvider.GetService(typeof(T));
32-
}
16+
/// <summary>
17+
/// Creates new instance and attaches the <see cref="IServiceProvider"/>.
18+
/// </summary>
19+
public PageService(IServiceProvider serviceProvider)
20+
{
21+
_serviceProvider = serviceProvider;
22+
}
3323

34-
/// <inheritdoc />
35-
public FrameworkElement? GetPage(Type pageType)
36-
{
37-
if (!typeof(FrameworkElement).IsAssignableFrom(pageType))
38-
throw new InvalidOperationException("The page should be a WPF control.");
24+
/// <inheritdoc />
25+
public object? GetPage(Type pageType)
26+
{
27+
if (!typeof(FrameworkElement).IsAssignableFrom(pageType))
28+
throw new InvalidOperationException("The page should be a WPF control.");
3929

40-
return _serviceProvider.GetService(pageType) as FrameworkElement;
41-
}
30+
return _serviceProvider.GetService(pageType) as FrameworkElement;
4231
}
43-
}
32+
}

0 commit comments

Comments
 (0)