Skip to content

Commit

Permalink
Merge branch 'dev_Filter' into dev_net48
Browse files Browse the repository at this point in the history
  • Loading branch information
Dierk Gramenz committed Feb 14, 2023
2 parents feef0dd + 5bdbb09 commit 974366c
Show file tree
Hide file tree
Showing 15 changed files with 319 additions and 440 deletions.
6 changes: 3 additions & 3 deletions Webradio/Dialogues/WebradioDlgDeleteFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ You should have received a copy of the GNU General Public License
using MediaPortal.UI.Presentation.Workflow;
using Webradio.Helper;
using Webradio.Models;
using Webradio.Settings;

namespace Webradio.Dialogues
{
internal class WebradioDlgDeleteFilter : IWorkflowModel
{
public static List<FilterInfo> FilterList = new List<FilterInfo>();
public static List<Filter> FilterList = new List<Filter>();
public ItemsList FilterItems = new ItemsList();

public void Init()
Expand All @@ -51,7 +52,6 @@ public void ImportFilter()
{
var item = new ListItem();
item.AdditionalProperties[NAME] = mf.Titel;
item.AdditionalProperties[ID] = mf.Id;
item.SetLabel("Name", mf.Titel);
FilterItems.Add(item);
}
Expand All @@ -70,7 +70,7 @@ public void Delete()
foreach (var item in FilterItems.Where(item => item.Selected))
foreach (var mf in FilterList)
{
if (mf.Id != (string)item.AdditionalProperties[ID]) continue;
if (mf.Titel != (string)item.AdditionalProperties[NAME]) continue;
FilterList.Remove(mf);
break;
}
Expand Down
10 changes: 8 additions & 2 deletions Webradio/Dialogues/WebradioDlgImportFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ public void ImportFilter()
FilterItems.Clear();
foreach (var f in WebradioFilterModel.FilterList)
{
var item = new ListItem();
item.AdditionalProperties[NAME] = f.Titel;
var item = new ListItem
{
AdditionalProperties =
{
[NAME] = f.Titel
}
};
item.SetLabel("Name", f.Titel);
FilterItems.Add(item);
}
FilterItems.FireChange();
}

/// <summary>
Expand Down
15 changes: 7 additions & 8 deletions Webradio/Dialogues/WebradioDlgShowFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace Webradio.Dialogues
internal class WebradioDlgShowFilter : IWorkflowModel
{
public static ItemsList FilterItems = new ItemsList();
public static List<FilterInfo> FilterList = new List<FilterInfo>();
private static Filter FilterSettings;
public static List<Filter> FilterList = new List<Filter>();
private static Filters FilterSettings;
private bool _quick;
private string _typ = string.Empty;

Expand All @@ -54,18 +54,17 @@ public void ShowFilter()
{
_typ = string.Empty;
_quick = false;
FilterList = ServiceRegistration.Get<ISettingsManager>().Load<Filter>().FilterSetupList;
FilterList = ServiceRegistration.Get<ISettingsManager>().Load<Filters>().FilterSetupList;
if (FilterList == null)
FilterList = new List<FilterInfo>
FilterList = new List<Filter>
{
new FilterInfo(
"New Filter", "0",
new List<string>(),
new Filter(
"New Filter",
new List<string>(),
new List<string>())
};

FilterSettings = new Filter(FilterList);
FilterSettings = new Filters(FilterList);

var list = new List<string>();

Expand Down
8 changes: 0 additions & 8 deletions Webradio/Dialogues/WebradioDlgShowMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ namespace Webradio.Dialogues
{
internal class WebradioDlgShowMessage : IWorkflowModel
{
public string Message = string.Empty;

public void Init()
{
Message = WebRadioPlayerHelper.StatusCode;
}

#region Consts

protected const string MODEL_ID_STR = "BEB5B535-15BF-4C6A-82CF-644ED5A4D8B5";
Expand All @@ -57,7 +50,6 @@ public bool CanEnterState(NavigationContext oldContext, NavigationContext newCon

public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext)
{
Init();
}

public void ExitModelContext(NavigationContext oldContext, NavigationContext newContext)
Expand Down
56 changes: 0 additions & 56 deletions Webradio/Helper/FilterInfo.cs

This file was deleted.

6 changes: 3 additions & 3 deletions Webradio/Helper/Radiostations.Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Webradio.Settings;

namespace Webradio.Helper
{
Expand Down Expand Up @@ -70,10 +71,9 @@ public static void Reset()
}
}

public static List<RadioStation> Filtered(FilterInfo filter, List<RadioStation> streams)
public static List<RadioStation> Filtered(Filter filter, List<RadioStation> streams)
{
//return (from s in streams where Contains(filter.Countrys, s.Country) && Contains(filter.Citys, s.City) from g in filter.Genres where s.Genres.Contains(g) select s).ToList();
return (from s in streams where Contains(filter.Countrys, s.Country) && Contains(filter.Citys, s.City) select s).ToList();
return streams.Where(stream => filter.Countrys.Contains(stream.Country)).Where(stream => stream.Genres.Any(genre => filter.Genres.Contains(genre))).ToList();
}

public static RadioStation ById(string id)
Expand Down
28 changes: 28 additions & 0 deletions Webradio/Models/WebradioDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ public WebradioDataModel()
{
}

#region WebradioDlgShowMessage

protected static AbstractProperty _dialogMessageProperty = new WProperty(typeof(string), "OK");

public AbstractProperty DialogMessageProperty => _dialogMessageProperty;

public static string DialogMessage
{
get => (string)_dialogMessageProperty.GetValue();
set => _dialogMessageProperty.SetValue(value);
}

#endregion

#region StreamList

protected static AbstractProperty _streamListCountProperty = new WProperty(typeof(int), 0);
Expand Down Expand Up @@ -204,6 +218,20 @@ public static string StationLanguage

#endregion

#region StationName

protected static AbstractProperty _activeFilterProperty = new WProperty(typeof(string), string.Empty);

public AbstractProperty ActiveFilterProperty => _activeFilterProperty;

public static string ActiveFilter
{
get => (string)_activeFilterProperty.GetValue();
set => _activeFilterProperty.SetValue(value);
}

#endregion

#region Track

#region TrackArtist
Expand Down
Loading

0 comments on commit 974366c

Please sign in to comment.