Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- ./EpgTimer.orig/EpgTimer/EpgView/EpgViewPanel.cs 2011-08-01 01:19:34.000000000 +0900
- +++ ./EpgTimer/EpgTimer/EpgView/EpgViewPanel.cs 2013-04-14 03:00:04.058794400 +0900
- @@ -17,7 +17,8 @@
- public static readonly DependencyProperty BackgroundProperty =
- Panel.BackgroundProperty.AddOwner(typeof(EpgViewPanel));
- private List<ProgramViewItem> items;
- - private List<TextDrawItem> textDrawList = new List<TextDrawItem>();
- + //private List<TextDrawItem> textDrawList = new List<TextDrawItem>();
- + private Dictionary<ProgramViewItem, List<TextDrawItem>> textDrawDict = new Dictionary<ProgramViewItem, List<TextDrawItem>>();
- public Brush Background
- {
- set { SetValue(BackgroundProperty, value); }
- @@ -46,9 +47,9 @@
- protected void CreateDrawTextList()
- {
- - textDrawList.Clear();
- - textDrawList = null;
- - textDrawList = new List<TextDrawItem>();
- + textDrawDict.Clear();
- + textDrawDict = null;
- + textDrawDict = new Dictionary<ProgramViewItem, List<TextDrawItem>>();
- Matrix m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
- this.VisualTextRenderingMode = TextRenderingMode.ClearType;
- @@ -134,15 +135,17 @@
- double sizeTitle = Settings.Instance.FontSizeTitle;
- foreach (ProgramViewItem info in Items)
- {
- + List<TextDrawItem> textDrawList = new List<TextDrawItem>();
- if (info.Height > 2)
- {
- + /*
- if (info.Height < 4 + sizeTitle + 2)
- {
- //高さ足りない
- info.TitleDrawErr = true;
- continue;
- }
- -
- + */
- double totalHeight = 0;
- //分
- @@ -159,6 +162,7 @@
- if (RenderText(min, ref textDrawList, glyphTypefaceNormal, sizeNormal, info.Width - 4, info.Height - 4, info.LeftPos, info.TopPos, ref useHeight, CommonManager.Instance.CustTitle1Color, m) == false)
- {
- info.TitleDrawErr = true;
- + textDrawDict[info] = textDrawList;
- continue;
- }
- @@ -172,6 +176,7 @@
- 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)
- {
- info.TitleDrawErr = true;
- + textDrawDict[info] = textDrawList;
- continue;
- }
- totalHeight += Math.Floor(useHeight + (sizeNormal / 2));
- @@ -185,6 +190,7 @@
- {
- 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)
- {
- + textDrawDict[info] = textDrawList;
- continue;
- }
- totalHeight += useHeight + sizeNormal;
- @@ -197,6 +203,7 @@
- {
- 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)
- {
- + textDrawDict[info] = textDrawList;
- continue;
- }
- totalHeight += useHeight;
- @@ -204,6 +211,7 @@
- }
- }
- }
- + textDrawDict[info] = textDrawList;
- }
- }
- catch (Exception ex)
- @@ -214,11 +222,13 @@
- 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)
- {
- + /*
- if (maxHeight < fontSize + 2)
- {
- useHeight = 0;
- return false;
- }
- + */
- double totalHeight = 0;
- string[] lineText = text.Replace("\r", "").Split('\n');
- @@ -234,7 +244,7 @@
- double width = glyphType.AdvanceWidths[glyphIndex] * fontSize;
- if (totalWidth + width > maxWidth)
- {
- - if (totalHeight + fontSize > maxHeight)
- + if (totalHeight > maxHeight)
- {
- //次の行無理
- glyphIndex = glyphType.CharacterToGlyphMap['…'];
- @@ -292,14 +302,15 @@
- textDrawList.Add(item);
- }
- + /*
- //高さ確認
- - if (totalHeight + fontSize > maxHeight)
- + if (totalHeight + fontSize> maxHeight)
- {
- //これ以上は無理
- useHeight = totalHeight;
- return false;
- }
- -
- + */
- }
- useHeight = Math.Floor(totalHeight);
- return true;
- @@ -327,12 +338,17 @@
- if (info.Height > 2)
- {
- dc.DrawRectangle(info.ContentColor, null, new Rect(info.LeftPos + 1, info.TopPos + 1, info.Width - 2, info.Height - 2));
- + if (textDrawDict.ContainsKey(info))
- + {
- + dc.PushClip(new RectangleGeometry(new Rect(info.LeftPos + 1, info.TopPos + 1, info.Width - 2, info.Height - 2)));
- + foreach (TextDrawItem txtinfo in textDrawDict[info])
- + {
- + dc.DrawGlyphRun(txtinfo.FontColor, txtinfo.Text);
- + }
- + dc.Pop();
- + }
- }
- }
- - foreach (TextDrawItem info in textDrawList)
- - {
- - dc.DrawGlyphRun(info.FontColor, info.Text);
- - }
- }
- catch (Exception ex)
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement