Exemplo n.º 1
0
        protected override void CreateDrawTextListMain(List <List <Tuple <Brush, GlyphRun> > > textDrawLists)
        {
            var        ItemFontNormal  = ItemFontCache.ItemFont(Settings.Instance.TunerFontName, false);
            var        ItemFontTitle   = ItemFontCache.ItemFont(Settings.Instance.TunerFontNameService, Settings.Instance.TunerFontBoldService);
            EpgSetting set             = Settings.Instance.EpgSettingList.FirstOrDefault(s => s.ApplyReplacePatternTuner);
            var        DictionaryTitle = set != null?CommonManager.GetReplaceDictionaryTitle(set) : null;

            bool recSettingInfo = PopUpMode == true ? Settings.Instance.TunerPopupRecinfo : false;
            bool noWrap         = PopUpMode == true ? false : Settings.Instance.TunerServiceNoWrap;

            double sizeTitle   = Settings.Instance.TunerFontSizeService;
            double sizeMin     = Math.Max(sizeTitle - 1, Math.Min(sizeTitle, Settings.Instance.TunerFontSize));
            double sizeNormal  = Settings.Instance.TunerFontSize;
            double indentTitle = recSettingInfo ? 0 : sizeMin *CulcRenderWidth("0", ItemFontNormal) * (2 + sizeTitle / sizeMin);

            double indentNormal = Settings.Instance.TunerTitleIndent ? indentTitle : 0;
            Brush  colorNormal  = Settings.BrushCache.CustTunerTextColor;

            //録画中のものを後で描画する
            Items = Items.Cast <TunerReserveViewItem>().OrderBy(info => info.Data.IsOnRec()).ToList();

            foreach (TunerReserveViewItem info in Items)
            {
                var textDrawList = new List <Tuple <Brush, GlyphRun> >();
                textDrawLists.Add(textDrawList);
                Rect   drawRect  = TextRenderRect(info);
                double useHeight = 0;

                //追加情報の表示
                if (recSettingInfo == true)
                {
                    var    resItem = new ReserveItem(info.Data);
                    string text    = info.Status;
                    if (text != "")
                    {
                        useHeight = sizeNormal / 5 + RenderText(textDrawList, text, ItemFontNormal, sizeNormal, drawRect, 0, 0, resItem.StatusColor);
                    }

                    text       = resItem.StartTimeShort;
                    text      += "\r\n" + "優先度 : " + resItem.Priority;
                    text      += "\r\n" + "録画モード : " + resItem.RecMode;
                    useHeight += sizeNormal / 2 + RenderText(textDrawList, text, ItemFontNormal, sizeNormal, drawRect, 0, useHeight, info.ServiceColor);
                }
                else
                {
                    //分のみ
                    RenderText(textDrawList, info.Data.StartTime.ToString("mm"), ItemFontNormal, sizeMin, drawRect, 0, 0, info.ServiceColor);
                }

                //サービス名
                string serviceName = info.Data.StationName + "(" + CommonManager.ConvertNetworkNameText(info.Data.OriginalNetworkID) + ")";
                serviceName = CommonManager.ReplaceText(serviceName, DictionaryTitle);
                useHeight  += sizeTitle / 3 + RenderText(textDrawList, serviceName, ItemFontTitle, sizeTitle, drawRect, indentTitle, useHeight, info.ServiceColor, noWrap);

                //番組名
                if (useHeight < drawRect.Height)
                {
                    string title = CommonManager.ReplaceText(info.Data.Title.TrimEnd(), DictionaryTitle);
                    if (title != "")
                    {
                        useHeight += sizeNormal / 3 + RenderText(textDrawList, title, ItemFontNormal, sizeNormal, drawRect, indentNormal, useHeight, colorNormal);
                    }
                }

                SaveMaxRenderHeight(useHeight);
            }
        }
Exemplo n.º 2
0
        protected override void OnRender(DrawingContext dc)
        {
            dc.DrawRectangle(Background, null, new Rect(RenderSize));

            var ps = PresentationSource.FromVisual(this);

            if (ps == null || Items == null)
            {
                return;
            }
            Matrix m = ps.CompositionTarget.TransformToDevice;

            var itemFontTitle  = new EpgView.EpgViewPanel.ItemFont(Settings.Instance.EpgSettingList[0].FontNameTitle, Settings.Instance.EpgSettingList[0].FontBoldTitle, true);
            var itemFontNormal = new EpgView.EpgViewPanel.ItemFont(Settings.Instance.EpgSettingList[0].FontName, false, true);

            if (itemFontTitle.GlyphType == null || itemFontNormal.GlyphType == null)
            {
                return;
            }

            {
                double          sizeTitle    = Math.Max(Settings.Instance.EpgSettingList[0].FontSizeTitle, 1);
                double          sizeNormal   = Math.Max(Settings.Instance.EpgSettingList[0].FontSize, 1);
                double          indentTitle  = sizeTitle * 1.7;
                double          indentNormal = 2;
                SolidColorBrush colorTitle   = ColorDef.CustColorBrush(Settings.Instance.EpgSettingList[0].TitleColor1,
                                                                       Settings.Instance.EpgSettingList[0].TitleCustColor1);
                SolidColorBrush colorNormal = ColorDef.CustColorBrush(Settings.Instance.EpgSettingList[0].TitleColor2,
                                                                      Settings.Instance.EpgSettingList[0].TitleCustColor2);

                foreach (ReserveViewItem info in Items)
                {
                    var textDrawList = new List <Tuple <Brush, GlyphRun> >();

                    double innerLeft   = info.LeftPos + 1;
                    double innerTop    = info.TopPos + 1;
                    double innerWidth  = info.Width - 2;
                    double innerHeight = info.Height - 2;
                    double useHeight;

                    info.TitleDrawErr = true;

                    //分
                    string min = info.ReserveInfo.StartTime.Minute.ToString("d02");
                    //設計的にやや微妙だがやる事が同じなのでEpgViewPanelのメソッドを流用する
                    if (EpgView.EpgViewPanel.RenderText(min, textDrawList, itemFontTitle, sizeTitle * 0.95,
                                                        innerWidth - 1, innerHeight,
                                                        innerLeft + 1, innerTop, out useHeight, colorTitle, m, 0))
                    {
                        //サービス名
                        string serviceName = info.ReserveInfo.StationName;
                        serviceName += " (" + CommonManager.ConvertNetworkNameText(info.ReserveInfo.OriginalNetworkID) + ")";
                        if (EpgView.EpgViewPanel.RenderText(serviceName, textDrawList, itemFontTitle, sizeTitle,
                                                            innerWidth - sizeTitle * 0.5 - indentTitle, innerHeight,
                                                            innerLeft + indentTitle, innerTop, out useHeight, colorTitle, m, 0))
                        {
                            double renderTextHeight = useHeight + sizeNormal * 0.5;
                            //番組名
                            if (EpgView.EpgViewPanel.RenderText(info.ReserveInfo.Title, textDrawList, itemFontNormal, sizeNormal,
                                                                innerWidth - sizeTitle * 0.5 - indentNormal, innerHeight - renderTextHeight,
                                                                innerLeft + indentNormal, innerTop + renderTextHeight, out useHeight, colorNormal, m, 0))
                            {
                                info.TitleDrawErr = innerHeight < renderTextHeight + useHeight;
                            }
                        }
                    }

                    if (info.Width > 0 && info.Height > 0)
                    {
                        dc.DrawRectangle(Brushes.LightGray, null, new Rect(info.LeftPos, info.TopPos, info.Width, info.Height));
                    }
                    if (innerWidth > 0 && innerHeight > 0)
                    {
                        var textArea = new Rect(innerLeft, innerTop, innerWidth, innerHeight);
                        dc.DrawRectangle(info.ReserveInfo.OverlapMode == 1 ? Brushes.Yellow : Brushes.White, null, textArea);
                        dc.PushClip(new RectangleGeometry(textArea));
                        foreach (Tuple <Brush, GlyphRun> txtinfo in textDrawList)
                        {
                            dc.DrawGlyphRun(txtinfo.Item1, txtinfo.Item2);
                        }
                        dc.Pop();
                    }
                }
            }
        }
Exemplo n.º 3
0
        void toolTipTimer_Tick(object sender, EventArgs e)
        {
            toolTipTimer.Stop();
            try
            {
                if (Settings.Instance.NoToolTip == true)
                {
                    return;
                }
                if (reserveViewPanel.Items != null)
                {
                    if (MainWindow.GetWindow(this).IsActive == false)
                    {
                        return;
                    }
                    Point cursorPos2 = Mouse.GetPosition(scrollViewer);
                    if (cursorPos2.X < 0 || cursorPos2.Y < 0 ||
                        scrollViewer.ViewportWidth < cursorPos2.X || scrollViewer.ViewportHeight < cursorPos2.Y)
                    {
                        return;
                    }
                    Point cursorPos = Mouse.GetPosition(reserveViewPanel);
                    foreach (ReserveViewItem info in reserveViewPanel.Items)
                    {
                        if (info.LeftPos <= cursorPos.X && cursorPos.X < info.LeftPos + info.Width)
                        {
                            if (info.TopPos <= cursorPos.Y && cursorPos.Y < info.TopPos + info.Height)
                            {
                                if (info.TitleDrawErr == true)
                                {
                                    string view = new CommonManager.TimeDuration(true, info.ReserveInfo.StartTime,
                                                                                 true, info.ReserveInfo.DurationSecond) + "\r\n";
                                    view += info.ReserveInfo.StationName;
                                    view += " (" + CommonManager.ConvertNetworkNameText(info.ReserveInfo.OriginalNetworkID) + ")" + "\r\n";

                                    view += info.ReserveInfo.Title;

                                    toolTipTextBlock.Text       = view;
                                    toolTipTextBlock.Background = new SolidColorBrush(Color.FromRgb(
                                                                                          Settings.Instance.EpgSettingList[0].EpgTipsBackColorR,
                                                                                          Settings.Instance.EpgSettingList[0].EpgTipsBackColorG,
                                                                                          Settings.Instance.EpgSettingList[0].EpgTipsBackColorB));
                                    toolTipTextBlock.Foreground = new SolidColorBrush(Color.FromRgb(
                                                                                          Settings.Instance.EpgSettingList[0].EpgTipsForeColorR,
                                                                                          Settings.Instance.EpgSettingList[0].EpgTipsForeColorG,
                                                                                          Settings.Instance.EpgSettingList[0].EpgTipsForeColorB));
                                    toolTip.IsOpen = true;
                                    toolTipOffTimer.Start();

                                    lastPopupInfo = info;
                                    lastPopupPos  = cursorPos;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 4
0
        void toolTipTimer_Tick(object sender, EventArgs e)
        {
            toolTipTimer.Stop();
            try
            {
                if (Settings.Instance.NoToolTip == true)
                {
                    return;
                }
                if (reserveViewPanel.Items != null)
                {
                    if (MainWindow.GetWindow(this).IsActive == false)
                    {
                        return;
                    }
                    Point cursorPos2 = Mouse.GetPosition(scrollViewer);
                    if (cursorPos2.X < 0 || cursorPos2.Y < 0 ||
                        scrollViewer.ViewportWidth < cursorPos2.X || scrollViewer.ViewportHeight < cursorPos2.Y)
                    {
                        return;
                    }
                    Point cursorPos = Mouse.GetPosition(reserveViewPanel);
                    foreach (ReserveViewItem info in reserveViewPanel.Items)
                    {
                        if (info.LeftPos <= cursorPos.X && cursorPos.X < info.LeftPos + info.Width)
                        {
                            if (info.TopPos <= cursorPos.Y && cursorPos.Y < info.TopPos + info.Height)
                            {
                                if (info.TitleDrawErr == true)
                                {
                                    string view = CommonManager.GetTimeDurationText(true, info.ReserveInfo.StartTime,
                                                                                    true, info.ReserveInfo.DurationSecond) + "\r\n";
                                    view += info.ReserveInfo.StationName;
                                    view += " (" + CommonManager.ConvertNetworkNameText(info.ReserveInfo.OriginalNetworkID) + ")" + "\r\n";

                                    view += info.ReserveInfo.Title;

                                    Border border = new Border();
                                    border.Background = Brushes.DarkGray;

                                    TextBlock block = new TextBlock();
                                    block.Text         = view;
                                    block.MaxWidth     = 400;
                                    block.TextWrapping = TextWrapping.Wrap;
                                    block.Margin       = new Thickness(2);

                                    block.Background = Brushes.LightGray;
                                    block.Foreground = Brushes.Black;
                                    border.Child     = block;
                                    toolTip.Child    = border;
                                    toolTip.IsOpen   = true;
                                    toolTipOffTimer.Start();

                                    lastPopupInfo = info;
                                    lastPopupPos  = cursorPos;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Exemplo n.º 5
0
        protected override void OnRender(DrawingContext dc)
        {
            dc.DrawRectangle(Background, null, new Rect(RenderSize));

            if (Items == null)
            {
                return;
            }

            if (ItemFontNormal == null || ItemFontNormal.GlyphType == null ||
                ItemFontTitle == null || ItemFontTitle.GlyphType == null)
            {
                return;
            }

            try
            {
                double sizeMin      = Settings.Instance.TunerFontSize;
                double sizeTitle    = Settings.Instance.TunerFontSizeService;
                double sizeNormal   = Settings.Instance.TunerFontSize;
                double indentTitle  = sizeMin * 1.7;
                double indentNormal = Settings.Instance.TunerTitleIndent ? indentTitle : 2;
                Brush  colorTitle   = CommonManager.Instance.CustTunerServiceColor;
                Brush  colorNormal  = CommonManager.Instance.CustTunerTextColor;

                double heightMin     = Settings.Instance.TunerFontHeight;
                double heightTitle   = Settings.Instance.TunerFontHeightService;
                double heightNormal  = Settings.Instance.TunerFontHeight;
                double height1stLine = Math.Max(heightMin, heightTitle);

                // 起点はベースラインになるので、それぞれのベースラインを計算しておく。
                // 分とサービス名はフォントが異なることができるのでセンタリングして合うように調整しておく。
                // (ベースラインを合わせてみたら XAML と違うので PopupItem の表示との差が大きかった。)
                double baselineMin    = sizeMin * ItemFontNormal.GlyphType.Baseline + (height1stLine - heightMin) / 2;
                double baselineTitle  = sizeTitle * ItemFontTitle.GlyphType.Baseline + (height1stLine - heightTitle) / 2;
                double baselineNormal = sizeNormal * ItemFontNormal.GlyphType.Baseline;

                //録画中のものを後で描画する
                List <ReserveViewItem> postdrawList = Items.Where(info => info.ReserveInfo.IsOnRec()).ToList();
                postdrawList.ForEach(info => Items.Remove(info));
                Items.AddRange(postdrawList);

                foreach (ReserveViewItem info in Items)
                {
                    colorTitle = Settings.Instance.TunerColorModeUse == true ? info.ForeColorPriTuner : colorTitle;

                    double x      = info.LeftPos;
                    double y      = info.TopPos;
                    double height = Math.Max(info.Height, 0) + 1;
                    double width  = info.Width + 1;

                    dc.DrawRectangle(info.BorderBrushTuner, null, new Rect(x, y, width, height));
                    if (height > 2)
                    {
                        // 枠の内側を計算
                        x      += 1;
                        y      += 1;
                        width  -= 2;
                        height -= 2;
                        dc.DrawRectangle(info.BackColorTuner, null, new Rect(x, y, width, height));

                        if (height < height1stLine) // ModifierMinimumHeight してるので足りなくならないハズ。
                        {
                            //高さ足りない
                            info.TitleDrawErr = true;
                            continue;
                        }

                        // margin 設定
                        x     += 2;
                        width -= 6;

                        double useHeight = 0;

                        //分
                        string min = info.ReserveInfo.StartTime.Minute.ToString("d02");
                        if (RenderText(min, dc, ItemFontNormal, colorTitle, sizeMin, width, height, x, y + baselineMin, ref useHeight) == false)
                        {
                            info.TitleDrawErr = true;
                            continue;
                        }

                        //サービス名
                        if (info.ReserveInfo.StationName.Length > 0)
                        {
                            string serviceName = info.ReserveInfo.StationName
                                                 + "(" + CommonManager.ConvertNetworkNameText(info.ReserveInfo.OriginalNetworkID) + ")";
                            if (RenderText(serviceName, dc, ItemFontTitle, colorTitle, sizeTitle, width - indentTitle, height, x + indentTitle, y + baselineTitle, ref useHeight, Settings.Instance.TunerServiceNoWrap) == false)
                            {
                                info.TitleDrawErr = true;
                                continue;
                            }
                            useHeight += 2; // margin: 番組名との間隔は 2px にする
                        }

                        //番組名
                        if (info.ReserveInfo.Title.Length > 0)
                        {
                            if (RenderText(info.ReserveInfo.Title, dc, ItemFontNormal, colorNormal, sizeNormal, width - indentNormal, height - useHeight, x + indentNormal, y + useHeight + baselineNormal, ref useHeight) == false)
                            {
                                info.TitleDrawErr = true;
                                continue;
                            }
                        }
                    }
                }

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