Ejemplo n.º 1
0
        public void PopulateMergedChannelItems()
        {
            MergedChannel.Refresh();
            SetServiceTypeFlags();
            var scanned = MergedChannel.PrimaryChannel.Lineup?.Name?.StartsWith("Scanned") ?? false;

            // set callsign and backcolor
            Callsign              = MergedChannel.PrimaryChannel.CallSign;
            CustomCallsign        = MergedChannel.HasUserSpecifiedCallSign ? MergedChannel.CallSign : null;
            SubItems[0].Text      = Custom ? CustomCallsign ?? Callsign : Callsign;
            SubItems[0].BackColor = MergedChannel.HasUserSpecifiedCallSign ? Color.Pink : SystemColors.Window;

            // set number and backcolor
            Number                = $"{MergedChannel.OriginalNumber}{(MergedChannel.OriginalSubNumber > 0 ? $".{MergedChannel.OriginalSubNumber}" : "")}";
            CustomNumber          = MergedChannel.HasUserSpecifiedNumber || MergedChannel.HasUserSpecifiedSubNumber ? $"{MergedChannel.Number}{(MergedChannel.SubNumber > 0 ? $".{MergedChannel.SubNumber}" : "")}" : null;
            SubItems[1].Text      = Custom ? CustomNumber ?? Number : Number;
            SubItems[1].BackColor = MergedChannel.HasUserSpecifiedNumber || MergedChannel.HasUserSpecifiedSubNumber ? Color.Pink : SystemColors.Window;

            // set service name, lineup name, and guide end time
            SubItems[2].Text = !scanned ? MergedChannel.Service?.Name : "";
            SubItems[3].Text = !scanned ? MergedChannel.PrimaryChannel.Lineup?.Name : "";
            SubItems[6].Text = !scanned?MergedChannel.Service?.ScheduleEndTime.ToLocalTime().ToString() : "";

            // set scanned sources and tuning info
            ScannedLineupIds = WmcStore.GetAllScannedSourcesForChannel(MergedChannel);
            if (ScannedLineupIds.Count > 0)
            {
                var names = new HashSet <string>();
                foreach (var name in ScannedLineupIds.Select(id =>
                                                             ((Lineup)WmcStore.WmcObjectStore.Fetch(id)).Name.Remove(0, 9)))
                {
                    names.Add(name.Remove(name.Length - 1));
                }

                var text = string.Empty;
                foreach (var name in names)
                {
                    if (!string.IsNullOrEmpty(text))
                    {
                        text += " + ";
                    }
                    text += name;
                }
                SubItems[4].Text = text;
            }
            SubItems[5].Text = WmcStore.GetAllTuningInfos((Channel)MergedChannel);

            // set checkbox
            Checked = Enabled = (!MergedChannel.IsSuggestedBlocked || MergedChannel.UserBlockedState != UserBlockedState.Unknown) && MergedChannel.UserBlockedState <= UserBlockedState.Enabled;
        }
Ejemplo n.º 2
0
        private ListViewItem BuildOrphanedChannelLvi(Channel orphanedChannel)
        {
            // build original channel number string
            var originalChannelNumber = orphanedChannel.OriginalNumber.ToString();

            if (orphanedChannel.OriginalSubNumber > 0)
            {
                originalChannelNumber += "." + orphanedChannel.OriginalSubNumber;
            }

            // build tuning info
            var tuneInfos = WmcStore.GetAllTuningInfos(orphanedChannel);

            // build ListViewItem
            try
            {
                var listViewItem = new ListViewItem(new[]
                {
                    orphanedChannel.CallSign,
                    originalChannelNumber,
                    TrimScannedLineupName(orphanedChannel.Lineup.Name),
                    tuneInfos
                })
                {
                    Tag = orphanedChannel
                };

                return(listViewItem);
            }
            catch
            {
                // ignored
            }

            return(null);
        }