More updates.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using MangaReader.WinUI.ViewModels;
|
||||
using MangaReader.Core.Data;
|
||||
using MangaReader.WinUI.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MangaReader.WinUI;
|
||||
|
||||
@@ -22,6 +24,11 @@ public partial class App : Application
|
||||
services.AddMangaReader();
|
||||
|
||||
ServiceProvider = services.BuildServiceProvider();
|
||||
|
||||
// Ensure the database is created
|
||||
using var scope = ServiceProvider.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<MangaContext>();
|
||||
dbContext.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public App()
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.250402" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.9" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.10" />
|
||||
<PackageReference Include="SkiaSharp" Version="3.119.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -67,6 +67,9 @@
|
||||
<Page Update="Resources\Fonts.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\LibraryView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\SearchView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
||||
24
MangaReader.WinUI/ViewModels/LibraryViewModel.cs
Normal file
24
MangaReader.WinUI/ViewModels/LibraryViewModel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using MangaReader.Core.Metadata;
|
||||
using MangaReader.Core.Pipeline;
|
||||
using MangaReader.Core.Search;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MangaReader.WinUI.ViewModels;
|
||||
|
||||
public partial class LibraryViewModel : ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using MangaReader.Core.Metadata;
|
||||
using MangaReader.Core.Pipeline;
|
||||
using MangaReader.Core.Search;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
@@ -16,7 +18,10 @@ using System.Windows.Input;
|
||||
|
||||
namespace MangaReader.WinUI.ViewModels;
|
||||
|
||||
public partial class SearchViewModel(IMangaSearchCoordinator searchCoordinator) : ViewModelBase
|
||||
public partial class SearchViewModel(
|
||||
IMangaSearchCoordinator searchCoordinator,
|
||||
IMangaMetadataCoordinator metadataCoordinator,
|
||||
IMangaPipeline pipeline) : ViewModelBase
|
||||
{
|
||||
private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
|
||||
@@ -65,6 +70,7 @@ public partial class SearchViewModel(IMangaSearchCoordinator searchCoordinator)
|
||||
}
|
||||
|
||||
public ICommand SearchCommand => new AsyncRelayCommand(SearchAsync);
|
||||
//public ICommand ImportCommand => new AsyncRelayCommand(ImportAsync);
|
||||
|
||||
public async Task SearchAsync()
|
||||
{
|
||||
@@ -87,6 +93,8 @@ public partial class SearchViewModel(IMangaSearchCoordinator searchCoordinator)
|
||||
|
||||
ObservableMangaSearchResult mangaSearchResult = new()
|
||||
{
|
||||
Source = searchResult.Source,
|
||||
Url = searchResult.Url,
|
||||
Title = searchResult.Title,
|
||||
Thumbnail = searchResult.Thumbnail,
|
||||
Description = searchResult.Description,
|
||||
@@ -124,10 +132,30 @@ public partial class SearchViewModel(IMangaSearchCoordinator searchCoordinator)
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public async Task ImportAsync(ObservableMangaSearchResult searchResult, CancellationToken cancellationToken)
|
||||
{
|
||||
IMangaMetadataProvider metadataProvider = metadataCoordinator.GetProvider(searchResult.Source);
|
||||
SourceManga? sourceManga = await metadataProvider.GetMangaAsync(searchResult.Url, cancellationToken);
|
||||
|
||||
if (sourceManga == null)
|
||||
return;
|
||||
|
||||
MangaMetadataPipelineRequest request = new()
|
||||
{
|
||||
SourceName = searchResult.Source,
|
||||
SourceUrl = searchResult.Url,
|
||||
SourceManga = sourceManga,
|
||||
};
|
||||
|
||||
await pipeline.RunMetadataAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ObservableMangaSearchResult : ObservableObject
|
||||
{
|
||||
public required string Source { get; init; }
|
||||
public required string Url { get; init; }
|
||||
public string? Title { get; init; }
|
||||
public string? Description { get; init; }
|
||||
public string? Thumbnail { get; init; }
|
||||
|
||||
41
MangaReader.WinUI/Views/LibraryView.xaml
Normal file
41
MangaReader.WinUI/Views/LibraryView.xaml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<UserControl
|
||||
x:Class="MangaReader.WinUI.Views.LibraryView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:MangaReader.WinUI.Views"
|
||||
xmlns:vm="using:MangaReader.WinUI.ViewModels"
|
||||
xmlns:search="using:MangaReader.Core.Search"
|
||||
xmlns:UI="using:CommunityToolkit.WinUI"
|
||||
xmlns:Controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:Media="using:CommunityToolkit.WinUI.Media"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=LibraryViewModel}"
|
||||
d:DataContext="{d:DesignInstance Type=vm:LibraryViewModel, IsDesignTimeCreatable=True}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Padding="0" RowSpacing="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Border HorizontalAlignment="Stretch">
|
||||
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Center" Padding="10">
|
||||
<TextBlock Text="Library" Width="300"></TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!--<ScrollViewer Grid.Row="1" RenderTransformOrigin=".5,.5" Padding="50">
|
||||
<ScrollViewer.RenderTransform>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1" />
|
||||
</ScrollViewer.RenderTransform>
|
||||
<ItemsRepeater ItemsSource="{Binding SearchResults2, Mode=OneWay}" ItemTemplate="{StaticResource MangaSearchResultTemplate}">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout MinRowSpacing="50" MinColumnSpacing="50" ItemsStretch="Fill" MinItemWidth="800"></UniformGridLayout>
|
||||
</ItemsRepeater.Layout>
|
||||
</ItemsRepeater>
|
||||
</ScrollViewer>-->
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
19
MangaReader.WinUI/Views/LibraryView.xaml.cs
Normal file
19
MangaReader.WinUI/Views/LibraryView.xaml.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using MangaReader.WinUI.ViewModels;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MangaReader.WinUI.Views;
|
||||
|
||||
public sealed partial class LibraryView : UserControl
|
||||
{
|
||||
private readonly LibraryViewModel viewModel;
|
||||
|
||||
public LibraryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
viewModel = (LibraryViewModel)DataContext;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{x:Bind Title, Mode=OneTime}" FontSize="24" FontFamily="{StaticResource PoppinsSemiBold}" TextWrapping="Wrap"></TextBlock>
|
||||
<ItemsControl Grid.Row="1" ItemsSource="{x:Bind Genres, Mode=OneTime}" ItemTemplate="{StaticResource GenreTemplate}">
|
||||
@@ -43,10 +44,17 @@
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<ScrollViewer Grid.Row="3">
|
||||
<ScrollViewer Grid.Row="2">
|
||||
<TextBlock Text="{x:Bind Description}" Foreground="{StaticResource TextFillColorSecondaryBrush}" FontSize="16" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" LineHeight="22"></TextBlock>
|
||||
</ScrollViewer>
|
||||
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button
|
||||
Content="Import"
|
||||
MinWidth="100"
|
||||
Tag="{x:Bind}"
|
||||
Click="Button_Click">
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -1,12 +1,30 @@
|
||||
using MangaReader.Core.Search;
|
||||
using MangaReader.WinUI.ViewModels;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MangaReader.WinUI.Views;
|
||||
|
||||
public sealed partial class SearchView : UserControl
|
||||
{
|
||||
private readonly SearchViewModel viewModel;
|
||||
|
||||
public SearchView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
viewModel = (SearchViewModel)DataContext;
|
||||
}
|
||||
|
||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not Button button)
|
||||
return;
|
||||
|
||||
if (button.Tag is not ObservableMangaSearchResult searchResult)
|
||||
return;
|
||||
|
||||
await viewModel.ImportAsync(searchResult, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user