notifications fix
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -21,6 +21,19 @@ namespace VDownload.Core.Tasks
|
|||||||
{
|
{
|
||||||
public partial class DownloadTask : ObservableObject
|
public partial class DownloadTask : ObservableObject
|
||||||
{
|
{
|
||||||
|
#region ENUMS
|
||||||
|
|
||||||
|
private enum TaskResult
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
Cancellation,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region SERVICES
|
#region SERVICES
|
||||||
|
|
||||||
protected readonly IConfigurationService _configurationService;
|
protected readonly IConfigurationService _configurationService;
|
||||||
@@ -156,6 +169,8 @@ namespace VDownload.Core.Tasks
|
|||||||
$"{_stringResourcesService.NotificationsResources.Get("Author")}: {Video.Author}"
|
$"{_stringResourcesService.NotificationsResources.Get("Author")}: {Video.Author}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
string errorMessage = null;
|
||||||
|
TaskResult? endingStatus = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IProgress<double> onProgressDownloading = new Progress<double>((value) =>
|
IProgress<double> onProgressDownloading = new Progress<double>((value) =>
|
||||||
@@ -194,16 +209,12 @@ namespace VDownload.Core.Tasks
|
|||||||
await Finalizing(outputFile);
|
await Finalizing(outputFile);
|
||||||
|
|
||||||
UpdateStatusWithDispatcher(DownloadTaskStatus.EndedSuccessfully);
|
UpdateStatusWithDispatcher(DownloadTaskStatus.EndedSuccessfully);
|
||||||
|
endingStatus = TaskResult.Success;
|
||||||
if (_settingsService.Data.Common.Notifications.OnSuccessful)
|
|
||||||
{
|
|
||||||
string title = _stringResourcesService.NotificationsResources.Get("OnSuccessfulTitle");
|
|
||||||
_notificationsService.SendNotification(title, content);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
UpdateStatusWithDispatcher(DownloadTaskStatus.EndedCancelled);
|
UpdateStatusWithDispatcher(DownloadTaskStatus.EndedCancelled);
|
||||||
|
endingStatus = TaskResult.Cancellation;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -228,16 +239,30 @@ namespace VDownload.Core.Tasks
|
|||||||
|
|
||||||
UpdateErrorWithDispatcher(message);
|
UpdateErrorWithDispatcher(message);
|
||||||
UpdateStatusWithDispatcher(DownloadTaskStatus.EndedUnsuccessfully);
|
UpdateStatusWithDispatcher(DownloadTaskStatus.EndedUnsuccessfully);
|
||||||
|
endingStatus = TaskResult.Error;
|
||||||
if (_settingsService.Data.Common.Notifications.OnUnsuccessful)
|
errorMessage = message;
|
||||||
{
|
|
||||||
string title = _stringResourcesService.NotificationsResources.Get("OnSuccessfulTitle");
|
|
||||||
content.Add($"{_stringResourcesService.NotificationsResources.Get("Message")}: {ex.Message}");
|
|
||||||
_notificationsService.SendNotification(title, content);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
switch (endingStatus)
|
||||||
|
{
|
||||||
|
case TaskResult.Error:
|
||||||
|
if (_settingsService.Data.Common.Notifications.OnUnsuccessful)
|
||||||
|
{
|
||||||
|
string title = _stringResourcesService.NotificationsResources.Get("OnUnsuccessfulTitle");
|
||||||
|
content.Add($"{_stringResourcesService.NotificationsResources.Get("Message")}: {errorMessage}");
|
||||||
|
_notificationsService.SendNotification(title, content);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TaskResult.Success:
|
||||||
|
if (_settingsService.Data.Common.Notifications.OnSuccessful)
|
||||||
|
{
|
||||||
|
string title = _stringResourcesService.NotificationsResources.Get("OnSuccessfulTitle");
|
||||||
|
_notificationsService.SendNotification(title, content);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (Status != DownloadTaskStatus.EndedUnsuccessfully || _settingsService.Data.Common.Temp.DeleteOnError)
|
if (Status != DownloadTaskStatus.EndedUnsuccessfully || _settingsService.Data.Common.Temp.DeleteOnError)
|
||||||
{
|
{
|
||||||
Directory.Delete(tempDirectory, true);
|
Directory.Delete(tempDirectory, true);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
<PackageReference Include="SimpleToolkit.MVVM" Version="1.7.4" />
|
<PackageReference Include="SimpleToolkit.MVVM" Version="1.7.4" />
|
||||||
<PackageReference Include="SimpleToolkit.UI.Models" Version="1.7.4" />
|
<PackageReference Include="SimpleToolkit.UI.Models" Version="1.7.4" />
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
|
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||||
<PackageReference Include="SimpleToolkit.UI.WinUI.Behaviors" Version="1.7.4" />
|
<PackageReference Include="SimpleToolkit.UI.WinUI.Behaviors" Version="1.7.4" />
|
||||||
<PackageReference Include="SimpleToolkit.UI.WinUI.Controls" Version="1.7.4" />
|
<PackageReference Include="SimpleToolkit.UI.WinUI.Controls" Version="1.7.4" />
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Windows.AppNotifications;
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
|
using Microsoft.Windows.AppNotifications;
|
||||||
using Microsoft.Windows.AppNotifications.Builder;
|
using Microsoft.Windows.AppNotifications.Builder;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -10,6 +11,7 @@ namespace VDownload.Services.UI.Notifications
|
|||||||
{
|
{
|
||||||
public interface INotificationsService
|
public interface INotificationsService
|
||||||
{
|
{
|
||||||
|
void Initialize(Action notificationInvoked);
|
||||||
void SendNotification(string title, IEnumerable<string> message);
|
void SendNotification(string title, IEnumerable<string> message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,8 +19,26 @@ namespace VDownload.Services.UI.Notifications
|
|||||||
|
|
||||||
public class NotificationsService : INotificationsService
|
public class NotificationsService : INotificationsService
|
||||||
{
|
{
|
||||||
|
#region CONSTRCUTORS
|
||||||
|
|
||||||
|
~NotificationsService()
|
||||||
|
{
|
||||||
|
AppNotificationManager.Default.Unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public void Initialize(Action notificationInvoked)
|
||||||
|
{
|
||||||
|
AppNotificationManager.Default.NotificationInvoked += (obj, args) => notificationInvoked.Invoke();
|
||||||
|
|
||||||
|
AppNotificationManager.Default.Register();
|
||||||
|
}
|
||||||
|
|
||||||
public void SendNotification(string title, IEnumerable<string> message)
|
public void SendNotification(string title, IEnumerable<string> message)
|
||||||
{
|
{
|
||||||
AppNotificationBuilder builder = new AppNotificationBuilder();
|
AppNotificationBuilder builder = new AppNotificationBuilder();
|
||||||
@@ -27,7 +47,9 @@ namespace VDownload.Services.UI.Notifications
|
|||||||
{
|
{
|
||||||
builder.AddText(text);
|
builder.AddText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppNotification notification = builder.BuildNotification();
|
AppNotification notification = builder.BuildNotification();
|
||||||
|
|
||||||
AppNotificationManager.Default.Show(notification);
|
AppNotificationManager.Default.Show(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Configuration.Json;
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.Windows.AppNotifications;
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -39,6 +41,7 @@ using VDownload.Sources.Twitch;
|
|||||||
using VDownload.Sources.Twitch.Api;
|
using VDownload.Sources.Twitch.Api;
|
||||||
using VDownload.Sources.Twitch.Authentication;
|
using VDownload.Sources.Twitch.Authentication;
|
||||||
using Windows.Graphics.Printing;
|
using Windows.Graphics.Printing;
|
||||||
|
using Windows.UI.Notifications;
|
||||||
|
|
||||||
namespace VDownload
|
namespace VDownload
|
||||||
{
|
{
|
||||||
@@ -175,32 +178,34 @@ namespace VDownload
|
|||||||
services.AddTransient<BaseWindow>();
|
services.AddTransient<BaseWindow>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
protected async Task InitializeServices()
|
||||||
{
|
|
||||||
await InitData();
|
|
||||||
|
|
||||||
_window = _serviceProvider.GetService<BaseWindow>();
|
|
||||||
_window.RootLoaded += Window_RootLoaded;
|
|
||||||
_window.Activate();
|
|
||||||
|
|
||||||
AssignStaticProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async Task InitData()
|
|
||||||
{
|
{
|
||||||
IApplicationDataService applicationDataService = _serviceProvider.GetService<IApplicationDataService>();
|
IApplicationDataService applicationDataService = _serviceProvider.GetService<IApplicationDataService>();
|
||||||
ISettingsService settingsService = _serviceProvider.GetService<ISettingsService>();
|
ISettingsService settingsService = _serviceProvider.GetService<ISettingsService>();
|
||||||
IAuthenticationDataService authenticationDataService = _serviceProvider.GetService<IAuthenticationDataService>();
|
IAuthenticationDataService authenticationDataService = _serviceProvider.GetService<IAuthenticationDataService>();
|
||||||
ISubscriptionsDataService subscriptionsDataService = _serviceProvider.GetService<ISubscriptionsDataService>();
|
ISubscriptionsDataService subscriptionsDataService = _serviceProvider.GetService<ISubscriptionsDataService>();
|
||||||
await Task.WhenAll(applicationDataService.Load(), settingsService.Load(), authenticationDataService.Load(), subscriptionsDataService.Load());
|
Task initViewModelToViewConverterTask = Task.Run(() => ViewModelToViewConverter.ServiceProvider = _serviceProvider);
|
||||||
|
Task initStoragePickerServiceTask = Task.Run(() => _serviceProvider.GetService<IStoragePickerService>().DefaultRoot = _window);
|
||||||
|
Task initNotificationsServiceTask = Task.Run(() => _serviceProvider.GetService<INotificationsService>().Initialize(() => WindowHelper.ShowWindow(_window)));
|
||||||
|
|
||||||
|
await Task.WhenAll(
|
||||||
|
applicationDataService.Load(),
|
||||||
|
settingsService.Load(),
|
||||||
|
authenticationDataService.Load(),
|
||||||
|
subscriptionsDataService.Load(),
|
||||||
|
initStoragePickerServiceTask,
|
||||||
|
initViewModelToViewConverterTask,
|
||||||
|
initNotificationsServiceTask
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AssignStaticProperties()
|
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||||
{
|
{
|
||||||
IStoragePickerService storagePickerService = _serviceProvider.GetService<IStoragePickerService>();
|
_window = _serviceProvider.GetService<BaseWindow>();
|
||||||
storagePickerService.DefaultRoot = _window;
|
_window.RootLoaded += Window_RootLoaded;
|
||||||
|
_window.Activate();
|
||||||
|
|
||||||
ViewModelToViewConverter.ServiceProvider = _serviceProvider;
|
await InitializeServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Window_RootLoaded(object sender, EventArgs e)
|
protected void Window_RootLoaded(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||||
IgnorableNamespaces="uap rescap">
|
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
|
||||||
|
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
|
||||||
|
IgnorableNamespaces="uap rescap com desktop">
|
||||||
|
|
||||||
<Identity
|
<Identity
|
||||||
Name="VDownload"
|
Name="VDownload"
|
||||||
@@ -42,6 +44,19 @@
|
|||||||
<uap:DefaultTile Wide310x150Logo="Assets\Logo\Wide310x150Logo.png" Square71x71Logo="Assets\Logo\SmallTile.png" Square310x310Logo="Assets\Logo\LargeTile.png"/>
|
<uap:DefaultTile Wide310x150Logo="Assets\Logo\Wide310x150Logo.png" Square71x71Logo="Assets\Logo\SmallTile.png" Square310x310Logo="Assets\Logo\LargeTile.png"/>
|
||||||
<uap:SplashScreen Image="Assets\Logo\SplashScreen.png" />
|
<uap:SplashScreen Image="Assets\Logo\SplashScreen.png" />
|
||||||
</uap:VisualElements>
|
</uap:VisualElements>
|
||||||
|
<Extensions>
|
||||||
|
<desktop:Extension Category="windows.toastNotificationActivation">
|
||||||
|
<desktop:ToastNotificationActivation ToastActivatorCLSID="1e95e58c-ce3f-421a-8cee-cd3332a87109" />
|
||||||
|
</desktop:Extension>
|
||||||
|
|
||||||
|
<com:Extension Category="windows.comServer">
|
||||||
|
<com:ComServer>
|
||||||
|
<com:ExeServer Executable="App1.exe" Arguments="----AppNotificationActivated:" DisplayName="Toast activator">
|
||||||
|
<com:Class Id="1e95e58c-ce3f-421a-8cee-cd3332a87109" DisplayName="Toast activator"/>
|
||||||
|
</com:ExeServer>
|
||||||
|
</com:ComServer>
|
||||||
|
</com:Extension>
|
||||||
|
</Extensions>
|
||||||
</Application>
|
</Application>
|
||||||
</Applications>
|
</Applications>
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
||||||
<Version>0.0.0</Version>
|
<Version>0.0.0</Version>
|
||||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="Assets\BaseView\AuthenticationDark.png" />
|
<Content Remove="Assets\BaseView\AuthenticationDark.png" />
|
||||||
@@ -167,8 +168,9 @@
|
|||||||
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.240109" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||||
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||||
<PackageReference Include="SimpleToolkit.UI.WinUI.Converters" Version="1.7.4" />
|
<PackageReference Include="SimpleToolkit.UI.WinUI.Converters" Version="1.7.4" />
|
||||||
<Manifest Include="$(ApplicationManifest)" />
|
<Manifest Include="$(ApplicationManifest)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
43
VDownload/WindowHelper.cs
Normal file
43
VDownload/WindowHelper.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VDownload
|
||||||
|
{
|
||||||
|
public static partial class WindowHelper
|
||||||
|
{
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public static void ShowWindow(Window window)
|
||||||
|
{
|
||||||
|
// Bring the window to the foreground... first get the window handle...
|
||||||
|
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
||||||
|
|
||||||
|
// Restore window if minimized... requires DLL import above
|
||||||
|
ShowWindow(hwnd, 0x00000009);
|
||||||
|
|
||||||
|
// And call SetForegroundWindow... requires DLL import above
|
||||||
|
SetForegroundWindow(hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
[LibraryImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static partial bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||||
|
|
||||||
|
[LibraryImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static partial bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user