Advertisement
Guest User

Untitled

a guest
Apr 13th, 2013
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- ./EpgTimer.orig/EpgTimer/EpgView/EpgViewPanel.cs    2011-08-01 01:19:34.000000000 +0900
  2. +++ ./EpgTimer/EpgTimer/EpgView/EpgViewPanel.cs 2013-04-14 04:54:24.320794400 +0900
  3. @@ -17,7 +17,8 @@
  4.          public static readonly DependencyProperty BackgroundProperty =
  5.              Panel.BackgroundProperty.AddOwner(typeof(EpgViewPanel));
  6.          private List<ProgramViewItem> items;
  7. -        private List<TextDrawItem> textDrawList = new List<TextDrawItem>();
  8. +        //private List<TextDrawItem> textDrawList = new List<TextDrawItem>();
  9. +        private Dictionary<ProgramViewItem, List<TextDrawItem>> textDrawDict = new Dictionary<ProgramViewItem, List<TextDrawItem>>();
  10.          public Brush Background
  11.          {
  12.              set { SetValue(BackgroundProperty, value); }
  13. @@ -46,9 +47,9 @@
  14.  
  15.          protected void CreateDrawTextList()
  16.          {
  17. -            textDrawList.Clear();
  18. -            textDrawList = null;
  19. -            textDrawList = new List<TextDrawItem>();
  20. +            textDrawDict.Clear();
  21. +            textDrawDict = null;
  22. +            textDrawDict = new Dictionary<ProgramViewItem, List<TextDrawItem>>();
  23.              Matrix m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
  24.  
  25.              this.VisualTextRenderingMode = TextRenderingMode.ClearType;
  26. @@ -134,15 +135,18 @@
  27.                  double sizeTitle = Settings.Instance.FontSizeTitle;
  28.                  foreach (ProgramViewItem info in Items)
  29.                  {
  30. +                    List<TextDrawItem> textDrawList = new List<TextDrawItem>();
  31. +                    textDrawDict[info] = textDrawList;
  32.                      if (info.Height > 2)
  33.                      {
  34. +                        /*
  35.                          if (info.Height < 4 + sizeTitle + 2)
  36.                          {
  37.                              //高さ足りない
  38.                              info.TitleDrawErr = true;
  39.                              continue;
  40.                          }
  41. -
  42. +                        */
  43.                          double totalHeight = 0;
  44.  
  45.                          //分
  46. @@ -214,11 +218,13 @@
  47.  
  48.          protected bool RenderText(String text, ref List<TextDrawItem> textDrawList, GlyphTypeface glyphType, double fontSize, double maxWidth, double maxHeight, double x, double y, ref double useHeight, SolidColorBrush fontColor, Matrix m)
  49.          {
  50. +            /*
  51.              if (maxHeight < fontSize + 2)
  52.              {
  53.                  useHeight = 0;
  54.                  return false;
  55.              }
  56. +             */
  57.              double totalHeight = 0;
  58.  
  59.              string[] lineText = text.Replace("\r", "").Split('\n');
  60. @@ -234,7 +240,7 @@
  61.                      double width = glyphType.AdvanceWidths[glyphIndex] * fontSize;
  62.                      if (totalWidth + width > maxWidth)
  63.                      {
  64. -                        if (totalHeight + fontSize > maxHeight)
  65. +                        if (totalHeight > maxHeight)
  66.                          {
  67.                              //次の行無理
  68.                              glyphIndex = glyphType.CharacterToGlyphMap['…'];
  69. @@ -292,14 +298,15 @@
  70.                      textDrawList.Add(item);
  71.  
  72.                  }
  73. +                /*
  74.                  //高さ確認
  75. -                if (totalHeight + fontSize > maxHeight)
  76. +                if (totalHeight + fontSize> maxHeight)
  77.                  {
  78.                      //これ以上は無理
  79.                      useHeight = totalHeight;
  80.                      return false;
  81.                  }
  82. -
  83. +                */
  84.              }
  85.              useHeight = Math.Floor(totalHeight);
  86.              return true;
  87. @@ -327,12 +334,17 @@
  88.                      if (info.Height > 2)
  89.                      {
  90.                          dc.DrawRectangle(info.ContentColor, null, new Rect(info.LeftPos + 1, info.TopPos + 1, info.Width - 2, info.Height - 2));
  91. +                        if (textDrawDict.ContainsKey(info))
  92. +                        {
  93. +                            dc.PushClip(new RectangleGeometry(new Rect(info.LeftPos + 1, info.TopPos + 1, info.Width - 2, info.Height - 2)));
  94. +                            foreach (TextDrawItem txtinfo in textDrawDict[info])
  95. +                            {
  96. +                                dc.DrawGlyphRun(txtinfo.FontColor, txtinfo.Text);
  97. +                            }
  98. +                            dc.Pop();
  99. +                        }
  100.                      }
  101.                  }
  102. -                foreach (TextDrawItem info in textDrawList)
  103. -                {
  104. -                    dc.DrawGlyphRun(info.FontColor, info.Text);
  105. -                }
  106.              }
  107.              catch (Exception ex)
  108.              {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement