From 6c766398d1b5d3fba749c1f682ada87cb45f6e7d Mon Sep 17 00:00:00 2001 From: MaKrotos Date: Wed, 22 May 2024 16:04:43 +0300 Subject: [PATCH] =?UTF-8?q?Added=20Buttons=20In=20Horizontal=20Lists=20all?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VK UI3/Controls/Blocks/ListPlaylists.xaml | 119 +++-------------- VK UI3/Controls/Blocks/ListPlaylists.xaml.cs | 121 +++--------------- VK UI3/Controls/Blocks/ListTracks.xaml | 5 +- VK UI3/Controls/Blocks/ListTracks.xaml.cs | 15 +-- .../Controls/Blocks/RecommsPlaylistBlock.xaml | 120 +++-------------- .../Blocks/RecommsPlaylistBlock.xaml.cs | 107 +--------------- .../Blocks/RemomendedUsersPlaylist.xaml | 48 ++++--- .../Blocks/RemomendedUsersPlaylist.xaml.cs | 40 +++++- .../Views/Controls/UniversalControl.xaml.cs | 6 +- 9 files changed, 135 insertions(+), 446 deletions(-) diff --git a/VK UI3/Controls/Blocks/ListPlaylists.xaml b/VK UI3/Controls/Blocks/ListPlaylists.xaml index 42a4f00..674800e 100644 --- a/VK UI3/Controls/Blocks/ListPlaylists.xaml +++ b/VK UI3/Controls/Blocks/ListPlaylists.xaml @@ -26,107 +26,28 @@ - - - - - + CornerRadius="8"> + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/VK UI3/Controls/Blocks/ListPlaylists.xaml.cs b/VK UI3/Controls/Blocks/ListPlaylists.xaml.cs index 4e7a21e..27d17db 100644 --- a/VK UI3/Controls/Blocks/ListPlaylists.xaml.cs +++ b/VK UI3/Controls/Blocks/ListPlaylists.xaml.cs @@ -23,31 +23,34 @@ public ListPlaylists() this.Loading += ListPlaylists_Loading; this.Loaded += ListPlaylists_Loaded; this.Unloaded += ListPlaylists_Unloaded; + myControl.loadMore = load; } private void ListPlaylists_Loaded(object sender, RoutedEventArgs e) { - if (gridV.CheckIfAllContentIsVisible()) + if (myControl.CheckIfAllContentIsVisible()) load(); - gridV.loadMore += loadMore; - gridV.LeftChange += LeftChange; - gridV.RightChange += RightChange; + } private void ListPlaylists_Unloaded(object sender, RoutedEventArgs e) { this.Unloaded -= ListPlaylists_Unloaded; - gridV.loadMore -= loadMore; + myControl.loadMore = null; - gridV.loadMore -= loadMore; - gridV.LeftChange -= LeftChange; - gridV.RightChange -= RightChange; } private SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); - + public bool itsAll + { + get + { + if (localBlock == null) return true; + if (localBlock.NextFrom == null) return true; else return false; + } + } private async void load() { await semaphore.WaitAsync(); @@ -61,7 +64,7 @@ private async void load() { playlists.Add(item); } - if (gridV.CheckIfAllContentIsVisible()) + if (myControl.CheckIfAllContentIsVisible()) load(); }); } @@ -85,11 +88,11 @@ private void ListPlaylists_Loading(FrameworkElement sender, object args) if (block.Meta != null && block.Meta.anchor == "vibes") { - gridV.ItemTemplate = this.Resources["compact"] as DataTemplate; + myControl.ItemTemplate = this.Resources["compact"] as DataTemplate; } else { - gridV.ItemTemplate = this.Resources["default"] as DataTemplate; + myControl.ItemTemplate = this.Resources["default"] as DataTemplate; } var pl = (DataContext as Block).Playlists; @@ -111,99 +114,7 @@ private void ListPlaylists_Loading(FrameworkElement sender, object args) - private void LeftChange(object sender, EventArgs e) - { - LeftCh(); - } - private void RightChange(object sender, EventArgs e) - { - RightCh(); - } - - private void RightCh() - { - if (gridV.showRight) - { - RightGrid.Visibility = Visibility.Visible; - - FadeOutAnimationRightBTN.Pause(); - FadeInAnimationRightBTN.Begin(); - - } - else - { - if (localBlock.NextFrom != null) - { - FadeInAnimationRightBTN.Pause(); - FadeOutAnimationRightBTN.Begin(); - } - } - } - private void FadeOutAnimationRightBTN_Completed(object sender, object e) - { - if (!gridV.showRight || !enterpoint) - { - RightGrid.Visibility = Visibility.Collapsed; - } - } - - private void FadeOutAnimationLeftBTN_Completed(object sender, object e) - { - if (!gridV.showLeft || !enterpoint) - { - LeftGrid.Visibility = Visibility.Collapsed; - } - - } - - private void gridCh_PointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) - { - enterpoint = true; - var a = gridV.ShowLeftChecker; - a = gridV.ShowRightChecker; - LeftCh(); - RightCh(); - } - bool enterpoint; - private void gridCh_PointerExited(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) - { - this.enterpoint = false; - FadeInAnimationLeftBTN.Pause(); - FadeOutAnimationLeftBTN.Begin(); - FadeInAnimationRightBTN.Pause(); - FadeOutAnimationRightBTN.Begin(); - } - private void LeftCh() - { - if (gridV.showLeft) - { - LeftGrid.Visibility = Visibility.Visible; - - FadeOutAnimationLeftBTN.Pause(); - FadeInAnimationLeftBTN.Begin(); - } - else - { - FadeInAnimationLeftBTN.Pause(); - FadeOutAnimationLeftBTN.Begin(); - - } - } - private void loadMore(object sender, EventArgs e) - { - load(); - } - - - private void ScrollRight_Click(object sender, RoutedEventArgs e) - { - gridV.ScrollRight(); - } - - private void ScrollLeft_Click(object sender, RoutedEventArgs e) - { - gridV.ScrollLeft(); - } + } } diff --git a/VK UI3/Controls/Blocks/ListTracks.xaml b/VK UI3/Controls/Blocks/ListTracks.xaml index 19d61f9..a99ae7f 100644 --- a/VK UI3/Controls/Blocks/ListTracks.xaml +++ b/VK UI3/Controls/Blocks/ListTracks.xaml @@ -10,7 +10,10 @@ Margin="0,0,0,0" mc:Ignorable="d"> - + diff --git a/VK UI3/Controls/Blocks/ListTracks.xaml.cs b/VK UI3/Controls/Blocks/ListTracks.xaml.cs index f475c61..ee29154 100644 --- a/VK UI3/Controls/Blocks/ListTracks.xaml.cs +++ b/VK UI3/Controls/Blocks/ListTracks.xaml.cs @@ -39,10 +39,7 @@ private void ListTracks_Unloaded(object sender, RoutedEventArgs e) } - private void loadMore(object sender, EventArgs e) - { - sectionAudio.GetTracks(); - } + private void ListTracks_Loaded(object sender, RoutedEventArgs e) { @@ -51,10 +48,12 @@ private void ListTracks_Loaded(object sender, RoutedEventArgs e) sectionAudio?.NotifyOnListUpdate(); } catch { } + myControl.loadMore = sectionAudio.GetTracks; + if (myControl.CheckIfAllContentIsVisible()) sectionAudio.GetTracks(); } - + bool connected = false; private void ListTracks_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { @@ -85,12 +84,6 @@ private void SectionAudio_onListUpdate(object sender, EventArgs e) } private SectionAudio sectionAudio; - - - - - - } } diff --git a/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml b/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml index 790b6e7..29ea40d 100644 --- a/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml +++ b/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml @@ -15,107 +15,23 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml.cs b/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml.cs index 4205139..eec3831 100644 --- a/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml.cs +++ b/VK UI3/Controls/Blocks/RecommsPlaylistBlock.xaml.cs @@ -26,9 +26,7 @@ public RecommsPlaylistBlock() private void RecommsPlaylistBlock_Loaded(object sender, RoutedEventArgs e) { - gridV.loadMore += loadMore; - gridV.LeftChange += LeftChange; - gridV.RightChange += RightChange; + myControl.loadMore = load; } Block localBlock; private void RecommsPlaylistBlock_Unloaded(object sender, RoutedEventArgs e) @@ -36,11 +34,8 @@ private void RecommsPlaylistBlock_Unloaded(object sender, RoutedEventArgs e) this.Loading -= RecommsPlaylistBlock_Loading; this.Unloaded -= RecommsPlaylistBlock_Unloaded; + myControl.loadMore = null; - - gridV.loadMore -= loadMore; - gridV.LeftChange -= LeftChange; - gridV.RightChange -= RightChange; } private SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); private async void load() @@ -56,7 +51,7 @@ private async void load() { playlists.Add(item); } - if (gridV.CheckIfAllContentIsVisible()) + if (myControl.CheckIfAllContentIsVisible()) load(); }); } @@ -84,101 +79,13 @@ private void RecommsPlaylistBlock_Loading(FrameworkElement sender, object args) } } - - - - private void LeftChange(object sender, EventArgs e) - { - LeftCh(); - } - private void RightChange(object sender, EventArgs e) - { - RightCh(); - } - - private void RightCh() - { - if (gridV.showRight) - { - RightGrid.Visibility = Visibility.Visible; - - FadeOutAnimationRightBTN.Pause(); - FadeInAnimationRightBTN.Begin(); - - } - else - { - if (localBlock.NextFrom != null) - { - FadeInAnimationRightBTN.Pause(); - FadeOutAnimationRightBTN.Begin(); - } - } - } - private void FadeOutAnimationRightBTN_Completed(object sender, object e) - { - if (!gridV.showRight || !enterpoint) - { - RightGrid.Visibility = Visibility.Collapsed; - } - } - - private void FadeOutAnimationLeftBTN_Completed(object sender, object e) + public bool itsAll { - if (!gridV.showLeft || !enterpoint) + get { - LeftGrid.Visibility = Visibility.Collapsed; + if (localBlock == null) return true; + if (localBlock.NextFrom == null) return true; else return false; } - - } - - private void gridCh_PointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) - { - enterpoint = true; - var a = gridV.ShowLeftChecker; - a = gridV.ShowRightChecker; - LeftCh(); - RightCh(); - } - bool enterpoint; - private void gridCh_PointerExited(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) - { - this.enterpoint = false; - FadeInAnimationLeftBTN.Pause(); - FadeOutAnimationLeftBTN.Begin(); - FadeInAnimationRightBTN.Pause(); - FadeOutAnimationRightBTN.Begin(); - } - private void LeftCh() - { - if (gridV.showLeft) - { - LeftGrid.Visibility = Visibility.Visible; - - FadeOutAnimationLeftBTN.Pause(); - FadeInAnimationLeftBTN.Begin(); - } - else - { - FadeInAnimationLeftBTN.Pause(); - FadeOutAnimationLeftBTN.Begin(); - - } - } - private void loadMore(object sender, EventArgs e) - { - load(); - } - - - private void ScrollRight_Click(object sender, RoutedEventArgs e) - { - gridV.ScrollRight(); - } - - private void ScrollLeft_Click(object sender, RoutedEventArgs e) - { - gridV.ScrollLeft(); } } diff --git a/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml b/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml index 0bb5c5b..9730477 100644 --- a/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml +++ b/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml @@ -4,38 +4,36 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:custom="using:VK_UI3.Controls" + xmlns:customV="using:VK_UI3.Views.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="using:VK_UI3.Controls.Blocks" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - Margin="10,0,10,0" + Margin="0,0,0,0" mc:Ignorable="d"> - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml.cs b/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml.cs index 8a5a95a..8b6c199 100644 --- a/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml.cs +++ b/VK UI3/Controls/Blocks/RemomendedUsersPlaylist.xaml.cs @@ -3,6 +3,8 @@ using MusicX.Core.Models; using System; using System.Collections.ObjectModel; +using System.Threading; +using VK_UI3.VKs; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -18,11 +20,12 @@ public RemomendedUsersPlaylist() this.Loading += RecommsPlaylistBlock_Loading; this.Unloaded += RecommsPlaylistBlock_Unloaded; + myControl.loadMore = load; } private void RecommsPlaylistBlock_Unloaded(object sender, RoutedEventArgs e) { - + myControl.loadMore = null; this.Loading -= RecommsPlaylistBlock_Loading; this.Unloaded -= RecommsPlaylistBlock_Unloaded; } @@ -34,6 +37,8 @@ private void RecommsPlaylistBlock_Loading(FrameworkElement sender, object args) if (DataContext is not Block block) return; + localBlock = block; + var pl = (DataContext as Block).RecommendedPlaylists; @@ -48,6 +53,39 @@ private void RecommsPlaylistBlock_Loading(FrameworkElement sender, object args) } } + private SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); + public bool itsAll + { + get + { + if (localBlock == null) return true; + if (localBlock.NextFrom == null) return true; else return false; + } + } + Block localBlock; + private async void load() + { + await semaphore.WaitAsync(); + try + { + if (localBlock.NextFrom == null) return; + var a = await VK.vkService.GetSectionAsync(localBlock.Id, localBlock.NextFrom); + localBlock.NextFrom = a.Section.NextFrom; + this.DispatcherQueue.TryEnqueue(async () => { + foreach (var item in a.RecommendedPlaylists) + { + playlists.Add(item); + } + if (myControl.CheckIfAllContentIsVisible()) + load(); + }); + } + finally + { + semaphore.Release(); + } + } + ObservableCollection playlists = new(); diff --git a/VK UI3/Views/Controls/UniversalControl.xaml.cs b/VK UI3/Views/Controls/UniversalControl.xaml.cs index f3e0866..1cb575c 100644 --- a/VK UI3/Views/Controls/UniversalControl.xaml.cs +++ b/VK UI3/Views/Controls/UniversalControl.xaml.cs @@ -26,7 +26,7 @@ public UniversalControl() } - public Action loadMore = nul; + public Action loadMore { get; set; } = nul; private static void nul() { @@ -51,6 +51,8 @@ public DataTemplate ItemTemplate set; } + public bool itsAll { get; set; } + private void ListPlaylists_Loaded(object sender, RoutedEventArgs e) { @@ -134,7 +136,7 @@ private void RightChange(object sender, EventArgs e) { RightCh(); } - public bool itsAll { get; set; } + private void RightCh() { if (gridV.showRight)