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