Example #1
0
        public static String ConvertNetworkNameText(ushort originalNetworkID)
        {
            String retText = "";

            if (ChSet5.IsDttv(originalNetworkID) == true)
            {
                retText = "地デジ";
            }
            else if (ChSet5.IsBS(originalNetworkID) == true)
            {
                retText = "BS";
            }
            else if (ChSet5.IsCS1(originalNetworkID) == true)
            {
                retText = "CS1";
            }
            else if (ChSet5.IsCS2(originalNetworkID) == true)
            {
                retText = "CS2";
            }
            else if (ChSet5.IsCS3(originalNetworkID) == true)
            {
                retText = "CS3";
            }
            else
            {
                retText = "その他";
            }
            return(retText);
        }
Example #2
0
        /// <summary>
        /// デフォルト表示のために番組情報のサービスを選択する
        /// </summary>
        public static IEnumerable <EpgServiceAllEventInfo> SelectServiceEventList(IEnumerable <EpgServiceAllEventInfo> sel)
        {
            if (Settings.Instance.ShowEpgCapServiceOnly)
            {
                sel = sel.Where(info =>
                                ChSet5.Instance.ChList.ContainsKey(CommonManager.Create64Key(info.serviceInfo.ONID, info.serviceInfo.TSID, info.serviceInfo.SID)) &&
                                ChSet5.Instance.ChList[CommonManager.Create64Key(info.serviceInfo.ONID, info.serviceInfo.TSID, info.serviceInfo.SID)].EpgCapFlag);
            }
            //リモコンキー優先のID順ソート。BSはなるべくSID順
            var bsmin = new Dictionary <ushort, ushort>();

            foreach (EpgServiceAllEventInfo info in sel)
            {
                if (ChSet5.IsBS(info.serviceInfo.ONID) &&
                    (bsmin.ContainsKey(info.serviceInfo.TSID) == false || bsmin[info.serviceInfo.TSID] > info.serviceInfo.SID))
                {
                    bsmin[info.serviceInfo.TSID] = info.serviceInfo.SID;
                }
            }
            sel = sel.OrderBy(info =>
                              (ulong)(ChSet5.IsDttv(info.serviceInfo.ONID) ? (info.serviceInfo.remote_control_key_id + 255) % 256 : 0) << 48 |
                              CommonManager.Create64Key(info.serviceInfo.ONID,
                                                        (ChSet5.IsBS(info.serviceInfo.ONID) ? bsmin[info.serviceInfo.TSID] : info.serviceInfo.TSID),
                                                        info.serviceInfo.SID));
            return(sel);
        }
Example #3
0
        public EpgDataViewSetting()
        {
            InitializeComponent();

            comboBox_timeH_week.ItemsSource   = Enumerable.Range(0, 24);
            comboBox_timeH_week.SelectedIndex = 4;

            for (int i = 0; i < 5; i++)
            {
                ListBox target = i == 0 ? listBox_serviceTere :
                                 i == 1 ? listBox_serviceBS :
                                 i == 2 ? listBox_serviceCS :
                                 i == 3 ? listBox_serviceCS3 : listBox_serviceOther;
                target.Items.Add(new Tuple <string, ulong>("[" + ((TabItem)target.Parent).Header + "]",
                                                           (ulong)(i == 0 ? CustomEpgTabInfo.SpecialViewServices.ViewServiceDttv :
                                                                   i == 1 ? CustomEpgTabInfo.SpecialViewServices.ViewServiceBS :
                                                                   i == 2 ? CustomEpgTabInfo.SpecialViewServices.ViewServiceCS :
                                                                   i == 3 ? CustomEpgTabInfo.SpecialViewServices.ViewServiceCS3 :
                                                                   CustomEpgTabInfo.SpecialViewServices.ViewServiceOther)));
                foreach (ChSet5Item info in ChSet5.Instance.ChListSelected)
                {
                    if (i == 0 && ChSet5.IsDttv(info.ONID) ||
                        i == 1 && ChSet5.IsBS(info.ONID) ||
                        i == 2 && ChSet5.IsCS(info.ONID) ||
                        i == 3 && ChSet5.IsCS3(info.ONID) ||
                        i == 4 && ChSet5.IsOther(info.ONID))
                    {
                        target.Items.Add(new Tuple <string, ulong>(info.ServiceName, info.Key));
                    }
                }
            }
            listBox_jyanru.ItemsSource = CommonManager.Instance.ContentKindList;
        }
Example #4
0
 private void button_1seg_on2_Click(object sender, RoutedEventArgs e)
 {
     foreach (ServiceItem info in listView_service.Items)
     {
         if (ChSet5.IsDttv(info.ServiceInfo.ONID) == true && info.ServiceInfo.partialReceptionFlag == 1)
         {
             info.IsSelected = true;
         }
     }
 }
Example #5
0
 private void button_dttv_on2_Click(object sender, RoutedEventArgs e)
 {
     foreach (ServiceItem info in listView_service.Items)
     {
         if (ChSet5.IsDttv(info.ServiceInfo.ONID) == true && ChSet5.IsVideo(info.ServiceInfo.service_type) == true)
         {
             info.IsSelected = true;
         }
     }
 }
Example #6
0
 public bool HasService(ushort onid, ushort tsid, ushort sid)
 {
     return(setViewInfo.ViewServiceList.Contains(CommonManager.Create64Key(onid, tsid, sid)) ||
            setViewInfo.ViewServiceList.Contains(
                (ulong)(ChSet5.IsDttv(onid) ? CustomEpgTabInfo.SpecialViewServices.ViewServiceDttv :
                        ChSet5.IsBS(onid) ? CustomEpgTabInfo.SpecialViewServices.ViewServiceBS :
                        ChSet5.IsCS(onid) ? CustomEpgTabInfo.SpecialViewServices.ViewServiceCS :
                        ChSet5.IsCS3(onid) ? CustomEpgTabInfo.SpecialViewServices.ViewServiceCS3 :
                        CustomEpgTabInfo.SpecialViewServices.ViewServiceOther)));
 }
Example #7
0
        public static ReserveData TryLoadTVPID(string filePath, IDictionary <ulong, ChSet5Item> chList)
        {
            Dictionary <string, string> paramList = TryLoadParamList(filePath);

            if (paramList != null &&
                paramList.ContainsKey("station") &&
                paramList.ContainsKey("version") &&
                paramList["version"] == "2")
            {
                // 放送種別とサービスID
                string station = paramList["station"];
                foreach (ChSet5Item info in chList.Values)
                {
                    ushort sid = 0;
                    if (ChSet5.IsDttv(info.ONID) &&
                        (station.StartsWith("DFS", StringComparison.Ordinal) || station.StartsWith("DOS", StringComparison.Ordinal)))
                    {
                        ushort.TryParse(station.Substring(3), NumberStyles.HexNumber, null, out sid);
                    }
                    else if (ChSet5.IsBS(info.ONID) && station.StartsWith("BSDT", StringComparison.Ordinal) ||
                             ChSet5.IsCS(info.ONID) && station.StartsWith("CSDT", StringComparison.Ordinal) ||
                             ChSet5.IsSP(info.ONID) && station.StartsWith("SPTV", StringComparison.Ordinal))
                    {
                        ushort.TryParse(station.Substring(4), out sid);
                    }
                    if (sid != 0 && sid == info.SID)
                    {
                        var addInfo = new ReserveData();
                        addInfo.OriginalNetworkID = info.ONID;
                        addInfo.TransportStreamID = info.TSID;
                        addInfo.ServiceID         = info.SID;
                        addInfo.StationName       = info.ServiceName;
                        // 開始時間と長さ
                        if (GetTimeValues(paramList, addInfo))
                        {
                            // イベントID(オプション)。なければプログラム予約
                            addInfo.EventID = 0xFFFF;
                            ushort eventID;
                            if (paramList.ContainsKey("program-id") && ushort.TryParse(paramList["program-id"], out eventID))
                            {
                                addInfo.EventID = eventID;
                            }
                            // 番組名(オプション)
                            if (paramList.ContainsKey("program-title"))
                            {
                                addInfo.Title = paramList["program-title"];
                            }
                            return(addInfo);
                        }
                        break;
                    }
                }
            }
            return(null);
        }
Example #8
0
        public EpgDataViewSetting()
        {
            InitializeComponent();

            try
            {
                comboBox_timeH_week.ItemsSource   = Enumerable.Range(0, 24);
                comboBox_timeH_week.SelectedIndex = 4;


                foreach (ChSet5Item info in ChSet5.Instance.ChListSelected)
                {
                    if (ChSet5.IsBS(info.ONID))
                    {
                        tabItem_bs.Visibility = Visibility.Visible;
                        listBox_serviceBS.Items.Add(info);
                    }
                    else if (ChSet5.IsCS3(info.ONID))
                    {
                        tabItem_cs3.Visibility = Visibility.Visible;
                        listBox_serviceCS3.Items.Add(info);
                    }
                    else if (ChSet5.IsCS(info.ONID))
                    {
                        tabItem_cs.Visibility = Visibility.Visible;
                        listBox_serviceCS.Items.Add(info);
                    }
                    else if (ChSet5.IsDttv(info.ONID))
                    {
                        tabItem_tere.Visibility = Visibility.Visible;
                        listBox_serviceTere.Items.Add(info);
                    }
                    else
                    {
                        tabItem_other.Visibility = Visibility.Visible;
                        listBox_serviceOther.Items.Add(info);
                    }
                }
                TabItem item = tabControl2.Items.Cast <TabItem>().FirstOrDefault(a => a.Visibility == Visibility.Visible);
                if (item != null)
                {
                    item.IsSelected = true;
                }
                listBox_jyanru.ItemsSource = CommonManager.Instance.ContentKindList;

                radioButton_rate.IsChecked = true;
                radioButton_week.IsChecked = false;
                radioButton_list.IsChecked = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Example #9
0
        public String ConvertProgramText(EpgEventInfo eventInfo, EventInfoTextMode textMode)
        {
            string retText   = "";
            string basicInfo = "";
            string extInfo   = "";

            if (eventInfo != null)
            {
                UInt64 key = Create64Key(eventInfo.original_network_id, eventInfo.transport_stream_id, eventInfo.service_id);
                if (ChSet5.Instance.ChList.ContainsKey(key) == true)
                {
                    basicInfo += ChSet5.Instance.ChList[key].ServiceName + "(" + ChSet5.Instance.ChList[key].NetworkName + ")" + "\r\n";
                }

                basicInfo += new TimeDuration(eventInfo.StartTimeFlag != 0, eventInfo.start_time,
                                              eventInfo.DurationFlag != 0, eventInfo.durationSec) + "\r\n";

                if (eventInfo.ShortInfo != null)
                {
                    basicInfo += eventInfo.ShortInfo.event_name + "\r\n\r\n";
                    extInfo   += eventInfo.ShortInfo.text_char + "\r\n\r\n";
                }

                if (eventInfo.ExtInfo != null)
                {
                    extInfo += eventInfo.ExtInfo.text_char + "\r\n\r\n";
                }

                //ジャンル
                extInfo += "ジャンル :\r\n";
                if (eventInfo.ContentInfo != null)
                {
                    foreach (EpgContentData info in eventInfo.ContentInfo.nibbleList)
                    {
                        String content = "";
                        int    nibble1 = info.content_nibble_level_1;
                        int    nibble2 = info.content_nibble_level_2;
                        if (nibble1 == 0x0E && nibble2 <= 0x01)
                        {
                            nibble1 = info.user_nibble_1 | (0x60 + nibble2 * 16);
                            nibble2 = info.user_nibble_2;
                        }
                        if (ContentKindDictionary.ContainsKey((ushort)(nibble1 << 8 | 0xFF)))
                        {
                            content += ContentKindDictionary[(ushort)(nibble1 << 8 | 0xFF)];
                        }
                        else
                        {
                            content += "(0x" + nibble1.ToString("X2") + ")";
                        }
                        if (ContentKindDictionary.ContainsKey((ushort)(nibble1 << 8 | nibble2)))
                        {
                            content += " - " + ContentKindDictionary[(ushort)(nibble1 << 8 | nibble2)];
                        }
                        else if (nibble1 != 0x0F)
                        {
                            content += " - (0x" + nibble2.ToString("X2") + ")";
                        }
                        extInfo += content + "\r\n";
                    }
                }
                extInfo += "\r\n";

                //映像
                extInfo += "映像 :";
                if (eventInfo.ComponentInfo != null)
                {
                    int    streamContent = eventInfo.ComponentInfo.stream_content;
                    int    componentType = eventInfo.ComponentInfo.component_type;
                    UInt16 componentKey  = (UInt16)(streamContent << 8 | componentType);
                    if (ComponentKindDictionary.ContainsKey(componentKey) == true)
                    {
                        extInfo += ComponentKindDictionary[componentKey];
                    }
                    if (eventInfo.ComponentInfo.text_char.Length > 0)
                    {
                        extInfo += "\r\n";
                        extInfo += eventInfo.ComponentInfo.text_char;
                    }
                }
                extInfo += "\r\n";

                //音声
                extInfo += "音声 :\r\n";
                if (eventInfo.AudioInfo != null)
                {
                    foreach (EpgAudioComponentInfoData info in eventInfo.AudioInfo.componentList)
                    {
                        int    streamContent = info.stream_content;
                        int    componentType = info.component_type;
                        UInt16 componentKey  = (UInt16)(streamContent << 8 | componentType);
                        if (ComponentKindDictionary.ContainsKey(componentKey) == true)
                        {
                            extInfo += ComponentKindDictionary[componentKey];
                        }
                        if (info.text_char.Length > 0)
                        {
                            extInfo += "\r\n";
                            extInfo += info.text_char;
                        }
                        extInfo += "\r\n";
                        extInfo += "サンプリングレート :";
                        switch (info.sampling_rate)
                        {
                        case 1:
                            extInfo += "16kHz";
                            break;

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

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

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

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

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

                        default:
                            break;
                        }
                        extInfo += "\r\n";
                    }
                }
                extInfo += "\r\n";

                //スクランブル
                if (!ChSet5.IsDttv(eventInfo.original_network_id))
                {
                    if (eventInfo.FreeCAFlag == 0)
                    {
                        extInfo += "無料放送\r\n";
                    }
                    else
                    {
                        extInfo += "有料放送\r\n";
                    }
                    extInfo += "\r\n";
                }

                //イベントリレー
                if (eventInfo.EventRelayInfo != null)
                {
                    if (eventInfo.EventRelayInfo.eventDataList.Count > 0)
                    {
                        extInfo += "イベントリレーあり:\r\n";
                        foreach (EpgEventData info in eventInfo.EventRelayInfo.eventDataList)
                        {
                            key = Create64Key(info.original_network_id, info.transport_stream_id, info.service_id);
                            if (ChSet5.Instance.ChList.ContainsKey(key) == true)
                            {
                                extInfo += ChSet5.Instance.ChList[key].ServiceName + "(" + ChSet5.Instance.ChList[key].NetworkName + ")" + " ";
                            }
                            else
                            {
                                extInfo += "OriginalNetworkID : " + info.original_network_id.ToString() + " (0x" + info.original_network_id.ToString("X4") + ") ";
                                extInfo += "TransportStreamID : " + info.transport_stream_id.ToString() + " (0x" + info.transport_stream_id.ToString("X4") + ") ";
                                extInfo += "ServiceID : " + info.service_id.ToString() + " (0x" + info.service_id.ToString("X4") + ") ";
                            }
                            extInfo += "EventID : " + info.event_id.ToString() + " (0x" + info.event_id.ToString("X4") + ")\r\n";
                            extInfo += "\r\n";
                        }
                        extInfo += "\r\n";
                    }
                }

                extInfo += "OriginalNetworkID : " + eventInfo.original_network_id.ToString() + " (0x" + eventInfo.original_network_id.ToString("X4") + ")\r\n";
                extInfo += "TransportStreamID : " + eventInfo.transport_stream_id.ToString() + " (0x" + eventInfo.transport_stream_id.ToString("X4") + ")\r\n";
                extInfo += "ServiceID : " + eventInfo.service_id.ToString() + " (0x" + eventInfo.service_id.ToString("X4") + ")\r\n";
                extInfo += "EventID : " + eventInfo.event_id.ToString() + " (0x" + eventInfo.event_id.ToString("X4") + ")\r\n";
            }

            if (textMode == EventInfoTextMode.All || textMode == EventInfoTextMode.BasicOnly)
            {
                retText = basicInfo;
            }
            if (textMode == EventInfoTextMode.All || textMode == EventInfoTextMode.ExtOnly)
            {
                retText += extInfo;
            }
            return(retText);
        }
Example #10
0
        /// <summary>
        /// タブ生成
        /// </summary>
        private bool CreateTabItem()
        {
            {
                List <CustomEpgTabInfo> defaultList = null;
                if (Settings.Instance.UseCustomEpgView == false)
                {
                    defaultList = new List <CustomEpgTabInfo>();
                    if (CommonManager.Instance.NWMode && CommonManager.Instance.NWConnectedIP == null)
                    {
                        return(false);
                    }
                    ErrCode err = CommonManager.Instance.DB.ReloadEpgData();
                    if (err != ErrCode.CMD_SUCCESS)
                    {
                        if (IsVisible && err != ErrCode.CMD_ERR_BUSY)
                        {
                            Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(CommonManager.GetErrCodeText(err) ?? "EPGデータの取得でエラーが発生しました。")));
                        }
                        return(false);
                    }

                    //デフォルト表示
                    for (int i = 0; i < 5; i++)
                    {
                        var setInfo = new CustomEpgTabInfo();
                        foreach (EpgServiceInfo info in CommonManager.Instance.DB.ServiceEventList.Values.Select(allInfo => allInfo.serviceInfo))
                        {
                            if (Settings.Instance.ShowEpgCapServiceOnly &&
                                (ChSet5.Instance.ChList.ContainsKey(CommonManager.Create64Key(info.ONID, info.TSID, info.SID)) == false ||
                                 ChSet5.Instance.ChList[CommonManager.Create64Key(info.ONID, info.TSID, info.SID)].EpgCapFlag == false))
                            {
                                continue;
                            }
                            if (i == 0 && ChSet5.IsDttv(info.ONID))
                            {
                                setInfo.TabName = "地デジ";
                                setInfo.ViewServiceList.Add((ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceDttv);
                            }
                            else if (i == 1 && ChSet5.IsBS(info.ONID))
                            {
                                setInfo.TabName = "BS";
                                setInfo.ViewServiceList.Add((ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceBS);
                            }
                            else if (i == 2 && ChSet5.IsCS(info.ONID) && ChSet5.IsCS3(info.ONID) == false)
                            {
                                setInfo.TabName = "CS";
                                setInfo.ViewServiceList.Add((ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceCS);
                            }
                            else if (i == 3 && ChSet5.IsCS3(info.ONID))
                            {
                                setInfo.TabName = "CS3";
                                setInfo.ViewServiceList.Add((ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceCS3);
                            }
                            else if (i == 4 && ChSet5.IsOther(info.ONID))
                            {
                                setInfo.TabName = "その他";
                                setInfo.ViewServiceList.Add((ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceOther);
                            }
                            else
                            {
                                continue;
                            }
                            defaultList.Add(setInfo);
                            break;
                        }
                    }
                }
                foreach (CustomEpgTabInfo info in defaultList ?? Settings.Instance.CustomEpgTabList)
                {
                    var tabItem = new TabItem();
                    tabItem.Header = info.TabName;
                    if (info.ViewMode == 1)
                    {
                        //1週間表示
                        var epgView = new EpgWeekMainView(info, DateTime.MaxValue);
                        epgView.ViewModeChangeRequested += item_ViewModeChangeRequested;
                        tabItem.Content = epgView;
                    }
                    else if (info.ViewMode == 2)
                    {
                        //リスト表示
                        var epgView = new EpgListMainView(info, DateTime.MaxValue);
                        epgView.ViewModeChangeRequested += item_ViewModeChangeRequested;
                        tabItem.Content = epgView;
                    }
                    else
                    {
                        //標準ラテ欄表示
                        var epgView = new EpgMainView(info, DateTime.MaxValue);
                        epgView.ViewModeChangeRequested += item_ViewModeChangeRequested;
                        tabItem.Content = epgView;
                    }
                    tabControl.Items.Add(tabItem);
                }
                if (tabControl.Items.Count > 0)
                {
                    tabControl.SelectedIndex = 0;
                }
            }
            return(true);
        }
Example #11
0
        private void ReloadProgramViewItem(bool enablePrev, bool enableNext)
        {
            try
            {
                if (listBox_service.ItemsSource != null)
                {
                    foreach (ServiceItem info in listBox_service.ItemsSource)
                    {
                        lastChkSID[info.ID] = info.IsSelected;
                    }
                }
                listBox_service.ItemsSource = null;
                var serviceList = new List <ServiceItem>();

                //特殊なサービス指定の展開と重複除去
                var viewIDList = new List <ulong>();
                foreach (ulong id in setViewInfo.ViewServiceList)
                {
                    IEnumerable <EpgServiceAllEventInfo> sel =
                        id == (ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceDttv ?
                        serviceEventList.Values.Where(info => ChSet5.IsDttv(info.serviceInfo.ONID)) :
                        id == (ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceBS ?
                        serviceEventList.Values.Where(info => ChSet5.IsBS(info.serviceInfo.ONID)) :
                        id == (ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceCS ?
                        serviceEventList.Values.Where(info => ChSet5.IsCS(info.serviceInfo.ONID)) :
                        id == (ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceCS3 ?
                        serviceEventList.Values.Where(info => ChSet5.IsCS3(info.serviceInfo.ONID)) :
                        id == (ulong)CustomEpgTabInfo.SpecialViewServices.ViewServiceOther ?
                        serviceEventList.Values.Where(info => ChSet5.IsOther(info.serviceInfo.ONID)) : null;
                    if (sel == null)
                    {
                        if (viewIDList.Contains(id) == false)
                        {
                            viewIDList.Add(id);
                        }
                        continue;
                    }
                    foreach (EpgServiceInfo info in DBManager.SelectServiceEventList(sel).Select(allInfo => allInfo.serviceInfo))
                    {
                        if (viewIDList.Contains(CommonManager.Create64Key(info.ONID, info.TSID, info.SID)) == false)
                        {
                            viewIDList.Add(CommonManager.Create64Key(info.ONID, info.TSID, info.SID));
                        }
                    }
                }
                for (int i = 0; i < viewIDList.Count;)
                {
                    //TSIDが同じでSIDが逆順のときは正順にする
                    int skip = i + 1;
                    while (viewIDList.Count > skip &&
                           viewIDList[skip] >> 16 == viewIDList[skip - 1] >> 16 &&
                           (viewIDList[skip] & 0xFFFF) < (viewIDList[skip - 1] & 0xFFFF))
                    {
                        skip++;
                    }
                    for (int j = skip - 1; j >= i; j--)
                    {
                        ulong id = viewIDList[j];
                        if (serviceEventList.ContainsKey(id))
                        {
                            var item = new ServiceItem(serviceEventList[id].serviceInfo);
                            item.IsSelected = lastChkSID.ContainsKey(id) == false || lastChkSID[id];
                            serviceList.Add(item);
                        }
                    }
                    i = skip;
                }
                listBox_service.ItemsSource = serviceList;
                button_prev.IsEnabled       = enablePrev;
                button_next.IsEnabled       = enableNext;

                UpdateEventList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #12
0
        /// <summary>
        /// タブ生成
        /// </summary>
        private bool CreateTabItem()
        {
            {
                List <CustomEpgTabInfo> defaultList = null;
                if (Settings.Instance.UseCustomEpgView == false)
                {
                    defaultList = new List <CustomEpgTabInfo>();
                    if (CommonManager.Instance.NWMode && CommonManager.Instance.NWConnectedIP == null)
                    {
                        return(false);
                    }
                    ErrCode err = CommonManager.Instance.DB.ReloadEpgData();
                    if (err != ErrCode.CMD_SUCCESS)
                    {
                        if (IsVisible && err != ErrCode.CMD_ERR_BUSY)
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                MessageBox.Show(CommonManager.GetErrCodeText(err) ?? "EPGデータの取得でエラーが発生しました。EPGデータが読み込まれていない可能性があります。");
                            }));
                        }
                        return(false);
                    }

                    //デフォルト表示
                    bool ignoreEpgCap = Settings.Instance.ShowEpgCapServiceOnly == false;
                    IEnumerable <EpgServiceInfo> sel = CommonManager.Instance.DB.ServiceEventList.Values.Select(info => info.serviceInfo).Where(info => {
                        ulong key = CommonManager.Create64Key(info.ONID, info.TSID, info.SID);
                        return(ignoreEpgCap || ChSet5.Instance.ChList.ContainsKey(key) && ChSet5.Instance.ChList[key].EpgCapFlag);
                    });
                    //リモコンキー優先のID順ソート。BSはなるべくSID順
                    var bsmin = new Dictionary <ushort, ushort>();
                    foreach (EpgServiceInfo info in sel)
                    {
                        if (ChSet5.IsBS(info.ONID) && (bsmin.ContainsKey(info.TSID) == false || bsmin[info.TSID] > info.SID))
                        {
                            bsmin[info.TSID] = info.SID;
                        }
                    }
                    sel = sel.OrderBy(info => (ulong)(ChSet5.IsDttv(info.ONID) ? (info.remote_control_key_id + 255) % 256 : 0) << 48 |
                                      CommonManager.Create64Key(info.ONID, (ChSet5.IsBS(info.ONID) ? bsmin[info.TSID] : info.TSID), info.SID));
                    for (int i = 0; i < 5; i++)
                    {
                        CustomEpgTabInfo setInfo = null;
                        foreach (EpgServiceInfo info in sel)
                        {
                            string tabName = null;
                            if (i == 0 && ChSet5.IsDttv(info.ONID))
                            {
                                tabName = "地デジ";
                            }
                            else if (i == 1 && ChSet5.IsBS(info.ONID))
                            {
                                tabName = "BS";
                            }
                            else if (i == 2 && ChSet5.IsCS(info.ONID) && ChSet5.IsCS3(info.ONID) == false)
                            {
                                tabName = "CS";
                            }
                            else if (i == 3 && ChSet5.IsCS3(info.ONID))
                            {
                                tabName = "CS3";
                            }
                            else if (i == 4 && ChSet5.IsOther(info.ONID))
                            {
                                tabName = "その他";
                            }
                            if (tabName != null)
                            {
                                if (setInfo == null)
                                {
                                    setInfo         = new CustomEpgTabInfo();
                                    setInfo.TabName = tabName;
                                }
                                setInfo.ViewServiceList.Add(CommonManager.Create64Key(info.ONID, info.TSID, info.SID));
                            }
                        }
                        if (setInfo != null)
                        {
                            defaultList.Add(setInfo);
                        }
                    }
                }
                foreach (CustomEpgTabInfo info in defaultList ?? Settings.Instance.CustomEpgTabList)
                {
                    var tabItem = new TabItem();
                    tabItem.Header = info.TabName;
                    if (info.ViewMode == 1)
                    {
                        //1週間表示
                        var epgView = new EpgWeekMainView(info);
                        epgView.ViewModeChangeRequested += item_ViewModeChangeRequested;
                        tabItem.Content = epgView;
                    }
                    else if (info.ViewMode == 2)
                    {
                        //リスト表示
                        var epgView = new EpgListMainView(info);
                        epgView.ViewModeChangeRequested += item_ViewModeChangeRequested;
                        tabItem.Content = epgView;
                    }
                    else
                    {
                        //標準ラテ欄表示
                        var epgView = new EpgMainView(info);
                        epgView.ViewModeChangeRequested += item_ViewModeChangeRequested;
                        tabItem.Content = epgView;
                    }
                    tabControl.Items.Add(tabItem);
                }
                if (tabControl.Items.Count > 0)
                {
                    tabControl.SelectedIndex = 0;
                }
            }
            return(true);
        }