private bool reloadEventList(List <SearchItem> dataList) { //絞り込んだイベントリストを作成 var eventList = new List <EpgEventInfo>(); foreach (ServiceItem info in serviceList) { if (info.IsSelected == true) { if (serviceEventList.ContainsKey(info.ID) == true) { foreach (EpgEventInfo eventInfo in serviceEventList[info.ID].eventList) { //ジャンル絞り込み if (ViewUtil.ContainsContent(eventInfo, this.viewCustContentKindList) == false) { continue; } //イベントグループのチェック if (eventInfo.EventGroupInfo != null) { bool spanFlag = false; foreach (EpgEventData data in eventInfo.EventGroupInfo.eventDataList) { if (info.ServiceInfo.Create64Key() == data.Create64Key()) { spanFlag = true; break; } } if (spanFlag == false) { //サービス2やサービス3の結合されるべきもの continue; } } eventList.Add(eventInfo); } } } } //SearchItemリストを作成 lstCtrl.dataList.AddFromEventList(eventList, true, setViewInfo.FilterEnded); return(true); }
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); } }
/// <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); } }