Esempio n. 1
0
        public static FlowDocument ConvertProgramText(EpgEventInfo eventInfo, EventInfoTextMode textMode)
        {
            if (eventInfo == null)
            {
                return(null);
            }

            FlowDocument flowDoc1 = new FlowDocument()
            {
                FontFamily = new FontFamily("メイリオ"),
                FontSize   = 11,
                Foreground = new SolidColorBrush(Color.FromRgb(10, 10, 100)),
            };
            Paragraph p_basicInfo1  = new Paragraph();
            Section   sctn_ExtInfo1 = new Section();

            string serviceName1 = null;
            UInt64 key          = eventInfo.Create64Key();

            if (ChSet5.ChList.ContainsKey(key) == true)
            {
                serviceName1 = ChSet5.ChList[key].service_name + "(" + ChSet5.ChList[key].network_name + ")";
            }

            string date1 = null;

            if (eventInfo.StartTimeFlag == 1)
            {
                date1 = CommonManager.ConvertTimeText(eventInfo.start_time, false, true) + " ~ ";
            }
            else
            {
                date1 = "未定 ~ ";
            }
            if (eventInfo.DurationFlag == 1)
            {
                DateTime endTime = eventInfo.start_time + TimeSpan.FromSeconds(eventInfo.durationSec);
                date1 += CommonManager.ConvertTimeText(endTime, true, true);
            }
            else
            {
                date1 += "未定";
            }

            if (eventInfo.ShortInfo != null)
            {
                Inline event_name1 = new Bold(
                    new Run(eventInfo.ShortInfo.event_name + Environment.NewLine))
                {
                    FontSize = 12
                };
                p_basicInfo1.Inlines.Add(event_name1);
                //
                if (!string.IsNullOrWhiteSpace(date1))
                {
                    p_basicInfo1.Inlines.Add(new Run(date1 + Environment.NewLine));
                }
                if (!string.IsNullOrWhiteSpace(serviceName1))
                {
                    p_basicInfo1.Inlines.Add(new Run(serviceName1));
                }
                addParagraph(eventInfo.ShortInfo.text_char, sctn_ExtInfo1, 0);
            }

            if (eventInfo.ExtInfo != null)
            {
                addParagraph(eventInfo.ExtInfo.text_char, sctn_ExtInfo1, 0);
            }

            //ジャンル
            Section sctn_Genre1 = addSection(sctn_ExtInfo1);

            addParagraph("ジャンル:", sctn_Genre1, 0);
            if (eventInfo.ContentInfo != null)
            {
                var contentList = new List <ContentKindInfo>();
                if (eventInfo.ContentInfo != null)
                {
                    contentList = eventInfo.ContentInfo.nibbleList.Select(data => CommonManager.ContentKindInfoForDisplay(data)).ToList();
                }
                foreach (ContentKindInfo info in contentList.Where(info => info.Data.IsAttributeInfo == false))
                {
                    addParagraph(info.ListBoxView, sctn_Genre1);
                }
            }

            //映像
            Section sctn_ComponentInfo1 = addSection(sctn_ExtInfo1);

            addParagraph("映像:", sctn_ComponentInfo1, 0);
            if (eventInfo.ComponentInfo != null)
            {
                StringBuilder sb1           = new StringBuilder();
                int           streamContent = eventInfo.ComponentInfo.stream_content;
                int           componentType = eventInfo.ComponentInfo.component_type;
                UInt16        componentKey  = (UInt16)(streamContent << 8 | componentType);
                if (CommonManager.ComponentKindDictionary.ContainsKey(componentKey) == true)
                {
                    addParagraph(CommonManager.ComponentKindDictionary[componentKey], sctn_ComponentInfo1);
                }
                if (eventInfo.ComponentInfo.text_char.Length > 0)
                {
                    addParagraph(eventInfo.ComponentInfo.text_char, sctn_ComponentInfo1);
                }
            }

            //音声
            Section sctn_AudioInfo1 = addSection(sctn_ExtInfo1);

            addParagraph("音声:", sctn_AudioInfo1, 0);
            if (eventInfo.AudioInfo != null)
            {
                foreach (EpgAudioComponentInfoData info in eventInfo.AudioInfo.componentList)
                {
                    StringBuilder sb1           = new StringBuilder();
                    int           streamContent = info.stream_content;
                    int           componentType = info.component_type;
                    UInt16        componentKey  = (UInt16)(streamContent << 8 | componentType);
                    if (CommonManager.ComponentKindDictionary.ContainsKey(componentKey) == true)
                    {
                        sb1.AppendLine(CommonManager.ComponentKindDictionary[componentKey]);
                    }
                    if (info.text_char.Length > 0)
                    {
                        sb1.AppendLine(info.text_char);
                    }
                    string samplingRate1 = "サンプリングレート: ";
                    switch (info.sampling_rate)
                    {
                    case 1:
                        samplingRate1 += "16kHz";
                        break;

                    case 2:
                        samplingRate1 += "22.05kHz";
                        break;

                    case 3:
                        samplingRate1 += "24kHz";
                        break;

                    case 5:
                        samplingRate1 += "32kHz";
                        break;

                    case 6:
                        samplingRate1 += "44.1kHz";
                        break;

                    case 7:
                        samplingRate1 += "48kHz";
                        break;

                    default:
                        break;
                    }
                    sb1.Append(samplingRate1);
                    double marginTop1 = 0;
                    if (1 < sctn_AudioInfo1.Blocks.Count)
                    {
                        marginTop1 = 5;
                    }
                    addParagraph(sb1.ToString(), sctn_AudioInfo1, marginTop0: marginTop1);
                }
            }
            {
                Section sctn_ID1 = addSection(sctn_ExtInfo1);
                addParagraph("OriginalNetworkID : " + eventInfo.original_network_id.ToString() + " (0x" + eventInfo.original_network_id.ToString("X4") + ")", sctn_ID1, 0);
                addParagraph("TransportStreamID : " + eventInfo.transport_stream_id.ToString() + " (0x" + eventInfo.transport_stream_id.ToString("X4") + ")", sctn_ID1, 0);
                addParagraph("ServiceID : " + eventInfo.service_id.ToString() + " (0x" + eventInfo.service_id.ToString("X4") + ")", sctn_ID1, 0);
                addParagraph("EventID : " + eventInfo.event_id.ToString() + " (0x" + eventInfo.event_id.ToString("X4") + ")", sctn_ID1, 0);
            }
            if (textMode == EventInfoTextMode.All || textMode == EventInfoTextMode.BasicOnly)
            {
                flowDoc1.Blocks.Add(p_basicInfo1);
            }
            if (textMode == EventInfoTextMode.All)
            {
                flowDoc1.Blocks.Add(sctn_ExtInfo1);
            }

            return(flowDoc1);
        }