Activation service
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.Common
|
||||
{
|
||||
public interface IInitializableService
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
Task Initialize();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public interface IInitializableService<T>
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
Task Initialize(T arg);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -4,11 +4,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Application
|
||||
{
|
||||
public interface IApplicationDataService
|
||||
public interface IApplicationDataService : IInitializableService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
@@ -73,6 +74,8 @@ namespace VDownload.Services.Data.Application
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize() => await Load();
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
if (File.Exists(_filePath))
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Authentication
|
||||
{
|
||||
public interface IAuthenticationDataService
|
||||
public interface IAuthenticationDataService : IInitializableService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
@@ -70,6 +71,8 @@ namespace VDownload.Services.Data.Authentication
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize() => await Load();
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
Data = null;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Settings
|
||||
{
|
||||
public interface ISettingsService
|
||||
public interface ISettingsService : IInitializableService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
@@ -73,6 +74,8 @@ namespace VDownload.Services.Data.Settings
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize() => await Load();
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
if (File.Exists(_filePath))
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\VDownload.Models\VDownload.Models.csproj" />
|
||||
<ProjectReference Include="..\..\..\VDownload.Sources\VDownload.Sources.Twitch\VDownload.Sources.Twitch.Settings\VDownload.Sources.Twitch.Settings.csproj" />
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using VDownload.Services.Data.Configuration;
|
||||
|
||||
namespace VDownload.Services.Data.Subscriptions
|
||||
{
|
||||
public interface ISubscriptionsDataService
|
||||
public interface ISubscriptionsDataService : IInitializableService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
@@ -72,6 +74,8 @@ namespace VDownload.Services.Data.Subscriptions
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize() => await Load();
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
if (File.Exists(_filePath))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\VDownload.Models\VDownload.Models.csproj" />
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -6,22 +6,13 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using VDownload.Services.UI.StringResources;
|
||||
|
||||
namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
public interface IDialogsService
|
||||
public interface IDialogsService : IInitializableService<XamlRoot>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
XamlRoot DefaultRoot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
Task ShowClose(string title, string message);
|
||||
Task<DialogResult> ShowDouble(string title, string message, string primaryButtonText, string secondaryButtonText);
|
||||
Task ShowOk(string title, string message);
|
||||
@@ -30,8 +21,6 @@ namespace VDownload.Services.UI.Dialogs
|
||||
Task<DialogResult> ShowTriple(string title, string message, string primaryButtonText, string secondaryButtonText, string cancelButtonText);
|
||||
Task<DialogResultYesNo> ShowYesNo(string title, string message);
|
||||
Task<DialogResultYesNoCancel> ShowYesNoCancel(string title, string message);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +43,7 @@ namespace VDownload.Services.UI.Dialogs
|
||||
protected string _yesString;
|
||||
protected string _noString;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public XamlRoot DefaultRoot { get; set; }
|
||||
protected XamlRoot _root;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -84,6 +67,8 @@ namespace VDownload.Services.UI.Dialogs
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize(XamlRoot arg) => await Task.Run(() => _root = arg);
|
||||
|
||||
public async Task ShowOk(string title, string message) => await ShowSingle(title, message, _okString);
|
||||
public async Task ShowClose(string title, string message) => await ShowSingle(title, message, _closeString);
|
||||
public async Task ShowSingle(string title, string message, string buttonText)
|
||||
@@ -138,7 +123,7 @@ namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
Title = title,
|
||||
Content = message,
|
||||
XamlRoot = DefaultRoot
|
||||
XamlRoot = _root
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.UI.StringResources\VDownload.Services.UI.StringResources.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -4,12 +4,13 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using Windows.Media.Core;
|
||||
|
||||
namespace VDownload.Services.UI.DictionaryResources
|
||||
{
|
||||
public interface IDictionaryResourcesService
|
||||
public interface IDictionaryResourcesService : IInitializableService<ResourceDictionary>
|
||||
{
|
||||
ResourceDictionary Resources { get; set; }
|
||||
T Get<T>(string key);
|
||||
}
|
||||
|
||||
@@ -17,17 +18,9 @@ namespace VDownload.Services.UI.DictionaryResources
|
||||
|
||||
public class DictionaryResourcesService : IDictionaryResourcesService
|
||||
{
|
||||
#region PROPERTIES
|
||||
#region FIELDS
|
||||
|
||||
public ResourceDictionary Resources { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public DictionaryResourcesService() { }
|
||||
protected ResourceDictionary _resources;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -35,9 +28,11 @@ namespace VDownload.Services.UI.DictionaryResources
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize(ResourceDictionary arg) => await Task.Run(() => _resources = arg);
|
||||
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
Resources.TryGetValue(key, out object value);
|
||||
_resources.TryGetValue(key, out object value);
|
||||
if (value is not null && value is T cast)
|
||||
{
|
||||
return cast;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
<ProjectReference Include="..\VDownload.Services.UI.Notifications\VDownload.Services.UI.Notifications.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.Windows.AppNotifications;
|
||||
using Microsoft.Windows.AppNotifications.Builder;
|
||||
using SimpleToolkit.UI.WinUI.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
|
||||
namespace VDownload.Services.UI.Notifications
|
||||
{
|
||||
public interface INotificationsService
|
||||
public interface INotificationsService : IInitializableService<Window>
|
||||
{
|
||||
void Initialize(Action notificationInvoked);
|
||||
void SendNotification(string title, IEnumerable<string> message);
|
||||
}
|
||||
|
||||
@@ -19,7 +21,15 @@ namespace VDownload.Services.UI.Notifications
|
||||
|
||||
public class NotificationsService : INotificationsService
|
||||
{
|
||||
#region CONSTRCUTORS
|
||||
#region FIELDS
|
||||
|
||||
protected Window _window;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
~NotificationsService()
|
||||
{
|
||||
@@ -32,12 +42,14 @@ namespace VDownload.Services.UI.Notifications
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public void Initialize(Action notificationInvoked)
|
||||
public async Task Initialize(Window window) => await Task.Run(() =>
|
||||
{
|
||||
AppNotificationManager.Default.NotificationInvoked += (obj, args) => notificationInvoked.Invoke();
|
||||
_window = window;
|
||||
|
||||
AppNotificationManager.Default.NotificationInvoked += NotificationInvoked;
|
||||
|
||||
AppNotificationManager.Default.Register();
|
||||
}
|
||||
});
|
||||
|
||||
public void SendNotification(string title, IEnumerable<string> message)
|
||||
{
|
||||
@@ -54,5 +66,13 @@ namespace VDownload.Services.UI.Notifications
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
private void NotificationInvoked(AppNotificationManager sender, AppNotificationActivatedEventArgs args) => WindowHelper.ShowWindow(_window);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,10 @@
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||
<PackageReference Include="SimpleToolkit.UI.WinUI.Helpers" Version="1.7.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -3,24 +3,15 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Services.Common;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace VDownload.Services.UI.StoragePicker
|
||||
{
|
||||
public interface IStoragePickerService
|
||||
public interface IStoragePickerService : IInitializableService<Window>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
Window DefaultRoot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
Task<string?> OpenDirectory();
|
||||
Task<string?> OpenDirectory(StoragePickerStartLocation startLocation);
|
||||
Task<IEnumerable<string>> OpenMultipleFiles();
|
||||
@@ -33,17 +24,15 @@ namespace VDownload.Services.UI.StoragePicker
|
||||
Task<string?> OpenSingleFile(string[] fileTypes, StoragePickerStartLocation startLocation);
|
||||
Task<string?> SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType);
|
||||
Task<string?> SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType, StoragePickerStartLocation startLocation);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class StoragePickerService : IStoragePickerService
|
||||
{
|
||||
#region PROPERTIES
|
||||
#region FIELDS
|
||||
|
||||
public Window DefaultRoot { get; set; }
|
||||
protected Window _root;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -51,6 +40,8 @@ namespace VDownload.Services.UI.StoragePicker
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Initialize(Window arg) => await Task.Run(() => _root = arg);
|
||||
|
||||
public async Task<string?> OpenDirectory() => await OpenDirectory(StoragePickerStartLocation.Unspecified);
|
||||
public async Task<string?> OpenDirectory(StoragePickerStartLocation startLocation)
|
||||
{
|
||||
@@ -111,7 +102,7 @@ namespace VDownload.Services.UI.StoragePicker
|
||||
|
||||
protected void InitializePicker(object picker)
|
||||
{
|
||||
var hwnd = WindowNative.GetWindowHandle(DefaultRoot);
|
||||
var hwnd = WindowNative.GetWindowHandle(_root);
|
||||
InitializeWithWindow.Initialize(picker, hwnd);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,8 @@
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VDownload.Services.Common\VDownload.Services.Common.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user