mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-01-19 13:52:04 +01:00
ChlFileSerializer converted to a SerializerBase subclass so it can use the same reference list logic as TV data files
This commit is contained in:
@@ -58,7 +58,6 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controller\ChlFileSerializer.cs" />
|
||||
<Compile Include="Controller\CsvFileSerializer.cs" />
|
||||
<Compile Include="Controller\Editor.cs" />
|
||||
<Compile Include="Controller\ISerializerPlugin.cs" />
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChanSort.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Reader for SamToolBox reference lists (*.chl)
|
||||
/// The file has no header, each line represents a channel and fields are separated by semi-colon:
|
||||
/// Number;Channel Name[;Transponder Index]
|
||||
/// </summary>
|
||||
public class ChlFileSerializer
|
||||
{
|
||||
private static readonly char[] Separators = new[] { ';' };
|
||||
private readonly StringBuilder warnings = new StringBuilder();
|
||||
private int lineNumber;
|
||||
private DataRoot dataRoot;
|
||||
private ChannelList channelList;
|
||||
|
||||
#region Load()
|
||||
public string Load(string fileName, DataRoot root, ChannelList list)
|
||||
{
|
||||
if (list.ReadOnly)
|
||||
return "The current channel list is read-only";
|
||||
|
||||
this.lineNumber = 0;
|
||||
this.dataRoot = root;
|
||||
this.channelList = list;
|
||||
this.warnings.Remove(0, this.warnings.Length);
|
||||
|
||||
foreach (var channel in this.channelList.Channels)
|
||||
channel.NewProgramNr = -1;
|
||||
|
||||
using (var stream = new StreamReader(fileName, Encoding.Default))
|
||||
{
|
||||
ReadChannelsFromStream(stream);
|
||||
}
|
||||
return this.warnings.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ReadChannelsFromStream()
|
||||
|
||||
private void ReadChannelsFromStream(TextReader stream)
|
||||
{
|
||||
string line;
|
||||
while ((line = stream.ReadLine()) != null)
|
||||
{
|
||||
++lineNumber;
|
||||
ParseChannel(line);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ParseChannel()
|
||||
|
||||
private void ParseChannel(string line)
|
||||
{
|
||||
var parts = line.Split(Separators);
|
||||
if (parts.Length < 2) return;
|
||||
int progNr;
|
||||
Transponder transponder = null;
|
||||
if (!int.TryParse(parts[0], out progNr)) return;
|
||||
if (parts.Length >= 3)
|
||||
{
|
||||
int transponderIndex;
|
||||
if (int.TryParse(parts[2], out transponderIndex))
|
||||
{
|
||||
transponder = this.dataRoot.Transponder.TryGet(transponderIndex);
|
||||
if (transponder == null)
|
||||
warnings.AppendFormat("Line #{0,4}: invalid transponder index {1}\r\n", this.lineNumber, transponderIndex);
|
||||
}
|
||||
}
|
||||
|
||||
string name = parts[1].Replace("\"", "");
|
||||
if (name.Trim().Length == 0)
|
||||
return;
|
||||
|
||||
int found = 0;
|
||||
var channels = channelList.GetChannelByName(name);
|
||||
if (transponder != null)
|
||||
channels = channels.Where(chan => chan.Transponder == transponder);
|
||||
|
||||
foreach(var channel in channels)
|
||||
{
|
||||
if (channel.NewProgramNr != -1)
|
||||
continue;
|
||||
++found;
|
||||
if (found > 1)
|
||||
break;
|
||||
channel.NewProgramNr = progNr;
|
||||
}
|
||||
|
||||
if (found == 0)
|
||||
this.warnings.AppendFormat("Line {0,4}: Pr# {1,4}, channel '{2}' could not be found\r\n", this.lineNumber, progNr, name);
|
||||
if (found > 1)
|
||||
this.warnings.AppendFormat("Line {0,4}: Pr# {1,4}, channel '{2}' found multiple times\r\n", this.lineNumber, progNr, name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Save()
|
||||
public void Save(string fileName, ChannelList list)
|
||||
{
|
||||
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
|
||||
{
|
||||
foreach (var channel in list.Channels.OrderBy(c => c.NewProgramNr))
|
||||
{
|
||||
if (channel.NewProgramNr == -1) continue;
|
||||
|
||||
writer.Write(channel.NewProgramNr);
|
||||
writer.Write(';');
|
||||
writer.Write(channel.Name);
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -215,14 +215,42 @@ namespace ChanSort.Api
|
||||
|
||||
public void ApplyReferenceList(DataRoot refDataRoot, ChannelList refList, ChannelList tvList, bool addProxyChannels = true, int positionOffset = 0, Predicate<ChannelInfo> chanFilter = null)
|
||||
{
|
||||
// create Hashtable for exact channel lookup
|
||||
// the UID of a TV channel list contains a source-indicator (Analog, Cable, Sat), which may be undefined in the reference list)
|
||||
var onidTsidSid = new Dictionary<long, List<ChannelInfo>>();
|
||||
foreach (var channel in tvList.Channels)
|
||||
{
|
||||
var key = DvbKey(channel.OriginalNetworkId, channel.TransportStreamId, channel.ServiceId);
|
||||
var list = onidTsidSid.TryGet(key);
|
||||
if (list == null)
|
||||
{
|
||||
list = new List<ChannelInfo>();
|
||||
onidTsidSid.Add(key, list);
|
||||
}
|
||||
list.Add(channel);
|
||||
}
|
||||
|
||||
foreach (var refChannel in refList.Channels)
|
||||
{
|
||||
if (!(chanFilter?.Invoke(refChannel) ?? true))
|
||||
continue;
|
||||
|
||||
var tvChannels = tvList.GetChannelByUid(refChannel.Uid);
|
||||
|
||||
// try to find matching channels based on ONID+TSID+SID
|
||||
if (tvChannels.Count == 0)
|
||||
{
|
||||
var key = DvbKey(refChannel.OriginalNetworkId, refChannel.TransportStreamId, refChannel.ServiceId);
|
||||
List<ChannelInfo> candidates;
|
||||
if (key != 0 && onidTsidSid.TryGetValue(key, out candidates))
|
||||
tvChannels = candidates;
|
||||
}
|
||||
|
||||
// try to find matching channels by name
|
||||
if (tvChannels.Count == 0 && !string.IsNullOrWhiteSpace(refChannel.Name))
|
||||
tvChannels = tvList.GetChannelByName(refChannel.Name).ToList();
|
||||
|
||||
// get the first unassigned channel from the candidates (e.g. when matching by non-unique names), or fall back to the first matching channel (e.g. by unique ID)
|
||||
ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.GetPosition(0) == -1);
|
||||
if (tvChannel == null && tvChannels.Count > 0)
|
||||
tvChannel = tvChannels[0];
|
||||
@@ -257,6 +285,11 @@ namespace ChanSort.Api
|
||||
}
|
||||
}
|
||||
|
||||
long DvbKey(int onid, int tsid, int sid)
|
||||
{
|
||||
return (onid << 32) | (tsid << 16) | sid;
|
||||
}
|
||||
|
||||
private void ApplyFavorites(DataRoot refDataRoot, ChannelInfo refChannel, ChannelInfo tvChannel)
|
||||
{
|
||||
if (this.DataRoot.SortedFavorites)
|
||||
|
||||
@@ -103,12 +103,20 @@ namespace ChanSort.Api
|
||||
{
|
||||
if (this.uid == null)
|
||||
{
|
||||
if ((this.SignalSource & SignalSource.Digital) == 0)
|
||||
this.uid = "A-0-" + (int)(this.FreqInMhz*20) + "-0";
|
||||
else if ((this.SignalSource & SignalSource.Sat) != 0)
|
||||
this.uid = "S" + /*this.SatPosition + */ "-" + this.OriginalNetworkId + "-" + this.TransportStreamId + "-" + this.ServiceId;
|
||||
if ((this.SignalSource & SignalSource.MaskAnalogDigital) == SignalSource.Analog)
|
||||
this.uid = "A-0-" + (int) (this.FreqInMhz*20) + "-0";
|
||||
else
|
||||
this.uid = "C-" + this.OriginalNetworkId + "-" + this.TransportStreamId + "-" + this.ServiceId + "-" + this.ChannelOrTransponder;
|
||||
{
|
||||
if ((this.SignalSource & SignalSource.MaskAntennaCableSat) == SignalSource.Sat)
|
||||
this.uid = "S" + /*this.SatPosition + */ "-" + this.OriginalNetworkId + "-" + this.TransportStreamId + "-" + this.ServiceId;
|
||||
else if ((this.SignalSource & SignalSource.MaskAntennaCableSat) == SignalSource.Antenna || (this.SignalSource & SignalSource.MaskAntennaCableSat) == SignalSource.Cable)
|
||||
{
|
||||
// ChannelOrTransponder is needed for DVB-T where the same ONID+TSID+SID can be received from 2 different towers (on different frequencies)
|
||||
this.uid = "C-" + this.OriginalNetworkId + "-" + this.TransportStreamId + "-" + this.ServiceId + "-" + this.ChannelOrTransponder;
|
||||
}
|
||||
else
|
||||
this.uid = this.OriginalNetworkId + "-" + this.TransportStreamId + "-" + this.ServiceId;
|
||||
}
|
||||
}
|
||||
return this.uid;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using ChanSort.Api;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -329,9 +330,11 @@ namespace ChanSort.Loader.Hisense
|
||||
ci.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(ci.FreqInMhz).ToString();
|
||||
|
||||
#if LOCK_LCN_LISTS
|
||||
// make the current list read-only if LCN is used
|
||||
// make the current list read-only if LCN is used
|
||||
if (r.GetInt32(i0 + 3) != 0)
|
||||
{
|
||||
this.channelLists[x - 1].ReadOnly = true;
|
||||
}
|
||||
#endif
|
||||
});
|
||||
}
|
||||
@@ -454,7 +457,10 @@ namespace ChanSort.Loader.Hisense
|
||||
{
|
||||
Editor.SequentializeFavPos(this.channelLists[6], 4);
|
||||
|
||||
using (var conn = new SQLiteConnection("Data Source=" + this.FileName))
|
||||
if (tvOutputFile != this.FileName)
|
||||
File.Copy(this.FileName, tvOutputFile, true);
|
||||
|
||||
using (var conn = new SQLiteConnection("Data Source=" + tvOutputFile))
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
@@ -475,6 +481,7 @@ namespace ChanSort.Loader.Hisense
|
||||
this.UpdateChannel(cmd, ci);
|
||||
}
|
||||
trans.Commit();
|
||||
this.FileName = tvOutputFile;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A2A5C606-167C-4FC2-87A8-2D67590B283B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ChanSort.Loader.RefList</RootNamespace>
|
||||
<AssemblyName>ChanSort.Loader.RefList</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RefSerializer.cs" />
|
||||
<Compile Include="RefSerializerPlugin.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">
|
||||
<Project>{dccffa08-472b-4d17-bb90-8f513fc01392}</Project>
|
||||
<Name>ChanSort.Api</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
36
source/ChanSort.Loader.RefList/Properties/AssemblyInfo.cs
Normal file
36
source/ChanSort.Loader.RefList/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ChanSort.Loader.RefList")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ChanSort.Loader.RefList")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a2a5c606-167c-4fc2-87a8-2d67590b283b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
147
source/ChanSort.Loader.RefList/RefSerializer.cs
Normal file
147
source/ChanSort.Loader.RefList/RefSerializer.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using ChanSort.Api;
|
||||
|
||||
namespace ChanSort.Loader.RefList
|
||||
{
|
||||
public class RefSerializer : SerializerBase
|
||||
{
|
||||
private static readonly char[] Separators = { ';' };
|
||||
|
||||
private readonly ChannelList allChannels =
|
||||
new ChannelList(SignalSource.DvbT | SignalSource.DvbC | SignalSource.DvbS | SignalSource.AnalogC | SignalSource.AnalogT | SignalSource.Tv | SignalSource.Radio, "All");
|
||||
|
||||
#region ctor()
|
||||
|
||||
public RefSerializer(string inputFile) : base(inputFile)
|
||||
{
|
||||
this.Features.ChannelNameEdit = ChannelNameEditMode.All;
|
||||
this.Features.CanSkipChannels = false;
|
||||
this.Features.CanDeleteChannels = true;
|
||||
this.Features.CanHaveGaps = true;
|
||||
this.Features.EncryptedFlagEdit = false;
|
||||
this.DataRoot.SortedFavorites = false;
|
||||
this.DataRoot.SupportedFavorites = 0;
|
||||
this.DataRoot.AddChannelList(this.allChannels);
|
||||
|
||||
allChannels.VisibleColumnFieldNames = new List<string>
|
||||
{
|
||||
"Position",
|
||||
"Name",
|
||||
"OriginalNetworkId",
|
||||
"TransportStreamId",
|
||||
"ServiceId"
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override string DisplayName => ".txt Reference List Loader";
|
||||
|
||||
#region Load()
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
this.ReadChannels();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReadChannels()
|
||||
|
||||
private void ReadChannels()
|
||||
{
|
||||
var lineNr = 0;
|
||||
|
||||
using (var file = new StreamReader(this.FileName))
|
||||
{
|
||||
string line;
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
++lineNr;
|
||||
var parts = line.Split(Separators);
|
||||
if (parts.Length < 2)
|
||||
continue;
|
||||
int progNr;
|
||||
if (!int.TryParse(parts[0], out progNr))
|
||||
continue;
|
||||
|
||||
var channel = new ChannelInfo(allChannels.SignalSource, lineNr, progNr, parts[1]);
|
||||
if (parts.Length >= 3)
|
||||
{
|
||||
var subParts = parts[2].Split('-');
|
||||
if (subParts.Length >= 3)
|
||||
{
|
||||
int val;
|
||||
if (int.TryParse(subParts[0], out val))
|
||||
channel.OriginalNetworkId = val;
|
||||
if (int.TryParse(subParts[1], out val))
|
||||
channel.TransportStreamId = val;
|
||||
if (int.TryParse(subParts[2], out val))
|
||||
channel.ServiceId = val;
|
||||
}
|
||||
}
|
||||
this.DataRoot.AddChannel(this.allChannels, channel);
|
||||
lineNr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetFileInformation()
|
||||
|
||||
public override string GetFileInformation()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(base.GetFileInformation());
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Save()
|
||||
|
||||
//public override void Save(string tvOutputFile)
|
||||
//{
|
||||
// var writer = new ChlFileSerializer();
|
||||
// writer.Save(tvOutputFile, this.allChannels);
|
||||
// this.FileName = tvOutputFile;
|
||||
//}
|
||||
|
||||
public override void Save(string tvOutputFile)
|
||||
{
|
||||
Save(tvOutputFile, this.allChannels);
|
||||
this.FileName = tvOutputFile;
|
||||
}
|
||||
|
||||
public static void Save(string fileName, ChannelList list)
|
||||
{
|
||||
var samToolBoxMode = (Path.GetExtension(fileName) ?? "").ToLower() == ".chl";
|
||||
|
||||
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
|
||||
{
|
||||
foreach (var channel in list.GetChannelsByNewOrder())
|
||||
{
|
||||
if (channel.NewProgramNr == -1) continue;
|
||||
|
||||
writer.Write(channel.NewProgramNr);
|
||||
writer.Write(Separators[0]);
|
||||
writer.Write(channel.Name);
|
||||
if (!samToolBoxMode)
|
||||
{
|
||||
writer.Write(Separators[0]);
|
||||
writer.Write(channel.OriginalNetworkId);
|
||||
writer.Write("-");
|
||||
writer.Write(channel.TransportStreamId);
|
||||
writer.Write("-");
|
||||
writer.Write(channel.ServiceId);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
16
source/ChanSort.Loader.RefList/RefSerializerPlugin.cs
Normal file
16
source/ChanSort.Loader.RefList/RefSerializerPlugin.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using ChanSort.Api;
|
||||
|
||||
namespace ChanSort.Loader.RefList
|
||||
{
|
||||
public class RefSerializerPlugin : ISerializerPlugin
|
||||
{
|
||||
public string PluginName => "ChanSort Reference List";
|
||||
|
||||
public string FileFilter => "*.txt;*.chl";
|
||||
|
||||
public SerializerBase CreateSerializer(string inputFile)
|
||||
{
|
||||
return new RefSerializer(inputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort", "ChanSort\ChanSort.csproj", "{5FAFDABC-A52F-498C-BD2F-AFFC4119797A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{33897002-0537-49A4-B963-A18D17311B3D} = {33897002-0537-49A4-B963-A18D17311B3D}
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B} = {A2A5C606-167C-4FC2-87A8-2D67590B283B}
|
||||
{74A18C6F-09FF-413E-90D9-827066FA5B36} = {74A18C6F-09FF-413E-90D9-827066FA5B36}
|
||||
{68DA8072-3A29-4076-9F64-D66F38349585} = {68DA8072-3A29-4076-9F64-D66F38349585}
|
||||
{A1C9A98D-368A-44E8-9B7F-7EACA46C9EC5} = {A1C9A98D-368A-44E8-9B7F-7EACA46C9EC5}
|
||||
@@ -45,6 +46,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Hisense", "
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Loader.Samsung", "Test.Loader.Samsung\Test.Loader.Samsung.csproj", "{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.RefList", "ChanSort.Loader.RefList\ChanSort.Loader.RefList.csproj", "{A2A5C606-167C-4FC2-87A8-2D67590B283B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -203,6 +206,18 @@ Global
|
||||
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Debug|x86.Build.0 = Debug|x86
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A2A5C606-167C-4FC2-87A8-2D67590B283B}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -306,6 +306,10 @@
|
||||
<Project>{DCCFFA08-472B-4D17-BB90-8F513FC01392}</Project>
|
||||
<Name>ChanSort.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ChanSort.Loader.RefList\ChanSort.Loader.RefList.csproj">
|
||||
<Project>{a2a5c606-167c-4fc2-87a8-2d67590b283b}</Project>
|
||||
<Name>ChanSort.Loader.RefList</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="app.ico" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -258,7 +258,7 @@
|
||||
<value>Numeric</value>
|
||||
</data>
|
||||
<data name="gridLeft.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>449, 392</value>
|
||||
<value>449, 386</value>
|
||||
</data>
|
||||
<data name="gridLeft.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
@@ -279,7 +279,7 @@
|
||||
<value>Bottom</value>
|
||||
</data>
|
||||
<data name="lblHotkeyLeft.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>2, 446</value>
|
||||
<value>2, 440</value>
|
||||
</data>
|
||||
<data name="lblHotkeyLeft.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||
<value>2, 2, 2, 2</value>
|
||||
@@ -315,7 +315,7 @@
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1450, 575</value>
|
||||
<value>1444, 569</value>
|
||||
</data>
|
||||
<data name="tabSubList.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left, Right</value>
|
||||
@@ -324,7 +324,7 @@
|
||||
<value>0, 5</value>
|
||||
</data>
|
||||
<data name="pageProgNr.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1439, 0</value>
|
||||
<value>1433, 0</value>
|
||||
</data>
|
||||
<data name="pageProgNr.Text" xml:space="preserve">
|
||||
<value>Pr#</value>
|
||||
@@ -342,7 +342,7 @@
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="tabSubList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1445, 22</value>
|
||||
<value>1439, 22</value>
|
||||
</data>
|
||||
<data name="tabSubList.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>6</value>
|
||||
@@ -366,7 +366,7 @@
|
||||
<value>0, 83</value>
|
||||
</data>
|
||||
<data name="grpSubList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1450, 27</value>
|
||||
<value>1444, 27</value>
|
||||
</data>
|
||||
<data name="grpSubList.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>10</value>
|
||||
@@ -690,7 +690,7 @@
|
||||
<value>0, 0</value>
|
||||
</data>
|
||||
<data name="barDockControlTop.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1450, 26</value>
|
||||
<value>1444, 26</value>
|
||||
</data>
|
||||
<data name=">>barDockControlTop.Name" xml:space="preserve">
|
||||
<value>barDockControlTop</value>
|
||||
@@ -708,10 +708,10 @@
|
||||
<value>Bottom</value>
|
||||
</data>
|
||||
<data name="barDockControlBottom.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>0, 575</value>
|
||||
<value>0, 569</value>
|
||||
</data>
|
||||
<data name="barDockControlBottom.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1450, 0</value>
|
||||
<value>1444, 0</value>
|
||||
</data>
|
||||
<data name=">>barDockControlBottom.Name" xml:space="preserve">
|
||||
<value>barDockControlBottom</value>
|
||||
@@ -732,7 +732,7 @@
|
||||
<value>0, 26</value>
|
||||
</data>
|
||||
<data name="barDockControlLeft.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>0, 549</value>
|
||||
<value>0, 543</value>
|
||||
</data>
|
||||
<data name=">>barDockControlLeft.Name" xml:space="preserve">
|
||||
<value>barDockControlLeft</value>
|
||||
@@ -750,10 +750,10 @@
|
||||
<value>Right</value>
|
||||
</data>
|
||||
<data name="barDockControlRight.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>1450, 26</value>
|
||||
<value>1444, 26</value>
|
||||
</data>
|
||||
<data name="barDockControlRight.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>0, 549</value>
|
||||
<value>0, 543</value>
|
||||
</data>
|
||||
<data name=">>barDockControlRight.Name" xml:space="preserve">
|
||||
<value>barDockControlRight</value>
|
||||
@@ -907,7 +907,7 @@
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="picDonate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>1272, 4</value>
|
||||
<value>1266, 4</value>
|
||||
</data>
|
||||
<data name="picDonate.Properties.Appearance.BackColor" type="System.Drawing.Color, System.Drawing">
|
||||
<value>Transparent</value>
|
||||
@@ -937,7 +937,7 @@
|
||||
<value>0, 33</value>
|
||||
</data>
|
||||
<data name="pageEmpty.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1260, 0</value>
|
||||
<value>1254, 0</value>
|
||||
</data>
|
||||
<data name="pageEmpty.Text" xml:space="preserve">
|
||||
<value>No channel lists</value>
|
||||
@@ -955,7 +955,7 @@
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="tabChannelList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1266, 22</value>
|
||||
<value>1260, 22</value>
|
||||
</data>
|
||||
<data name="tabChannelList.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
@@ -1039,7 +1039,7 @@
|
||||
<value>0, 26</value>
|
||||
</data>
|
||||
<data name="grpTopPanel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1450, 57</value>
|
||||
<value>1444, 57</value>
|
||||
</data>
|
||||
<data name="grpTopPanel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -1843,7 +1843,7 @@
|
||||
<value>DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v15.2, Version=15.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
|
||||
</data>
|
||||
<data name="SharedImageCollection.Timestamp" type="System.DateTime, mscorlib">
|
||||
<value>04/27/2016 17:52:40</value>
|
||||
<value>05/04/2016 22:31:52</value>
|
||||
</data>
|
||||
<data name="SharedImageCollection.ImageSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>16, 16</value>
|
||||
@@ -2182,7 +2182,7 @@
|
||||
<value>0, 0</value>
|
||||
</data>
|
||||
<data name="grpOutputList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>453, 465</value>
|
||||
<value>453, 459</value>
|
||||
</data>
|
||||
<data name="grpOutputList.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -2542,7 +2542,7 @@
|
||||
<value>Signal source</value>
|
||||
</data>
|
||||
<data name="gridRight.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>987, 392</value>
|
||||
<value>981, 386</value>
|
||||
</data>
|
||||
<data name="gridRight.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
@@ -2563,7 +2563,7 @@
|
||||
<value>Bottom</value>
|
||||
</data>
|
||||
<data name="lblHotkeyRight.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>2, 446</value>
|
||||
<value>2, 440</value>
|
||||
</data>
|
||||
<data name="lblHotkeyRight.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||
<value>2, 2, 2, 2</value>
|
||||
@@ -2752,7 +2752,7 @@ specific provider, satellite or country lists.</value>
|
||||
<value>2, 21</value>
|
||||
</data>
|
||||
<data name="panelControl3.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>987, 33</value>
|
||||
<value>981, 33</value>
|
||||
</data>
|
||||
<data name="panelControl3.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -2776,7 +2776,7 @@ specific provider, satellite or country lists.</value>
|
||||
<value>0, 0</value>
|
||||
</data>
|
||||
<data name="grpInputList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>991, 465</value>
|
||||
<value>985, 459</value>
|
||||
</data>
|
||||
<data name="grpInputList.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -2800,7 +2800,7 @@ specific provider, satellite or country lists.</value>
|
||||
<value>Panel2</value>
|
||||
</data>
|
||||
<data name="splitContainerControl1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1450, 465</value>
|
||||
<value>1444, 459</value>
|
||||
</data>
|
||||
<data name="splitContainerControl1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
|
||||
@@ -21,15 +21,33 @@ namespace ChanSort.Ui
|
||||
this.UpdateButtons();
|
||||
}
|
||||
|
||||
#region OnLoad()
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
this.CreateHandle();
|
||||
this.Update();
|
||||
BeginInvoke((Action) (() =>
|
||||
{
|
||||
var ser = ShowOpenFileDialog(main);
|
||||
if (ser != null)
|
||||
this.SetInput(ser);
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UpdateButtons()
|
||||
private void UpdateButtons()
|
||||
{
|
||||
this.btnOk.Visible = this.rbAuto.Checked;
|
||||
this.btnClose.Text = this.rbAuto.Checked ? "Cancel" : "Close";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ShowOpenFileDialog()
|
||||
|
||||
private SerializerBase ShowOpenFileDialog()
|
||||
private static SerializerBase ShowOpenFileDialog(MainForm main)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -45,7 +63,7 @@ namespace ChanSort.Ui
|
||||
dlg.FilterIndex = numberOfFilters + 1;
|
||||
dlg.CheckFileExists = true;
|
||||
dlg.RestoreDirectory = true;
|
||||
if (dlg.ShowDialog() != DialogResult.OK)
|
||||
if (dlg.ShowDialog(main) != DialogResult.OK)
|
||||
return null;
|
||||
|
||||
if (main.DetectCommonFileCorruptions(dlg.FileName))
|
||||
@@ -142,14 +160,19 @@ namespace ChanSort.Ui
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region edFile_ButtonClick
|
||||
|
||||
private void edFile_ButtonClick(object sender, ButtonPressedEventArgs e)
|
||||
{
|
||||
serializer = ShowOpenFileDialog();
|
||||
if (serializer == null)
|
||||
return;
|
||||
var ser = ShowOpenFileDialog(this.main);
|
||||
if (ser != null)
|
||||
SetInput(ser);
|
||||
}
|
||||
|
||||
private void SetInput(SerializerBase ser)
|
||||
{
|
||||
this.serializer = ser;
|
||||
this.edFile.Text = serializer.FileName;
|
||||
this.rbAuto.Enabled = this.rbManual.Enabled = true;
|
||||
|
||||
@@ -201,6 +224,40 @@ namespace ChanSort.Ui
|
||||
|
||||
#endregion
|
||||
|
||||
#region comboTarget_EditValueChanged
|
||||
private void comboTarget_EditValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInfoTextAndOptions();
|
||||
|
||||
// auto-select a compatible source list
|
||||
var list = (ChannelList)this.comboTarget.EditValue;
|
||||
if (list != null)
|
||||
{
|
||||
this.comboSource.SelectedIndex = -1;
|
||||
var src = list.SignalSource;
|
||||
foreach (ChannelList sourceList in this.comboSource.Properties.Items)
|
||||
{
|
||||
if ((sourceList.SignalSource & src) == src)
|
||||
{
|
||||
this.comboSource.SelectedItem = sourceList;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region comboSource_EditValueChanged
|
||||
|
||||
private void comboSource_EditValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInfoTextAndOptions();
|
||||
var list = (ChannelList)this.comboSource.EditValue;
|
||||
this.comboPrNr.Text = list == null || list.Count == 0 ? "1" : list.Channels.Min(ch => Math.Max(ch.OldProgramNr, 1)).ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region btnApply_Click
|
||||
|
||||
private void btnApply_Click(object sender, EventArgs e)
|
||||
@@ -226,36 +283,5 @@ namespace ChanSort.Ui
|
||||
|
||||
#endregion
|
||||
|
||||
private void comboTarget_EditValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInfoTextAndOptions();
|
||||
|
||||
// auto-select a compatible source list
|
||||
var list = (ChannelList)this.comboTarget.EditValue;
|
||||
if (list != null)
|
||||
{
|
||||
this.comboSource.SelectedIndex = -1;
|
||||
var src = list.SignalSource;
|
||||
foreach (ChannelList sourceList in this.comboSource.Properties.Items)
|
||||
{
|
||||
if ((sourceList.SignalSource & src) == src)
|
||||
{
|
||||
this.comboSource.SelectedItem = sourceList;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region comboSource_EditValueChanged
|
||||
|
||||
private void comboSource_EditValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInfoTextAndOptions();
|
||||
var list = (ChannelList)this.comboSource.EditValue;
|
||||
this.comboPrNr.Text = list == null || list.Count == 0 ? "1" : list.Channels.Min(ch => Math.Max(ch.OldProgramNr, 1)).ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user