Advertisement
Guest User

Untitled

a guest
Apr 13th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.21 KB | None | 0 0
  1. --- ./EpgTimer.orig/EpgTimer/EpgView/EpgViewPanel.cs    2011-08-01 01:19:34.000000000 +0900
  2. +++ ./EpgTimer/EpgTimer/EpgView/EpgViewPanel.cs 2013-04-14 03:00:04.058794400 +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,17 @@
  27.                  double sizeTitle = Settings.Instance.FontSizeTitle;
  28.                  foreach (ProgramViewItem info in Items)
  29.                  {
  30. +                    List<TextDrawItem> textDrawList = new List<TextDrawItem>();
  31.                      if (info.Height > 2)
  32.                      {
  33. +                        /*
  34.                          if (info.Height < 4 + sizeTitle + 2)
  35.                          {
  36.                              //高さ足りない
  37.                              info.TitleDrawErr = true;
  38.                              continue;
  39.                          }
  40. -
  41. +                        */
  42.                          double totalHeight = 0;
  43.  
  44.                          //分
  45. @@ -159,6 +162,7 @@
  46.                          if (RenderText(min, ref textDrawList, glyphTypefaceNormal, sizeNormal, info.Width - 4, info.Height - 4, info.LeftPos, info.TopPos, ref useHeight, CommonManager.Instance.CustTitle1Color, m) == false)
  47.                          {
  48.                              info.TitleDrawErr = true;
  49. +                            textDrawDict[info] = textDrawList;
  50.                              continue;
  51.                          }
  52.  
  53. @@ -172,6 +176,7 @@
  54.                                  if (RenderText(info.EventInfo.ShortInfo.event_name, ref textDrawList, glyphTypefaceTitle, sizeTitle, info.Width - 6 - widthOffset, info.Height - 6 - totalHeight, info.LeftPos + widthOffset, info.TopPos + totalHeight, ref useHeight, CommonManager.Instance.CustTitle1Color, m) == false)
  55.                                  {
  56.                                      info.TitleDrawErr = true;
  57. +                                    textDrawDict[info] = textDrawList;
  58.                                      continue;
  59.                                  }
  60.                                  totalHeight += Math.Floor(useHeight + (sizeNormal / 2));
  61. @@ -185,6 +190,7 @@
  62.                              {
  63.                                  if (RenderText(info.EventInfo.ShortInfo.text_char, ref textDrawList, glyphTypefaceNormal, sizeNormal, info.Width - 6 - widthOffset, info.Height - 6 - totalHeight, info.LeftPos + widthOffset, info.TopPos + totalHeight, ref useHeight, CommonManager.Instance.CustTitle2Color, m) == false)
  64.                                  {
  65. +                                    textDrawDict[info] = textDrawList;
  66.                                      continue;
  67.                                  }
  68.                                  totalHeight += useHeight + sizeNormal;
  69. @@ -197,6 +203,7 @@
  70.                                  {
  71.                                      if (RenderText(info.EventInfo.ExtInfo.text_char, ref textDrawList, glyphTypefaceNormal, sizeNormal, info.Width - 6 - widthOffset, info.Height - 6 - totalHeight, info.LeftPos + widthOffset, info.TopPos + totalHeight, ref useHeight, CommonManager.Instance.CustTitle2Color, m) == false)
  72.                                      {
  73. +                                        textDrawDict[info] = textDrawList;
  74.                                          continue;
  75.                                      }
  76.                                      totalHeight += useHeight;
  77. @@ -204,6 +211,7 @@
  78.                              }
  79.                          }
  80.                      }
  81. +                    textDrawDict[info] = textDrawList;
  82.                  }
  83.              }
  84.              catch (Exception ex)
  85. @@ -214,11 +222,13 @@
  86.  
  87.          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)
  88.          {
  89. +            /*
  90.              if (maxHeight < fontSize + 2)
  91.              {
  92.                  useHeight = 0;
  93.                  return false;
  94.              }
  95. +             */
  96.              double totalHeight = 0;
  97.  
  98.              string[] lineText = text.Replace("\r", "").Split('\n');
  99. @@ -234,7 +244,7 @@
  100.                      double width = glyphType.AdvanceWidths[glyphIndex] * fontSize;
  101.                      if (totalWidth + width > maxWidth)
  102.                      {
  103. -                        if (totalHeight + fontSize > maxHeight)
  104. +                        if (totalHeight > maxHeight)
  105.                          {
  106.                              //次の行無理
  107.                              glyphIndex = glyphType.CharacterToGlyphMap['…'];
  108. @@ -292,14 +302,15 @@
  109.                      textDrawList.Add(item);
  110.  
  111.                  }
  112. +                /*
  113.                  //高さ確認
  114. -                if (totalHeight + fontSize > maxHeight)
  115. +                if (totalHeight + fontSize> maxHeight)
  116.                  {
  117.                      //これ以上は無理
  118.                      useHeight = totalHeight;
  119.                      return false;
  120.                  }
  121. -
  122. +                */
  123.              }
  124.              useHeight = Math.Floor(totalHeight);
  125.              return true;
  126. @@ -327,12 +338,17 @@
  127.                      if (info.Height > 2)
  128.                      {
  129.                          dc.DrawRectangle(info.ContentColor, null, new Rect(info.LeftPos + 1, info.TopPos + 1, info.Width - 2, info.Height - 2));
  130. +                        if (textDrawDict.ContainsKey(info))
  131. +                        {
  132. +                            dc.PushClip(new RectangleGeometry(new Rect(info.LeftPos + 1, info.TopPos + 1, info.Width - 2, info.Height - 2)));
  133. +                            foreach (TextDrawItem txtinfo in textDrawDict[info])
  134. +                            {
  135. +                                dc.DrawGlyphRun(txtinfo.FontColor, txtinfo.Text);
  136. +                            }
  137. +                            dc.Pop();
  138. +                        }
  139.                      }
  140.                  }
  141. -                foreach (TextDrawItem info in textDrawList)
  142. -                {
  143. -                    dc.DrawGlyphRun(info.FontColor, info.Text);
  144. -                }
  145.              }
  146.              catch (Exception ex)
  147.              {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement