/// <summary>
        /// 予約情報の再描画
        /// </summary>
        private void ReloadReserveViewItem()
        {
            try
            {
                tunerReserveView.ClearInfo();
                tunerReserveTimeView.ClearInfo();
                tunerReserveNameView.ClearInfo();
                reserveList.Clear();

                var tunerList = new List <PanelItem <TunerReserveInfo> >();
                var timeSet   = new HashSet <DateTime>();

                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);
                }

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

                double singleWidth = Settings.Instance.TunerWidth;
                double leftPos     = 0;
                var    resDic      = CommonManager.Instance.DB.ReserveList;
                tunerReserveList.ForEach(info =>
                {
                    var cols = new List <List <ReserveViewItem> >();
                    foreach (ReserveData resInfo in info.reserveList.Where(id => resDic.ContainsKey(id) == true).Select(id => resDic[id]).OrderBy(res => res.Create64Key()))//.ThenBy(res => res.StartTimeActual))
                    {
                        var newItem = new TunerReserveViewItem(resInfo)
                        {
                            Width = singleWidth
                        };
                        reserveList.Add(newItem);

                        //横位置の設定・列を拡げて表示する処置
                        var addCol = cols.FindIndex(col => col.All(item =>
                                                                   MenuUtil.CulcOverlapLength(resInfo.StartTime, resInfo.DurationSecond, item.Data.StartTime, item.Data.DurationSecond) <= 0));
                        if (addCol < 0)
                        {
                            addCol = cols.Count;
                            cols.Add(new List <ReserveViewItem>());
                        }
                        cols[addCol].Add(newItem);
                        newItem.LeftPos = leftPos + addCol * singleWidth;

                        //マージン込みの時間でリストを構築
                        ViewUtil.AddTimeList(timeSet, resInfo.StartTimeActual, resInfo.DurationActual);
                    }
                    double tunerWidth = singleWidth * Math.Max(1, cols.Count);
                    tunerList.Add(new PanelItem <TunerReserveInfo>(info)
                    {
                        Width = tunerWidth
                    });
                    leftPos += tunerWidth;
                });

                //縦位置の設定
                var timeList = new List <DateTime>(timeSet.OrderBy(time => time));

                reserveList.ForEach(item =>
                {
                    ViewUtil.SetItemVerticalPos(timeList, item, item.Data.StartTimeActual, item.Data.DurationActual, Settings.Instance.TunerMinHeight, true);

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

                //最低表示行数を適用。また、最低表示高さを確保して、位置も調整する。
                ViewUtil.ModifierMinimumLine(reserveList, Settings.Instance.TunerMinimumLine, Settings.Instance.TunerFontSizeService, Settings.Instance.TunerBorderTopSize);

                //必要時間リストの修正。最低表示行数の適用で下に溢れた分を追加する。
                ViewUtil.AdjustTimeList(reserveList, timeList, Settings.Instance.TunerMinHeight);

                tunerReserveTimeView.SetTime(timeList, false, 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()
        {
            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); }
        }
示例#3
0
 public TunerNameViewItem(TunerReserveInfo info, double width)
 {
     TunerInfo = info;
     Width     = width;
 }
示例#4
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);
            }
        }
示例#5
0
 public TunerNameViewItem(TunerReserveInfo info, double width)
 {
     TunerInfo = info;
     Width = width;
 }
        /// <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);
            }
        }