Skip to content

Commit

Permalink
Upload completed
Browse files Browse the repository at this point in the history
Download Completed
Fixes
  • Loading branch information
MaKrotos committed Apr 5, 2024
1 parent 480f5b0 commit fa677c0
Show file tree
Hide file tree
Showing 27 changed files with 961 additions and 141 deletions.
2 changes: 1 addition & 1 deletion VK UI3 (Package)/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="FDW.VKM"
Publisher="CN=FDW"
Version="0.1.5.7" />
Version="0.1.5.8" />

<mp:PhoneIdentity PhoneProductId="b7c1f34e-9025-4935-9d7a-7d0a632a368d" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
15 changes: 8 additions & 7 deletions VK UI3/Controllers/AccountController.xaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl

RightTapped="PersonPicture_RightTapped"
x:Class="VK_UI3.Controllers.AccountController"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VK_UI3.Controllers"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<FlyoutBase.AttachedFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Удалить" Click="Delete_Click"/>
</MenuFlyout>
</FlyoutBase.AttachedFlyout>

<StackPanel Padding="0" Height="70" Orientation="Horizontal">
<Grid Padding="0">
<PersonPicture x:Name="PersonPicture" Width="50" Grid.Column="1" Grid.Row="1" ProfilePicture="{x:Bind accounts.UserPhoto}" RightTapped="PersonPicture_RightTapped">
<FlyoutBase.AttachedFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Удалить" Click="Delete_Click"/>
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
<PersonPicture x:Name="PersonPicture" Width="50" Grid.Column="1" Grid.Row="1" ProfilePicture="{x:Bind accounts.UserPhoto}">

</PersonPicture>
<SymbolIcon Visibility="Collapsed" Width="50" x:Name="iconPic" Symbol="AddFriend"/>
</Grid>
Expand Down
4 changes: 3 additions & 1 deletion VK UI3/Controllers/AccountController.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ private void PersonPicture_RightTapped(object sender, RightTappedRoutedEventArgs
private void Delete_Click(object sender, RoutedEventArgs e)
{
// Здесь добавьте код для удаления элемента
DatabaseHandler.getConnect().Delete<Accounts>(this.accounts.id);
//
AccountsDB.DeleteAccount(this.accounts);

// MainView.invokeUpdateAccounts();

}
Expand Down
1 change: 1 addition & 0 deletions VK UI3/Controls/Blocks/ListTracksFull.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private void ListTracksFull_Unloaded(object sender, RoutedEventArgs e)
this.DataContextChanged -= ListTracks_DataContextChanged;
try
{
if (sectionAudio != null)
sectionAudio.onListUpdate -= SectionAudio_onListUpdate;
}
catch { }
Expand Down
14 changes: 13 additions & 1 deletion VK UI3/Controls/TrackControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<UserControl.ContextFlyout>
<MenuFlyout x:Name="flyOutm">
<MenuFlyoutItem Visibility="Collapsed" x:Name="EditTrack" Text="Редактировать" Click="EditTrack_Click" Icon="Edit" />
<MenuFlyoutItem x:Name="AddRemove" Text="Добавить к себе" Click="AddRemove_Click" Icon="Add" />
<MenuFlyoutItem Visibility="Collapsed" x:Name="RemovePlayList" Text="Удалить из плейлиста" Click="RemovePlayList_Click" Icon="Delete" />
<MenuFlyoutSubItem x:Name="GoArtist" Text="Перейти к исполнителю" Icon="ContactInfo">
Expand Down Expand Up @@ -50,7 +51,18 @@
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem Text="Пропускать треки исполнителя" Click="AddArtistIgnore_Click" Icon="BlockContact" />
<MenuFlyoutItem Text="Скачать" Click="Download_Click" Icon="Download" />


<MenuFlyoutSubItem x:Name="DownloadFlyOut" Text="Скачать" Icon="Download">

<MenuFlyoutItem x:Name="PickFolderDownload" Text="Выбрать папку" Click="PickFolderDownload_Click">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xF12B;" ></FontIcon>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyoutSubItem>


<MenuFlyoutItem Text="Возпроизвести следующим" Click="PlayNext_Click" Icon="Play" />
<MenuFlyoutItem Text="Добавить в очередь" Click="AddToQueue_Click" Icon="Add" />
<MenuFlyoutItem Text="Скопировать ссылку" Click="CopyLink" Icon="Link" />
Expand Down
192 changes: 168 additions & 24 deletions VK UI3/Controls/TrackControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using VK_UI3.Controllers;
using VK_UI3.Converters;
using VK_UI3.DB;
using VK_UI3.DownloadTrack;
using VK_UI3.Helpers;
using VK_UI3.Helpers.Animations;
using VK_UI3.Views;
Expand All @@ -20,6 +21,7 @@
using VkNet.Model.Attachments;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
using Windows.Storage.Pickers;
using static VK_UI3.Views.SectionView;

// To learn more about WinUI, the WinUI project structure,
Expand Down Expand Up @@ -69,12 +71,23 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex

dataTrack = (DataContext as ExtendedAudio);


updateUI();

bool isOwner = track.OwnerId == AccountsDB.activeAccount.id;

}
}

private void updateUI()
{
this.DispatcherQueue.TryEnqueue(() => {
bool isOwner = dataTrack.audio.OwnerId == AccountsDB.activeAccount.id;

if (dataTrack.audio.Release_audio_id == null && dataTrack.audio.OwnerId == AccountsDB.activeAccount.id)
{

EditTrack.Visibility = Visibility.Visible;
}
else EditTrack.Visibility = Visibility.Collapsed;
AddRemove.Visibility = Visibility.Visible;
AddRemove.Text = isOwner ? "Удалить" : "Добавить";
AddRemove.Icon = new SymbolIcon(isOwner ? Symbol.Delete : Symbol.Add);
Expand All @@ -92,18 +105,18 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex
RemovePlayList.Visibility = Visibility.Collapsed;
}

Title.Text = track.Title;
Subtitle.Text = track.Subtitle;
Artists.Text = track.Artist;

Title.Text = dataTrack.audio.Title;
Subtitle.Text = dataTrack.audio.Subtitle;
Artists.Text = dataTrack.audio.Artist;


if (track.Album != null && track.Album.Thumb != null)

if (dataTrack.audio.Album != null && dataTrack.audio.Album.Thumb != null)
{
photouri = track.Album.Thumb.Photo270 ??
track.Album.Thumb.Photo300 ??
track.Album.Thumb.Photo600 ??
track.Album.Thumb.Photo34 ??
photouri = dataTrack.audio.Album.Thumb.Photo270 ??
dataTrack.audio.Album.Thumb.Photo300 ??
dataTrack.audio.Album.Thumb.Photo600 ??
dataTrack.audio.Album.Thumb.Photo34 ??
null;
if (photouri == null || photouri == "")
{
Expand All @@ -125,9 +138,9 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex



if ((track.MainArtists == null) || (!track.MainArtists.Any()))
if ((dataTrack.audio.MainArtists == null) || (!dataTrack.audio.MainArtists.Any()))
{
Artists.Text = track.Artist;
Artists.Text = dataTrack.audio.Artist;
// Artists.MouseEnter += Artists_MouseEnter;
// Artists.MouseLeave += Artists_MouseLeave;
// Artists.MouseLeftButtonDown += Artists_MouseLeftButtonDown;
Expand All @@ -145,7 +158,7 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex
if (goArtistItem != null)
{
goArtistItem.Items.Clear();
foreach (var artist in track.MainArtists)
foreach (var artist in dataTrack.audio.MainArtists)
{
var menuItem = new MenuFlyoutItem
{
Expand Down Expand Up @@ -178,15 +191,15 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex
SecondsToTimeConverter converter = new SecondsToTimeConverter();

// Преобразование секунд в строку времени
object timeString = converter.Convert(track.Duration, null, null, null);
object timeString = converter.Convert(dataTrack.audio.Duration, null, null, null);
Console.WriteLine(timeString);
Time.Text = (string)timeString;





if (this.dataTrack.audio.Album != null)

if (this.dataTrack.audio.Album != null)
{
FlyGoAlbum.Visibility = Visibility.Visible;
}
Expand All @@ -213,11 +226,9 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex
dataTrack.iVKGetAudio.AudioPlayedChangeEvent += UserAudio_AudioPlayedChangeEvent;
addedHandler = true;
}
}
});
}



private void SetIconDislike()
{
// Загрузите ResourceDictionary из файла XAML внутри пакета .appx
Expand Down Expand Up @@ -388,12 +399,12 @@ public void CopyLink(object sender, RoutedEventArgs e)

public void AddRemove_Click(object sender, RoutedEventArgs e)
{

var vkService = VK.vkService;

if (dataTrack.audio.OwnerId == AccountsDB.activeAccount.id)
{
vkService.AudioDeleteAsync((long)dataTrack.audio.Id, (long)dataTrack.audio.OwnerId);
dataTrack.iVKGetAudio.listAudioTrue.Remove(dataTrack);
}
else
{
Expand Down Expand Up @@ -486,6 +497,7 @@ private void GoToAlbum(object sender, RoutedEventArgs e)
dataTrack.audio.Album.AccessKey);
}
List<MenuFlyoutItem> menuFlyoutItems = new List<MenuFlyoutItem>();
List<MenuFlyoutItem> menuFlyoutItemsUploads = new List<MenuFlyoutItem>();
private void UCcontrol_RightTapped(object sender, RightTappedRoutedEventArgs e)
{

Expand Down Expand Up @@ -538,9 +550,50 @@ private void UCcontrol_RightTapped(object sender, RightTappedRoutedEventArgs e)
AddPlayList.Items.Insert(i++, menuItem);
}
});

});

var j = 0;
var paths = PathTable.GetAllPaths();


DispatcherQueue.TryEnqueue(async () =>
{

foreach (var item in menuFlyoutItemsUploads)
{
DownloadFlyOut.Items.Remove(item);
}

menuFlyoutItemsUploads.Clear();

foreach (var path in paths)
{
var menuItem = new MenuFlyoutItem
{
Text = path.path,
Icon = new FontIcon { Glyph = "\uF12B" }
};


menuItem.Click += (s, e) =>
{
IVKGetAudio iVKGetAudio = new SimpleAudio(this.DispatcherQueue);
iVKGetAudio.name = dataTrack.audio.Title;
iVKGetAudio.itsAll = true;
iVKGetAudio.countTracks = 1;
iVKGetAudio.listAudio.Add(dataTrack);

_ = Task.Run(
async () =>
{
PlayListDownload playListDownload = new PlayListDownload(iVKGetAudio, path.path, this.DispatcherQueue, true);
});
};
menuFlyoutItemsUploads.Add(menuItem);
DownloadFlyOut.Items.Insert(j++, menuItem);
}
});

});
}

private void CreatePlayListBTN_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -575,7 +628,54 @@ private void CreatePlayListBTN_Click(object sender, RoutedEventArgs e)

}

private void addToPlayListMore_Click(object sender, RoutedEventArgs e)
private async void pickFolder()
{
try
{
FolderPicker folderPicker = new();
folderPicker.FileTypeFilter.Add("*");


WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, MainWindow.hvn);

Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
if (folder != null)
{
// Директория выбрана, можно продолжить работу с folder
PathTable.AddPath(folder.Path);

IVKGetAudio iVKGetAudio = new SimpleAudio(this.DispatcherQueue);
iVKGetAudio.name = dataTrack.audio.Title;
iVKGetAudio.itsAll = true;
iVKGetAudio.countTracks = 1;
iVKGetAudio.listAudio.Add(dataTrack);

_ = Task.Run(
async () =>
{
new PlayListDownload(iVKGetAudio, folder.Path, this.DispatcherQueue, true);
});
}
else
{
// Операция была отменена пользователем
}
}
catch (Exception ex)
{
}
}

private void PickFolderDownload_Click(object sender, RoutedEventArgs e)
{

pickFolder();


}


private void addToPlayListMore_Click(object sender, RoutedEventArgs e)
{
ContentDialog dialog = new CustomDialog();

Expand Down Expand Up @@ -653,5 +753,49 @@ private async void RemovePlayList_Click(object sender, RoutedEventArgs e)


}

private void EditTrack_Click(object sender, RoutedEventArgs e)
{
ContentDialog dialog = new CustomDialog();
dialog.XamlRoot = this.XamlRoot;
var a = new EditTrack(dataTrack.audio);
dialog.Content = a;

EventHandler handler = null;
handler = (s, e) =>
{
dialog.Hide();
if (s is Audio ss)
{
dataTrack.audio = ss;
updateUI();
}
// a.selectedPlayList -= handler; // Отписка от события
};

a.cancelPressed += handler;

TypedEventHandler<ContentDialog, ContentDialogClosedEventArgs> closedHandler = null;
closedHandler = (s, e) =>
{
a.cancelPressed -= handler;
dialog.Closed -= closedHandler;
dialog = null;
};

dialog.Closed += closedHandler;

dialog.ShowAsync();

dialog.Background = new SolidColorBrush(Microsoft.UI.Colors.Transparent);
dialog.Resources["ContentDialogMaxWidth"] = double.PositiveInfinity;
dialog.Resources["ContentDialogMaxHeight"] = double.PositiveInfinity;
dialog.BorderBrush = new SolidColorBrush(Microsoft.UI.Colors.Transparent);
dialog.Translation = new System.Numerics.Vector3(0, 0, 0);
dialog.Resources.Remove("BackgroundElement");

dialog.Shadow = null;
dialog.BorderThickness = new Thickness(0);
}
}
}
Loading

0 comments on commit fa677c0

Please sign in to comment.