diff --git a/source/ChanSort.Api/ChanSort.Api.csproj b/source/ChanSort.Api/ChanSort.Api.csproj
index 11f6e71..807ff5a 100644
--- a/source/ChanSort.Api/ChanSort.Api.csproj
+++ b/source/ChanSort.Api/ChanSort.Api.csproj
@@ -58,7 +58,6 @@
-
diff --git a/source/ChanSort.Api/Controller/ChlFileSerializer.cs b/source/ChanSort.Api/Controller/ChlFileSerializer.cs
deleted file mode 100644
index f4cebe5..0000000
--- a/source/ChanSort.Api/Controller/ChlFileSerializer.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace ChanSort.Api
-{
- ///
- /// 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]
- ///
- 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
- }
-}
diff --git a/source/ChanSort.Api/Controller/Editor.cs b/source/ChanSort.Api/Controller/Editor.cs
index 2d8bdd3..565807a 100644
--- a/source/ChanSort.Api/Controller/Editor.cs
+++ b/source/ChanSort.Api/Controller/Editor.cs
@@ -215,14 +215,42 @@ namespace ChanSort.Api
public void ApplyReferenceList(DataRoot refDataRoot, ChannelList refList, ChannelList tvList, bool addProxyChannels = true, int positionOffset = 0, Predicate 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>();
+ 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();
+ 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 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)
diff --git a/source/ChanSort.Api/Model/ChannelInfo.cs b/source/ChanSort.Api/Model/ChannelInfo.cs
index d626c63..bcf9680 100644
--- a/source/ChanSort.Api/Model/ChannelInfo.cs
+++ b/source/ChanSort.Api/Model/ChannelInfo.cs
@@ -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;
}
diff --git a/source/ChanSort.Loader.Hisense/HisDbSerializer.cs b/source/ChanSort.Loader.Hisense/HisDbSerializer.cs
index c311750..fba32a4 100644
--- a/source/ChanSort.Loader.Hisense/HisDbSerializer.cs
+++ b/source/ChanSort.Loader.Hisense/HisDbSerializer.cs
@@ -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
{
diff --git a/source/ChanSort.Loader.RefList/ChanSort.Loader.RefList.csproj b/source/ChanSort.Loader.RefList/ChanSort.Loader.RefList.csproj
new file mode 100644
index 0000000..9641c97
--- /dev/null
+++ b/source/ChanSort.Loader.RefList/ChanSort.Loader.RefList.csproj
@@ -0,0 +1,80 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {A2A5C606-167C-4FC2-87A8-2D67590B283B}
+ Library
+ Properties
+ ChanSort.Loader.RefList
+ ChanSort.Loader.RefList
+ v4.0
+ 512
+
+
+
+ true
+ full
+ false
+ ..\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dccffa08-472b-4d17-bb90-8f513fc01392}
+ ChanSort.Api
+
+
+
+
+
\ No newline at end of file
diff --git a/source/ChanSort.Loader.RefList/Properties/AssemblyInfo.cs b/source/ChanSort.Loader.RefList/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5d132e2
--- /dev/null
+++ b/source/ChanSort.Loader.RefList/Properties/AssemblyInfo.cs
@@ -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")]
diff --git a/source/ChanSort.Loader.RefList/RefSerializer.cs b/source/ChanSort.Loader.RefList/RefSerializer.cs
new file mode 100644
index 0000000..5cb5d2e
--- /dev/null
+++ b/source/ChanSort.Loader.RefList/RefSerializer.cs
@@ -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
+ {
+ "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
+ }
+}
\ No newline at end of file
diff --git a/source/ChanSort.Loader.RefList/RefSerializerPlugin.cs b/source/ChanSort.Loader.RefList/RefSerializerPlugin.cs
new file mode 100644
index 0000000..ca7215a
--- /dev/null
+++ b/source/ChanSort.Loader.RefList/RefSerializerPlugin.cs
@@ -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);
+ }
+ }
+}
diff --git a/source/ChanSort.sln b/source/ChanSort.sln
index 0df77eb..59f74bc 100644
--- a/source/ChanSort.sln
+++ b/source/ChanSort.sln
@@ -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
diff --git a/source/ChanSort/ChanSort.csproj b/source/ChanSort/ChanSort.csproj
index ea7b2ee..d317df2 100644
--- a/source/ChanSort/ChanSort.csproj
+++ b/source/ChanSort/ChanSort.csproj
@@ -306,6 +306,10 @@
{DCCFFA08-472B-4D17-BB90-8F513FC01392}
ChanSort.Api
+
+ {a2a5c606-167c-4fc2-87a8-2d67590b283b}
+ ChanSort.Loader.RefList
+
diff --git a/source/ChanSort/MainForm.cs b/source/ChanSort/MainForm.cs
index 30b37f7..61fe741 100644
--- a/source/ChanSort/MainForm.cs
+++ b/source/ChanSort/MainForm.cs
@@ -56,7 +56,7 @@ namespace ChanSort.Ui
private readonly IList plugins;
private string currentTvFile;
- private string currentCsvFile;
+ private string currentRefFile;
private ISerializerPlugin currentPlugin;
private SerializerBase currentTvSerializer;
private Editor editor;
@@ -194,8 +194,8 @@ namespace ChanSort.Ui
this.currentTvFile = tvDataFile;
if (!string.IsNullOrEmpty(tvDataFile))
{
- this.currentCsvFile = Path.Combine(Path.GetDirectoryName(this.currentTvFile) ?? "",
- Path.GetFileNameWithoutExtension(this.currentTvFile) + ".csv");
+ this.currentRefFile = Path.Combine(Path.GetDirectoryName(this.currentTvFile) ?? "",
+ Path.GetFileNameWithoutExtension(this.currentTvFile) + ".txt");
}
this.Text = this.title + " - " + Path.GetFileName(this.currentTvFile);
}
@@ -504,6 +504,7 @@ namespace ChanSort.Ui
#region ShowOpenReferenceFileDialog()
private void ShowOpenReferenceFileDialog(bool addChannels)
{
+#if false
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.Title = Resources.MainForm_ShowOpenReferenceFileDialog_Title;
@@ -541,6 +542,9 @@ namespace ChanSort.Ui
this.LoadReferenceFile(dlg.FileName, addChannels);
}
}
+#else
+ new ReferenceListForm(this).ShowDialog(this);
+#endif
}
#endregion
@@ -556,12 +560,12 @@ namespace ChanSort.Ui
var csvSerializer = new CsvFileSerializer(fileName, this.dataRoot, addChannels);
csvSerializer.Load();
}
- else if (ext == ".chl")
- {
- ChlFileSerializer loader = new ChlFileSerializer();
- string warnings = loader.Load(fileName, this.dataRoot, this.currentChannelList);
- InfoBox.Show(this, warnings, Path.GetFileName(fileName));
- }
+ //else if (ext == ".chl" || ext == ".txt")
+ //{
+ // ChlFileSerializer loader = new ChlFileSerializer();
+ // string warnings = loader.Load(fileName, this.dataRoot, this.currentChannelList);
+ // InfoBox.Show(this, warnings, Path.GetFileName(fileName));
+ //}
else
{
var plugin = this.GetPluginForFile(fileName);
@@ -581,9 +585,9 @@ namespace ChanSort.Ui
this.gviewLeft.EndDataUpdate();
}
- #endregion
+#endregion
- #region IsLeftGridSortedByNewProgNr
+#region IsLeftGridSortedByNewProgNr
private bool IsLeftGridSortedByNewProgNr
{
get
@@ -592,9 +596,9 @@ namespace ChanSort.Ui
this.gviewLeft.SortedColumns[0].FieldName == this.colOutSlot.FieldName;
}
}
- #endregion
+#endregion
- #region ShowChannelList()
+#region ShowChannelList()
private void ShowChannelList(ChannelList channelList)
{
if (this.currentChannelList != null)
@@ -663,9 +667,9 @@ namespace ChanSort.Ui
if (!this.grpSubList.Visible)
this.tabSubList.SelectedTabPageIndex = 0;
}
- #endregion
+#endregion
- #region UpdateGridReadOnly
+#region UpdateGridReadOnly
private void UpdateGridReadOnly()
{
bool allowEdit = !this.currentChannelList?.ReadOnly ?? true;
@@ -680,9 +684,9 @@ namespace ChanSort.Ui
this.lblPredefinedList.Visible = !(allowEdit || forceEdit);
}
- #endregion
+#endregion
- #region ShowSaveFileDialog()
+#region ShowSaveFileDialog()
private void ShowSaveFileDialog()
{
@@ -706,9 +710,9 @@ namespace ChanSort.Ui
}
}
- #endregion
+#endregion
- #region SaveFiles()
+#region SaveFiles()
private void SaveFiles()
{
@@ -736,9 +740,9 @@ namespace ChanSort.Ui
}
}
- #endregion
+#endregion
- #region PromptHandlingOfUnsortedChannels()
+#region PromptHandlingOfUnsortedChannels()
private bool PromptHandlingOfUnsortedChannels()
{
bool hasUnsorted = false;
@@ -774,9 +778,9 @@ namespace ChanSort.Ui
res == DialogResult.Yes ? UnsortedChannelMode.AppendInOrder : UnsortedChannelMode.MarkDeleted);
return true;
}
- #endregion
+#endregion
- #region HandleChannelNumberGaps()
+#region HandleChannelNumberGaps()
private bool HandleChannelNumberGaps()
{
if (this.currentTvSerializer.Features.CanHaveGaps)
@@ -795,9 +799,9 @@ namespace ChanSort.Ui
}
return true;
}
- #endregion
+#endregion
- #region ProcessChannelNumberGaps()
+#region ProcessChannelNumberGaps()
private bool ProcessChannelNumberGaps(bool testOnly)
{
bool wasRenumbered = false;
@@ -822,9 +826,9 @@ namespace ChanSort.Ui
}
return wasRenumbered;
}
- #endregion
+#endregion
- #region SaveReferenceFile()
+#region SaveReferenceFile()
private void SaveReferenceFile()
{
@@ -832,10 +836,10 @@ namespace ChanSort.Ui
using (var dlg = new SaveFileDialog())
{
dlg.RestoreDirectory = true;
- dlg.InitialDirectory = Path.GetDirectoryName(this.currentCsvFile);
- dlg.FileName = Path.GetFileName(this.currentCsvFile);
- dlg.DefaultExt = ".csv";
- dlg.Filter = "ChanSort|*.csv|SamToolBox|*.chl|All files|*";
+ dlg.InitialDirectory = Path.GetDirectoryName(this.currentRefFile);
+ dlg.FileName = Path.GetFileName(this.currentRefFile);
+ dlg.DefaultExt = ".txt";
+ dlg.Filter = "ChanSort Single-List|*.txt|ChanSort Multi-List|*.csv|SamToolBox|*.chl|All files|*";
dlg.FilterIndex = 1;
dlg.CheckPathExists = true;
dlg.CheckFileExists = false;
@@ -848,13 +852,13 @@ namespace ChanSort.Ui
string ext = (Path.GetExtension(fileName)??"").ToLower();
if (ext == ".csv")
new CsvFileSerializer(fileName, this.dataRoot, false).Save();
- else if (ext == ".chl")
- new ChlFileSerializer().Save(fileName, this.currentChannelList);
+ else if (ext == ".chl" || ext == ".txt")
+ Loader.RefList.RefSerializer.Save(fileName, this.currentChannelList);
}
- #endregion
+#endregion
- #region SaveTvDataFile()
+#region SaveTvDataFile()
private void SaveTvDataFile()
{
@@ -886,9 +890,9 @@ namespace ChanSort.Ui
this.splashScreenManager1.CloseWaitForm();
}
}
- #endregion
+#endregion
- #region AddChannels()
+#region AddChannels()
private void AddChannels()
{
var selectedChannels = this.GetSelectedChannels(gviewRight);
@@ -923,9 +927,9 @@ namespace ChanSort.Ui
++rowHandle;
this.SelectFocusedRow(this.gviewLeft, rowHandle);
}
- #endregion
+#endregion
- #region RemoveChannels()
+#region RemoveChannels()
private void RemoveChannels(GridView grid, bool closeGap)
{
@@ -951,9 +955,9 @@ namespace ChanSort.Ui
this.UpdateInsertSlotTextBox();
}
- #endregion
+#endregion
- #region SelectFocusedRow()
+#region SelectFocusedRow()
private void SelectFocusedRow(GridView grid, int rowHandle)
{
grid.BeginSelection();
@@ -962,9 +966,9 @@ namespace ChanSort.Ui
grid.SelectRow(rowHandle);
grid.EndSelection();
}
- #endregion
+#endregion
- #region MoveChannels()
+#region MoveChannels()
private void MoveChannels(bool up)
{
@@ -984,9 +988,9 @@ namespace ChanSort.Ui
this.UpdateInsertSlotNumber();
}
- #endregion
+#endregion
- #region SetSlotNumber()
+#region SetSlotNumber()
private bool SetSlotNumber(string progNr)
{
int prog;
@@ -1007,9 +1011,9 @@ namespace ChanSort.Ui
}
return true;
}
- #endregion
+#endregion
- #region SortSelectedChannels()
+#region SortSelectedChannels()
private void SortSelectedChannels()
{
var selectedChannels = this.GetSelectedChannels(this.gviewLeft);
@@ -1026,9 +1030,9 @@ namespace ChanSort.Ui
this.gviewLeft.EndDataUpdate();
}
}
- #endregion
+#endregion
- #region AddAllUnsortedChannels()
+#region AddAllUnsortedChannels()
private void AddAllUnsortedChannels()
{
if (this.currentChannelList == null) return;
@@ -1049,9 +1053,9 @@ namespace ChanSort.Ui
this.gviewRight.EndDataUpdate();
this.gviewLeft.EndDataUpdate();
}
- #endregion
+#endregion
- #region RenumberSelectedChannels()
+#region RenumberSelectedChannels()
private void RenumberSelectedChannels()
{
var list = this.GetSelectedChannels(this.gviewLeft);
@@ -1062,9 +1066,9 @@ namespace ChanSort.Ui
this.gviewLeft.EndDataUpdate();
this.gviewRight.EndDataUpdate();
}
- #endregion
+#endregion
- #region GetSelectedChannels()
+#region GetSelectedChannels()
private List GetSelectedChannels(GridView gview)
{
var channels = new List();
@@ -1075,9 +1079,9 @@ namespace ChanSort.Ui
}
return channels;
}
- #endregion
+#endregion
- #region TryExecute()
+#region TryExecute()
private void TryExecute(Action action)
{
@@ -1085,16 +1089,16 @@ namespace ChanSort.Ui
catch (Exception ex) { HandleException(ex); }
}
- #endregion
+#endregion
- #region HandleException()
+#region HandleException()
public static void HandleException(Exception ex)
{
XtraMessageBox.Show(string.Format(Resources.MainForm_TryExecute_Exception, ex));
}
- #endregion
+#endregion
- #region LoadSettings()
+#region LoadSettings()
private void LoadSettings()
{
@@ -1122,9 +1126,9 @@ namespace ChanSort.Ui
}
this.UpdateMruMenu();
}
- #endregion
+#endregion
- #region SelectLanguageMenuItem()
+#region SelectLanguageMenuItem()
private void SelectLanguageMenuItem()
{
this.barManager1.ForceLinkCreate();
@@ -1139,9 +1143,9 @@ namespace ChanSort.Ui
}
}
}
- #endregion
+#endregion
- #region SetGridLayout()
+#region SetGridLayout()
private void SetGridLayout(GridView grid, string layout)
{
if (string.IsNullOrEmpty(layout)) return;
@@ -1166,9 +1170,9 @@ namespace ChanSort.Ui
this.gviewRight.SetRowCellValue(GridControl.AutoFilterRowHandle, col, parts[1]);
}
}
- #endregion
+#endregion
- #region SaveSettings(), GetGridLayout()
+#region SaveSettings(), GetGridLayout()
private void SaveSettings()
{
this.gviewRight.PostEditor();
@@ -1198,9 +1202,9 @@ namespace ChanSort.Ui
return rdr.ReadToEnd();
}
- #endregion
+#endregion
- #region UpdateInsertSlotNumber()
+#region UpdateInsertSlotNumber()
private void UpdateInsertSlotNumber()
{
var channel = (ChannelInfo)this.gviewLeft.GetFocusedRow();
@@ -1218,17 +1222,17 @@ namespace ChanSort.Ui
this.UpdateInsertSlotTextBox();
this.gviewLeft.SelectRow(this.gviewLeft.FocusedRowHandle);
}
- #endregion
+#endregion
- #region UpdateInsertSlotTextBox()
+#region UpdateInsertSlotTextBox()
private void UpdateInsertSlotTextBox()
{
int programNr = this.currentChannelList == null ? 0 : this.currentChannelList.InsertProgramNumber;
this.txtSetSlot.Text = programNr.ToString();
}
- #endregion
+#endregion
- #region FillMenuWithIsoEncodings()
+#region FillMenuWithIsoEncodings()
private void FillMenuWithIsoEncodings()
{
this.miIsoCharSets.Strings.Clear();
@@ -1241,9 +1245,9 @@ namespace ChanSort.Ui
this.isoEncodings.Add(encoding.Name);
}
}
- #endregion
+#endregion
- #region ShowCharsetForm()
+#region ShowCharsetForm()
private void ShowCharsetForm()
{
using (var form = new CharsetForm(this.defaultEncoding))
@@ -1253,9 +1257,9 @@ namespace ChanSort.Ui
form.ShowDialog(this);
}
}
- #endregion
+#endregion
- #region SetDefaultEncoding()
+#region SetDefaultEncoding()
private void SetDefaultEncoding(Encoding encoding)
{
this.defaultEncoding = encoding;
@@ -1267,9 +1271,9 @@ namespace ChanSort.Ui
this.gviewRight.EndDataUpdate();
this.gviewLeft.EndDataUpdate();
}
- #endregion
+#endregion
- #region ClearLeftFilter(), ClearRightFilter()
+#region ClearLeftFilter(), ClearRightFilter()
private void ClearLeftFilter()
{
this.gviewLeft.BeginSort();
@@ -1287,9 +1291,9 @@ namespace ChanSort.Ui
this.colPrNr.FilterInfo = new ColumnFilterInfo("[NewProgramNr]<>-1");
this.gviewRight.EndSort();
}
- #endregion
+#endregion
- #region LoadInputGridLayout()
+#region LoadInputGridLayout()
private void LoadInputGridLayout()
{
#if false
@@ -1310,18 +1314,18 @@ namespace ChanSort.Ui
this.ShowGridColumns(this.gviewRight);
this.ClearRightFilter();
}
- #endregion
+#endregion
- #region ShowGridColumns()
+#region ShowGridColumns()
private void ShowGridColumns(GridView gview)
{
int visIndex = 0;
foreach (GridColumn col in gview.Columns)
col.VisibleIndex = GetGridColumnVisibility(col) ? visIndex++ : -1;
}
- #endregion
+#endregion
- #region SaveInputGridLayout()
+#region SaveInputGridLayout()
private void SaveInputGridLayout(SignalSource signalSource)
{
string currentLayout = GetGridLayout(this.gviewRight);
@@ -1332,9 +1336,9 @@ namespace ChanSort.Ui
else //if ((signalSource & SignalSource.DvbCT) != 0)
Settings.Default.InputGridLayoutDvbCT = currentLayout;
}
- #endregion
+#endregion
- #region GetGridColumnVisibility()
+#region GetGridColumnVisibility()
private bool GetGridColumnVisibility(GridColumn col)
{
@@ -1372,9 +1376,9 @@ namespace ChanSort.Ui
return true;
}
- #endregion
+#endregion
- #region SetFavorite()
+#region SetFavorite()
private void SetFavorite(string fav, bool set)
{
if (string.IsNullOrEmpty(fav)) return;
@@ -1389,9 +1393,9 @@ namespace ChanSort.Ui
this.gviewRight.EndDataUpdate();
this.gviewLeft.EndDataUpdate();
}
- #endregion
+#endregion
- #region SetChannelFlag()
+#region SetChannelFlag()
private void SetChannelFlag(Action setFlag)
{
var list = this.GetSelectedChannels(this.lastFocusedGrid);
@@ -1405,9 +1409,9 @@ namespace ChanSort.Ui
this.gviewLeft.EndDataUpdate();
this.dataRoot.NeedsSaving = true;
}
- #endregion
+#endregion
- #region NavigateToChannel
+#region NavigateToChannel
private void NavigateToChannel(ChannelInfo channel, GridView view)
{
if (channel == null) return;
@@ -1418,9 +1422,9 @@ namespace ChanSort.Ui
view.MakeRowVisible(rowHandle);
}
}
- #endregion
+#endregion
- #region SetActiveGrid()
+#region SetActiveGrid()
private void SetActiveGrid(GridView grid)
{
if (grid == this.gviewLeft)
@@ -1439,9 +1443,9 @@ namespace ChanSort.Ui
}
this.UpdateMenu();
}
- #endregion
+#endregion
- #region UpdateMenu
+#region UpdateMenu
private void UpdateMenu()
{
bool fileLoaded = this.dataRoot != null;
@@ -1499,9 +1503,9 @@ namespace ChanSort.Ui
this.txtSetSlot.Enabled = mayEdit;
}
- #endregion
+#endregion
- #region UpdateMruMenu()
+#region UpdateMruMenu()
private void UpdateMruMenu()
{
this.miRecentFiles.Strings.Clear();
@@ -1513,9 +1517,9 @@ namespace ChanSort.Ui
this.miRecentFiles.Strings.Add(key);
}
}
- #endregion
+#endregion
- #region RestoreBackupFile()
+#region RestoreBackupFile()
private void RestoreBackupFile()
{
var bakFile = this.currentTvFile + ".bak";
@@ -1550,9 +1554,9 @@ namespace ChanSort.Ui
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
- #endregion
+#endregion
- #region ShowFileInformation()
+#region ShowFileInformation()
private void ShowFileInformation()
{
if (this.currentTvSerializer == null)
@@ -1569,17 +1573,17 @@ namespace ChanSort.Ui
InfoBox.Show(this, info, this.miFileInformation.Caption.Replace("...", "").Replace("&",""));
}
- #endregion
+#endregion
- #region VerifyChannelNameModified()
+#region VerifyChannelNameModified()
private void VerifyChannelNameModified(ChannelInfo info, string newName)
{
if (newName != info.Name)
info.IsNameModified = true;
}
- #endregion
+#endregion
- #region RefreshGrid()
+#region RefreshGrid()
internal void RefreshGrids()
{
@@ -1594,17 +1598,17 @@ namespace ChanSort.Ui
grid.EndDataUpdate();
}
}
- #endregion
+#endregion
- #region ShowTvCountrySettings()
+#region ShowTvCountrySettings()
private void ShowTvCountrySettings()
{
if (this.currentTvSerializer != null)
this.currentTvSerializer.ShowDeviceSettingsForm(this);
}
- #endregion
+#endregion
- #region ToggleFavorite()
+#region ToggleFavorite()
private void ToggleFavorite(string fav)
{
var list = this.GetSelectedChannels(this.gviewLeft);
@@ -1613,9 +1617,9 @@ namespace ChanSort.Ui
this.SetFavorite(fav, (list[0].Favorites&value) == 0);
this.RefreshGrid(gviewLeft, gviewRight);
}
- #endregion
+#endregion
- #region ToggleLock()
+#region ToggleLock()
private void ToggleLock()
{
var list = this.GetSelectedChannels(this.gviewLeft);
@@ -1625,9 +1629,9 @@ namespace ChanSort.Ui
channel.Lock = setLock;
this.RefreshGrid(gviewLeft, gviewRight);
}
- #endregion
+#endregion
- #region RenameChannel()
+#region RenameChannel()
private void RenameChannel()
{
if (this.lastFocusedGrid == null) return;
@@ -1639,9 +1643,9 @@ namespace ChanSort.Ui
this.dontOpenEditor = false;
this.lastFocusedGrid.ShowEditor();
}
- #endregion
+#endregion
- #region CleanupChannelData()
+#region CleanupChannelData()
private void CleanupChannelData()
{
if (this.currentTvSerializer != null && this.currentTvSerializer.Features.CleanUpChannelData)
@@ -1652,9 +1656,9 @@ namespace ChanSort.Ui
this.RefreshGrid(gviewLeft, gviewRight);
}
}
- #endregion
+#endregion
- #region ExportExcelList()
+#region ExportExcelList()
private void ExportExcelList()
{
const string header = "List;Pr#;Channel Name;Favorites;Lock;Skip;Hide;Encrypted;Satellite;Ch/Tp;Freq;ONID;TSID;SymRate;SID;VPID;APID";
@@ -1696,17 +1700,17 @@ namespace ChanSort.Ui
this.miExcelExport.Caption,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
- #endregion
+#endregion
- #region Print()
+#region Print()
private void Print()
{
using (var dlg = new Printing.ReportOptionsDialog(this.currentChannelList, this.subListIndex))
dlg.ShowDialog(this);
}
- #endregion
+#endregion
- #region Accessibility
+#region Accessibility
private void FocusRightList()
{
@@ -1740,19 +1744,19 @@ namespace ChanSort.Ui
this.gridLeft.Focus();
}
- #endregion
+#endregion
// UI events
- #region MainForm_Load
+#region MainForm_Load
private void MainForm_Load(object sender, EventArgs e)
{
this.TryExecute(this.LoadSettings);
this.TryExecute(this.InitAppAfterMainWindowWasShown);
}
- #endregion
+#endregion
- #region ProcessCmdKey()
+#region ProcessCmdKey()
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.F1)
@@ -1768,11 +1772,11 @@ namespace ChanSort.Ui
}
return base.ProcessCmdKey(ref msg, keyData);
}
- #endregion
+#endregion
// -- menus
- #region File menu
+#region File menu
private void miOpen_ItemClick(object sender, ItemClickEventArgs e)
{
@@ -1781,12 +1785,7 @@ namespace ChanSort.Ui
private void miOpenReferenceFile_ItemClick(object sender, ItemClickEventArgs e)
{
- //this.TryExecute(() => this.ShowOpenReferenceFileDialog(false));
- this.TryExecute(() =>
- {
- using (var form = new ReferenceListForm(this))
- form.ShowDialog(this);
- });
+ this.TryExecute(() => this.ShowOpenReferenceFileDialog(false));
}
private void miAddFromRefList_ItemClick(object sender, ItemClickEventArgs e)
@@ -1844,9 +1843,9 @@ namespace ChanSort.Ui
TryExecute(()=>this.LoadFiles(null, this.mruFiles[e.Index]));
}
- #endregion
+#endregion
- #region Edit menu
+#region Edit menu
private void miMoveDown_ItemClick(object sender, ItemClickEventArgs e)
{
@@ -1919,9 +1918,9 @@ namespace ChanSort.Ui
{
this.TryExecute(() => this.SetChannelFlag(ch => ch.Hidden = false));
}
- #endregion
+#endregion
- #region Language menu
+#region Language menu
private void miLanguage_DownChanged(object sender, ItemClickEventArgs e)
{
try
@@ -1940,9 +1939,9 @@ namespace ChanSort.Ui
}
catch (Exception ex) { HandleException(ex); }
}
- #endregion
+#endregion
- #region TV-Set menu
+#region TV-Set menu
private void miTvCountrySetup_ItemClick(object sender, ItemClickEventArgs e)
{
this.TryExecute(this.ShowTvCountrySettings);
@@ -1953,9 +1952,9 @@ namespace ChanSort.Ui
this.TryExecute(this.CleanupChannelData);
}
- #endregion
+#endregion
- #region Character set menu
+#region Character set menu
private void miIsoCharSets_ListItemClick(object sender, ListItemClickEventArgs e)
{
@@ -1971,9 +1970,9 @@ namespace ChanSort.Ui
{
SetDefaultEncoding(e.Encoding);
}
- #endregion
+#endregion
- #region Help menu
+#region Help menu
private void miWiki_ItemClick(object sender, ItemClickEventArgs e)
{
@@ -1989,9 +1988,9 @@ namespace ChanSort.Ui
{
TryExecute(() => new AboutForm(this.plugins).ShowDialog());
}
- #endregion
+#endregion
- #region Accessibility menu
+#region Accessibility menu
private void miInputSource_ItemClick(object sender, ItemClickEventArgs e)
{
@@ -2029,25 +2028,25 @@ namespace ChanSort.Ui
TryExecute(this.FocusRightList);
}
- #endregion
+#endregion
// -- controls
- #region picDonate_Click
+#region picDonate_Click
private void picDonate_Click(object sender, EventArgs e)
{
BrowserHelper.OpenHtml(Resources.paypal_button);
}
- #endregion
+#endregion
- #region tabChannelList_SelectedPageChanged
+#region tabChannelList_SelectedPageChanged
private void tabChannelList_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
{
this.TryExecute(() => ShowChannelList(e.Page == null ? null : (ChannelList)e.Page.Tag));
}
- #endregion
+#endregion
- #region tabSubList_SelectedPageChanged
+#region tabSubList_SelectedPageChanged
private void tabSubList_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
{
this.subListIndex = this.tabSubList.SelectedTabPageIndex;
@@ -2063,9 +2062,9 @@ namespace ChanSort.Ui
this.colPrNr.ClearFilter();
this.gviewRight.EndSort();
}
- #endregion
+#endregion
- #region gview_CustomUnboundColumnData
+#region gview_CustomUnboundColumnData
private void gview_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
{
var channel = (ChannelInfo) e.Row;
@@ -2074,9 +2073,9 @@ namespace ChanSort.Ui
else if (e.Column.FieldName == "OldPosition")
e.Value = channel.GetOldPosition(this.subListIndex);
}
- #endregion
+#endregion
- #region gview_MouseDown, gview_MouseUp, timerEditDelay_Tick, gview_ShowingEditor
+#region gview_MouseDown, gview_MouseUp, timerEditDelay_Tick, gview_ShowingEditor
// these 4 event handler in combination override the default row-selection and editor-opening
// behavior of the grid control.
@@ -2135,9 +2134,9 @@ namespace ChanSort.Ui
if (this.dontOpenEditor && (field == this.colSlotNew.FieldName || field == this.colName.FieldName))
e.Cancel = true;
}
- #endregion
+#endregion
- #region gview_ShownEditor, gview_KeyPress
+#region gview_ShownEditor, gview_KeyPress
private void gview_ShownEditor(object sender, EventArgs e)
{
@@ -2153,9 +2152,9 @@ namespace ChanSort.Ui
if (view.FocusedColumn.DisplayFormat.FormatType == FormatType.Numeric && (e.KeyChar < '0' || e.KeyChar > '9'))
e.Handled = true;
}
- #endregion
+#endregion
- #region gview_MouseMove
+#region gview_MouseMove
private void gview_MouseMove(object sender, MouseEventArgs e)
{
try
@@ -2180,9 +2179,9 @@ namespace ChanSort.Ui
}
catch (Exception ex) { HandleException(ex); }
}
- #endregion
+#endregion
- #region grid_GiveFeedback
+#region grid_GiveFeedback
private void grid_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
// this event is called on the source of the drag operation
@@ -2201,9 +2200,9 @@ namespace ChanSort.Ui
else
Cursor.Current = Cursors.No;
}
- #endregion
+#endregion
- #region gridLeft_DragOver
+#region gridLeft_DragOver
private void gridLeft_DragOver(object sender, DragEventArgs e)
{
if (this.dragDropInfo == null) // drag operation from outside ChanSort
@@ -2237,9 +2236,9 @@ namespace ChanSort.Ui
e.Effect = DragDropEffects.None;
this.dragDropInfo.DropRowHandle = GridControl.InvalidRowHandle;
}
- #endregion
+#endregion
- #region gridLeft_DragDrop
+#region gridLeft_DragDrop
private void gridLeft_DragDrop(object sender, DragEventArgs e)
{
try
@@ -2273,9 +2272,9 @@ namespace ChanSort.Ui
HandleException(ex);
}
}
- #endregion
+#endregion
- #region gridLeft_ProcessGridKey
+#region gridLeft_ProcessGridKey
private void gridLeft_ProcessGridKey(object sender, KeyEventArgs e)
{
if (this.currentChannelList != null && this.currentChannelList.ReadOnly)
@@ -2293,25 +2292,25 @@ namespace ChanSort.Ui
e.Handled = true;
e.SuppressKeyPress = true;
}
- #endregion
+#endregion
- #region gviewLeft_FocusedRowChanged
+#region gviewLeft_FocusedRowChanged
private void gviewLeft_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
{
TryExecute(UpdateInsertSlotNumber);
}
- #endregion
+#endregion
- #region gviewLeft_SelectionChanged
+#region gviewLeft_SelectionChanged
private void gviewLeft_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
{
this.UpdateMenu();
}
- #endregion
+#endregion
- #region gviewLeft_CustomColumnDisplayText
+#region gviewLeft_CustomColumnDisplayText
private void gviewLeft_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
{
if (e.Column == this.colOutFav)
@@ -2321,9 +2320,9 @@ namespace ChanSort.Ui
e.DisplayText = string.Empty;
}
}
- #endregion
+#endregion
- #region gviewLeft_RowCellStyle
+#region gviewLeft_RowCellStyle
private void gviewLeft_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
var channel = (ChannelInfo)this.gviewLeft.GetRow(e.RowHandle);
@@ -2344,9 +2343,9 @@ namespace ChanSort.Ui
e.Appearance.Options.UseForeColor = true;
}
}
- #endregion
+#endregion
- #region gviewLeft_ValidatingEditor
+#region gviewLeft_ValidatingEditor
private void gviewLeft_ValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e)
{
try
@@ -2366,17 +2365,17 @@ namespace ChanSort.Ui
}
catch (Exception ex) { HandleException(ex); }
}
- #endregion
+#endregion
- #region gviewLeft_CellValueChanged
+#region gviewLeft_CellValueChanged
private void gviewLeft_CellValueChanged(object sender, CellValueChangedEventArgs e)
{
this.gviewRight.BeginDataUpdate();
this.gviewRight.EndDataUpdate();
}
- #endregion
+#endregion
- #region gviewLeft_PopupMenuShowing
+#region gviewLeft_PopupMenuShowing
private void gviewLeft_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
this.lastFocusedGrid = this.gviewLeft;
@@ -2384,9 +2383,9 @@ namespace ChanSort.Ui
if (e.MenuType == GridMenuType.Row && e.HitInfo.InRow && this.gviewLeft.IsDataRow(e.HitInfo.RowHandle))
this.popupContext.ShowPopup(this.gridLeft.PointToScreen(e.Point));
}
- #endregion
+#endregion
- #region gviewLeft_RowClick
+#region gviewLeft_RowClick
private void gviewLeft_RowClick(object sender, RowClickEventArgs e)
{
if (e.Clicks == 2 && e.Button == MouseButtons.Left && this.gviewLeft.IsDataRow(e.RowHandle))
@@ -2395,16 +2394,16 @@ namespace ChanSort.Ui
this.NavigateToChannel(channel, this.gviewRight);
}
}
- #endregion
+#endregion
- #region gviewLeft_EndSorting
+#region gviewLeft_EndSorting
private void gviewLeft_EndSorting(object sender, EventArgs e)
{
TryExecute(this.UpdateMenu);
}
- #endregion
+#endregion
- #region gviewLeft_LayoutUpgrade, gviewRight_LayoutUpgrade
+#region gviewLeft_LayoutUpgrade, gviewRight_LayoutUpgrade
private void gviewLeft_LayoutUpgrade(object sender, LayoutUpgradeEventArgs e)
{
this.gviewLeft.ClearGrouping();
@@ -2416,9 +2415,9 @@ namespace ChanSort.Ui
this.gviewRight.ClearGrouping();
this.gviewRight.OptionsCustomization.AllowGroup = false;
}
- #endregion
+#endregion
- #region gridRight_ProcessGridKey
+#region gridRight_ProcessGridKey
private void gridRight_ProcessGridKey(object sender, KeyEventArgs e)
{
if (this.gviewRight.ActiveEditor != null)
@@ -2430,16 +2429,16 @@ namespace ChanSort.Ui
}
}
- #endregion
+#endregion
- #region gviewRight_FocusedRowChanged
+#region gviewRight_FocusedRowChanged
private void gviewRight_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
{
this.gviewRight.SelectRow(e.FocusedRowHandle);
}
- #endregion
+#endregion
- #region gviewRight_CustomColumnDisplayText
+#region gviewRight_CustomColumnDisplayText
private void gviewRight_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
{
if (e.Column == this.colSlotNew || e.Column == this.colSlotOld || e.Column == this.colPrNr)
@@ -2455,9 +2454,9 @@ namespace ChanSort.Ui
e.DisplayText = string.Empty;
}
}
- #endregion
+#endregion
- #region gviewRight_RowCellStyle
+#region gviewRight_RowCellStyle
private void gviewRight_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
ChannelInfo channel = (ChannelInfo)this.gviewRight.GetRow(e.RowHandle);
@@ -2473,17 +2472,17 @@ namespace ChanSort.Ui
e.Appearance.Options.UseForeColor = true;
}
}
- #endregion
+#endregion
- #region gviewRight_RowClick
+#region gviewRight_RowClick
private void gviewRight_RowClick(object sender, RowClickEventArgs e)
{
if (e.Clicks == 2 && e.Button == MouseButtons.Left && this.gviewRight.IsDataRow(e.RowHandle))
TryExecute(this.AddChannels);
}
- #endregion
+#endregion
- #region gviewRight_ValidatingEditor
+#region gviewRight_ValidatingEditor
private void gviewRight_ValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e)
{
try
@@ -2503,16 +2502,16 @@ namespace ChanSort.Ui
dataRoot.NeedsSaving = true;
} catch(Exception ex) { HandleException(ex); }
}
- #endregion
+#endregion
- #region gviewRight_CellValueChanged
+#region gviewRight_CellValueChanged
private void gviewRight_CellValueChanged(object sender, CellValueChangedEventArgs e)
{
TryExecute(() => RefreshGrid(this.gviewLeft));
}
- #endregion
+#endregion
- #region gviewRight_PopupMenuShowing
+#region gviewRight_PopupMenuShowing
private void gviewRight_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
this.lastFocusedGrid = this.gviewRight;
@@ -2520,10 +2519,10 @@ namespace ChanSort.Ui
if (e.MenuType == GridMenuType.Row)
this.popupContext.ShowPopup(this.gridRight.PointToScreen(e.Point));
}
- #endregion
+#endregion
- #region rbInsertMode_CheckedChanged
+#region rbInsertMode_CheckedChanged
private void rbInsertMode_CheckedChanged(object sender, EventArgs e)
{
if (!((CheckEdit)sender).Checked)
@@ -2541,9 +2540,9 @@ namespace ChanSort.Ui
: EditMode.Swap;
} catch(Exception ex) { HandleException(ex); }
}
- #endregion
+#endregion
- #region btnClearLeftFilter_Click, btnClearRightFilter_Click
+#region btnClearLeftFilter_Click, btnClearRightFilter_Click
private void btnClearLeftFilter_Click(object sender, EventArgs e)
{
TryExecute(this.ClearLeftFilter);
@@ -2553,17 +2552,17 @@ namespace ChanSort.Ui
{
TryExecute(this.ClearRightFilter);
}
- #endregion
+#endregion
- #region btnAdd_Click
+#region btnAdd_Click
private void btnAdd_Click(object sender, EventArgs e)
{
TryExecute(this.AddChannels);
}
- #endregion
+#endregion
- #region btnRemoveLeft_Click, btnRemoveRight_Click
+#region btnRemoveLeft_Click, btnRemoveRight_Click
private void btnRemoveLeft_Click(object sender, EventArgs e)
{
@@ -2574,9 +2573,9 @@ namespace ChanSort.Ui
{
this.TryExecute(() => this.RemoveChannels(this.gviewRight, this.cbCloseGap.Checked));
}
- #endregion
+#endregion
- #region btnUp_Click, btnDown_Click
+#region btnUp_Click, btnDown_Click
private void btnUp_Click(object sender, EventArgs e)
{
@@ -2588,9 +2587,9 @@ namespace ChanSort.Ui
TryExecute(() => MoveChannels(false));
}
- #endregion
+#endregion
- #region txtSetSlot_EditValueChanged
+#region txtSetSlot_EditValueChanged
private void txtSetSlot_EditValueChanged(object sender, EventArgs e)
{
TryExecute(() =>
@@ -2601,9 +2600,9 @@ namespace ChanSort.Ui
this.currentChannelList.InsertProgramNumber = nr;
});
}
- #endregion
+#endregion
- #region txtSetSlot_ButtonClick, txtSetSlot_KeyDown
+#region txtSetSlot_ButtonClick, txtSetSlot_KeyDown
private void txtSetSlot_ButtonClick(object sender, ButtonPressedEventArgs e)
{
TryExecute(() => this.SetSlotNumber(this.txtSetSlot.Text));
@@ -2617,16 +2616,16 @@ namespace ChanSort.Ui
e.Handled = true;
}
}
- #endregion
+#endregion
- #region btnRenum_Click
+#region btnRenum_Click
private void btnRenum_Click(object sender, EventArgs e)
{
TryExecute(this.RenumberSelectedChannels);
}
- #endregion
+#endregion
- #region MainForm_FormClosing
+#region MainForm_FormClosing
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (this.PromptSaveAndContinue())
@@ -2634,16 +2633,16 @@ namespace ChanSort.Ui
else
e.Cancel = true;
}
- #endregion
+#endregion
- #region btnAddAll_Click
+#region btnAddAll_Click
private void btnAddAll_Click(object sender, EventArgs e)
{
this.TryExecute(this.AddAllUnsortedChannels);
}
- #endregion
+#endregion
- #region btnToggleFav_Click, btnToggleLock_Click
+#region btnToggleFav_Click, btnToggleLock_Click
private void btnToggleFav_Click(object sender, EventArgs e)
{
string fav = ((Control) sender).Text.Substring(1);
@@ -2654,9 +2653,9 @@ namespace ChanSort.Ui
{
this.TryExecute(this.ToggleLock);
}
- #endregion
+#endregion
- #region grpOutputList_Enter, grpInputList_Enter
+#region grpOutputList_Enter, grpInputList_Enter
private void grpOutputList_Enter(object sender, EventArgs e)
{
this.SetActiveGrid(this.gviewLeft);
@@ -2666,18 +2665,18 @@ namespace ChanSort.Ui
{
this.SetActiveGrid(this.gviewRight);
}
- #endregion
+#endregion
- #region miRenumFavByPrNr_ItemClick
+#region miRenumFavByPrNr_ItemClick
private void miRenumFavByPrNr_ItemClick(object sender, ItemClickEventArgs e)
{
TryExecute(this.editor.ApplyPrNrToFavLists);
this.RefreshGrid(this.gviewLeft, this.gviewRight);
}
- #endregion
+#endregion
- #region miAllowEditPredefinedLists_DownChanged
+#region miAllowEditPredefinedLists_DownChanged
private void miAllowEditPredefinedLists_DownChanged(object sender, ItemClickEventArgs e)
{
TryExecute(() =>
@@ -2686,6 +2685,6 @@ namespace ChanSort.Ui
this.UpdateMenu();
});
}
- #endregion
+#endregion
}
}
diff --git a/source/ChanSort/MainForm.resx b/source/ChanSort/MainForm.resx
index 542526a..3d922f8 100644
--- a/source/ChanSort/MainForm.resx
+++ b/source/ChanSort/MainForm.resx
@@ -258,7 +258,7 @@
Numeric
- 449, 392
+ 449, 386
1
@@ -279,7 +279,7 @@
Bottom
- 2, 446
+ 2, 440
2, 2, 2, 2
@@ -315,7 +315,7 @@
6, 13
- 1450, 575
+ 1444, 569
Bottom, Left, Right
@@ -324,7 +324,7 @@
0, 5
- 1439, 0
+ 1433, 0
Pr#
@@ -342,7 +342,7 @@
0
- 1445, 22
+ 1439, 22
6
@@ -366,7 +366,7 @@
0, 83
- 1450, 27
+ 1444, 27
10
@@ -690,7 +690,7 @@
0, 0
- 1450, 26
+ 1444, 26
barDockControlTop
@@ -708,10 +708,10 @@
Bottom
- 0, 575
+ 0, 569
- 1450, 0
+ 1444, 0
barDockControlBottom
@@ -732,7 +732,7 @@
0, 26
- 0, 549
+ 0, 543
barDockControlLeft
@@ -750,10 +750,10 @@
Right
- 1450, 26
+ 1444, 26
- 0, 549
+ 0, 543
barDockControlRight
@@ -907,7 +907,7 @@
Top, Right
- 1272, 4
+ 1266, 4
Transparent
@@ -937,7 +937,7 @@
0, 33
- 1260, 0
+ 1254, 0
No channel lists
@@ -955,7 +955,7 @@
0
- 1266, 22
+ 1260, 22
5
@@ -1039,7 +1039,7 @@
0, 26
- 1450, 57
+ 1444, 57
0
@@ -1843,7 +1843,7 @@
DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v15.2, Version=15.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
- 04/27/2016 17:52:40
+ 05/04/2016 22:31:52
16, 16
@@ -2182,7 +2182,7 @@
0, 0
- 453, 465
+ 453, 459
0
@@ -2542,7 +2542,7 @@
Signal source
- 987, 392
+ 981, 386
1
@@ -2563,7 +2563,7 @@
Bottom
- 2, 446
+ 2, 440
2, 2, 2, 2
@@ -2752,7 +2752,7 @@ specific provider, satellite or country lists.
2, 21
- 987, 33
+ 981, 33
0
@@ -2776,7 +2776,7 @@ specific provider, satellite or country lists.
0, 0
- 991, 465
+ 985, 459
0
@@ -2800,7 +2800,7 @@ specific provider, satellite or country lists.
Panel2
- 1450, 465
+ 1444, 459
5
diff --git a/source/ChanSort/ReferenceListForm.cs b/source/ChanSort/ReferenceListForm.cs
index 0cf694d..dbf0b58 100644
--- a/source/ChanSort/ReferenceListForm.cs
+++ b/source/ChanSort/ReferenceListForm.cs
@@ -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
}
}
\ No newline at end of file