Cleaning
This commit is contained in:
parent
52b0a6fc85
commit
468ec8be07
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -35,31 +33,20 @@ namespace unison
|
||||
return;
|
||||
|
||||
SongList.Clear();
|
||||
|
||||
int song = _mpd.GetStats().Songs;
|
||||
|
||||
Debug.WriteLine("before search command / song == " + song);
|
||||
|
||||
IEnumerable<IMpdFile> response = await _mpd.SafelySendCommandAsync(new SearchCommand(filter, 0, song + 1));
|
||||
|
||||
Debug.WriteLine("got response => " + response.Count());
|
||||
|
||||
foreach (IMpdFile file in response)
|
||||
{
|
||||
SongList.Add(file.Path);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddToQueueRandom(int SongNumber, CancellationToken token)
|
||||
{
|
||||
Debug.WriteLine("Add To Queue Random");
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
int AddedSongs = 0;
|
||||
|
||||
Debug.WriteLine("song to add => " + SongNumber);
|
||||
|
||||
var commandList = new CommandList();
|
||||
int songTotal = _mpd.GetStats().Songs;
|
||||
|
||||
@ -75,25 +62,18 @@ namespace unison
|
||||
}
|
||||
|
||||
await _mpd.SafelySendCommandAsync(commandList);
|
||||
|
||||
Debug.WriteLine("Add To Queue Random - finished with " + AddedSongs + " songs");
|
||||
}
|
||||
|
||||
public async Task AddToQueueFilter(int SongNumber, CancellationToken token)
|
||||
{
|
||||
Debug.WriteLine("Add To Queue Filter - start");
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
int AddedSongs = 0;
|
||||
|
||||
Debug.WriteLine("song to add => " + SongNumber);
|
||||
// more (or equal) requested songs than available => add everything
|
||||
if (SongNumber >= SongList.Count)
|
||||
{
|
||||
Trace.WriteLine("more requested songs than available => add everything");
|
||||
|
||||
var commandList = new CommandList();
|
||||
foreach (string path in SongList)
|
||||
{
|
||||
@ -107,8 +87,6 @@ namespace unison
|
||||
// we add unique indexes until we reach the requested amount
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("more available songs than requested");
|
||||
|
||||
HashSet<int> SongIndex = new();
|
||||
while (SongIndex.Count < SongNumber)
|
||||
{
|
||||
@ -125,8 +103,6 @@ namespace unison
|
||||
|
||||
await _mpd.SafelySendCommandAsync(commandList);
|
||||
}
|
||||
|
||||
Debug.WriteLine("Add To Queue Filter - finished");
|
||||
}
|
||||
}
|
||||
}
|
@ -7,10 +7,6 @@ using System.Windows.Interop;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using unison.Handlers;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace unison
|
||||
{
|
||||
@ -126,24 +122,14 @@ namespace unison
|
||||
EndTime.Text = FormatSeconds(_mpd.GetCurrentSong().Time);
|
||||
}
|
||||
|
||||
Debug.WriteLine("Song changed called!");
|
||||
Trace.WriteLine("Song changed called!");
|
||||
|
||||
if (!_shuffleWin.GetContinuous())
|
||||
return;
|
||||
|
||||
Debug.WriteLine("playlist length => " + _mpd.GetStatus().PlaylistLength);
|
||||
|
||||
if (_mpd.GetStatus().PlaylistLength > 4)
|
||||
if (_shuffleWin.GetContinuous())
|
||||
{
|
||||
Debug.WriteLine("return :)");
|
||||
return;
|
||||
_mpd.CanPrevNext = false;
|
||||
await _shuffleWin.HandleContinuous();
|
||||
_mpd.CanPrevNext = true;
|
||||
}
|
||||
|
||||
Debug.WriteLine("start continuous handling");
|
||||
_mpd.CanPrevNext = false;
|
||||
await _shuffleWin.HandleContinuous();
|
||||
_mpd.CanPrevNext = true;
|
||||
Debug.WriteLine("finished continuous");
|
||||
}
|
||||
|
||||
public void OnStatusChanged(object sender, EventArgs e)
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@ -159,8 +158,6 @@ namespace unison
|
||||
|
||||
private async Task UpdateFilter()
|
||||
{
|
||||
Debug.WriteLine("update filter => start");
|
||||
|
||||
Filters.Clear();
|
||||
|
||||
foreach (ContentPresenter superChild in FilterPanel.Children)
|
||||
@ -170,8 +167,6 @@ namespace unison
|
||||
string value = "";
|
||||
bool isDir = false;
|
||||
|
||||
Debug.WriteLine("update filter => part 1");
|
||||
|
||||
StackPanel stackPanel = VisualTreeHelper.GetChild(superChild, 0) as StackPanel;
|
||||
foreach (TextBox child in stackPanel.Children.OfType<TextBox>())
|
||||
{
|
||||
@ -179,8 +174,6 @@ namespace unison
|
||||
value = child.Text;
|
||||
}
|
||||
|
||||
Debug.WriteLine("update filter => part 2");
|
||||
|
||||
foreach (ComboBox child in stackPanel.Children.OfType<ComboBox>())
|
||||
{
|
||||
if (child.Name == "FilterType")
|
||||
@ -198,8 +191,6 @@ namespace unison
|
||||
value = child.SelectedItem.ToString();
|
||||
}
|
||||
|
||||
Debug.WriteLine("update filter => part 3");
|
||||
|
||||
if (value != "")
|
||||
{
|
||||
if (!isDir)
|
||||
@ -214,11 +205,7 @@ namespace unison
|
||||
SongFilterPanel.Visibility = Visibility.Visible;
|
||||
SongFilterNumber.Text = _shuffle.SongList.Count.ToString();
|
||||
}
|
||||
|
||||
Debug.WriteLine("update filter => part 4");
|
||||
}
|
||||
|
||||
Debug.WriteLine("update filter => stop");
|
||||
}
|
||||
|
||||
private void FilterType_Change(object sender, string Operator, List<string> Listing)
|
||||
@ -281,7 +268,6 @@ namespace unison
|
||||
|
||||
private void OperatorType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Debug.WriteLine("selection changed => operator type");
|
||||
SongFilterNumber.Text = "0";
|
||||
}
|
||||
|
||||
@ -382,19 +368,15 @@ namespace unison
|
||||
public async Task HandleContinuous()
|
||||
{
|
||||
if (!_continuous)
|
||||
{
|
||||
Debug.WriteLine("continuous return nothing!");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.WriteLine("continuous __before__ add to queue");
|
||||
int PlaylistLength = _mpd.GetStatus().PlaylistLength;
|
||||
int Num = 10 - PlaylistLength;
|
||||
if (Num < 1)
|
||||
return;
|
||||
|
||||
await UpdateFilter();
|
||||
|
||||
int Num = 5;
|
||||
await AddToQueue_Internal(Num);
|
||||
|
||||
Debug.WriteLine("continuous __after__ add to queue");
|
||||
}
|
||||
|
||||
private async void ContinuousShuffle_Checked(object sender, RoutedEventArgs e)
|
||||
@ -404,7 +386,7 @@ namespace unison
|
||||
else
|
||||
_continuous = false;
|
||||
|
||||
if (_mpd.GetStatus().PlaylistLength < 5)
|
||||
if (_mpd.GetStatus().PlaylistLength < 10)
|
||||
await HandleContinuous();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user