diff --git a/source/ChanSort.Api/Controller/Editor.cs b/source/ChanSort.Api/Controller/Editor.cs index f68744c..3f01b62 100644 --- a/source/ChanSort.Api/Controller/Editor.cs +++ b/source/ChanSort.Api/Controller/Editor.cs @@ -200,7 +200,7 @@ namespace ChanSort.Api foreach (var channelList in this.DataRoot.ChannelLists) { foreach (var channel in channelList.Channels) - channel.SetPosition(this.SubListIndex, -1); + channel.SetPosition(0, -1); } StringBuilder log = new StringBuilder(); @@ -212,47 +212,76 @@ namespace ChanSort.Api log.AppendFormat("Skipped reference list {0}\r\n", refList.ShortCaption); continue; } - foreach (var refChannel in refList.Channels) + ApplyReferenceList(refDataRoot, refList, tvList); + } + } + + public void ApplyReferenceList(DataRoot refDataRoot, ChannelList refList, ChannelList tvList, bool addProxyChannels = true, int positionOffset = 0, Predicate chanFilter = null) + { + foreach (var refChannel in refList.Channels) + { + if (!(chanFilter?.Invoke(refChannel) ?? true)) + continue; + + var tvChannels = tvList.GetChannelByUid(refChannel.Uid); + if (tvChannels.Count == 0 && !string.IsNullOrWhiteSpace(refChannel.Name)) + tvChannels = tvList.GetChannelByName(refChannel.Name).ToList(); + ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.GetPosition(0) == -1); + if (tvChannel == null && tvChannels.Count > 0) + tvChannel = tvChannels[0]; + + if (tvChannel != null) { - var tvChannels = tvList.GetChannelByUid(refChannel.Uid); - ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.GetPosition(this.SubListIndex) == -1); - if (tvChannel != null) + if (!(chanFilter?.Invoke(tvChannel) ?? true)) + continue; + + var curChans = tvList.GetChannelByNewProgNr(refChannel.OldProgramNr + positionOffset); + foreach (var chan in curChans) + chan.NewProgramNr = -1; + + tvChannel.SetPosition(0, refChannel.OldProgramNr + positionOffset); + tvChannel.Skip = refChannel.Skip; + tvChannel.Lock = refChannel.Lock; + tvChannel.Hidden = refChannel.Hidden; + tvChannel.IsDeleted = refChannel.IsDeleted; + if ((tvChannel.SignalSource & SignalSource.Analog) != 0 && !string.IsNullOrEmpty(refChannel.Name)) { - tvChannel.SetPosition(this.SubListIndex, refChannel.OldProgramNr); - tvChannel.Favorites = refChannel.Favorites & DataRoot.SupportedFavorites; - tvChannel.Skip = refChannel.Skip; - tvChannel.Lock = refChannel.Lock; - tvChannel.Hidden = refChannel.Hidden; - tvChannel.IsDeleted = refChannel.IsDeleted; - if ((tvChannel.SignalSource & SignalSource.Analog) != 0) - { - tvChannel.Name = refChannel.Name; - tvChannel.IsNameModified = true; - } - if (this.DataRoot.SortedFavorites) - { - if (refDataRoot.SortedFavorites) - { - var c = Math.Min(refChannel.FavIndex.Count, tvChannel.FavIndex.Count); - for (int i = 0; i < c; i++) - tvChannel.FavIndex[i] = refChannel.FavIndex[i]; - } - else - { - this.ApplyPrNrToFavLists(tvChannel); - } - } - } - else - { - tvChannel = new ChannelInfo(refChannel.SignalSource, refChannel.Uid, refChannel.OldProgramNr, - refChannel.Name); - tvList.AddChannel(tvChannel); + tvChannel.Name = refChannel.Name; + tvChannel.IsNameModified = true; } + + ApplyFavorites(refDataRoot, refChannel, tvChannel); + } + else if (addProxyChannels) + { + tvChannel = new ChannelInfo(refChannel.SignalSource, refChannel.Uid, refChannel.OldProgramNr, refChannel.Name); + tvList.AddChannel(tvChannel); } } } + private void ApplyFavorites(DataRoot refDataRoot, ChannelInfo refChannel, ChannelInfo tvChannel) + { + if (this.DataRoot.SortedFavorites) + { + if (!this.DataRoot.MixedSourceFavorites || refDataRoot.MixedSourceFavorites) + { + tvChannel.Favorites = refChannel.Favorites & DataRoot.SupportedFavorites; + if (refDataRoot.SortedFavorites) + { + var c = Math.Min(refChannel.FavIndex.Count, tvChannel.FavIndex.Count); + for (int i = 0; i < c; i++) + tvChannel.FavIndex[i] = refChannel.FavIndex[i]; + } + else + this.ApplyPrNrToFavLists(tvChannel); + } + } + else + { + tvChannel.Favorites = refChannel.Favorites & DataRoot.SupportedFavorites; + } + } #endregion diff --git a/source/ChanSort.Loader.Hisense/HisDbSerializer.cs b/source/ChanSort.Loader.Hisense/HisDbSerializer.cs index 874902a..d4bfb24 100644 --- a/source/ChanSort.Loader.Hisense/HisDbSerializer.cs +++ b/source/ChanSort.Loader.Hisense/HisDbSerializer.cs @@ -521,6 +521,10 @@ namespace ChanSort.Loader.Hisense private void UpdateChannel(SQLiteCommand cmd, ChannelInfo ci) { + //return; + if (ci.RecordIndex < 0) // skip reference list proxy channels + return; + int x = (int) ((ulong) ci.RecordIndex >> 32); // the table number is kept in the higher 32 bits int id = (int) (ci.RecordIndex & 0xFFFFFFFF); // the record id is kept in the lower 32 bits @@ -529,8 +533,12 @@ namespace ChanSort.Loader.Hisense if (ci.Lock) setFlags |= NwMask.Lock; if (!ci.Hidden && ci.NewProgramNr >= 0) setFlags |= NwMask.Visible; - cmd.CommandText = $"update svl_{x} set channel_id=(channel_id&{0xFFFC})|@chnr, ac_name=@name, " + - $"option_mask=option_mask|{(int) (OptionMask.ChNumEdited | OptionMask.NameEdited)}, nw_mask=(nw_mask&@resetFlags)|@setFlags where svl_rec_id=@id"; + cmd.CommandText = $"update svl_{x} set channel_id=(channel_id&{0x3FFFF})|(@chnr << 18)" + + ", ch_id_txt=@chnr || ' 0'" + + ", ac_name=@name" + + $", option_mask=option_mask|{(int) (OptionMask.ChNumEdited | OptionMask.NameEdited)}" + + ", nw_mask=(nw_mask&@resetFlags)|@setFlags" + + " where svl_rec_id=@id"; cmd.Parameters.Clear(); cmd.Parameters.Add("@id", DbType.Int32); cmd.Parameters.Add("@chnr", DbType.Int32); @@ -538,7 +546,7 @@ namespace ChanSort.Loader.Hisense cmd.Parameters.Add("@resetFlags", DbType.Int32); cmd.Parameters.Add("@setFlags", DbType.Int32); cmd.Parameters["@id"].Value = id; - cmd.Parameters["@chnr"].Value = ci.NewProgramNr << 18; + cmd.Parameters["@chnr"].Value = ci.NewProgramNr; cmd.Parameters["@name"].Value = ci.Name; cmd.Parameters["@resetFlags"].Value = ~(int) resetFlags; cmd.Parameters["@setFlags"].Value = (int) setFlags; diff --git a/source/ChanSort/MainForm.cs b/source/ChanSort/MainForm.cs index da0040e..c87ac03 100644 --- a/source/ChanSort/MainForm.cs +++ b/source/ChanSort/MainForm.cs @@ -76,6 +76,7 @@ namespace ChanSort.Ui internal IList Plugins => plugins; internal DataRoot DataRoot => dataRoot; internal Editor Editor => editor; + internal ChannelList CurrentChannelList => currentChannelList; #region ctor() public MainForm() @@ -1548,6 +1549,12 @@ namespace ChanSort.Ui #endregion #region RefreshGrid() + + internal void RefreshGrids() + { + RefreshGrid(this.gviewLeft, this.gviewRight); + } + private void RefreshGrid(params GridView[] grids) { foreach (var grid in grids) diff --git a/source/ChanSort/MainForm.de.resx b/source/ChanSort/MainForm.de.resx index 0702baa..99e3bc7 100644 --- a/source/ChanSort/MainForm.de.resx +++ b/source/ChanSort/MainForm.de.resx @@ -357,12 +357,6 @@ speziellen Anbieter, Satelliten oder Länderlisten aus. dahinter - - ChanSort {0} - Editor für TV-Senderlisten - - - Kindersicherung bei markierten Sendern ein/ausschalten - Kindersicherung @@ -552,6 +546,12 @@ speziellen Anbieter, Satelliten oder Länderlisten aus. Programplatz für Einfügen und Festlegen + + ChanSort {0} - Editor für TV-Senderlisten + + + Kindersicherung bei markierten Sendern ein/ausschalten + 333, 17 diff --git a/source/ChanSort/MainForm.pt.resx b/source/ChanSort/MainForm.pt.resx index 16af7da..5198625 100644 --- a/source/ChanSort/MainForm.pt.resx +++ b/source/ChanSort/MainForm.pt.resx @@ -194,9 +194,6 @@ Depois - - ChanSort {0} - Editor de listas de canais para televisores Samsung, LG, Panasonic e Toshiba - Parental lock @@ -326,6 +323,9 @@ Acrescentar e definar posição de canal + + ChanSort {0} - Editor de listas de canais para televisores Samsung, LG, Panasonic e Toshiba + Tipo serviço diff --git a/source/ChanSort/MainForm.resx b/source/ChanSort/MainForm.resx index 8aeec23..67bacd3 100644 --- a/source/ChanSort/MainForm.resx +++ b/source/ChanSort/MainForm.resx @@ -1890,12 +1890,6 @@ specific provider, satellite or country lists. after - - ChanSort {0} - TV Channel List Editor - - - Toggle parental lock - Parental lock @@ -2145,6 +2139,12 @@ specific provider, satellite or country lists. \d{1,4} + + ChanSort {0} - TV Channel List Editor + + + Toggle parental lock + 157, 5 diff --git a/source/ChanSort/MainForm.ru.resx b/source/ChanSort/MainForm.ru.resx index 3a34c63..038e24c 100644 --- a/source/ChanSort/MainForm.ru.resx +++ b/source/ChanSort/MainForm.ru.resx @@ -303,9 +303,6 @@ после - - ChanSort {0} - редактор списка каналов для телевизоров Samsung, LG, Pansonic и Toshiba - Родительский контроль @@ -462,6 +459,9 @@ Номер программы для добавления и настройки операций + + ChanSort {0} - редактор списка каналов для телевизоров Samsung, LG, Pansonic и Toshiba + Тип сервиса diff --git a/source/ChanSort/ReferenceListForm.Designer.cs b/source/ChanSort/ReferenceListForm.Designer.cs index 7db36e2..fff6655 100644 --- a/source/ChanSort/ReferenceListForm.Designer.cs +++ b/source/ChanSort/ReferenceListForm.Designer.cs @@ -44,14 +44,9 @@ this.labelControl6 = new DevExpress.XtraEditors.LabelControl(); this.comboPrNr = new DevExpress.XtraEditors.ComboBoxEdit(); this.grpManual = new DevExpress.XtraEditors.GroupControl(); - this.cbIP = new DevExpress.XtraEditors.CheckEdit(); this.labelControl9 = new DevExpress.XtraEditors.LabelControl(); this.cbAnalog = new DevExpress.XtraEditors.CheckEdit(); this.cbDigital = new DevExpress.XtraEditors.CheckEdit(); - this.labelControl8 = new DevExpress.XtraEditors.LabelControl(); - this.cbSatellite = new DevExpress.XtraEditors.CheckEdit(); - this.cbAntenna = new DevExpress.XtraEditors.CheckEdit(); - this.cbCable = new DevExpress.XtraEditors.CheckEdit(); this.lblTargetInfo = new DevExpress.XtraEditors.LabelControl(); this.lblSourceInfo = new DevExpress.XtraEditors.LabelControl(); this.labelControl7 = new DevExpress.XtraEditors.LabelControl(); @@ -68,12 +63,8 @@ ((System.ComponentModel.ISupportInitialize)(this.comboPrNr.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.grpManual)).BeginInit(); this.grpManual.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.cbIP.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cbAnalog.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cbDigital.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.cbSatellite.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.cbAntenna.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.cbCable.Properties)).BeginInit(); this.SuspendLayout(); // // labelControl1 @@ -136,82 +127,82 @@ // // labelControl3 // - this.labelControl3.Location = new System.Drawing.Point(5, 10); + this.labelControl3.Location = new System.Drawing.Point(5, 36); this.labelControl3.Name = "labelControl3"; this.labelControl3.Size = new System.Drawing.Size(73, 13); - this.labelControl3.TabIndex = 0; + this.labelControl3.TabIndex = 3; this.labelControl3.Text = "Reference List:"; // // comboSource // - this.comboSource.Location = new System.Drawing.Point(123, 7); + this.comboSource.Location = new System.Drawing.Point(123, 33); this.comboSource.Name = "comboSource"; this.comboSource.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); this.comboSource.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; this.comboSource.Size = new System.Drawing.Size(178, 20); - this.comboSource.TabIndex = 1; + this.comboSource.TabIndex = 4; this.comboSource.EditValueChanged += new System.EventHandler(this.comboSource_EditValueChanged); // // comboTarget // - this.comboTarget.Location = new System.Drawing.Point(123, 33); + this.comboTarget.Location = new System.Drawing.Point(123, 7); this.comboTarget.Name = "comboTarget"; this.comboTarget.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); this.comboTarget.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; this.comboTarget.Size = new System.Drawing.Size(178, 20); - this.comboTarget.TabIndex = 4; + this.comboTarget.TabIndex = 1; this.comboTarget.EditValueChanged += new System.EventHandler(this.comboTarget_EditValueChanged); // // labelControl4 // - this.labelControl4.Location = new System.Drawing.Point(5, 36); + this.labelControl4.Location = new System.Drawing.Point(5, 10); this.labelControl4.Name = "labelControl4"; this.labelControl4.Size = new System.Drawing.Size(55, 13); - this.labelControl4.TabIndex = 3; + this.labelControl4.TabIndex = 0; this.labelControl4.Text = "Target List:"; // // cbTv // - this.cbTv.Location = new System.Drawing.Point(123, 109); + this.cbTv.Location = new System.Drawing.Point(123, 84); this.cbTv.Name = "cbTv"; this.cbTv.Properties.AutoWidth = true; this.cbTv.Properties.Caption = "TV"; this.cbTv.Size = new System.Drawing.Size(34, 19); - this.cbTv.TabIndex = 15; + this.cbTv.TabIndex = 10; this.cbTv.TabStop = false; // // cbRadio // - this.cbRadio.Location = new System.Drawing.Point(204, 109); + this.cbRadio.Location = new System.Drawing.Point(204, 84); this.cbRadio.Name = "cbRadio"; this.cbRadio.Properties.AutoWidth = true; this.cbRadio.Properties.Caption = "Radio"; this.cbRadio.Size = new System.Drawing.Size(49, 19); - this.cbRadio.TabIndex = 16; + this.cbRadio.TabIndex = 11; this.cbRadio.TabStop = false; // // labelControl5 // - this.labelControl5.Location = new System.Drawing.Point(5, 137); + this.labelControl5.Location = new System.Drawing.Point(5, 112); this.labelControl5.Name = "labelControl5"; this.labelControl5.Size = new System.Drawing.Size(62, 13); - this.labelControl5.TabIndex = 17; + this.labelControl5.TabIndex = 12; this.labelControl5.Text = "Start at Pr#:"; // // labelControl6 // - this.labelControl6.Location = new System.Drawing.Point(204, 137); + this.labelControl6.Location = new System.Drawing.Point(204, 112); this.labelControl6.Name = "labelControl6"; this.labelControl6.Size = new System.Drawing.Size(177, 13); - this.labelControl6.TabIndex = 19; + this.labelControl6.TabIndex = 14; this.labelControl6.Text = "(i.e. let radio channels start at 5000)"; // // comboPrNr // this.comboPrNr.EditValue = "1"; - this.comboPrNr.Location = new System.Drawing.Point(123, 134); + this.comboPrNr.Location = new System.Drawing.Point(123, 109); this.comboPrNr.Name = "comboPrNr"; this.comboPrNr.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); @@ -225,20 +216,15 @@ "5000", "9000"}); this.comboPrNr.Size = new System.Drawing.Size(75, 20); - this.comboPrNr.TabIndex = 18; + this.comboPrNr.TabIndex = 13; // // grpManual // this.grpManual.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.grpManual.Controls.Add(this.cbIP); this.grpManual.Controls.Add(this.labelControl9); this.grpManual.Controls.Add(this.cbAnalog); this.grpManual.Controls.Add(this.cbDigital); - this.grpManual.Controls.Add(this.labelControl8); - this.grpManual.Controls.Add(this.cbSatellite); - this.grpManual.Controls.Add(this.cbAntenna); - this.grpManual.Controls.Add(this.cbCable); this.grpManual.Controls.Add(this.lblTargetInfo); this.grpManual.Controls.Add(this.lblSourceInfo); this.grpManual.Controls.Add(this.labelControl7); @@ -246,134 +232,87 @@ this.grpManual.Controls.Add(this.comboSource); this.grpManual.Controls.Add(this.comboPrNr); this.grpManual.Controls.Add(this.labelControl3); - this.grpManual.Controls.Add(this.labelControl6); - this.grpManual.Controls.Add(this.labelControl4); - this.grpManual.Controls.Add(this.labelControl5); this.grpManual.Controls.Add(this.comboTarget); + this.grpManual.Controls.Add(this.labelControl4); + this.grpManual.Controls.Add(this.labelControl6); + this.grpManual.Controls.Add(this.labelControl5); this.grpManual.Controls.Add(this.cbTv); this.grpManual.Controls.Add(this.cbRadio); this.grpManual.Enabled = false; this.grpManual.Location = new System.Drawing.Point(71, 129); this.grpManual.Name = "grpManual"; this.grpManual.ShowCaption = false; - this.grpManual.Size = new System.Drawing.Size(609, 201); + this.grpManual.Size = new System.Drawing.Size(609, 177); this.grpManual.TabIndex = 5; this.grpManual.Text = "grpManual"; // - // cbIP - // - this.cbIP.Location = new System.Drawing.Point(369, 59); - this.cbIP.Name = "cbIP"; - this.cbIP.Properties.AutoWidth = true; - this.cbIP.Properties.Caption = "IP"; - this.cbIP.Size = new System.Drawing.Size(32, 19); - this.cbIP.TabIndex = 10; - this.cbIP.TabStop = false; - // // labelControl9 // - this.labelControl9.Location = new System.Drawing.Point(5, 87); + this.labelControl9.Location = new System.Drawing.Point(5, 62); this.labelControl9.Name = "labelControl9"; this.labelControl9.Size = new System.Drawing.Size(59, 13); - this.labelControl9.TabIndex = 11; + this.labelControl9.TabIndex = 6; this.labelControl9.Text = "Signal Type:"; // // cbAnalog // - this.cbAnalog.Location = new System.Drawing.Point(123, 84); + this.cbAnalog.Location = new System.Drawing.Point(123, 59); this.cbAnalog.Name = "cbAnalog"; this.cbAnalog.Properties.AutoWidth = true; this.cbAnalog.Properties.Caption = "Analog"; this.cbAnalog.Size = new System.Drawing.Size(55, 19); - this.cbAnalog.TabIndex = 12; + this.cbAnalog.TabIndex = 7; this.cbAnalog.TabStop = false; // // cbDigital // - this.cbDigital.Location = new System.Drawing.Point(204, 84); + this.cbDigital.Location = new System.Drawing.Point(204, 59); this.cbDigital.Name = "cbDigital"; this.cbDigital.Properties.AutoWidth = true; this.cbDigital.Properties.Caption = "Digital"; this.cbDigital.Size = new System.Drawing.Size(51, 19); - this.cbDigital.TabIndex = 13; + this.cbDigital.TabIndex = 8; this.cbDigital.TabStop = false; // - // labelControl8 - // - this.labelControl8.Location = new System.Drawing.Point(5, 62); - this.labelControl8.Name = "labelControl8"; - this.labelControl8.Size = new System.Drawing.Size(68, 13); - this.labelControl8.TabIndex = 6; - this.labelControl8.Text = "Signal Source:"; - // - // cbSatellite - // - this.cbSatellite.Location = new System.Drawing.Point(283, 59); - this.cbSatellite.Name = "cbSatellite"; - this.cbSatellite.Properties.AutoWidth = true; - this.cbSatellite.Properties.Caption = "Satellite"; - this.cbSatellite.Size = new System.Drawing.Size(60, 19); - this.cbSatellite.TabIndex = 9; - this.cbSatellite.TabStop = false; - // - // cbAntenna - // - this.cbAntenna.Location = new System.Drawing.Point(123, 59); - this.cbAntenna.Name = "cbAntenna"; - this.cbAntenna.Properties.AutoWidth = true; - this.cbAntenna.Properties.Caption = "Antenna"; - this.cbAntenna.Size = new System.Drawing.Size(63, 19); - this.cbAntenna.TabIndex = 7; - this.cbAntenna.TabStop = false; - // - // cbCable - // - this.cbCable.Location = new System.Drawing.Point(204, 59); - this.cbCable.Name = "cbCable"; - this.cbCable.Properties.AutoWidth = true; - this.cbCable.Properties.Caption = "Cable"; - this.cbCable.Size = new System.Drawing.Size(49, 19); - this.cbCable.TabIndex = 8; - this.cbCable.TabStop = false; - // // lblTargetInfo // - this.lblTargetInfo.Location = new System.Drawing.Point(308, 36); + this.lblTargetInfo.Location = new System.Drawing.Point(308, 10); this.lblTargetInfo.Name = "lblTargetInfo"; this.lblTargetInfo.Size = new System.Drawing.Size(3, 13); - this.lblTargetInfo.TabIndex = 5; + this.lblTargetInfo.TabIndex = 2; this.lblTargetInfo.Text = " "; // // lblSourceInfo // - this.lblSourceInfo.Location = new System.Drawing.Point(308, 10); + this.lblSourceInfo.Location = new System.Drawing.Point(308, 36); this.lblSourceInfo.Name = "lblSourceInfo"; this.lblSourceInfo.Size = new System.Drawing.Size(3, 13); - this.lblSourceInfo.TabIndex = 2; + this.lblSourceInfo.TabIndex = 5; this.lblSourceInfo.Text = " "; // // labelControl7 // - this.labelControl7.Location = new System.Drawing.Point(5, 112); + this.labelControl7.Location = new System.Drawing.Point(5, 87); this.labelControl7.Name = "labelControl7"; this.labelControl7.Size = new System.Drawing.Size(70, 13); - this.labelControl7.TabIndex = 14; + this.labelControl7.TabIndex = 9; this.labelControl7.Text = "Channel Type:"; // // btnApply // this.btnApply.Enabled = false; - this.btnApply.Location = new System.Drawing.Point(123, 169); + this.btnApply.Location = new System.Drawing.Point(123, 144); this.btnApply.Name = "btnApply"; this.btnApply.Size = new System.Drawing.Size(103, 23); - this.btnApply.TabIndex = 20; + this.btnApply.TabIndex = 15; this.btnApply.Text = "Apply"; this.btnApply.Click += new System.EventHandler(this.btnApply_Click); // // btnOk // this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOk.Location = new System.Drawing.Point(497, 346); + this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOk.Location = new System.Drawing.Point(497, 321); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(88, 23); this.btnOk.TabIndex = 6; @@ -384,7 +323,7 @@ // this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnClose.Location = new System.Drawing.Point(592, 346); + this.btnClose.Location = new System.Drawing.Point(592, 321); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(88, 23); this.btnClose.TabIndex = 7; @@ -394,7 +333,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(692, 381); + this.ClientSize = new System.Drawing.Size(692, 356); this.Controls.Add(this.btnClose); this.Controls.Add(this.btnOk); this.Controls.Add(this.grpManual); @@ -417,12 +356,8 @@ ((System.ComponentModel.ISupportInitialize)(this.grpManual)).EndInit(); this.grpManual.ResumeLayout(false); this.grpManual.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.cbIP.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cbAnalog.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cbDigital.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.cbSatellite.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.cbAntenna.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.cbCable.Properties)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -451,13 +386,8 @@ private DevExpress.XtraEditors.LabelControl labelControl7; private DevExpress.XtraEditors.LabelControl lblTargetInfo; private DevExpress.XtraEditors.LabelControl lblSourceInfo; - private DevExpress.XtraEditors.LabelControl labelControl8; - private DevExpress.XtraEditors.CheckEdit cbSatellite; - private DevExpress.XtraEditors.CheckEdit cbAntenna; - private DevExpress.XtraEditors.CheckEdit cbCable; private DevExpress.XtraEditors.LabelControl labelControl9; private DevExpress.XtraEditors.CheckEdit cbAnalog; private DevExpress.XtraEditors.CheckEdit cbDigital; - private DevExpress.XtraEditors.CheckEdit cbIP; } } \ No newline at end of file diff --git a/source/ChanSort/ReferenceListForm.cs b/source/ChanSort/ReferenceListForm.cs index 3b4ee9e..adf0634 100644 --- a/source/ChanSort/ReferenceListForm.cs +++ b/source/ChanSort/ReferenceListForm.cs @@ -1,21 +1,18 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Linq; +using System.Text; using System.Windows.Forms; using ChanSort.Api; using ChanSort.Ui.Properties; using DevExpress.XtraEditors; +using DevExpress.XtraEditors.Controls; namespace ChanSort.Ui { - public partial class ReferenceListForm : DevExpress.XtraEditors.XtraForm + public partial class ReferenceListForm : XtraForm { private readonly MainForm main; - private SerializerBase ser; + private SerializerBase serializer; public ReferenceListForm(MainForm main) { @@ -31,6 +28,7 @@ namespace ChanSort.Ui } #region ShowOpenFileDialog() + private SerializerBase ShowOpenFileDialog() { try @@ -39,7 +37,7 @@ namespace ChanSort.Ui int numberOfFilters; var filter = main.GetTvDataFileFilter(out supportedExtensions, out numberOfFilters); - using (OpenFileDialog dlg = new OpenFileDialog()) + using (var dlg = new OpenFileDialog()) { dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); dlg.AddExtension = true; @@ -64,9 +62,11 @@ namespace ChanSort.Ui return null; } } + #endregion #region UpdateInfoTextAndOptions() + private void UpdateInfoTextAndOptions() { foreach (var ctl in this.grpManual.Controls) @@ -76,20 +76,19 @@ namespace ChanSort.Ui checkEdit.Checked = checkEdit.Enabled = true; } - var list = (ChannelList)this.comboSource.EditValue; + var list = (ChannelList) this.comboSource.EditValue; this.lblSourceInfo.Text = GetInfoText(list); - list = (ChannelList)this.comboTarget.EditValue; + list = (ChannelList) this.comboTarget.EditValue; this.lblTargetInfo.Text = GetInfoText(list); - bool canApply = - (cbAntenna.Checked || cbCable.Checked || cbSatellite.Checked) - && (cbAnalog.Checked || cbDigital.Checked) - && (cbTv.Checked || cbRadio.Checked); + var canApply = (cbAnalog.Checked || cbDigital.Checked) && (cbTv.Checked || cbRadio.Checked); this.btnApply.Enabled = canApply; } + #endregion #region GetInfoText() + private string GetInfoText(ChannelList list) { var src = list?.SignalSource ?? 0; @@ -97,23 +96,12 @@ namespace ChanSort.Ui if ((src & SignalSource.Antenna) != 0) sb.Append(", Antenna"); - else - this.cbAntenna.Enabled = this.cbAntenna.Checked = false; - if ((src & SignalSource.Cable) != 0) sb.Append(", Cable"); - else - this.cbCable.Enabled = this.cbCable.Checked = false; - if ((src & SignalSource.Sat) != 0) sb.Append(", Satellite"); - else - this.cbSatellite.Enabled = this.cbSatellite.Checked = false; - if ((src & SignalSource.IP) != 0) sb.Append(", IP"); - else - this.cbIP.Enabled = this.cbIP.Checked = false; if ((src & SignalSource.Analog) != 0) sb.Append(", Analog"); @@ -139,44 +127,70 @@ namespace ChanSort.Ui sb.Remove(0, 2); return sb.ToString(); } + + #endregion + + #region FilterChannel() + private bool FilterChannel(ChannelInfo ch) + { + var ss = ch.SignalSource; + if (!(this.cbAnalog.Checked && (ss & SignalSource.Analog) != 0 || this.cbDigital.Checked && (ss & SignalSource.Digital) != 0)) + return false; + if (!(this.cbTv.Checked && (ss & SignalSource.Tv) != 0 || this.cbRadio.Checked && (ss & SignalSource.Radio) != 0)) + return false; + return true; + } #endregion #region edFile_ButtonClick - private void edFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) + + private void edFile_ButtonClick(object sender, ButtonPressedEventArgs e) { - ser = ShowOpenFileDialog(); - if (ser == null) + serializer = ShowOpenFileDialog(); + if (serializer == null) return; - this.edFile.Text = ser.FileName; + this.edFile.Text = serializer.FileName; this.rbAuto.Enabled = this.rbManual.Enabled = true; + this.comboSource.EditValue = null; this.comboSource.Properties.Items.Clear(); - foreach (var list in ser.DataRoot.ChannelLists) + foreach (var list in serializer.DataRoot.ChannelLists) { if (!list.IsMixedSouceFavoritesList && list.Channels.Count > 0) this.comboSource.Properties.Items.Add(list); } + this.comboTarget.EditValue = null; this.comboTarget.Properties.Items.Clear(); foreach (var list in main.DataRoot.ChannelLists) { if (!list.IsMixedSouceFavoritesList && list.Channels.Count > 0) + { this.comboTarget.Properties.Items.Add(list); + if (main.CurrentChannelList == list) + this.comboTarget.SelectedItem = list; + } } - if (this.comboSource.Properties.Items.Count > 0) - this.comboSource.SelectedIndex = 0; + if (this.comboTarget.SelectedIndex < 0 && this.comboTarget.Properties.Items.Count > 0) + this.comboTarget.SelectedIndex = 0; - this.rbAuto.Enabled = - ser.DataRoot.MixedSourceFavorites == main.DataRoot.MixedSourceFavorites && - ser.DataRoot.SortedFavorites == main.DataRoot.SortedFavorites; - if (!this.rbAuto.Enabled) + this.rbAuto.Enabled = true; + foreach (var list in main.DataRoot.ChannelLists) + this.rbAuto.Enabled &= (serializer.DataRoot.GetChannelList(list.SignalSource)?.SignalSource ?? 0) == list.SignalSource; + //serializer.DataRoot.MixedSourceFavorites == main.DataRoot.MixedSourceFavorites && + //serializer.DataRoot.SortedFavorites == main.DataRoot.SortedFavorites; + if (this.rbAuto.Enabled) + this.rbAuto.Checked = true; + else this.rbManual.Checked = true; } + #endregion #region rbAuto_CheckedChanged + private void rbAuto_CheckedChanged(object sender, EventArgs e) { var ed = (CheckEdit) sender; @@ -184,50 +198,64 @@ namespace ChanSort.Ui UpdateButtons(); this.grpManual.Enabled = this.rbManual.Checked && this.rbManual.Enabled; } + #endregion - #region comboSource_EditValueChanged - private void comboSource_EditValueChanged(object sender, EventArgs e) + #region btnApply_Click + + private void btnApply_Click(object sender, EventArgs e) + { + var src = (ChannelList) this.comboSource.EditValue; + var target = (ChannelList) this.comboTarget.EditValue; + int offset; + if (int.TryParse(this.comboPrNr.Text, out offset)) + offset -= src.Channels.Min(ch => Math.Max(ch.OldProgramNr, 1)); + main.Editor.ApplyReferenceList(this.serializer.DataRoot, src, target, false, offset, FilterChannel); + main.RefreshGrids(); + } + + #endregion + + #region btnOk_Click + + private void btnOk_Click(object sender, EventArgs e) + { + main.Editor.ApplyReferenceList(serializer.DataRoot); + main.RefreshGrids(); + } + + #endregion + + private void comboTarget_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(); - // auto-select a compatible target list + // auto-select a compatible source list + var list = (ChannelList)this.comboTarget.EditValue; if (list != null) { - this.comboTarget.SelectedIndex = -1; + this.comboSource.SelectedIndex = -1; var src = list.SignalSource; - foreach (ChannelList targetList in this.comboTarget.Properties.Items) + foreach (ChannelList sourceList in this.comboSource.Properties.Items) { - if ((targetList.SignalSource & src) == src) + if ((sourceList.SignalSource & src) == src) { - this.comboTarget.SelectedItem = targetList; + this.comboSource.SelectedItem = sourceList; break; } } } } - private void comboTarget_EditValueChanged(object sender, EventArgs e) + #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) - { - - } - #endregion - - #region btnOk_Click - private void btnOk_Click(object sender, EventArgs e) - { - main.Editor.ApplyReferenceList(ser.DataRoot); - } - #endregion - } } \ No newline at end of file