Esempio n. 1
0
 public void SetProgramList(List <Tuple <double, List <ProgramViewItem> > > programGroupList, double height)
 {
     try
     {
         for (int i = 0; i < canvas.Children.Count; i++)
         {
             if (canvas.Children[i] is EpgViewPanel)
             {
                 canvas.Children.RemoveAt(i--);
             }
         }
         var itemFontNormal = new EpgViewPanel.ItemFont(EpgSetting.FontName, false, false);
         var itemFontTitle  = new EpgViewPanel.ItemFont(EpgSetting.FontNameTitle, EpgSetting.FontBoldTitle, false);
         var background     = new SolidColorBrush(Color.FromRgb(EpgSetting.EpgBackColorR, EpgSetting.EpgBackColorG, EpgSetting.EpgBackColorB));
         //フリーズしないとかなり重い
         background.Freeze();
         var   dictTitle   = CommonManager.CreateReplaceDictionary(EpgSetting.EpgReplacePatternTitle);
         var   dicNormal   = CommonManager.CreateReplaceDictionary(EpgSetting.EpgReplacePattern);
         Brush brushTitle  = ColorDef.CustColorBrush(EpgSetting.TitleColor1, EpgSetting.TitleCustColor1);
         Brush brushNormal = ColorDef.CustColorBrush(EpgSetting.TitleColor2, EpgSetting.TitleCustColor2);
         //ジャンル別の背景ブラシ
         var contentBrushList = new List <Brush>();
         for (int i = 0; i < EpgSetting.ContentColorList.Count; i++)
         {
             SolidColorBrush brush = ColorDef.CustColorBrush(EpgSetting.ContentColorList[i], EpgSetting.ContentCustColorList[i]);
             contentBrushList.Add(EpgSetting.EpgGradation ? (Brush)ColorDef.GradientBrush(brush.Color) : brush);
         }
         double totalWidth = 0;
         foreach (var programList in programGroupList)
         {
             EpgViewPanel item = new EpgViewPanel();
             item.Background = background;
             item.Height     = Math.Ceiling(height);
             item.Width      = programList.Item1;
             Canvas.SetLeft(item, totalWidth);
             item.Initialize(programList.Item2, EpgSetting.EpgBorderLeftSize, EpgSetting.EpgBorderTopSize,
                             false, EpgSetting.EpgTitleIndent, EpgSetting.EpgExtInfoTable,
                             dictTitle, dicNormal, itemFontTitle, itemFontNormal,
                             EpgSetting.FontSizeTitle, EpgSetting.FontSize, brushTitle, brushNormal,
                             EpgSetting.EpgBackColorA, contentBrushList);
             item.InvalidateVisual();
             canvas.Children.Add(item);
             totalWidth += programList.Item1;
         }
         //包含するCanvasにも直接適用する(Bindingは遅延するため)。GridやStackPanelで包含してもよいはずだが
         //非表示中にここを通るとなぜか包含側のActualHeight(Width)が正しく更新されず、結果スクロール不能になる
         canvasContainer.Height = canvas.Height = Math.Ceiling(height);
         canvasContainer.Width  = canvas.Width = totalWidth;
         itemFontNormal.ClearCache();
         itemFontTitle.ClearCache();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Esempio n. 2
0
 public void SetProgramList(List <Tuple <double, List <ProgramViewItem> > > programGroupList, double height)
 {
     try
     {
         for (int i = 0; i < canvas.Children.Count; i++)
         {
             if (canvas.Children[i] is EpgViewPanel)
             {
                 canvas.Children.RemoveAt(i--);
             }
         }
         var itemFontNormal = new EpgViewPanel.ItemFont(Settings.Instance.FontName, false, false);
         var itemFontTitle  = new EpgViewPanel.ItemFont(Settings.Instance.FontNameTitle, Settings.Instance.FontBoldTitle, false);
         epgViewPanel.Background = CommonManager.Instance.EpgBackColor;
         epgViewPanel.ReplaceDictionaryNormal = CommonManager.CreateReplaceDictionary(Settings.Instance.EpgReplacePattern);
         epgViewPanel.ReplaceDictionaryTitle  = CommonManager.CreateReplaceDictionary(Settings.Instance.EpgReplacePatternTitle);
         double totalWidth = 0;
         foreach (var programList in programGroupList)
         {
             EpgViewPanel item = new EpgViewPanel();
             item.Background              = epgViewPanel.Background;
             item.Height                  = Math.Ceiling(height);
             item.Width                   = programList.Item1;
             item.BorderLeftSize          = Settings.Instance.EpgBorderLeftSize;
             item.BorderTopSize           = Settings.Instance.EpgBorderTopSize;
             item.IsTitleIndent           = Settings.Instance.EpgTitleIndent;
             item.ReplaceDictionaryNormal = epgViewPanel.ReplaceDictionaryNormal;
             item.ReplaceDictionaryTitle  = epgViewPanel.ReplaceDictionaryTitle;
             item.ItemFontNormal          = itemFontNormal;
             item.ItemFontTitle           = itemFontTitle;
             Canvas.SetLeft(item, totalWidth);
             item.Items = programList.Item2;
             item.InvalidateVisual();
             canvas.Children.Add(item);
             totalWidth += programList.Item1;
         }
         canvas.Height = Math.Ceiling(height);
         canvas.Width  = totalWidth;
         itemFontNormal.ClearCache();
         itemFontTitle.ClearCache();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
     }
 }