Beispiel #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;
        }
Beispiel #2
0
        private bool ImportMxfFile()
        {
            var ret = true;

            UpdateStatusText("Importing remote MXF file");
            var frmRemote = new frmRemoteServers();

            frmRemote.ShowDialog();
            if (string.IsNullOrEmpty(frmRemote.mxfPath))
            {
                return(ret);
            }

            Logger.EventId = 0;
            mxfImport      = statusLogo.MxfFile = frmRemote.mxfPath;
            var importForm = new frmImport(mxfImport);

            importForm.ShowDialog();

            if (importForm.Success)
            {
                WmcStore.ActivateEpg123LineupsInStore();
                WmcRegistries.ActivateGuide();
                WmcStore.AutoMapChannels();
                WmcUtilities.ReindexDatabase();
            }
            else
            {
                MessageBox.Show("There was an error importing the MXF file.", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UpdateStatusText("Click the 'Step 3' button to try again.");
                ret = cbAutostep.Checked = false;
            }
            statusLogo.StatusImage();
            Helper.SendPipeMessage("Import Complete");

            return(ret);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        private void btnAddChannel_Click(object sender, EventArgs e)
        {
            // get the scannedlineup from the combo list
            var scannedLineup = (Lineup)cmbScannedLineups.SelectedItem;

            Service service; Channel channel; string msg;

            if (sender.Equals(btnAddChannelTuningInfo))
            {
                service = new Service
                {
                    CallSign = chnTiCallsign.Text,
                    Name     = chnTiCallsign.Text
                };

                channel = new Channel
                {
                    Service           = service,
                    Number            = (int)chnTiNumber.Value,
                    SubNumber         = (int)chnTiSubnumber.Value,
                    OriginalNumber    = (int)chnTiNumber.Value,
                    OriginalSubNumber = (int)chnTiSubnumber.Value,
                    ChannelType       = ChannelType.UserAdded
                };

                msg = $"{channel.ChannelNumber}{(chnTiPhysicalNumber.Value > 0 ? $" ({chnTiPhysicalNumber.Value})" : string.Empty)} {channel.CallSign}";
            }
            else if (sender.Equals(btnAddDvbChannel))
            {
                if (!int.TryParse(dvbFreq.Text, out var i1) || !int.TryParse(dvbOnid.Text, out var i2) ||
                    !int.TryParse(dvbNid.Text, out var i3) || !int.TryParse(dvbTsid.Text, out var i4) ||
                    !int.TryParse(dvbSid.Text, out var i5) || !int.TryParse(dvbLcn.Text, out var i6))
                {
                    return;
                }

                service = new Service
                {
                    CallSign = dvbTiCallsign.Text,
                    Name     = dvbTiCallsign.Text
                };

                channel = new Channel
                {
                    Service           = service,
                    Number            = int.Parse(dvbLcn.Text),
                    SubNumber         = 0,
                    OriginalNumber    = int.Parse(dvbLcn.Text),
                    OriginalSubNumber = 0,
                    ChannelType       = ChannelType.UserAdded
                };

                msg = $"{channel.ChannelNumber} {channel.CallSign} ({int.Parse(dvbFreq.Text) / 1000.0:n3} MHz, {int.Parse(dvbOnid.Text)}:{int.Parse(dvbTsid.Text)}:{int.Parse(dvbSid.Text)})";
            }
            else
            {
                return;
            }

            // create a device specific tuning info
            var tuningInfos = new List <TuningInfo>();

            foreach (ListViewItem item in lvDevices.Items)
            {
                var device = (Device)item.Tag;
                switch (device.DeviceType.TuningSpaceName)
                {
                case "ATSC":
                    channel.MatchName = $"OC:{channel.Number}:{channel.SubNumber}{(!string.IsNullOrEmpty(service.CallSign) ? $"|{service.CallSign}" : "")}";
                    tuningInfos.Add(new ChannelTuningInfo(device, (int)chnTiNumber.Value, (int)chnTiSubnumber.Value, (int)chnTiPhysicalNumber.Value));
                    break;

                case "ClearQAM":
                    channel.MatchName = !string.IsNullOrEmpty(chnTiCallsign.Text) ? chnTiCallsign.Text : "";
                    tuningInfos.Add(new ChannelTuningInfo(device, (int)chnTiNumber.Value, (int)chnTiSubnumber.Value, (ModulationType)(chnTiModulationType.SelectedIndex + 1)));
                    break;

                case "Cable":
                case "Digital Cable":
                case "{adb10da8-5286-4318-9ccb-cbedc854f0dc}":
                    channel.MatchName = !string.IsNullOrEmpty(chnTiCallsign.Text) ? chnTiCallsign.Text : "";
                    tuningInfos.Add(new ChannelTuningInfo(device, (int)chnTiNumber.Value, (int)chnTiSubnumber.Value, ModulationType.BDA_MOD_NOT_DEFINED));
                    break;

                case "dc65aa02-5cb0-4d6d-a020-68702a5b34b8":
                    channel.MatchName = !string.IsNullOrEmpty(chnTiCallsign.Text) ? chnTiCallsign.Text : "";
                    var tuningString = $"<tune:ChannelID ChannelID=\"{channel.OriginalNumber}\">" +
                                       "  <tune:TuningSpace xsi:type=\"tune:ChannelIDTuningSpaceType\" Name=\"DC65AA02-5CB0-4d6d-A020-68702A5B34B8\" NetworkType=\"{DC65AA02-5CB0-4d6d-A020-68702A5B34B8}\" />" +
                                       "  <tune:Locator xsi:type=\"tune:ATSCLocatorType\" Frequency=\"-1\" PhysicalChannel=\"-1\" TransportStreamID=\"-1\" ProgramNumber=\"1\" />" +
                                       "  <tune:Components xsi:type=\"tune:ComponentsType\" />" +
                                       "</tune:ChannelID>";
                    tuningInfos.Add(new StringTuningInfo(device, tuningString));
                    break;

                case "DVB-T":
                    channel.MatchName = $"DVBT:{dvbOnid.Text}:{dvbTsid.Text}:{dvbSid}{(string.IsNullOrEmpty(service.CallSign) ? $"|{dvbTiCallsign.Text}" : "")}";
                    tuningInfos.Add(new DvbTuningInfo(device, int.Parse(dvbOnid.Text), int.Parse(dvbTsid.Text), int.Parse(dvbSid.Text), int.Parse(dvbNid.Text), int.Parse(dvbFreq.Text)));
                    break;
                }
            }

            // add the channel
            WmcStore.AddUserChannel(scannedLineup, service, channel, tuningInfos);
            rtbChannelAddHistory.Text += $"Adding channel {msg} to {scannedLineup.Name}\n\n";
            Logger.WriteInformation(msg);
            ChannelAdded = true;
        }
Beispiel #5
0
        private bool OpenEpg123Configuration()
        {
            const string text    = "You have both the EPG123 executable for guide listings from Schedules Direct and the HDHR2MXF executable for guide listings from SiliconDust.\n\nDo you wish to proceed with HDHR2MXF?";
            const string caption = "Multiple Guide Sources";

            if (File.Exists(Helper.Epg123ExePath) && File.Exists(Helper.Hdhr2MxfExePath) && DialogResult.Yes == MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) ||
                File.Exists(Helper.Hdhr2MxfExePath) && !File.Exists(Helper.Epg123ExePath))
            {
                Hdhr2MxfSrv = true;
                UpdateStatusText("Running HDHR2MXF to create the guide ...");
                Logger.WriteVerbose("Running HDHR2MXF to create the guide ...");

                var startInfo = new ProcessStartInfo()
                {
                    FileName  = Helper.Hdhr2MxfExePath,
                    Arguments = "-update",
                };
                var hdhr2Mxf = Process.Start(startInfo);
                hdhr2Mxf.WaitForExit();

                Logger.EventId     = 0;
                statusLogo.MxfFile = Helper.Epg123MxfPath;
                if (hdhr2Mxf.ExitCode == 0)
                {
                    // use the client to import the mxf file
                    var importForm = new frmImport(Helper.Epg123MxfPath);
                    importForm.ShowDialog();

                    // kick off the reindex
                    if (importForm.Success)
                    {
                        WmcStore.ActivateEpg123LineupsInStore();
                        WmcRegistries.ActivateGuide();
                        WmcStore.AutoMapChannels();
                        WmcUtilities.ReindexDatabase();
                    }
                    else
                    {
                        MessageBox.Show("There was an error importing the MXF file.", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        UpdateStatusText("Click the 'Step 3' button to try again.");
                        return(cbAutostep.Checked = false);
                    }
                }
                else
                {
                    MessageBox.Show("There was an error using HDHR2MXF to create the MXF file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UpdateStatusText("Click the 'Step 3' button to try again.");
                    return(cbAutostep.Checked = false);
                }
                statusLogo.StatusImage();
                Helper.SendPipeMessage("Import Complete");

                return(true);
            }

            UpdateStatusText("Opening EPG123 Configuration GUI ...");
            Logger.WriteVerbose("Opening EPG123 Configuration GUI ...");
            Process procEpg123;

            if (Epg123Running())
            {
                var processes = Process.GetProcessesByName("epg123");
                procEpg123 = processes[0];
                if (IsIconic(procEpg123.MainWindowHandle))
                {
                    ShowWindow(procEpg123.MainWindowHandle, SW_RESTORE);
                }
            }
            else
            {
                // start epg123 configuration GUI
                procEpg123 = Process.Start(Helper.Epg123ExePath);
                procEpg123?.WaitForInputIdle(10000);
            }
            SetForegroundWindow(procEpg123.MainWindowHandle);
            UpdateStatusText("Waiting for EPG123 to close ...");
            Logger.WriteVerbose("Waiting for EPG123 to close ...");

            do
            {
                Thread.Sleep(100);
                Application.DoEvents();
            } while (!procEpg123.HasExited);

            UpdateStatusText(string.Empty);

            return(true);
        }