From 3bb80ed6bb4eb4454b4986e282f34a47a929c8cd Mon Sep 17 00:00:00 2001 From: hbeham Date: Tue, 2 Jul 2013 23:55:02 +0200 Subject: [PATCH] - support for individually sorted favorite lists (Panasonic, Samsung E+F) - FIX: "insert after" when dropping a channel from right list --- ChanSort.Api/Controller/Editor.cs | 146 ++++++++++++++++------ ChanSort.Api/Controller/SerializerBase.cs | 1 - ChanSort.Api/Model/ChannelInfo.cs | 47 ++++++- ChanSort.Api/Model/DataRoot.cs | 1 + ChanSort.Loader.Panasonic/DbChannel.cs | 5 +- ChanSort.Loader.Panasonic/Serializer.cs | 5 +- ChanSort.Loader.Samsung/ScmChannelBase.cs | 8 +- ChanSort.Loader.Samsung/ScmSerializer.cs | 1 + ChanSort/MainForm.Designer.cs | 44 ++++++- ChanSort/MainForm.cs | 131 +++++++++++++------ ChanSort/MainForm.de.resx | 2 +- ChanSort/MainForm.resx | 106 +++++++++++++--- readme.txt | 24 ++-- 13 files changed, 404 insertions(+), 117 deletions(-) diff --git a/ChanSort.Api/Controller/Editor.cs b/ChanSort.Api/Controller/Editor.cs index e9d57e0..bf0eceb 100644 --- a/ChanSort.Api/Controller/Editor.cs +++ b/ChanSort.Api/Controller/Editor.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,38 +9,43 @@ namespace ChanSort.Api { public DataRoot DataRoot; public ChannelList ChannelList; + public int SubListIndex; private UnsortedChannelMode unsortedChannelMode; #region AddChannels() public ChannelInfo AddChannels(IList channels) { - int count = channels.Count(channel => channel.NewProgramNr == -1); + int count = channels.Count(channel => channel.GetPosition(this.SubListIndex) == -1); if (count == 0) return null; ChannelInfo lastInsertedChannel = null; int progNr = this.ChannelList.InsertProgramNumber; int relativeChannelNumber = 0; int progNrCopy = progNr; // prevent "access to modified closure" warning - foreach(var channel in this.ChannelList.Channels.Where(c => c.NewProgramNr>=progNrCopy).OrderBy(c=>c.NewProgramNr)) + foreach ( + var channel in + this.ChannelList.Channels.Where(c => c.GetPosition(this.SubListIndex) >= progNrCopy) + .OrderBy(c => c.GetPosition(this.SubListIndex))) { - int gap = count - (channel.NewProgramNr - progNr - relativeChannelNumber); + var curPos = channel.GetPosition(this.SubListIndex); + int gap = count - (curPos - progNr - relativeChannelNumber); if (gap > 0) { - channel.NewProgramNr += gap; + channel.SetPosition(this.SubListIndex, curPos + gap); ++relativeChannelNumber; } } foreach (var channel in channels) { - if (channel.NewProgramNr != -1) + if (channel.GetPosition(this.SubListIndex) != -1) { // TODO notify user continue; } - channel.NewProgramNr = progNr++; + channel.SetPosition(this.SubListIndex, progNr++); lastInsertedChannel = channel; } this.ChannelList.InsertProgramNumber += count; @@ -47,6 +53,7 @@ namespace ChanSort.Api this.DataRoot.NeedsSaving |= lastInsertedChannel != null; return lastInsertedChannel; } + #endregion #region RemoveChannels() @@ -55,27 +62,30 @@ namespace ChanSort.Api { if (channels.Count == 0) return; - this.ChannelList.InsertProgramNumber = channels[0].NewProgramNr; - var orderedChannelList = this.ChannelList.Channels.Where(c => c.NewProgramNr != -1).OrderBy(c => c.NewProgramNr); + this.ChannelList.InsertProgramNumber = channels[0].GetPosition(this.SubListIndex); + var orderedChannelList = + this.ChannelList.Channels.Where(c => c.GetPosition(this.SubListIndex) != -1) + .OrderBy(c => c.GetPosition(this.SubListIndex)); foreach (var channel in channels) { - if (channel.NewProgramNr == -1) + if (channel.GetPosition(this.SubListIndex) == -1) continue; if (closeGap) { - int prevNr = channel.NewProgramNr; + int prevNr = channel.GetPosition(this.SubListIndex); foreach (var channel2 in orderedChannelList) { - if (channel2.NewProgramNr > channel.NewProgramNr) + if (channel2.GetPosition(this.SubListIndex) > channel.GetPosition(this.SubListIndex)) { - if (prevNr != -1 && channel2.NewProgramNr != prevNr + 1) // don't pull down numbers after a gap + if (prevNr != -1 && channel2.GetPosition(this.SubListIndex) != prevNr + 1) + // don't pull down numbers after a gap break; - prevNr = channel2.NewProgramNr; - --channel2.NewProgramNr; + prevNr = channel2.GetPosition(this.SubListIndex); + channel2.ChangePosition(this.SubListIndex, -1); } } } - channel.NewProgramNr = -1; + channel.SetPosition(this.SubListIndex, -1); } this.DataRoot.NeedsSaving = true; @@ -89,17 +99,18 @@ namespace ChanSort.Api { if (channels.Count == 0) return; - if (up && channels[0].NewProgramNr <= this.ChannelList.FirstProgramNumber) + if (up && channels[0].GetPosition(this.SubListIndex) <= this.ChannelList.FirstProgramNumber) return; - int delta = (up ? - 1 : +1); + int delta = (up ? -1 : +1); foreach (var channel in (up ? channels : channels.Reverse())) { - int newProgramNr = channel.NewProgramNr + delta; - ChannelInfo channelAtNewProgramNr = this.ChannelList.Channels.FirstOrDefault(ch => ch.NewProgramNr == newProgramNr); - if (channelAtNewProgramNr != null) - channelAtNewProgramNr.NewProgramNr -= delta; - channel.NewProgramNr += delta; + int newProgramNr = channel.GetPosition(this.SubListIndex) + delta; + ChannelInfo channelAtNewPos = + this.ChannelList.Channels.FirstOrDefault(ch => ch.GetPosition(this.SubListIndex) == newProgramNr); + if (channelAtNewPos != null) + channelAtNewPos.ChangePosition(this.SubListIndex, -delta); + channel.ChangePosition(this.SubListIndex, delta); } this.DataRoot.NeedsSaving = true; } @@ -107,15 +118,16 @@ namespace ChanSort.Api #endregion #region SortSelectedChannels(), ChannelComparerForSortingByName() + public void SortSelectedChannels(List selectedChannels) { if (selectedChannels.Count == 0) return; var sortedChannels = new List(selectedChannels); sortedChannels.Sort(this.ChannelComparerForSortingByName); - var programNumbers = selectedChannels.Select(ch => ch.NewProgramNr).ToList(); + var programNumbers = selectedChannels.Select(ch => ch.GetPosition(this.SubListIndex)).ToList(); for (int i = 0; i < sortedChannels.Count; i++) - sortedChannels[i].NewProgramNr = programNumbers[i]; - + sortedChannels[i].SetPosition(this.SubListIndex, programNumbers[i]); + this.DataRoot.NeedsSaving = true; } @@ -123,9 +135,11 @@ namespace ChanSort.Api { return channel1.Name.CompareTo(channel2.Name); } + #endregion #region SetSlotNumber() + public void SetSlotNumber(IList channels, int slot, bool swap, bool closeGap) { if (channels.Count == 0) return; @@ -137,9 +151,9 @@ namespace ChanSort.Api { var others = this.ChannelList.GetChannelByNewProgNr(slot); foreach (var other in others) - other.NewProgramNr = channel.NewProgramNr; + other.SetPosition(this.SubListIndex, channel.GetPosition(this.SubListIndex)); } - channel.NewProgramNr = slot++; + channel.SetPosition(this.SubListIndex, slot++); } } else @@ -150,16 +164,18 @@ namespace ChanSort.Api } this.DataRoot.NeedsSaving = true; } + #endregion #region RenumberChannels() + public void RenumberChannels(List channels) { if (channels.Count == 0) return; - int progNr = channels.Min(ch => ch.NewProgramNr); - foreach(var channel in channels) + int progNr = channels.Min(ch => ch.GetPosition(this.SubListIndex)); + foreach (var channel in channels) { - if (channel.NewProgramNr == progNr) + if (channel.GetPosition(this.SubListIndex) == progNr) { ++progNr; continue; @@ -173,17 +189,18 @@ namespace ChanSort.Api this.DataRoot.NeedsSaving = true; } } + #endregion #region ApplyReferenceList() + public void ApplyReferenceList(DataRoot refDataRoot) { - foreach (var channelList in this.DataRoot.ChannelLists) { foreach (var channel in channelList.Channels) - channel.NewProgramNr = -1; + channel.SetPosition(this.SubListIndex, -1); } StringBuilder log = new StringBuilder(); @@ -198,10 +215,10 @@ namespace ChanSort.Api foreach (var refChannel in refList.Channels) { var tvChannels = tvList.GetChannelByUid(refChannel.Uid); - ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.NewProgramNr == -1); + ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.GetPosition(this.SubListIndex) == -1); if (tvChannel != null) { - tvChannel.NewProgramNr = refChannel.OldProgramNr; + tvChannel.SetPosition(this.SubListIndex, refChannel.OldProgramNr); tvChannel.Favorites = refChannel.Favorites; tvChannel.Skip = refChannel.Skip; tvChannel.Lock = refChannel.Lock; @@ -210,7 +227,8 @@ namespace ChanSort.Api } else { - tvChannel = new ChannelInfo(refChannel.SignalSource, refChannel.Uid, refChannel.OldProgramNr, refChannel.Name); + tvChannel = new ChannelInfo(refChannel.SignalSource, refChannel.Uid, refChannel.OldProgramNr, + refChannel.Name); tvList.AddChannel(tvChannel); } } @@ -237,18 +255,19 @@ namespace ChanSort.Api if (appChannel.NewProgramNr == -1 && mode == UnsortedChannelMode.MarkDeleted) continue; - int progNr = GetNewProgramNr(appChannel, ref maxProgNr); + int progNr = GetNewPogramNr(appChannel, ref maxProgNr); appChannel.NewProgramNr = progNr; } } } #region ChanSortCriteria() + private string ChanSortCriteria(ChannelInfo channel) { // explicitly sorted - if (channel.NewProgramNr != -1) - return channel.NewProgramNr.ToString("d4"); + if (channel.GetPosition(this.SubListIndex) != -1) + return channel.GetPosition(this.SubListIndex).ToString("d4"); // eventually hide unsorted channels if (this.unsortedChannelMode == UnsortedChannelMode.MarkDeleted) @@ -265,10 +284,12 @@ namespace ChanSort.Api return "C"; return "A" + channel.Name; } + #endregion - #region GetNewProgramNr() - private int GetNewProgramNr(ChannelInfo appChannel, ref int maxPrNr) + #region GetNewPogramNr() + + private int GetNewPogramNr(ChannelInfo appChannel, ref int maxPrNr) { int prNr = appChannel.NewProgramNr; if (prNr > maxPrNr) @@ -280,8 +301,51 @@ namespace ChanSort.Api } return prNr; } + #endregion #endregion + + #region SetFavorites() + public void SetFavorites(List list, Favorites favorites, bool set) + { + bool sortedFav = this.DataRoot.SortedFavorites; + int favIndex = 0; + if (sortedFav) + { + for (int mask = (int) favorites; (mask & 1) == 0; mask >>= 1) + ++favIndex; + } + + if (set) + { + int maxPosition = 0; + if (sortedFav) + { + foreach (var channel in this.ChannelList.Channels) + maxPosition = Math.Max(maxPosition, channel.FavIndex[favIndex]); + } + + foreach (var channel in list) + { + if (sortedFav && channel.FavIndex[favIndex] == -1) + channel.FavIndex[favIndex] = ++maxPosition; + channel.Favorites |= favorites; + } + } + else + { + foreach (var channel in list) + { + if (sortedFav && channel.FavIndex[favIndex] != -1) + { + channel.FavIndex[favIndex] = -1; + // TODO close gap by pulling down higher numbers + } + channel.Favorites &= ~favorites; + } + } + } + #endregion } } diff --git a/ChanSort.Api/Controller/SerializerBase.cs b/ChanSort.Api/Controller/SerializerBase.cs index 0fa886c..2202591 100644 --- a/ChanSort.Api/Controller/SerializerBase.cs +++ b/ChanSort.Api/Controller/SerializerBase.cs @@ -9,7 +9,6 @@ namespace ChanSort.Api public bool ChannelNameEdit { get; set; } public bool FileInformation { get; set; } public bool CleanUpChannelData { get; set; } - public bool DeviceSettings { get; set; } } diff --git a/ChanSort.Api/Model/ChannelInfo.cs b/ChanSort.Api/Model/ChannelInfo.cs index 42ecdcc..1d327b6 100644 --- a/ChanSort.Api/Model/ChannelInfo.cs +++ b/ChanSort.Api/Model/ChannelInfo.cs @@ -5,6 +5,8 @@ namespace ChanSort.Api { public class ChannelInfo { + private const int MAX_FAV_LISTS = 5; + private string uid; /// /// List of channels that have the same UID as this channel and were not added to the channel list directly @@ -38,6 +40,7 @@ namespace ChanSort.Api public string Debug { get; private set; } public string SatPosition { get; set; } public Transponder Transponder { get; set; } + public IList FavIndex { get; private set; } public bool IsNameModified { get; set; } @@ -45,12 +48,15 @@ namespace ChanSort.Api protected ChannelInfo() { this.NewProgramNr = -1; + this.FavIndex = new List(MAX_FAV_LISTS); + for (int i = 0; i < MAX_FAV_LISTS; i++) + this.FavIndex.Add(-1); } /// /// Constructor for exiting TV channel /// - public ChannelInfo(SignalSource source, int index, int oldProgNr, string name) + public ChannelInfo(SignalSource source, int index, int oldProgNr, string name) : this() { this.SignalSource = source; this.RecordIndex = index; @@ -64,7 +70,7 @@ namespace ChanSort.Api /// /// Constructor for reference list channels which no longer exist in TV list /// - public ChannelInfo(SignalSource source, string uid, int newProgNr, string name) + public ChannelInfo(SignalSource source, string uid, int newProgNr, string name) : this() { this.SignalSource = source; this.Uid = uid; @@ -203,12 +209,47 @@ namespace ChanSort.Api } #endregion + #region UpdateRawData() public virtual void UpdateRawData() { } + #endregion + #region ChangeEncoding() public virtual void ChangeEncoding(System.Text.Encoding encoding) - { + { } + #endregion + + #region GetPosition(), SetPosition(), ChangePosition() + + public int GetPosition(int subListIndex) + { + return subListIndex == 0 ? this.NewProgramNr : this.FavIndex[subListIndex - 1]; + } + + public void SetPosition(int subListIndex, int newPos) + { + if (subListIndex == 0) + this.NewProgramNr = newPos; + else + { + this.FavIndex[subListIndex - 1] = newPos; + int mask = 1 << (subListIndex - 1); + if (newPos == -1) + this.Favorites &= (Favorites)~mask; + else + this.Favorites |= (Favorites)mask; + } + } + + internal void ChangePosition(int subListIndex, int delta) + { + if (subListIndex == 0) + this.NewProgramNr += delta; + else + this.FavIndex[subListIndex - 1] += delta; + } + #endregion } } diff --git a/ChanSort.Api/Model/DataRoot.cs b/ChanSort.Api/Model/DataRoot.cs index 42a7ddd..82bfc75 100644 --- a/ChanSort.Api/Model/DataRoot.cs +++ b/ChanSort.Api/Model/DataRoot.cs @@ -17,6 +17,7 @@ namespace ChanSort.Api public bool IsEmpty { get { return this.channelLists.Count == 0; } } public bool NeedsSaving { get; set; } public Favorites SupportedFavorites { get; set; } + public bool SortedFavorites { get; set; } public DataRoot() { diff --git a/ChanSort.Loader.Panasonic/DbChannel.cs b/ChanSort.Loader.Panasonic/DbChannel.cs index d4be40c..6cc55eb 100644 --- a/ChanSort.Loader.Panasonic/DbChannel.cs +++ b/ChanSort.Loader.Panasonic/DbChannel.cs @@ -55,7 +55,10 @@ namespace ChanSort.Loader.Panasonic { int favIndex = r.GetInt32(field["profile" + (i + 1) + "index"]); if (favIndex > 0) - this.Favorites |= (Favorites)(1 << i); + { + this.Favorites |= (Favorites) (1 << i); + this.FavIndex[i] = favIndex; + } } } #endregion diff --git a/ChanSort.Loader.Panasonic/Serializer.cs b/ChanSort.Loader.Panasonic/Serializer.cs index 400eccd..31b51c9 100644 --- a/ChanSort.Loader.Panasonic/Serializer.cs +++ b/ChanSort.Loader.Panasonic/Serializer.cs @@ -302,6 +302,7 @@ namespace ChanSort.Loader.Panasonic public Serializer(string inputFile) : base(inputFile) { this.Features.ChannelNameEdit = true; + this.DataRoot.SortedFavorites = true; this.DataRoot.AddChannelList(this.avbtChannels); this.DataRoot.AddChannelList(this.avbcChannels); @@ -538,8 +539,6 @@ order by s.ntype,major_channel #region WriteChannels() private void WriteChannels(SQLiteCommand cmd, ChannelList channelList) { - int[] favIndex = new int[4]; - cmd.CommandText = "update SVL set major_channel=@progNr, sname=@name, profile1index=@fav1, profile2index=@fav2, profile3index=@fav3, profile4index=@fav4, child_lock=@lock, skip=@skip where rowid=@rowid"; cmd.Parameters.Clear(); cmd.Parameters.Add(new SQLiteParameter("@rowid", DbType.Int32)); @@ -560,7 +559,7 @@ order by s.ntype,major_channel cmd.Parameters["@rowid"].Value = channel.RecordIndex; cmd.Parameters["@progNr"].Value = channel.NewProgramNr; for (int fav = 0; fav < 4; fav++) - cmd.Parameters["@fav" + (fav + 1)].Value = ((int) channel.Favorites & (1< isoEncodings = new List(); private ChannelList currentChannelList; + private int subListIndex; private GridView lastFocusedGrid; private EditMode curEditMode = EditMode.InsertAfter; private bool dontOpenEditor; @@ -310,6 +311,7 @@ namespace ChanSort.Ui this.repositoryItemCheckedComboBoxEdit2.Items.Clear(); byte mask = 0x01; string regex = "["; + int favCount = 0; for (int bit=0; bit<8; bit++, mask<<=1) { if (((int) favorites & mask) != 0) @@ -322,11 +324,28 @@ namespace ChanSort.Ui string str = c.ToString(); this.miFavSet.Strings.Add(str); this.miFavUnset.Strings.Add(str); + ++favCount; } } regex += "]*"; this.repositoryItemCheckedComboBoxEdit1.Mask.EditMask = regex; this.repositoryItemCheckedComboBoxEdit2.Mask.EditMask = regex; + + while (this.tabSubList.TabPages.Count > favCount + 1) + this.tabSubList.TabPages.RemoveAt(this.tabSubList.TabPages.Count-1); + while (this.tabSubList.TabPages.Count < favCount + 1) + { + var page = this.tabSubList.TabPages.Add(); + page.Text = "Fav " + (char)('A' + this.tabSubList.TabPages.Count - 2); + } + if (!this.dataRoot.SortedFavorites || this.subListIndex >= favCount) + { + this.tabSubList.SelectedTabPageIndex = 0; + this.subListIndex = 0; + } + this.grpSubList.Visible = this.dataRoot.SortedFavorites; + this.colOutFav.OptionsColumn.AllowEdit = !this.dataRoot.SortedFavorites; + this.colFavorites.OptionsColumn.AllowEdit = !this.dataRoot.SortedFavorites; } #endregion @@ -788,7 +807,7 @@ namespace ChanSort.Ui { this.gviewLeft.EndDataUpdate(); } - this.UpdateInsertSlotTextBox(); + this.UpdateInsertSlotNumber(); } #endregion @@ -843,11 +862,11 @@ namespace ChanSort.Ui this.gviewLeft.BeginDataUpdate(); int maxNr = this.currentChannelList.InsertProgramNumber; foreach (var channel in this.currentChannelList.Channels) - maxNr = Math.Max(maxNr, channel.NewProgramNr); + maxNr = Math.Max(maxNr, channel.GetPosition(this.subListIndex)); foreach (var channel in this.currentChannelList.Channels) { - if (channel.NewProgramNr == -1 && !channel.IsDeleted) - channel.NewProgramNr = maxNr++; + if (channel.GetPosition(this.subListIndex) == -1 && !channel.IsDeleted) + channel.SetPosition(this.subListIndex, maxNr++); } this.gviewRight.EndDataUpdate(); this.gviewLeft.EndDataUpdate(); @@ -915,6 +934,7 @@ namespace ChanSort.Ui this.miShowWarningsAfterLoad.Checked = Settings.Default.ShowWarningsAfterLoading; this.cbCloseGap.Checked = Settings.Default.CloseGaps; this.ClearLeftFilter(); + this.ClearRightFilter(); for (int i = MaxMruEntries-1; i >= 0; i--) { @@ -1000,6 +1020,26 @@ namespace ChanSort.Ui #endregion + #region UpdateInsertSlotNumber() + private void UpdateInsertSlotNumber() + { + var channel = (ChannelInfo)this.gviewLeft.GetFocusedRow(); + int programNr; + if (channel == null) + programNr = this.currentChannelList == null ? 1 : this.currentChannelList.FirstProgramNumber; + else + { + programNr = channel.GetPosition(this.subListIndex); + if (this.rbInsertAfter.Checked) + ++programNr; + } + if (this.currentChannelList != null) + this.currentChannelList.InsertProgramNumber = programNr; + this.UpdateInsertSlotTextBox(); + this.gviewLeft.SelectRow(this.gviewLeft.FocusedRowHandle); + } + #endregion + #region UpdateInsertSlotTextBox() private void UpdateInsertSlotTextBox() { @@ -1054,7 +1094,7 @@ namespace ChanSort.Ui { this.gviewLeft.BeginSort(); this.gviewLeft.ClearColumnsFilter(); - this.colOutSlot.FilterInfo = new ColumnFilterInfo("[NewProgramNr]<>-1"); + this.colOutSlot.FilterInfo = new ColumnFilterInfo("[Position]<>-1"); this.gviewLeft.EndSort(); } @@ -1136,20 +1176,13 @@ namespace ChanSort.Ui { if (string.IsNullOrEmpty(fav)) return; char ch = Char.ToUpper(fav[0]); - if (ch<'A' || ch>'D') return; + if (ch<'A' || ch>'E' || this.subListIndex == ch-'A'+1) return; var list = this.GetSelectedChannels(this.lastFocusedGrid); if (list.Count == 0) return; this.gviewRight.BeginDataUpdate(); this.gviewLeft.BeginDataUpdate(); - Favorites mask = (Favorites)(1 << (ch - 'A')); - foreach(var channel in list) - { - if (set) - channel.Favorites |= mask; - else - channel.Favorites &= ~mask; - } + this.editor.SetFavorites(list, (Favorites) (1 << (ch - 'A')), set); this.gviewRight.EndDataUpdate(); this.gviewLeft.EndDataUpdate(); } @@ -1220,11 +1253,11 @@ namespace ChanSort.Ui this.btnRemoveLeft.Enabled = mayEdit; this.btnRemoveRight.Enabled = mayEdit; this.btnRenum.Enabled = mayEdit; - this.btnToggleFavA.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.A) != 0; - this.btnToggleFavB.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.B) != 0; - this.btnToggleFavC.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.C) != 0; - this.btnToggleFavD.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.D) != 0; - this.btnToggleFavE.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.E) != 0; + this.btnToggleFavA.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.A) != 0 && this.subListIndex != 1; + this.btnToggleFavB.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.B) != 0 && this.subListIndex != 2; + this.btnToggleFavC.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.C) != 0 && this.subListIndex != 3; + this.btnToggleFavD.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.D) != 0 && this.subListIndex != 4; + this.btnToggleFavE.Enabled = mayEdit && (this.dataRoot.SupportedFavorites & Favorites.E) != 0 && this.subListIndex != 5; this.btnToggleLock.Enabled = mayEdit; this.miReload.Enabled = fileLoaded; @@ -1250,7 +1283,8 @@ namespace ChanSort.Ui bool isLeftGridSortedByNewProgNr = this.IsLeftGridSortedByNewProgNr; var sel = this.gviewLeft.GetSelectedRows(); var channel = sel.Length == 0 ? null : (ChannelInfo) this.gviewRight.GetRow(sel[0]); - this.miMoveUp.Enabled = this.btnUp.Enabled = mayEdit && isLeftGridSortedByNewProgNr && channel != null && channel.NewProgramNr > this.currentChannelList.FirstProgramNumber; + this.miMoveUp.Enabled = this.btnUp.Enabled = mayEdit && isLeftGridSortedByNewProgNr && channel != null + && channel.GetPosition(this.subListIndex) > this.currentChannelList.FirstProgramNumber; this.miMoveDown.Enabled = this.btnDown.Enabled = mayEdit && isLeftGridSortedByNewProgNr; this.miTvSettings.Enabled = this.currentTvSerializer != null; @@ -1679,6 +1713,29 @@ namespace ChanSort.Ui } #endregion + #region tabSubList_SelectedPageChanged + private void tabSubList_SelectedPageChanged(object sender, TabPageChangedEventArgs e) + { + this.subListIndex = this.tabSubList.SelectedTabPageIndex; + this.editor.SubListIndex = this.subListIndex; + this.gviewLeft.BeginSort(); + this.gviewLeft.EndSort(); + this.gviewRight.BeginSort(); + if (this.subListIndex > 0) + this.colSlotNew.FilterInfo = new ColumnFilterInfo("[NewProgramNr]<>-1"); + else + this.colSlotNew.ClearFilter(); + this.gviewRight.EndSort(); + } + #endregion + + private void gview_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) + { + var channel = (ChannelInfo) e.Row; + if (e.Column.FieldName == "Position") + e.Value = channel.GetPosition(this.subListIndex); + } + #region gview_MouseDown, gview_MouseUp, timerEditDelay_Tick, gview_ShowingEditor // these 4 event handler in combination override the default row-selection and editor-opening @@ -1777,7 +1834,7 @@ namespace ChanSort.Ui // start drag operation var channel = (ChannelInfo)view.GetRow(downHit.RowHandle); - this.dragDropInfo = new DragDropInfo(view, channel.NewProgramNr); + this.dragDropInfo = new DragDropInfo(view, channel.GetPosition(this.subListIndex)); view.GridControl.DoDragDrop(this.dragDropInfo, DragDropEffects.Move); this.downHit = null; } @@ -1817,7 +1874,7 @@ namespace ChanSort.Ui var vi = (DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo)this.gviewLeft.GetViewInfo(); var rowInfo = vi.GetGridRowInfo(hit.RowHandle); ChannelInfo dropChannel = (ChannelInfo)this.gviewLeft.GetRow(hit.RowHandle); - bool moveUp = this.dragDropInfo.SourceProgramNumber < 0 || dropChannel.NewProgramNr <= this.dragDropInfo.SourceProgramNumber; + bool moveUp = this.dragDropInfo.SourcePosition < 0 || dropChannel.GetPosition(this.subListIndex) <= this.dragDropInfo.SourcePosition; if (moveUp && point.Y < rowInfo.Bounds.Top + rowInfo.Bounds.Height / 2) this.dragDropInfo.EditMode = EditMode.InsertBefore; else if (!moveUp && point.Y > rowInfo.Bounds.Top + rowInfo.Bounds.Height / 2) @@ -1850,17 +1907,19 @@ namespace ChanSort.Ui var selectedChannels = this.GetSelectedChannels(this.dragDropInfo.SourceView); int newProgNr; + int dropPos = dropChannel.GetPosition(this.subListIndex); if (this.dragDropInfo.EditMode != EditMode.InsertAfter || !this.cbCloseGap.Checked) - newProgNr = dropChannel.NewProgramNr; + newProgNr = dropPos; else { int numberOfChannelsToMoveDown = 0; foreach (var channel in selectedChannels) { - if (channel.NewProgramNr <= dropChannel.NewProgramNr) + int curPos = channel.GetPosition(this.subListIndex); + if (curPos != -1 && curPos <= dropPos) ++numberOfChannelsToMoveDown; } - newProgNr = dropChannel.NewProgramNr + 1 - numberOfChannelsToMoveDown; + newProgNr = dropPos + 1 - numberOfChannelsToMoveDown; } this.editor.SetSlotNumber(selectedChannels, newProgNr, this.dragDropInfo.EditMode == EditMode.Swap, this.cbCloseGap.Checked); @@ -1897,16 +1956,7 @@ namespace ChanSort.Ui private void gviewLeft_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) { - var channel = (ChannelInfo)this.gviewLeft.GetRow(e.FocusedRowHandle); - if (channel == null) - return; - int programNr = channel.NewProgramNr; - if (this.rbInsertAfter.Checked) - ++programNr; - if (this.currentChannelList != null) - this.currentChannelList.InsertProgramNumber = programNr; - this.UpdateInsertSlotTextBox(); - this.gviewLeft.SelectRow(e.FocusedRowHandle); + TryExecute(UpdateInsertSlotNumber); } #endregion @@ -2064,7 +2114,7 @@ namespace ChanSort.Ui e.Appearance.ForeColor = Color.Red; e.Appearance.Options.UseForeColor = true; } - else if (channel.NewProgramNr != -1) + else if (channel.GetPosition(this.subListIndex) != -1) { e.Appearance.ForeColor = Color.Gray; e.Appearance.Options.UseForeColor = true; @@ -2300,5 +2350,6 @@ namespace ChanSort.Ui this.SetActiveGrid(this.gviewRight); } #endregion + } } diff --git a/ChanSort/MainForm.de.resx b/ChanSort/MainForm.de.resx index 44e2e4f..1234960 100644 --- a/ChanSort/MainForm.de.resx +++ b/ChanSort/MainForm.de.resx @@ -328,7 +328,7 @@ Programplatz für Einfügen und Festlegen - ChanSort {0} - Senderlisten-Editor für Samsung, LG und Toshiba TVs + ChanSort {0} - Senderlisten-Editor für Samsung, LG, Panasonic und Toshiba TVs Kindersicherung diff --git a/ChanSort/MainForm.resx b/ChanSort/MainForm.resx index 022545c..d9d7c5a 100644 --- a/ChanSort/MainForm.resx +++ b/ChanSort/MainForm.resx @@ -123,7 +123,7 @@ - 0, 81 + 0, 108 361, 17 @@ -234,7 +234,7 @@ Numeric - 382, 445 + 382, 418 1 @@ -255,7 +255,7 @@ Bottom - 2, 499 + 2, 472 2, 2, 2, 2 @@ -293,6 +293,78 @@ 1474, 599 + + Bottom, Left, Right + + + 0, 5 + + + 1463, 0 + + + Pr# + + + pageProgNr + + + DevExpress.XtraTab.XtraTabPage, DevExpress.XtraEditors.v12.2, Version=12.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + + tabSubList + + + 0 + + + 1469, 22 + + + 6 + + + tabSubList + + + DevExpress.XtraTab.XtraTabControl, DevExpress.XtraEditors.v12.2, Version=12.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + + grpSubList + + + 0 + + + Top + + + 0, 81 + + + 1474, 27 + + + 10 + + + Sub List + + + False + + + grpSubList + + + DevExpress.XtraEditors.GroupControl, DevExpress.Utils.v12.2, Version=12.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + + $this + + + 1 + 256, 6 @@ -497,7 +569,7 @@ $this - 5 + 6 Bottom @@ -518,7 +590,7 @@ $this - 4 + 5 Left @@ -539,7 +611,7 @@ $this - 2 + 3 Right @@ -560,7 +632,7 @@ $this - 3 + 4 Move up @@ -726,13 +798,13 @@ 5 - Bottom, Left + Bottom, Left, Right 0, 33 - 632, 0 + 1284, 0 No channel lists @@ -750,7 +822,7 @@ 0 - 638, 22 + 1290, 22 5 @@ -852,7 +924,7 @@ $this - 1 + 2 CenterScreen @@ -1431,7 +1503,7 @@ DevExpress.XtraEditors.XtraForm, DevExpress.Utils.v12.2, Version=12.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - 06/29/2013 12:47:45 + 07/02/2013 20:57:05 16, 16 @@ -1749,7 +1821,7 @@ 0, 0 - 386, 518 + 386, 491 0 @@ -2085,7 +2157,7 @@ Signal source - 1079, 445 + 1079, 418 1 @@ -2106,7 +2178,7 @@ Bottom - 2, 499 + 2, 472 2, 2, 2, 2 @@ -2274,7 +2346,7 @@ 0, 0 - 1083, 518 + 1083, 491 0 @@ -2298,7 +2370,7 @@ Panel2 - 1474, 518 + 1474, 491 5 diff --git a/readme.txt b/readme.txt index 52355ad..3c1c03c 100644 --- a/readme.txt +++ b/readme.txt @@ -1,17 +1,18 @@ -Version v2013-07-01 ====================================================== +Version v2013-07-03 ====================================================== -This version is identical to Beta v2013-06-29.3 -Changes since last official version v2013-06-24: -- Added support for Panasonic channel list (svl.db and svl.bin format) -- Translated UI to Portuguese (Thanks to Vitor Martins Augusto) +Changes: +- Support for individually sorted favorite lists, if supported by TV + (e.g. Samsung E and F series, Panasonic Viera) +- FIX: "insert after" using drag and drop from right to left list + inserted before instead of after the drop position The complete change log can be found at the end of this document About ChanSort ============================================================ -ChanSort is a program to manage your Samsung, LG or Toshiba TV's channel -list on your PC. +ChanSort is a program to manage your Samsung, LG, Toshiba or Panasonic TV's +channel list on your PC. It allows you to change program numbers and channel names, select your favorites, set a parental lock and much more. With its multi-selection @@ -103,6 +104,15 @@ OTHER DEALINGS IN THE SOFTWARE. Change log ================================================================ +2013-07-03 +- Support for individually sorted favorite lists, if supported by TV + (e.g. Samsung E and F series, Panasonic Viera) +- FIX: "insert after" using drag and drop from right to left list + inserted before instead of after the drop position + +2013-07-02 +- FIX: wrong version number (caused a popup about a newer version online) + 2013-07-01 - Added support for Panasonic channel list (svl.db and svl.bin format) - Translated UI to Portuguese (Thanks to Vitor Martins Augusto)