예제 #1
0
        public void SetReserveList(List <ReserveViewItem> reserveList)
        {
            try
            {
                for (int i = 0; i < canvas.Children.Count; i++)
                {
                    if (canvas.Children[i] is Rectangle)
                    {
                        canvas.Children.RemoveAt(i--);
                    }
                }

                //0→50で塗りつぶしの不透明度が上がる
                int fillOpacity = Math.Min(EpgSetting.ReserveRectFillOpacity, 50) * 2;
                //50→100で枠の不透明度が下がる
                int strokeOpacity = Math.Min(100 - EpgSetting.ReserveRectFillOpacity, 50) * 2;
                //予約枠が色名指定のときは少し透過(0xA0)する
                Brush strokeNormal  = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorNormal, EpgSetting.ContentCustColorList[17], 0xA0, strokeOpacity);
                Brush strokeNo      = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorNo, EpgSetting.ContentCustColorList[18], 0xA0, strokeOpacity);
                Brush strokeNoTuner = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorNoTuner, EpgSetting.ContentCustColorList[19], 0xA0, strokeOpacity);
                Brush strokeWarning = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorWarning, EpgSetting.ContentCustColorList[20], 0xA0, strokeOpacity);
                Brush fillNormal    = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorNormal, EpgSetting.ContentCustColorList[17], 0xA0, fillOpacity);
                Brush fillNo        = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorNo, EpgSetting.ContentCustColorList[18], 0xA0, fillOpacity);
                Brush fillNoTuner   = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorNoTuner, EpgSetting.ContentCustColorList[19], 0xA0, fillOpacity);
                Brush fillWarning   = ColorDef.CustColorBrush(EpgSetting.ReserveRectColorWarning, EpgSetting.ContentCustColorList[20], 0xA0, fillOpacity);
                var   blurEffect    = new System.Windows.Media.Effects.DropShadowEffect()
                {
                    BlurRadius = 10
                };
                blurEffect.Freeze();
                var dashArray = new DoubleCollection()
                {
                    2.5, 1.5
                };
                dashArray.Freeze();

                foreach (ReserveViewItem info in reserveList)
                {
                    Rectangle rect         = new Rectangle();
                    Rectangle fillOnlyRect = EpgSetting.ReserveRectFillWithShadow ? null : new Rectangle();
                    Rectangle fillRect     = fillOnlyRect ?? rect;

                    if (info.ReserveInfo.RecSetting.IsNoRec())
                    {
                        rect.Stroke   = strokeNo;
                        fillRect.Fill = fillNo;
                    }
                    else if (info.ReserveInfo.OverlapMode == 2)
                    {
                        rect.Stroke   = strokeNoTuner;
                        fillRect.Fill = fillNoTuner;
                    }
                    else if (info.ReserveInfo.OverlapMode == 1)
                    {
                        rect.Stroke   = strokeWarning;
                        fillRect.Fill = fillWarning;
                    }
                    else
                    {
                        rect.Stroke   = strokeNormal;
                        fillRect.Fill = fillNormal;
                    }

                    rect.Effect          = blurEffect;
                    rect.StrokeThickness = 3;
                    if (info.ReserveInfo.RecSetting.GetRecMode() == 4)
                    {
                        rect.StrokeDashArray = dashArray;
                        rect.StrokeDashCap   = PenLineCap.Round;
                    }
                    rect.Width                = info.Width;
                    rect.Height               = info.Height;
                    rect.IsHitTestVisible     = false;
                    fillRect.Width            = info.Width;
                    fillRect.Height           = info.Height;
                    fillRect.IsHitTestVisible = false;

                    Canvas.SetLeft(rect, info.LeftPos);
                    Canvas.SetTop(rect, info.TopPos);
                    Canvas.SetZIndex(rect, 10);
                    canvas.Children.Add(rect);

                    if (fillOnlyRect != null)
                    {
                        Canvas.SetLeft(fillOnlyRect, info.LeftPos);
                        Canvas.SetTop(fillOnlyRect, info.TopPos);
                        Canvas.SetZIndex(fillOnlyRect, 9);
                        canvas.Children.Add(fillOnlyRect);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }