twitch vod downloading done

ffmpeg essentials

fix

Project reorganized

git lfs

ffmpeg removed

ffmpeg added
This commit is contained in:
2024-02-14 02:07:22 +01:00
Unverified
parent 91f9b645bd
commit e3ec5c3a48
264 changed files with 6239 additions and 4014 deletions

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="VDownload.Core.Views.Authentication.AuthenticationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VDownload.Core.Views.Authentication"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ctuc="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
xmlns:ct="using:CommunityToolkit.WinUI"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d"
Background="{ThemeResource ViewBackgroundColor}">
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="Loaded">
<ic:InvokeCommandAction Command="{Binding NavigationCommand}"/>
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<Grid Padding="20"
RowSpacing="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock x:Uid="/VDownload.Core.Strings/AuthenticationViewResources/Header"
Grid.Row="0"
FontSize="28"
FontWeight="SemiBold"/>
<StackPanel Grid.Row="1"
Spacing="10">
<ctc:SettingsCard Header="Twitch">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding TwitchButtonState, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="NotEqual"
Value="Loading">
<ic:ChangePropertyAction PropertyName="Description"
Value="{Binding TwitchDescription}"/>
<ic:ChangePropertyAction PropertyName="Content">
<ic:ChangePropertyAction.Value>
<Button Command="{Binding TwitchAuthenticationCommand}">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding TwitchButtonState, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="SignIn">
<ic:ChangePropertyAction x:Uid="/VDownload.Core.Strings/AuthenticationViewResources/AuthenticationButtonSignIn"
PropertyName="Content"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding TwitchButtonState, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="SignOut">
<ic:ChangePropertyAction x:Uid="/VDownload.Core.Strings/AuthenticationViewResources/AuthenticationButtonSignOut"
PropertyName="Content"/>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Button>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding TwitchButtonState, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Loading">
<ic:ChangePropertyAction x:Uid="/VDownload.Core.Strings/AuthenticationViewResources/AuthenticationDescriptionLoading"
PropertyName="Description"/>
<ic:ChangePropertyAction PropertyName="Content">
<ic:ChangePropertyAction.Value>
<ProgressRing Width="20"
Height="20"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
<ctc:SettingsCard.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{StaticResource ImageSourcesTwitch}"/>
</ctc:SettingsCard.HeaderIcon>
</ctc:SettingsCard>
</StackPanel>
</Grid>
</Page>

View File

@@ -0,0 +1,18 @@
using Microsoft.UI.Xaml.Controls;
using VDownload.Core.ViewModels.Authentication;
namespace VDownload.Core.Views.Authentication
{
public sealed partial class AuthenticationView : Page
{
#region CONSTRUCTORS
public AuthenticationView(AuthenticationViewModel viewModel)
{
this.InitializeComponent();
this.DataContext = viewModel;
}
#endregion
}
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="VDownload.Core.Views.BaseWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:cb="using:VDownload.Toolkit.UI.Behaviors"
mc:Ignorable="d">
<Window.SystemBackdrop>
<MicaBackdrop Kind="Base"/>
</Window.SystemBackdrop>
<Grid x:Name="Root"
Loaded="Root_Loaded">
<Border x:Name="AppTitleBar"
IsHitTestVisible="True"
VerticalAlignment="Top"
Height="40"
Canvas.ZIndex="1"
Margin="55,4,0,0">
<StackPanel Orientation="Horizontal">
<Image HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="{StaticResource ImageLogo}"
Width="16"
Height="16"/>
<TextBlock Text="VDownload"
VerticalAlignment="Center"
Margin="12, 0, 0, 0"
Style="{StaticResource CaptionTextBlockStyle}"/>
</StackPanel>
</Border>
<NavigationView IsTitleBarAutoPaddingEnabled="True"
IsBackButtonVisible="Collapsed"
PaneDisplayMode="LeftCompact"
Canvas.ZIndex="0"
MenuItemsSource="{Binding Items}"
FooterMenuItemsSource="{Binding FooterItems}"
SelectedItem="{Binding SelectedItem}"
Background="Transparent">
<i:Interaction.Behaviors>
<cb:EventToCommandBehavior Command="{Binding NavigateCommand}"
Event="ItemInvoked"
PassArguments="True"/>
</i:Interaction.Behaviors>
<NavigationView.Resources>
<SolidColorBrush x:Key="NavigationViewContentBackground"
Color="Transparent"/>
</NavigationView.Resources>
<NavigationView.MenuItemTemplate>
<DataTemplate>
<NavigationViewItem Content="{Binding Name}" Tag="{Binding}">
<NavigationViewItem.Icon>
<ImageIcon Source="{Binding IconSource}"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
</DataTemplate>
</NavigationView.MenuItemTemplate>
<Frame Margin="0,48,0,0"
CornerRadius="10"
Content="{Binding CurrentViewModel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ViewModelToViewConverter}}">
</Frame>
</NavigationView>
</Grid>
</Window>

View File

@@ -0,0 +1,59 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using VDownload.Core.ViewModels;
using Windows.Foundation;
using Windows.Foundation.Collections;
namespace VDownload.Core.Views
{
public sealed partial class BaseWindow : Window
{
#region PROPERTIES
public XamlRoot XamlRoot => this.Root.XamlRoot;
#endregion
#region EVENTS
public event EventHandler RootLoaded;
#endregion
#region CONSTRUCTORS
public BaseWindow(BaseViewModel viewModel)
{
this.InitializeComponent();
this.ExtendsContentIntoTitleBar = true;
this.SetTitleBar(this.AppTitleBar);
this.Root.DataContext = viewModel;
}
#endregion
#region PRIVATE METHODS
private void Root_Loaded(object sender, RoutedEventArgs e) => RootLoaded?.Invoke(this, EventArgs.Empty);
#endregion
}
}

View File

@@ -0,0 +1,397 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="VDownload.Core.Views.Home.HomeDownloadsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VDownload.Core.Views.Home"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:m="using:VDownload.Models"
xmlns:ct="using:CommunityToolkit.WinUI"
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
xmlns:ctuc="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:ctb="using:CommunityToolkit.WinUI.Behaviors"
mc:Ignorable="d"
x:Name="Root"
Background="Transparent">
<ctuc:SwitchPresenter Value="{Binding TaskListIsEmpty, Converter={StaticResource ObjectToStringConverter}}">
<ctuc:Case Value="True">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image Source="{StaticResource ImageHomeDownloadsViewNoTasks}"
Width="100"/>
<TextBlock Text="Click Video/Playlist search button to add new tasks"
Foreground="{StaticResource GreyText}"/>
</StackPanel>
</ctuc:Case>
<ctuc:Case Value="False">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Tasks}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="{ThemeResource ViewBackgroundColor}"
CornerRadius="10"
Height="150"
Margin="0,0,0,10">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
Source="{Binding Video.ThumbnailUrl}"
VerticalAlignment="Stretch"/>
<Grid Grid.Column="1"
Margin="10"
RowSpacing="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0"
ColumnSpacing="10"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
FontWeight="SemiBold"
FontSize="18"
Text="{Binding Video.Title}"
TextTrimming="CharacterEllipsis"/>
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
FontWeight="Light"
FontSize="12"
Text="{Binding Video.Author}"/>
</Grid>
<Grid Grid.Row="1"
RowSpacing="10"
ColumnSpacing="10">
<Grid.Resources>
<x:Double x:Key="TextSize">12</x:Double>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Grid.Row="0"
Grid.Column="0"
Source="{ThemeResource ImageHomeDownloadsViewQuality}"/>
<StackPanel Grid.Row="0"
Grid.Column="1"
VerticalAlignment="Center"
Orientation="Horizontal">
<ctuc:SwitchPresenter Value="{Binding DownloadOptions.MediaType, Converter={StaticResource ObjectToStringConverter}}">
<ctuc:Case Value="Original">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/MediaTypeOriginal"
FontSize="{StaticResource TextSize}"/>
</ctuc:Case>
<ctuc:Case Value="OnlyVideo">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/MediaTypeOnlyVideo"
FontSize="{StaticResource TextSize}"/>
</ctuc:Case>
<ctuc:Case Value="OnlyAudio">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/MediaTypeOnlyAudio"
FontSize="{StaticResource TextSize}"/>
</ctuc:Case>
</ctuc:SwitchPresenter>
<TextBlock FontSize="{StaticResource TextSize}">
<Run Text=" ("/><Run Text="{Binding DownloadOptions.SelectedStream.Name}"/>)
</TextBlock>
</StackPanel>
<Image Grid.Row="1"
Grid.Column="0"
Source="{ThemeResource ImageHomeDownloadsViewTime}"/>
<StackPanel Grid.Row="1"
Grid.Column="1"
Orientation="Horizontal"
VerticalAlignment="Center">
<TextBlock Text="{Binding DownloadOptions.DurationAfterTrim}"
FontSize="{StaticResource TextSize}"/>
<TextBlock Visibility="{Binding DownloadOptions.IsTrimmed, Converter={StaticResource BoolToVisibilityConverter}}"
FontSize="{StaticResource TextSize}">
<Run Text=" "/>(<Run Text="{Binding DownloadOptions.TrimStart}"/> - <Run Text="{Binding DownloadOptions.TrimEnd}"/>)
</TextBlock>
</StackPanel>
<Image Grid.Row="2"
Grid.Column="0"
Source="{ThemeResource ImageHomeDownloadsViewFile}"/>
<TextBlock Grid.Row="2"
Grid.Column="1"
FontSize="{StaticResource TextSize}"
VerticalAlignment="Center">
<Run Text="{Binding DownloadOptions.Directory}"/>\<Run Text="{Binding DownloadOptions.Filename}"/>.<Run Text="{Binding DownloadOptions.Extension}"/>
</TextBlock>
<Image Grid.Row="3"
Grid.Column="0">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Idle">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewIdle}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Queued">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewQueued}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Initializing">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewInitializing}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Downloading">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewDownloading}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Processing">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewProcessing}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Finalizing">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewFinalizing}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="EndedUnsuccessfully">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewError}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="EndedSuccessfully">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewDone}"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="EndedCancelled">
<ic:ChangePropertyAction PropertyName="Source"
Value="{ThemeResource ImageHomeDownloadsViewCancelled}"/>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Image>
<Border Grid.Row="3"
Grid.Column="1"
VerticalAlignment="Center">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Idle">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusIdle"
FontSize="{StaticResource TextSize}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Queued">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusQueued"
FontSize="{StaticResource TextSize}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Initializing">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusInitializing"
FontSize="{StaticResource TextSize}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Downloading">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<StackPanel Orientation="Horizontal">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusDownloading"
FontSize="{StaticResource TextSize}"/>
<TextBlock Text="{Binding Progress, Converter={StaticResource StringFormatConverter}, ConverterParameter='{} ({0:0.##}%)'}"
FontSize="{StaticResource TextSize}"/>
</StackPanel>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Processing">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock FontSize="{StaticResource TextSize}">
<Run x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusProcessing"/><Run Text=" ("/><Run Text="{Binding Progress, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}"/>%)
</TextBlock>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Finalizing">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusFinalizing"
FontSize="{StaticResource TextSize}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="EndedUnsuccessfully">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock FontSize="{StaticResource TextSize}">
<Run x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusError"/><Run Text=" ("/><Run Text="{Binding Error}"/>)
</TextBlock>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="EndedSuccessfully">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusDone"
FontSize="{StaticResource TextSize}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="EndedCancelled">
<ic:ChangePropertyAction PropertyName="Child">
<ic:ChangePropertyAction.Value>
<TextBlock x:Uid="/VDownload.Core.Strings/HomeDownloadsViewResources/StatusCancelled"
FontSize="{StaticResource TextSize}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Border>
</Grid>
</Grid>
<Grid Grid.Column="2"
Margin="0,0,5,0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<AppBarButton Grid.Row="0"
Width="40"
Height="48">
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="Click">
<ctb:NavigateToUriAction NavigateUri="{Binding Video.Url}"/>
</ic:EventTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Video.Source, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="Twitch">
<ic:ChangePropertyAction PropertyName="Icon">
<ic:ChangePropertyAction.Value>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{StaticResource ImageSourcesTwitch}"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</AppBarButton>
<AppBarButton Grid.Row="1"
Width="40"
Height="48"
Command="{Binding ElementName=Root, Path=DataContext.StartCancelTaskCommand}"
CommandParameter="{Binding}">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToIntConverter}}"
ComparisonCondition="LessThan"
Value="4">
<ic:ChangePropertyAction PropertyName="Icon">
<ic:ChangePropertyAction.Value>
<SymbolIcon Symbol="Download"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToIntConverter}}"
ComparisonCondition="GreaterThanOrEqual"
Value="4">
<ic:ChangePropertyAction PropertyName="Icon">
<ic:ChangePropertyAction.Value>
<SymbolIcon Symbol="Cancel"/>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</AppBarButton>
<AppBarButton Grid.Row="2"
Icon="Delete"
Width="40"
Height="48"
Command="{Binding ElementName=Root, Path=DataContext.RemoveTaskCommand}"
CommandParameter="{Binding}"/>
</Grid>
</Grid>
<ProgressBar Grid.Row="1"
Value="{Binding Progress}"
Maximum="100">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToIntConverter}}"
ComparisonCondition="LessThan"
Value="5">
<ic:ChangePropertyAction PropertyName="Visibility" Value="Collapsed"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToIntConverter}}"
ComparisonCondition="GreaterThanOrEqual"
Value="5">
<ic:ChangePropertyAction PropertyName="Visibility" Value="Visible"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToIntConverter}}"
ComparisonCondition="LessThan"
Value="7">
<ic:ChangePropertyAction PropertyName="IsIndeterminate" Value="True"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding Status, Converter={StaticResource ObjectToIntConverter}}"
ComparisonCondition="GreaterThanOrEqual"
Value="7">
<ic:ChangePropertyAction PropertyName="IsIndeterminate" Value="False"/>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</ProgressBar>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</ctuc:Case>
</ctuc:SwitchPresenter>
</Page>

View File

@@ -0,0 +1,31 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using VDownload.Core.ViewModels.Home;
using Windows.Foundation;
using Windows.Foundation.Collections;
namespace VDownload.Core.Views.Home
{
public sealed partial class HomeDownloadsView : Page
{
#region CONSTRUCTORS
public HomeDownloadsView(HomeDownloadsViewModel viewModel)
{
this.InitializeComponent();
this.DataContext = viewModel;
}
#endregion
}
}

View File

@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="VDownload.Core.Views.Home.HomeVideoView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VDownload.Core.Views.Home"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:m="using:VDownload.Models"
xmlns:ct="using:CommunityToolkit.WinUI"
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
xmlns:ctuc="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:c="using:VDownload.Toolkit.UI.Controls"
mc:Ignorable="d"
Background="{ThemeResource ViewBackgroundColor}">
<Grid Padding="15"
RowSpacing="20">
<Grid.RowDefinitions>
<RowDefinition Height="150"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0"
ColumnSpacing="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0"
CornerRadius="{ThemeResource ControlCornerRadius}">
<Image Source="{Binding ThumbnailUrl}"
VerticalAlignment="Stretch"/>
</Border>
<StackPanel Grid.Column="1"
Spacing="15">
<TextBlock Text="{Binding Title}"
FontWeight="Bold"
FontSize="20"
TextWrapping="WrapWholeWords"/>
<Grid ColumnSpacing="10"
RowSpacing="10">
<Grid.Resources>
<x:Double x:Key="IconSize">18</x:Double>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Grid.Column="0"
Grid.Row="0"
Source="{ThemeResource ImageHomeVideoViewAuthor}"
Width="{StaticResource IconSize}"/>
<TextBlock Grid.Column="1"
Grid.Row="0"
Text="{Binding Author}"/>
<Image Grid.Column="0"
Grid.Row="1"
Source="{ThemeResource ImageHomeVideoViewDate}"
Width="{StaticResource IconSize}"/>
<TextBlock Grid.Column="1"
Grid.Row="1"
Text="{Binding PublishDate}"/>
<Image Grid.Column="0"
Grid.Row="2"
Source="{ThemeResource ImageHomeVideoViewTime}"
Width="{StaticResource IconSize}"/>
<TextBlock Grid.Column="1"
Grid.Row="2"
Text="{Binding Duration}"/>
<Image Grid.Column="0"
Grid.Row="3"
Source="{ThemeResource ImageHomeVideoViewViews}"
Width="{StaticResource IconSize}"/>
<TextBlock Grid.Column="1"
Grid.Row="3"
Text="{Binding Views}"/>
</Grid>
</StackPanel>
</Grid>
<ScrollViewer Grid.Row="1">
<StackPanel Spacing="20">
<StackPanel Spacing="5">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/MediaOptionsHeader"
FontWeight="Bold"
FontSize="15"/>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/QualitySettingsCard">
<ctc:SettingsCard.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{ThemeResource ImageHomeVideoViewQuality}"/>
</ctc:SettingsCard.HeaderIcon>
<ComboBox ItemsSource="{Binding Streams}"
SelectedItem="{Binding SelectedStream, Mode=TwoWay}">
<!-- ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ComboBox.ItemTemplate -->
</ComboBox>
</ctc:SettingsCard>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/MediaTypeSettingsCard">
<ctc:SettingsCard.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{ThemeResource ImageHomeVideoViewMedia}"/>
</ctc:SettingsCard.HeaderIcon>
<ComboBox ItemsSource="{ct:EnumValues Type=m:MediaType}"
SelectedItem="{Binding MediaType, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<ctuc:SwitchPresenter Value="{Binding Converter={StaticResource ObjectToStringConverter}}">
<ctuc:Case Value="Original">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/MediaTypeOriginal"/>
</ctuc:Case>
<ctuc:Case Value="OnlyVideo">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/MediaTypeOnlyVideo"/>
</ctuc:Case>
<ctuc:Case Value="OnlyAudio">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/MediaTypeOnlyAudio"/>
</ctuc:Case>
</ctuc:SwitchPresenter>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</ctc:SettingsCard>
<ctc:SettingsExpander x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/TrimSettingsGroup">
<ctc:SettingsExpander.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{ThemeResource ImageHomeVideoViewTrim}"/>
</ctc:SettingsExpander.HeaderIcon>
<ctc:SettingsExpander.Items>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/TrimStartSettingsCard">
<c:TimeSpanControl Value="{Binding TrimStart, Mode=TwoWay}"
Maximum="{Binding TrimEnd, Mode=OneWay}"/>
</ctc:SettingsCard>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/TrimEndSettingsCard">
<c:TimeSpanControl Minimum="{Binding TrimStart, Mode=OneWay}"
Value="{Binding TrimEnd, Mode=TwoWay}"
Maximum="{Binding Duration, Mode=OneWay}"/>
</ctc:SettingsCard>
</ctc:SettingsExpander.Items>
</ctc:SettingsExpander>
</StackPanel>
<StackPanel Spacing="5">
<TextBlock x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/FileOptionsHeader"
FontWeight="Bold"
FontSize="15"/>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/DirectorySettingsCard"
Description="{Binding DirectoryPath}">
<ctc:SettingsCard.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{ThemeResource ImageHomeVideoViewDirectory}"/>
</ctc:SettingsCard.HeaderIcon>
<Button x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/DirectorySettingsCardButton"
Command="{Binding BrowseCommand}"/>
</ctc:SettingsCard>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/FilenameSettingsCard">
<ctc:SettingsCard.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{ThemeResource ImageHomeVideoViewFilename}"/>
</ctc:SettingsCard.HeaderIcon>
<TextBox Text="{Binding Filename, Mode=TwoWay}"/>
</ctc:SettingsCard>
<ctc:SettingsCard x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/FileTypeSettingsCard">
<ctc:SettingsCard.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="{ThemeResource ImageHomeVideoViewExtension}"/>
</ctc:SettingsCard.HeaderIcon>
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding MediaType, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="OnlyAudio">
<ic:ChangePropertyAction PropertyName="Content">
<ic:ChangePropertyAction.Value>
<ComboBox ItemsSource="{ct:EnumValues Type=m:AudioExtension}"
SelectedItem="{Binding AudioExtension, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding MediaType, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="NotEqual"
Value="OnlyAudio">
<ic:ChangePropertyAction PropertyName="Content">
<ic:ChangePropertyAction.Value>
<ComboBox ItemsSource="{ct:EnumValues Type=m:VideoExtension}"
SelectedItem="{Binding VideoExtension, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</ic:ChangePropertyAction.Value>
</ic:ChangePropertyAction>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</ctc:SettingsCard>
</StackPanel>
</StackPanel>
</ScrollViewer>
<StackPanel Grid.Row="2"
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="10">
<Button x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/CreateAndStartButton"
Command="{Binding CreateTaskAndDownloadCommand}"/>
<Button x:Uid="/VDownload.Core.Strings/HomeVideoViewResources/CreateButton"
Style="{StaticResource AccentButtonStyle}"
Command="{Binding CreateTaskCommand}"/>
</StackPanel>
</Grid>
</Page>

View File

@@ -0,0 +1,31 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using VDownload.Core.ViewModels.Home;
using Windows.Foundation;
using Windows.Foundation.Collections;
namespace VDownload.Core.Views.Home
{
public sealed partial class HomeVideoView : Page
{
#region CONSTRUCTORS
public HomeVideoView(HomeVideoViewModel viewModel)
{
this.InitializeComponent();
this.DataContext = viewModel;
}
#endregion
}
}

View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="VDownload.Core.Views.Home.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:ctuc="using:CommunityToolkit.WinUI.UI.Controls"
mc:Ignorable="d"
Background="Transparent"
x:Name="Root">
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="Loaded">
<ic:InvokeCommandAction Command="{Binding NavigationCommand}"/>
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<Grid RowSpacing="10"
Margin="10">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Frame Content="{Binding MainContent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ViewModelToViewConverter}}">
</Frame>
<Grid Grid.Row="1"
Background="{ThemeResource OptionBarBackgroundColor}"
CornerRadius="10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ctuc:UniformGrid Grid.Column="0"
Rows="1"
Margin="15,0,0,0">
<ctuc:UniformGrid.RowDefinitions>
<RowDefinition/>
</ctuc:UniformGrid.RowDefinitions>
<ctuc:UniformGrid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</ctuc:UniformGrid.ColumnDefinitions>
<ctuc:SwitchPresenter Grid.Row="0"
VerticalAlignment="Stretch"
Margin="0,0,15,0"
Value="{Binding OptionBarContent, Converter={StaticResource ObjectToStringConverter}}">
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding OptionBarContent, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="Equal"
Value="None">
<ic:ChangePropertyAction PropertyName="Visibility"
Value="Collapsed"/>
</ic:DataTriggerBehavior>
<ic:DataTriggerBehavior Binding="{Binding OptionBarContent, Converter={StaticResource ObjectToStringConverter}}"
ComparisonCondition="NotEqual"
Value="None">
<ic:ChangePropertyAction PropertyName="Visibility"
Value="Visible"/>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
<ctuc:Case Value="VideoSearch">
<Grid ColumnSpacing="10"
VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarVideoSearchContentTextBox"
Grid.Column="0"
VerticalAlignment="Center"
Text="{Binding OptionBarVideoSearchTBValue, Mode=TwoWay}"/>
<Button x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarSearchButton"
Grid.Column="1"
IsEnabled="{Binding OptionBarSearchNotPending}"
Command="{Binding VideoSearchStartCommand}"/>
</Grid>
</ctuc:Case>
<ctuc:Case Value="PlaylistSearch">
<Grid ColumnSpacing="10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarPlaylistSearchContentTextBox"
Grid.Column="0"
VerticalAlignment="Center"
Text="{Binding OptionBarPlaylistSearchTBValue, Mode=TwoWay}"/>
<NumberBox x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarPlaylistSearchContentNumberBox"
Grid.Column="1"
VerticalAlignment="Center"
SpinButtonPlacementMode="Compact"
SmallChange="1"
LargeChange="10"
Value="{Binding OptionBarPlaylistSearchNBValue, Mode=TwoWay}"
Minimum="0"/>
<Button x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarSearchButton"
Grid.Column="2"
IsEnabled="{Binding OptionBarSearchNotPending}"
Command="{Binding PlaylistSearchStartCommand}"/>
</Grid>
</ctuc:Case>
</ctuc:SwitchPresenter>
<StackPanel VerticalAlignment="Center"
Orientation="Horizontal">
<ProgressRing Width="20"
Height="20"
Margin="0,0,10,0"
Visibility="{Binding OptionBarLoading, Converter={StaticResource BoolToVisibilityConverter}}"/>
<TextBlock Text="{Binding OptionBarMessage}"/>
</StackPanel>
</ctuc:UniformGrid>
<StackPanel Grid.Column="2"
Orientation="Horizontal">
<AppBarButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarLoadSubscription"
Icon="Favorite"
IsEnabled="{Binding OptionBarSearchNotPending}"
Command="{Binding LoadFromSubscriptionCommand}"/>
<AppBarToggleButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarVideoSearch"
Icon="Video"
IsEnabled="{Binding OptionBarSearchNotPending}"
IsChecked="{Binding OptionBarVideoSearchButtonChecked, Mode=TwoWay}"
Command="{Binding VideoSearchShowCommand}"/>
<AppBarToggleButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarPlaylistSearch"
Icon="List"
IsEnabled="{Binding OptionBarSearchNotPending}"
IsChecked="{Binding OptionBarPlaylistSearchButtonChecked, Mode=TwoWay}"
Command="{Binding PlaylistSearchShowCommand}"/>
<AppBarSeparator/>
<AppBarButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarDownloadAll"
Icon="Download"
Command="{Binding DownloadCommand}"/>
</StackPanel>
</Grid>
</Grid>
</Page>

View File

@@ -0,0 +1,18 @@
using Microsoft.UI.Xaml.Controls;
using VDownload.Core.ViewModels.Home;
namespace VDownload.Core.Views.Home
{
public sealed partial class HomeView : Page
{
#region CONSTRUCTORS
public HomeView(HomeViewModel viewModel)
{
this.InitializeComponent();
this.DataContext = viewModel;
}
#endregion
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="VDownload.Core.Views.Settings.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VDownload.Core.Views.Settings"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
</Grid>
</Page>

View File

@@ -0,0 +1,26 @@
using Microsoft.UI.Xaml.Controls;
using VDownload.Core.ViewModels.Settings;
namespace VDownload.Core.Views.Settings
{
public sealed partial class SettingsView : Page
{
#region PROPERTIES
public new SettingsViewModel DataContext { get; set; }
#endregion
#region CONSTRUCTORS
public SettingsView(SettingsViewModel viewModel)
{
this.InitializeComponent();
this.DataContext = viewModel;
}
#endregion
}
}

View File

@@ -0,0 +1,81 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>VDownload.Core.Views</RootNamespace>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<UseRidGraph>true</UseRidGraph>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VDownload.Toolkit\VDownload.Toolkit.UI\VDownload.Toolkit.UI.Behaviors\VDownload.Toolkit.UI.Behaviors.csproj" />
<ProjectReference Include="..\..\VDownload.Toolkit\VDownload.Toolkit.UI\VDownload.Toolkit.UI.Controls\VDownload.Toolkit.UI.Controls.csproj" />
<ProjectReference Include="..\VDownload.Core.Strings\VDownload.Core.Strings.csproj" />
<ProjectReference Include="..\VDownload.Core.ViewModels\VDownload.Core.ViewModels.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Authentication\AuthenticationView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="BaseWindow.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Home\HomeDownloadsView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Home\HomeVideoView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Settings\SettingsView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
<ItemGroup>
<Page Update="Home\HomeVideoView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="BaseWindow.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Home\HomeView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Home\HomeDownloadsView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Authentication\AuthenticationView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Settings\SettingsView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,70 @@
using Microsoft.UI.Xaml.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using VDownload.Core.ViewModels.Authentication;
using VDownload.Core.ViewModels.Home;
using VDownload.Core.ViewModels.Settings;
using VDownload.Core.Views.Authentication;
using VDownload.Core.Views.Home;
using VDownload.Core.Views.Settings;
namespace VDownload.Core.Views
{
public class ViewModelToViewConverter : IValueConverter
{
#region FIELDS
private readonly Dictionary<Type, Type> _viewModelViewBinding = new Dictionary<Type, Type>
{
{ typeof(HomeViewModel), typeof(HomeView) },
{ typeof(HomeDownloadsViewModel), typeof(HomeDownloadsView) },
{ typeof(HomeVideoViewModel), typeof(HomeVideoView) },
{ typeof(SettingsViewModel), typeof(SettingsView) },
{ typeof(AuthenticationViewModel), typeof(AuthenticationView) }
};
#endregion
#region PROPERTIES
public static IServiceProvider ServiceProvider { protected get; set; }
#endregion
#region PUBLIC METHODS
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is null)
{
return null;
}
if (value is Type type && _viewModelViewBinding.ContainsKey(type))
{
return ServiceProvider.GetService(_viewModelViewBinding[type]);
}
if (_viewModelViewBinding.ContainsKey(value.GetType()))
{
return ServiceProvider.GetService(_viewModelViewBinding[value.GetType()]);
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
Dictionary<Type, Type> viewViewModelBinding = _viewModelViewBinding.ToDictionary(x => x.Value, x => x.Key);
if (viewViewModelBinding.ContainsKey(value.GetType()))
{
return viewViewModelBinding[value.GetType()];
}
return null;
}
#endregion
}
}