diff --git a/ChanSort.Api/Controller/CsvFileSerializer.cs b/ChanSort.Api/Controller/CsvFileSerializer.cs index f36e021..47f1997 100644 --- a/ChanSort.Api/Controller/CsvFileSerializer.cs +++ b/ChanSort.Api/Controller/CsvFileSerializer.cs @@ -49,21 +49,18 @@ namespace ChanSort.Api if (!int.TryParse(parts[2], out transportStreamId)) return; string uid = parts[3].Replace("\"", ""); SignalSource signalSource; - switch (uid[0]) - { - case 'S': signalSource = SignalSource.DvbS; break; - case 'C': signalSource = SignalSource.DvbCT; break; - case 'A': signalSource = SignalSource.AnalogCT; break; - case 'H': signalSource = SignalSource.HdPlusD; break; - default: return; - } - var signalType = slot < 0x4000 ? SignalType.Tv : SignalType.Radio; - var channelList = dataRoot.GetChannelList(signalSource, signalType, true); + SignalType signalType; + if (!GetSignalSourceAndType(ref slot, uid, parts, out signalSource, out signalType)) + return; + string name = parts[4].Replace("\"", ""); + ChannelList channelList = dataRoot.GetChannelList(signalSource, signalType, true); + + IEnumerable channels = FindChannels(channelList, name, uid); var channel = channels == null ? null : channels.FirstOrDefault(c => c.NewProgramNr == 0); if (channel != null) - channel.NewProgramNr = slot & 0x3FFF; + channel.NewProgramNr = slot; else { channel = new ChannelInfo(signalSource, signalType, uid, slot, name); @@ -71,6 +68,34 @@ namespace ChanSort.Api channelList.AddChannel(channel); } } + + private static bool GetSignalSourceAndType(ref int slot, string uid, string[] parts, out SignalSource signalSource, out SignalType signalType) + { + // new lists store a bitmask which defines the type of channel and list it came from + if (parts.Length >= 6) + { + signalSource = (SignalSource)int.Parse(parts[5]); + signalType = (SignalType)((int)signalSource & (int)SignalType.Mixed); + return true; + } + + // compatibility for older lists + signalSource = 0; + signalType = 0; + switch (uid[0]) + { + case 'S': signalSource = SignalSource.DvbS; break; + case 'C': signalSource = SignalSource.DvbCT; break; + case 'A': signalSource = SignalSource.AnalogCT; break; + case 'H': signalSource = SignalSource.HdPlusD; break; + default: return false; + } + signalType = slot < 0x4000 ? SignalType.Tv : SignalType.Radio; + signalSource |= (SignalSource)signalType; + slot &= 0x3FFFF; + return true; + } + #endregion #region FindChannels() diff --git a/ChanSort.Api/Model/Enums.cs b/ChanSort.Api/Model/Enums.cs index fbde3bd..876e031 100644 --- a/ChanSort.Api/Model/Enums.cs +++ b/ChanSort.Api/Model/Enums.cs @@ -2,16 +2,33 @@ namespace ChanSort.Api { + /// + /// Bitmask for channel and list classification. + /// An individual channel can only have one bit of each group set. + /// A ChannelList can have multiple bits set to indicate which type of channels it can hold. + /// [Flags] public enum SignalSource { - Analog = 0x00, - Digital = 0x10, + // bit 1+2: analog/digital + Analog = 0x0001, + Digital = 0x0002, - Cable = 0x01, - Antenna = 0x02, - Sat = 0x04, - HdPlus = 0x08, + // bit 5+6+7: Antenna/Cable/Sat + Antenna = 0x0010, + Cable = 0x0020, + Sat = 0x0040, + + // bit 9+10: TV/Radio + Tv = 0x0100, + Radio = 0x0200, + + // bit 13-16: Preset list selector (AstraHD+, Freesat, TivuSat, CanalDigitalSat, ... for Samsung) + StandardSat = 0 << 24, + HdPlus = 1 << 24, + Freesat = 2 << 24, + TivuSat = 3 << 24, + CanalDigital = 4 << 24, AnalogC=Analog + Cable, AnalogT=Analog + Antenna, @@ -22,7 +39,8 @@ namespace ChanSort.Api DvbS= Digital + Sat, HdPlusD = Digital + HdPlus } - public enum SignalType { Tv, Radio, Mixed } + + public enum SignalType { Tv = SignalSource.Tv, Radio = SignalSource.Radio, Mixed = SignalSource.Tv|SignalSource.Radio } [Flags] public enum Favorites : byte { A = 0x01, B = 0x02, C = 0x04, D = 0x08, E = 0x10 } diff --git a/ChanSort/MainForm.cs b/ChanSort/MainForm.cs index 9447276..369ead5 100644 --- a/ChanSort/MainForm.cs +++ b/ChanSort/MainForm.cs @@ -20,10 +20,10 @@ using DevExpress.XtraGrid.Views.Grid; namespace ChanSort.Ui { - // http://www.lg-forum.com/lg-led-plasma-lcd-fernseher/5098-channeleditor-40.html - // http://www.lg-hack.info/cgi-bin/sn_forumr.cgi?fid=2677&cid=2674&tid=2690&pg=1&sc=20&x=0 public partial class MainForm : XtraForm { + private const string Version = "v2013-04-03"; + #region enum EditMode private enum EditMode { @@ -59,7 +59,8 @@ namespace ChanSort.Ui this.SetControlsEnabled(false); if (!Settings.Default.WindowSize.IsEmpty) this.Size = Settings.Default.WindowSize; - this.title = this.Text; + this.title = string.Format(this.Text, Version); + this.Text = title; this.plugins = this.LoadSerializerPlugins(); this.FillMenuWithIsoEncodings(); @@ -244,6 +245,8 @@ namespace ChanSort.Ui #region UpdateFavoritesEditor() private void UpdateFavoritesEditor(Favorites favorites) { + this.miFavSet.Strings.Clear(); + this.miFavUnset.Strings.Clear(); this.repositoryItemCheckedComboBoxEdit1.Items.Clear(); this.repositoryItemCheckedComboBoxEdit2.Items.Clear(); byte mask = 0x01; @@ -256,6 +259,10 @@ namespace ChanSort.Ui this.repositoryItemCheckedComboBoxEdit1.Items.Add(c); this.repositoryItemCheckedComboBoxEdit2.Items.Add(c); regex += c; + + string str = c.ToString(); + this.miFavSet.Strings.Add(str); + this.miFavUnset.Strings.Add(str); } } regex += "]*"; @@ -1063,6 +1070,14 @@ namespace ChanSort.Ui } #endregion + #region RefreshGrid() + private void RefreshGrid(GridView grid) + { + grid.BeginDataUpdate(); + grid.EndDataUpdate(); + } + #endregion + #region ShowTvCountrySettings() private void ShowTvCountrySettings() { @@ -1385,7 +1400,11 @@ namespace ChanSort.Ui else if (this.gviewInput.FocusedColumn == this.colFavorites && e.Value is string) e.Value = ChannelInfo.ParseFavString((string)e.Value); else if (gviewInput.FocusedColumn == this.colName) - this.VerifyChannelNameModified(this.gviewInput.GetFocusedRow() as ChannelInfo, e.Value as string); + { + var ci = this.gviewInput.GetFocusedRow() as ChannelInfo; + this.VerifyChannelNameModified(ci, e.Value as string); + this.BeginInvoke((Action) (() => RefreshGrid(this.gviewOutput))); + } dataRoot.NeedsSaving = true; } catch(Exception ex) { HandleException(ex); } } @@ -1457,7 +1476,10 @@ namespace ChanSort.Ui else if (this.gviewOutput.FocusedColumn == this.colOutFav && e.Value is string) e.Value = ChannelInfo.ParseFavString((string) e.Value); else if (gviewOutput.FocusedColumn == this.colOutName) + { this.VerifyChannelNameModified(this.gviewOutput.GetFocusedRow() as ChannelInfo, e.Value as string); + this.BeginInvoke((Action) (() => RefreshGrid(this.gviewOutput))); + } dataRoot.NeedsSaving = true; } catch (Exception ex) { HandleException(ex); } diff --git a/ChanSort/MainForm.de.resx b/ChanSort/MainForm.de.resx index 6ffc157..d00db8b 100644 --- a/ChanSort/MainForm.de.resx +++ b/ChanSort/MainForm.de.resx @@ -433,7 +433,7 @@ Senderliste: - ChanSort v2013-03-30 - Senderlisten Editor für LG und Samsung TV + ChanSort {0} - Senderlisten Editor für LG und Samsung TV Nach oben diff --git a/ChanSort/MainForm.resx b/ChanSort/MainForm.resx index bbb1eff..1b1021e 100644 --- a/ChanSort/MainForm.resx +++ b/ChanSort/MainForm.resx @@ -663,7 +663,7 @@ CenterScreen - ChanSort v2013-03-30 - Channel List Editor for LG and Samsung TVs + ChanSort {0} - Channel List Editor for LG and Samsung TVs dsChannels