From 180ad35d8ea91d5f6e26c30b9f98ad0189ca44ac Mon Sep 17 00:00:00 2001 From: Horst Beham Date: Sun, 12 Jul 2020 02:39:43 +0200 Subject: [PATCH] - added UTF-16 Big Endian and Little Endian options to character set menu - Samsung .zip loader: auto-detect UTF-16 endianness and allow to change encoding after loading to UTF-16 LE/BE (some files use Little Endian format and show chinese characters when loaded with the default Big Endian format) - Customized column order is now preserved across file formats and input sources - Note about LG WebOS 5 files (e.g. CX series): It is still unclear what exact firmware version and conditions are needed to properly import a channel list. Users reported about varying success of an import, reaching from not possible at all, only after a factory reset, importing the same list twice or working just fine. The problems is not related to ChanSort, as it can be reproduced by exporting a list to USB, swapping channels in the TV's menu and trying to loading the previously exported list back. The TV may keep the swapped channels and show inconsistencies between the channel list in the settings menu and the EPG. - upgrade to DevExpress 20.1.4 --- source/ChanSort.Api/ChanSort.Api.csproj | 1 + source/ChanSort.Api/Utils/DelegateComparer.cs | 60 +++ source/ChanSort.Api/Utils/Tools.cs | 10 + .../GcJsonSerializer.cs | 16 +- .../ChanSort.Loader.LG.csproj | 8 +- .../PresetProgramNrDialog.resx | 20 +- source/ChanSort.Loader.LG/TvSettingsForm.resx | 40 +- source/ChanSort.Loader.SamsungJ/DbChannel.cs | 10 +- .../ChanSort.Loader.SamsungJ/DbSerializer.cs | 76 +++- source/ChanSort/AboutForm.resx | 34 +- source/ChanSort/ActionBox.resx | 10 +- source/ChanSort/ActionImages.resx | 2 +- source/ChanSort/ChanSort.csproj | 50 ++- source/ChanSort/ChanSort.csproj.DotSettings | 2 + source/ChanSort/CharsetForm.resx | 26 +- source/ChanSort/GlobalImageCollection.resx | 2 +- source/ChanSort/MainForm.Designer.cs | 52 ++- source/ChanSort/MainForm.cs | 76 ++-- source/ChanSort/MainForm.de.resx | 2 +- source/ChanSort/MainForm.pt.resx | 8 +- source/ChanSort/MainForm.resx | 412 +++++++++--------- .../Printing/ReportOptionsDialog.resx | 24 +- source/ChanSort/Properties/Config.cs | 14 +- source/ChanSort/Properties/licenses.licx | 6 + source/ChanSort/ReferenceListForm.resx | 78 ++-- source/ChanSort/WaitForm1.resx | 4 +- source/ChanSort/XGrid/XGridControl.cs | 409 +++++++++++++++++ .../XGrid/XGridView.LayoutPersister.cs | 272 ++++++++++++ source/ChanSort/XGrid/XGridView.cs | 271 ++++++++++++ source/changelog.md | 15 +- source/makeDistribZip.cmd | 4 +- 31 files changed, 1577 insertions(+), 437 deletions(-) create mode 100644 source/ChanSort.Api/Utils/DelegateComparer.cs create mode 100644 source/ChanSort/ChanSort.csproj.DotSettings create mode 100644 source/ChanSort/XGrid/XGridControl.cs create mode 100644 source/ChanSort/XGrid/XGridView.LayoutPersister.cs create mode 100644 source/ChanSort/XGrid/XGridView.cs diff --git a/source/ChanSort.Api/ChanSort.Api.csproj b/source/ChanSort.Api/ChanSort.Api.csproj index 98c79cc..efb17b2 100644 --- a/source/ChanSort.Api/ChanSort.Api.csproj +++ b/source/ChanSort.Api/ChanSort.Api.csproj @@ -86,6 +86,7 @@ True Resources.resx + diff --git a/source/ChanSort.Api/Utils/DelegateComparer.cs b/source/ChanSort.Api/Utils/DelegateComparer.cs new file mode 100644 index 0000000..f8be3e7 --- /dev/null +++ b/source/ChanSort.Api/Utils/DelegateComparer.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace ChanSort +{ + /// + /// The DelegateComparer class is used as an adapter to use a simple delegate method in places + /// where an IComparer interface is expected + /// + public class DelegateComparer : IComparer + { + private readonly Func handler; + private readonly bool reverse; + + + /// + /// Create a new DelegateComparer + /// + /// The method used to compare two objects + public DelegateComparer(Func handler) + { + this.handler = handler; + } + + public DelegateComparer(Func handler, bool reverse) : this(handler) + { + this.reverse=reverse; + } + + /// + /// Compares two objects by delegating the request to the handler-delegate + /// + public int Compare(object o1, object o2) + { + int r=this.handler(o1, o2); + return this.reverse ? -r : +r; + } + } + + public class DelegateComparer : IComparer, IComparer + { + private readonly Func handler; + private readonly bool reverse; + + public DelegateComparer(Func handler, bool reverse = false) + { + this.handler = handler; + this.reverse = reverse; + } + + public int Compare(T x, T y) + { + var r = handler(x, y); + return reverse ? -r : r; + } + + int IComparer.Compare(object x, object y) => this.Compare((T) x, (T) y); + } +} diff --git a/source/ChanSort.Api/Utils/Tools.cs b/source/ChanSort.Api/Utils/Tools.cs index 7848745..14ec834 100644 --- a/source/ChanSort.Api/Utils/Tools.cs +++ b/source/ChanSort.Api/Utils/Tools.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; using System.Text; namespace ChanSort.Api @@ -206,5 +207,14 @@ namespace ChanSort.Api } #endregion + + #region FirstNotDefault() + public static T FirstNotDefault(params T[] values) + { + var def = default(T); + return values.FirstOrDefault(v => !Equals(v, def)); + } + #endregion + } } diff --git a/source/ChanSort.Loader.GlobalClone/GcJsonSerializer.cs b/source/ChanSort.Loader.GlobalClone/GcJsonSerializer.cs index 94daa27..bf82677 100644 --- a/source/ChanSort.Loader.GlobalClone/GcJsonSerializer.cs +++ b/source/ChanSort.Loader.GlobalClone/GcJsonSerializer.cs @@ -200,6 +200,7 @@ namespace ChanSort.Loader.GlobalClone { foreach (var list in this.DataRoot.ChannelLists) { + int radioMask = (list.SignalSource & SignalSource.Radio) != 0 ? 0x4000 : 0; foreach (var chan in list.Channels) { if (!(chan is GcChannel ch)) @@ -212,15 +213,20 @@ namespace ChanSort.Loader.GlobalClone } node["deleted"] = ch.IsDeleted; - var nr = Math.Max(ch.NewProgramNr, 0); // radio channels, except the deleted ones with Nr 0, have 0x4000 added to their number - if (nr != 0 && (ch.SignalSource & SignalSource.Radio) != 0) - nr |= 0x4000; + var nr = Math.Max(ch.NewProgramNr, 0); // radio channels, except the deleted ones with nr=0, have 0x4000 added to their number + if (nr != 0) + nr |= radioMask; node["majorNumber"] = nr; node["skipped"] = ch.Skip; node["locked"] = ch.Lock; node["Invisible"] = ch.Hidden; - node["userEditChNumber"] = true; - node["userSelCHNo"] = true; + if (ch.NewProgramNr != ch.OldProgramNr) + { + node["userEditChNumber"] = true; + node["userSelCHNo"] = true; + } + + //node["disableUpdate"] = true; // experimental to prevent "DTV Auto Update" of channel numbers right after importing the list } } } diff --git a/source/ChanSort.Loader.LG/ChanSort.Loader.LG.csproj b/source/ChanSort.Loader.LG/ChanSort.Loader.LG.csproj index a0a023f..b1b40fe 100644 --- a/source/ChanSort.Loader.LG/ChanSort.Loader.LG.csproj +++ b/source/ChanSort.Loader.LG/ChanSort.Loader.LG.csproj @@ -60,10 +60,10 @@ false - - - - + + + + diff --git a/source/ChanSort.Loader.LG/PresetProgramNrDialog.resx b/source/ChanSort.Loader.LG/PresetProgramNrDialog.resx index 6647199..3fe1cb2 100644 --- a/source/ChanSort.Loader.LG/PresetProgramNrDialog.resx +++ b/source/ChanSort.Loader.LG/PresetProgramNrDialog.resx @@ -121,7 +121,7 @@ Top, Left, Right - + Vertical @@ -143,7 +143,7 @@ labelControl1 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -176,7 +176,7 @@ labelControl3 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -209,7 +209,7 @@ labelControl4 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -239,7 +239,7 @@ labelControl5 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -269,7 +269,7 @@ labelControl6 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -299,7 +299,7 @@ labelControl7 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -353,7 +353,7 @@ btnOk - DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -383,7 +383,7 @@ labelControl2 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -410,6 +410,6 @@ PresetProgramNrDialog - DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a \ No newline at end of file diff --git a/source/ChanSort.Loader.LG/TvSettingsForm.resx b/source/ChanSort.Loader.LG/TvSettingsForm.resx index 6da8164..4bc5317 100644 --- a/source/ChanSort.Loader.LG/TvSettingsForm.resx +++ b/source/ChanSort.Loader.LG/TvSettingsForm.resx @@ -139,7 +139,7 @@ cbHbbTv - DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpOption @@ -166,7 +166,7 @@ cbCustomCountry - DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpOption @@ -177,7 +177,7 @@ 72, 29 - + Combo @@ -191,7 +191,7 @@ comboBoxEdit1 - DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpOption @@ -215,7 +215,7 @@ labelControl1 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpOption @@ -242,7 +242,7 @@ grpOption - DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -269,7 +269,7 @@ btnOk - DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -296,7 +296,7 @@ btnCancel - DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -304,7 +304,7 @@ 2 - + Vertical @@ -324,7 +324,7 @@ labelControl3 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpHotelMode @@ -348,7 +348,7 @@ labelControl2 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpHotelMode @@ -375,7 +375,7 @@ cbDtvUpdate - DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpHotelMode @@ -402,7 +402,7 @@ cbHotelMode - DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpHotelMode @@ -429,7 +429,7 @@ grpHotelMode - DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -456,7 +456,7 @@ cbAutoChannelUpdate - DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpSetup @@ -483,7 +483,7 @@ grpSetup - DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -510,7 +510,7 @@ labelControl4 - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a grpInformation @@ -537,7 +537,7 @@ grpInformation - DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -567,7 +567,7 @@ lblHotelMenuAutoDetect - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -594,6 +594,6 @@ TvSettingsForm - DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a \ No newline at end of file diff --git a/source/ChanSort.Loader.SamsungJ/DbChannel.cs b/source/ChanSort.Loader.SamsungJ/DbChannel.cs index 34eb90a..ccbc3ae 100644 --- a/source/ChanSort.Loader.SamsungJ/DbChannel.cs +++ b/source/ChanSort.Loader.SamsungJ/DbChannel.cs @@ -7,7 +7,7 @@ namespace ChanSort.Loader.SamsungJ internal class DbChannel : ChannelInfo { #region ctor() - internal DbChannel(SQLiteDataReader r, IDictionary field, DataRoot dataRoot, Dictionary providers, Satellite sat, Transponder tp) + internal DbChannel(SQLiteDataReader r, IDictionary field, DbSerializer loader, Dictionary providers, Satellite sat, Transponder tp) { var chType = r.GetInt32(field["chType"]); this.SignalSource = DbSerializer.ChTypeToSignalSource(chType); @@ -20,7 +20,7 @@ namespace ChanSort.Loader.SamsungJ (this.SignalSource & SignalSource.DvbC) == SignalSource.DvbC ? LookupData.Instance.GetDvbcTransponder(this.FreqInMhz).ToString() : (this.SignalSource & SignalSource.DvbS) == SignalSource.DvbS ? LookupData.Instance.GetAstraTransponder((int)this.FreqInMhz).ToString() : ""; - this.Name = DbSerializer.ReadUtf16(r, field["srvName"]); + this.Name = loader.ReadUtf16(r, field["srvName"]); this.Hidden = r.GetBoolean(field["hidden"]); this.Encrypted = r.GetBoolean(field["scrambled"]); this.Lock = r.GetBoolean(field["lockMode"]); @@ -39,7 +39,7 @@ namespace ChanSort.Loader.SamsungJ } if ((this.SignalSource & SignalSource.Digital) != 0) - this.ReadDvbData(r, field, dataRoot, providers); + this.ReadDvbData(r, field, loader, providers); else this.ReadAnalogData(r, field); @@ -56,9 +56,9 @@ namespace ChanSort.Loader.SamsungJ #endregion #region ReadDvbData() - protected void ReadDvbData(SQLiteDataReader r, IDictionary field, DataRoot dataRoot, Dictionary providers) + protected void ReadDvbData(SQLiteDataReader r, IDictionary field, DbSerializer loader, Dictionary providers) { - this.ShortName = DbSerializer.ReadUtf16(r, field["srvName"]); + this.ShortName = loader.ReadUtf16(r, field["srvName"]); this.RecordOrder = r.GetInt32(field["major"]); int serviceType = r.GetInt32(field["srvType"]); this.ServiceType = serviceType; diff --git a/source/ChanSort.Loader.SamsungJ/DbSerializer.cs b/source/ChanSort.Loader.SamsungJ/DbSerializer.cs index 8c57e23..b40bc2b 100644 --- a/source/ChanSort.Loader.SamsungJ/DbSerializer.cs +++ b/source/ChanSort.Loader.SamsungJ/DbSerializer.cs @@ -17,6 +17,7 @@ namespace ChanSort.Loader.SamsungJ private readonly Dictionary channelById = new Dictionary(); private readonly Dictionary dbPathByChannelList = new Dictionary(); private readonly List tableNames = new List(); + private Encoding encoding; private enum FileType { Unknown, SatDb, ChannelDbDvb, ChannelDbAnalog, ChannelDbIp } @@ -262,7 +263,7 @@ namespace ChanSort.Loader.SamsungJ // ... and get the satellite from that transponder - if set // Note that we can have channels from multiple satellites in the same list, so this is a loop variable now var sat = tp?.Satellite; - var channel = new DbChannel(r, fields, this.DataRoot, providers, sat, tp); + var channel = new DbChannel(r, fields, this, providers, sat, tp); if (channel.OldProgramNr == prevNr) // when there is a SRV_EXT_APP table in the database, the service with the highest ext_app "recState" takes priority continue; @@ -278,6 +279,7 @@ namespace ChanSort.Loader.SamsungJ } #endregion + #region CreateChannelList() private ChannelList CreateChannelList(SignalSource signalSource, string name) { var list = new ChannelList(signalSource, name); @@ -290,6 +292,7 @@ namespace ChanSort.Loader.SamsungJ } return list; } + #endregion #region DetectSignalSource() private static SignalSource DetectSignalSource(SQLiteCommand cmd, FileType fileType) @@ -383,13 +386,77 @@ namespace ChanSort.Loader.SamsungJ #endregion #region ReadUtf16() - internal static string ReadUtf16(SQLiteDataReader r, int fieldIndex) + internal string ReadUtf16(SQLiteDataReader r, int fieldIndex) { if (r.IsDBNull(fieldIndex)) return null; byte[] nameBytes = new byte[200]; int nameLen = (int)r.GetBytes(fieldIndex, 0, nameBytes, 0, nameBytes.Length); - return Encoding.BigEndianUnicode.GetString(nameBytes, 0, nameLen).Replace("\0", ""); // remove trailing \0 characters found in Samsung "_T_..." channel list + this.encoding ??= AutoDetectUtf16Endian(nameBytes, nameLen); + if (this.encoding == null) + return string.Empty; + + return encoding.GetString(nameBytes, 0, nameLen).Replace("\0", ""); // remove trailing \0 characters found in Samsung "_T_..." channel list + } + #endregion + + #region AutoDetectUtf16Endian() + private Encoding AutoDetectUtf16Endian(byte[] nameBytes, int nameLen) + { + if (this.DefaultEncoding is UnicodeEncoding) + return this.DefaultEncoding; + + int evenBytesZero = 0; + int oddBytesZero = 0; + for (int i = 0; i < nameLen; i += 2) + { + if (nameBytes[i] == 0) + ++evenBytesZero; + if (nameBytes[i + 1] == 0) + ++oddBytesZero; + } + + if (evenBytesZero + oddBytesZero == nameLen) + return null; + + return evenBytesZero >= oddBytesZero ? Encoding.BigEndianUnicode : Encoding.Unicode; + } + + #endregion + + #region DefaultEncoding + public override Encoding DefaultEncoding + { + get => base.DefaultEncoding; + set + { + if (!(value is UnicodeEncoding)) + return; + + var oldEncoding = base.DefaultEncoding; + if (oldEncoding != null) + { + // change encoding of channel names + foreach (var list in this.DataRoot.ChannelLists) + { + foreach (var chan in list.Channels) + { + byte[] bytes; + if (chan.Name != null) + { + bytes = oldEncoding.GetBytes(chan.Name); + chan.Name = value.GetString(bytes); + } + if (chan.ShortName != null) + { + bytes = oldEncoding.GetBytes(chan.ShortName); + chan.ShortName = value.GetString(bytes); + } + } + } + } + base.DefaultEncoding = value; + } } #endregion @@ -528,7 +595,7 @@ namespace ChanSort.Loader.SamsungJ cmdUpdateSrv.Parameters["@lock"].Value = channel.Lock; cmdUpdateSrv.Parameters["@hidden"].Value = channel.Hidden; cmdUpdateSrv.Parameters["@numsel"].Value = !channel.Skip; - cmdUpdateSrv.Parameters["@srvname"].Value = channel.Name == null ? (object)DBNull.Value : Encoding.BigEndianUnicode.GetBytes(channel.Name); + cmdUpdateSrv.Parameters["@srvname"].Value = channel.Name == null ? (object)DBNull.Value : encoding.GetBytes(channel.Name); cmdUpdateSrv.ExecuteNonQuery(); // update favorites @@ -557,6 +624,5 @@ namespace ChanSort.Loader.SamsungJ } } #endregion - } } diff --git a/source/ChanSort/AboutForm.resx b/source/ChanSort/AboutForm.resx index a4b909f..feaae75 100644 --- a/source/ChanSort/AboutForm.resx +++ b/source/ChanSort/AboutForm.resx @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Vertical @@ -139,7 +139,7 @@ lblWebsite - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -170,7 +170,7 @@ lnkDownload - DevExpress.XtraEditors.HyperLinkEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.HyperLinkEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -194,7 +194,7 @@ gcPlugins - DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a horst@beham.biz @@ -215,7 +215,7 @@ lnkEmail - DevExpress.XtraEditors.HyperLinkEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.HyperLinkEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -242,7 +242,7 @@ lblAuthor - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -269,7 +269,7 @@ lblLicense - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -299,7 +299,7 @@ lnkLicense - DevExpress.XtraEditors.HyperLinkEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.HyperLinkEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -326,7 +326,7 @@ lblCredits - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -350,7 +350,7 @@ txtCredits - DevExpress.XtraEditors.MemoEdit, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.MemoEdit, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -377,7 +377,7 @@ btnClose - DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.SimpleButton, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -401,7 +401,7 @@ txtAuthor - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -428,30 +428,30 @@ gvPlugins - DevExpress.XtraGrid.Views.Grid.GridView, DevExpress.XtraGrid.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraGrid.Views.Grid.GridView, DevExpress.XtraGrid.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a colPlugin - DevExpress.XtraGrid.Columns.GridColumn, DevExpress.XtraGrid.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraGrid.Columns.GridColumn, DevExpress.XtraGrid.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a colDisplayText - DevExpress.XtraGrid.Columns.GridColumn, DevExpress.XtraGrid.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraGrid.Columns.GridColumn, DevExpress.XtraGrid.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a colFileTypes - DevExpress.XtraGrid.Columns.GridColumn, DevExpress.XtraGrid.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraGrid.Columns.GridColumn, DevExpress.XtraGrid.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a AboutForm - DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a \ No newline at end of file diff --git a/source/ChanSort/ActionBox.resx b/source/ChanSort/ActionBox.resx index afd46ec..829b570 100644 --- a/source/ChanSort/ActionBox.resx +++ b/source/ChanSort/ActionBox.resx @@ -125,7 +125,7 @@ Tahoma, 9pt - + Vertical @@ -146,7 +146,7 @@ lblMessage - DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.LabelControl, DevExpress.XtraEditors.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a $this @@ -160,7 +160,7 @@ 32, 32 - + AAEAAAD/////AQAAAAAAAAAMAgAAAFpEZXZFeHByZXNzLlV0aWxzLnYxMi4yLCBWZXJzaW9uPTEyLjIu @@ -459,12 +459,12 @@ imageCollection1 - DevExpress.Utils.ImageCollection, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.Utils.ImageCollection, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a ActionBoxDialog - DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v20.1, Version=20.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a \ No newline at end of file diff --git a/source/ChanSort/ActionImages.resx b/source/ChanSort/ActionImages.resx index a458083..a646692 100644 --- a/source/ChanSort/ActionImages.resx +++ b/source/ChanSort/ActionImages.resx @@ -120,7 +120,7 @@ 349, 503 - + AAEAAAD/////AQAAAAAAAAAMAgAAAFpEZXZFeHByZXNzLlV0aWxzLnYxNS4yLCBWZXJzaW9uPTE1LjIu diff --git a/source/ChanSort/ChanSort.csproj b/source/ChanSort/ChanSort.csproj index 6866780..d0dbb4d 100644 --- a/source/ChanSort/ChanSort.csproj +++ b/source/ChanSort/ChanSort.csproj @@ -69,47 +69,47 @@ app.manifest - + False - - + + False - + False - + False - - + + False - + False - - + + False - + False - + False - + False - - - - - - - - + + + + + + + + @@ -201,6 +201,13 @@ CharsetForm.cs + + Component + + + Component + + AboutForm.cs @@ -540,6 +547,7 @@ PreserveNewest +