From cc80c6ae70aa05e6e86fad069af93d4cc5b51bd6 Mon Sep 17 00:00:00 2001 From: Horst Beham Date: Sun, 4 Dec 2022 18:18:52 +0100 Subject: [PATCH] - fixed: various .xml file formats could not be loaded anymore - channels can also be swapped now be directly selecting two rows and clicking on "swap" - swapping mark (strike through) is now automatically removed after swapping - swapping is now recognized as a change and will prompt to save the list on exit --- .../Binary/TllFileSerializer.cs | 2 +- .../ChanSort.Loader.Philips/PhilipsPlugin.cs | 4 ++- source/ChanSort/MainForm.cs | 35 ++++++++++++++++--- source/changelog.md | 6 ++++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/source/ChanSort.Loader.LG/Binary/TllFileSerializer.cs b/source/ChanSort.Loader.LG/Binary/TllFileSerializer.cs index 098de29..16523a0 100644 --- a/source/ChanSort.Loader.LG/Binary/TllFileSerializer.cs +++ b/source/ChanSort.Loader.LG/Binary/TllFileSerializer.cs @@ -166,7 +166,7 @@ namespace ChanSort.Loader.LG.Binary this.fileContent = File.ReadAllBytes(this.FileName); if (this.fileContent[0] == '<') - throw LoaderException.Fail("Invalid binary TLL file format. Maybe a GlobalClone/XML file?"); + throw LoaderException.TryNext("Invalid binary TLL file format. Maybe a GlobalClone/XML file?"); int off = 0; diff --git a/source/ChanSort.Loader.Philips/PhilipsPlugin.cs b/source/ChanSort.Loader.Philips/PhilipsPlugin.cs index 1849606..98db765 100644 --- a/source/ChanSort.Loader.Philips/PhilipsPlugin.cs +++ b/source/ChanSort.Loader.Philips/PhilipsPlugin.cs @@ -138,7 +138,9 @@ namespace ChanSort.Loader.Philips if (majorVersion == -1) return new DbSerializer(inputFile); - throw LoaderException.Fail(majorVersion == int.MinValue ? SerializerBase.ERR_UnknownFormat : $"Philips ChannelMap format version {majorVersion} is not supported (yet)."); + if (majorVersion != int.MinValue) + throw LoaderException.Fail($"Philips ChannelMap format version {majorVersion} is not supported (yet)."); + throw LoaderException.TryNext(SerializerBase.ERR_UnknownFormat); } } } diff --git a/source/ChanSort/MainForm.cs b/source/ChanSort/MainForm.cs index abecb8a..e4753ee 100644 --- a/source/ChanSort/MainForm.cs +++ b/source/ChanSort/MainForm.cs @@ -1804,7 +1804,7 @@ namespace ChanSort.Ui this.miMarkForSwapping.Enabled = mayEdit && sel.Count == 1; this.miMarkForSwapping.Down = swapMarkChannel != null; - this.miSwapWithMarked.Enabled = mayEdit && swapMarkList != null && this.CurrentChannelList == swapMarkList; + this.miSwapWithMarked.Enabled = mayEdit && (sel.Count == 2 || swapMarkList != null && this.CurrentChannelList == swapMarkList); this.miSkipOn.Enabled = this.miSkipOff.Enabled = this.currentTvSerializer?.Features.CanSkipChannels ?? false; this.miLockOn.Enabled = this.miLockOff.Enabled = this.currentTvSerializer?.Features.CanLockChannels ?? false; this.miHideOn.Enabled = this.miHideOff.Enabled = this.currentTvSerializer?.Features.CanHideChannels ?? false; @@ -2057,9 +2057,6 @@ namespace ChanSort.Ui private void SwapWithMarked() { - if (this.swapMarkList == null || this.swapMarkList != this.CurrentChannelList || this.swapMarkSubList != this.subListIndex) - return; - GridView gv; if (this.gridLeft.ContainsFocus) gv = this.gviewLeft; @@ -2069,6 +2066,26 @@ namespace ChanSort.Ui return; var chanB = (ChannelInfo)gv.FocusedRowObject; + + if (this.swapMarkList == null || this.swapMarkList != this.CurrentChannelList || this.swapMarkSubList != this.subListIndex) + { + if (gv.SelectedRowsCount != 2) + return; + + // allow implicit selection of 2 channels to swap + var sel = GetSelectedChannels(gv); + if (sel[0] == chanB) + this.swapMarkChannel = sel[1]; + else if (sel[1] == chanB) + this.swapMarkChannel = sel[0]; + else + return; + + this.swapMarkList = this.CurrentChannelList; + this.swapMarkSubList = this.subListIndex; + } + + if (chanB == null || chanB == this.swapMarkChannel) return; @@ -2079,10 +2096,20 @@ namespace ChanSort.Ui this.gviewLeft.BeginDataUpdate(); this.gviewRight.BeginDataUpdate(); + this.swapMarkChannel.NewProgramNr = chanB.NewProgramNr; chanB.NewProgramNr = nrA; + + this.miMarkForSwapping.Down = false; + this.swapMarkList = null; + this.swapMarkSubList = -1; + this.swapMarkChannel = null; + this.gviewRight.EndDataUpdate(); this.gviewLeft.EndDataUpdate(); + + this.DataRoot.NeedsSaving = true; + } #endregion diff --git a/source/changelog.md b/source/changelog.md index a6b4907..87be1d3 100644 --- a/source/changelog.md +++ b/source/changelog.md @@ -1,6 +1,12 @@ ChanSort Change Log =================== +2022-12-04 +- fixed: various .xml file formats could not be loaded anymore +- channels can also be swapped now be directly selecting two rows and clicking on "swap" +- swapping mark (strike through) is now automatically removed after swapping +- swapping is now recognized as a change and will prompt to save the list on exit + 2022-11-30 - fixed Samsung .zip lists changing channel names to "Chinese" characters in the saved file (caused by a breaking change in the new version of the Microsoft.Data.Sqlite library)