Exemple #1
0
        /// <summary>SPKeyが無ければ指定サービスのみ過去EPGを読み込む</summary>
        public ErrCode LoadEpgArcData(DateTime start, DateTime end, ref List <EpgServiceEventInfo> list, IEnumerable <ulong> keys = null)
        {
            try
            {
                List <long> keyList;
                if (keys == null || keys.Any(key => EpgServiceInfo.IsSPKey(key)))
                {
                    keyList = new List <long> {
                        0xFFFFFFFFFFFF, 0xFFFFFFFFFFFF
                    };
                }
                else
                {
                    keyList = keys.Select(key => new List <long> {
                        0, (long)key
                    }).SelectMany(lst => lst).ToList();
                }
                //EDCB系の時刻は、UTCじゃないけどUTC扱いなので
                keyList.Add(start.ToFileTimeUtc());
                keyList.Add(end == DateTime.MaxValue ? long.MaxValue : end.ToFileTimeUtc());

                return(CommonManager.CreateSrvCtrl().SendEnumPgArc(keyList, ref list));
            }
            catch { return(ErrCode.CMD_ERR); }
        }
Exemple #2
0
        /// <summary>現在の取得データに合わせてデフォルト表示の番組情報を展開する</summary>
        public List <UInt64> ExpandSpecialKey(List <UInt64> keyList, IEnumerable <EpgServiceInfo> additionalInfo = null)
        {
            if (keyList.All(key => !EpgServiceInfo.IsSPKey(key)))
            {
                return(keyList);
            }

            var list1 = Settings.Instance.ShowEpgCapServiceOnly ? ChSet5.ChListSelected :
                        (ServiceEventList.Any() ? ServiceEventList.Values.Select(info => info.serviceInfo) : ChSet5.ChList.Values)
                        .Concat(additionalInfo ?? Enumerable.Empty <EpgServiceInfo>());

            List <EpgServiceInfo> infoList = ChSet5.GetSortedChList(list1.Distinct(), true, true).ToList();
            var exDic = new Dictionary <UInt64, UInt64[]>();

            exDic.Add((UInt64)EpgServiceInfo.SpecialViewServices.ViewServiceDttv, infoList.Where(info => info.IsDttv).Select(info => info.Key).ToArray());
            exDic.Add((UInt64)EpgServiceInfo.SpecialViewServices.ViewServiceBS, infoList.Where(info => info.IsBS).Select(info => info.Key).ToArray());
            exDic.Add((UInt64)EpgServiceInfo.SpecialViewServices.ViewServiceCS, infoList.Where(info => info.IsCS).Select(info => info.Key).ToArray());
            exDic.Add((UInt64)EpgServiceInfo.SpecialViewServices.ViewServiceCS3, infoList.Where(info => info.IsSPHD).Select(info => info.Key).ToArray());
            exDic.Add((UInt64)EpgServiceInfo.SpecialViewServices.ViewServiceOther, infoList.Where(info => info.IsOther).Select(info => info.Key).ToArray());

            var exList = new List <UInt64>();

            foreach (UInt64 key in keyList)
            {
                if (exDic.ContainsKey(key))//一応チェック
                {
                    exList.AddRange(exDic[key]);
                }
                else
                {
                    exList.Add(key);
                }
            }
            return(exList.Distinct().ToList());
        }
Exemple #3
0
        public static EpgServiceInfo FromKey(UInt64 key)
        {
            if (IsSPKey(key))
            {
                return(CreateSPInfo(key));
            }

            EpgServiceInfo info = ChSet5.ChItem(key, true, true);

            if (info.Key != key)
            {
                //TSID移動前のチャンネルだった場合
                info.TSID = (ushort)(key >> 16);
            }
            else if (string.IsNullOrEmpty(info.service_name))
            {
                //ChSet5で全く見つからず、キーだけが入って戻ってきた場合
                info.network_name = CommonManager.ConvertNetworkNameText(info.ONID);
                //info.partialReceptionFlag = 0;不明
                info.remote_control_key_id = info.RemoconID();
                info.service_name          = "[不明]";
                info.service_provider_name = info.network_name;
                //info.service_type = 0x01;不明
                info.ts_name = info.network_name;
            }
            return(info);
        }
Exemple #4
0
        public static bool LoadWithStreamReader(Stream stream)
        {
            try
            {
                enc = Encoding.GetEncoding(932);
            }
            catch
            {
                enc = Encoding.UTF8;
            }

            try
            {
                chList             = new Dictionary <UInt64, EpgServiceInfo>();
                chListOrderByIndex = new List <EpgServiceInfo>();
                using (var reader = new System.IO.StreamReader(stream, enc))
                {
                    for (string buff = reader.ReadLine(); buff != null; buff = reader.ReadLine())
                    {
                        if (buff.StartsWith(";", StringComparison.Ordinal))
                        {
                            //コメント行
                            continue;
                        }
                        string[] list = buff.Split('\t');
                        var      item = new EpgServiceInfo();
                        try
                        {
                            item.service_name = list[0];
                            item.network_name = list[1];
                            item.ONID         = Convert.ToUInt16(list[2]);
                            item.TSID         = Convert.ToUInt16(list[3]);
                            item.SID          = Convert.ToUInt16(list[4]);
                            item.service_type = Convert.ToByte(list[5]);
                            item.PartialFlag  = Convert.ToInt32(list[6]) != 0;
                            item.EpgCapFlag   = Convert.ToInt32(list[7]) != 0;
                            item.SearchFlag   = Convert.ToInt32(list[8]) != 0;
                        }
                        catch
                        {
                            //不正
                            continue;
                        }
                        if (chList.ContainsKey(item.Key) == false)
                        {
                            chList[item.Key] = item;
                            chListOrderByIndex.Add(item);
                        }
                    }
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Exemple #5
0
        public static byte RemoconID(this EpgServiceInfo item)
        {
            byte ret = 0;

            if (item.IsDttv)
            {
                Settings.Instance.RemoconIDList.TryGetValue(item.TSID, out ret);
            }
            return(ret);
        }
Exemple #6
0
        /// <summary>予約情報の再描画</summary>
        protected override void ReloadReserveViewItem()
        {
            try
            {
                reserveList.Clear();
                recinfoList.Clear();

                var serviceReserveList = CombinedReserveList().ToLookup(data => data.Create64Key());
                int mergePos           = 0;
                int mergeNum           = 0;
                int servicePos         = -1;
                for (int i = 0; i < serviceEventList.Count; i++)
                {
                    //TSIDが同じでSIDが逆順に登録されているときは併合する
                    if (--mergePos < i - mergeNum)
                    {
                        EpgServiceInfo curr = serviceEventList[i].serviceInfo;
                        for (mergePos = i; mergePos + 1 < serviceEventList.Count; mergePos++)
                        {
                            EpgServiceInfo next = serviceEventList[mergePos + 1].serviceInfo;
                            if (next.ONID != curr.ONID || next.TSID != curr.TSID || next.SID >= curr.SID)
                            {
                                break;
                            }
                            curr = next;
                        }
                        mergeNum = mergePos + 1 - i;
                        servicePos++;
                    }
                    var key = serviceEventList[mergePos].serviceInfo.Key;
                    if (serviceReserveList.Contains(key) == true)
                    {
                        foreach (var info in serviceReserveList[key])
                        {
                            ProgramViewItem refPgItem = null;
                            ReserveViewItem resItem   = AddReserveViewItem(info, ref refPgItem, true);
                            if (resItem != null)
                            {
                                //横位置の設定
                                if (refPgItem != null && refPgItem.Data.Create64Key() != key)
                                {
                                    refPgItem = null;
                                }
                                resItem.Width   = refPgItem != null ? refPgItem.Width : this.EpgStyle().ServiceWidth / mergeNum;
                                resItem.LeftPos = this.EpgStyle().ServiceWidth *(servicePos + (double)((mergeNum + i - mergePos - 1) / 2) / mergeNum);
                            }
                        }
                    }
                }

                epgProgramView.SetReserveList(dataItemList);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #7
0
        public static EpgServiceInfo CreateSPInfo(UInt64 key)
        {
            var networks = new UInt16[] { 0x7880, 0x0004, 0x0006, 0x000A, 0x0000 };
            int idx      = Math.Min((int)(key & 0xFFFFUL), networks.Length - 1);
            var ret      = new EpgServiceInfo();

            ret.Key          = key;
            ret.ONID         = networks[idx];
            ret.network_name = CommonManager.ConvertNetworkNameText(ret.ONID, true);
            ret.service_name = string.Format("[{0}:全サービス]", ret.network_name);
            return(ret);
        }
Exemple #8
0
        public ErrCode SearchPgLists(List <EpgSearchKeyInfo> key, ref Dictionary <UInt64, EpgServiceAllEventInfo> serviceDic, EpgViewPeriod period = null)
        {
            ErrCode err = ErrCode.CMD_SUCCESS;

            //Epgデータ未取得時、SendSearchPg()の最古データは取得してみないと分からない。
            var  list            = new List <EpgEventInfo>();
            bool noSearchCurrent = period != null && IsEpgLoaded && period.End <= EventTimeMinCurrent;

            if (noSearchCurrent == false)
            {
                try { err = CommonManager.CreateSrvCtrl().SendSearchPg(key, ref list); } catch { err = ErrCode.CMD_ERR; }
                if (err != ErrCode.CMD_SUCCESS)
                {
                    return(err);
                }
                if (period != null && period.StrictLoad)
                {
                    list = PeriodApplied(list, period);
                }
            }

            var  list2       = new List <EpgEventInfo>();
            bool noSearchArc = period == null || EventTimeMaxArc != DateTime.MinValue && period.StartLoad > EventTimeMaxArc;

            if (noSearchArc == false)
            {
                try
                {
                    var pram = new SearchPgParam();
                    pram.keyList   = key;
                    pram.enumStart = period.StartLoad.ToFileTimeUtc();
                    pram.enumEnd   = period.End == DateTime.MaxValue ? long.MaxValue : period.End.ToFileTimeUtc();
                    CommonManager.CreateSrvCtrl().SendSearchPgArc(pram, ref list2);
                }
                catch { }
            }

            //サービス毎のリストに変換
            var sList = list.GroupBy(info => info.Create64Key()).Select(gr => new EpgServiceEventInfo {
                serviceInfo = EpgServiceInfo.FromKey(gr.Key), eventList = gr.ToList()
            }).ToList();
            var sList2 = list2.GroupBy(info => info.Create64Key()).Select(gr => new EpgServiceEventInfo {
                serviceInfo = EpgServiceInfo.FromKey(gr.Key), eventList = gr.ToList()
            }).ToList();

            serviceDic = EpgServiceAllEventInfo.CreateEpgServiceDictionary(sList, sList2);

            //サービス名の補正、イベントデータの再使用
            CorrectServiceInfo(serviceDic.Values, period == null || EventTimeBaseArc < period.End || EventTimeMinCurrent < period.End);

            return(err);
        }
Exemple #9
0
        public static EpgServiceInfo ChItemMask(UInt64 key, bool noNullReturn, UInt64 orMask)
        {
            EpgServiceInfo item = null;

            if ((chListOrderByIndex != null || LoadFile() != false) &&
                ChList.TryGetValue(key, out item) == false && orMask != 0)
            {
                item = chListOrderByIndex.FirstOrDefault(ch => (ch.Key | orMask) == (key | orMask));
            }
            return(item ?? (noNullReturn ? new EpgServiceInfo {
                Key = key
            } : null));
        }
Exemple #10
0
        //過去番組情報用の補正
        public void CorrectServiceInfo(IEnumerable <EpgServiceEventInfo> list, bool reUseData = false)
        {
            //データ未ロード時は再利用不可
            reUseData &= IsEpgLoaded;

            foreach (EpgServiceEventInfo info in list)
            {
                //あれば取得EPGデータのEpgServiceInfo、EventInfoに差し替え
                EpgServiceAllEventInfo refInfo;
                if (reUseData && ServiceEventList.TryGetValue(info.serviceInfo.Key, out refInfo))
                {
                    info.serviceInfo = refInfo.serviceInfo;
                }
                else
                {
                    EpgServiceInfo chSet5Item = ChSet5.ChItem(info.serviceInfo.Key, true, true);
                    if (info.serviceInfo.TSID != chSet5Item.TSID)
                    {
                        info.serviceInfo.service_name = "[廃]" + info.serviceInfo.service_name;
                    }
                    else if (string.IsNullOrWhiteSpace(chSet5Item.service_name) == false)
                    {
                        //過去チャンネルでない場合はChSet5の名称を優先する
                        info.serviceInfo.service_name = chSet5Item.service_name;
                        info.serviceInfo.network_name = chSet5Item.network_name;
                    }
                }

                new List <List <EpgEventInfo> > {
                    info.eventList, info is EpgServiceAllEventInfo ? (info as EpgServiceAllEventInfo).eventArcList : new List <EpgEventInfo>()
                }
                .ForEach(eventList =>
                {
                    for (int i = 0; i < eventList.Count; i++)
                    {
                        EpgEventInfo refData;
                        if (reUseData && EventUIDList.TryGetValue(eventList[i].CurrentPgUID(), out refData))
                        {
                            eventList[i] = refData;
                        }
                        else
                        {
                            eventList[i].ServiceInfo = info.serviceInfo;
                        }
                    }
                });
            }
        }
Exemple #11
0
        protected override object GetJumpTabService()
        {
            int idx = (int)Math.Floor(clickPos.X / viewData.EpgStyle().ServiceWidth);

            if (idx < 0 || idx >= primeServiceList.Count)
            {
                return(null);
            }
            EpgServiceInfo info = primeServiceList[idx];

            return(new SearchItem {
                ReserveInfo = new ReserveData {
                    OriginalNetworkID = info.ONID, TransportStreamID = info.TSID, ServiceID = info.SID
                }
            });
        }
Exemple #12
0
        private static int BSQuickCh(this EpgServiceInfo item)
        {
            //BSの連動放送のチャンネルをくくる
            if (item.IsBS == false)
            {
                return(0);
            }
            if (bsmin == null)
            {
                bsmin = (chListOrderByIndex ?? new List <EpgServiceInfo>()).GroupBy(d => d.TSID, d => d.SID)
                        .ToDictionary(d => d.Key, d => d.Min());
            }
            ushort ret = 0;

            bsmin.TryGetValue(item.TSID, out ret);
            return(ret);
        }
Exemple #13
0
        public static EpgServiceInfo ConvertChSet5To(ChSet5Item item)
        {
            EpgServiceInfo info = new EpgServiceInfo();

            {
                info.ONID                  = item.ONID;
                info.TSID                  = item.TSID;
                info.SID                   = item.SID;
                info.network_name          = item.NetworkName;
                info.partialReceptionFlag  = (byte)(item.PartialFlag ? 1 : 0);
                info.remote_control_key_id = 0;
                info.service_name          = item.ServiceName;
                info.service_provider_name = item.NetworkName;
                info.service_type          = (byte)item.ServiceType;
                info.ts_name               = item.NetworkName;
            }
            return(info);
        }
Exemple #14
0
        public EpgServiceItem(EpgServiceInfo info)
        {
            network_name          = info.network_name;
            ONID                  = info.ONID;
            partialReceptionFlag  = info.partialReceptionFlag;
            remote_control_key_id = info.remote_control_key_id;
            service_name          = info.service_name;
            service_provider_name = info.service_provider_name;
            service_type          = info.service_type;
            SID     = info.SID;
            ts_name = info.ts_name;
            TSID    = info.TSID;

            GroupID    = 0;
            GroupNext  = 0;
            LeftPos    = 0;
            Width      = 0;
            GroupWidth = 0;
        }
Exemple #15
0
        private static void CheckService(bool apply, ulong id, Action <ulong> SetNewId, ref string log)
        {
            EpgServiceInfo item = ChSet5.ChItem(id, true, true);

            if (item.Key != id)
            {
                if (apply)
                {
                    SetNewId(item.Key);
                }
                else if (log.Count(c => c == '\n') < 5)
                {
                    log += "  ID=0x" + id.ToString("X12") + " -> 0x" + item.Key.ToString("X12") + " (" + item.service_name + ")\r\n";
                }
                else if (log.EndsWith(".\r\n", StringComparison.Ordinal) == false)
                {
                    log += "  ...\r\n";
                }
            }
        }
Exemple #16
0
        public EpgServiceAllEventInfo(EpgServiceInfo serviceInfo, List <EpgEventInfo> eventList = null, List <EpgEventInfo> eventArcList = null)
        {
            this.serviceInfo  = serviceInfo;
            this.eventList    = eventList ?? new List <EpgEventInfo>();
            this.eventArcList = eventArcList ?? new List <EpgEventInfo>();

            //基本情報のEPGデータだけ未更新だったりするときがあるようなので一応重複確認する
            //重複排除は開始時刻のみチェックなので、幾つかに分割されている場合などは不十分になる
            //過去番組はアーカイブを優先する
            if (this.eventList.Count != 0 && this.eventArcList.Count != 0)
            {
                var timeSet = new HashSet <DateTime>(eventArcList.Select(data => data.PgStartTime)); //無いはずだが時間未定(PgStartTime=DateTime.MinValue)は吸収
                var addList = eventList.Where(data => timeSet.Contains(data.PgStartTime) == false);  //時間未定(PgStartTime=DateTime.MaxValue)は通過する。
                this.eventMergeList = eventArcList.Concat(addList).ToList();
            }
            else
            {
                this.eventMergeList = this.eventList.Count != 0 ? eventList : this.eventArcList;
            }
        }
        protected override void OnLoadingSubProc()
        {
            // サービス選択
            UInt64 serviceKey_Target = BlackoutWindow.Create64Key();

            if (serviceKey_Target == 0)
            {
                return;
            }

            foreach (ComboBoxItem item in this.comboBox_service.Items)
            {
                EpgServiceInfo serviceInfo = item.DataContext as EpgServiceInfo;
                if (serviceKey_Target == serviceInfo.Create64Key())
                {
                    if (this.comboBox_service.SelectedItem != item)
                    {
                        this.comboBox_service.SelectedItem = item;
                    }
                    break;
                }
            }
        }
Exemple #18
0
 public ServiceViewItem(EpgServiceInfo info)
 {
     ServiceInfo = info;
 }
Exemple #19
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        protected override void ReloadReserveViewItem()
        {
            try
            {
                reserveList.Clear();

                foreach (ReserveData info in CommonManager.Instance.DB.ReserveList.Values)
                {
                    int mergePos   = 0;
                    int mergeNum   = 0;
                    int servicePos = -1;
                    for (int i = 0; i < serviceList.Count; i++)
                    {
                        //TSIDが同じでSIDが逆順に登録されているときは併合する
                        if (--mergePos < i - mergeNum)
                        {
                            EpgServiceInfo curr = serviceList[i];
                            for (mergePos = i; mergePos + 1 < serviceList.Count; mergePos++)
                            {
                                EpgServiceInfo next = serviceList[mergePos + 1];
                                if (next.ONID != curr.ONID || next.TSID != curr.TSID || next.SID >= curr.SID)
                                {
                                    break;
                                }
                                curr = next;
                            }
                            mergeNum = mergePos + 1 - i;
                            servicePos++;
                        }
                        if (serviceList[mergePos].Create64Key() == info.Create64Key())
                        {
                            //timeListは番組表ベースなので、chkStartTimeはマージン適用前に作成する。
                            DateTime startTime    = info.StartTime;
                            DateTime chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);

                            //離れた時間のプログラム予約など、番組表が無いので表示不可
                            if (timeList.ContainsKey(chkStartTime) == false)
                            {
                                break;
                            }

                            //マージンを適用
                            Int32 duration = (Int32)info.DurationSecond;
                            ViewUtil.ApplyMarginForPanelView(info, ref startTime, ref duration);

                            var viewItem = new ReserveViewItem(info);
                            reserveList.Add(viewItem);

                            viewItem.LeftPos = Settings.Instance.ServiceWidth * (servicePos + (double)((mergeNum + i - mergePos - 1) / 2) / mergeNum);

                            //最低表示行数の適用の際、最低表示高さを設定しているので、Settings.Instance.MinimumHeight == 0 でも検索するようにする
                            ProgramViewItem pgInfo = null;
                            if (info.IsEpgReserve == true && info.DurationSecond != 0)
                            {
                                //予約情報から番組情報を特定し、枠表示位置を再設定する
                                UInt64 key = info.Create64PgKey();
                                pgInfo = timeList[chkStartTime].Find(info1 => key == info1.EventInfo.Create64PgKey());
                            }

                            if (pgInfo != null)
                            {
                                viewItem.TopPos = pgInfo.TopPos + pgInfo.Height * (startTime - info.StartTime).TotalSeconds / info.DurationSecond;
                                viewItem.Height = Math.Max(pgInfo.Height * duration / info.DurationSecond, ViewUtil.PanelMinimumHeight);
                                viewItem.Width  = pgInfo.Width;
                            }
                            else
                            {
                                int index = timeList.IndexOfKey(chkStartTime);
                                viewItem.TopPos = Settings.Instance.MinHeight * (index * 60 + (startTime - chkStartTime).TotalMinutes);
                                viewItem.Height = Math.Max(duration * Settings.Instance.MinHeight / 60, ViewUtil.PanelMinimumHeight);

                                //番組表の統合関係
                                pgInfo = timeList.Values[index].Find(info1 => info1.LeftPos == viewItem.LeftPos &&
                                                                     info1.TopPos <= viewItem.TopPos && viewItem.TopPos < info1.TopPos + info1.Height);
                                if (pgInfo != null)
                                {
                                    viewItem.Width = pgInfo.Width;
                                }
                                else
                                {
                                    viewItem.Width = Settings.Instance.ServiceWidth / mergeNum;
                                }
                            }

                            break;
                        }
                    }
                }
                epgProgramView.SetReserveList(reserveList);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #20
0
 public EpgServiceAllEventInfo(EpgServiceInfo serviceInfo)
     : this(serviceInfo, new List <EpgEventInfo>(), new List <EpgEventInfo>())
 {
 }
Exemple #21
0
 public EpgServiceAllEventInfo(EpgServiceInfo serviceInfo, List <EpgEventInfo> eventList, List <EpgEventInfo> eventArcList)
 {
     this.serviceInfo  = serviceInfo;
     this.eventList    = eventList;
     this.eventArcList = eventArcList;
 }
Exemple #22
0
 public EpgServiceEventInfo()
 {
     serviceInfo = new EpgServiceInfo();
     eventList   = new List <EpgEventInfo>();
 }
Exemple #23
0
 public EpgServiceEventInfo()
 {
     serviceInfo = new EpgServiceInfo();
     eventList = new List<EpgEventInfo>();
 }
Exemple #24
0
 public static UInt64 Create64Key(this EpgServiceInfo obj)
 {
     return(CommonManager.Create64Key(obj.ONID, obj.TSID, obj.SID));
 }
Exemple #25
0
 public static int ChNumber(this EpgServiceInfo item)
 {
     return(item.IsDttv ? item.RemoconID() : item.SID& 0x3FF);
 }
Exemple #26
0
        /// <summary>番組情報の再描画</summary>
        protected override void ReloadProgramViewItem()
        {
            try
            {
                dateView.ClearInfo();
                timeView.ClearInfo();
                serviceView.ClearInfo();
                epgProgramView.ClearInfo();
                timeList.Clear();
                programList.Clear();
                ReDrawNowLine();

                if (serviceEventList.Count == 0)
                {
                    return;
                }

                //必要番組の抽出と時間チェック
                var primeServiceList = new List <EpgServiceInfo>();
                //番組表でまとめて描画する矩形の幅と番組集合のリスト
                var programGroupList = new List <PanelItem <List <ProgramViewItem> > >();
                int groupSpan        = 1;
                int mergePos         = 0;
                int mergeNum         = 0;
                int servicePos       = -1;
                for (int i = 0; i < serviceEventList.Count; i++)
                {
                    //TSIDが同じでSIDが逆順に登録されているときは併合する
                    int spanCheckNum = 1;
                    if (--mergePos < i - mergeNum)
                    {
                        EpgServiceInfo curr = serviceEventList[i].serviceInfo;
                        for (mergePos = i; mergePos + 1 < serviceEventList.Count; mergePos++)
                        {
                            EpgServiceInfo next = serviceEventList[mergePos + 1].serviceInfo;
                            if (next.ONID != curr.ONID || next.TSID != curr.TSID || next.SID >= curr.SID)
                            {
                                break;
                            }
                            curr = next;
                        }
                        mergeNum = mergePos + 1 - i;
                        servicePos++;
                        //正順のときは貫きチェックするサービス数を調べる
                        for (; mergeNum == 1 && i + spanCheckNum < serviceEventList.Count; spanCheckNum++)
                        {
                            EpgServiceInfo next = serviceEventList[i + spanCheckNum].serviceInfo;
                            if (next.ONID != curr.ONID || next.TSID != curr.TSID)
                            {
                                break;
                            }
                            else if (next.SID < curr.SID)
                            {
                                spanCheckNum--;
                                break;
                            }
                            curr = next;
                        }
                        if (--groupSpan <= 0)
                        {
                            groupSpan = spanCheckNum;
                            programGroupList.Add(new PanelItem <List <ProgramViewItem> >(new List <ProgramViewItem>())
                            {
                                Width = this.EpgStyle().ServiceWidth *groupSpan
                            });
                        }
                        primeServiceList.Add(serviceEventList[mergePos].serviceInfo);
                    }

                    foreach (EpgEventInfo eventInfo in serviceEventList[mergePos].eventList)
                    {
                        //イベントグループのチェック
                        int widthSpan = 1;
                        if (eventInfo.EventGroupInfo != null)
                        {
                            //サービス2やサービス3の結合されるべきもの
                            if (eventInfo.IsGroupMainEvent == false)
                            {
                                continue;
                            }

                            //横にどれだけ貫くかチェック
                            int count = 1;
                            while (mergeNum == 1 ? count < spanCheckNum : count < mergeNum - (mergeNum + i - mergePos - 1) / 2)
                            {
                                EpgServiceInfo nextInfo = serviceEventList[mergeNum == 1 ? i + count : mergePos - count].serviceInfo;
                                bool           findNext = false;
                                foreach (EpgEventData data in eventInfo.EventGroupInfo.eventDataList)
                                {
                                    if (nextInfo.Key == data.Create64Key())
                                    {
                                        widthSpan++;
                                        findNext = true;
                                    }
                                }
                                if (findNext == false)
                                {
                                    break;
                                }
                                count++;
                            }
                        }

                        //continueが途中にあるので登録はこの位置
                        var viewItem = new ProgramViewItem(eventInfo)
                        {
                            EpgSettingIndex = viewInfo.EpgSettingIndex, Filtered = viewData.EventFilteredHash.Contains(eventInfo.CurrentPgUID())
                        };
                        viewItem.DrawHours = eventInfo.start_time != LimitedStart(eventInfo);
                        programList[eventInfo.CurrentPgUID()] = viewItem;
                        programGroupList.Last().Data.Add(viewItem);

                        //横位置の設定
                        viewItem.Width   = this.EpgStyle().ServiceWidth *widthSpan / mergeNum;
                        viewItem.LeftPos = this.EpgStyle().ServiceWidth *(servicePos + (double)((mergeNum + i - mergePos - 1) / 2) / mergeNum);
                    }
                }

                //縦位置の設定
                if (viewCustNeedTimeOnly == false && programList.Count != 0)
                {
                    ViewUtil.AddTimeList(timeList, programList.Values.Min(item => LimitedStart(item.Data)), 0);
                }
                SetProgramViewItemVertical();

                epgProgramView.SetProgramList(programGroupList, timeList.Count * 60 * this.EpgStyle().MinHeight);
                timeView.SetTime(timeList, false);
                dateView.SetTime(timeList, ViewPeriod);
                serviceView.SetService(primeServiceList);

                ReDrawNowLine();
                MoveNowTime();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #27
0
 public ServiceViewItem(UInt64 key)
 {
     ServiceInfo = EpgServiceInfo.FromKey(key);
 }
Exemple #28
0
        /// <summary>
        /// 番組情報の再描画処理
        /// </summary>
        protected override void ReloadProgramViewItem()
        {
            try
            {
                epgProgramView.ClearInfo();
                timeList.Clear();
                programList.Clear();
                nowViewTimer.Stop();
                serviceList.Clear();

                foreach (UInt64 id in viewCustServiceList)
                {
                    if (serviceEventList.ContainsKey(id) == true)
                    {
                        EpgServiceInfo serviceInfo = serviceEventList[id].serviceInfo;
                        if (serviceList.Exists(i => i.Create64Key() == serviceInfo.Create64Key()) == false)
                        {
                            serviceList.Add(serviceInfo);
                        }
                    }
                }

                //必要番組の抽出と時間チェック
                List <EpgServiceInfo> primeServiceList = new List <EpgServiceInfo>();
                //番組表でまとめて描画する矩形の幅と番組集合のリスト
                var programGroupList = new List <Tuple <double, List <ProgramViewItem> > >();
                int groupSpan        = 1;
                int mergePos         = 0;
                int mergeNum         = 0;
                int servicePos       = -1;
                for (int i = 0; i < serviceList.Count; i++)
                {
                    //TSIDが同じでSIDが逆順に登録されているときは併合する
                    int spanCheckNum = 1;
                    if (--mergePos < i - mergeNum)
                    {
                        EpgServiceInfo curr = serviceList[i];
                        for (mergePos = i; mergePos + 1 < serviceList.Count; mergePos++)
                        {
                            EpgServiceInfo next = serviceList[mergePos + 1];
                            if (next.ONID != curr.ONID || next.TSID != curr.TSID || next.SID >= curr.SID)
                            {
                                break;
                            }
                            curr = next;
                        }
                        mergeNum = mergePos + 1 - i;
                        servicePos++;
                        //正順のときは貫きチェックするサービス数を調べる
                        for (; mergeNum == 1 && i + spanCheckNum < serviceList.Count; spanCheckNum++)
                        {
                            EpgServiceInfo next = serviceList[i + spanCheckNum];
                            if (next.ONID != curr.ONID || next.TSID != curr.TSID)
                            {
                                break;
                            }
                            else if (next.SID < curr.SID)
                            {
                                spanCheckNum--;
                                break;
                            }
                            curr = next;
                        }
                        if (--groupSpan <= 0)
                        {
                            groupSpan = spanCheckNum;
                            programGroupList.Add(new Tuple <double, List <ProgramViewItem> >(Settings.Instance.ServiceWidth * groupSpan, new List <ProgramViewItem>()));
                        }
                        primeServiceList.Add(serviceList[mergePos]);
                    }

                    EpgServiceInfo serviceInfo = serviceList[mergePos];
                    UInt64         id          = serviceInfo.Create64Key();
                    foreach (EpgEventInfo eventInfo in serviceEventList[id].eventList)
                    {
                        if (eventInfo.StartTimeFlag == 0)
                        {
                            //開始未定は除外
                            continue;
                        }
                        //ジャンル絞り込み
                        if (ViewUtil.ContainsContent(eventInfo, this.viewCustContentKindList) == false)
                        {
                            continue;
                        }
                        //イベントグループのチェック
                        int widthSpan = 1;
                        if (eventInfo.EventGroupInfo != null)
                        {
                            bool spanFlag = false;
                            foreach (EpgEventData data in eventInfo.EventGroupInfo.eventDataList)
                            {
                                if (serviceInfo.Create64Key() == data.Create64Key())
                                {
                                    spanFlag = true;
                                    break;
                                }
                            }

                            if (spanFlag == false)
                            {
                                //サービス2やサービス3の結合されるべきもの
                                continue;
                            }
                            else
                            {
                                //横にどれだけ貫くかチェック
                                int count = 1;
                                while (mergeNum == 1 ? count < spanCheckNum : count < mergeNum - (mergeNum + i - mergePos - 1) / 2)
                                {
                                    EpgServiceInfo nextInfo = serviceList[mergeNum == 1 ? i + count : mergePos - count];
                                    bool           findNext = false;
                                    foreach (EpgEventData data in eventInfo.EventGroupInfo.eventDataList)
                                    {
                                        if (nextInfo.Create64Key() == data.Create64Key())
                                        {
                                            widthSpan++;
                                            findNext = true;
                                        }
                                    }
                                    if (findNext == false)
                                    {
                                        break;
                                    }
                                    count++;
                                }
                            }
                        }

                        var viewItem = new ProgramViewItem(eventInfo);
                        viewItem.Height    = Settings.Instance.MinHeight * eventInfo.PgDurationSecond / 60;
                        viewItem.HeightDef = viewItem.Height;//元の情報も保存
                        viewItem.Width     = Settings.Instance.ServiceWidth * widthSpan / mergeNum;
                        viewItem.LeftPos   = Settings.Instance.ServiceWidth * (servicePos + (double)((mergeNum + i - mergePos - 1) / 2) / mergeNum);
                        programGroupList[programGroupList.Count - 1].Item2.Add(viewItem);
                        programList.Add(viewItem);

                        //必要時間リストの構築
                        var chkStartTime = new DateTime(eventInfo.start_time.Year, eventInfo.start_time.Month, eventInfo.start_time.Day, eventInfo.start_time.Hour, 0, 0);
                        while (chkStartTime <= eventInfo.start_time.AddSeconds(eventInfo.PgDurationSecond))
                        {
                            if (timeList.ContainsKey(chkStartTime) == false)
                            {
                                timeList.Add(chkStartTime, new List <ProgramViewItem>());
                            }
                            chkStartTime = chkStartTime.AddHours(1);
                        }
                    }
                }

                //必要時間のチェック
                if (viewCustNeedTimeOnly == false)
                {
                    //番組のない時間帯を追加
                    for (int i = 1; i < timeList.Count; i++)
                    {
                        if (timeList.Keys[i] > timeList.Keys[i - 1].AddHours(1))
                        {
                            timeList.Add(timeList.Keys[i - 1].AddHours(1), new List <ProgramViewItem>());
                        }
                    }

                    //番組の表示位置設定
                    foreach (ProgramViewItem item in programList)
                    {
                        item.TopPos    = (item.EventInfo.start_time - timeList.Keys[0]).TotalMinutes * Settings.Instance.MinHeight;
                        item.TopPosDef = item.TopPos;//元の情報も保存
                    }
                }
                else
                {
                    //番組の表示位置設定
                    foreach (ProgramViewItem item in programList)
                    {
                        var chkStartTime = new DateTime(item.EventInfo.start_time.Year,
                                                        item.EventInfo.start_time.Month,
                                                        item.EventInfo.start_time.Day,
                                                        item.EventInfo.start_time.Hour,
                                                        0,
                                                        0);
                        if (timeList.ContainsKey(chkStartTime) == true)
                        {
                            int index = timeList.IndexOfKey(chkStartTime);
                            item.TopPos = (index * 60 + (item.EventInfo.start_time - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                        }
                    }
                }

                //最低表示行数からドット数を計算する。
                //double fontHeight = Math.Max(Settings.Instance.FontHeight, Settings.Instance.FontHeightTitle);
                //double lineHeight = Settings.Instance.MinimumHeight * fontHeight;
                // メイリオみたいに行間のあるフォントはフォントの高さをそのまま使う。
                double fontHeight = Math.Max(Settings.Instance.FontHeight, Settings.Instance.FontHeightTitle);
                // MS P ゴシックみたいな行間のないフォントは 2px あける。
                double fontSize = Math.Max(Settings.Instance.FontSize, Settings.Instance.FontSizeTitle) + 2;
                // 大きい方をフォントの高さとして採用し、最低表示px数を計算する。
                double lineHeight = Settings.Instance.MinimumHeight * Math.Max(fontHeight, fontSize);
                if (Settings.Instance.MinimumHeight >= 2)
                {
                    lineHeight += 4;                                                                         // 説明との間隔は 4px にする
                }
                ViewUtil.ModifierMinimumHeight <EpgEventInfo, ProgramViewItem>(programList, lineHeight + 1); //1ドットは枠の分

                //必要時間リストと時間と番組の関連づけ
                ViewUtil.SetTimeList(programList, timeList);

                epgProgramView.SetProgramList(
                    programGroupList,
                    timeList.Count * 60 * Settings.Instance.MinHeight);

                var dateTimeList = new List <DateTime>();
                foreach (var item in timeList)
                {
                    dateTimeList.Add(item.Key);
                }
                timeView.SetTime(dateTimeList, viewCustNeedTimeOnly, false);
                dateView.SetTime(dateTimeList);
                serviceView.SetService(primeServiceList);

                ReDrawNowLine();
                MoveNowTime();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #29
0
 public static EpgServiceInfo ConvertChSet5To(ChSet5Item item)
 {
     EpgServiceInfo info = new EpgServiceInfo();
     try
     {
         info.ONID = item.ONID;
         info.TSID = item.TSID;
         info.SID = item.SID;
         info.network_name = item.NetworkName;
         info.partialReceptionFlag = item.PartialFlag;
         info.remote_control_key_id = item.RemoconID;
         info.service_name = item.ServiceName;
         info.service_provider_name = item.NetworkName;
         info.service_type = (byte)item.ServiceType;
         info.ts_name = item.NetworkName;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
     }
     return info;
 }
Exemple #30
0
 public EpgServiceAllEventInfo(EpgServiceInfo serviceInfo, List <EpgEventInfo> eventList = null, List <EpgEventInfo> eventArcList = null)
 {
     this.serviceInfo  = serviceInfo;
     this.eventList    = eventList ?? new List <EpgEventInfo>();
     this.eventArcList = eventArcList ?? new List <EpgEventInfo>();
 }