Example #1
0
        //SearchItem関係
        public virtual int MoveToReserveItem(ReserveData target, JumpItemStyle style = JumpItemStyle.MoveTo, bool dryrun = false)
        {
            if (DataListBox == null || DataListBox.Items.Count == 0)
            {
                return(-1);
            }

            var items = DataListBox.Items.OfType <SearchItem>();

            if (target != null && target.IsEpgReserve == true)
            {
                //重複予約には注意する。
                var item = items.FirstOrDefault(d => d.IsReserved == true && d.ReserveInfo.ReserveID == target.ReserveID);
                int idx  = ViewUtil.ScrollToFindItem(item, DataListBox, style, dryrun);
                if (dryrun == false)
                {
                    ItemIdx = idx;
                }
                return(idx);
            }
            else
            {
                //プログラム予約だと見つからないので、それらしい番組へジャンプする。
                return(MoveToProgramItem(target == null ? null : MenuUtil.GetPgInfoLikeThat(target, null, items.GetEventList()), style, dryrun));
            }
        }
Example #2
0
        public EpgEventInfo GetReserveEventList(ReserveData master, bool isSrv = true)
        {
            if (master == null || master.ReserveID == 0)
            {
                return(null);
            }

            if (reserveEventList == null)
            {
                if (IsEpgLoaded || Settings.Instance.NoReserveEventList == true)
                {
                    reserveEventList = ReserveList.Values.ToDictionary(rs => rs.ReserveID,
                                                                       rs => rs.IsEpgReserve ? MenuUtil.GetPgInfoUid(rs.CurrentPgUID()) : MenuUtil.GetPgInfoLikeThat(rs));
                }
                else
                {
                    reserveEventList      = new Dictionary <uint, EpgEventInfo>();
                    reserveEventListCache = reserveEventListCache ?? new Dictionary <ulong, EpgEventInfo>();

                    //要求はしないが、有効なデータが既に存在していればキーワード予約の追加データを参照する。
                    bool useAppend = epgAutoAddAppendList != null && updateEpgAutoAddAppend == false &&
                                     updateEpgAutoAddAppendReserveInfo == false;

                    //プログラム予約はここで探しても精度低いので諦める
                    var trgList = new List <ReserveData>();
                    foreach (ReserveData data in ReserveList.Values.Where(r => r.IsEpgReserve))
                    {
                        EpgEventInfo info = null;
                        ulong        key  = data.Create64PgKey();
                        if (useAppend == true)
                        {
                            List <EpgAutoAddData> epgAutoList = data.GetEpgAutoAddList();
                            if (epgAutoList.Count != 0)
                            {
                                SearchItem item = epgAutoList[0].GetSearchList()
                                                  .Find(sI => sI.IsReserved == true && sI.ReserveInfo.ReserveID == data.ReserveID);
                                if (item != null)
                                {
                                    info = item.EventInfo;
                                    reserveEventListCache[key] = info;
                                }
                            }
                        }
                        if (info != null || reserveEventListCache.TryGetValue(key, out info))
                        {
                            reserveEventList[data.ReserveID] = info;
                        }
                        else
                        {
                            trgList.Add(data);
                        }
                    }

                    if (isSrv == true && trgList.Any())
                    {
                        var pgIDset = trgList.ToLookup(data => data.Create64PgKey(), data => data.ReserveID);
                        var keys    = pgIDset.Select(lu => lu.Key).ToList();
                        var list    = new List <EpgEventInfo>();
                        try { CommonManager.CreateSrvCtrl().SendGetPgInfoList(keys, ref list); } catch { }

                        foreach (EpgEventInfo info in list)
                        {
                            ulong key = info.Create64PgKey();
                            if (pgIDset.Contains(key) == true)
                            {
                                foreach (uint rID in pgIDset[key])
                                {
                                    reserveEventList[rID] = info;
                                }
                                reserveEventListCache[key] = info;
                            }
                        }
                    }
                }
            }

            EpgEventInfo retv;

            reserveEventList.TryGetValue(master.ReserveID, out retv);
            return(retv);
        }