Exemple #1
0
        /// <summary>予約情報の再描画</summary>
        protected override void ReloadReserveViewItem()
        {
            try
            {
                reserveList.Clear();

                UInt64 selectID = GetSelectID(true);
                foreach (ReserveData info in CommonManager.Instance.DB.ReserveList.Values)
                {
                    if (selectID == info.Create64Key())
                    {
                        ProgramViewItem dummy   = null;
                        ReserveViewItem resItem = AddReserveViewItem(info, ref dummy);
                        if (resItem != null)
                        {
                            //横位置の設定
                            resItem.Width   = Settings.Instance.ServiceWidth;
                            resItem.LeftPos = resItem.Width * dayList.BinarySearch(GetViewDay(info.StartTime));

                            //範囲外は削除する。日を追加するのは簡単だが、viewCustNeedTimeOnly==trueで時間の方を追加するのが面倒すぎる。
                            if (resItem.LeftPos < 0)
                            {
                                reserveList.Remove(resItem);
                            }
                        }
                    }
                }

                epgProgramView.SetReserveList(reserveList);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #2
0
        /// <summary>予約情報の再描画</summary>
        protected override void ReloadReserveViewItem()
        {
            try
            {
                reserveList.Clear();
                recinfoList.Clear();

                UInt64 selectID = GetSelectID(true);
                foreach (ReserveData info in CombinedReserveList())
                {
                    if (selectID == info.Create64Key())
                    {
                        //離れたプログラム予約など範囲外は除外。
                        int dayPos = dayList.BinarySearch(GetViewDay(info.StartTime));
                        if (dayPos < 0)
                        {
                            continue;
                        }

                        ProgramViewItem dummy   = null;
                        ReserveViewItem resItem = AddReserveViewItem(info, ref dummy);
                        if (resItem != null)
                        {
                            //横位置の設定
                            resItem.Width   = this.EpgStyle().ServiceWidth;
                            resItem.LeftPos = resItem.Width * dayPos;
                        }
                    }
                }

                epgProgramView.SetReserveList(dataItemList);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #3
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 #4
0
        /// <summary>
        /// 番組情報の再描画処理
        /// </summary>
        private void ReloadProgramViewItem()
        {
            try
            {
                Dictionary<UInt64, EpgServiceEventInfo> serviceEventList =
                    setViewInfo.SearchMode == true ? searchEventList : CommonManager.Instance.DB.ServiceEventList;

                //直前にthis.ClearInfo()が走ってるので無くても同じ
                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 (vutil.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.DurationFlag == 0 ? 300 : eventInfo.durationSec) / 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.DurationFlag == 0 ? 300 : eventInfo.durationSec)))
                        {
                            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 にする
                }
                vutil.ModifierMinimumHeight<EpgEventInfo, ProgramViewItem>(programList, lineHeight + 1); //1ドットは枠の分

                //必要時間リストと時間と番組の関連づけ
                vutil.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);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Exemple #5
0
        /// <summary>
        /// 番組情報の再描画処理
        /// </summary>
        private void ReloadProgramViewItemForSearch()
        {
            try
            {
                epgProgramView.ClearInfo();
                timeList.Clear();
                programList.Clear();
                nowViewTimer.Stop();

                serviceList.Clear();

                //番組情報の検索
                List<EpgSearchKeyInfo> keyList = new List<EpgSearchKeyInfo>();
                keyList.Add(setViewInfo.SearchKey);
                List<EpgEventInfo> list = new List<EpgEventInfo>();

                cmd.SendSearchPg(keyList, ref list);

                //サービス毎のリストに変換
                Dictionary<UInt64, EpgServiceEventInfo> serviceEventList = new Dictionary<UInt64, EpgServiceEventInfo>();
                foreach (EpgEventInfo eventInfo in list)
                {
                    UInt64 id = CommonManager.Create64Key(eventInfo.original_network_id, eventInfo.transport_stream_id, eventInfo.service_id);
                    EpgServiceEventInfo serviceInfo = null;
                    if (serviceEventList.ContainsKey(id) == false)
                    {
                        if (ChSet5.Instance.ChList.ContainsKey(id) == false)
                        {
                            //サービス情報ないので無効
                            continue;
                        }
                        serviceInfo = new EpgServiceEventInfo();
                        serviceInfo.serviceInfo = CommonManager.ConvertChSet5To(ChSet5.Instance.ChList[id]);

                        serviceEventList.Add(id, serviceInfo);
                    }
                    else
                    {
                        serviceInfo = serviceEventList[id];
                    }
                    serviceInfo.eventList.Add(eventInfo);
                }


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


                //必要番組の抽出と時間チェック
                List<EpgServiceInfo> primeServiceList = new List<EpgServiceInfo>();
                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;
                        }
                        primeServiceList.Add(serviceList[mergePos]);
                    }

                    EpgServiceInfo serviceInfo = serviceList[mergePos];
                    UInt64 id = CommonManager.Create64Key(serviceInfo.ONID, serviceInfo.TSID, serviceInfo.SID);
                    foreach (EpgEventInfo eventInfo in serviceEventList[id].eventList)
                    {
                        if (eventInfo.StartTimeFlag == 0)
                        {
                            //開始未定は除外
                            continue;
                        }
                        //ジャンル絞り込み
                        if (this.viewCustContentKindList.Count > 0)
                        {
                            bool find = false;
                            if (eventInfo.ContentInfo != null)
                            {
                                if (eventInfo.ContentInfo.nibbleList.Count > 0)
                                {
                                    foreach (EpgContentData contentInfo in eventInfo.ContentInfo.nibbleList)
                                    {
                                        UInt16 ID1 = (UInt16)(((UInt16)contentInfo.content_nibble_level_1) << 8 | 0xFF);
                                        UInt16 ID2 = (UInt16)(((UInt16)contentInfo.content_nibble_level_1) << 8 | contentInfo.content_nibble_level_2);
                                        if (this.viewCustContentKindList.ContainsKey(ID1) == true)
                                        {
                                            find = true;
                                            break;
                                        }
                                        else if (this.viewCustContentKindList.ContainsKey(ID2) == true)
                                        {
                                            find = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (find == false)
                            {
                                //ジャンル見つからないので除外
                                continue;
                            }
                        }
                        //イベントグループのチェック
                        int widthSpan = 1;
                        if (eventInfo.EventGroupInfo != null)
                        {
                            bool spanFlag = false;
                            foreach (EpgEventData data in eventInfo.EventGroupInfo.eventDataList)
                            {
                                if (serviceInfo.ONID == data.original_network_id &&
                                    serviceInfo.TSID == data.transport_stream_id &&
                                    serviceInfo.SID == data.service_id)
                                {
                                    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.ONID == data.original_network_id &&
                                            nextInfo.TSID == data.transport_stream_id &&
                                            nextInfo.SID == data.service_id)
                                        {
                                            widthSpan++;
                                            findNext = true;
                                        }
                                    }
                                    if (findNext == false)
                                    {
                                        break;
                                    }
                                    count++;
                                }
                            }
                        }

                        ProgramViewItem viewItem = new ProgramViewItem(eventInfo);
                        viewItem.Height = ((eventInfo.DurationFlag == 0 ? 300 : eventInfo.durationSec) * Settings.Instance.MinHeight) / 60;
                        viewItem.Width = Settings.Instance.ServiceWidth * widthSpan / mergeNum;
                        viewItem.LeftPos = Settings.Instance.ServiceWidth * (servicePos + (double)((mergeNum+i-mergePos-1)/2) / mergeNum);
                        //viewItem.TopPos = (eventInfo.start_time - startTime).TotalMinutes * Settings.Instance.MinHeight;
                        programList.Add(viewItem);

                        //日付チェック
                        DateTime EndTime;
                        if (eventInfo.DurationFlag == 0)
                        {
                            //終了未定
                            EndTime = eventInfo.start_time.AddSeconds(30 * 10);
                        }
                        else
                        {
                            EndTime = eventInfo.start_time.AddSeconds(eventInfo.durationSec);
                        }
                        //必要時間リストの構築
                        DateTime chkStartTime = new DateTime(eventInfo.start_time.Year, eventInfo.start_time.Month, eventInfo.start_time.Day, eventInfo.start_time.Hour, 0, 0);
                        while (chkStartTime <= EndTime)
                        {
                            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;
                    }
                }
                else
                {
                    //番組の表示位置設定
                    foreach (ProgramViewItem item in programList)
                    {
                        DateTime 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;
                        }
                    }
                }

                if (Settings.Instance.MinimumHeight > 0)
                {
                    //最低表示行数を適用
                    programList.Sort((x, y) => Math.Sign(x.LeftPos - y.LeftPos) * 2 + Math.Sign(x.TopPos - y.TopPos));
                    double minimum = (Settings.Instance.FontSizeTitle + 2) * Settings.Instance.MinimumHeight;
                    double lastLeft = double.MinValue;
                    double lastBottom = 0;
                    foreach (ProgramViewItem item in programList)
                    {
                        if (lastLeft != item.LeftPos)
                        {
                            lastLeft = item.LeftPos;
                            lastBottom = double.MinValue;
                        }
                        item.Height = Math.Max(item.Height, minimum);
                        if (item.TopPos < lastBottom)
                        {
                            item.Height = Math.Max(item.TopPos + item.Height - lastBottom, minimum);
                            item.TopPos = lastBottom;
                        }
                        lastBottom = item.TopPos + item.Height;
                    }
                }

                //必要時間リストと時間と番組の関連づけ
                foreach (ProgramViewItem item in programList)
                {
                    int index = Math.Max((int)(item.TopPos / (60 * Settings.Instance.MinHeight)), 0);
                    while (index < Math.Min((int)((item.TopPos + item.Height) / (60 * Settings.Instance.MinHeight)) + 1, timeList.Count))
                    {
                        timeList.Values[index++].Add(item);
                    }
                }

                epgProgramView.SetProgramList(
                    programList,
                    timeList,
                    primeServiceList.Count() * Settings.Instance.ServiceWidth,
                    timeList.Count * 60 * Settings.Instance.MinHeight);

                List<DateTime> 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();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
        private void UpdateProgramView()
        {
            try
            {
                epgProgramView.ClearInfo();
                timeList.Clear();
                dayList.Clear();
                programList.Clear();

                nowViewTimer.Stop();

                if (comboBox_service.Items.Count == 0)
                {
                    return;
                }

                UInt64 selectID = 0;
                if (comboBox_service.SelectedItem != null)
                {
                    ComboBoxItem item = comboBox_service.SelectedItem as ComboBoxItem;
                    EpgServiceInfo serviceInfo = item.DataContext as EpgServiceInfo;
                    selectID = CommonManager.Create64Key(serviceInfo.ONID, serviceInfo.TSID, serviceInfo.SID);
                }
                else
                {
                    ComboBoxItem item = comboBox_service.Items.GetItemAt(0) as ComboBoxItem;
                    EpgServiceInfo serviceInfo = item.DataContext as EpgServiceInfo;
                    selectID = CommonManager.Create64Key(serviceInfo.ONID, serviceInfo.TSID, serviceInfo.SID);
                }

                Dictionary<UInt64, EpgServiceEventInfo> serviceEventList = null;
                if (setViewInfo.SearchMode == true)
                {
                    serviceEventList = searchEventList;
                }
                else
                {
                    serviceEventList = CommonManager.Instance.DB.ServiceEventList;
                }

                //まず日時のチェック
                foreach (EpgEventInfo eventInfo in serviceEventList[selectID].eventList)
                {
                    if (eventInfo.StartTimeFlag == 0)
                    {
                        //開始未定は除外
                        continue;
                    }
                    //ジャンル絞り込み
                    if (this.viewCustContentKindList.Count > 0)
                    {
                        bool find = false;
                        if (eventInfo.ContentInfo != null)
                        {
                            if (eventInfo.ContentInfo.nibbleList.Count > 0)
                            {
                                foreach (EpgContentData contentInfo in eventInfo.ContentInfo.nibbleList)
                                {
                                    UInt16 ID1 = (UInt16)(((UInt16)contentInfo.content_nibble_level_1) << 8 | 0xFF);
                                    UInt16 ID2 = (UInt16)(((UInt16)contentInfo.content_nibble_level_1) << 8 | contentInfo.content_nibble_level_2);
                                    if (this.viewCustContentKindList.ContainsKey(ID1) == true)
                                    {
                                        find = true;
                                        break;
                                    }
                                    else if (this.viewCustContentKindList.ContainsKey(ID2) == true)
                                    {
                                        find = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (find == false)
                        {
                            //ジャンル見つからないので除外
                            continue;
                        }
                    }

                    ProgramViewItem viewItem = new ProgramViewItem(eventInfo);
                    viewItem.Height = ((eventInfo.DurationFlag == 0 ? 300 : eventInfo.durationSec) * Settings.Instance.MinHeight) / 60;
                    viewItem.Width = Settings.Instance.ServiceWidth;
                    programList.Add(viewItem);

                    //日付列の決定
                    DateTime dayInfo;
                    if (eventInfo.start_time.Hour < setViewInfo.StartTimeWeek)
                    {
                        DateTime time = eventInfo.start_time.AddDays(-1);
                        dayInfo = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0);
                    }
                    else
                    {
                        dayInfo = new DateTime(eventInfo.start_time.Year, eventInfo.start_time.Month, eventInfo.start_time.Day, 0, 0, 0);
                    }

                    if (dayList.ContainsKey(dayInfo) == false)
                    {
                        dayList.Add(dayInfo, dayInfo);
                    }

                    //時間行の決定
                    DateTime chkStartTime;
                    DateTime startTime;
                    if (eventInfo.start_time.Hour < setViewInfo.StartTimeWeek)
                    {
                        chkStartTime = new DateTime(2001, 1, 2, eventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 2, eventInfo.start_time.Hour, eventInfo.start_time.Minute, eventInfo.start_time.Second);
                    }
                    else
                    {
                        chkStartTime = new DateTime(2001, 1, 1, eventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 1, eventInfo.start_time.Hour, eventInfo.start_time.Minute, eventInfo.start_time.Second);
                    }
                    DateTime EndTime;
                    if (eventInfo.DurationFlag == 0)
                    {
                        //終了未定
                        EndTime = startTime.AddSeconds(30 * 10);
                    }
                    else
                    {
                        EndTime = startTime.AddSeconds(eventInfo.durationSec);
                    }

                    while (chkStartTime <= EndTime)
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new List<ProgramViewItem>());
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //必要時間のチェック
                if (viewCustNeedTimeOnly == false)
                {
                    //番組のない時間帯を追加
                    DateTime chkStartTime = new DateTime(2001, 1, 1, setViewInfo.StartTimeWeek, 0, 0);
                    DateTime chkEndTime = new DateTime(2001, 1, 2, setViewInfo.StartTimeWeek, 0, 0);
                    while (chkStartTime < chkEndTime)
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new List<ProgramViewItem>());
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //番組の表示位置設定
                foreach (ProgramViewItem item in programList)
                {
                    DateTime chkStartTime;
                    DateTime startTime;
                    DateTime dayInfo;
                    if (item.EventInfo.start_time.Hour < setViewInfo.StartTimeWeek)
                    {
                        chkStartTime = new DateTime(2001, 1, 2, item.EventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 2, item.EventInfo.start_time.Hour, item.EventInfo.start_time.Minute, item.EventInfo.start_time.Second);
                        DateTime tmp = item.EventInfo.start_time.AddDays(-1);
                        dayInfo = new DateTime(tmp.Year, tmp.Month, tmp.Day, 0, 0, 0);
                    }
                    else
                    {
                        chkStartTime = new DateTime(2001, 1, 1, item.EventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 1, item.EventInfo.start_time.Hour, item.EventInfo.start_time.Minute, item.EventInfo.start_time.Second);
                        dayInfo = new DateTime(item.EventInfo.start_time.Year, item.EventInfo.start_time.Month, item.EventInfo.start_time.Day, 0, 0, 0);
                    }
                    if (timeList.ContainsKey(chkStartTime) == true)
                    {
                        int index = timeList.IndexOfKey(chkStartTime);
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                    }
                    if (dayList.ContainsKey(dayInfo) == true)
                    {
                        int index = dayList.IndexOfKey(dayInfo);
                        item.LeftPos = index * Settings.Instance.ServiceWidth;
                    }
                }
                if (Settings.Instance.MinimumHeight > 0)
                {
                    //最低表示行数を適用
                    programList.Sort((x, y) => Math.Sign(x.LeftPos - y.LeftPos) * 2 + Math.Sign(x.TopPos - y.TopPos));
                    double minimum = (Settings.Instance.FontSizeTitle + 2) * Settings.Instance.MinimumHeight;
                    double lastLeft = double.MinValue;
                    double lastBottom = 0;
                    foreach (ProgramViewItem item in programList)
                    {
                        if (lastLeft != item.LeftPos)
                        {
                            lastLeft = item.LeftPos;
                            lastBottom = double.MinValue;
                        }
                        item.Height = Math.Max(item.Height, minimum);
                        if (item.TopPos < lastBottom)
                        {
                            item.Height = Math.Max(item.TopPos + item.Height - lastBottom, minimum);
                            item.TopPos = lastBottom;
                        }
                        lastBottom = item.TopPos + item.Height;
                    }
                }

                //必要時間リストと時間と番組の関連づけ
                foreach (ProgramViewItem item in programList)
                {
                    int index = Math.Max((int)(item.TopPos / (60 * Settings.Instance.MinHeight)), 0);
                    while (index < Math.Min((int)((item.TopPos + item.Height) / (60 * Settings.Instance.MinHeight)) + 1, timeList.Count))
                    {
                        timeList.Values[index++].Add(item);
                    }
                }

                epgProgramView.SetProgramList(
                    programList,
                    timeList,
                    dayList.Count * Settings.Instance.ServiceWidth,
                    timeList.Count * 60 * Settings.Instance.MinHeight);

                List<DateTime> dateTimeList = new List<DateTime>();
                foreach (var item in timeList)
                {
                    dateTimeList.Add(item.Key);
                }
                timeView.SetTime(dateTimeList, viewCustNeedTimeOnly, true);
                weekDayView.SetDay(dayList);

                ReDrawNowLine();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
        private void UpdateProgramView()
        {
            try
            {
                epgProgramView.ClearInfo();
                timeList.Clear();
                programList.Clear();
                nowViewTimer.Stop();
                dayList.Clear();

                if (comboBox_service.Items.Count == 0)
                {
                    return;
                }

                UInt64 selectID = GetSelectID(true);

                //まず日時のチェック
                foreach (EpgEventInfo eventInfo in serviceEventList[selectID].eventList)
                {
                    if (eventInfo.StartTimeFlag == 0)
                    {
                        //開始未定は除外
                        continue;
                    }
                    //ジャンル絞り込み
                    if (ViewUtil.ContainsContent(eventInfo, this.viewCustContentKindList) == false)
                    {
                        continue;
                    }

                    var viewItem = new ProgramViewItem(eventInfo);
                    viewItem.Height    = Settings.Instance.MinHeight * eventInfo.PgDurationSecond / 60;
                    viewItem.HeightDef = viewItem.Height;//元の情報も保存
                    viewItem.Width     = Settings.Instance.ServiceWidth;
                    programList.Add(viewItem);

                    //日付列の決定
                    DateTime dayInfo = GetWeekMainViewTime(eventInfo.start_time, TimeSelect.DayOnly);

                    if (dayList.ContainsKey(dayInfo) == false)
                    {
                        dayList.Add(dayInfo, dayInfo);
                    }

                    //時間行の決定
                    DateTime chkStartTime = GetWeekMainViewTime(eventInfo.start_time, TimeSelect.HourOnly);
                    DateTime startTime    = GetWeekMainViewTime(eventInfo.start_time);

                    while (chkStartTime <= startTime.AddSeconds(eventInfo.PgDurationSecond))
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new List <ProgramViewItem>());
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //必要時間のチェック
                if (viewCustNeedTimeOnly == false)
                {
                    //番組のない時間帯を追加
                    var chkStartTime = new DateTime(2001, 1, 1, setViewInfo.StartTimeWeek, 0, 0);
                    var chkEndTime   = new DateTime(2001, 1, 2, setViewInfo.StartTimeWeek, 0, 0);
                    while (chkStartTime < chkEndTime)
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new List <ProgramViewItem>());
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //番組の表示位置設定
                foreach (ProgramViewItem item in programList)
                {
                    var chkStartTime = GetWeekMainViewTime(item.EventInfo.start_time, TimeSelect.HourOnly);
                    var startTime    = GetWeekMainViewTime(item.EventInfo.start_time);
                    var dayInfo      = GetWeekMainViewTime(item.EventInfo.start_time, TimeSelect.DayOnly);

                    if (timeList.ContainsKey(chkStartTime) == true)
                    {
                        int index = timeList.IndexOfKey(chkStartTime);
                        item.TopPos    = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                        item.TopPosDef = item.TopPos;//元の情報も保存
                    }
                    if (dayList.ContainsKey(dayInfo) == true)
                    {
                        int index = dayList.IndexOfKey(dayInfo);
                        item.LeftPos = index * Settings.Instance.ServiceWidth;
                    }
                }

                //最低表示行数からドット数を計算する。
                // メイリオみたいに行間のあるフォントはフォントの高さをそのまま使う。
                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(
                    programList,
                    dayList.Count * Settings.Instance.ServiceWidth,
                    timeList.Count * 60 * Settings.Instance.MinHeight);

                var dateTimeList = new List <DateTime>();
                foreach (var item in timeList)
                {
                    dateTimeList.Add(item.Key);
                }
                timeView.SetTime(dateTimeList, viewCustNeedTimeOnly, true);
                weekDayView.SetDay(dayList);

                ReDrawNowLine();
                MoveNowTime();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #8
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); }
        }
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        protected override void ReloadReserveViewItem()
        {
            try
            {
                reserveList.Clear();

                if (comboBox_service.Items.Count == 0)
                {
                    return;
                }

                UInt64 selectID = GetSelectID(true);

                foreach (ReserveData info in CommonManager.Instance.DB.ReserveList.Values)
                {
                    if (selectID == info.Create64Key())
                    {
                        //timeListは番組表ベースなので、chkStartTimeはマージン適用前に作成する。
                        DateTime startTime     = GetWeekMainViewTime(info.StartTime);
                        DateTime chkStartTime  = GetWeekMainViewTime(startTime, TimeSelect.HourOnly);
                        DateTime baseStartTime = startTime;

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

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

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

                        DateTime chkDay = GetWeekMainViewTime(info.StartTime, TimeSelect.DayOnly);
                        viewItem.LeftPos = Settings.Instance.ServiceWidth * dayList.IndexOfKey(chkDay);
                        viewItem.Width   = Settings.Instance.ServiceWidth;

                        //最低表示行数の適用の際、最低表示高さを設定しているので、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 - baseStartTime).TotalSeconds / info.DurationSecond;
                            viewItem.Height = Math.Max(pgInfo.Height * duration / info.DurationSecond, ViewUtil.PanelMinimumHeight);
                        }
                        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);
                        }
                    }
                }
                epgProgramView.SetReserveList(reserveList);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
        private void UpdateProgramView()
        {
            try
            {
                epgProgramView.ClearInfo();
                timeList.Clear();
                programList.Clear();
                nowViewTimer.Stop();
                dayList.Clear();

                if (comboBox_service.Items.Count == 0) return;

                UInt64 selectID = GetSelectID(true);

                //まず日時のチェック
                foreach (EpgEventInfo eventInfo in serviceEventList[selectID].eventList)
                {
                    if (eventInfo.StartTimeFlag == 0)
                    {
                        //開始未定は除外
                        continue;
                    }
                    //ジャンル絞り込み
                    if (ViewUtil.ContainsContent(eventInfo, this.viewCustContentKindList) == false)
                    {
                        continue;
                    }

                    var viewItem = new ProgramViewItem(eventInfo);
                    viewItem.Height = Settings.Instance.MinHeight * eventInfo.PgDurationSecond / 60;
                    viewItem.HeightDef = viewItem.Height;//元の情報も保存
                    viewItem.Width = Settings.Instance.ServiceWidth;
                    programList.Add(viewItem);

                    //日付列の決定
                    DateTime dayInfo = GetWeekMainViewTime(eventInfo.start_time, TimeSelect.DayOnly);

                    if (dayList.ContainsKey(dayInfo) == false)
                    {
                        dayList.Add(dayInfo, dayInfo);
                    }

                    //時間行の決定
                    DateTime chkStartTime = GetWeekMainViewTime(eventInfo.start_time, TimeSelect.HourOnly);
                    DateTime startTime = GetWeekMainViewTime(eventInfo.start_time);

                    while (chkStartTime <= startTime.AddSeconds(eventInfo.PgDurationSecond))
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new List<ProgramViewItem>());
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //必要時間のチェック
                if (viewCustNeedTimeOnly == false)
                {
                    //番組のない時間帯を追加
                    var chkStartTime = new DateTime(2001, 1, 1, setViewInfo.StartTimeWeek, 0, 0);
                    var chkEndTime = new DateTime(2001, 1, 2, setViewInfo.StartTimeWeek, 0, 0);
                    while (chkStartTime < chkEndTime)
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new List<ProgramViewItem>());
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //番組の表示位置設定
                foreach (ProgramViewItem item in programList)
                {
                    var chkStartTime = GetWeekMainViewTime(item.EventInfo.start_time, TimeSelect.HourOnly);
                    var startTime = GetWeekMainViewTime(item.EventInfo.start_time);
                    var dayInfo = GetWeekMainViewTime(item.EventInfo.start_time, TimeSelect.DayOnly);

                    if (timeList.ContainsKey(chkStartTime) == true)
                    {
                        int index = timeList.IndexOfKey(chkStartTime);
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                        item.TopPosDef = item.TopPos;//元の情報も保存
                    }
                    if (dayList.ContainsKey(dayInfo) == true)
                    {
                        int index = dayList.IndexOfKey(dayInfo);
                        item.LeftPos = index * Settings.Instance.ServiceWidth;
                    }
                }

                //最低表示行数からドット数を計算する。
                // メイリオみたいに行間のあるフォントはフォントの高さをそのまま使う。
                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(
                    programList,
                    dayList.Count * Settings.Instance.ServiceWidth,
                    timeList.Count * 60 * Settings.Instance.MinHeight);

                var dateTimeList = new List<DateTime>();
                foreach (var item in timeList)
                {
                    dateTimeList.Add(item.Key);
                }
                timeView.SetTime(dateTimeList, viewCustNeedTimeOnly, true);
                weekDayView.SetDay(dayList);

                ReDrawNowLine();
                MoveNowTime();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #11
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 #12
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); }
        }
        private void UpdateProgramView()
        {
            try
            {
                epgProgramView.ClearInfo();
                timeList.Clear();
                dayList.Clear();
                programList.Clear();

                nowViewTimer.Stop();

                if (comboBox_service.Items.Count == 0)
                {
                    return;
                }

                UInt64 selectID = 0;
                if (comboBox_service.SelectedItem != null)
                {
                    ComboBoxItem item = comboBox_service.SelectedItem as ComboBoxItem;
                    EpgServiceInfo serviceInfo = item.DataContext as EpgServiceInfo;
                    selectID = CommonManager.Create64Key(serviceInfo.ONID, serviceInfo.TSID, serviceInfo.SID);
                }
                else
                {
                    ComboBoxItem item = comboBox_service.Items.GetItemAt(0) as ComboBoxItem;
                    EpgServiceInfo serviceInfo = item.DataContext as EpgServiceInfo;
                    selectID = CommonManager.Create64Key(serviceInfo.ONID, serviceInfo.TSID, serviceInfo.SID);
                }

                Dictionary<UInt64, EpgServiceEventInfo> serviceEventList = null;
                if (setViewInfo.SearchMode == true)
                {
                    serviceEventList = searchEventList;
                }
                else
                {
                    serviceEventList = CommonManager.Instance.DB.ServiceEventList;
                }

                //まず日時のチェック
                foreach (EpgEventInfo eventInfo in serviceEventList[selectID].eventList)
                {
                    if (eventInfo.StartTimeFlag == 0)
                    {
                        //開始未定は除外
                        continue;
                    }
                    //ジャンル絞り込み
                    if (this.viewCustContentKindList.Count > 0)
                    {
                        bool find = false;
                        if (eventInfo.ContentInfo != null)
                        {
                            if (eventInfo.ContentInfo.nibbleList.Count > 0)
                            {
                                foreach (EpgContentData contentInfo in eventInfo.ContentInfo.nibbleList)
                                {
                                    UInt16 ID1 = (UInt16)(((UInt16)contentInfo.content_nibble_level_1) << 8 | 0xFF);
                                    UInt16 ID2 = (UInt16)(((UInt16)contentInfo.content_nibble_level_1) << 8 | contentInfo.content_nibble_level_2);
                                    if (this.viewCustContentKindList.ContainsKey(ID1) == true)
                                    {
                                        find = true;
                                        break;
                                    }
                                    else if (this.viewCustContentKindList.ContainsKey(ID2) == true)
                                    {
                                        find = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (find == false)
                        {
                            //ジャンル見つからないので除外
                            continue;
                        }
                    }

                    ProgramViewItem viewItem = new ProgramViewItem(eventInfo);
                    viewItem.Height = (eventInfo.durationSec * Settings.Instance.MinHeight) / 60;
                    viewItem.Width = Settings.Instance.ServiceWidth;
                    programList.Add(viewItem);

                    //日付列の決定
                    DateTime dayInfo;
                    if (eventInfo.start_time.Hour < setViewInfo.StartTimeWeek)
                    {
                        DateTime time = eventInfo.start_time.AddDays(-1);
                        dayInfo = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0);
                    }
                    else
                    {
                        dayInfo = new DateTime(eventInfo.start_time.Year, eventInfo.start_time.Month, eventInfo.start_time.Day, 0, 0, 0);
                    }

                    if (dayList.ContainsKey(dayInfo) == false)
                    {
                        dayList.Add(dayInfo, dayInfo);
                    }

                    //時間行の決定
                    DateTime chkStartTime;
                    DateTime startTime;
                    if (eventInfo.start_time.Hour < setViewInfo.StartTimeWeek)
                    {
                        chkStartTime = new DateTime(2001, 1, 2, eventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 2, eventInfo.start_time.Hour, eventInfo.start_time.Minute, eventInfo.start_time.Second);
                    }
                    else
                    {
                        chkStartTime = new DateTime(2001, 1, 1, eventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 1, eventInfo.start_time.Hour, eventInfo.start_time.Minute, eventInfo.start_time.Second);
                    }
                    DateTime EndTime;
                    if (eventInfo.DurationFlag == 0)
                    {
                        //終了未定
                        EndTime = startTime.AddSeconds(30 * 10);
                    }
                    else
                    {
                        EndTime = startTime.AddSeconds(eventInfo.durationSec);
                    }

                    while (chkStartTime <= EndTime)
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new TimePosInfo(chkStartTime, 0));
                        }
                        TimePosInfo timeInfo = timeList[chkStartTime] as TimePosInfo;
                        timeInfo.ProgramList.Add(viewItem);
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }

                //必要時間のチェック
                if (viewCustNeedTimeOnly == false)
                {
                    //番組のない時間帯を追加
                    DateTime chkStartTime = new DateTime(2001, 1, 1, setViewInfo.StartTimeWeek, 0, 0);
                    DateTime chkEndTime = new DateTime(2001, 1, 2, setViewInfo.StartTimeWeek, 0, 0);
                    while (chkStartTime < chkEndTime)
                    {
                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            timeList.Add(chkStartTime, new TimePosInfo(chkStartTime, 0));
                        }
                        chkStartTime = chkStartTime.AddHours(1);
                    }
                }
                //時間軸の表示位置決定
                double topPos = 0;
                foreach (TimePosInfo time in timeList.Values)
                {
                    time.TopPos = topPos;
                    topPos += 60 * Settings.Instance.MinHeight;
                }

                //番組の表示位置設定
                foreach (ProgramViewItem item in programList)
                {
                    DateTime chkStartTime;
                    DateTime startTime;
                    DateTime dayInfo;
                    if (item.EventInfo.start_time.Hour < setViewInfo.StartTimeWeek)
                    {
                        chkStartTime = new DateTime(2001, 1, 2, item.EventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 2, item.EventInfo.start_time.Hour, item.EventInfo.start_time.Minute, item.EventInfo.start_time.Second);
                        DateTime tmp = item.EventInfo.start_time.AddDays(-1);
                        dayInfo = new DateTime(tmp.Year, tmp.Month, tmp.Day, 0, 0, 0);
                    }
                    else
                    {
                        chkStartTime = new DateTime(2001, 1, 1, item.EventInfo.start_time.Hour, 0, 0);
                        startTime = new DateTime(2001, 1, 1, item.EventInfo.start_time.Hour, item.EventInfo.start_time.Minute, item.EventInfo.start_time.Second);
                        dayInfo = new DateTime(item.EventInfo.start_time.Year, item.EventInfo.start_time.Month, item.EventInfo.start_time.Day, 0, 0, 0);
                    }
                    if (timeList.ContainsKey(chkStartTime) == true)
                    {
                        int index = timeList.IndexOfKey(chkStartTime);
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                    }
                    if (dayList.ContainsKey(dayInfo) == true)
                    {
                        int index = dayList.IndexOfKey(dayInfo);
                        item.LeftPos = index * Settings.Instance.ServiceWidth;
                    }
                }
                epgProgramView.SetProgramList(
                    programList,
                    dayList.Count * Settings.Instance.ServiceWidth,
                    timeList.Count * 60 * Settings.Instance.MinHeight);

                timeView.SetTime(timeList, viewCustNeedTimeOnly, true);
                weekDayView.SetDay(dayList);

                ReDrawNowLine();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }