Ejemplo 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());
     }
 }
Ejemplo n.º 2
0
        public void SetDay(List <DateTime> dayList, double serviceWidth, bool gradationHeader)
        {
            stackPanel_day.Children.Clear();
            if (serviceWidth > 2)
            {
                foreach (DateTime time in dayList)
                {
                    TextBlock item = new TextBlock();

                    item.Width = serviceWidth - 2;
                    item.Text  = time.ToString("M\\/d\r\n(ddd)");

                    Color backgroundColor;
                    if (time.DayOfWeek == DayOfWeek.Saturday)
                    {
                        item.Foreground = Brushes.DarkBlue;
                        backgroundColor = Colors.Lavender;
                    }
                    else if (time.DayOfWeek == DayOfWeek.Sunday)
                    {
                        item.Foreground = Brushes.DarkRed;
                        backgroundColor = Colors.MistyRose;
                    }
                    else
                    {
                        item.Foreground = Brushes.Black;
                        backgroundColor = Colors.White;
                    }
                    var gridItem = new System.Windows.Controls.Primitives.UniformGrid();
                    if (gradationHeader == false)
                    {
                        gridItem.Background = new SolidColorBrush(backgroundColor);
                        gridItem.Background.Freeze();
                    }
                    else
                    {
                        gridItem.Background = ColorDef.GradientBrush(backgroundColor, 0.8);
                    }

                    gridItem.Margin    = new Thickness(1, 1, 1, 1);
                    item.TextAlignment = TextAlignment.Center;
                    item.FontSize      = 12;
                    item.FontWeight    = FontWeights.Bold;
                    // 単にCenterだとやや重い感じになるので上げる
                    item.Padding           = new Thickness(0, 0, 0, 4);
                    item.VerticalAlignment = VerticalAlignment.Center;
                    gridItem.Children.Add(item);
                    stackPanel_day.Children.Add(gridItem);
                }
            }
        }
Ejemplo n.º 3
0
        public void SetDay(System.Collections.SortedList dayList)
        {
            try
            {
                stackPanel_day.Children.Clear();
                foreach (DateTime time in dayList.Values)
                {
                    TextBlock item = new TextBlock();

                    item.Width = Settings.Instance.ServiceWidth - 2;
                    item.Text  = time.ToString("M/d\r\n(ddd)");


                    Color backgroundColor;
                    if (time.DayOfWeek == DayOfWeek.Saturday)
                    {
                        item.Foreground = Brushes.DarkBlue;
                        backgroundColor = Colors.Lavender;
                    }
                    else if (time.DayOfWeek == DayOfWeek.Sunday)
                    {
                        item.Foreground = Brushes.DarkRed;
                        backgroundColor = Colors.MistyRose;
                    }
                    else
                    {
                        item.Foreground = Brushes.Black;
                        backgroundColor = Colors.White;
                    }
                    if (Settings.Instance.EpgGradationHeader == false)
                    {
                        item.Background = new SolidColorBrush(backgroundColor);
                    }
                    else
                    {
                        item.Background = ColorDef.GradientBrush(backgroundColor, 0.8);
                    }

                    item.Padding       = new Thickness(0, 0, 0, 2);
                    item.Margin        = new Thickness(1, 1, 1, 1);
                    item.TextAlignment = TextAlignment.Center;
                    item.FontSize      = 12;
                    item.FontWeight    = FontWeights.Bold;
                    stackPanel_day.Children.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
        public void SetDay(List <DateTime> dayList)
        {
            {
                stackPanel_day.Children.Clear();
                foreach (DateTime time in dayList)
                {
                    TextBlock item = ViewUtil.GetPanelTextBlock(time.ToString("M/d\r\n(ddd)"));
                    item.Tag   = time;
                    item.Width = this.EpgStyle().ServiceWidth - 1;

                    Color backgroundColor;
                    if (time.DayOfWeek == DayOfWeek.Saturday)
                    {
                        item.Foreground = Brushes.DarkBlue;
                        backgroundColor = Colors.Lavender;
                    }
                    else if (time.DayOfWeek == DayOfWeek.Sunday)
                    {
                        item.Foreground = Brushes.DarkRed;
                        backgroundColor = Colors.MistyRose;
                    }
                    else
                    {
                        item.Foreground = Brushes.Black;
                        backgroundColor = Colors.White;
                    }
                    item.Padding           = new Thickness(0, 0, 0, 2);
                    item.VerticalAlignment = VerticalAlignment.Center;
                    item.FontWeight        = FontWeights.Bold;

                    var grid = new UniformGrid();
                    grid.Background = this.EpgStyle().EpgGradationHeader ? (Brush)ColorDef.GradientBrush(backgroundColor, 0.8, 1.2) : new SolidColorBrush(backgroundColor);
                    grid.Background.Freeze();
                    grid.Margin = new Thickness(0, 1, 1, 1);
                    grid.Tag    = time;
                    grid.Children.Add(item);
                    stackPanel_day.Children.Add(grid);
                }
                rect_day.Width = this.EpgStyle().ServiceWidth - 1;
                SetTodayMark();
            }
        }
Ejemplo n.º 5
0
        public void SetDay(SortedList <DateTime, DateTime> dayList)
        {
            try
            {
                stackPanel_day.Children.Clear();
                foreach (DateTime time in dayList.Values)
                {
                    TextBlock item = new TextBlock();

                    item.Width = Settings.Instance.ServiceWidth - 2;
                    item.Text  = time.ToString("M月d日\r\n(ddd)");


                    if (time.DayOfWeek == DayOfWeek.Saturday)
                    {
                        item.Foreground = Brushes.DarkBlue;
                        item.Background = ColorDef.GradientBrush(Colors.Lavender, 0.8);
                    }
                    else if (time.DayOfWeek == DayOfWeek.Sunday)
                    {
                        item.Foreground = Brushes.DarkRed;
                        item.Background = ColorDef.GradientBrush(Colors.MistyRose, 0.8);
                    }
                    else
                    {
                        item.Foreground = Brushes.Black;
                        item.Background = ColorDef.GradientBrush(Colors.White, 0.8);
                    }

                    item.Margin        = new Thickness(1, 1, 1, 1);
                    item.TextAlignment = TextAlignment.Center;
                    item.FontSize      = 12;
                    item.FontWeight    = FontWeights.Bold;
                    stackPanel_day.Children.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Ejemplo n.º 6
0
        public void SetDay(List <DateTime> dayList)
        {
            try
            {
                stackPanel_day.Children.Clear();
                foreach (DateTime time in dayList)
                {
                    var item = ViewUtil.GetPanelTextBlock(time.ToString("M/d\r\n(ddd)"));
                    item.Width = Settings.Instance.ServiceWidth - 1;

                    Color backgroundColor;
                    if (time.DayOfWeek == DayOfWeek.Saturday)
                    {
                        item.Foreground = Brushes.DarkBlue;
                        backgroundColor = Colors.Lavender;
                    }
                    else if (time.DayOfWeek == DayOfWeek.Sunday)
                    {
                        item.Foreground = Brushes.DarkRed;
                        backgroundColor = Colors.MistyRose;
                    }
                    else
                    {
                        item.Foreground = Brushes.Black;
                        backgroundColor = Colors.White;
                    }
                    item.Background = Settings.Instance.EpgGradationHeader ? (Brush)ColorDef.GradientBrush(backgroundColor, 0.8, 1.2) : new SolidColorBrush(backgroundColor);

                    item.Padding    = new Thickness(0, 0, 0, 2);
                    item.Margin     = new Thickness(0, 1, 1, 1);
                    item.FontWeight = FontWeights.Bold;
                    stackPanel_day.Children.Add(item);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }