Esempio n. 1
0
        //パネル系画面の移動用
        public static object MoveNextReserve(ref int itemIdx, PanelViewBase view, IEnumerable <ReserveViewItem> reslist, ref Point jmpPos,
                                             UInt64 id, int direction, bool move = true, JumpItemStyle style = JumpItemStyle.MoveTo)
        {
            Point pos = jmpPos;

            jmpPos = new Point(-1, -1);
            if (reslist.Any() == false)
            {
                return(null);
            }

            List <ReserveViewItem> list     = reslist.OrderBy(d => d.Data.StartTimeActual).ToList();
            ReserveViewItem        viewItem = null;
            int idx = id == 0 ? -1 : list.FindIndex(item => item.Data.ReserveID == id);

            if (idx == -1 && pos.X >= 0)
            {
                viewItem = list.GetNearDataList(pos).First();
                idx      = list.IndexOf(viewItem);
            }
            else
            {
                idx      = ViewUtil.GetNextIdx(itemIdx, idx, list.Count, direction);
                viewItem = list[idx];
            }
            if (move == true)
            {
                view.ScrollToFindItem(viewItem, style);
            }
            if (move == true)
            {
                itemIdx = idx;
            }
            return(viewItem == null ? null : viewItem.Data);
        }
        protected void MoveToReserveItem(ReserveData target, bool IsMarking)
        {
            uint            ID          = target.ReserveID;
            ReserveViewItem target_item = this.reserveList.Find(item => item.ReserveInfo.ReserveID == ID);

            this.tunerReserveView.ScrollToFindItem(target_item, IsMarking);
        }
Esempio n. 3
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); }
        }
Esempio n. 4
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); }
        }
Esempio n. 5
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); }
        }
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            try
            {
                tunerReserveView.ClearInfo();
                tunerReserveTimeView.ClearInfo();
                tunerReserveNameView.ClearInfo();
                List <DateTime> timeList = new List <DateTime>();
                tunerList.Clear();
                reserveList.Clear();

                List <TunerReserveInfo> tunerReserveList = CommonManager.Instance.DB.TunerReserveList.Values
                                                           .OrderBy(info => info.tunerID).ToList();//多分大丈夫だけど一応ソートしておく
                if (Settings.Instance.TunerDisplayOffReserve == true)
                {
                    var tuner_off = new TunerReserveInfo();
                    tuner_off.tunerID     = 0xFFFFFFFF;//IDの表示判定に使っている
                    tuner_off.tunerName   = "無効予約";
                    tuner_off.reserveList = CommonManager.Instance.DB.ReserveList.Values
                                            .Where(info => info.IsEnabled == false).Select(info => info.ReserveID).ToList();
                    tunerReserveList.Add(tuner_off);
                }

                //チューナ不足と無効予約はアイテムがなければ非表示
                var delList = tunerReserveList.Where(item => item.tunerID == 0xFFFFFFFF && item.reserveList.Count == 0).ToList();
                delList.ForEach(item => tunerReserveList.Remove(item));

                double tunerWidthSingle = Settings.Instance.TunerWidth;
                double leftPos          = 0;
                tunerReserveList.ForEach(info =>
                {
                    double tunerWidth = tunerWidthSingle;

                    var tunerAddList = new List <ReserveViewItem>();
                    foreach (UInt32 reserveID in info.reserveList)
                    {
                        ReserveData reserveInfo;
                        if (CommonManager.Instance.DB.ReserveList.TryGetValue(reserveID, out reserveInfo) == false)
                        {
                            continue;
                        }
                        var newItem = new ReserveViewItem(reserveInfo);

                        //マージンを適用
                        DateTime startTime = reserveInfo.StartTime;
                        Int32 duration     = (Int32)reserveInfo.DurationSecond;
                        ViewUtil.ApplyMarginForTunerPanelView(reserveInfo, ref startTime, ref duration);

                        newItem.Height  = duration * Settings.Instance.TunerMinHeight / 60;
                        newItem.Width   = tunerWidthSingle;
                        newItem.LeftPos = leftPos;

                        foreach (ReserveViewItem addedItem in tunerAddList)
                        {
                            ReserveData addedInfo = addedItem.ReserveInfo;

                            //マージンを適用
                            DateTime startTimeAdd = addedInfo.StartTime;
                            Int32 durationAdd     = (Int32)addedInfo.DurationSecond;
                            ViewUtil.ApplyMarginForTunerPanelView(addedInfo, ref startTimeAdd, ref durationAdd);

                            if (MenuUtil.CulcOverlapLength(startTime, (UInt32)duration, startTimeAdd, (UInt32)durationAdd) > 0)
                            {
                                if (newItem.LeftPos <= addedItem.LeftPos)
                                {
                                    if (reserveInfo.Create64Key() == addedInfo.Create64Key())
                                    {
                                        newItem.LeftPos = addedItem.LeftPos;
                                    }
                                    else
                                    {
                                        newItem.LeftPos = addedItem.LeftPos + tunerWidthSingle;
                                        if (newItem.LeftPos - leftPos >= tunerWidth)
                                        {
                                            tunerWidth += tunerWidthSingle;
                                        }
                                    }
                                }
                            }
                        }

                        reserveList.Add(newItem);
                        tunerAddList.Add(newItem);

                        //必要時間リストの構築
                        var chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                        DateTime EndTime = startTime.AddSeconds(duration);
                        while (chkStartTime <= EndTime)
                        {
                            int index = timeList.BinarySearch(chkStartTime);
                            if (index < 0)
                            {
                                timeList.Insert(~index, chkStartTime);
                            }
                            chkStartTime = chkStartTime.AddHours(1);
                        }
                    }

                    tunerList.Add(new TunerNameViewItem(info, tunerWidth));
                    leftPos += tunerWidth;
                });

                //表示位置設定
                foreach (ReserveViewItem item in reserveList)
                {
                    //マージンを適用
                    DateTime startTime = item.ReserveInfo.StartTime;
                    Int32    dummy     = 0;
                    ViewUtil.ApplyMarginForTunerPanelView(item.ReserveInfo, ref startTime, ref dummy);

                    var chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                    int index        = timeList.BinarySearch(chkStartTime);
                    if (index >= 0)
                    {
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.TunerMinHeight;
                    }
                }

                //ごく小さいマージンの表示を抑制する。
                reserveList.ForEach(info =>
                {
                    info.TopPos = Math.Round(info.TopPos);
                    info.Height = Math.Round(info.Height);
                });

                //最低表示行数からドット数を計算する。
                // メイリオみたいに行間のあるフォントはフォントの高さをそのまま使う。
                double fontHeight = Math.Max(Settings.Instance.TunerFontHeight, Settings.Instance.TunerFontHeightService);
                // MS P ゴシックみたいな行間のないフォントは 2px あける。
                double fontSize = Math.Max(Settings.Instance.TunerFontSize, Settings.Instance.TunerFontSizeService) + 2;
                // 大きい方をフォントの高さとして採用し、最低表示px数を計算する。
                double lineHeight = Settings.Instance.TunerMinimumLine * Math.Max(fontHeight, fontSize);
                if (Settings.Instance.TunerMinimumLine >= 2)
                {
                    lineHeight += 2;                                                                        // 番組名との間隔は 2px にする
                }
                ViewUtil.ModifierMinimumHeight <ReserveData, ReserveViewItem>(reserveList, lineHeight + 2); //2ドットは枠の分

                //必要時間リストの修正。最低表示行数の適用で下に溢れた分を追加する。
                if (reserveList.Count != 0 && timeList.Count > 0)
                {
                    double bottom = reserveList.Max(info => info.TopPos + info.Height);
                    int    end    = (int)(bottom / (60 * Settings.Instance.TunerMinHeight)) + 1;
                    while (end > timeList.Count)
                    {
                        DateTime time_tail = timeList[timeList.Count - 1].AddHours(1);
                        timeList.Add(time_tail);
                    }
                }

                tunerReserveTimeView.SetTime(timeList);
                tunerReserveNameView.SetTunerInfo(tunerList);
                tunerReserveView.SetReserveList(reserveList,
                                                leftPos,
                                                timeList.Count * 60 * Settings.Instance.TunerMinHeight);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Esempio n. 7
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private 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;
                            vutil.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.EventID != 0xFFFF && 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);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            reserveList.Clear();
            reserveList = null;
            reserveList = new List<ReserveViewItem>();
            try
            {
                //TODO: ここでデフォルトマージンを確認するがEpgTimerNWでは無意味。根本的にはSendCtrlCmdの拡張が必要
                int defStartMargin = IniFileHandler.GetPrivateProfileInt("SET", "StartMargin", 0, SettingPath.TimerSrvIniPath);
                int defEndMargin = IniFileHandler.GetPrivateProfileInt("SET", "EndMargin", 0, SettingPath.TimerSrvIniPath);

                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++;
                            }
                            EpgServiceInfo srvInfo = serviceList[mergePos];
                            if (srvInfo.ONID == info.OriginalNetworkID &&
                                srvInfo.TSID == info.TransportStreamID &&
                                srvInfo.SID == info.ServiceID)
                            {
                                ReserveViewItem viewItem = new ReserveViewItem(info);
                                viewItem.LeftPos = Settings.Instance.ServiceWidth * (servicePos + (double)((mergeNum + i - mergePos - 1) / 2) / mergeNum);

                                Int32 duration = (Int32)info.DurationSecond;
                                DateTime startTime = info.StartTime;
                                if (info.RecSetting.UseMargineFlag == 1)
                                {
                                    if (info.RecSetting.StartMargine < 0)
                                    {
                                        startTime = info.StartTime.AddSeconds(info.RecSetting.StartMargine * -1);
                                        duration += info.RecSetting.StartMargine;
                                    }
                                    if (info.RecSetting.EndMargine < 0)
                                    {
                                        duration += info.RecSetting.EndMargine;
                                    }
                                }
                                else
                                {
                                    if (defStartMargin < 0)
                                    {
                                        startTime = info.StartTime.AddSeconds(defStartMargin * -1);
                                        duration += defStartMargin;
                                    }
                                    if (defEndMargin < 0)
                                    {
                                        duration += defEndMargin;
                                    }
                                }
                                //if ((duration/60) < Settings.Instance.MinHeight)
                                //{
                                //    duration = (int)Settings.Instance.MinHeight;
                                //}

                                //TimePosInfo topTime = timeList.GetByIndex(0) as TimePosInfo;
                                //viewItem.TopPos = Math.Floor((startTime - topTime.Time).TotalMinutes * Settings.Instance.MinHeight);

                                viewItem.Height = Math.Floor((duration / 60) * Settings.Instance.MinHeight);
                                if (viewItem.Height < Settings.Instance.MinHeight)
                                {
                                    viewItem.Height = Settings.Instance.MinHeight;
                                }
                                viewItem.Width = Settings.Instance.ServiceWidth / mergeNum;

                                reserveList.Add(viewItem);
                                DateTime chkTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                                if (timeList.ContainsKey(chkTime) == true)
                                {
                                    bool modified = false;
                                    if (Settings.Instance.MinimumHeight > 0 && viewItem.ReserveInfo.EventID != 0xFFFF)
                                    {
                                        //予約情報から番組情報を特定し、枠表示位置を再設定する
                                        foreach (ProgramViewItem pgInfo in timeList[chkTime])
                                        {
                                            if (viewItem.ReserveInfo.OriginalNetworkID == pgInfo.EventInfo.original_network_id &&
                                                viewItem.ReserveInfo.TransportStreamID == pgInfo.EventInfo.transport_stream_id &&
                                                viewItem.ReserveInfo.ServiceID == pgInfo.EventInfo.service_id &&
                                                viewItem.ReserveInfo.EventID == pgInfo.EventInfo.event_id &&
                                                info.DurationSecond != 0)
                                            {
                                                viewItem.TopPos = pgInfo.TopPos + pgInfo.Height * (startTime - info.StartTime).TotalSeconds / info.DurationSecond;
                                                viewItem.Width = pgInfo.Width;
                                                viewItem.Height = Math.Max(pgInfo.Height * duration / info.DurationSecond, Settings.Instance.MinHeight);
                                                modified = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (modified == false)
                                    {
                                        int index = timeList.IndexOfKey(chkTime);
                                        viewItem.TopPos = index * 60 * Settings.Instance.MinHeight;
                                        viewItem.TopPos += Math.Floor((startTime - chkTime).TotalMinutes * Settings.Instance.MinHeight);
                                        foreach (ProgramViewItem pgInfo in timeList.Values[index])
                                        {
                                            if (pgInfo.LeftPos == viewItem.LeftPos && pgInfo.TopPos <= viewItem.TopPos && viewItem.TopPos < pgInfo.TopPos + pgInfo.Height)
                                            {
                                                viewItem.Width = pgInfo.Width;
                                                break;
                                            }
                                        }
                                    }
                                }

                                break;
                            }
                        }
                    }
                }
                epgProgramView.SetReserveList(reserveList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            reserveList.Clear();
            try
            {
                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);
                }

                //TODO: ここでデフォルトマージンを確認するがEpgTimerNWでは無意味。根本的にはSendCtrlCmdの拡張が必要
                int defStartMargin = IniFileHandler.GetPrivateProfileInt("SET", "StartMargin", 0, SettingPath.TimerSrvIniPath);
                int defEndMargin = IniFileHandler.GetPrivateProfileInt("SET", "EndMargin", 0, SettingPath.TimerSrvIniPath);

                foreach (ReserveData info in CommonManager.Instance.DB.ReserveList.Values)
                {
                    UInt64 key = CommonManager.Create64Key(info.OriginalNetworkID, info.TransportStreamID, info.ServiceID);
                    if (selectID == key)
                    {
                        DateTime chkStartTime;
                        DateTime startTime;
                        if (info.StartTime.Hour < setViewInfo.StartTimeWeek)
                        {
                            chkStartTime = new DateTime(2001, 1, 2, info.StartTime.Hour, 0, 0);
                            startTime = new DateTime(2001, 1, 2, info.StartTime.Hour, info.StartTime.Minute, info.StartTime.Second);
                        }
                        else
                        {
                            chkStartTime = new DateTime(2001, 1, 1, info.StartTime.Hour, 0, 0);
                            startTime = new DateTime(2001, 1, 1, info.StartTime.Hour, info.StartTime.Minute, info.StartTime.Second);
                        }
                        DateTime baseStartTime = startTime;
                        Int32 duration = (Int32)info.DurationSecond;
                        if (info.RecSetting.UseMargineFlag == 1)
                        {
                            if (info.RecSetting.StartMargine < 0)
                            {
                                startTime = startTime.AddSeconds(info.RecSetting.StartMargine * -1);
                                duration += info.RecSetting.StartMargine;
                            }
                            if (info.RecSetting.EndMargine < 0)
                            {
                                duration += info.RecSetting.EndMargine;
                            }
                        }
                        else
                        {
                            if (defStartMargin < 0)
                            {
                                startTime = startTime.AddSeconds(defStartMargin * -1);
                                duration += defStartMargin;
                            }
                            if (defEndMargin < 0)
                            {
                                duration += defEndMargin;
                            }
                        }
                        DateTime EndTime;
                        EndTime = startTime.AddSeconds(duration);
                        //if ((duration / 60) < Settings.Instance.MinHeight)
                        //{
                        //    duration = (int)Settings.Instance.MinHeight;
                        //}

                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            //時間ないので除外
                            continue;
                        }
                        ReserveViewItem viewItem = new ReserveViewItem(info);
                        //viewItem.LeftPos = i * Settings.Instance.ServiceWidth;

                        viewItem.Height = Math.Floor((duration / 60) * Settings.Instance.MinHeight);
                        if (viewItem.Height < Settings.Instance.MinHeight)
                        {
                            viewItem.Height = Settings.Instance.MinHeight;
                        }
                        viewItem.Width = Settings.Instance.ServiceWidth;

                        bool modified = false;
                        if (Settings.Instance.MinimumHeight > 0 && viewItem.ReserveInfo.EventID != 0xFFFF)
                        {
                            //予約情報から番組情報を特定し、枠表示位置を再設定する
                            foreach (ProgramViewItem pgInfo in timeList[chkStartTime])
                            {
                                if (viewItem.ReserveInfo.OriginalNetworkID == pgInfo.EventInfo.original_network_id &&
                                    viewItem.ReserveInfo.TransportStreamID == pgInfo.EventInfo.transport_stream_id &&
                                    viewItem.ReserveInfo.ServiceID == pgInfo.EventInfo.service_id &&
                                    viewItem.ReserveInfo.EventID == pgInfo.EventInfo.event_id &&
                                    info.DurationSecond != 0)
                                {
                                    viewItem.TopPos = pgInfo.TopPos + pgInfo.Height * (startTime - baseStartTime).TotalSeconds / info.DurationSecond;
                                    viewItem.Height = Math.Max(pgInfo.Height * duration / info.DurationSecond, Settings.Instance.MinHeight);
                                    modified = true;
                                    break;
                                }
                            }
                        }
                        if (modified == false)
                        {
                            int index = timeList.IndexOfKey(chkStartTime);
                            viewItem.TopPos = index * 60 * Settings.Instance.MinHeight;
                            viewItem.TopPos += Math.Floor((startTime - chkStartTime).TotalMinutes * Settings.Instance.MinHeight);
                        }

                        DateTime chkDay;
                        if (info.StartTime.Hour < setViewInfo.StartTimeWeek)
                        {
                            chkDay = info.StartTime.AddDays(-1);
                            chkDay = new DateTime(chkDay.Year, chkDay.Month, chkDay.Day, 0, 0, 0);
                        }
                        else
                        {
                            chkDay = new DateTime(info.StartTime.Year, info.StartTime.Month, info.StartTime.Day, 0, 0, 0);
                        }
                        viewItem.LeftPos = Settings.Instance.ServiceWidth * dayList.IndexOfKey(chkDay);

                        reserveList.Add(viewItem);
                    }
                }
                epgProgramView.SetReserveList(reserveList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 10
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); }
        }
Esempio n. 11
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            tunerReserveView.ClearInfo();
            tunerReserveTimeView.ClearInfo();
            tunerReserveNameView.ClearInfo();
            var timeList  = new List <DateTime>();
            var tunerList = new List <TunerNameViewItem>();

            reserveList.Clear();
            try
            {
                double leftPos = 0;
                foreach (TunerReserveInfo info in CommonManager.Instance.DB.TunerReserveList.Values)
                {
                    double width     = 150;
                    int    addOffset = reserveList.Count();
                    foreach (uint reserveID in info.reserveList)
                    {
                        ReserveData reserveInfo;
                        if (CommonManager.Instance.DB.ReserveList.TryGetValue(reserveID, out reserveInfo) == false)
                        {
                            continue;
                        }

                        DateTime startTime = reserveInfo.StartTime;
                        DateTime endTime   = startTime.AddSeconds(reserveInfo.DurationSecond);
                        if (reserveInfo.RecSetting.UseMargineFlag == 1)
                        {
                            if (reserveInfo.RecSetting.StartMargine < 0)
                            {
                                startTime = startTime.AddSeconds(-reserveInfo.RecSetting.StartMargine);
                            }
                            if (reserveInfo.RecSetting.EndMargine < 0)
                            {
                                endTime = endTime.AddSeconds(reserveInfo.RecSetting.EndMargine);
                            }
                        }

                        var viewItem = new ReserveViewItem(reserveInfo);
                        viewItem.Height = Math.Floor((endTime - startTime).TotalMinutes * Settings.Instance.EpgSettingList[0].MinHeight);
                        if (viewItem.Height < Settings.Instance.EpgSettingList[0].MinHeight)
                        {
                            viewItem.Height = Settings.Instance.EpgSettingList[0].MinHeight;
                        }
                        viewItem.Width   = 150;
                        viewItem.LeftPos = leftPos;

                        for (int i = addOffset; i < reserveList.Count; i++)
                        {
                            ReserveData addInfo      = reserveList[i].ReserveInfo;
                            DateTime    startTimeAdd = addInfo.StartTime;
                            DateTime    endTimeAdd   = startTimeAdd.AddSeconds(addInfo.DurationSecond);
                            if (addInfo.RecSetting.UseMargineFlag == 1)
                            {
                                if (addInfo.RecSetting.StartMargine < 0)
                                {
                                    startTimeAdd = startTimeAdd.AddSeconds(-addInfo.RecSetting.StartMargine);
                                }
                                if (addInfo.RecSetting.EndMargine < 0)
                                {
                                    endTimeAdd = endTimeAdd.AddSeconds(addInfo.RecSetting.EndMargine);
                                }
                            }

                            if ((startTimeAdd <= startTime && startTime < endTimeAdd) ||
                                (startTimeAdd < endTime && endTime <= endTimeAdd) ||
                                (startTime <= startTimeAdd && startTimeAdd < endTime) ||
                                (startTime < endTimeAdd && endTimeAdd <= endTime)
                                )
                            {
                                if (reserveList[i].LeftPos == viewItem.LeftPos)
                                {
                                    //追加済みのものと重なるので移動して再チェック
                                    i = addOffset - 1;
                                    viewItem.LeftPos += 150;
                                    width             = Math.Max(width, viewItem.LeftPos + viewItem.Width - leftPos);
                                }
                            }
                        }

                        reserveList.Add(viewItem);

                        //必要時間リストの構築

                        DateTime chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                        while (chkStartTime <= endTime)
                        {
                            int index = timeList.BinarySearch(chkStartTime);
                            if (index < 0)
                            {
                                timeList.Insert(~index, chkStartTime);
                            }
                            chkStartTime = chkStartTime.AddHours(1);
                        }
                    }
                    tunerList.Add(new TunerNameViewItem(info, width));
                    leftPos += width;
                }

                //表示位置設定
                foreach (ReserveViewItem item in reserveList)
                {
                    DateTime startTime = item.ReserveInfo.StartTime;
                    if (item.ReserveInfo.RecSetting.UseMargineFlag == 1)
                    {
                        if (item.ReserveInfo.RecSetting.StartMargine < 0)
                        {
                            startTime = startTime.AddSeconds(-item.ReserveInfo.RecSetting.StartMargine);
                        }
                    }

                    DateTime chkStartTime = new DateTime(startTime.Year,
                                                         startTime.Month,
                                                         startTime.Day,
                                                         startTime.Hour,
                                                         0,
                                                         0);
                    int index = timeList.BinarySearch(chkStartTime);
                    if (index >= 0)
                    {
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.EpgSettingList[0].MinHeight;
                    }
                }

                tunerReserveTimeView.SetTime(timeList, true);
                tunerReserveNameView.SetTunerInfo(tunerList);
                tunerReserveView.SetReserveList(reserveList,
                                                leftPos,
                                                timeList.Count * 60 * Settings.Instance.EpgSettingList[0].MinHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            tunerReserveView.ClearInfo();
            tunerReserveTimeView.ClearInfo();
            tunerReserveNameView.ClearInfo();
            timeList.Clear();
            tunerList.Clear();
            reserveList.Clear();
            try
            {
                double leftPos = 0;
                for (int i = 0; i < CommonManager.Instance.DB.TunerReserveList.Count; i++)
                {
                    double            width     = 150;
                    TunerReserveInfo  info      = CommonManager.Instance.DB.TunerReserveList.Values.ElementAt(i);
                    TunerNameViewItem tunerInfo = new TunerNameViewItem(info, width);
                    tunerList.Add(tunerInfo);

                    List <ReserveViewItem> tunerAddList = new List <ReserveViewItem>();
                    for (int j = 0; j < info.reserveList.Count; j++)
                    {
                        UInt32 reserveID = (UInt32)info.reserveList[j];
                        if (CommonManager.Instance.DB.ReserveList.ContainsKey(reserveID) == false)
                        {
                            continue;
                        }
                        ReserveData     reserveInfo = CommonManager.Instance.DB.ReserveList[reserveID];
                        ReserveViewItem viewItem    = new ReserveViewItem(CommonManager.Instance.DB.ReserveList[reserveID]);

                        Int32    duration  = (Int32)reserveInfo.DurationSecond;
                        DateTime startTime = reserveInfo.StartTime;
                        if (reserveInfo.RecSetting.UseMargineFlag == 1)
                        {
                            if (reserveInfo.RecSetting.StartMargine < 0)
                            {
                                startTime = reserveInfo.StartTime.AddSeconds(reserveInfo.RecSetting.StartMargine * -1);
                                duration += reserveInfo.RecSetting.StartMargine;
                            }
                            if (reserveInfo.RecSetting.EndMargine < 0)
                            {
                                duration += reserveInfo.RecSetting.EndMargine;
                            }
                        }
                        DateTime EndTime;
                        EndTime = startTime.AddSeconds(duration);
                        //if ((duration / 60) < Settings.Instance.MinHeight)
                        //{
                        //    duration = (int)Settings.Instance.MinHeight;
                        //}

                        viewItem.Height = Math.Floor((duration / 60) * Settings.Instance.MinHeight);
                        if (viewItem.Height < Settings.Instance.MinHeight)
                        {
                            viewItem.Height = Settings.Instance.MinHeight;
                        }
                        viewItem.Width   = 150;
                        viewItem.LeftPos = leftPos;

                        foreach (ReserveViewItem addItem in tunerAddList)
                        {
                            ReserveData addInfo      = addItem.ReserveInfo;
                            Int32       durationAdd  = (Int32)addInfo.DurationSecond;
                            DateTime    startTimeAdd = addInfo.StartTime;
                            if (addInfo.RecSetting.UseMargineFlag == 1)
                            {
                                if (addInfo.RecSetting.StartMargine < 0)
                                {
                                    startTimeAdd = addInfo.StartTime.AddSeconds(addInfo.RecSetting.StartMargine * -1);
                                    durationAdd += addInfo.RecSetting.StartMargine;
                                }
                                if (addInfo.RecSetting.EndMargine < 0)
                                {
                                    durationAdd += addInfo.RecSetting.EndMargine;
                                }
                            }
                            DateTime endTimeAdd;
                            endTimeAdd = startTimeAdd.AddSeconds(durationAdd);

                            if ((startTimeAdd <= startTime && startTime < endTimeAdd) ||
                                (startTimeAdd < EndTime && EndTime <= endTimeAdd) ||
                                (startTime <= startTimeAdd && startTimeAdd < EndTime) ||
                                (startTime < endTimeAdd && endTimeAdd <= EndTime)
                                )
                            {
                                if (addItem.LeftPos >= viewItem.LeftPos)
                                {
                                    viewItem.LeftPos += 150;
                                    if (viewItem.LeftPos - leftPos >= width)
                                    {
                                        width += 150;
                                    }
                                }
                            }
                        }

                        reserveList.Add(viewItem);
                        tunerAddList.Add(viewItem);

                        //必要時間リストと時間と番組の関連づけ

                        DateTime chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                        while (chkStartTime <= EndTime)
                        {
                            if (timeList.ContainsKey(chkStartTime) == false)
                            {
                                timeList.Add(chkStartTime, new TimePosInfo(chkStartTime, 0));
                            }
                            TimePosInfo timeInfo = timeList[chkStartTime];
                            timeInfo.ReserveList.Add(viewItem);
                            chkStartTime = chkStartTime.AddHours(1);
                        }
                    }
                    tunerInfo.Width = width;
                    leftPos        += width;
                }

                //表示位置設定
                foreach (ReserveViewItem item in reserveList)
                {
                    DateTime startTime = item.ReserveInfo.StartTime;
                    if (item.ReserveInfo.RecSetting.UseMargineFlag == 1)
                    {
                        if (item.ReserveInfo.RecSetting.StartMargine < 0)
                        {
                            startTime = item.ReserveInfo.StartTime.AddSeconds(item.ReserveInfo.RecSetting.StartMargine * -1);
                        }
                    }

                    DateTime chkStartTime = new DateTime(startTime.Year,
                                                         startTime.Month,
                                                         startTime.Day,
                                                         startTime.Hour,
                                                         0,
                                                         0);
                    if (timeList.ContainsKey(chkStartTime) == true)
                    {
                        int index = timeList.IndexOfKey(chkStartTime);
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                    }
                }

                double topPos = 0;
                foreach (TimePosInfo time in timeList.Values)
                {
                    time.TopPos = topPos;
                    topPos     += 60 * Settings.Instance.MinHeight;
                }

                tunerReserveTimeView.SetTime(timeList, true);
                tunerReserveNameView.SetTunerInfo(tunerList);
                tunerReserveView.SetReserveList(reserveList,
                                                leftPos,
                                                timeList.Count * 60 * Settings.Instance.MinHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 13
0
        /// <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); }
        }
Esempio n. 14
0
        /// <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); }
        }
Esempio n. 15
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            tunerReserveView.ClearInfo();
            tunerReserveTimeView.ClearInfo();
            tunerReserveNameView.ClearInfo();
            timeList.Clear();
            tunerList.Clear();
            reserveList.Clear();
            try
            {
                double leftPos = 0;
                for (int i = 0; i < CommonManager.Instance.DB.TunerReserveList.Count; i++)
                {
                    double width = 150;
                    TunerReserveInfo info = CommonManager.Instance.DB.TunerReserveList.Values.ElementAt(i);
                    TunerNameViewItem tunerInfo = new TunerNameViewItem(info, width);
                    tunerList.Add(tunerInfo);

                    List<ReserveViewItem> tunerAddList = new List<ReserveViewItem>();
                    for (int j = 0; j < info.reserveList.Count; j++ )
                    {
                        UInt32 reserveID = (UInt32)info.reserveList[j];
                        if (CommonManager.Instance.DB.ReserveList.ContainsKey(reserveID) == false)
                        {
                            continue;
                        }
                        ReserveData reserveInfo = CommonManager.Instance.DB.ReserveList[reserveID];
                        ReserveViewItem viewItem = new ReserveViewItem(CommonManager.Instance.DB.ReserveList[reserveID]);

                        Int32 duration = (Int32)reserveInfo.DurationSecond;
                        DateTime startTime = reserveInfo.StartTime;
                        if (reserveInfo.RecSetting.UseMargineFlag == 1)
                        {
                            if (reserveInfo.RecSetting.StartMargine < 0)
                            {
                                startTime = reserveInfo.StartTime.AddSeconds(reserveInfo.RecSetting.StartMargine*-1);
                                duration += reserveInfo.RecSetting.StartMargine;
                            }
                            if (reserveInfo.RecSetting.EndMargine < 0)
                            {
                                duration += reserveInfo.RecSetting.EndMargine;
                            }
                        }
                        DateTime EndTime;
                        EndTime = startTime.AddSeconds(duration);
                        //if ((duration / 60) < Settings.Instance.MinHeight)
                        //{
                        //    duration = (int)Settings.Instance.MinHeight;
                        //}

                        viewItem.Height = Math.Floor((duration / 60) * Settings.Instance.MinHeight);
                        if (viewItem.Height == 0)
                        {
                            viewItem.Height = Settings.Instance.MinHeight;
                        }
                        viewItem.Width = 150;
                        viewItem.LeftPos = leftPos;

                        foreach (ReserveViewItem addItem in tunerAddList)
                        {
                            ReserveData addInfo = addItem.ReserveInfo;
                            Int32 durationAdd = (Int32)addInfo.DurationSecond;
                            DateTime startTimeAdd = addInfo.StartTime;
                            if (addInfo.RecSetting.UseMargineFlag == 1)
                            {
                                if (addInfo.RecSetting.StartMargine < 0)
                                {
                                    startTimeAdd = addInfo.StartTime.AddSeconds(addInfo.RecSetting.StartMargine*-1);
                                    durationAdd += addInfo.RecSetting.StartMargine;
                                }
                                if (addInfo.RecSetting.EndMargine < 0)
                                {
                                    durationAdd += addInfo.RecSetting.EndMargine;
                                }
                            }
                            DateTime endTimeAdd;
                            endTimeAdd = startTimeAdd.AddSeconds(durationAdd);

                            if ((startTimeAdd <= startTime && startTime < endTimeAdd) ||
                                (startTimeAdd < EndTime && EndTime <= endTimeAdd) ||
                                (startTime <= startTimeAdd && startTimeAdd < EndTime) ||
                                (startTime < endTimeAdd && endTimeAdd <= EndTime)
                                )
                            {
                                if (addItem.LeftPos >= viewItem.LeftPos)
                                {
                                    viewItem.LeftPos += 150;
                                    if (viewItem.LeftPos - leftPos >= width)
                                    {
                                        width += 150;
                                    }
                                }
                            }
                        }

                        reserveList.Add(viewItem);
                        tunerAddList.Add(viewItem);

                        //必要時間リストと時間と番組の関連づけ

                        DateTime chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                        while (chkStartTime <= EndTime)
                        {
                            if (timeList.ContainsKey(chkStartTime) == false)
                            {
                                timeList.Add(chkStartTime, new TimePosInfo(chkStartTime, 0));
                            }
                            TimePosInfo timeInfo = timeList[chkStartTime] as TimePosInfo;
                            timeInfo.ReserveList.Add(viewItem);
                            chkStartTime = chkStartTime.AddHours(1);
                        }

                    }
                    tunerInfo.Width = width;
                    leftPos += width;
                }

                //表示位置設定
                foreach (ReserveViewItem item in reserveList)
                {
                    DateTime startTime = item.ReserveInfo.StartTime;
                    if (item.ReserveInfo.RecSetting.UseMargineFlag == 1)
                    {
                        if (item.ReserveInfo.RecSetting.StartMargine < 0)
                        {
                            startTime = item.ReserveInfo.StartTime.AddSeconds(item.ReserveInfo.RecSetting.StartMargine*-1);
                        }
                    }

                    DateTime chkStartTime = new DateTime(startTime.Year,
                        startTime.Month,
                        startTime.Day,
                        startTime.Hour,
                        0,
                        0);
                    if (timeList.ContainsKey(chkStartTime) == true)
                    {
                        int index = timeList.IndexOfKey(chkStartTime);
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.MinHeight;
                    }
                }

                double topPos = 0;
                foreach (TimePosInfo time in timeList.Values)
                {
                    time.TopPos = topPos;
                    topPos += 60 * Settings.Instance.MinHeight;
                }

                tunerReserveTimeView.SetTime(timeList, true);
                tunerReserveNameView.SetTunerInfo(tunerList);
                tunerReserveView.SetReserveList(reserveList,
                    leftPos,
                    timeList.Count * 60 * Settings.Instance.MinHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            try
            {
                tunerReserveView.ClearInfo();
                tunerReserveTimeView.ClearInfo();
                tunerReserveNameView.ClearInfo();
                List<DateTime> timeList = new List<DateTime>();
                tunerList.Clear();
                reserveList.Clear();

                List<TunerReserveInfo> tunerReserveList = CommonManager.Instance.DB.TunerReserveList.Values
                    .OrderBy(info => info.tunerID).ToList();//多分大丈夫だけど一応ソートしておく
                if (Settings.Instance.TunerDisplayOffReserve == true)
                {
                    var tuner_off = new TunerReserveInfo();
                    tuner_off.tunerID = 0xFFFFFFFF;//IDの表示判定に使っている
                    tuner_off.tunerName = "無効予約";
                    tuner_off.reserveList = CommonManager.Instance.DB.ReserveList.Values
                        .Where(info => info.RecSetting.RecMode == 5).Select(info => info.ReserveID).ToList();
                    tunerReserveList.Add(tuner_off);
                }

                //チューナ不足と無効予約はアイテムがなければ非表示
                var delList = tunerReserveList.Where(item => item.tunerID == 0xFFFFFFFF && item.reserveList.Count == 0).ToList();
                delList.ForEach(item => tunerReserveList.Remove(item));

                double tunerWidthSingle = Settings.Instance.TunerWidth;
                double leftPos = 0;
                tunerReserveList.ForEach(info =>
                {
                    double tunerWidth = tunerWidthSingle;

                    var tunerAddList = new List<ReserveViewItem>();
                    foreach(UInt32 reserveID in info.reserveList)
                    {
                        ReserveData reserveInfo;
                        if (CommonManager.Instance.DB.ReserveList.TryGetValue(reserveID,out reserveInfo) == false)
                        {
                            continue;
                        }
                        var newItem = new ReserveViewItem(reserveInfo);

                        //マージンを適用
                        DateTime startTime = reserveInfo.StartTime;
                        Int32 duration = (Int32)reserveInfo.DurationSecond;
                        vutil.ApplyMarginForTunerPanelView(reserveInfo, ref startTime, ref duration);

                        newItem.Height = duration * Settings.Instance.TunerMinHeight / 60;
                        newItem.Width = tunerWidthSingle;
                        newItem.LeftPos = leftPos;

                        foreach (ReserveViewItem addedItem in tunerAddList)
                        {
                            ReserveData addedInfo = addedItem.ReserveInfo;

                            //マージンを適用
                            DateTime startTimeAdd = addedInfo.StartTime;
                            Int32 durationAdd = (Int32)addedInfo.DurationSecond;
                            vutil.ApplyMarginForTunerPanelView(addedInfo, ref startTimeAdd, ref durationAdd);

                            if (MenuUtil.CulcOverlapLength(startTime, (UInt32)duration, startTimeAdd, (UInt32)durationAdd) > 0)
                            {
                                if (newItem.LeftPos <= addedItem.LeftPos)
                                {
                                    if (reserveInfo.Create64Key() == addedInfo.Create64Key())
                                    {
                                        newItem.LeftPos = addedItem.LeftPos;
                                    }
                                    else
                                    {
                                        newItem.LeftPos = addedItem.LeftPos + tunerWidthSingle;
                                        if (newItem.LeftPos - leftPos >= tunerWidth)
                                        {
                                            tunerWidth += tunerWidthSingle;
                                        }
                                    }
                                }
                            }
                        }

                        reserveList.Add(newItem);
                        tunerAddList.Add(newItem);

                        //必要時間リストの構築
                        var chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                        DateTime EndTime = startTime.AddSeconds(duration);
                        while (chkStartTime <= EndTime)
                        {
                            int index = timeList.BinarySearch(chkStartTime);
                            if (index < 0)
                            {
                                timeList.Insert(~index, chkStartTime);
                            }
                            chkStartTime = chkStartTime.AddHours(1);
                        }

                    }

                    tunerList.Add(new TunerNameViewItem(info, tunerWidth));
                    leftPos += tunerWidth;
                });

                //表示位置設定
                foreach (ReserveViewItem item in reserveList)
                {
                    //マージンを適用
                    DateTime startTime = item.ReserveInfo.StartTime;
                    Int32 dummy = 0;
                    vutil.ApplyMarginForTunerPanelView(item.ReserveInfo, ref startTime, ref dummy);

                    var chkStartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
                    int index = timeList.BinarySearch(chkStartTime);
                    if (index >= 0)
                    {
                        item.TopPos = (index * 60 + (startTime - chkStartTime).TotalMinutes) * Settings.Instance.TunerMinHeight;
                    }
                }

                //ごく小さいマージンの表示を抑制する。
                reserveList.ForEach(info =>
                {
                    info.TopPos = Math.Round(info.TopPos);
                    info.Height = Math.Round(info.Height);
                });

                //最低表示行数からドット数を計算する。
                // メイリオみたいに行間のあるフォントはフォントの高さをそのまま使う。
                double fontHeight = Math.Max(Settings.Instance.TunerFontHeight, Settings.Instance.TunerFontHeightService);
                // MS P ゴシックみたいな行間のないフォントは 2px あける。
                double fontSize = Math.Max(Settings.Instance.TunerFontSize, Settings.Instance.TunerFontSizeService) + 2;
                // 大きい方をフォントの高さとして採用し、最低表示px数を計算する。
                double lineHeight = Settings.Instance.TunerMinimumLine *  Math.Max(fontHeight, fontSize);
                if (Settings.Instance.TunerMinimumLine >= 2)
                {
                    lineHeight += 2; // 番組名との間隔は 2px にする
                }
                vutil.ModifierMinimumHeight<ReserveData, ReserveViewItem>(reserveList, lineHeight + 2); //2ドットは枠の分

                //必要時間リストの修正。最低表示行数の適用で下に溢れた分を追加する。
                if (reserveList.Count != 0 && timeList.Count > 0)
                {
                    double bottom = reserveList.Max(info => info.TopPos + info.Height);
                    int end = (int)(bottom / (60 * Settings.Instance.TunerMinHeight)) + 1;
                    while (end > timeList.Count)
                    {
                        DateTime time_tail = timeList[timeList.Count - 1].AddHours(1);
                        timeList.Add(time_tail);
                    }
                }

                tunerReserveTimeView.SetTime(timeList, true);
                tunerReserveNameView.SetTunerInfo(tunerList);
                tunerReserveView.SetReserveList(reserveList,
                    leftPos,
                    timeList.Count * 60 * Settings.Instance.TunerMinHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
        /// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            reserveList.Clear();
            foreach (TimePosInfo time in timeList.Values)
            {
                time.ReserveList.Clear();
            }
            try
            {
                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);
                }

                foreach (ReserveData info in CommonManager.Instance.DB.ReserveList.Values)
                {
                    UInt64 key = CommonManager.Create64Key(info.OriginalNetworkID, info.TransportStreamID, info.ServiceID);
                    if (selectID == key)
                    {
                        DateTime chkStartTime;
                        DateTime startTime;
                        if (info.StartTime.Hour < setViewInfo.StartTimeWeek)
                        {
                            chkStartTime = new DateTime(2001, 1, 2, info.StartTime.Hour, 0, 0);
                            startTime = new DateTime(2001, 1, 2, info.StartTime.Hour, info.StartTime.Minute, info.StartTime.Second);
                        }
                        else
                        {
                            chkStartTime = new DateTime(2001, 1, 1, info.StartTime.Hour, 0, 0);
                            startTime = new DateTime(2001, 1, 1, info.StartTime.Hour, info.StartTime.Minute, info.StartTime.Second);
                        }
                        Int32 duration = (Int32)info.DurationSecond;
                        if (info.RecSetting.UseMargineFlag == 1)
                        {
                            if (info.RecSetting.StartMargine < 0)
                            {
                                startTime = startTime.AddSeconds(info.RecSetting.StartMargine * -1);
                                duration += info.RecSetting.StartMargine;
                            }
                            if (info.RecSetting.EndMargine < 0)
                            {
                                duration += info.RecSetting.EndMargine;
                            }
                        }
                        DateTime EndTime;
                        EndTime = startTime.AddSeconds(duration);
                        //if ((duration / 60) < Settings.Instance.MinHeight)
                        //{
                        //    duration = (int)Settings.Instance.MinHeight;
                        //}

                        if (timeList.ContainsKey(chkStartTime) == false)
                        {
                            //時間ないので除外
                            continue;
                        }
                        ReserveViewItem viewItem = new ReserveViewItem(info);
                        //viewItem.LeftPos = i * Settings.Instance.ServiceWidth;

                        viewItem.Height = Math.Floor((duration / 60) * Settings.Instance.MinHeight);
                        if (viewItem.Height == 0)
                        {
                            viewItem.Height = Settings.Instance.MinHeight;
                        }
                        viewItem.Width = Settings.Instance.ServiceWidth;

                        TimePosInfo time = timeList[chkStartTime] as TimePosInfo;
                        int index = timeList.IndexOfKey(chkStartTime);
                        viewItem.TopPos = index * 60 * Settings.Instance.MinHeight;
                        viewItem.TopPos += Math.Floor((startTime - chkStartTime).TotalMinutes * Settings.Instance.MinHeight);

                        DateTime chkDay;
                        if (info.StartTime.Hour < setViewInfo.StartTimeWeek)
                        {
                            chkDay = info.StartTime.AddDays(-1);
                            chkDay = new DateTime(chkDay.Year, chkDay.Month, chkDay.Day, 0, 0, 0);
                        }
                        else
                        {
                            chkDay = new DateTime(info.StartTime.Year, info.StartTime.Month, info.StartTime.Day, 0, 0, 0);
                        }
                        viewItem.LeftPos = Settings.Instance.ServiceWidth * dayList.IndexOfKey(chkDay);


                        //必要時間リストと時間と番組の関連づけ
                        while (chkStartTime <= EndTime)
                        {
                            if (timeList.ContainsKey(chkStartTime) != false)
                            {
                                TimePosInfo timeInfo = timeList[chkStartTime] as TimePosInfo;
                                timeInfo.ReserveList.Add(viewItem);
                            }
                            chkStartTime = chkStartTime.AddHours(1);
                        }
                        reserveList.Add(viewItem);
                    }
                }
                epgProgramView.SetReserveList(reserveList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }